Skip to content

Instantly share code, notes, and snippets.

@sdon2
Last active October 18, 2022 06:19
Show Gist options
  • Save sdon2/6c613881e64ea9764b7b8a5cfe2a468b to your computer and use it in GitHub Desktop.
Save sdon2/6c613881e64ea9764b7b8a5cfe2a468b to your computer and use it in GitHub Desktop.
<?php
include_once('./db.class.php');
include_once('./fun.php');
ini_set('memory_limit', '-1');
set_time_limit(0);
//echo date('Y-m-d H:i:s',time())."<br/>";
$http_url='http://'.$_SERVER['HTTP_HOST'].':'.$_SERVER["SERVER_PORT"];
$db = new Db();
$_hd_url='http://'.$_SERVER['SERVER_NAME'].':'.$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
$sql="select * from fa_user_upload where (synchro_status=2 or synchro_status=0) and did=0 order by id asc limit 0,1 ";
$name_res = mysqli_fetch_all($db->execute($sql),MYSQLI_ASSOC);
if(empty($name_res)){
sleep(2);
$uri="./statistics.php?rand=".rand();
header('Location:'.$uri);
exit;
}
$id=$name_res[0]['id'];
$name=$name_res[0]['name'];
$userid=$name_res[0]['user_id'];
$sn=$name_res[0]['sn'];
CreateTable($userid);
//文件名处理
//$name_arr= explode(".", $name_res[0]['name']);
$log_name=$name.".log";
$real_name=$name.".real";
if(!file_exists("../uploads/sd_file/".$userid."/".$log_name) || !file_exists("../uploads/sd_file/".$userid."/".$real_name)){
$log_up['synchro_status']=1;
$db->update($log_up,"fa_user_upload"," where name='".$name."'");
echo $name."的数据不全";
unlink("../uploads/sd_file/".$userid."/".$log_name);
unlink("../uploads/sd_file/".$userid."/".$real_name);
sleep(1);
$uri="./insert_data.php?round=".rand();
header('Location:'.$uri);
exit;
//header('Location: '. $_hd_url);
//header("refresh: 3");
//echo "no file";exit;
}
$pre_set_max=30;
$pre_set_min=4;
$sn_flag=substr($sn,0,1);
if($sn_flag<3){
$pre_set_max=20;
}else if($sn_flag>=3 && $sn_flag<7){
$pre_set_max=25;
}else{
$pre_set_max=30;
}
//内容获取
$log_data = file_get_contents("../uploads/sd_file/".$userid."/".$log_name, 'r');
$log_data=bin2hex($log_data);
$len=strlen($log_data);
if($len<10){
$log_up['synchro_status']=1;
$db->update($log_up,"fa_user_upload"," where name='".$name."'");
echo $name."的数据不全";
unlink("../uploads/sd_file/".$userid."/".$log_name);
unlink("../uploads/sd_file/".$userid."/".$real_name);
sleep(1);
$uri="./insert_data.php?rand=".rand();
header('Location:'.$uri);
exit;
}
echo $log_name."<br/>";
$data_time_arrs=array();
$arr=array();//默认数组
$_float=0;//标识
$t_str=0;//往后推的数
$l_float=0;
$log_float=0;//日志标识
for ($i = 0; $i < $len/10; $i++){
$_float=10*$i+$t_str;
$_str=substr($log_data, $_float,10);
$wi=0;
while(check_binstr($_str)==true){//如果前面2位是00,则补2位
$_float=$_float+2;
$_str=substr($log_data, $_float, 10);
$wi=$wi+2;
$t_str=$t_str+2;
}
$old_str=$_str;
$type=base_convert(substr($_str,0,2),16,2);//16进制转2进制,截取2位
$val1=base_convert(substr($_str,2,2),16,2);//第1个16进制参数
$val2=base_convert(substr($_str,4,2),16,2);//第2个16进制参数
$val3=base_convert(substr($_str,6,2),16,2);//第3个16进制参数
$val4=base_convert(substr($_str,8,2),16,2);//第4个16进制参数
if($type!='' && !empty($type) && $type!=0 && $type!=null){
$data_arr=array();
$type_flag=sprintf('%08s', $type);//自动补齐8位
$type_flag=substr($type_flag,1,5);//取1-5位
$type_flag=bindec($type_flag);
if($type_flag==18){//id
$id=get_val($type,$val1,$val2,$val3,$val4);
}
if($type_flag==1){//serialid
$serialid=get_val($type,$val1,$val2,$val3,$val4);
}
if($type_flag==2){//hapdate
$hapdate=get_val($type,$val1,$val2,$val3,$val4);
}
if($type_flag==3){//haptime
$haptime=get_val($type,$val1,$val2,$val3,$val4);
if($times_flag==0){
$times_flag=strtotime($hapdate." ".$haptime);
$del_start_time= $times_flag;
}else{
$times_flag=$times_flag;
}
$times=strtotime($hapdate." ".$haptime);
// echo $times."-".
$dif_times=$times-$time_float;
if($dif_times==2){
$times=$times-1;
$times_flag=$times;
}
}
if($type_flag==5){//close_event
//$close_event=get_val($type,$val1,$val2,$val3,$val4);
//有关机事件时候加入关机时间
$close_event=$times_flag;
}
if($type_flag==4){//open_event
$open_event=get_val($type,$val1,$val2,$val3,$val4);
}
if($type_flag==6 || $type_flag==7 || $type_flag==8 || $type_flag==9 || $type_flag==10 || $type_flag==11 || $type_flag==19|| $type_flag==23){//parameter
$event_time=get_val($type,$val1,$val2,$val3,$val4);
$event_type=$type_flag;
if($event_time==0){
$event_time=999;
}
// echo "aaa-".$times_flag."#".$event_type."#".$event_time."-bbb<br/>";
}
if($type_flag==12 || $type_flag==13 || $type_flag==14 || $type_flag==15 || $type_flag==20 || $type_flag==21 || $type_flag==22){//parameter
$parameters.=get_val($type,$val1,$val2,$val3,$val4);
if($type_flag==12){
$pressure_value_min_arr=explode("#",$parameters);
$pressure_value_min= $pressure_value_min_arr[1];
}
}
if($type_flag==13){//压力基值
//$pressure_value=get_val($type,$val1,$val2,$val3,$val4);
// $pressure_arr=explode("#",$pressure_value);
$val=get_val($type,$val1,$val2,$val3,$val4);
echo $val;
$pre_arr_set=explode("#",$val);
$pre_set_max=round($pre_arr_set[0]/10,1);//
$pre_set_min=round($pre_arr_set[1]/10,1);//
if($pre_set_max>30){
$pre_set_max=30;
}
if($pre_set_min<4){
$pre_set_min=4;
}
}
if($type_flag==16){//压力基值
$pressure_value=get_val($type,$val1,$val2,$val3,$val4);
//echo $pressure_value;
$pressure_arr=explode("#",$pressure_value);
$pressure_time=$pressure_arr[1];
$pressure_value=$pressure_arr[0];
//$data_arr['pressure_value']=$pressure_value;
}
if($type_flag==17){//漏气量
$vleak=get_val($type,$val1,$val2,$val3,$val4);
$vleak_arr=explode("#",$vleak);
//print_r($vleak_arr);
$vleak_time=$vleak_arr[1];
$i_float=0;
//echo $vleak_time;
//echo $time_float;
$data_arr['vleak']=$vleak_arr[0];
$data_arr['pressure_value']=$pressure_value;
$data_arr['pressure_value_min']=round($pressure_value_min/10,1);
$vleak_sum= $vleak_sum+$vleak_arr[0];
$pressure_value_sum= $pressure_value_sum+$pressure_value;
$data_arr['datatime']=$times_flag+$vleak_time;
$data_arr['id']='null';
$data_arr['dataid']=$id;
$data_arr['serialid']=$del_start_time;//改为时间段标识
$data_arr['sn']=$sn;
$data_arr['hapdate']=$hapdate;
//$data_arr['haptime']=$haptime;
//$data_arr['close_event']=$close_event;
//$data_arr['open_event']=$open_event;
//$data_arr['parameter']=$parameters;
$l_float=$l_float+1;
if($data_arr['vleaks']){
$data_arr['vleaks']=$data_arr['vleaks'].",".$vleak_arr[0];
}else{
$data_arr['vleaks']=$vleak_arr[0];
}
if($data_arr['pressure_values']){
$data_arr['pressure_values']=$data_arr['pressure_values'].",".$pressure_value;
}else{
$data_arr['pressure_values']=$pressure_value;
}
$i_float++;
$arr_times= $data_arr['datatime'];
if($vleak_time==0 && $l_float==1){
//$res=$db->insert($data_arr,"fa_statistic");
$data_arrs[]=$data_arr;
$data_time_arrs[$arr_times][]=$data_arr;
unset($vleak_sum);unset($pressure_value_sum);
}
if($l_float%2==0 && $vleak_time!=0){
$data_arr['vleak']=$vleak_sum/2;
//$data_arr['pressure_value']=$pressure_value_sum/10;
$data_arr['event_type']=$event_type;
$data_arr['event_time']=$event_time;
$data_time_arr=$data_arr;
//$res=@$db->insert($data_arr,"fa_statistic");
$data_time_arrs[$arr_times][]=$data_arr;
//$data_arr[]=array_column($data_arr, null, 'datatime');
$log_float=$log_float+1;
//echo $log_float."<br/>";
unset($vleak_sum);unset($pressure_value_sum);unset($event_type);unset($event_time);
}
if($vleak_time==100){
//print_r($data_time_arrs);exit;
}
//unset($data_arr);
}
}
}
//***********************************LOG解析完毕*************************************//
$real_data = file_get_contents("../uploads/sd_file/".$userid."/".$real_name, 'r');
$real_data=bin2hex($real_data);
$len=strlen($real_data);
$arr=array();
$_float=0;
$t_str=0;//往后推的数
$r_float=0;//压力行数标识数
$real_float=1;//入库标识数,20为一秒
$real_arr=$real_arrs=array();
$times_flag2=0;
for ($i = 0; $i < $len/8; $i++){
$_float=8*$i+$t_str;
$_str=substr($real_data, $_float,8);
$wi=0;
while(check_binstr($_str)==true){//如果前面2位是00,则补2位
$_float=$_float+2;
$_str=substr($real_data, $_float, 8);
$wi=$wi+2;
$t_str=$t_str+2;
}
$old_str=$_str;
$type=base_convert(substr($_str,0,2),16,2);//16进制转2进制,截取2位
$val1=base_convert(substr($_str,2,2),16,2);//第1个16进制参数
$val2=base_convert(substr($_str,4,2),16,2);//第2个16进制参数
$val3=base_convert(substr($_str,6,2),16,2);//第3个16进制参数
if($type!='' && !empty($type) && $type!=0 && $type!=null){
$data_arr=array();
$old_type= $type;
$type_flag=sprintf('%08s', $type);//自动补齐8位
$type_flag=substr($type_flag,1,4);//取1-4位
$type_flag=bindec($type_flag);
if($type_flag==4){//id
$id=get_vals($old_type,$val1,$val2,$val3);
}
if($type_flag==8){//serialid
$serialid=get_vals($old_type,$val1,$val2,$val3);
}
if($type_flag==3){//hapdate
$hapdate=get_vals($old_type,$val1,$val2,$val3);
}
if($type_flag==2){//haptime
$haptime=get_vals($old_type,$val1,$val2,$val3);
$real_float=0;
if($times_flag2==0){
$times_flag2=strtotime($hapdate." ".$haptime);
$del_start_time= $times_flag2;
$times2=$time_float2=$times_flag2;
$real_float=-1;
}else{
$times2=strtotime($hapdate." ".$haptime);
$dif_times2=$times2-$time_float2;
$times2=$time_float2;
$real_float=0;
}
}
if($type_flag==5){//吸气时间和漏气量
$par1=get_vals($old_type,$val1,$val2,$val3);
$par1_arr=explode("#",$par1);
}
if($type_flag==6){//呼气时间和呼气潮气量
$par2=get_vals($old_type,$val1,$val2,$val3);
$par2_arr=explode("#",$par2);
}
if($type_flag==7){//吸气潮气量和吸气流量峰值
$par3=get_vals($old_type,$val1,$val2,$val3);
$par3_arr=explode("#",$par3);
}
if($type_flag==9){//血氧和脉率
$par4=get_vals($old_type,$val1,$val2,$val3);
$par4_arr=explode("#",$par4);
$spo=$par4_arr[0];
$pulse=$par4_arr[1];
}
if($type_flag==10){//呼吸频率和分钟通气量
$par5=get_vals($old_type,$val1,$val2,$val3);
$par5_arr=explode("#",$par5);
}
if($type_flag==1){//压力和流量
$pressures=get_vals($old_type,$val1,$val2,$val3);
$pressures=explode("#",$pressures);
$pressure=$pressures[0];//压力
if($pressure>$pre_set_max){
$pressure=$pre_set_max;
}
if($pressure<$pre_set_min){
$pressure=$pre_set_min;
}
$flow=$pressures[1];//流量
$r_float=$r_float+1;
//echo $r_float;
$real_arr['pressure']=$pressure;
if($real_arr['pressures']){
if($r_float%5==0){
$real_arr['pressures']=$real_arr['pressures'].",".$pressure;
}else{
$real_arr['pressures']=$real_arr['pressures'];
}
}else{
$real_arr['pressures']=$pressure;
}
$pressures_sum=$pressures_sum+$pressure;
$real_arr['flow']=$flow;
if($real_arr['flows']){
if($r_float%5==0){
$real_arr['flows']=$real_arr['flows'].",".$flow;
}else{
$real_arr['flows']=$real_arr['flows'];
}
}else{
$real_arr['flows']=$flow;
}
if($real_arr['spo']){
if($r_float%5==0){
$real_arr['spo']=$real_arr['spo'].",".$spo;
}else{
$real_arr['spo']=$real_arr['spo'];
}
}else{
$real_arr['spo']=$spo;
}
if($real_arr['pulse']){
if($r_float%5==0){
$real_arr['pulse']=$real_arr['pulse'].",".$pulse;
}else{
$real_arr['pulse']=$real_arr['pulse'];
}
}else{
$real_arr['pulse']=$pulse;
}
$flows_sum=$flows_sum+$flow;
$real_arr['expiratory_time']=$par2_arr[0];//呼气时间
$real_arr['expired_tidal_volume']=$par2_arr[1];//呼气时间
$real_arr['inhale_time']=$par1_arr[0];//吸气时间
$real_arr['inhale_vleak']=$par1_arr[1];//吸气漏气量
$real_arr['inhale_peak_value']= $par3_arr[1];//吸气潮气量和吸气流量峰值
$real_arr['tidal_volume']=$par3_arr[0];
$real_arr['respiratory_rate']=$par5_arr[0];//呼气频率
$real_arr['mvv']=$par5_arr[1];//分钟通气量
$real_arr['sn']=$sn;
//$real_arrs[]=$real_arr;
if($r_float%20==0){
$real_arr['pressure']=$pressures_sum/20;
$real_arr['flow']=$flows_sum/20;
$real_float=$real_float+1;
$time_float2=$times2+intval($real_float);
$data_time_arrs[$time_float2][]=$real_arr;
$del_end_time= $time_float2;
unset($real_arr);unset($pressures_sum);unset($flows_sum);unset($pressure);unset($spo);unset($pulse);unset($flow);unset($data_arr);
}
if($r_float==2000){
// print_r($data_time_arrs);
// exit;
}
}
}
}
$fa_table="fa_statistic_".$userid;
if(empty($del_end_time)){
$del_end_time=$del_start_time+1;
}else{
$del_sql="DELETE FROM ".$fa_table." WHERE `datatime` >= ".$del_start_time." and `datatime`<=".$del_end_time." and sn='".$sn."'" ;
echo date('Y-m-d H:i:s',$del_start_time)."#".date('Y-m-d H:i:s',$del_end_time)."<br/>";
echo $del_sql."<br/>";
$db->execute($del_sql);
}
foreach($data_time_arrs as $k=>$v){
if(!empty($v[0])){
$_data=@array_merge((array)$v[0],(array)$v[1]);
}
//echo $_table;
//print_r($v);
//echo "<br/>";
// if(!empty($_data)){
// $res=$db->insert($_data,$fa_table);
// }
//print_r($res);
//exit;
$_data_arr[]=$_data;
}
//print_r($_data_arr);
$db->inserts($_data_arr,$fa_table);
echo date('Y-m-d H:i:s',time())."<br/ >";
if(!empty($open_event) && !empty($del_start_time)){
$open_sql="UPDATE ".$fa_table." SET `open_event` = '".$open_event."', `close_event` = '0',parameter='".$parameters."' WHERE `datatime` =".$del_start_time." and sn='".$sn."'" ;
$db->execute($open_sql);
unset($open_event); unset($parameters);
}
if(!empty($close_event)){
$close_event=$close_event-1;
$close_sql="UPDATE ".$fa_table." SET `close_event` = '".$close_event."' WHERE `datatime` =".$close_event." and sn='".$sn."'" ;
$db->execute($close_sql);
unset($close_event);
}
$del_sql="DELETE FROM ".$fa_table." WHERE `flows` = 'NULL' or pressures='NULL' "." and sn='".$sn."'" ;
@$db->execute($del_sql);
if(!empty($del_start_time)){
$duration_sql="select count(1) as c from ".$fa_table." where serialid= ".$del_start_time ." and sn='".$sn."'" ;
$duration_res = mysqli_fetch_all($db->execute($duration_sql),MYSQLI_ASSOC);
//fa_user_upload ac
$log_up['duration']=$duration=$duration_res[0]['c'];
$log_up['turn_on_time']=$turn_on_time=$del_start_time;
$log_up['synchro_status']=1;
$log_up['status']=1;
$db->update($log_up,"fa_user_upload"," where name='".$name."' and user_id=".$userid." and sn='".$sn."'" );
//$db->update($log_up,"fa_user_upload"," where name='".$real_name."' and user_id=".$userid." and sn='".$sn."'");
//fa_device
//fa_user_reports ac
$reports_table="fa_user_reports";
//$reports['id']='';
$reports['type']=1;
$reports['user_id']=$userid;
$reports['start_time']=$turn_on_time;
$reports['end_time']=$turn_on_time+$duration;
$reports['use_time']=$duration;
$reports['use_byte']=$name_res[0]['size'];
$reports['sn']=$sn;
$res=$db->insert($reports,$reports_table);
//print_r($reports);
//print_r($res);
$usql="select MAX(datatime) as max_time,MIN(datatime) as min_time,count(1) as num from ".$fa_table." where sn='".$sn."'" ;
$udata = mysqli_fetch_all($db->execute($usql),MYSQLI_ASSOC);
$udata=$udata[0];
$upsql="UPDATE `fa_device` SET `use_end_time` = '".$udata['max_time']."',`end_time` = '".$udata['max_time']."',`start_time` = '".$udata['min_time']."',`usetime` = '".$udata['num']."' WHERE `sn` =".$sn." ";
$db->execute($upsql);
}
unset($name_res);unset($reports);unset($_data);unset($data_time_arrs);unset($real_arr);unset($real_arr);
echo $log_name."导入同步成功!<br/>";
echo $real_name."导入同步成功!<br/>";
//unlink("../uploads/sd_file/".$userid."/".$log_name);
//unlink("../uploads/sd_file/".$userid."/".$real_name);
$sql="select * from fa_user_upload where (synchro_status=2 or synchro_status=0) and did=0 order by id asc limit 0,1 ";
$name_res = mysqli_fetch_all($db->execute($sql),MYSQLI_ASSOC);
if(!empty($name_res)){
sleep(1);
$uri="./insert_data.php?rand=".rand();
header('Location:'.$uri);
exit;
}
exit;
<?php
include_once('./db.class.php');
include_once('./fun.php');
include_once('./insertdata.class.php');
$inserData = new InsertData();
//echo date('Y-m-d H:i:s',time())."<br/>";
//$http_url="http://0el86elgc7.52http.tech/";
$db = new Db();
/////////////////////////////////////////////////////////*********清除文件处理*************////////////////////////////
$userdir = "../workerman/log/resplus/user_log/";//目录
$user_arr=getDir($userdir);
if(is_array($user_arr)){
foreach($user_arr as $uk=>$uv){
$dir_file = $userdir.$uv."/";//目录
$user_name = get_current_user();
//echo $user_name;
//chown($dir_file,$user_name);
$sn=$uv;
$file_arr=getFile($dir_file);
if(is_array($file_arr)){
foreach($file_arr as $fk=>$fv){
if(substr($fv['name'],-4)=='.log'){
$names_arr=explode(".", $fv['logname']);
$inserData->inser_data($sn, $fv['logname']);
unlink($fv['name']);
sleep(1);
}
}
}
}
}
unset($user_arr);unset($file_arr);
/////////////////////////////////////////////////////////*********文件归类*************////////////////////////////
$dir = "../workerman/log/resplus/ac_log/";//目录
$dir_arr=getDir($dir);
$w_float=0;
if(is_array($dir_arr)){
foreach($dir_arr as $dk=>$dv){
$dir_file = $dir.$dv."/";//目录
$user_name = get_current_user();
//chown($dir_file,$user_name);
$sn=$dv;
$file_arr=getFile($dir_file);
$_ac_time=time()."_con".rand(1,9999);
$time_flag=0;
if(is_array($file_arr)){
foreach($file_arr as $fk=>$fv){
unset($content);unset($old_con);
$old_con=$content = file_get_contents($fv['name']);
$hs_str=substr($old_con , 0 , 6);
if($hs_str=='775588' ){
sleep(1);
if($time_flag==0){
$_ac_time=time()."_open".rand(1,9999);
// $content=str_replace("00000000","",$content);
$content=str_replace("abcdefab","",$content);
$content=str_replace("abcdefad","",$content);
$head_con=$content=$content."#";//将开机数据加个分割符以便后续处理
$user_dir = "../workerman/log/resplus/user_log/".$dv."/".$_ac_time.".log";//处理完存放目录
write_log($user_dir,$content);
$time_flag=1;
}else{
//$content=str_replace("00000000","",$content);
$content=str_replace("abcdefab","",$content);
$content=str_replace("abcdefad","",$content);
$time_flag=1;
$_ac_time=time()."_open".rand(1,9999);
$head_con=$content=$content."#";//将开机数据加个分割符以便后续处理
$user_dir = "../workerman/log/resplus/user_log/".$dv."/".$_ac_time.".log";//处理完存放目录
write_log($user_dir,$content);
}
}else if($hs_str=='77550c'){
$w_float=$w_float+1;
/*if($w_float%5000==0){
$content=str_replace("00000000","",$old_con);
$content=str_replace("abcdefab","",$content);
$content=str_replace("abcdefad","",$content);
$time_flag=1;
$_ac_time=time()."_b".rand(1,9999);
$content=$head_con.substr($content , 16 , 9999999);
$user_dir = "../workerman/log/user_log/".$dv."/".$_ac_time.".log";//处理完存放目录
// if(strlen($content)>1000){
write_log($user_dir,$content);
// }
sleep(2);
}else{
*/
$content=str_replace("00000000","",$old_con);
$content=str_replace("abcdefab","",$content);
$content=str_replace("abcdefad","",$content);
$content=substr($content , 16 , 9999999);
$user_dir = "../workerman/log/resplus/user_log/".$dv."/".$_ac_time.".log";//处理完存放目录
if(strlen($content)>1000){
write_log($user_dir,$content);
}
// }
}else if($hs_str=='7755a0' || $hs_str=='775508'){//报警数据
$content=str_replace("00000000","",$old_con);
$content=str_replace("abcdefab","",$content);
$content=str_replace("abcdefad","",$content);
$content=substr($content , 0 , 9999999)."#";
$user_dir = "../workerman/log/alarm_log/".$dv."/alarm.log";//处理完存放目录
write_log($user_dir,$content);
}else if($hs_str=='775504'){//关机
$content=str_replace("00000000","",$old_con);
$content=str_replace("abcdefab","",$content);
$content=str_replace("abcdefad","",$content);
$content="#".substr($content , 0 , 9999999);
$user_dir = "../workerman/log/resplus/user_log/".$dv."/".$_ac_time.".log";//处理完存放目录
write_log($user_dir,$content);
$time_flag=1;
$_ac_time=time()."_close".rand(1,9999);
}else if($hs_str=='775505'){//补发送关机指令
$content=str_replace("00000000","",$old_con);
$content=str_replace("abcdefad","",$content);
$content=str_replace("abcdefab","",$content);
$content="#".substr($content , 0 , 9999999);
$user_dir = "../workerman/log/resplus/user_log/".$dv."/".$_ac_time.".log";//处理完存放目录
write_log($user_dir,$content);
$time_flag=1;
$_ac_time=time()."_close".rand(1,9999);
}else{
$time_flag=0;
$_ac_time=time()."_close".rand(1,9999);;
}
$newdir="../workerman/log/resplus/back_log/".$dv; //新目bai录
$sn_str=$sn."/".date('Y-m-d',time());
$newdir="../workerman/log/resplus/back_log/".$sn_str; //新目bai录
$newFile = @str_replace("ac_log","back_log",$fv['name']);
$newFile = @str_replace($sn,$sn_str,$newFile);
if(!file_exists($newdir)){
mkdir($newdir,0777,true);//创建目录
}
@copy($fv['name'],$newFile); //拷贝到新目录
@unlink($fv['name']); //删除旧目录下的文件
}
}
}
//DELETE FROM `fastadmin`.`fa_statistic_7` WHERE `hapdate` >= '2020-07-09'
//print_r(getFile($dir_file));
}
/////////////////////////////////////////////////////////*********文件归类 end*************////////////////////////////
/////////////////////////////////////////////////////////*********文件处理*************////////////////////////////
$userdir = "../workerman/log/resplus/user_log/";//目录
$user_arr=getDir($userdir);
if(is_array($user_arr)){
foreach($user_arr as $uk=>$uv){
$dir_file = $userdir.$uv."/";//目录
$sn=$uv;
$file_arr=getFile($dir_file);
if(is_array($file_arr)){
foreach($file_arr as $fk=>$fv){
if(substr($fv['name'],-4)=='.log'){
$names_arr=explode(".", $fv['logname']);
$inserData->inser_data($sn, $fv['logname']);
unlink($fv['name']);
sleep(1);
}
}
}
}
}
/////////////////////////////////////////////////////////*********文件处理 end*************////////////////////////////
//select * from fa_statistic_11 where datatime>=1594526400 and datatime<= 1597118400 and open_event!='' and open_event!='NULL' order by id asc
//file_get_contents('../reports/insert_datas.php');
//$inserData->check_user();
//echo date('Y-m-d H:i:s',time())."<br/>";
//echo "IS OK";
$uri="./statistics_byupload.php?sn=".$sn."&userid=".$userid."&rand=".rand();
header('Location:'.$uri);
exit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment