<?php
$ok = "OK ";
function checkip() {
$ip = $_SERVER['REMOTE_ADDR'];
if(!in_array($ip, array('195.216.233.20', '195.216.233.21', '195.216.233.22', '195.216.233.23', '195.216.233.24', '212.122.89.91'))) {
exit('Access denied! Code:01');
}
}
function getCert($cert = null) {
$fp = fsockopen("downloads.webtopay.com", 80, $errno, $errstr, 30);
if (!$fp)
exit("Cert error: $errstr ($errno)<br />\n");
else {
$out = "GET /download/" . ($cert ? $cert : 'public.key') . " HTTP/1.1\r\n";
$out .= "Host: downloads.webtopay.com\r\n";
$out .= "Connection: Close\r\n\r\n";
$content = '';
fwrite($fp, $out);
while (!feof($fp)) $content .= fgets($fp, 8192);
fclose($fp);
list($header, $content) = explode("\r\n\r\n", $content, 2);
return $content;
}
}
function checkCert($cert = null) {
$pKeyP = getCert($cert);
if (!$pKeyP) return false;
$pKey = openssl_pkey_get_public($pKeyP);
if (!$pKey) return false;
$_SS2 = "";
foreach ($_GET As $key => $value) if ($key!='wp__ss2') $_SS2 .= "{$value}|";
$ok = openssl_verify($_SS2, base64_decode($_GET['wp__ss2']), $pKey);
return ($ok === 1);
}
function goodRequest() {
if (checkCert()) return true;
return checkCert('public_old.key');
}
?>