|
@@ -176,6 +176,8 @@ class Wechat
|
|
|
}
|
|
|
}
|
|
|
$this->postxml = $array[1];
|
|
|
+ if (!$this->appid)
|
|
|
+ $this->appid = $array[2];
|
|
|
} else {
|
|
|
$this->postxml = $postStr;
|
|
|
}
|
|
@@ -183,7 +185,7 @@ class Wechat
|
|
|
$echoStr = isset($_GET["echostr"]) ? $_GET["echostr"]: '';
|
|
|
}
|
|
|
if ($return) {
|
|
|
- if ($echoStr) {
|
|
|
+ if (isset($echoStr)) {
|
|
|
if ($this->checkSignature($encryptStr))
|
|
|
return $echoStr;
|
|
|
else
|
|
@@ -191,7 +193,7 @@ class Wechat
|
|
|
} else
|
|
|
return $this->checkSignature($encryptStr);
|
|
|
} else {
|
|
|
- if ($echoStr) {
|
|
|
+ if (isset($echoStr)) {
|
|
|
if ($this->checkSignature($encryptStr))
|
|
|
die($echoStr);
|
|
|
else
|
|
@@ -2076,7 +2078,7 @@ class Prpcrypt
|
|
|
|
|
|
try {
|
|
|
|
|
|
- $random = "aaaabbbbccccdddd";
|
|
|
+ $random = $this->getRandomStr();
|
|
|
$text = $random . pack("N", strlen($text)) . $text . $appid;
|
|
|
|
|
|
$size = mcrypt_get_block_size(MCRYPT_RIJNDAEL_128, MCRYPT_MODE_CBC);
|
|
@@ -2095,7 +2097,7 @@ class Prpcrypt
|
|
|
|
|
|
return array(ErrorCode::$OK, base64_encode($encrypted));
|
|
|
} catch (Exception $e) {
|
|
|
- print $e;
|
|
|
+
|
|
|
return array(ErrorCode::$EncryptAESError, null);
|
|
|
}
|
|
|
}
|
|
@@ -2135,13 +2137,17 @@ class Prpcrypt
|
|
|
$xml_len = $len_list[1];
|
|
|
$xml_content = substr($content, 4, $xml_len);
|
|
|
$from_appid = substr($content, $xml_len + 4);
|
|
|
+ if (!$appid)
|
|
|
+ $appid = $from_appid;
|
|
|
+
|
|
|
} catch (Exception $e) {
|
|
|
- print $e;
|
|
|
+
|
|
|
return array(ErrorCode::$IllegalBuffer, null);
|
|
|
}
|
|
|
if ($from_appid != $appid)
|
|
|
return array(ErrorCode::$ValidateAppidError, null);
|
|
|
- return array(0, $xml_content);
|
|
|
+
|
|
|
+ return array(0, $xml_content, $from_appid);
|
|
|
|
|
|
}
|
|
|
|