Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.
 
 
 
 

122 linhas
3.2 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['user_id'])){
  31. return $_COOKIE['user_id'];
  32. /*
  33. $xm_data=$_COOKIE['xm_data'];
  34. $data=unserialize($xm_data);
  35. $id=$data['id'];
  36. $user=$data['user'];
  37. $checkToken=$data['token'];
  38. $list=$data['list'];
  39. $token=makeSign(array($id,$user,serialize($list)));
  40. if ($checkToken == $token){
  41. return $id;
  42. }else{
  43. return false;
  44. }*/
  45. }else{
  46. return false;
  47. }
  48. }
  49. function httpRequest($url,$data=null){
  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 sendTelMessage($phones,$user_name,$content,$order_id){
  64. $send_data = array();
  65. $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
  66. $send_data["password"] = "175348";
  67. $send_data["phone"] = $phones;
  68. $send_data["message"] = '【蜘蛛行】'.$content;
  69. if (SEND_MESSAGE ==true){
  70. //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
  71. $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action';
  72. //echo $url;
  73. $response=httpRequest($url,$send_data);
  74. // echo $response;die();
  75. writeLog('url'.$url."返回值".$response);
  76. }else{
  77. return array("未开启短信通知");
  78. }
  79. return $response;
  80. }
  81. function getDispAreaNameForCtrip( $city_name ) {
  82. $suzhou_array = array("拙政园","观前街");
  83. if( in_array($city_name, $suzhou_array) ) {
  84. return "苏州";
  85. }
  86. if( mb_strlen($city_name) <= 2 ) { return $city_name;}
  87. $last_word = mb_substr($city_name,-1,1);
  88. $cut_word = array("市","区","镇");
  89. if( in_array($last_word,$cut_word) ) {
  90. return mb_substr($city_name,0,mb_strlen($city_name)-1);
  91. }
  92. return $city_name;
  93. }
  94. function set_memcache( $key, $value ) {
  95. $mem = new Memcache;
  96. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  97. $mem->set( $key, $value, 0, 3600*24*7 );
  98. }
  99. function get_memcache( $key ) {
  100. $mem = new Memcache;
  101. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  102. $value = $mem->get( $key );
  103. return $value;
  104. }
  105. function delete_memcache( $key ) {
  106. $mem = new Memcache;
  107. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  108. $value = $mem->delete($key);
  109. return $value;
  110. }
  111. function clear_memcache() {
  112. $mem = new Memcache;
  113. $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
  114. $mem->flush();
  115. }