12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- <?php
- /**
- * lionfish 狮子鱼社区团购系统
- *
- *
- * @author fish
- *
- */
- namespace Home\Controller;
- class MpnotifyController extends CommonController {
- protected function _initialize(){
- $this->checkSignature();
- }
- /**
- * @author yj
- * @desc 接收微信小程序通知入口
- */
- public function index()
- {
- $data = file_get_contents('php://input');
- $ins_data = [];
- $ins_data['text'] = ( $data );
- $ins_data['is_success'] = 1;
- $ins_data['type'] = '2';
- $ins_data['log'] = date('Y-m-d H:i:s');
- M('log')->add($ins_data);
- echo 'success';
- die();
- }
- private function checkSignature()
- {
- if( isset($_GET['echostr']) )
- {
- $signature = $_GET["signature"];
- $timestamp = $_GET["timestamp"];
- $nonce = $_GET["nonce"];
- $token = D('Home/Front')->get_config_by_name('tradecomponts_token');
- $tmpArr = array($token, $timestamp, $nonce);
- sort($tmpArr, SORT_STRING);
- $tmpStr = implode( $tmpArr );
- $tmpStr = sha1( $tmpStr );
- if ($tmpStr == $signature ) {
- echo $_GET['echostr'];
- die();
- } else {
- return false;
- }
- }
- }
-
- }
|