/** * 获取prepay_id */ function getPrepayId() { $this->getResult(); if ($this->result['return_code'] != 'SUCCESS') { sae_log('getPrepayId', $this->result['return_msg']); } $prepay_id = $this->result["prepay_id"]; return $prepay_id; }
/** * Implements writing to log files. * * @param string $type The type of log you are making. * @param string $message The message you want to log. * @return bool success of write. */ public function write($type, $message) { $output = date('Y-m-d H:i:s') . ' ' . ucfirst($type) . ': ' . $message . "\n"; $filename = $this->_getFilename($type); /* if (!empty($this->_size)) { $this->_rotateFile($filename); } */ $pathname = $this->_path . $filename; $str_path_and_output = $pathname . ":\n" . $output; sae_log($str_path_and_output); return strlen($str_path_and_output); /* if ( empty($this->_config['mask'])) { return file_put_contents($pathname, $output, FILE_APPEND); } $exists = file_exists($pathname); $result = file_put_contents($pathname, $output, FILE_APPEND); static $selfError = false; if (!$selfError && !$exists && !chmod($pathname, (int)$this->_config['mask'])) { $selfError = true; trigger_error(__d( 'cake_dev', 'Could not apply permission mask "%s" on log file "%s"', array($this->_config['mask'], $pathname)), E_USER_WARNING); $selfError = false; } return $result; */ }
<?php /** * Created by PhpStorm. * User: Nigel * Date: 2016/2/5 * Time: 3:24 */ $q = @addslashes(htmlspecialchars(trim($_POST["q"]))); //$filename = 'www.nigel.top.html'; //$file = addslashes(file_get_contents($filename)); //$query = "INSERT INTO cheater(filename,file) VALUES('{$filename}','{$file}')"; $db = new mysqli(SAE_MYSQL_HOST_M . ':' . SAE_MYSQL_PORT, SAE_MYSQL_USER, SAE_MYSQL_PASS, SAE_MYSQL_DB) or sae_log("new mysqli " . $db->error); $db->set_charset('utf8'); $res = $db->query("SELECT file FROM cheater WHERE file REGEXP '{$q}'") or sae_log("query " . $db->error); $db->close(); $output = ''; while ($text = $res->fetch_array()) { $output .= $text[0] . "<hr/>"; //$text = stripslashes($text); //preg_match("|<p.*?{$q}.*?</p>|i", iconv(mb_detect_encoding($text), "UTF-8", $text), $output); //echo $output[0]; } echo $output ? $output : "Nothing Found"; /** * @param $msg string * * @return string */ function sae_log($msg) {
public function notify() { /* * <xml> <appid><![CDATA[wx4e81aacd38a27424]]></appid> <bank_type><![CDATA[CFT]]></bank_type> <cash_fee><![CDATA[1]]></cash_fee> <fee_type><![CDATA[CNY]]></fee_type> <is_subscribe><![CDATA[Y]]></is_subscribe> <mch_id><![CDATA[1247136201]]></mch_id> <nonce_str><![CDATA[7haw88jm20b078lxufc3vhl1j5i5kiwm]]></nonce_str> <openid><![CDATA[oVe75s2v_gh8E_ed5-MS57NVVXhg]]></openid> <out_trade_no><![CDATA[wx4e81aacd38a274241434089697]]></out_trade_no> <result_code><![CDATA[SUCCESS]]></result_code> <return_code><![CDATA[SUCCESS]]></return_code> <sign><![CDATA[8791ACDF25B56957CA0AB4F055304BBA]]></sign> <time_end><![CDATA[20150612141518]]></time_end> <total_fee>1</total_fee> <trade_type><![CDATA[JSAPI]]></trade_type> <transaction_id><![CDATA[1000040089201506120240872710]]></transaction_id> </xml> */ //使用通用通知接口 $notify = D('Server', 'Pay'); //存储微信的回调 $xml = $GLOBALS['HTTP_RAW_POST_DATA']; sae_log('notify', $xml); $notify->saveData($xml); //验证签名,并回应微信。 //对后台通知交互时,如果微信收到商户的应答不是成功或超时,微信认为通知失败, //微信会通过一定的策略(如30分钟共8次)定期重新发起通知, //尽可能提高通知的成功率,但微信不保证通知最终能成功。 if ($notify->checkSign() == FALSE) { $notify->setReturnParameter("return_code", "FAIL"); //返回状态码 $notify->setReturnParameter("return_msg", "签名失败"); //返回信息 } else { $notify->setReturnParameter("return_code", "SUCCESS"); //设置返回码 } if ($notify->checkSign() == TRUE) { if ($notify->data["return_code"] == "FAIL") { //通信出错 } elseif ($notify->data["result_code"] == "FAIL") { //业务出错 } else { //支付成功 $data = $notify->getData(); $order = M('OrderWeixin'); $attach = $data['attach']; $attach = json_decode($attach); foreach ($attach as $key => $val) { $data[$key] = $val; } $Orderrecord = D('Orderrecord'); $vertifyCode = $Orderrecord->buildVertifyCode(); $dataRecord = array('orderno' => $data['out_trade_no'], 'paytime' => tounix($data['time_end']), 'paymethod' => '__weixin__', 'chargeid' => $data['transaction_id'], 'vertifycode' => $vertifyCode); M()->startTrans(); $flg = $order->add($data); if (!$flg) { sae_log('OrderWeixin', $data); M()->rollback(); $returnXml = $notify->returnXml(); echo $returnXml; exit; } $flg = $Orderrecord->add($dataRecord); if (!$flg) { sae_log('Orderrecord', $dataRecord); M()->rollback(); $returnXml = $notify->returnXml(); echo $returnXml; exit; } $party = D('Party')->cache("party_" . $data['nid'], 60 * 60 * 24)->relation(true)->where('nid = %d', $data['nid'])->find(); D('Party')->where('id = %d', $party['id'])->setDec('cntremain', $data['quantity']); S("party_" . $data['nid'], null); M()->commit(); $time = date('Y-m-d H:i', $party['starttime']); $ret = D('Sms', 'Logic')->sendOrderVerify($data['phonenumber'], $party['title'], $vertifyCode, $time); if ($ret != null) { $returnXml = $notify->returnXml(); echo $returnXml; exit; } } //商户自行增加处理流程, //例如:更新订单状态 //例如:数据库操作 //例如:推送支付完成信息 } $returnXml = $notify->returnXml(); echo $returnXml; }
if ($amount > 1) { $description .= sprintf("\n第%s张脸\n", $i + 1); } $attr = $info[$i]['attributes']; $description .= "年龄: " . $attr['age']; $description .= "\n性别: " . $attr['gender']; } return Message::make('news')->item(Message::make("news_item")->title($title)->description($description)->url($savedUrl)->PicUrl($savedUrl)); } return Message::make('text')->content($title); } return Message::make('text')->content("不好意思出错啦/:bye"); }); //语音消息处理,使用微信的识别结果 $server->on('message', 'voice', function ($message) use($welcome) { sae_log($message->Recogniton); return handleText($message->Recognition, $message->FromUserName, $welcome); }); $result = $server->serve(); echo $result; /** * 处理文字消息 * @param $text string * @param $openid string * @param $welcome closure * @return mixed */ function handleText($text, $openid, $welcome) { if (in_array(trim($text), array("你好", "你能干什么", "哈哈", "您好", "喂", "你有什么功能"))) { return Message::make('news')->items($welcome);
//数据库保存的openid $openid_db = $query['openid']; $name = $query['name']; $_SESSION['examid'] = $examid; $_SESSION['name'] = $name; //var_dump($examid); //var_dump($mysql->getLine($query)); //var_dump($mysql->getVar($query)); //sae_log(json_encode($openid . "-" . $examid)); //用户尚未注册 if (empty($openid_db)) { $signup = "INSERT INTO wechat_user (openid) VALUES ('{$openid}') "; $bool = $mysql->runSql($signup); if (!$bool) { echo $debug = sprintf("注册失败 %d : %s", $mysql->errno(), $mysql->errmsg()); sae_log($debug); } else { // echo "你已成功注册" . "<br/>"; // echo "即将跳转到备份的页面"; // echo "if 111111"; //跳到填写考号和姓名的页面 header("Location:http://5.n1gel.sinaapp.com/cet_query.php"); //填写之后,更新session,更新数据库 } //用户已注册,为备份考号和姓名 } elseif (empty($examid)) { // echo "即将跳转到备份的页面"; // echo "if 222222222"; header("Location:http://5.n1gel.sinaapp.com/cet_query.php"); //页面获取exanid和姓名直接查询,将查询结果存到数据库并显示到页面,生成一个模板图片,让用户保存 //填写之后,更新session,更新数据库
sae_log("filename" . $filename); $respose[$i]['file'] = $filename; $respose[$i]['error'] = ''; $flag = true; if ($files['size'][$i] / 1024 > 2000) { $respose[$i]['error'] .= "File is too big"; $flag = false; } if ($files['error'][$i] !== 0) { $respose[$i]['error'] .= "\n" . $files['error'][$i]; $flag = false; } if ($flag) { $file = addslashes(file_get_contents($files["tmp_name"][$i])); foreach (str_split($file, 20000) as $piece) { $stmt->bind_param("ss", $filename, $piece) or sae_log($stmt->error); $stmt->execute() or $respose[$i]["error"] .= "\n{$stmt->errno}:{$stmt->error}"; } } } echo json_encode($respose); /** * @param $msg string * * @return string */ function sae_log($msg) { sae_set_display_errors(false); //关闭信息输出 sae_debug($msg);
</script> <?php } else { $is_name = true; } if ($is_examid && $is_name) { $_SESSION['examid'] = $examid; $_SESSION['name'] = $name; //更新数据库 $mysql = new SaeMysql(); $update = "insert into cet (examid,name,openid) VALUES ('{$examid}','{$name}','{$openid}')"; $updata_wx = "update wechat_user set name='{$name}' WHERE openid='{$openid}'"; $bool = $mysql->runSql($update); $bool = $mysql->runSql($updata_wx); if (!$bool) { sae_log("插入考号姓名出错" . $mysql->errmsg()); } $mysql->closeDb(); //跳转 header("Location:http://5.n1gel.sinaapp.com/cet_result.php"); } } //endregion ?> <!doctype> <html lang="zh"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width,user-scalable=no,initial-scale=1"/> <link rel="stylesheet" href="http://cdn.rmbz.net/bootstrap-3.3.5-dist/css/bootstrap.min.css"> <title>四六级查分</title>