123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110 |
- <?php
-
- function api_result( $status, $text, $deviceId ){
- echo json_encode(array('status'=>$status,'statustext'=>$text),JSON_UNESCAPED_UNICODE);
- debug_post_log('api_result_log','deviceId '.$deviceId.' status:'.$status.' statustext'.$text);
- exit;
-
- }
-
-
- function send_post_message( $data ){
- //dump($data);
- $post_data=array(
- 'TransId'=>'',
- 'Seq'=>0,
- 'MsgType'=>$data['MsgType'],
- 'DevAddress'=>'192.168.1.10:9996',
- 'DeviceId'=>$data['imei']['value'],
- 'DevType'=>'0',
- 'Data'=>array('ResultAck'=>$data['result']),
- );
-
- $url='http://openapi.rltest.cn/v1/receive_message';
- $postFields = json_encode($post_data);
- $ch = curl_init ();
- curl_setopt( $ch, CURLOPT_URL, $url );
- curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json; charset=utf-8'));
- curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 );
- curl_setopt( $ch, CURLOPT_POST, 1 );
- curl_setopt( $ch, CURLOPT_POSTFIELDS, $postFields);
- curl_setopt( $ch, CURLOPT_TIMEOUT,1);
- curl_setopt( $ch, CURLOPT_SSL_VERIFYHOST, 0);
- curl_setopt( $ch, CURLOPT_SSL_VERIFYPEER, 0);
- $res=curl_exec ( $ch );
- var_dump($res);
- //echo $res;
-
- }
-
-
- function debug_log( $filename, $data ){
- if(!APP_DEBUG){
- return;
- }
- $file = SOLUTION_LOG_PATH .debug .'/'.date("Ymd", time()) ."/".$filename.".log";
- $folder=dirname($file);
- if (!is_dir($folder)){
- mkdir($folder,0777,true);
- }
- //echo '[' . date('Y-m-d H:i:s') . ']' . $data . PHP_EOL;
- file_put_contents($file, '[' . date('Y-m-d H:i:s') . ']' . $data . PHP_EOL,FILE_APPEND);
- }
-
-
- function result_error_log( $data ){
- $file = SOLUTION_LOG_PATH.error.'/'.date("Y-m-d", time()) ."/"."error.log";
- $folder=dirname($file);
- if (!is_dir($folder)){
- mkdir($folder,0777,true);
- }
- //echo '[' . date('Y-m-d H:i:s') . ']' . $data . PHP_EOL;
- file_put_contents($file, '[' . date('Y-m-d H:i:s') . ']' . $data . PHP_EOL,FILE_APPEND);
- }
-
-
- function scanTargetFile( $dir, $ext ){
- $files = '';
- if($head = opendir($dir))
- {
- while(($file = readdir($head)) !== false)
- {
- if($file != ".." && $file!=".")
- {
- if(is_dir($dir.'/'.$file))
- {
- $files.=scanTargetFile($dir.'/'.$file);
- }
- else
- {
- $path = $dir.'/'.$file;
- $pathInfo = pathinfo($path);
- if($pathInfo['extension'] != 'md5'){
- continue;
- }
- $files.=$path . ';';
- }
- }
- }
- }
- closedir($head);
- return $files;
- }
-
-
- function debug_post_log( ){
- if(!APP_DEBUG){
- return;
- }
- $file = SOLUTION_LOG_PATH .debug .'/'.date("Y-m-d", time()) ."/".$filename.".log";
- $folder=dirname($file);
- if (!is_dir($folder)){
- mkdir($folder,0777,true);
- }
- //echo '[' . date('Y-m-d H:i:s') . ']' . $data . PHP_EOL;
- file_put_contents($file, '[' . date('Y-m-d H:i:s') . ']' . $data . PHP_EOL,FILE_APPEND);
- }
-
|