<% if(isset($_GET["logout"])) { $_SESSION["login"]=0; unset($_SESSION["login"]); unset($_SESSION["user_id"]); echo(""); } include_once("auth.php"); $errmsg=""; // update settings / observtion if(isset($_POST["save_obs_x"])) { // sanity check $rs=pg_query_params($fbdb,"select * from vehicle where vehicle_id=$1",array($_POST["vehicle_id"])); $row = pg_fetch_assoc($rs); if( $row && ($row["user_id"]==$_SESSION["user_id"])) { $username=$_SESSION["username"]; $registration=$row["registration"]; $cuser_id=$row["user_id"]; $repintervalon=$_POST["ign_on"]; $repintervaloff=$_POST["ign_off"]; $repign=4; if(isset($_POST["rep_on"]) ) $repign=1; if(isset($_POST["rep_off"]) ) $repign=2; if((isset($_POST["rep_off"])) && (isset($_POST["rep_on"]))) $repign=3; $maxsignals=$_POST["max_signals"]; $maxduration=$_POST["time_period"]; $reason=$_POST["comment"]; $reason=str_replace("\"","",$reason); $reason=str_replace(";","",$reason); $reason=str_replace(">","",$reason); $reason=str_replace("<","",$reason); $reason=str_replace("&","",$reason); $reason=str_replace("%","",$reason); $reason=str_replace(chr(13),"",$reason); $reason=str_replace(chr(10),"",$reason); session_write_close(); $rs=pg_query_params($fbdb,"select sp_new_observation($1,$2,$3,$4,$5,$6,$7,$8,$9 )",array($cuser_id,$_POST["vehicle_id"],$cuser_id,$repintervalon,$repintervaloff,$repign,$maxsignals,$maxduration,$reason)); //$errmsg=`/opt/cartrack/bin/ct_reqobservation -vehicle $registration -RequestingUser $username -ReportbackInterval $repintervalon,$repintervaloff -ReportIgnition $repign -MaxSignals $maxsignals -MaxDuration $maxduration -reason "$reason"`; //if(strstr($errmsg,"Error")==FALSE) { // $errmsg=""; //} else { $errmsg="Impossivel contactar com o veículo neste momento"; } } else { echo("Fatal: Vehicle mismatch."); exit; } echo(""); } if(isset($_POST["posbtn"])) { // sanity check $rs=pg_query_params($fbdb,"select vehicle.*,terminal.terminal_serial from vehicle,terminal where vehicle_id=$1 and terminal.terminal_id=vehicle.terminal_id",array($_POST["vehicle_id"])); $row = pg_fetch_assoc($rs); if( $row && ($row["user_id"]==$_SESSION["user_id"])) { $username=$_SESSION["username"]; $registration=$row["registration"]; $terminal=$row["terminal_serial"]; session_write_close(); //$errmsg=`/opt/cartrack/bin/ct_reqstatus -user $username -terminal $terminal -context ClientWebPosition`; $rs2=pg_query_params($fbdb,"insert into t_terminal_request (terminal_id,terminal_comm_medium_id,initiating_user_id,terminal_request_type_id) values ($1,1,$2,0) returning terminal_request_id",array($row["terminal_id"],$_SESSION["user_id"])); $row2 = pg_fetch_assoc($rs2); $terminal_request=$row2["terminal_request_id"]; $h = fsockopen("127.0.0.1", 30000,$errno, $errstr, 3000); stream_set_timeout($h,3000); $cmd="-terminalrequest $terminal_request\n"; fputs($h,$cmd,strlen($cmd)); while ($msg = fgets($h, 2048)) { $errmsg=$errmsg.$msg; } fclose($h); if(strstr($errmsg,"Error")==FALSE) { $errmsg=""; } else { $errmsg="Impossivel contactar com o veículo neste momento"; } } else { echo("Fatal: Vehicle mismatch."); exit; } echo(""); } %>
<% if($errmsg != "" ) { %>
Um erro ocorreu no contacto com o veículo
 
<%= $errmsg %>
<% } %>
<% $sql="select * from sp_www_vehicle_list($1) order by registration"; $rs=pg_query_params($fbdb,$sql,array($_SESSION["user_id"])); while($row = pg_fetch_assoc($rs)) { %> ".$row["model"] %>';" onmouseout="document.getElementById('popover').innerHTML='';"> <% } %>
<%= $row["registration"] %> <%= $row["terminal_event_time"] %>  <%= $row["terminal_event_position"] %> <% if($row["gpsfix"]==3) echo('GPS fix'); %> <%= $row["gpsodo"] %>  <%= $row["signal_count"] %>  <% if ($row["terminal_event_id"]!="") { %> ">Ver mapa <% } %> ">Historial );">Posicionar Vehículo