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.

преди 3 години
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <?php
  2. /*
  3. Author:XM
  4. Compeny:Spiders Travel
  5. */
  6. function writeLog($log){
  7. $dir=__DIR__."/../Log/";
  8. if (!is_dir($dir)){
  9. mkdir($dir);
  10. }
  11. $filename=$dir.date("Y-m-d").".log";
  12. $need_chmod = file_exists($filename);
  13. file_put_contents($filename, date("Y-m-d H:i:s")."\t".$log.PHP_EOL,FILE_APPEND);
  14. if( $need_chmod == false ) {
  15. @chmod( $filename, 0777);
  16. }
  17. }
  18. function makeSign($array){
  19. $str='';
  20. foreach ($array as $v){
  21. $str.=$v;
  22. }
  23. return sha1($str.TOKEN);
  24. }
  25. function getUserId(){
  26. if (isset($_COOKIE['xm_data'])){
  27. $xm_data=$_COOKIE['xm_data'];
  28. $data=unserialize($xm_data);
  29. $id=$data['id'];
  30. $user=$data['user'];
  31. $checkToken=$data['token'];
  32. $list=$data['list'];
  33. $token=makeSign(array($id,$user,serialize($list)));
  34. if ($checkToken == $token){
  35. return $id;
  36. }else{
  37. return false;
  38. }
  39. }else{
  40. return false;
  41. }
  42. }
  43. function httpRequest($url,$data=null){
  44. $ch=curl_init();
  45. curl_setopt($ch, CURLOPT_URL, $url);
  46. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  47. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  48. if (!empty($data)){
  49. curl_setopt($ch, CURLOPT_POST, 1);
  50. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  51. }
  52. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  53. $output=curl_exec($ch);
  54. curl_close($ch);
  55. return $output;
  56. }
  57. /*
  58. function sendTelMessage($phones,$user_name,$content,$order_id){
  59. $send_data = array();
  60. $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  61. $send_data["password"] = "175348";
  62. $send_data["phone"] = $phones;
  63. $send_data["message"] = '【蜘蛛行】'.$content;
  64. if (SEND_MESSAGE ==true){
  65. //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  66. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phones.'&message=【蜘蛛行】'.$content;
  67. //echo $url;
  68. $response=httpRequest($url,$send_data);
  69. // echo $response;die();
  70. writeLog('url'.$url."返回值".$response);
  71. }else{
  72. return array("未开启短信通知");
  73. }
  74. return $response;
  75. }
  76. */
  77. function sendTelMessage($phones,$user_name,$content,$order_id){
  78. $send_data = array();
  79. $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  80. $send_data["password"] = "175348";
  81. $send_data["phone"] = $phones;
  82. $send_data["message"] = '【蜘蛛行】'.$content;
  83. if (SEND_MESSAGE ==true){
  84. //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  85. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action';
  86. //echo $url;
  87. $response=httpRequest($url,$send_data);
  88. // echo $response;die();
  89. writeLog('url'.$url."返回值".$response);
  90. }else{
  91. return array("未开启短信通知");
  92. }
  93. return $response;
  94. }
  95. function getDispAreaNameForCtrip( $city_name ) {
  96. $suzhou_array = array("拙政园","观前街","苏州汇融广场假日酒店","苏州吴宫泛太平洋酒店","苏州希尔顿逸林酒店");
  97. if( in_array($city_name, $suzhou_array) ) {
  98. return "苏州";
  99. }
  100. $suzhou_array = array("舟山");
  101. if( in_array($city_name, $suzhou_array) ) {
  102. return "普陀山";
  103. }
  104. /*
  105. $suzhou_array = array("南京禄口国际机场 ","南京禄口国际机场");
  106. if( in_array($city_name, $suzhou_array) ) {
  107. return "禄口机场";
  108. }
  109. */
  110. if (mb_strpos($city_name, "南京") !== false) {
  111. return "南京";
  112. }
  113. if (mb_strpos($city_name, "黄山") !== false) {
  114. return "黄山";
  115. }
  116. $suzhou_array = array("小红山客运站");
  117. if( in_array($city_name, $suzhou_array) ) {
  118. return "南京";
  119. }
  120. if( mb_strlen($city_name,"utf-8") <= 2 ) { return $city_name;}
  121. $last_word = mb_substr($city_name,-1,1,"utf-8");
  122. $cut_word = array("市","区","镇");
  123. if( in_array($last_word,$cut_word) ) {
  124. return mb_substr($city_name,0,mb_strlen($city_name,"utf-8")-1,"utf-8");
  125. }
  126. return $city_name;
  127. }
  128. function getDispAreaNameForCtrip2( $city_name, $type = 1 ) {
  129. $suzhou_array = array("拙政园","观前街","苏州汇融广场假日酒店");
  130. if( in_array($city_name, $suzhou_array) ) {
  131. return "苏州";
  132. }
  133. $suzhou_array = array("舟山");
  134. if( in_array($city_name, $suzhou_array) ) {
  135. if( $type == 2 ) {
  136. return "朱家尖";
  137. } else {
  138. return "普陀";
  139. }
  140. }
  141. if( mb_strlen($city_name,"utf-8") <= 2 ) { return $city_name;}
  142. $last_word = mb_substr($city_name,-1,1,"utf-8");
  143. $cut_word = array("市","区","镇");
  144. if( in_array($last_word,$cut_word) ) {
  145. return mb_substr($city_name,0,mb_strlen($city_name,"utf-8")-1,"utf-8");
  146. }
  147. return $city_name;
  148. }
  149. function getDispResNameForCtrip( $res_name ) {
  150. if( $res_name == "浦东国际机场T1" || $res_name == "浦东国际机场T2" ) { return "浦东机场"; };
  151. return $res_name;
  152. }
  153. function set_memcache( $key, $value ) {
  154. $mem = new Memcache;
  155. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  156. $mem->set( $key, $value, 0, 3600*24*7 );
  157. }
  158. function get_memcache( $key ) {
  159. $mem = new Memcache;
  160. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  161. $value = $mem->get( $key );
  162. return $value;
  163. }
  164. function delete_memcache( $key ) {
  165. $mem = new Memcache;
  166. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  167. $value = $mem->delete($key);
  168. return $value;
  169. }
  170. function clear_memcache() {
  171. $mem = new Memcache;
  172. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  173. $mem->flush();
  174. }