|
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- function writeLog($log)
- {
- $dir = __DIR__ . "/../Log/";
- if (!is_dir($dir)) {
- mkdir($dir);
- }
- $filename = $dir . date("Y-m-d") . ".log";
- $need_chmod = file_exists($filename);
- file_put_contents($filename, date("Y-m-d H:i:s") . "\t" . $log . PHP_EOL, FILE_APPEND);
- if ($need_chmod == false) {
- @chmod($filename, 0777);
- }
- }
-
- function makeSign($array)
- {
- $str = '';
- foreach ($array as $v) {
- $str .= $v;
- }
- return sha1($str . TOKEN);
- }
-
- function getUserId()
- {
- if (isset($_COOKIE['user_id'])) {
- return $_COOKIE['user_id'];
- /*
- $xm_data=$_COOKIE['xm_data'];
- $data=unserialize($xm_data);
- $id=$data['id'];
- $user=$data['user'];
- $checkToken=$data['token'];
- $list=$data['list'];
- $token=makeSign(array($id,$user,serialize($list)));
- if ($checkToken == $token){
- return $id;
- }else{
- return false;
- }*/
- } else {
- return false;
- }
- }
-
- function httpRequest($url, $data = null)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- if (!empty($data)) {
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output = curl_exec($ch);
- curl_close($ch);
- return $output;
- }
-
- function httpRequest2($url, $post_data)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- $json_data = curl_exec($ch);
- return $json_data;
- }
-
- /*
- function sendTelMessage($phones,$user_name,$content,$order_id){
- $send_data = array();
- $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
- $send_data["password"] = "175348";
- $send_data["phone"] = $phones;
- $send_data["message"] = '【蜘蛛行】'.$content;
- if (SEND_MESSAGE ==true){
- //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
- $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phones.'&message=【蜘蛛行】'.$content;
- //echo $url;
- $response=httpRequest($url,$send_data);
- // echo $response;die();
- writeLog('url'.$url."返回值".$response);
- }else{
- return array("未开启短信通知");
- }
- return $response;
- }
- */
- function sendTelMessage($phones, $user_name, $content, $order_id)
- {
- // $send_data = array();
- // $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
- // $send_data["password"] = "175348";
- // $send_data["phone"] = $phones;
- // $send_data["message"] = '【蜘蛛行】'.$content;
- // if (SEND_MESSAGE ==true){
- // //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
- // $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action';
- // //echo $url;
- // $response=httpRequest($url,$send_data);
- // // echo $response;die();
- // writeLog('url'.$url."返回值".$response);
- // }else{
- // return array("未开启短信通知");
- // }
-
- // $send_data = array();
- // $send_data["text"] = '【蜘蛛行】' . $content;
- // $send_data["apikey"] = "2f29960346a3b5be1131d6c782ec48b2";
- // $send_data["mobile"] = $phones;
- // $url = 'https://sms.yunpian.com/v2/sms/single_send.json';
- // if( strpos( $phones , ',') != false ) {
- // $url = 'https://sms.yunpian.com/v2/sms/batch_send.json';
- // }
- // $response = httpRequest2($url, $send_data);
- // $return_array = json_decode($response,true);
- // $error_code = $return_array["code"];
-
- if ($order_id == "") {
- $MAIN_CORP_ID = 1;
- } else {
- $sql = "select MAIN_CORP_ID from order_main where order_id = {$order_id}";
- $pdo = conn();
- $result = $pdo->query($sql);
- $result->setFetchMode(PDO::FETCH_ASSOC);
- $MAIN_CORP_ID = $result->fetchColumn();
- }
- if ($MAIN_CORP_ID == "34") {
- $sign = "【昆山集散中心】";
- } else if ($MAIN_CORP_ID == "36") {
- $sign = "【舟山群岛旅游】";
- } else if ($MAIN_CORP_ID == "37") {
- $sign = "【快行漫游】";
- } else {
- $sign = "【蜘蛛出行】";
- }
- $send_data = array();
- $send_data["account"] = "dh78301";
- $send_data["password"] = strtolower(md5("jGRk34B7"));
- $send_data["sign"] = $sign;
- $send_data["phones"] = $phones;
- $send_data["content"] = $content;
- $url = 'http://www.dh3t.com/json/sms/Submit';
- $response = send_post_json($url, urldecode(json_encode($send_data)));
- $error_code = $response[0] == 200 ? 0 : -1;
-
- writeLog('url' . $url . "|返回值" . $response);
- return $error_code;
- }
-
- function getDispAreaNameForCtrip($city_name)
- {
- $suzhou_array = array("拙政园", "观前街", "苏州汇融广场假日酒店", "苏州吴宫泛太平洋酒店", "苏州希尔顿逸林酒店");
- if (in_array($city_name, $suzhou_array)) {
- return "苏州";
- }
-
- $suzhou_array = array("舟山");
- if (in_array($city_name, $suzhou_array)) {
- return "普陀山";
- }
- /*
- $suzhou_array = array("南京禄口国际机场 ","南京禄口国际机场");
- if( in_array($city_name, $suzhou_array) ) {
- return "禄口机场";
- }
- */
- if (mb_strpos($city_name, "南京") !== false) {
- return "南京";
- }
- if (mb_strpos($city_name, "黄山") !== false) {
- return "黄山";
- }
- $suzhou_array = array("小红山客运站");
- if (in_array($city_name, $suzhou_array)) {
- return "南京";
- }
-
-
- if (mb_strlen($city_name, "utf-8") <= 2) {
- return $city_name;
- }
- $last_word = mb_substr($city_name, -1, 1, "utf-8");
- $cut_word = array("市", "区", "镇");
- if (in_array($last_word, $cut_word)) {
- return mb_substr($city_name, 0, mb_strlen($city_name, "utf-8") - 1, "utf-8");
- }
- return $city_name;
- }
-
- function getDispAreaNameForCtrip2($city_name, $type = 1)
- {
- $suzhou_array = array("拙政园", "观前街", "苏州汇融广场假日酒店");
- if (in_array($city_name, $suzhou_array)) {
- return "苏州";
- }
-
- $suzhou_array = array("舟山");
- if (in_array($city_name, $suzhou_array)) {
- if ($type == 2) {
- return "朱家尖";
- } else {
- return "普陀";
- }
- }
-
- if (mb_strlen($city_name, "utf-8") <= 2) {
- return $city_name;
- }
- $last_word = mb_substr($city_name, -1, 1, "utf-8");
- $cut_word = array("市", "区", "镇");
- if (in_array($last_word, $cut_word)) {
- return mb_substr($city_name, 0, mb_strlen($city_name, "utf-8") - 1, "utf-8");
- }
- return $city_name;
- }
-
- function getDispResNameForCtrip($res_name)
- {
- if ($res_name == "浦东国际机场T1" || $res_name == "浦东国际机场T2") {
- return "浦东机场";
- };
- if ($res_name == "禄口机场") {
- return "禄口国际机场";
- };
- if ($res_name == "小红山客运站") {
- return "小红山汽车客运站";
- };
- return $res_name;
- }
-
- function set_memcache($key, $value)
- {
- $mem = new Memcache;
- $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
- $mem->set($key, $value, 0, 3600 * 24 * 7);
- }
-
- function get_memcache($key)
- {
- $mem = new Memcache;
- $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
- $value = $mem->get($key);
- return $value;
- }
-
- function delete_memcache($key)
- {
- $mem = new Memcache;
- $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
- $value = $mem->delete($key);
- return $value;
- }
-
- function clear_memcache()
- {
- $mem = new Memcache;
- $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
- $mem->flush();
- }
-
- function send_post_json($url, $data_string)
- {
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json; charset=utf-8',
- 'Content-Length: ' . strlen($data_string))
- );
- ob_start();
- curl_exec($ch);
- $return_content = ob_get_contents();
- ob_end_clean();
- $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
- return array($return_code, $return_content);
- }
-
- function send_mail($user, $pwd, $toemail, $title, $content)
- {
- include_once "../../../Common/Smtp.class.php";
- //******************** 配置信息 ********************************
- $smtpserver = "smtp.exmail.qq.com";//SMTP服务器
- $smtpserverport = 25;//SMTP服务器端口
- $smtpusermail = $user;//SMTP服务器的用户邮箱
- $smtpemailto = $toemail;//发送给谁
- $smtpuser = $user;//SMTP服务器的用户帐号,注:部分邮箱只需@前面的用户名
- $smtppass = $pwd;//SMTP服务器的用户密码
- $mailtitle = $title;//邮件主题
- $mailcontent = "<h1>" . $content . "</h1>";//邮件内容
- $mailtype = "HTML";//邮件格式(HTML/TXT),TXT为文本邮件
- //************************ 配置信息 ****************************
- set_time_limit(0);
- $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
- $smtp->debug = false;//是否显示发送的调试信息
- $state = $smtp->sendmail($smtpemailto, $smtpusermail, $mailtitle, $mailcontent, $mailtype);
- if ($state == "") {
- $data['code'] = '1';
- $data['info'] = '邮件发送失败,请联系管理员';
- } else {
- $data['code'] = '0';
- $data['info'] = '邮件发送成功';
- }
- return $data;
- }
|