Server : Apache System : Linux iZ2vcgyutqttsd1p850kl8Z 3.10.0-1160.92.1.el7.x86_64 #1 SMP Tue Jun 20 11:48:01 UTC 2023 x86_64 User : www ( 1000) PHP Version : 5.6.40 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv Directory : /www/wwwroot/saimikebio.com/mobile/ |
<?php function weixin_remind_admin_pay($notice,$order_id){ /*获取消息模板信息*/ $sql = "SELECT * FROM " .$GLOBALS['ecs']->table('weixin_remind'). " WHERE id = 1"; $ret_re = $GLOBALS['db']->getRow($sql); $access_token_remind = access_token_remind($db); $wxapiurl = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token_remind; //订单支付成功提醒开始 if($notice == 2){ if($ret_re['is_pay_admin'] == 1) { //支付成功提醒管理员 $admin_id_sql = "SELECT `cfg_value` FROM " . $GLOBALS['ecs']->table('weixin_cfg') . " WHERE `cfg_name`='admin_id'"; $admin_id = $GLOBALS['db'] -> getOne($admin_id_sql); $admin_wxid_sql = "SELECT `wxid` FROM " . $GLOBALS['ecs']->table('users') . " WHERE user_id = '$admin_id'"; $orders = $GLOBALS['db'] -> getRow("SELECT * FROM " . $GLOBALS['ecs']->table('order_info') . " WHERE `order_id` = '$order_id' "); $wxid = $GLOBALS['db'] -> getOne($admin_wxid_sql); $w_order_sn = $orders['order_sn']; $w_order_amount = $orders['goods_amount']; $consignee = $orders['consignee']; $mobile = $orders['mobile']; $w_url = "index.php"; $post_msg = '{ "touser":"'.$wxid.'", "template_id":"'.$ret_re['pay_admin'].'", "url":"'.$w_url.'", "topcolor":"#FF0000", "data":{ "first": { "value":"'.$GLOBALS['_LANG']['admin_pay_first'].'", "color":"#FF0000" }, "keyword1":{ "value":"'.$w_order_sn.'", "color":"#0000FF" }, "keyword2": { "value":"'.$w_order_amount.'", "color":"#0000FF" }, "keyword3": { "value":"'.$consignee.'", "color":"#0000FF" }, "keyword4": { "value":"'.$mobile.'", "color":"#0000FF" }, "remark":{ "value":"'.$GLOBALS['_LANG']['admin_pay_remark'].'", "color":"#FF0000" } } }'; $ret_json = curl_grab_page_remind($wxapiurl, $post_msg); $ret = json_decode($ret_json); if($ret->errmsg != 'ok' || empty($ret->errmsg)) { $access_token_remind = access_token_remind($db); $wxapiurl = 'https://api.weixin.qq.com/cgi-bin/message/template/send?access_token='.$access_token_remind; $ret_json = curl_grab_page_remind($wxapiurl, $post_msg); $ret = json_decode($ret_json); } } } } //订单支付成功提醒end function access_token_remind($db) { $time = time(); $ret = $GLOBALS['db']->getRow("SELECT * FROM ". $GLOBALS['ecs']->table('weixin_config') ." WHERE `id` = 1"); $appid = $ret['appid']; $appsecret = $ret['appsecret']; $wxtokenurl = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=$appid&secret=$appsecret"; $ret_json = curl_get_contents_remind($wxtokenurl); $ret = json_decode($ret_json); if($ret->access_token) { $GLOBALS['db']-> query("UPDATE ". $GLOBALS['ecs']->table('weixin_config') ." SET `access_token` = '$ret->access_token',`dateline` = '$time' WHERE `id` =1;"); } return $ret->access_token; } function curl_get_contents_remind($url){ $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER["HTTP_USER_AGENT"]); curl_setopt($ch,CURLOPT_FOLLOWLOCATION,1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); $r = curl_exec($ch); curl_close($ch); return $r; } function curl_grab_page_remind($url,$data,$proxy='',$proxystatus='',$ref_url='') { $header = array('Expect:'); $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, "Mozilla/4.0 (compatible; MSIE 5.01; Windows NT 5.0)"); curl_setopt($ch, CURLOPT_TIMEOUT, 1); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); if ($proxystatus == 'true') { curl_setopt($ch, CURLOPT_HTTPPROXYTUNNEL, TRUE); curl_setopt($ch, CURLOPT_PROXY, $proxy); } curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($ch, CURLOPT_URL, $url); if(!empty($ref_url)){ curl_setopt($ch, CURLOPT_HEADER, TRUE); curl_setopt($ch, CURLOPT_REFERER, $ref_url); } curl_setopt($ch, CURLOPT_USERAGENT, $_SERVER['HTTP_USER_AGENT']); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt($ch, CURLOPT_POST, TRUE); curl_setopt($ch, CURLOPT_HTTPHEADER, $header); curl_setopt($ch, CURLOPT_POSTFIELDS, $data); ob_start(); return curl_exec ($ch); ob_end_clean(); curl_close ($ch); unset($ch); } ?>