44 lines
1.4 KiB
PHP
44 lines
1.4 KiB
PHP
<?php
|
|
|
|
// Invoked by run.php in a fresh PHP CGI process for each request.
|
|
if (getenv('SEBSTR_KDP_TEST_URL') === false || PHP_SAPI !== 'cgi-fcgi') {
|
|
exit;
|
|
}
|
|
|
|
define('YOURLS_ABSPATH', dirname(__DIR__, 4) . '/');
|
|
require YOURLS_ABSPATH . 'includes/functions-plugins.php';
|
|
require YOURLS_ABSPATH . 'includes/functions.php';
|
|
|
|
function yourls_get_option($name, $default = false)
|
|
{
|
|
return $name === 'sebstr_amazon_kdp_asins' ? ['TESTBOOK01' => 'Standard', '1234567890' => 'Left-handed'] : $default;
|
|
}
|
|
|
|
$clicks = $logs = 0;
|
|
yourls_add_filter('shunt_update_clicks', static function () use (&$clicks) {
|
|
++$clicks;
|
|
return true;
|
|
});
|
|
yourls_add_filter('shunt_log_redirect', static function () use (&$logs) {
|
|
++$logs;
|
|
return true;
|
|
});
|
|
yourls_add_filter('shunt_robots_tag_header', static fn () => true);
|
|
register_shutdown_function(static function () use (&$clicks, &$logs) {
|
|
echo "clicks=$clicks logs=$logs";
|
|
});
|
|
|
|
if (getenv('SEBSTR_KDP_TEST_KDP') === '1') {
|
|
require dirname(__DIR__) . '/plugin.php';
|
|
}
|
|
if (getenv('SEBSTR_KDP_TEST_SELLER') === '1') {
|
|
require dirname(__DIR__, 2) . '/sebstr_amazon/plugin.php';
|
|
}
|
|
|
|
$_SERVER['REMOTE_ADDR'] = getenv('SEBSTR_KDP_TEST_PEER');
|
|
$country = getenv('SEBSTR_KDP_TEST_COUNTRY');
|
|
if ($country !== '') {
|
|
$_SERVER['HTTP_CF_IPCOUNTRY'] = $country;
|
|
}
|
|
yourls_redirect_shorturl(getenv('SEBSTR_KDP_TEST_URL'), 'existing-keyword');
|