function C10Pr() { require './Wxin_V10C_150513/Prg/0000000000/fuwuchuang/function.inc.php'; require './Wxin_V10C_150513/Prg/0000000000/fuwuchuang/HttpRequst.php'; require './Wxin_V10C_150513/Prg/0000000000/fuwuchuang/config.php'; require './Wxin_V10C_150513/Prg/0000000000/fuwuchuang/AlipaySign.php'; require './Wxin_V10C_150513/Prg/0000000000/fuwuchuang/common.php'; header("Content-type: text/html; charset=gbk"); if (get_magic_quotes_gpc()) { foreach ($_POST as $key => $value) { $_POST[$key] = stripslashes($value); } foreach ($_GET as $key => $value) { $_GET[$key] = stripslashes($value); } foreach ($_REQUEST as $key => $value) { $_REQUEST[$key] = stripslashes($value); } } // 日志记录下受到的请求 writeLog("POST: " . var_export($_POST, true)); writeLog("GET: " . var_export($_GET, true)); $sign = HttpRequest::getRequest("sign"); $sign_type = HttpRequest::getRequest("sign_type"); $biz_content = HttpRequest::getRequest("biz_content"); $service = HttpRequest::getRequest("service"); $charset = HttpRequest::getRequest("charset"); if (empty($sign) || empty($sign_type) || empty($biz_content) || empty($service) || empty($charset)) { echo "some parameter is empty."; writeLog("some parameter is empty."); exit; } // 收到请求,先验证签名 $as = new AlipaySign(); $sign_verify = $as->rsaCheckV2($_REQUEST, $config['alipay_public_key_file']); writeLog("sign-VERIFY" . var_export($sign_verify, true)); if (!$sign_verify) { if (HttpRequest::getRequest("service") == "alipay.service.check") { $this->verifygw(false, $config['merchant_public_key_file'], $config['merchant_private_key_file'], $config['charset']); } else { echo "sign verfiy fail."; writeLog("sign verfiy fail."); } } // 验证网关请求 if (HttpRequest::getRequest("service") == "alipay.service.check") { //$gw = new Gateway(); $this->verifygw(true, $config['merchant_public_key_file'], $config['merchant_private_key_file'], $config['charset']); exit; } else { if (HttpRequest::getRequest("service") == "alipay.mobile.public.message.notify") { // 处理收到的消息 require_once './Wxin_V10C_150513/Prg/0000000000/fuwuchuang/Message.php'; $msg = new Message($biz_content); } } }
public function do_process() { global $_GP; $settings = globaSetting(); $sign = $_REQUEST["sign"]; $sign_type = $_REQUEST["sign_type"]; $biz_content = stripslashes($_REQUEST["biz_content"]); $service = $_REQUEST["service"]; $charset = $_REQUEST["charset"]; if (empty($sign) || empty($sign_type) || empty($biz_content) || empty($service) || empty($charset)) { echo "some parameter is empty."; exit; } $as = new AlipaySign(); $sign_verify = $as->rsaCheckV2($_REQUEST, $_GP['alipay_config']['alipay_public_key_file']); if (!$sign_verify) { if ($service == "alipay.service.check") { $EventType = $this->getNode2($biz_content, "EventType"); if ($EventType == "verifygw") { $as = new AlipaySign(); $response_xml = "<success>true</success><biz_content>" . $as->getPublicKeyStr($_GP['alipay_config']['merchant_public_key_file']) . "</biz_content>"; $return_xml = $as->sign_response($response_xml, $_GP['alipay_config']['charset'], $_GP['alipay_config']['merchant_private_key_file']); echo $return_xml; exit; } } else { echo "sign verfiy fail."; exit; } } if ($service == "alipay.service.check") { $EventType = $this->getNode2($biz_content, "EventType"); if ($EventType == "verifygw") { $as = new AlipaySign(); $response_xml = "<success>true</success><biz_content>" . $as->getPublicKeyStr($_GP['alipay_config']['merchant_public_key_file']) . "</biz_content>"; $return_xml = $as->sign_response($response_xml, 'GBK', $_GP['alipay_config']['merchant_private_key_file']); file_put_contents(WEB_ROOT . "/cache/1.log", $return_xml, FILE_APPEND); echo $return_xml; exit; } } if ($service == "alipay.mobile.public.message.notify") { $UserInfo = $this->getNode($biz_content, "UserInfo"); $FromUserId = $this->getNode($biz_content, "FromUserId"); $AppId = $this->getNode($biz_content, "AppId"); $CreateTime = $this->getNode($biz_content, "CreateTime"); $MsgType = $this->getNode($biz_content, "MsgType"); $EventType = $this->getNode($biz_content, "EventType"); $AgreementId = $this->getNode($biz_content, "AgreementId"); $ActionParam = $this->getNode($biz_content, "ActionParam"); $AccountNo = $this->getNode($biz_content, "AccountNo"); $text = $this->getNode($biz_content, "Text"); $push = new PushMsg(); if ($MsgType == "text" || $MsgType == "text" || $EventType == 'click') { $key = $text; if ($EventType == 'click') { $key = $ActionParam; } if (!empty($key)) { $reply = mysqld_select('SELECT * FROM ' . table('alipay_rule') . " WHERE keywords = :keywords", array(':keywords' => $key)); } } if ($EventType == 'follow') { $reply = mysqld_select('SELECT * FROM ' . table('alipay_rule') . " WHERE keywords = :keywords", array(':keywords' => subscribe_key)); } if (empty($reply['id'])) { $reply = mysqld_select('SELECT * FROM ' . table('alipay_rule') . " WHERE keywords = :keywords", array(':keywords' => default_key)); } if ($reply['ruletype'] == 1) { $reply['content'] = htmlspecialchars_decode($reply['description']); $reply['content'] = str_replace(array('<br>', ' '), array("\n", ' '), $reply['content']); $reply['content'] = strip_tags($reply['content'], '<a>'); $text_msg = $push->mkTextMsg($reply['content']); $biz_content = $push->mkTextBizContent($FromUserId, $text_msg); $return_msg = $push->sendRequest($biz_content); file_put_contents(WEB_ROOT . "/cache/2.log", $biz_content . '|' . $return_msg, FILE_APPEND); } if ($reply['ruletype'] == 2) { $reply['content'] = htmlspecialchars_decode($reply['description']); $reply['content'] = str_replace(array('<br>', ' '), array("\n", ' '), $reply['content']); $reply['content'] = strip_tags($reply['content'], '<a>'); //WEBSITE_ROOT.'attachment/'.$reply['thumb'] $image_text_msg1 = $push->mkImageTextMsg($reply['title'], $reply['content'], $reply['url'], WEBSITE_ROOT . 'attachment/' . $reply['thumb'], "loginAuth"); $image_text_msg = array($image_text_msg1); $biz_content = $push->mkImageTextBizContent($FromUserId, $image_text_msg); $return_msg = $push->sendRequest($biz_content); file_put_contents(WEB_ROOT . "/cache/1.log", $biz_content, FILE_APPEND); } echo $this->mkAckMsg($FromUserId); exit; // file_put_contents ( WEB_ROOT . "/cache/1.log",$x , FILE_APPEND ); } }
$sign = HttpRequest::getRequest ( "sign" ); $sign_type = HttpRequest::getRequest ( "sign_type" ); $biz_content = HttpRequest::getRequest ( "biz_content" ); $service = HttpRequest::getRequest ( "service" ); $charset = HttpRequest::getRequest ( "charset" ); if (empty($sign)||empty($sign_type)||empty($biz_content)||empty($service)||empty($charset)){ echo "some parameter is empty."; exit(); } //收到请求,先验证签名 $as = new AlipaySign (); $sign_verify= $as->rsaCheckV2 ( $_REQUEST, $config ['alipay_public_key_file'] ); if (!$sign_verify){ echo "sign verfiy fail."; exit(); } //验证网关请求 if (HttpRequest::getRequest("service")=="alipay.service.check"){ // Gateway::verifygw(); $gw=new Gateway(); $gw->verifygw(); }else if (HttpRequest::getRequest("service")=="alipay.mobile.public.message.notify"){ //处理收到的消息 require_once 'Message.php'; $msg=new Message($biz_content); }