# Copyright 2012 AX Gold Software Limited, All Rights Reserved
function SplitTestPxPluginAdmin ()
{
if (! is_admin()) return;
global $splittestpx_domaincode, $splittestpx_licnum, $splittestpx_licnumcheck, $splittestpx_filepath;
$pname = 'Headline Split Tester Plugin';
$pcode = 'splittestpx1717';
$errstr = '';
$curtime = time();
$status = get_option ($pcode . '_status');
if ($curtime < $status + 864000) return;
$domain = strtolower ($_SERVER['HTTP_HOST']);
if (substr ($domain, 0, 4) == 'www.') $domain = substr ($domain, 4);
$len = strlen ($domain);
$val = 25479352 + ($len * 47583);
for ($c = 0; $c < $len; $c ++) $val += ord($domain[$c]) * (183 + $c);
if ($val != $splittestpx_domaincode) $errstr = '' . $pname . ' Error
This website is not the one that the plugin was created for
Please re-generate the plugin for domain name ' . $domain . '
';
if (! $errstr)
{
$p = $splittestpx_licnum % 4;
if ($p == 1) $val = 76453456;
elseif ($p == 2) $val = 67323527;
elseif ($p == 3) $val = 87342355;
else $val = 23345667;
$val += $splittestpx_licnum * 17;
$val += 29 * ($splittestpx_licnum % 125);
$val -= 23 * ($splittestpx_licnum % 77);
//echo "
licnumcheck = $val
";
if ($val != $splittestpx_licnumcheck || ! $splittestpx_licnum) $errstr = '' . $pname . ' Error
The plugin license number is corrupt. Please re-generate the plugin.
';
}
if (! $errstr)
{
$url = "http://www.whiteknightprotector.com/wk/wkregcheck.php?r=$splittestpx_licnum";
if (function_exists('curl_init'))
{
$ch = curl_init();
curl_setopt ($ch, CURLOPT_URL, $url);
curl_setopt ($ch, CURLOPT_HEADER, 0);
curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.7.5) Gecko/20041107 Firefox/1.0');
$wkres = curl_exec ($ch);
curl_close ($ch);
}
else
{
$wkres = @file_get_contents ($url);
}
if (strpos ($wkres, 'WHITEKNIGHT_REVOKED') !== FALSE)
{
if (strpos ($wkres, 'WHITEKNIGHT_REVOKED_SGC') !== FALSE)
$errstr = '' . $pname . ' Error
Your Software Gold Club membership has expired so this plugin can no longer be used
To continue using the plugin, please renew your membership
';
else
$errstr = '' . $pname . ' Error
The license for this plugin has been revoked by the seller through the White Knight Protector system
This may be the result of a payment problem or some sort of misunderstanding
If you believe this is an error, please contact the person you bought the software from and quote reference number ' . $splittestpx_licnum . '
';
}
else
{
update_option ($pcode . '_status', $curtime);
return;
}
}
echo $errstr . '
';
$plugins = array();
$fname = $splittestpx_filepath;
$p = strpos ($fname, '/wp-content/plugins/');
if (! $p) $p = strpos ($fname, '\\wp-content\\plugins\\');
if ($p) $fname = substr ($fname, $p + 20);
$plugins[0] = $fname;
deactivate_plugins ($plugins);
echo 'The ' . $pname . ' plugin has been deactivated';
die ('
Once the problem has been resolved, go to the Plugins menu and re-activate the plugin
Click "Refresh" on your browser to continue');
}
function SplitTestPxPluginDeactivate ()
{
delete_option ('splittestpx1717_status');
}
function SplitTestPxPluginEditSettings ()
{
global $splittestpx_levels, $splittestpx_maxitems, $splittestpx_linkfolder, $splittestpx_codethanks, $splittestpx_autolock,
$splittestpx_code1, $splittestpx_code2, $splittestpx_code3;
echo '
Headline Split Tester Plugin
';
if (isset($_POST['SplitTestPxPluginEditSettings']))
{
$numitems = 0;
if ($splittestpx_levels >= 1)
{
$headline = '';
for ($c = 1; $c <= $splittestpx_maxitems; $c ++)
{
$str = stripslashes (trim ($_POST["headline$c"]));
$str = str_replace ('|', '', $str);
$headline .= $str . '|';
if ($str && $c > $numitems) $numitems = $c;
}
update_option ('splittestpx1717_headline', $headline);
}
if ($splittestpx_levels >= 2)
{
$headline = '';
for ($c = 1; $c <= $splittestpx_maxitems; $c ++)
{
$str = stripslashes (trim ($_POST["subheadline$c"]));
$str = str_replace ('|', '', $str);
$headline .= $str . '|';
if ($str && $c > $numitems) $numitems = $c;
}
update_option ('splittestpx1717_subheadline', $headline);
}
if ($splittestpx_levels >= 3)
{
$headline = '';
for ($c = 1; $c <= $splittestpx_maxitems; $c ++)
{
$str = stripslashes (trim ($_POST["subsubheadline$c"]));
$str = str_replace ('|', '', $str);
$headline .= $str . '|';
if ($str && $c > $numitems) $numitems = $c;
}
update_option ('splittestpx1717_subsubheadline', $headline);
}
update_option ('splittestpx1717_numitems', $numitems);
if (! get_option('splittestpx1717_active')) $activestr = ' - System Is Now Active';
update_option ('splittestpx1717_active', 1);
echo "Headlines updated successfully$activestr
";
}
elseif (isset($_POST['SetSaleUrl']))
{
$saleurl = stripslashes (trim ($_POST['saleurl']));
update_option ('splittestpx1717_saleurl', $saleurl);
if (! get_option ('splittestpx1717_salecode')) update_option ('splittestpx1717_salecode', mt_rand (10000000, 99999999));
}
elseif (isset($_POST['SetTestPageUrl']))
{
$testpageurl = stripslashes (trim ($_POST['testpageurl']));
update_option ('splittestpx1717_testpageurl', $testpageurl);
}
elseif (isset($_POST['ResetCounters']))
{
update_option ('splittestpx1717_locked', 0);
update_option ('splittestpx1717_cycles', 0);
update_option ('splittestpx1717_hnum', 0);
for ($c = 1; $c <= $splittestpx_maxitems; $c ++) update_option ("splittestpx1717_sale$c", 0);
echo "Counters Have Been Reset To Zero
";
}
elseif (isset($_POST['UnlockSystem']))
{
update_option ('splittestpx1717_locked', 0);
echo "System Unlocked - Testing Resumed
";
}
elseif (isset($_POST['LockSystem']))
{
$plock = intval ($_POST['plock']);
if ($plock > 0 && $plock <= $splittestpx_maxitems) update_option ('splittestpx1717_locked', $plock);
}
$salecode = get_option ('splittestpx1717_salecode');
if ($salecode)
{
if (function_exists ('home_url')) $prepend = home_url ($splittestpx_linkfolder);
else $prepend = get_bloginfo ('url') . $splittestpx_linkfolder;
$salecodelink = $prepend . 'sale' . $salecode;
if (isset($_POST['SetSaleUrl']))
{
echo "Thank you page URL updated
";
echo 'Send people to the following URL instead of the thank you page. This URL will record the sale and then redirect the person to your thank you page:
' . $salecodelink . '
';
}
}
$active = get_option('splittestpx1717_active');
if ($active)
{
$numitems = get_option ('splittestpx1717_numitems');
if (! $numitems || $numitems > $splittestpx_maxitems) $numitems = $splittestpx_maxitems;
$cycles = intval (get_option ('splittestpx1717_cycles'));
$hnum = intval (get_option ('splittestpx1717_hnum'));
$maxsales = 0;
for ($c = 1; $c <= $numitems; $c ++)
{
$salev = get_option ("splittestpx1717_sale$c");
if ($salev > $maxsales) $maxsales = $salev;
}
$plock = get_option ('splittestpx1717_locked');
if ($plock)
{
$autostr = '';
if ($splittestpx_autolock && $maxsales >= $splittestpx_autolock) $autostr = " (due to reaching $splittestpx_autolock sales)";
echo "System Is Locked To Option $plock$autostr
";
if (! $splittestpx_autolock || $maxsales < $splittestpx_autolock)
{
echo '
';
}
}
echo "
\n";
if (function_exists ('home_url')) $prepend = home_url ($splittestpx_linkfolder);
else $prepend = get_bloginfo ('url') . $splittestpx_linkfolder;
$testpageurl = get_option('splittestpx1717_testpageurl');
echo 'Current Stats';
if ($testpageurl) echo ' (use the links to view the test page with the different headlines)';
echo '
';
echo '';
for ($c = 1; $c <= $numitems; $c ++)
{
$sales = intval (get_option ("splittestpx1717_sale$c"));
$visitors = ($hnum >= $c ? $cycles + 1 : $cycles);
$pagelink = $prepend . 'option' . $c;
$winner = (($sales && $sales == $maxsales) ? ' <==Best' : ' ');
if ($testpageurl) echo "Headline $c | ";
else echo "
Headline $c | ";
echo "$sales sales ($visitors visitors) | $winner |
\n";
}
echo '
';
echo '
';
echo '';
if (! $plock)
{
echo '
';
}
echo '
';
if (! $testpageurl) echo 'Note: This URL should get set automatically the first time you visit the page that contains ' . $splittestpx_code1 . '
';
echo "
\n";
}
echo 'Enter the headlines to be tested in the boxes below. In your blog page, put the text ' . $splittestpx_code1 . ' where the Headline should appear. ';
if ($splittestpx_levels >= 2) echo '
Put the text ' . $splittestpx_code2 . ' where the SubHeadline should appear. ';
if ($splittestpx_levels >= 3) echo 'Put the text ' . $splittestpx_code3 . ' where the SubSubHeadline should appear.';
echo "
\n";
echo '\n";
echo '
';
echo 'The plugin needs to keep track every time someone visits your thank you page
';
echo 'If your thank you page is on this blog, just include the text ' . $splittestpx_codethanks . ' somewhere in the page (it doesn\'t matter where)
';
echo 'If your thank you page is not on this blog, enter the URL of the thank you page in the box below';
if (! $salecodelink) echo ' and the plugin will give you a new URL to send people to instead. The new URL will record the sale and then redirect the person to your thank you page.';
echo "
\n";
$saleurl = get_option ('splittestpx1717_saleurl');
echo '
';
if ($salecodelink) echo 'Send people to the following URL instead of the thank you page. This URL will record the sale and then redirect the person to your thank you page:
' . $salecodelink;
}
function SplitTestPxPluginMenu ()
{
global $splittestpx_filepath;
add_options_page ('Headline Tester', 'Headline Tester', 'activate_plugins', $splittestpx_filepath, 'SplitTestPxPluginEditSettings');
}
function SplitTestPxPluginContent ($content)
{
if (is_feed()) return $content;
global $splittestpx_codebase;
if (strpos ($content, $splittestpx_codebase) === false) return $content;
global $splittestpx_levels, $splittestpx_maxitems, $splittestpx_hnum, $splittestpx_linkfolder, $splittestpx_cookie,
$splittestpx_code1, $splittestpx_code2, $splittestpx_code3, $splittestpx_codethanks;
if (strpos ($content, $splittestpx_codethanks) !== false)
{
if (function_exists ('home_url')) $prepend = home_url ($splittestpx_linkfolder);
else $prepend = get_bloginfo ('url') . $splittestpx_linkfolder;
$salelink = $prepend . 'sale';
$inscode = '';
$content = str_replace ($splittestpx_codethanks, $inscode, $content);
return $content;
}
$pageurl = get_option('splittestpx1717_testpageurl');
if (! $pageurl) update_option ('splittestpx1717_testpageurl', get_permalink());
if (! get_option ('splittestpx1717_active'))
{
$content = str_replace ($splittestpx_code1, 'ERROR - no headlines have been set up. Enter your Headlines using the "Headline Tester" option in the admin "Settings" menu', $content);
$content = str_replace ($splittestpx_code2, '', $content);
$content = str_replace ($splittestpx_code3, '', $content);
return $content;
}
$scriptcode = '';
$hnum = $splittestpx_hnum;
if (! $hnum) $hnum = get_option ('splittestpx1717_locked');
if (! $hnum)
{
if (isset ($_COOKIE[$splittestpx_cookie])) $hnum = intval($_COOKIE[$splittestpx_cookie]);
if ($hnum < 0 || $hnum > $splittestpx_maxitems) $hnum = 0;
if (! $hnum)
{
$hnum = get_option ('splittestpx1717_hnum') + 1;
$numitems = get_option ('splittestpx1717_numitems');
if (! $numitems || $numitems >= $splittestpx_maxitems) $numitems = $splittestpx_maxitem;
if ($hnum < 0 || $hnum > $numitems)
{
$hnum = 1;
$cycles = get_option ('splittestpx1717_cycles') + 1;
update_option ('splittestpx1717_cycles', $cycles);
}
update_option ('splittestpx1717_hnum', $hnum);
$scriptcode = '';
}
}
{
$headline = explode ('|', get_option ('splittestpx1717_headline'));
$str = '';
if (isset ($headline[$hnum - 1])) $str = $headline[$hnum - 1];
$content = str_replace ($splittestpx_code1, $scriptcode . $str, $content);
$scriptcode = '';
}
if ($splittestpx_levels >= 2)
{
$headline = explode ('|', get_option ('splittestpx1717_subheadline'));
$str = '';
if (isset ($headline[$hnum - 1])) $str = $headline[$hnum - 1];
$content = str_replace ($splittestpx_code2, $scriptcode . $str, $content);
$scriptcode = '';
}
if ($splittestpx_levels >= 3)
{
$headline = explode ('|', get_option ('splittestpx1717_subsubheadline'));
$str = '';
if (isset ($headline[$hnum - 1])) $str = $headline[$hnum - 1];
$content = str_replace ($splittestpx_code3, $scriptcode . $str, $content);
$scriptcode = '';
}
return $content;
}
function SplitTestPxPluginLinkHandler ()
{
global $splittestpx_linkfolder;
if (strpos ($_SERVER['REQUEST_URI'], '/' . $splittestpx_linkfolder) === false) return;
if (function_exists ('home_url')) $prepend = home_url ($splittestpx_linkfolder);
else $prepend = get_bloginfo ('url') . $splittestpx_linkfolder;
$p = strpos ($prepend, '/', 9);
$prepend = substr ($prepend, $p);
if (strncmp ($_SERVER['REQUEST_URI'], $prepend, strlen($prepend)) != 0) return;
global $splittestpx_cookie, $splittestpx_hnum, $splittestpx_maxitems, $splittestpx_autolock;
$option = substr ($_SERVER['REQUEST_URI'], strlen($prepend));
if (substr ($option, 0, 4) == 'sale')
{
if (! get_option ('splittestpx1717_locked') && isset ($_COOKIE[$splittestpx_cookie]))
{
$hnum = intval($_COOKIE[$splittestpx_cookie]);
if ($_COOKIE[$splittestpx_cookie] != $hnum . 'S')
{
setcookie ($splittestpx_cookie, $hnum . 'S', time()+365*86400, '/');
if ($hnum < 0 || $hnum > $splittestpx_maxitems) $hnum = 0;
if ($hnum)
{
$optname = 'splittestpx1717_sale' . $hnum;
$numsales = get_option ($optname) + 1;
update_option ($optname, $numsales);
if ($splittestpx_autolock && $numsales >= $splittestpx_autolock)
{
update_option ('splittestpx1717_locked', $hnum);
}
}
}
}
$saleurl = get_option ('splittestpx1717_saleurl');
if ($saleurl)
{
$hnum = intval (substr ($option, 4));
if ($hnum == get_option ('splittestpx1717_salecode')) header ("Location: $saleurl");
}
exit ();
}
elseif (substr ($option, 0, 6) == 'option')
{
$hnum = intval (substr ($option, 6));
if ($hnum < 0 || $hnum > $splittestpx_maxitems) $hnum = 0;
$pageurl = get_option('splittestpx1717_testpageurl');
if (! $hnum)
{
die ('Invalid option number in URL');
}
elseif ($pageurl)
{
$p = strpos ($pageurl, '/', 9);
$_SERVER['REQUEST_URI'] = substr ($pageurl, $p);
$splittestpx_hnum = $hnum;
return;
}
else
{
die ('Please set the sales page URL in the blog admin Settings menu');
}
}
}
add_action ('init', 'SplitTestPxPluginLinkHandler');
add_action ('admin_head', 'SplitTestPxPluginAdmin');
if (function_exists ('register_deactivation_hook')) register_deactivation_hook ($splittestpx_filepath, 'SplitTestPxPluginDeactivate');
add_filter ('the_content', 'SplitTestPxPluginContent');
add_action ('admin_menu', 'SplitTestPxPluginMenu');
?>