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.
 
 
 
 

130 lines
3.7 KiB

  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. file_put_contents($filename, date("Y-m-d H:i:s")."\t".$log.PHP_EOL,FILE_APPEND);
  13. }
  14. function makeSign($array){
  15. $str='';
  16. foreach ($array as $v){
  17. $str.=$v;
  18. }
  19. return sha1($str.TOKEN);
  20. }
  21. //获取唯一的id
  22. function getUniqeId(){
  23. $pdo= conn();
  24. $result=$pdo->query("select FUNC_GET_UNIQUE_ID('1','1') id");
  25. $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
  26. $pdo=NULL;
  27. return $rowset[0]['id'];
  28. }
  29. function getUserId(){
  30. if (isset($_COOKIE['xm_data'])){
  31. $xm_data=$_COOKIE['xm_data'];
  32. $data=unserialize($xm_data);
  33. $id=$data['id'];
  34. $user=$data['user'];
  35. $checkToken=$data['token'];
  36. $list=$data['list'];
  37. $token=makeSign(array($id,$user,serialize($list)));
  38. if ($checkToken == $token){
  39. return $id;
  40. }else{
  41. return false;
  42. }
  43. }else{
  44. return false;
  45. }
  46. }
  47. function httpRequest($url,$data=null){
  48. $ch=curl_init();
  49. curl_setopt($ch, CURLOPT_URL, $url);
  50. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  51. curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
  52. if (!empty($data)){
  53. curl_setopt($ch, CURLOPT_POST, 1);
  54. curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
  55. }
  56. curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  57. $output=curl_exec($ch);
  58. curl_close($ch);
  59. return $output;
  60. }
  61. //function sendTelMessage($phones,$user_name,$content,$order_id){
  62. // if (SEND_MESSAGE ==true){
  63. // //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  64. // $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phones.'&message=【蜘蛛行】'.$content;
  65. // $response=httpRequest($url);
  66. // writeLog('url'.$url."返回值".$response);
  67. // }else{
  68. // return array("未开启短信通知");
  69. // }
  70. // return $response;
  71. //}
  72. function sendTelMessage($phones,$user_name,$content,$order_id){
  73. $send_data = array();
  74. $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  75. $send_data["password"] = "175348";
  76. $send_data["phone"] = $phones;
  77. $send_data["message"] = '【蜘蛛行】'.$content;
  78. if (SEND_MESSAGE ==true){
  79. //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  80. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action';
  81. //echo $url;
  82. $response=httpRequest($url,$send_data);
  83. // echo $response;die();
  84. writeLog('url'.$url."返回值".$response);
  85. }else{
  86. return array("未开启短信通知");
  87. }
  88. return $response;
  89. }
  90. function getDispAreaNameForCtrip( $city_name ) {
  91. $suzhou_array = array("拙政园","观前街");
  92. if( in_array($city_name, $suzhou_array) ) {
  93. return "苏州";
  94. }
  95. if( mb_strlen($city_name) <= 2 ) { return $city_name;}
  96. $last_word = mb_substr($city_name,-1,1);
  97. $cut_word = array("市","区","镇");
  98. if( in_array($last_word,$cut_word) ) {
  99. return mb_substr($city_name,0,mb_strlen($city_name)-1);
  100. }
  101. return $city_name;
  102. }
  103. function set_memcache( $key, $value ) {
  104. $mem = new Memcache;
  105. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  106. $mem->set( $key, $value, 0, 3600*24*7 );
  107. }
  108. function get_memcache( $key ) {
  109. $mem = new Memcache;
  110. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  111. $value = $mem->get( $key );
  112. return $value;
  113. }
  114. function delete_memcache( $key ) {
  115. $mem = new Memcache;
  116. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  117. $value = $mem->delete($key);
  118. return $value;
  119. }
  120. function clear_memcache() {
  121. $mem = new Memcache;
  122. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  123. $mem->flush();
  124. }