Fernando Posted September 15, 2012 Report Share Posted September 15, 2012 Hello. I'm designing a system for automatic approval of pireps this system when the forwards pilot send your PIREP, the system reads the file PIREP "Log Check" Files for downloads http://www.crocko.co...Pirepsystem.rar File "LOGCHECK.TPL" ?php$sql = mysql_query("SELECT * FROM phpvms_pireps WHERE accepted='0'"); $query = mysql_fetch_array($sql); $n = mysql_num_rows($sql); $a = $query["log"]; // Verificar validade $sql2 = mysql_query("SELECT * FROM phpvms_bids"); $query2 = mysql_fetch_array($sql2); $n2 = mysql_num_rows($sql2); $rtime = $query2["rtime"]; $rid = $query2["routeid"]; $bidid = $query2["bidid"]; $hr = substr($rtime,10,9); //echo "<br />"; //echo "Time reaching system --> ".$hr; //echo "<br />"; date_Default_timezone_set('UTC'); $h_atual = date('H:i:s'); //echo "Time Actual --> ".$h_atual; //echo "<br />"; $k=0; while ($k < $n2) { // Passar hora do sistema para UTC $inicio=$hr; $fim="03:00:00"; if (!is_array($hr)) { $inicio = explode(":",$hr); } if (!is_array($fim)) { $fim = explode(":",$fim); } $time_inicio = (($inicio[0]*60)*60) + ($inicio[1]*60) + $inicio[2]; $time_fim = (($fim[0]*60)*60) + ($fim[1]*60) + $fim[2]; $t[0] = floor(($time_fim + $time_inicio) / 60); $t[1] = floor((($time_fim + $time_inicio) / 60) / 60); $t[2] = $time_fim + $time_inicio; $h = $t[1]; $m = $t[0] - ($t[1]*60); if ($m < 10) $m = "0$m"; $s = $t[2] - (($h*60) + $m) * 60; if ($s < 10) $s = "0$s"; $t[3] = "$h:$m:$s"; $t[4] = "0".$h.$m.$s; // Array[0] = all in minuts ... // Array[1] = all ahours ... // Array[2] = all senconds ... // Array[3] = retun all h:m:s ... //echo "<br />"; //echo "soma --> ". $t[1]; //echo "<br />"; if ($t[1] >= 24) { $t[1] = $t[1] - 24; echo " new ahours --> ". $t[1]; } //echo "<br />"; $atu = "$t[1]:$m:$s"; //echo "even new ----> " . $atu; //echo "<br />"; // Check difference between system time and current. $inicio=$atu; $fim=$h_atual; if (!is_array($inicio)) { $inicio = explode(":",$inicio); } if (!is_array($fim)) { $fim = explode(":",$fim); } $time_inicio = (($inicio[0]*60)*60) + ($inicio[1]*60) + $inicio[2]; $time_fim = (($fim[0]*60)*60) + ($fim[1]*60) + $fim[2]; $t[0] = floor(($time_fim - $time_inicio) / 60); $t[1] = floor((($time_fim - $time_inicio) / 60) / 60); $t[2] = $time_fim - $time_inicio; $h = $t[1]; $m = $t[0] - ($t[1]*60); if ($m < 10) $m = "0$m"; $s = $t[2] - (($h*60) + $m) * 60; if ($s < 10) $s = "0$s"; $t[3] = "$h:$m:$s"; // Array[0] = all in minuts ... // Array[1] = all ahours ... // Array[2] = all senconds ... // Array[3] = retun all h:m:s ... //echo "<br />"; //echo "difference between the time the flight was booked and the current time--> ". $t[3]; //echo "<br />"; // Check if the difference of time that was booked the flight is longer than the TSE: $sql3 = mysql_query("SELECT * FROM phpvms_schedules WHERE id='$rid'"); $query3 = mysql_fetch_array($sql3); $fltr = $query3["flighttime"]; // taking the flight time //echo "<br />"; //echo "flighttime ----->".$fltr; //echo "<br />"; $pont = "."; $p_p = strpos($fltr, $pont); $h1 = substr($fltr, 0,1); $m1 = substr($fltr, $p_p+1,2); $h1 = $h1 + 1; if ($m1 < 10) { $m1 = $m1."0"; } //$h2 = "0".$h1.":".$m1.":00"; //echo "<BR>"; //echo $h2; $h3 = "0" . $h1 . $m1 . "00"; //echo "<BR>"; //echo " time difference with the system------> " . $t[4]; //echo "<BR>"; //echo " EET ------> " . $h3; //echo "<BR>"; if ($t[4] > $h3) { echo "<BR> T[4] is greater --- " . $t[4]; $del = 1; $coment .= "<br /> The time limit for sending the log was exceeded<br /> "; } //echo "<BR>"; //echo " del del pirep ------> " . $del; //echo "<BR>"; $k++; } if ($del==1) { $deletar = mysql_query("DELETE FROM phpvms_bids WHERE bidid='$bidid'"); } $pontos = 100; $i = 0; $j = 0; while ($i <= $n) { while ($j <= 100) { $log = explode("*", $a); $texto = "Aircraft Type"; $p_texto = strpos($log[$j], $texto); if($p_texto!==false){ $v_posi = $p_texto+14; $pontuacao = substr($log[$j], $v_posi,6); echo "bonuuuuussssss".$pontuacao; if ($pontuacao == "B737") { include ("log_B737.tpl"); } elseif ($pontuacao == "B738") { include ("log_B738.tpl"); } else { echo ""; } } else { echo""; }// p_texto $j++; } //fim J $i++; } // fim i ?> Archive for approval of aircraft <?php$sql = mysql_query("SELECT * FROM phpvms_pireps WHERE accepted='0'"); $query = mysql_fetch_array($sql); $n = mysql_num_rows($sql); $a = $query["log"]; $aid = $query["pirepid"]; $plid = $query["pilotid"]; $dicao = $query["depicao"]; $aicao = $query["arricao"]; $flnum = $query["flightnum"]; $thora = $query["flighttime_stamp"]; $pay = $query["pilotpay"]; $ldgrate = $query["landingrate"]; $fuelused = $query["fuelused"]; $pontos = 100; $pont = 100; if ($ldgrate >= -350) { $pont = $pont; } elseif (($ldgrate < -350) AND ($ldgrate >= -500)) { $pont = $pont - 10; $coment .= "<br /> Exceeded the Touchdown Rate "; } elseif (($ldgrate < -500) AND ($ldgrate > -880)) { $pont = $pont - 25; $coment .= "<br /> Exceeded the Touchdown Rate "; } elseif ($ldgrate <= -880) { $rec=1; $coment .= "<br /> Exceeded the Maximum Rate of Touchdown "; } else { $pont = $pont - 5; $coment .= "<br /> Exceeded the Touchdown Rate "; } $pontos = $pont; while ($i <= $n) { while ($j <= "50") { $log = explode("*", $a); /***********************/ /* FL / TD */ /***********************/ $mfl = "Flight Level"; $tdr = "TouchDown:Rate"; $p_mfl = strpos($log[$j], $mfl); $p_tdr = strpos($log[$j], $tdr); if($p_mfl!==false){ $v_posi = $p_mfl + 13; $pontuacao = substr($log[$j], $v_posi,6); if ($pontuacao <= 41000) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Exceeded the ceiling of the operating "; } } else {echo ""; } $fif = ", Fuel Weight:"; $zfw = "Zero fuel Weight"; $mtow = "Take off Weight"; $ldw = "Landing Weight"; //$fif = "Final Fuel"; $p_zfw = strpos($log[$j], $zfw); $p_mtow = strpos($log[$j], $mtow); $p_ldw = strpos($log[$j], $ldw); $p_fif = strpos($log[$j], $fif); if($p_zfw!==false){ $v_posi = $p_zfw + 18; $pontuacao = substr($log[$j], $v_posi,5); if ($pontuacao <= 42600) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Zero Fuel Weight exceeded"; } } else {echo "<br />"; } if($p_mtow!==false){ $v_posi = $p_mtow + 16; $pontuacao = substr($log[$j], $v_posi,6); if ($pontuacao <= 52290) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Maximum takeoff weight exceeded "; } } else {echo "<br />"; } if($p_ldw!==false){ $v_posi = $p_ldw + 15; $pontuacao = substr($log[$j], $v_posi,6); if ($pontuacao <= 45800) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Maximum Landing Weight exceeded "; } } else {echo "<br />"; } if($p_fif!==false){ $v_posi = $p_fif + 14; $pontuacao = substr($log[$j], $v_posi,5); $sobra = $pontuacao - $fuelused; if (($sobra) >= 1200) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Fuel-mi nimo below the target "; } } else {echo "<br />"; } $vgu = "Gear Up"; $vgd = "Gear Down"; $vr = "VR="; $vld = "Speed"; $p_vgu=strpos($log[$j], $vgu); $p_vgd=strpos($log[$j], $vgd); $p_vr=strpos($log[$j], $vr); $p_ld=strpos($log[$j], $vld); if($p_vr!==false){ $v_posi = $p_vr + 3; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 185) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Rotation speed (VR) exceeded the limit "; } } else { } if($p_vgu!==false){ $v_posi = $p_vgu + 3; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 255) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= " <br /> Gear up speed exceeded "; } } else { } if($p_vgd!==false){ $v_posi = $p_vgd + 3; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 240) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> He lowered his landing gear above the speed limit "; } } else { } if($p_ld!==false){ $v_posi = $p_ld + 3; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 195) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Touched down very fast "; } } else { } $flp0 = "Flaps:0 at"; $flp1 = "Flaps:1 at"; $flp2 = "Flaps:2 at"; $flp3 = "Flaps:3 at"; $flp4 = "Flaps:4 at"; $flp5 = "Flaps:5 at"; $flp6 = "Flaps:6 at"; $p_0=strpos($log[$j], $flp0); $p_1=strpos($log[$j], $flp1); $p_2=strpos($log[$j], $flp2); $p_3=strpos($log[$j], $flp3); $p_4=strpos($log[$j], $flp4); $p_5=strpos($log[$j], $flp5); $p_6=strpos($log[$j], $flp6); if($p_0!==false){ $v_posi = $p_0 + 10; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 230) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Flaps operation speed exceeded 0 "; } } else { } if($p_1!==false){ $v_posi = $p_1 + 10; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 230) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Flaps operation speed exceeded 1 "; } } else { } if($p_2!==false){ $v_posi = $p_2 + 10; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 215) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Flaps operation speed exceeded 2 "; } } else { } if($p_3!==false){ $v_posi = $p_3 + 10; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 200) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Flaps operation speed exceeded 3 "; } } else { } if($p_4!==false){ $v_posi = $p_4 + 10; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 180) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Flaps operation speed exceeded 4 "; } } else { } if($p_5!==false){ $v_posi = $p_5 + 10; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 180) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Flaps operation speed exceeded 5 "; } } else { } if($p_6!==false){ $v_posi = $p_6 + 10; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao <= 165) { $pontos = $pontos; } else { $pontos = $pontos - 5; $coment .= "<br /> Flaps operation speed exceeded 6 "; } } else { } $dep = "Departing Airport: "; $arr = "Destination Airport: "; //$alt = "Alternate Airport:"; $p_dep=strpos($log[$j], $dep); $p_arr=strpos($log[$j], $arr); //$p_alt=strpos($log[$j], $alt); if($p_dep!==false){ $v_posi = $p_dep + 19; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao !== $dicao) { $rec = 1; $coment .= "<br /> Different origin of the flight plan "; } else { $pontos = $pontos; } } else { } if($p_arr!==false){ $v_posi = $p_arr + 21; $pontuacao = substr($log[$j], $v_posi,4); if ($pontuacao !== $aicao) { $rec = 1; $coment .= "<br /> Different destination of the flight plan "; } else { $pontos = $pontos; } } else { } /* $art = "Aircraft Type:"; $p_art=strpos($log[$j], $art); if($p_art!==false){ $v_posi = $p_art + 14; $pontuacao = substr($log[$j], $v_posi,6); if ($pontuacao != "E190/M") { $rec = 1; $coment .= "<br /> Aeronave operada deveria ser E190/M "; } } */ $j++; } $i++; } $cm = utf8_encode($coment); if (($pontos > 99) AND ($rec != 1)) { $cm = " all operating limits respected ! "; } $sql = mysql_query("SELECT * FROM phpvms_pireps ORDER BY pirepid DESC LIMIT 1,1"); $query = mysql_fetch_array($sql); $dep = $query["depicao"]; $arr = $query["arricao"]; $flightnum = $query["flightnum"]; $pilotpay = $query["pilotpay"]; $sql = mysql_query("SELECT * FROM phpvms_pilots WHERE pilotid='$plid'"); $query = mysql_fetch_array($sql); $totalpay = $query["totalpay"]; $tempo_de_voo = $query["flighttime"]; if ($tempo_de_voo <= 1.00) { $totalpay = $totalpay + $pilotpay; } else { $totalpay = $totalpay + ($pilotpay * $tempo_de_voo ); } $totalflights = $query["totalflights"]; $totalflights = $totalflights + 1; $totalhours = $query["totalhours"]; if ($totalhours < 1) $totalhours = 0.01; $totalhours = str_replace('.', ':', $totalhours); $totalhours = $totalhours.":00"; $inicio=$totalhours; $fim=$thora; if (!is_array($inicio)) { $inicio = explode(":",$inicio); } if (!is_array($fim)) { $fim = explode(":",$fim); } $time_inicio = (($inicio[0]*60)*60) + ($inicio[1]*60) + $inicio[2]; $time_fim = (($fim[0]*60)*60) + ($fim[1]*60) + $fim[2]; $t[10] = floor(($time_fim + $time_inicio) / 60); $t[11] = floor((($time_fim + $time_inicio) / 60) / 60); $t[12] = $time_fim + $time_inicio; $h = $t[11]; $m = $t[10] - ($t[11]*60); if ($m < 10) $m = "0$m"; $s = $t[12] - (($h*60) + $m) * 60; if ($s < 10) $s = "0$s"; $t[15] = "0$h.$m"; //horas de voo no formato h.m $totalhours = $t[15]; $consulta = mysql_query("SELECT * FROM phpvms_bids WHERE pilotid='$plid'"); $q = mysql_fetch_array($consulta); $bidid = $q["bidid"]; $sql = mysql_query("SELECT * FROM phpvms_schedules WHERE bidid='$bidid'"); $query = mysql_fetch_array($sql); $timesflown = $query["timesflown"]; $timesflown = $timesflown + 1; if (($flightnum == $flnum) && ($dicao == $dep) && ($aicao == $arr)) { $rec = 1; $cm="Log Duplicado"; } if ($rec==1) { $upd = mysql_query("UPDATE phpvms_pireps SET accepted = '2', source='e-foqa', comment='$cm', rating='',status='R' WHERE phpvms_pireps.pirepid=$aid"); $upd2 = mysql_query("UPDATE phpvms_schedules SET bidid='0' WHERE bidid=$bidid"); $del = mysql_query("DELETE FROM phpvms_bids WHERE pilotid='$plid'")or die(mysql_error()); } else { $upd = mysql_query("UPDATE phpvms_pireps SET accepted='1', source='e-foqa', comment='$cm', rating='$pontos', status='A' WHERE pirepid=$aid"); $upd2 = mysql_query("UPDATE phpvms_pilots SET totalflights='$totalflights', totalhours='$totalhours',totalpay='$totalpay' WHERE phpvms_pilots.pilotid='$plid'")or die(mysql_error()); $upd3 = mysql_query("UPDATE phpvms_schedules SET bidid='0', timesflown='$timesflown' WHERE bidid='$bidid'")or die(mysql_error()); $del = mysql_query("DELETE FROM phpvms_bids WHERE phpvms_bids.pilotid='$plid'")or die(mysql_error()); } Log.tpl <?phpmysql_connect('localhost', 'login', 'senha') or die(mysql_error()); mysql_select_db('your BD ') or die(mysql_error()); // Contagem de horas totais $query = mysql_query("SELECT flighttime FROM phpvms_pireps") or die(mysql_error()); while ($row = mysql_fetch_assoc($query)) { $input = explode('.', $row['flighttime']); $hours = $input[0] * 60; $minutes = $input[1]; $total = $total + $hours + $minutes; } $finalhours = floor($total / 60); $minutesleft = $total - $finalhours * 60; $finalminutes = (strlen($minutesleft) == 1) ? '0'.$minutesleft: $minutesleft; $value = $finalhours.".".$finalminutes; mysql_query("UPDATE phpvms_settings SET value = ".$value." WHERE id = 6"); // Avaliação de logs $logs = mysql_query("SELECT * FROM phpvms_pireps WHERE accepted = 0 OR status = 'P'"); while ($log = mysql_fetch_assoc($logs)) { $log = $log['log']; $aircraft = explode('Aircraft Type:', $log); $aircraft = substr($aircraft[1], 0, 6); if ($aircraft == "B737/M") include ("log_B737.inc"); else if ($aircraft == "B738/M") include("log_B738.inc"); } ?> Can someone tell me if I'm going the right way? is my first system 1 Quote Link to comment Share on other sites More sharing options...
mattia Posted September 16, 2012 Report Share Posted September 16, 2012 how does it work? Quote Link to comment Share on other sites More sharing options...
Fernando Posted September 16, 2012 Author Report Share Posted September 16, 2012 I'm still doing testing, so most want to finish work as follows. - The pilot reserves in its route system - The pilot will open the system to calculate your hours (KAcars, Fsacars, Fspax) - Check the System Log, vai check a possible irregularity example: The system of reservation to the start time of the flight, as seen in the file LOGCHECK.TPL - If you do not find any irregularity the pilot can start your flight - The pilot carries out ends your flight - Send to the company website - You will be redirected to this approval system - Archive log_B737.ini, is the file that contains the conditions for approval of the flight plan, where you can configure according to your needs. - If you have some data that you put such restrictions, flying is refused and is pending for a manual review would be an opportunity to review. - If the flight the pilot has completed its flight within the conditions of the flight log_B737.ini file is automatically approved. Details, log_B737.ini the file is the file you will insirar the conditions for approval, this file has a points system. That is, the pilot lowers the landing gear with 260kt, he loses a number of points. There are several restrictions, speed, fraps, weight, among others. I'm thinking of entering 100 points if the pilot lost 30 points flying is refused. I'm still thinking how I will add more to doing some tests. this is my idea;. 1 Quote Link to comment Share on other sites More sharing options...
mattia Posted September 16, 2012 Report Share Posted September 16, 2012 Wow very nice sorry but I'm no expert and I can not help you Quote Link to comment Share on other sites More sharing options...
Fernando Posted September 16, 2012 Author Report Share Posted September 16, 2012 No problem, I'm testing, when you are ready you can download for free and enjoy the work ... The cool thing is that this system semenhante to fspasangers with several benificios , Penalty for irregularities during the flight, automatic approval, points, editable system according to the needs. It is a more difficult job I am doing as fast as possible for everyone to enjoy and enter in their companies. Thanks, already have news soon. Quote Link to comment Share on other sites More sharing options...
mattia Posted September 16, 2012 Report Share Posted September 16, 2012 thanks sir but how to "install" this module? Quote Link to comment Share on other sites More sharing options...
Fernando Posted September 16, 2012 Author Report Share Posted September 16, 2012 Mattia The files that are for download is just the beginning of the project, I'm linking it with the system phpvms, but need to test when finished leave the module ready. Quote Link to comment Share on other sites More sharing options...
stuartpb Posted September 16, 2012 Report Share Posted September 16, 2012 Subbed to this thread, and extremely interested in how it progresses! It's a great idea and would be a very welcome add on for phpVMS, in my opinion. Quote Link to comment Share on other sites More sharing options...
Fernando Posted September 16, 2012 Author Report Share Posted September 16, 2012 Stuartpb , thank you! It's a difficult project, more community PHPVMS is valid and complete work ... will be a system with great features and I'm sure will be very useful. Quote Link to comment Share on other sites More sharing options...
Moderators Parkho Posted September 18, 2012 Moderators Report Share Posted September 18, 2012 Okay. Let's see here. The checking log should go to the gateway of receiving PIREPS which is in here :Admin/modules/PIREPadmin/PIREPAdmin.php and that should resolve the issues with this. The thing is that if you want this to be a module then you're gonna have to redirect the receiving PIREPS gateway to your module for it to process the flight and after that redirect it back to the admin center for manual approval if any conditions were not met. Quote Link to comment Share on other sites More sharing options...
lucasroger Posted November 3, 2012 Report Share Posted November 3, 2012 Olá Fernando! Estou em duvida com este sistema. Por gentileza você tem Skype ou MSN? Obrigado, Lucas Quote Link to comment Share on other sites More sharing options...
Marmus Posted November 5, 2012 Report Share Posted November 5, 2012 This seems to have lots of conditions to accept....what if I just want all submitted PIREPs to be automatically approved? Is there a quick code I can add? and where would I add it? Thanks. [sOLVED} My question got solved by doing some more searching though these forums....seems that all answers are here somewhere, just need to be able to search properly or stumble upon the answer! Answer to my question can be found here: http://forum.phpvms.net/topic/3041-auto-accept-pireps/ Quote Link to comment Share on other sites More sharing options...
eliezerazevedo Posted October 28, 2016 Report Share Posted October 28, 2016 The download link is not working, someone can offer this project to download? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.