function kmsPerDay($path) { $timeArr = array(); $cnt = 1; $totalDistance = 0; $file1 = @fopen($path, "r"); if ($file1) { $i = 0; while (!feof($file1)) { $data = fgets($file1); //$i++; } $data = getSortedData($data); $data1 = explode("#", $data); for ($j1 = 0; $j1 < count($data1); $j1++) { $data2 = explode("\$", $data1[$j1]); if (count($data2) > 1) { $data3 = explode(",", $data2[1]); $vehi = $data3[0]; $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3])); $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3])); $pos1 = convertLat(calLat($data3[7])); $pos2 = convertLong(calLong($data3[8])); if ($pos1 > 0 && $pos2 > 0) { if (!in_array($geoTime, $timeArr)) { if ($j1 == 0) { $pits1 = $pos1; $pits2 = $pos2; } else { $pits3 = $pos1; $pits4 = $pos2; $dist = getDistance($pits1, $pits2, $pits3, $pits4); $totalDistance += $dist; $pits1 = $pits3; $pits2 = $pits4; } } } } array_push($timeArr, $geoTime); } //echo $data3[11]; $res = simpleGeocode($pos1, $pos2); //print_r($res); $res = str_replace('"', "", $res); //echo $res."<br>"; //echo round($totalDistance,2); $finalData = round($totalDistance) . "#" . $geodate . "#" . $res; fclose($file1); return $finalData; } }
function kmsPerDay($path1) { //echo $path; $timeArr = array(); $cnt = 1; $totalDistance = 0; $file1 = @fopen($path1, "r"); if ($file1) { //echo $path1; while (!feof($file1)) { $data = @fgets($file1); } $data = getSortedData($data); $data1 = explode("#", $data); //print_r($data1); for ($j1 = 0; $j1 < count($data1); $j1++) { $data2 = explode("@", $data1[$j1]); if (count($data2) > 1) { $data3 = explode(",", $data2[1]); $vehi = $data3[0]; $geodate = $data3[8]; $geoTime = date("h:i A", strtotime($data3[9])); $pos1 = calLat($data3[2]); $pos2 = calLong($data3[1]); if ($pos1 > 0 && $pos2 > 0) { if (!in_array($geoTime, $timeArr)) { if ($j1 == 0) { $pits1 = $pos1; $pits2 = $pos2; } else { $pits3 = $pos1; $pits4 = $pos2; $dist = getDistance($pits1, $pits2, $pits3, $pits4); $totalDistance += $dist; $pits1 = $pits3; $pits2 = $pits4; } } } } array_push($timeArr, $geoTime); } $locat = simpleGeocode($pits1, $pits2); $locat = str_replace('"', "", $locat); $finalData = round($totalDistance) . "," . $locat . "," . $data3[3] . "," . $geodate . "," . $geoTime; @fclose($file1); return $finalData; } else { return false; } }
function gpspathAll($path1) { $file1 = @fopen($path1, "r"); if ($file1) { while (!@feof($file1)) { $data = @fgets($file1); } $data = getSortedData($data); return $data; } else { return 0; } @fclose($file1); }
function gpspathFun($source) { $file1 = @fopen($source, "r"); if ($file1) { while (!@feof($file1)) { $data = @fgets($file1); //$i++; } $data = getSortedData($data); return $data; } else { return 0; } @fclose($file1); }
function geofenceChk($date_offline, $deviceIMEI) { $path1 = $GLOBALS[dataPath] . "src/data/" . date('d-m-Y', strtotime($date_offline)) . "/" . $deviceIMEI . ".txt"; if (chk_folder($path1)) { $file1 = @fopen($path1, "r"); if ($file1) { $i = 0; while (!feof($file1)) { $data1 = fgets($file1); } $data1 = getSortedData($data1); fclose($file1); } return $data1; } }
function gpspathFunAll($date_offline, $deviceIMEI) { $path1 = $GLOBALS[dataPath] . "src/data/" . date('d-m-Y', strtotime($date_offline)) . "/" . $deviceIMEI . ".txt"; //$path1="http://localhost/gpsapp/data/".date('d-m-Y',strtotime($date_offline))."/352848025507217.txt"; if (chk_folder($path1)) { $file1 = @fopen($path1, "r"); if ($file1) { $i = 0; while (!feof($file1)) { $data1 = fgets($file1); } $data1 = getSortedData($data1); fclose($file1); } return $data1; } }
function PrintKMLFolder($path1, $vehiName, $resellID) { //echo $path; $timeArr = array(); $cnt = 1; $totalDistance = 0; $file1 = @fopen($path1, "r"); if ($file1) { //echo $path1; while (!feof($file1)) { $data = @fgets($file1); } $data = getSortedData($data); $data1 = explode("#", $data); //print_r($data1); for ($j1 = 0; $j1 < count($data1); $j1++) { $data2 = explode("@", $data1[$j1]); if (count($data2) > 1) { $data3 = explode(",", $data2[1]); $vehi = $data3[0]; $geodate = $data3[8]; $geoTime = date("h:i A", strtotime($data3[9])); $pos1 = calLat($data3[2]); $pos2 = calLong($data3[1]); $mph = $data3[3]; if ($pos1 > 0 && $pos2 > 0) { if (!in_array($geoTime, $timeArr)) { if ($j1 == 0) { $pits1 = $pos1; $pits2 = $pos2; } else { $pits3 = $pos1; $pits4 = $pos2; $dist = getDistance($pits1, $pits2, $pits3, $pits4); $totalDistance += $dist; $pits1 = $pits3; $pits2 = $pits4; } } } } array_push($timeArr, $geoTime); } $locat = simpleGeocode($pits1, $pits2); $locat = str_replace('"', "", $locat); //$finalData = round($totalDistance).",".$locat.",".$data3[3].",".$geodate.",".$geoTime; @fclose($file1); print "Dear Client! " . $vehiName . " is located at " . $locat . " on " . $geodate . ", Sd = " . $mph . " k/h TD = " . round($totalDistance) . " km - VTS Alert."; $from = ""; $to = $_GET[from]; //sendLocation($from,$to,$msg,$resellID); //sendGatewaySMS($from,$to,$msg,$smsUri,$smsUname,$smsPwd,$smsSender); //return $finalData; } else { //return false; print_r("Dear Client! " . $vehiName . " is not avilable today - VTS Alert."); $from = ""; $to = $_GET[from]; //sendLocation($from,$to,$msg,$resellID); //sendGatewaySMS($from,$to,$msg,$smsUri,$smsUname,$smsPwd,$smsSender); } }
function gpspathFunAll($clientId, $date_offline, $deviceIMEI) { $date_offline = $_GET[date_offline]; $path1 = $GLOBALS[dataPath] . "src/data/" . date('d-m-Y', strtotime($date_offline)) . "/" . $deviceIMEI . ".txt"; if (chk_folder($path1)) { $file1 = @fopen($path1, "r"); if ($file1) { $i = 0; while (!feof($file1)) { $data1 = fgets($file1); } $data1 = getSortedData($data1); $km = liveKmsAllPerDay($data1); //exit; //$data = $data1; $devName = getDeviceName($_GET["deviceIMEI"]); storeData($data1, $km, $devName, '', ''); fclose($file1); } else { $data = 0; storeData($data); } } }
} $analog_empty_tank_signal = $fuel_info_fetch[di_emptyTanksignal]; $analog_empty_tank_signal_meas = $fuel_info_fetch[di_emptyTanksignalmeasure]; if ($analog_empty_tank_signal_meas == 'mv') { $analog_empty_tank_signal = $analog_empty_tank_signal / 1000; } $fuel_port = $fuel_info_fetch[di_Fuelport]; } $file = $GLOBALS[dataPath] . "src/data/" . date("d-m-Y", strtotime($sdate)) . "/" . $srcData[1] . ".txt"; if (chk_folder($file)) { $file1 = @fopen($file, "r"); if ($file1) { while (!feof($file1)) { $data = fgets($file1); } $data = getSortedData($data); } /*echo $data; exit;*/ if (count($data) > 0) { $data1 = explode("#", $data); $j1 = 0; //echo count($data1); for ($j1 = 0; $j1 < count($data1); $j1++) { $intervals = count($data1) * 0.1; $data2 = explode("@", $data1[$j1]); //echo '<pre>'; print_r($data2);echo '</pre>'; if (count($data2) > 1) { $data3 = explode(",", $data2[1]); $fule_param = $data3[7]; $d = preg_split("/[\\s,]+/", $fule_param);
function kmsPerDay($path) { $timeArr = array(); $cnt = 1; $totalDistance = 0; $file1 = @fopen($path, "r"); if ($file1) { $i = 0; while (!feof($file1)) { $data = fgets($file1); //$i++; } $data = getSortedData($data); $data1 = explode("#", $data); for ($j1 = 0; $j1 < count($data1); $j1++) { $data2 = explode("\$", $data1[$j1]); if (count($data2) > 1) { $data3 = explode(",", $data2[1]); $vehi = $data3[0]; $geodate = date("d-m-Y h:i A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3])); $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3])); $pos1 = convertLat(calLat($data3[7])); $pos2 = convertLong(calLong($data3[8])); if ($pos1 > 0 && $pos2 > 0) { if (!in_array($geoTime, $timeArr)) { if ($j1 == 0) { $pits1 = $pos1; $pits2 = $pos2; } else { $pits3 = $pos1; $pits4 = $pos2; $dist = getDistance($pits1, $pits2, $pits3, $pits4); $totalDistance += $dist; $pits1 = $pits3; $pits2 = $pits4; } $mph = $data3[9]; $direction = $data3[10]; $distance = ''; $date = $date; $locationMethod = '327681'; //echo getDateFromJavaDate($date); $phoneNumber = $data3[0]; $sessionID = $_GET["sessionID"]; $accuracy = 11; $locationIsValid = yes; $extraInfo = $data3[11]; $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" distance="' . round($totalDistance, 2) . '" locationMethod="327681" gpsTime="' . $geodate . '" phoneNumber="' . $phoneNumber . '" sessionID="' . $sessionID . '" accuracy="11" isLocationValid="yes" extraInfo="' . $extraInfo . '" />'; } } } array_push($timeArr, $geoTime); } //echo $data3[11]; //$res=simpleGeocode($pos1,$pos2); //print_r($res); //$res=str_replace(",","-",$res[0]); //echo $res."<br>"; //echo round($totalDistance,2); $finalData = round($totalDistance) . "#" . $geodate . "#" . $res; fclose($file1); return $finalData; } }
function getStopReport($sdate, $devName, $devId, $st_time, $en_time) { $cnt = 1; $tmp = -1; $t1 = 0.0; $t2 = 0.0; $timeArr = array(); $timediff = array(); $strTime = ''; $endTime = ''; $totTime = 0; $k1 = 0; $totDist = 0; $file = $GLOBALS[dataPath] . "src/data/" . date("d-m-Y", strtotime($sdate)) . "/" . $devId . ".txt"; if (chk_folder($file)) { $file1 = @fopen($file, "r"); if ($file1) { while (!feof($file1)) { $data = fgets($file1); } $data = getSortedData($data); } if (count($data) > 0) { $data1 = explode("#", $data); for ($j1 = 0; $j1 < count($data1); $j1++) { $data2 = explode("@", $data1[$j1]); if (count($data2) > 1) { $data3 = explode(",", $data2[1]); //echo date("d-m-Y", strtotime($sdate))."==".date("d-m-Y",@mktime(($data3[4]+5),($data3[5]+30),$data3[6],$data3[2],$data3[1],$data3[3])); $device = $data3[0]; $geodate = $data3[8] . " " . $data3[9]; $geoTime = $data3[9]; $pos1 = calLat($data3[2]); $pos2 = calLong($data3[1]); $curTime = explode(":", $data3[9]); $curTime = $curTime[0] * 60; if ($curTime >= $st_time && $curTime <= $en_time) { if ($pos1 > 0 && $pos2 > 0) { if (!in_array($geoTime, $timeArr)) { //echo $geoTime." sss ".$data3[3]; //echo "<BR>"; if ($data3[3] == 0 && $strTime == '') { $strTime = $geoTime; //$res2=simpleGeocode($pos1,$pos2); //$res2=str_replace('"',"",$res2); $pits1 = $pos1; $pits2 = $pos2; } else { if ($data3[3] > 0 && $endTime == '' && $strTime != '') { $endTime = $geoTime; if (strtotime($endTime) - strtotime($strTime) >= 600) { //echo strtotime($endTime) - strtotime($strTime)."<br>"; $res2 = simpleGeocode($pos1, $pos2); $res2 = str_replace('"', "", $res2); $totTime += strtotime($endTime) - strtotime($strTime); $finaTime = $strTime . "#" . $res2 . "#" . $endTime . "#" . gmdate("H:i:s", strtotime($endTime) - strtotime($strTime)) . "#" . $device . "#" . $devName . "#" . $totTime; array_push($timediff, $finaTime); } $strTime = ''; $endTime = ''; $strPoint = ''; //} } } $cnt++; array_push($timeArr, $geoTime); } } } } } fclose($file1); } } return $timediff; }
function getOverAllTripReport($sdate, $vehId, $dest) { $cnt = 1; $tmp = -1; $t1 = 0.0; $t2 = 0.0; $timeArr = array(); $timediff = array(); $strTime = ''; $endTime = ''; $tmpId = 0; $srcArr = array(); $destArr = array(); $stCunt = 0; $stChk = 0; $geocheck = 0; $ids = $dest; $ids = explode(",", $ids); //print_r($ids); $file = $GLOBALS[dataPath] . "client_" . $_SESSION[clientID] . "/" . date("d-m-Y", strtotime($sdate)) . "/" . $vehId . ".txt"; if (chk_folder($file)) { $file1 = @fopen($file, "r"); if ($file1) { while (!feof($file1)) { $data = fgets($file1); } $data = getSortedData($data); } if (count($data) > 0) { $data1 = explode("#", $data); for ($j1 = 0; $j1 < count($data1); $j1++) { $data2 = explode("\$", $data1[$j1]); if (count($data2) > 1) { $data3 = explode(",", $data2[1]); //echo date("d-m-Y", strtotime($sdate))."==".date("d-m-Y",@mktime(($data3[4]+5),($data3[5]+30),$data3[6],$data3[2],$data3[1],$data3[3])); $vehi = $data3[0]; $geodate = date("d-m-Y", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3])); $geoTime = date("H:i:s A", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3])); $pos1 = convertLat(calLat($data3[7])); $pos2 = convertLong(calLong($data3[8])); $vehi = $data3[0]; /*$getLL=drawCircle("17.98264333","79.601965","0.16"); print_r($getLL); echo $resLL=getGeofenceStatus($getLL,"17.9809383333","79.6004683333"); exit;*/ if ($pos1 > 0 && $pos2 > 0) { for ($k = 0; $k < count($ids) - 1; $k++) { //echo $ids[$k]; $sel_pts = "SELECT * FROM gps_geopoints_info WHERE gpi_clientID=" . $_SESSION[clientID] . " AND gpi_id=" . $ids[$k]; $rs_sel_pts = mysql_query($sel_pts); while ($fetch_sel_pts = @mysql_fetch_assoc($rs_sel_pts)) { $gcdLatLng = drawCircle($fetch_sel_pts[gpi_latVal], $fetch_sel_pts[gpi_longVal], $fetch_sel_pts[gpi_miles]); //print_r($fetch_sel_pts); $geocheck = getGeofenceStatus($gcdLatLng, $pos1, $pos2); if ($geocheck == 1) { //print_r($gcdLatLng); /*$getLL=drawCircle("17.97905965","79.59972382","0.10"); print_r($getLL); $resLL=getGeofenceStatus($getLL,$pos1,$pos2);*/ //print_r($getLL); $result_pt = $fetch_sel_pts[gpi_stopName] . "#" . $geoTime; //echo $k." ".$j1." ".$result_pt." ".$pos1."&&".$pos2.""; if ($tmpId != $fetch_sel_pts[gpi_id]) { $tmpId = $fetch_sel_pts[gpi_id]; //echo "pos ".in_array($fetch_sel_pts[gpi_id],$ids); if (in_array($fetch_sel_pts[gpi_id], $ids)) { if ($destArr[$tmpId] == "") { //echo "ss".count($destArr[$tmpId])." ".$tmpId." ".$result_pt."<br>"; //$destArr = array_push_assoc($destArr, $tmpId, $result_pt); $destArr[$tmpId] = $result_pt; //print_r($destArr); } else { //echo $result_pt."<br>"; foreach ($destArr as $key => $value) { // echo "Key: $key; Value: $value<br />\n"; if ($key == $tmpId) { //echo $key ."==". $tmpId; $tmpVal = $value; //unset($destArr[$key]); $destArr[$key] = $value . ',' . $result_pt; //print_r($destArr); //echo "<br>"; //echo "<br>"; } else { // $destArr[$tmpId]=$result_pt; //$destArr = array_push_assoc($destArr, $tmpId, $result_pt); //print_r($destArr); //echo "<br>"; } } // foreach end } // else end } //print_r($destArr); } } else { $tmpId = 0; } } //echo "<br>"; } } } } fclose($file1); } } $result = $destArr; //print_r($destArr); //echo $timediff; return $result; }
function getTripReport($sdate, $userId, $devId, $usrSTime, $usrETime, $flag) { $cnt = 1; $tmp = -1; $t1 = 0.0; $t2 = 0.0; $timeArr = array(); $timediff = array(); $strTime = ''; $endTime = ''; $k1 = 0; $totDist = 0; $file = $GLOBALS[dataPath] . "src/data/" . date('d-m-Y', strtotime($sdate)) . "/" . $devId . ".txt"; //echo "<br><br>"; if (chk_folder($file)) { $file1 = @fopen($file, "r"); if ($file1) { while (!feof($file1)) { $data = fgets($file1); } $data = getSortedData($data); } if (count($data) > 0) { $data1 = explode("#", $data); for ($j1 = 0; $j1 < count($data1); $j1++) { $data2 = explode("@", $data1[$j1]); if (count($data2) > 1) { $data3 = explode(",", $data2[1]); //echo date("d-m-Y", strtotime($sdate))."==".date("d-m-Y",@mktime(($data3[4]+5),($data3[5]+30),$data3[6],$data3[2],$data3[1],$data3[3])); $device = $data3[0]; $geodate = $data3[8] . " " . $data3[9]; $geoTime = $data3[9]; $curTime = explode(":", $data3[9]); $curTime = $curTime[0] * 60 + $curTime[1]; $pos1 = calLat($data3[2]); $pos2 = calLong($data3[1]); if ($curTime >= $usrSTime && $curTime <= $usrETime) { if ($pos1 > 0 && $pos2 > 0) { if (!in_array($geoTime, $timeArr)) { //echo $geoTime." sss ".$data3[3]; //echo $usrSTime." >= ".$curTime." <= ".$usrETime." ".$totalDistance."<br>"; //echo "<BR>"; if ($data3[3] > 0 && $strTime == '') { $strTime = $geoTime; $res2 = simpleGeocode($pos1, $pos2); $res2 = str_replace('"', "", $res2); $strPoint = $res2; $avgSpeed += $data3[3]; $pits1 = $pos1; $pits2 = $pos2; $k1++; } else { if ($data3[3] > 0 && $endTime == '' && $strTime != '') { $avgSpeed += intval($data3[3]); $pits3 = $pos1; $pits4 = $pos2; $dist = getDistance($pits1, $pits2, $pits3, $pits4); $totDist += $dist; $pits1 = $pits3; $pits2 = $pits4; $k1++; } else { if ($data3[3] == 0 && $endTime == '' && $strTime != '') { $endTime = $geoTime; $res2 = simpleGeocode($pos1, $pos2); $res2 = str_replace('"', "", $res2); $endPoint = $res2; $avgSpeed += $data3[3]; $avgSpeed = round($avgSpeed / $k1, 2); $pits3 = $pos1; $pits4 = $pos2; $dist = getDistance($pits1, $pits2, $pits3, $pits4); $totDist += $dist; $pits1 = $pits3; $pits2 = $pits4; $finaTime = $strPoint . "#" . $strTime . "#" . $endPoint . "#" . $endTime . "#" . gmdate("H:i:s", strtotime($endTime) - strtotime($strTime)) . "#" . round($totDist) . "#" . round($avgSpeed) . "#" . $device . "#" . date('d-m-Y', strtotime($sdate)); //echo "<br>"; //echo "---------------------------------------------------------------------------------------------------------------------------------------------"; //echo "<BR>"; if ($flag == 0) { $strTime = ''; $endTime = ''; $strPoint = ''; $endPoint = ''; $pits1 = ''; $pits2 = ''; $pits3 = ''; $pits4 = ''; $totDist = 0; $avgSpeed = 0; } array_push($timediff, $finaTime); } } } $cnt++; array_push($timeArr, $geoTime); } } } } } fclose($file1); } } return $timediff; }