TransWar File Browser

Path: C:\

<?php
ini_set('max_execution_time',259200); 
ini_set ('memory_limit','-1');
$aviso[0]='';
$aviso[1]='Identificamos seu inicio de viagem, nao esqueca de verificar doc. do veiculo/carreta e fazer Mobile. Boa viagem!';
$aviso[2]='Cuidado com tempo de Almoco/Janta, deve ser de 1 hora, podendo ser fracionado, sendo obrigado avisar a empresa caso descumpra o procedimento.';
$aviso[3]='Se em TEMPO DE ESPERA, o PERNOITE DEVE INICIAR as 18:00 hs. Acessar o link para ciencia do DESCUMPRIMENTO DE REGRA. https://form.jotform.com/transwar/fo0304dri';
$aviso[4]='Tempo de Almoco/Janta INFERIOR a 30 MINUTOS. Favor acessar o link para ciencia do DESCUMPRIMENTO DE REGRA. https://form.jotform.com/transwar/fo0304dri';
$aviso[5]='Tempo de Almoco/Janta SUPERIOR A 1 HORA. Favor acessar o link para ciencia do DESCUMPRIMENTO DE REGRA. https://form.jotform.com/transwar/fo0304dri';
date_default_timezone_set('America/Sao_Paulo');
$agora=date("d-m-Y G:i:s");
function tempo($hi, $hf){
  $hi=strtotime($hi);
  $hf=strtotime($hf);
  $df[0]=$hf-$hi;
  $difh=substr(($df[0]/3600)+100,1,2); 
  $difm=substr(($df[0]/60%60)+100,1,2);
  $df[1]=$difh.":".$difm; 
  return $df;
}
function mensagem($m_ant, $m_atu, $tempo, $ia){
  $av[0]=0;$av[1]=$ia;
  if($m_atu==32)
  { if($m_ant===39)
    { if(($tempo+$ia)<=1799)
      { $av[0]=4;}
      else
      { if($tempo+$ia>4200)
        { $av[0]=5;}
        else
        { $av[0]=0;}
      }
      $av[1]=$tempo+$ia;
    }
    else 
    { $av[0]=1;}
  }
  else
  { if($m_atu==39)
    { if($m_ant===39)
      { if($tempo+$ia<=1799)
        { $av[0]=4;}
        else
        { if($tempo+$ia>4200)
          { $av[0]=5;}
          else
          { $av[0]=2;}
        }
        $av[1]=$tempo+$ia;
      }
      else
      {$av[0]=2;}
    } 
    else
    { if($m_atu==44)
      { if($m_ant==37 or $m_ant===40 or $m_ant===41 or $m_ant===50 or $m_ant===53 or $m_ant===54)
        { $av[0]=3;}
        else
        { $av[0]=0;}
      }
      else
      { if($m_ant===39)
        { if($tempo+$ia<=1799)
          { $av[0]=4;}
          else
          { if($tempo+$ia>4200)
            { $av[0]=5;}
            else
            { $av[0]=0;}
          }
          $av[1]=$tempo+$ia;
        }
        else
        { $av[0]=0;}
      }
    }
  }
  return $av;
}
$json = file_get_contents('sms.json');
$atu = json_decode($json, true);
$i=count($atu);
if ($atu == true)
{ 
  foreach ($atu as $value => $x)
  { if($value==='INICIO'){continue;}
    $n=0;
    $nome =$value;
    $cel  =$x['cel'];
    $dia  =$x['dia'];
    if(isset($x['IA'])){$IA=$x['IA'];}else{$IA=0;}
    $d=count($x['macro']);
    for($q=0;$q<$d;$q++)
    { if(isset($x['macro'][$q]['ja'])){continue;}else{$atu[$nome]['macro'][$q]['ja']='ja';}
      $id=$x['macro'][$q]['id'];
      $hora=$x['macro'][$q]['hora'];
      $a=array();
      if($q>0)
      { $id_ant=$x['macro'][$q-1]['id'];$hora_ant=$x['macro'][$q-1]['hora'];
        $dif=tempo($hora_ant,$hora);
        $df0=$dif[0];$df1=$dif[1];
        $a[0]=0;
        $a=mensagem($id_ant,$id,$df0,$IA);
      }
      else
      { $hora_ant='';$id_ant=0;$df0=0;$df1='';
        $a=mensagem($id_ant,$id,$df0,$IA);
      }
      if ($a[0]!==0)
      { 
        $atu[$nome]['IA']=$a[1];
        include('sms3.php');
      }
    }
  }
  $json=json_encode($atu);
  $fopen=fopen('sms.json','w');
  $fwrite=fwrite($fopen,$json);
  fclose($fopen);
}
header("Refresh: 30;url=sms1.php");
?>