OPENLINE_WINDOW) return false; $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; $want = hash_hmac('sha256', $slug . '|' . $path . '|' . $ts . '|' . $p[3], $token); if (!hash_equals($want, $p[4])) return false; $key = 'openline_n_' . substr(hash('sha256', $p[3]), 0, 32); if (get_transient($key)) return false; // replayed set_transient($key, 1, 2 * OPENLINE_WINDOW); return true; } add_action('init', function () { if (is_admin() || (defined('DOING_CRON') && DOING_CRON)) return; $slug = get_option('openline_slug'); $token = get_option('openline_token'); if (!$slug || !$token) return; $path = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/'; if (strpos($path, '/.well-known/') === 0 || $path === '/robots.txt') return; if (openline_is_paid($slug, $token)) return; $ua = isset($_SERVER['HTTP_USER_AGENT']) ? $_SERVER['HTTP_USER_AGENT'] : ''; if (!openline_is_ai_bot($ua)) return; $line = get_option('openline_line') ?: ($slug . '@bitcoinisbsv.com'); $price = intval(get_option('openline_price')) ?: null; status_header(402); header('Content-Type: application/json; charset=utf-8'); header('Cache-Control: no-store'); header('Link: <' . OPENLINE_PAY_HOST . '/api/pages/site/' . rawurlencode($_SERVER['HTTP_HOST']) . '>; rel="payment"'); header('X-OpenLine-Line: ' . $line); echo wp_json_encode(array( 'error' => 'payment_required', 'message' => 'This site sells its pages to AI agents' . ($price ? ' at ' . $price . ' sats a page' : '') . ' through Open Line. Pay per page; unused money comes back.', 'protocol' => 'openline-pages/1', 'line' => $line, 'price_sats_per_page' => $price, 'site' => $_SERVER['HTTP_HOST'], 'pay_via' => OPENLINE_PAY_HOST . '/pages', 'agent' => OPENLINE_PAY_HOST . '/agent.js', 'well_known' => '/.well-known/openline-pages.txt', )); exit; }, 0); add_action('admin_menu', function () { add_options_page('Open Line', 'Open Line', 'manage_options', 'openline-pages', 'openline_settings_page'); }); add_action('admin_init', function () { foreach (array('openline_slug', 'openline_token', 'openline_line', 'openline_price', 'openline_charge_all') as $k) register_setting('openline', $k, array('sanitize_callback' => 'sanitize_text_field')); }); function openline_settings_page() { ?>
Get paid when AI reads your site. Copy these from the /.well-known/openline-pages.txt file you got when you registered at call.bitcoinisbsv.com/pages.
People and search engines are never affected. Only known AI crawlers without a valid Open Line payment get 402 Payment Required.