|
- <?php
- /*
- Author:XM
- Compeny:Spiders Travel
- */
- function writeLog($log){
- $dir=__DIR__."/../Log/";
- if (!is_dir($dir)){
- mkdir($dir);
- }
- $filename=$dir.date("Y-m-d").".log";
- file_put_contents($filename, date("Y-m-d H:i:s")."\t".$log.PHP_EOL,FILE_APPEND);
- }
- function makeSign($array){
- $str='';
- foreach ($array as $v){
- $str.=$v;
- }
- return sha1($str.TOKEN);
- }
- //获取唯一的id
- function getUniqeId(){
- $pdo= conn();
- $result=$pdo->query("select FUNC_GET_UNIQUE_ID('1','1') id");
- $rowset = $result -> fetchAll(PDO::FETCH_ASSOC);
- $pdo=NULL;
-
- return $rowset[0]['id'];
- }
-
-
- function getUserId(){
- if (isset($_COOKIE['xm_data'])){
- $xm_data=$_COOKIE['xm_data'];
- $data=unserialize($xm_data);
- $id=$data['id'];
- $user=$data['user'];
- $checkToken=$data['token'];
- $list=$data['list'];
- $token=makeSign(array($id,$user,serialize($list)));
- if ($checkToken == $token){
- return $id;
- }else{
- return false;
- }
- }else{
- return false;
- }
- }
- function httpRequest($url,$data=null){
- $ch=curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
- if (!empty($data)){
- curl_setopt($ch, CURLOPT_POST, 1);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
- }
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- $output=curl_exec($ch);
- curl_close($ch);
- return $output;
- }
- //function sendTelMessage($phones,$user_name,$content,$order_id){
- // if (SEND_MESSAGE ==true){
- // //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
- // $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action?cdkey=8SDK-EMY-6699-RISUM&password=175348&phone='.$phones.'&message=【蜘蛛行】'.$content;
- // $response=httpRequest($url);
- // writeLog('url'.$url."返回值".$response);
- // }else{
- // return array("未开启短信通知");
- // }
- // return $response;
- //}
- function sendTelMessage($phones,$user_name,$content,$order_id){
- $send_data = array();
- $send_data["cdkey"] = "8SDK-EMY-6699-RISUM";
- $send_data["password"] = "175348";
- $send_data["phone"] = $phones;
- $send_data["message"] = '【蜘蛛行】'.$content;
- if (SEND_MESSAGE ==true){
- //$url='http://www.mxtong.net.cn/GateWay/Services.asmx/DirectSend?UserID=995596&Account=alert&Password=zzcx8888&Phones='.$phones.'&Content='.$content.'【蜘蛛行】&SendTime=&SendType=1&PostFixNumber=';
- $url='http://hprpt2.eucp.b2m.cn:8080/sdkproxy/sendsms.action';
- //echo $url;
- $response=httpRequest($url,$send_data);
- // echo $response;die();
- writeLog('url'.$url."返回值".$response);
- }else{
- return array("未开启短信通知");
- }
- return $response;
- }
- function getDispAreaNameForCtrip( $city_name ) {
- $suzhou_array = array("拙政园","观前街");
- if( in_array($city_name, $suzhou_array) ) {
- return "苏州";
- }
-
- if( mb_strlen($city_name) <= 2 ) { return $city_name;}
- $last_word = mb_substr($city_name,-1,1);
- $cut_word = array("市","区","镇");
- if( in_array($last_word,$cut_word) ) {
- return mb_substr($city_name,0,mb_strlen($city_name)-1);
- }
- return $city_name;
- }
- function set_memcache( $key, $value ) {
- $mem = new Memcache;
- $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
- $mem->set( $key, $value, 0, 3600*24*7 );
- }
- function get_memcache( $key ) {
- $mem = new Memcache;
- $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
- $value = $mem->get( $key );
- return $value;
- }
- function delete_memcache( $key ) {
- $mem = new Memcache;
- $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
- $value = $mem->delete($key);
- return $value;
- }
-
- function clear_memcache() {
- $mem = new Memcache;
- $mem->connect( MEMCACHE_HOST, MEMCACHE_PORT );
- $mem->flush();
- }
|