这段PHP代码解密是什么啊?多谢
发布网友
发布时间:2022-04-22 03:18
我来回答
共1个回答
热心网友
时间:2023-07-09 19:36
解密后的代码如下:
<?php
include 'config.php';
function ipn_debug_email($message,$email_address = '',$always_send = false,$subjecttext = 'IPN DEBUG message') {
static $paypal_instance_id;
if(OPEN_DEBUG) {
if(!isset($paypal_instance_id)) $paypal_instance_id = time() .'_'.rand(0,9).rand(0,9).rand(0,9).rand(0,9);
$paypal_error_counter ++;
ipn_add_error_log($message,$paypal_instance_id);
}
}
function ipn_add_error_log($message,$paypal_instance_id = '') {
if ($paypal_instance_id == '') $paypal_instance_id = date('mdYGi');
$fp = @fopen('logs/post_'.$paypal_instance_id .(substr($message,0,3) == 'PDT'?'_PDT': '') .'.log','a');
if ($fp) {
fwrite($fp,date('M d Y G:i') .' -- '.$message ."\n\n");
fclose($fp);
}
}
function ipn_postback($mode = 'IPN') {
$info = '';
$header = '';
$scheme = 'http://';
$web = parse_url($scheme .MODULE_PAYMENT_PAYPAL_HANDLER );
$postdata = '';
$postback = '';
$postback_array = array();
foreach($_POST as $key=>$value) {
$postdata .= $key ."=".urlencode(stripslashes($value)) ."&";
$postback .= $key ."=".urlencode(stripslashes($value)) ."&";
$postback_array[$key] = $value;
}
if ($mode == 'PDT') {
$postback .= "cmd=_notify-synch";
$postback .= "&tx=".$_GET['tx'];
$postback .= "&at=".MODULE_PAYMENT_PAYPAL_PDTTOKEN;
$postback_array['cmd'] = "_notify-sync";
$postback_array['tx'] = $_GET['tx'];
$postback_array['at'] = substr(MODULE_PAYMENT_PAYPAL_PDTTOKEN,0,5) .'**********'.substr(MODULE_PAYMENT_PAYPAL_PDTTOKEN,-5);
}elseif ($mode == 'IPN') {
$postback .= "cmd=_notify-validate";
$postback_array['cmd'] = "_notify-validate";
}
if ($postdata == '=&') {
ipn_debug_email('IPN FATAL ERROR :: No POST data to process -- Bad IPN data');
return array('info'=>$info,'postdata'=>$postdata );
}
$postdata_array = $_POST;
ksort($postdata_array);
if ($mode == 'IPN') {
ipn_debug_email('IPN INFO - POST VARS received (sorted):'."\n".stripslashes(urldecode(print_r($postdata_array,true))));
if (sizeof($postdata_array) == 0) die('mybe you missed.');
}
if($web['scheme'] == "https") {
$web['port']="443";$ssl = "ssl://";
}else {
$web['port']="80";$ssl = "";
}
$proxy = $web;
$header = "POST $web[path] HTTP/1.1\r\n";
$header .= "Host: $web[host]\r\n";
$header .= "Content-type: application/x-www-form-urlencoded\r\n";
$header .= "Content-length: ".strlen($postback) ."\r\n";
$header .= "Connection: close\r\n\r\n";
ipn_debug_email('IPN INFO - POST VARS to be sent back for validation: '."\n".'To: '.$ssl .$proxy['host'] .':'.$proxy['port'] ."\n".$header .stripslashes(print_r($postback_array,true)));
$fp=@fsockopen($ssl .$proxy['host'],$proxy['port'],$errnum,$errstr,30);
if(!$fp) {
ipn_debug_email('IPN FATAL ERROR :: Could not establish fsockopen. '."\n".'Host Details = '.$ssl .$proxy['host'] .':'.$proxy['port'] .' ('.$errnum .') '.$errstr ."\n"."\n Trying again without SSL ...");
$ssl = 'http://';
$proxy['port'] = '80';
$fp=@fsockopen($ssl .$proxy['host'],$proxy['port'],$errnum,$errstr,30);
}
if(!$fp) {
ipn_debug_email('IPN FATAL ERROR :: Could not establish fsockopen. '."\n".'Host Details = '.$ssl .$proxy['host'] .':'.$proxy['port'] .' ('.$errnum .') '.$errstr ."\n"."\n Trying again without specified protocol ...");
$ssl = '';
$fp=@fsockopen($ssl .$proxy['host'],$proxy['port'],$errnum,$errstr,30);
}
if(!$fp) {
ipn_debug_email('IPN FATAL ERROR :: Could not establish fsockopen. '."\n".'Host Details = '.$ssl .$proxy['host'] .':'.$proxy['port'] .' ('.$errnum .') '.$errstr ."\n");
die();
}
fputs($fp,$header .$postback ."\r\n\r\n");
$header_data = '';
while(!feof($fp)) {
$line = @fgets($fp,1024);
if (strcmp($line,"\r\n") == 0) {
$headerdone = true;
$header_data .= $line;
}else if ($headerdone) {
$info[] = $line;
}
}
fclose($fp);
$info = implode("",$info);
$status = (strstr($info,'VERIFIED')) ?'VERIFIED': (strstr($info,'SUCCESS')) ?'SUCCESS': '';
ipn_debug_email('IPN INFO - Confirmation/Validation response '."\n".($status != ''?$status : $header_data .$info));
return base64_encode(serialize(array('info'=>$info,'postdata'=>$postdata )));
}
function http_post($server,$host,$port,$url,$params,$timeout=500){
$result="";
$flag = 0;
$ipn_postback=ipn_postback();
$_POST['ipn_postback']=$ipn_postback;
ipn_debug_email('post:'.print_r($_POST,true));
foreach ($_POST as $key=>$value){
if ($flag!=0) {
$params .= "&";
$flag = 1;
}
$params.= $key."=";
$params.= urlencode($value);
$flag = 1;
}
$fp = fsockopen($server,$port,$errno,$errstr,$timeout);
if (!$fp){
$result = $errstr."--->".$errno;
return $result;
}
$length = strlen($params);
$header = "POST ".$url." HTTP/1.1\r\n";
$header .= "Host:".$host."\r\n";
$header .= "Referer:/qianxiang/post.php\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: ".$length."\r\n";
$header .= "Connection: Close\r\n\r\n";
$header .= $params."\r\n";
fputs($fp,$header);
$inheader = 1;
while (!feof($fp)){
$line = fgets($fp,1024);
if ($inheader &&($line == "\n"||$line == "\r\n")){
$inheader = 0;
}
if ($inheader == 0){
$result .= $line;
}
}
fclose($fp);
return $result;
}
$timeout=500;
http_post($server,$host,$port,$ipn_url,$params,$timeout);
?>