You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

316 lines
9.7 KiB

  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. function writeLog($log)
  7. {
  8. $dir = __DIR__ . "/../Log/";
  9. if (!is_dir($dir)) {
  10. mkdir($dir);
  11. }
  12. $filename = $dir . date("Y-m-d") . ".log";
  13. $need_chmod = file_exists($filename);
  14. file_put_contents($filename, date("Y-m-d H:i:s") . "\t" . $log . PHP_EOL, FILE_APPEND);
  15. if ($need_chmod == false) {
  16. @chmod($filename, 0777);
  17. }
  18. }
  19. function makeSign($array)
  20. {
  21. $str = '';
  22. foreach ($array as $v) {
  23. $str .= $v;
  24. }
  25. return sha1($str . TOKEN);
  26. }
  27. function getUserId()
  28. {
  29. if (isset($_COOKIE['user_id'])) {
  30. return $_COOKIE['user_id'];
  31. /*
  32. $xm_data=$_COOKIE['xm_data'];
  33. $data=unserialize($xm_data);
  34. $id=$data['id'];
  35. $user=$data['user'];
  36. $checkToken=$data['token'];
  37. $list=$data['list'];
  38. $token=makeSign(array($id,$user,serialize($list)));
  39. if ($checkToken == $token){
  40. return $id;
  41. }else{
  42. return false;
  43. }*/
  44. } else {
  45. return false;
  46. }
  47. }
  48. function httpRequest($url, $data = null)
  49. {
  50. $ch = curl_init();
  51. curl_setopt($ch, CURLOPT_URL, $url);
  52. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  53. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  54. if (!empty($data)) {
  55. curl_setopt($ch, CURLOPT_POST, 1);
  56. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  57. }
  58. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  59. $output = curl_exec($ch);
  60. curl_close($ch);
  61. return $output;
  62. }
  63. function httpRequest2($url, $post_data)
  64. {
  65. $ch = curl_init();
  66. curl_setopt($ch, CURLOPT_URL, $url);
  67. curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));
  68. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  69. $json_data = curl_exec($ch);
  70. return $json_data;
  71. }
  72. /*
  73. function sendTelMessage($phones,$user_name,$content,$order_id){
  74. $send_data = array();
  75. $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  76. $send_data["password"] = "175348";
  77. $send_data["phone"] = $phones;
  78. $send_data["message"] = '【蜘蛛行】'.$content;
  79. if (SEND_MESSAGE ==true){
  80. //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  81. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phones.'&message=【蜘蛛行】'.$content;
  82. //echo $url;
  83. $response=httpRequest($url,$send_data);
  84. // echo $response;die();
  85. writeLog('url'.$url."返回值".$response);
  86. }else{
  87. return array("未开启短信通知");
  88. }
  89. return $response;
  90. }
  91. */
  92. function sendTelMessage($phones, $user_name, $content, $order_id)
  93. {
  94. // $send_data = array();
  95. // $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  96. // $send_data["password"] = "175348";
  97. // $send_data["phone"] = $phones;
  98. // $send_data["message"] = '【蜘蛛行】'.$content;
  99. // if (SEND_MESSAGE ==true){
  100. // //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  101. // $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action';
  102. // //echo $url;
  103. // $response=httpRequest($url,$send_data);
  104. // // echo $response;die();
  105. // writeLog('url'.$url."返回值".$response);
  106. // }else{
  107. // return array("未开启短信通知");
  108. // }
  109. // $send_data = array();
  110. // $send_data["text"] = '【蜘蛛行】' . $content;
  111. // $send_data["apikey"] = "2f29960346a3b5be1131d6c782ec48b2";
  112. // $send_data["mobile"] = $phones;
  113. // $url = 'https://sms.yunpian.com/v2/sms/single_send.json';
  114. // if( strpos( $phones , ',') != false ) {
  115. // $url = 'https://sms.yunpian.com/v2/sms/batch_send.json';
  116. // }
  117. // $response = httpRequest2($url, $send_data);
  118. // $return_array = json_decode($response,true);
  119. // $error_code = $return_array["code"];
  120. if ($order_id == "") {
  121. $MAIN_CORP_ID = 1;
  122. } else {
  123. $sql = "select MAIN_CORP_ID from order_main where order_id = {$order_id}";
  124. $pdo = conn();
  125. $result = $pdo->query($sql);
  126. $result->setFetchMode(PDO::FETCH_ASSOC);
  127. $MAIN_CORP_ID = $result->fetchColumn();
  128. }
  129. if ($MAIN_CORP_ID == "34") {
  130. $sign = "【昆山集散中心】";
  131. } else if ($MAIN_CORP_ID == "36") {
  132. $sign = "【舟山群岛旅游】";
  133. } else if ($MAIN_CORP_ID == "37") {
  134. $sign = "【快行漫游】";
  135. } else {
  136. $sign = "【蜘蛛出行】";
  137. }
  138. $send_data = array();
  139. $send_data["account"] = "dh78301";
  140. $send_data["password"] = strtolower(md5("jGRk34B7"));
  141. $send_data["sign"] = $sign;
  142. $send_data["phones"] = $phones;
  143. $send_data["content"] = $content;
  144. $url = 'http://www.dh3t.com/json/sms/Submit';
  145. $response = send_post_json($url, urldecode(json_encode($send_data)));
  146. $error_code = $response[0] == 200 ? 0 : -1;
  147. writeLog('url' . $url . "|返回值" . $response);
  148. return $error_code;
  149. }
  150. function getDispAreaNameForCtrip($city_name)
  151. {
  152. $suzhou_array = array("拙政园", "观前街", "苏州汇融广场假日酒店", "苏州吴宫泛太平洋酒店", "苏州希尔顿逸林酒店");
  153. if (in_array($city_name, $suzhou_array)) {
  154. return "苏州";
  155. }
  156. $suzhou_array = array("舟山");
  157. if (in_array($city_name, $suzhou_array)) {
  158. return "普陀山";
  159. }
  160. /*
  161. $suzhou_array = array("南京禄口国际机场 ","南京禄口国际机场");
  162. if( in_array($city_name, $suzhou_array) ) {
  163. return "禄口机场";
  164. }
  165. */
  166. if (mb_strpos($city_name, "南京") !== false) {
  167. return "南京";
  168. }
  169. if (mb_strpos($city_name, "黄山") !== false) {
  170. return "黄山";
  171. }
  172. $suzhou_array = array("小红山客运站");
  173. if (in_array($city_name, $suzhou_array)) {
  174. return "南京";
  175. }
  176. if (mb_strlen($city_name, "utf-8") <= 2) {
  177. return $city_name;
  178. }
  179. $last_word = mb_substr($city_name, -1, 1, "utf-8");
  180. $cut_word = array("市", "区", "镇");
  181. if (in_array($last_word, $cut_word)) {
  182. return mb_substr($city_name, 0, mb_strlen($city_name, "utf-8") - 1, "utf-8");
  183. }
  184. return $city_name;
  185. }
  186. function getDispAreaNameForCtrip2($city_name, $type = 1)
  187. {
  188. $suzhou_array = array("拙政园", "观前街", "苏州汇融广场假日酒店");
  189. if (in_array($city_name, $suzhou_array)) {
  190. return "苏州";
  191. }
  192. $suzhou_array = array("舟山");
  193. if (in_array($city_name, $suzhou_array)) {
  194. if ($type == 2) {
  195. return "朱家尖";
  196. } else {
  197. return "普陀";
  198. }
  199. }
  200. if (mb_strlen($city_name, "utf-8") <= 2) {
  201. return $city_name;
  202. }
  203. $last_word = mb_substr($city_name, -1, 1, "utf-8");
  204. $cut_word = array("市", "区", "镇");
  205. if (in_array($last_word, $cut_word)) {
  206. return mb_substr($city_name, 0, mb_strlen($city_name, "utf-8") - 1, "utf-8");
  207. }
  208. return $city_name;
  209. }
  210. function getDispResNameForCtrip($res_name)
  211. {
  212. if ($res_name == "浦东国际机场T1" || $res_name == "浦东国际机场T2") {
  213. return "浦东机场";
  214. };
  215. if ($res_name == "禄口机场") {
  216. return "禄口国际机场";
  217. };
  218. if ($res_name == "小红山客运站") {
  219. return "小红山汽车客运站";
  220. };
  221. return $res_name;
  222. }
  223. function set_memcache($key, $value)
  224. {
  225. $mem = new Memcache;
  226. $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
  227. $mem->set($key, $value, 0, 3600 * 24 * 7);
  228. }
  229. function get_memcache($key)
  230. {
  231. $mem = new Memcache;
  232. $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
  233. $value = $mem->get($key);
  234. return $value;
  235. }
  236. function delete_memcache($key)
  237. {
  238. $mem = new Memcache;
  239. $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
  240. $value = $mem->delete($key);
  241. return $value;
  242. }
  243. function clear_memcache()
  244. {
  245. $mem = new Memcache;
  246. $mem->connect(MEMCACHE_HOST, MEMCACHE_PORT);
  247. $mem->flush();
  248. }
  249. function send_post_json($url, $data_string)
  250. {
  251. $ch = curl_init();
  252. curl_setopt($ch, CURLOPT_POST, 1);
  253. curl_setopt($ch, CURLOPT_URL, $url);
  254. curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  255. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  256. 'Content-Type: application/json; charset=utf-8',
  257. 'Content-Length: ' . strlen($data_string))
  258. );
  259. ob_start();
  260. curl_exec($ch);
  261. $return_content = ob_get_contents();
  262. ob_end_clean();
  263. $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
  264. return array($return_code, $return_content);
  265. }
  266. function send_mail($user, $pwd, $toemail, $title, $content)
  267. {
  268. include_once "../../../Common/Smtp.class.php";
  269. //******************** 配置信息 ********************************
  270. $smtpserver = "smtp.exmail.qq.com";//SMTP服务器
  271. $smtpserverport = 25;//SMTP服务器端口
  272. $smtpusermail = $user;//SMTP服务器的用户邮箱
  273. $smtpemailto = $toemail;//发送给谁
  274. $smtpuser = $user;//SMTP服务器的用户帐号,注:部分邮箱只需@前面的用户名
  275. $smtppass = $pwd;//SMTP服务器的用户密码
  276. $mailtitle = $title;//邮件主题
  277. $mailcontent = "<h1>" . $content . "</h1>";//邮件内容
  278. $mailtype = "HTML";//邮件格式(HTML/TXT),TXT为文本邮件
  279. //************************ 配置信息 ****************************
  280. set_time_limit(0);
  281. $smtp = new Smtp($smtpserver, $smtpserverport, true, $smtpuser, $smtppass);//这里面的一个true是表示使用身份验证,否则不使用身份验证.
  282. $smtp->debug = false;//是否显示发送的调试信息
  283. $state = $smtp->sendmail($smtpemailto, $smtpusermail, $mailtitle, $mailcontent, $mailtype);
  284. if ($state == "") {
  285. $data['code'] = '1';
  286. $data['info'] = '邮件发送失败,请联系管理员';
  287. } else {
  288. $data['code'] = '0';
  289. $data['info'] = '邮件发送成功';
  290. }
  291. return $data;
  292. }