|
@@ -0,0 +1,109 @@
|
|
|
+<?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);
|
|
|
+ }
|
|
|
+
|
|
|
+
|