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. // if(WRITE_FILE_FLAG==true){
  8. // $dir=__DIR__."/../Log/";
  9. // if (!is_dir($dir)){
  10. // mkdir($dir);
  11. // }
  12. // $filename=$dir.date("Y-m-d").".log";
  13. // $backtrace = debug_backtrace()[0];
  14. // array_shift($backtrace);
  15. // $date=date("Y-m-d H:i:s");
  16. // $line=isset($backtrace['line'])?$backtrace['line']:"0";
  17. // $func=isset($backtrace['function'])?$backtrace['function']:"func";
  18. // $str="line ".$line."|".$date."|func=".$func."\t".$log;
  19. //
  20. // file_put_contents($filename, $str.PHP_EOL,FILE_APPEND);
  21. // }
  22. //}
  23. function writeLog($log){
  24. if(WRITE_FILE_FLAG==true){
  25. // $backtrace = debug_backtrace();
  26. // array_shift($backtrace);
  27. // $dir=__DIR__."/../Log/";
  28. // if (!is_dir($dir)){
  29. // mkdir($dir);
  30. // }
  31. // $filename=$dir.date("Y-m-d").".log";
  32. // $need_chmod = file_exists($filename);
  33. // $log_str=''.date("Y-m-d H:i:s").' ['. $backtrace[0]['class'].'.class.php] ['.$backtrace[0]['class'].'] ['.$backtrace[0]['function'].'] ['.$log.']';
  34. // file_put_contents($filename, $log_str.PHP_EOL,FILE_APPEND);
  35. // if( $need_chmod == false )
  36. // {
  37. // @chmod( $filename, 0777);
  38. // }
  39. $dir=__DIR__."/../Log/";
  40. if (!is_dir($dir)){
  41. mkdir($dir);
  42. }
  43. $filename=$dir.date("Y-m-d").".log";
  44. $need_chmod = file_exists($filename);
  45. file_put_contents($filename, date("Y-m-d H:i:s")."\t".$log.PHP_EOL,FILE_APPEND);
  46. if( $need_chmod == false ) {
  47. @chmod( $filename, 0777);
  48. }
  49. }
  50. }
  51. //判断参数是否为空
  52. function ifNullParam($param_arr){
  53. $data=array();
  54. $data['code']="0";
  55. $data['info']="";
  56. foreach ($param_arr as $k => $v) {
  57. if(empty($v) && $v!="0"){
  58. $data['code']="16";
  59. $data['info']="错误的请求参数";
  60. break;
  61. }
  62. }
  63. return $data;
  64. }
  65. function makeSign($array){
  66. $str='';
  67. foreach ($array as $v){
  68. $str.=$v;
  69. }
  70. return sha1($str."xm-zzcx8888!@#");
  71. }
  72. function getUserId(){
  73. if(isset($_COOKIE['user_id'])){
  74. return $_COOKIE['user_id'];
  75. }else{
  76. return false;
  77. }
  78. // if (isset($_COOKIE['xm_data'])){
  79. // $xm_data=$_COOKIE['xm_data'];
  80. // $data=unserialize($xm_data);
  81. // $id=$data['id'];
  82. // $user=$data['user'];
  83. // $checkToken=$data['token'];
  84. // $list=$data['list'];
  85. // $token=makeSign(array($id,$user,serialize($list)));
  86. // if ($checkToken == $token){
  87. // return $id;
  88. // }else{
  89. // return false;
  90. // }
  91. // }else{
  92. // return false;
  93. // }
  94. }
  95. function httpRequest($url,$data=null){
  96. $ch=curl_init();
  97. curl_setopt($ch, CURLOPT_URL, $url);
  98. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  99. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  100. if (!empty($data)){
  101. curl_setopt($ch, CURLOPT_POST, 1);
  102. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  103. }
  104. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  105. $output=curl_exec($ch);
  106. curl_close($ch);
  107. return $output;
  108. }
  109. /*
  110. function sendTelMessage($phones,$user_name,$content,$order_id){
  111. $send_data = array();
  112. $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  113. $send_data["password"] = "175348";
  114. $send_data["phone"] = $phones;
  115. $send_data["message"] = '【蜘蛛行】'.$content;
  116. if (SEND_MESSAGE ==true){
  117. //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  118. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phones.'&message=【蜘蛛行】'.$content;
  119. //echo $url;
  120. $response=httpRequest($url,$send_data);
  121. // echo $response;die();
  122. writeLog('url'.$url."返回值".$response);
  123. }else{
  124. return array("未开启短信通知");
  125. }
  126. return $response;
  127. }
  128. */
  129. function sendTelMessage($phones,$content){
  130. $send_data = array();
  131. $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  132. $send_data["password"] = "175348";
  133. $send_data["phone"] = $phones;
  134. $send_data["message"] = '【蜘蛛行】'.$content;
  135. if (SEND_MESSAGE ==true){
  136. //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  137. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action';
  138. //echo $url;
  139. $response=httpRequest($url,$send_data);
  140. // echo $response;die();
  141. writeLog('url'.$url."返回值".$response);
  142. }else{
  143. return array("未开启短信通知");
  144. }
  145. return $response;
  146. }
  147. function getDispAreaNameForCtrip( $city_name ) {
  148. $suzhou_array = array("拙政园","观前街");
  149. if( in_array($city_name, $suzhou_array) ) {
  150. return "苏州";
  151. }
  152. if( mb_strlen($city_name) <= 2 ) { return $city_name;}
  153. $last_word = mb_substr($city_name,-1,1);
  154. $cut_word = array("市","区","镇");
  155. if( in_array($last_word,$cut_word) ) {
  156. return mb_substr($city_name,0,mb_strlen($city_name)-1);
  157. }
  158. return $city_name;
  159. }
  160. function set_memcache( $key, $value ) {
  161. $mem = new Memcache;
  162. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  163. $mem->set( $key, $value, 0, 3600*24*7 );
  164. }
  165. function get_memcache( $key ) {
  166. $mem = new Memcache;
  167. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  168. $value = $mem->get( $key );
  169. return $value;
  170. }
  171. function clear_memcache() {
  172. $mem = new Memcache;
  173. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  174. $mem->flush();
  175. }