Ejemplo n.º 1
0
function findDistance($data)
{
    $timeArr = array();
    $totalDistance = 0;
    $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);
    }
    return round($totalDistance);
}
Ejemplo n.º 2
0
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;
    }
}
Ejemplo n.º 3
0
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;
    }
}
Ejemplo n.º 4
0
function liveKmsPerDay($lData, $sTime1, $eTime1)
{
    $timeArr = array();
    //$ptArr = array();
    $cnt = 0;
    $totalDistance = 0;
    $data1 = explode("#", $lData);
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1];
            //echo "<br>";
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        if ($cnt == 0) {
                            $pits1 = $pos1;
                            $pits2 = $pos2;
                        } else {
                            $pits3 = $pos1;
                            $pits4 = $pos2;
                            //echo $sTime1." >= ".$curTime." <= ".$eTime1." ".$totalDistance."<br>";
                            $dist = getDistance($pits1, $pits2, $pits3, $pits4);
                            $totalDistance += $dist;
                            $pits1 = $pits3;
                            $pits2 = $pits4;
                        }
                    }
                }
                $cnt++;
            }
        }
        array_push($timeArr, $geoTime);
    }
    //$res=simpleGeocode($pos1,$pos2);
    //$res=str_replace('"',"",$res);
    $finalData = round($totalDistance);
    return $finalData;
}
function storeData1($data)
{
    //echo $data;
    $data1 = explode("#", $data);
    $latnlong_values = "";
    if ($_GET[sessionID] != '') {
        $getDriver = "SELECT di_id,di_driverId,di_license,di_firstName,di_lastName,di_phone1,di_profile_image from driver_info,gps_task_info, vehicle_info  WHERE gti_clientId=" . $_GET[sessionID] . " AND di_id=gti_driver_id AND  '" . $_GET[date_offline] . "' BETWEEN DATE_FORMAT( gti_start_date, '%Y-%m-%d' ) AND DATE_FORMAT( gti_end_date, '%Y-%m-%d' ) AND vi_reg_no = '" . $_GET[phoneNumber] . "' LIMIT 0 , 30";
        $resDriver = mysql_query($getDriver);
        $fetchDriver = @mysql_fetch_assoc($resDriver);
        $qr = "SELECT * FROM gps_geopoints_info WHERE gpi_clientID=" . $_SESSION["clientID"];
        $rs_geofence_details = mysql_query($qr);
        if (@mysql_num_rows($rs_geofence_details) == 0) {
            $latnlong_values = "";
        } else {
            $latnlong_values = "";
            $ct = 0;
            while ($fetch_geofence_details = @mysql_fetch_assoc($rs_geofence_details)) {
                //print_r($fetch_geofence_details);
                if ($ct == 0) {
                    $latnlong_values = $fetch_geofence_details[gpi_miles] . "," . $fetch_geofence_details[gpi_latVal] . "," . $fetch_geofence_details[gpi_longVal] . "@";
                    $ct++;
                } else {
                    $latnlong_values .= $fetch_geofence_details[gpi_miles] . "," . $fetch_geofence_details[gpi_latVal] . "," . $fetch_geofence_details[gpi_longVal] . "@";
                    $ct++;
                }
                if ($ct != @mysql_num_rows($rs_geofence_details)) {
                    $point_names .= $fetch_geofence_details[gpi_stopName] . ",";
                } else {
                    $point_names .= $fetch_geofence_details[gpi_stopName];
                }
            }
            //echo $latnlong_values;
        }
    } else {
        $client_array = array();
        $res_clients = SuperAdminSF::getClients();
        while ($clientIds = mysql_fetch_assoc($res_clients)) {
            array_push($client_array, $clientIds);
        }
        for ($cl = 0; $cl < count($client_array); $cl++) {
            $fetchDriver = getDriverDetails($client_array[$cl][clin_id], $_GET[date_offline], $_GET[phoneNumber]);
        }
    }
    $xml = '<gps geoData="' . $latnlong_values . '" geoPointName="' . $point_names . '">';
    $timeArr = array();
    $totalDistance = 0;
    if ($_GET[from_hrs] != '' && ($fm = $_GET[from_mins] != '' && ($th = $_GET[to_hrs] != '' && ($tm = $_GET[to_mins] != '')))) {
        for ($j1 = 0; $j1 < count($data1); $j1++) {
            $data2 = explode("\$", $data1[$j1]);
            if (count($data2) > 1) {
                $data3 = explode(",", $data2[1]);
                if (date("d-m-Y", strtotime($_GET[date_offline])) == date("d-m-Y", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]))) {
                    $fh = $_GET[from_hrs];
                    $fm = $_GET[from_mins];
                    $fs = '00';
                    $th = $_GET[to_hrs];
                    $tm = $_GET[to_mins];
                    $ts = '00';
                    $h = date("H", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    $m = date("i", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    $s = date("s", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
                    if ($fh == $th && $fh == $h) {
                        if ($m >= $fm && $m < $tm) {
                            $show = 1;
                        } else {
                            $show = 0;
                        }
                    } else {
                        if ($h >= $fh && $h <= $th) {
                            if ($h < $th) {
                                if ($m >= $fm || $m < $tm) {
                                    $show = 1;
                                } else {
                                    $show = 0;
                                }
                            } else {
                                if ($h == $th) {
                                    if ($m >= $fm && $m < $tm) {
                                        $show = 1;
                                    } else {
                                        $show = 0;
                                    }
                                }
                            }
                        } else {
                            $show = 0;
                        }
                    }
                    if ($show == 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)) {
                                //echo $sPt=$pos1."#".$pos2;
                                if ($cnt == 1) {
                                    $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 . '"  route="' . $rtName . '"/>';
                            }
                        }
                    }
                    array_push($timeArr, $geoTime);
                }
            }
        }
    } else {
        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 . '"  route="' . $rtName . '"/>';
                    }
                }
            }
            array_push($timeArr, $geoTime);
        }
    }
    //echo $totalDistance;
    $xml .= '</gps>';
    header('Content-Type: text/xml');
    echo $xml;
}
Ejemplo n.º 6
0
 $c = 0;
 preg_match_all("/(a href\\=\")([^\\?\"]*)(\")/i", get_text($path1), $matches);
 //print_r($matches[2]);
 $xml = '<gps>';
 for ($i = 1; $i < count($matches[2]); $i++) {
     //echo $mydata=gpspathFun($path1,$matches[2][$i]);
     $mydata = gpspathAll($path1, $matches[2][$i]);
     $data1 = explode("#", $mydata);
     $data2 = explode("\$", $data1[count($data1) - 2]);
     if (count($data2) > 1) {
         $data3 = explode(",", $data2[1]);
         $vehi = $data3[0];
         $date = date("Y-m-d H:i:s", @mktime($data3[4] + 5, $data3[5] + 30, $data3[6], $data3[2], $data3[1], $data3[3]));
         $info .= "Direction : " . $data3[10] . "&lt;br&gt;";
         $pos1 = calLat($data3[7]);
         $pos2 = calLong($data3[8]);
         $lat = $pos1;
         $lng = $pos2;
         $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="' . $lat . '" longitude="' . $lng . '" speed="' . $mph . '" direction="' . $direction . '" distance="" locationMethod="327681" gpsTime="' . $date . '" phoneNumber="' . $phoneNumber . '" sessionID="' . $sessionID . '" accuracy="11" isLocationValid="yes" extraInfo="' . $extraInfo . '" />';
         $vehicle_reg_no[$c] = explode('.', $matches[2][$i]);
Ejemplo n.º 7
0
function geoAlrtPerDay($lData, $sTime1, $eTime1)
{
    $timeArr = array();
    //$ptArr = array();
    $cnt = 0;
    $totalDistance = 0;
    $data1 = explode("#", $lData);
    $timeArr = array();
    $timediff = array();
    $srcArr = array();
    $destArr = array();
    $strTime = '';
    $endTime = '';
    $endPoint = '';
    $tmpId = -1;
    $lat_lngArr = array();
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1];
            //echo "<br>";
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                //echo "<br>";
                //echo $curTime." >= ".$sTime1." && ".$curTime."<=".$eTime1;
                //echo "<br>";
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_clientId = " . $_SESSION[clientID] . " AND tgi_isActive = 1 ORDER BY tgi_id ASC";
                        //$getDevice = "SELECT * FROM `tb_geofence_info` WHERE `tgi_name` = 'Colva Beach'";
                        $resDevice = mysql_query($getDevice);
                        if (@mysql_affected_rows() > 0) {
                            while ($fetDevice = @mysql_fetch_assoc($resDevice)) {
                                $lat_lngArr = explode("#", $fetDevice[tgi_coordinates]);
                                for ($i = 0; $i < count($lat_lngArr) - 1; $i++) {
                                    $lat_lng1 = explode(",", $lat_lngArr[$i]);
                                    $lat_lng[$i] = $lat_lng1[0] . "," . $lat_lng1[1];
                                }
                                //print_r($lat_lng);
                                //exit;
                                $res = getGeofenceStatus($lat_lng, $pos1, $pos2);
                                if ($res) {
                                    if ($tmpId == -1) {
                                        $tmpId = $fetDevice[tgi_id];
                                        $finaTime[] = $tmpId . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                    } elseif ($tmpId == $fetDevice[tgi_id]) {
                                        $endTime = $geodate . " " . $geoTime;
                                        //echo " ";
                                        $endId = $fetDevice[tgi_id];
                                        $endPoint = $fetDevice[tgi_name];
                                        //echo "<br>";
                                        //$tmpId = $fetDevice[tgi_id];
                                    } elseif ($tmpId != $fetDevice[tgi_id] && $tmpid != -1 && $endPoint != '') {
                                        //$finaTime .=$endTime."#LEFT#".$endPoint."@";
                                        //echo $tmpId."#".$geodate." ".$geoTime."#".$endTime."#Left#".$endPoint;
                                        //echo "<br>";
                                        $finaTime[] = $tmpId . "#" . $endTime . "#Left#" . $endPoint;
                                        $tmpId = $fetDevice[tgi_id];
                                        $endPoint = "";
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                        //echo "<br>";
                                    }
                                    //echo $finaTime;
                                    //echo "<br>";
                                }
                                $result_pt = "";
                                $lat_lngArr = "";
                                $lat_lng = array();
                                /*if($res == 1 && $data3[3]>0 && $strTime=='')
                                		{
                                			 $finaTime .=$geoTime."#Entered#".$fetDevice[tgi_name]."@";
                                			 $strTime = $geoTime;
                                			 
                                		}
                                		else if($res == 1 && $data3[3]==0 && $endTime=='' && $strTime!='')
                                		{													
                                			$finaTime .=$geoTime."#LEFT#".$fetDevice[tgi_name]."@";
                                			
                                		}*/
                                /*if($res)
                                		{
                                			echo $finaTime = $geodate."#".$geoTime."#".$fetDevice[tgi_name]."@";
                                			echo "<br>";
                                			$strTime='';
                                			$endTime='';
                                			$lat_lngArr = '';
                                		}*/
                            }
                        }
                    }
                }
                $cnt++;
            }
        }
        array_push($timeArr, $geoTime);
    }
    //print_r($finaTime);
    //exit;
    if (count($finaTime) > 0) {
        $finaTime = implode("@", $finaTime);
        return $finaTime;
    } else {
        return false;
    }
}
Ejemplo n.º 8
0
    @fclose($file1);
}
if (isset($_GET[gpsdata]) && $_GET[gpsdata]) {
    $gpsdata = str_replace("\$", "", $_GET[gpsdata]);
    $gpsdata = str_replace("@", "", $gpsdata);
    $gpsdata = explode(",", $gpsdata);
    if ($gpsdata[8] == date("d-m-Y")) {
        $path1 = $GLOBALS[dataPath] . "src/data/" . date('d-m-Y', strtotime($gpsdata[8])) . "/" . $gpsdata[0] . ".txt";
        $mydata = gpspathAll($path1);
        $data1 = explode("#", $mydata);
        $data2 = explode("@", $data1[count($data1) - 2]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            //print_r($data3);
            $lat = calLat($data3[2]);
            $lng = calLong($data3[1]);
            $devDateTime = $data3[8] . " " . $data3[9];
            $devImei = $data3[0];
            $sessionid = $_GET["sessionid"];
        }
        //exit;
        $getDevice = "SELECT * FROM tb_deviceinfo WHERE di_imeiId = " . $gpsdata[0] . " AND di_status = 1";
        $resDevice = $db->query($getDevice);
        if ($db->affected_rows > 0) {
            $fetDevice = $db->fetch_array($resDevice);
            //print_r($fetDevice);
            $getGeofenceInfo = "SELECT * FROM tb_assigngeofence WHERE tag_diId = " . $fetDevice[di_id] . " AND tag_isActive = 1 ORDER BY tag_id ASC";
            $resGeofenceInfo = $db->query($getGeofenceInfo);
            if ($db->affected_rows > 0) {
                while ($fetGeofence = $db->fetch_array($resGeofenceInfo)) {
                    $gpspts = $fetGeofence[tag_geofenceId] . "#" . $fetGeofence[tag_id] . "#" . $fetGeofence[tag_alertSrc] . "#" . $fetGeofence[tag_noofTimes] . "#" . $fetGeofence[tag_inout];
Ejemplo n.º 9
0
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;
}
Ejemplo n.º 10
0
function storeData($data, $km, $devName, $sTime2, $eTime2)
{
    //echo $data;
    $data1 = explode("#", $data);
    $latnlong_values = "";
    //$xml = '<gps geoData="'.$latnlong_values.'" geoPointName="'.$point_names.'">';
    $km = explode("#", $km);
    $totKm += $km[0];
    $totPath .= $km[1];
    //print_r($km);
    //exit;
    $xml = '<gps>';
    $timeArr = array();
    $totalDistance = 0;
    $ct = 0;
    $j1 = 0;
    while ($j1 < count($data1)) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            //print_r($data3);
            $date = $data3[8] / 1000;
            $date = $data3[8] . " " . $data3[9];
            $geodate = $data3[8] . " " . $data3[9];
            $geoTime = $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;
                    }
                    $mph = $data3[3];
                    $direction = $data3[4];
                    $altitute = $data3[5];
                    $deviceIMEI = $data3[0];
                    $sessionID = $_GET["sessionID"];
                    $accuracy = $data3[6];
                    $extraInfo = $data3[6];
                    $fule_param = $data3[7];
                    $d = preg_split("/[\\s,]+/", $fule_param);
                    foreach ($d as $e) {
                        if (substr($e, 0, 3) == '[9=') {
                            $fuel = str_replace(array('[9=', ']'), '', $e);
                        }
                        if (substr($e, 0, 3) == '[1=') {
                            $engine = str_replace(array('[1=', ']'), '', $e);
                            if ($engine == '1') {
                                $engine_st = 'On';
                            } else {
                                $engine_st = 'Off';
                            }
                        }
                    }
                    $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" altitute="' . $altitute . '" curTime = "' . $curTime . '" distance="' . round($totalDistance) . '" gpsTime="' . date("h:i A", strtotime($geoTime)) . '" geodate="' . $geodate . '" deviceIMEI="' . $deviceIMEI . '" deviceName="' . $devName . '" sessionID="' . $sessionID . '"  extraInfo="' . $extraInfo . '"  route="' . $rtName . '"  other="' . $data3[7] . '"/>';
                }
            }
        }
        array_push($timeArr, $geoTime);
        if ($j1 > 0) {
            $dif = count($data1) - $j1;
            if ($dif > 10) {
                $j1 = $j1 + 10;
            } else {
                $j1 = $j1 + 1;
            }
            //echo $dif." ".$j1." ".count($data1)."<br>";
        } else {
            $j1 = $j1 + 1;
            //echo $dif." ".$j1." ".count($data1)."<br>";
        }
    }
    $xml .= '<OtherData totPt="' . $totPath . '" geoData="" geoPointName="" totalDist="' . $totKm . '" />';
    $xml .= '</gps>';
    header('Content-Type: text/xml');
    echo $xml;
}
Ejemplo n.º 11
0
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;
}
Ejemplo n.º 12
0
<?php

error_reporting(E_ALL ^ E_NOTICE);
require "../includes/config.inc.php";
require "../includes/Database.class.php";
require "../includes/GPSFunction.php";
require "../includes/smsSF.php";
require "../includes/mailSMTP.php";
$db = new Database(DB_SERVER, DB_USER, DB_PASS, DB_DATABASE);
$db->connect();
if (isset($_GET[gpsdata]) && $_GET[gpsdata]) {
    $gpsdata = str_replace("\$", "", $_GET[gpsdata]);
    $gpsdata = str_replace("@", "", $gpsdata);
    $gpsdata = explode(",", $gpsdata);
    $lat = calLat($gpsdata[2]);
    $lng = calLong($gpsdata[1]);
    $devDateTime = $gpsdata[8] . " " . $gpsdata[9];
    $devImei = $gpsdata[0];
    if ($gpsdata[8] == date("d-m-Y")) {
        $getDevice = "SELECT * FROM tb_deviceinfo WHERE di_imeiId = " . $gpsdata[0] . " AND di_status = 1";
        $resDevice = $db->query($getDevice);
        if ($db->affected_rows > 0) {
            $fetDevice = $db->fetch_array($resDevice);
            //print_r($fetDevice);
            $getGeofenceInfo = "SELECT * FROM tb_assigngeofence WHERE tag_diId = " . $fetDevice[di_id] . " AND tag_isActive = 1 ORDER BY tag_id ASC";
            $resGeofenceInfo = $db->query($getGeofenceInfo);
            if ($db->affected_rows > 0) {
                while ($fetGeofence = $db->fetch_array($resGeofenceInfo)) {
                    $gpspts = $fetGeofence[tag_geofenceId] . "#" . $fetGeofence[tag_id] . "#" . $fetGeofence[tag_alertSrc] . "#" . $fetGeofence[tag_noofTimes] . "#" . $fetGeofence[tag_inout];
                    $resSrv1 = explode("#", $gpspts);
                    //print_r($resSrv1);
Ejemplo n.º 13
0
function geoAlrtPerDay($lData, $sTime1, $eTime1)
{
    $cnt = 0;
    $data1 = explode("#", $lData);
    $timeArr = array();
    /*$latlngArr = drawCircle("15.2857824","73.958976","0.50");
    	for($i=0; $i<count($latlngArr);$i++)
    	{
    		$tarr = explode(",",$latlngArr[$i]);
    		$newArr[]= $tarr[1].",".$tarr[0];
    	}
    	print_r($latlngArr);
    	echo $res = getGeofenceStatus($latlngArr,"15.2677360","73.9664768");
    
    	exit;*/
    for ($j1 = 0; $j1 < count($data1); $j1++) {
        $data2 = explode("@", $data1[$j1]);
        if (count($data2) > 1) {
            $data3 = explode(",", $data2[1]);
            //echo '<pre>';print_r($data3); echo '</pre>';
            $geodate = $data3[8];
            $geoTime = $data3[9];
            $curTime = explode(":", $data3[9]);
            $curTime = $curTime[0] * 60 + $curTime[1] + $curTime[2];
            if ($curTime >= $sTime1 && $curTime <= $eTime1) {
                $pos1 = calLat($data3[2]);
                $pos2 = calLong($data3[1]);
                //$pos1 = "17.4145664";
                //$pos2 = "78.4665856";
                //echo $curTime." >= ".$sTime1." && ".$curTime."<=".$eTime1." ".$tmpId." ".$res." ".$pos1.",".$pos2;
                //echo "<br>";
                if ($pos1 > 0 && $pos2 > 0) {
                    if (!in_array($geoTime, $timeArr)) {
                        $getDevice = "SELECT * FROM tb_geofence_info WHERE tgi_clientId = " . $_SESSION[clientID] . " AND tgi_isActive = 1 ORDER BY tgi_id ASC";
                        $resDevice = mysql_query($getDevice);
                        if (@mysql_affected_rows() > 0) {
                            while ($fetDevice = @mysql_fetch_assoc($resDevice)) {
                                $lat_lng = explode(",", $fetDevice[tgi_latLong]);
                                $radius = $fetDevice[tgi_radius];
                                //echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$pos1." , ".$pos2."<br>";
                                $latlngArr = drawCircle($lat_lng[0], $lat_lng[1], $radius);
                                $res = getGeofenceStatus($latlngArr, $pos1, $pos2);
                                if ($res) {
                                    if (count($geoId) == 0) {
                                        $geoId[] = $fetDevice[tgi_id];
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                        //echo "<br><br>";
                                        $end = 0;
                                    } else {
                                        if ($geoId[count($geoId) - 1] != $fetDevice[tgi_id]) {
                                            /*echo $lat_lng[0]." , ".$lat_lng[1]." , ".$radius." , ".$pos1." , ".$pos2."<br>";
                                            		echo '<pre>';print_r($latlngArr);echo '</pre>';
                                            		for($i=0; $i<count($latlngArr);$i++)
                                            		{
                                            			$tarr = explode(",",$latlngArr[$i]);
                                            			$str .= "new GLatLng(".$tarr[1].",".$tarr[0]."),";
                                            		}
                                            		echo $str;
                                            		exit;*/
                                            $geoId[] = $fetDevice[tgi_id];
                                            $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Entered#" . $fetDevice[tgi_name];
                                            //echo "<br><br>";
                                            $end = 0;
                                        }
                                    }
                                } else {
                                    if ($geoId[count($geoId) - 1] == $fetDevice[tgi_id] && $end == 0) {
                                        $geoId[] = $fetDevice[tgi_id];
                                        $end = 1;
                                        $finaTime[] = $fetDevice[tgi_id] . "#" . $geodate . " " . $geoTime . "#Left#" . $fetDevice[tgi_name];
                                        //echo "<br><br>";
                                    }
                                }
                            }
                        }
                        array_push($timeArr, $geoTime);
                    }
                }
            }
        }
    }
    //print_r($finaTime);
    //exit;
    if (count($finaTime) > 0) {
        $finaTime = implode("@", $finaTime);
        return $finaTime;
    } else {
        return false;
    }
}
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;
    }
}
Ejemplo n.º 15
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]);
         $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]));
         //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]));
         if (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]))) {
             $pos1 = convertLat(calLat($data3[7]));
             $pos2 = convertLong(calLong($data3[8]));
             $vehi = $data3[0];
             if ($pos1 > 0 && $pos2 > 0) {
                 if (!in_array($geoTime, $timeArr)) {
                     $sts = geoStatusReport($pos1, $pos2, $vehi);
                     //echo $sts."asds".$data3[9];
                     //echo "<br>";
                     if ($sts == 0) {
                         if ($data3[9] > 0) {
                             //$res=simpleGeocode($pos1,$pos2);
                             //print_r($res);
                             //$res=str_replace(",","-",$res[0]);
                             //echo $res."<br>";
                             $outData .= $geodate . ',' . $vehi . ',' . $geoTime . ',' . $res . ',' . $pos1 . ',' . $pos2 . ',' . round($data3[9]);
                             $outData .= "@";
                             ?>
Ejemplo n.º 16
0
         		$datDate1 = $z[$y];*/
         break;
     }
     @fclose($path);
 }
 //echo $path;
 //exit;
 if ($mydata = gpspathFun($path)) {
     $data1 = explode("#", $mydata);
     $data2 = explode("@", $data1[count($data1) - 2]);
     if (count($data2) > 1) {
         $data3 = explode(",", $data2[1]);
         //print_r($data3);
         $vehi = $data3[0];
         $pos1 = calLat($data3[2]);
         $pos2 = calLong($data3[1]);
         $recTime = date("h:i A", strtotime($data3[9]));
         $d = explode("-", $data3[8]);
         $result_pt = $fetDevice[di_deviceId] . "#" . $fetDevice[di_imeiId] . "#" . "00ff00" . "#0#" . $_GET[sessionid] . "#" . $d[0] . "#" . $d[1] . "#" . $d[2] . "#" . $fetDevice[di_imeiId] . "#" . $recTime . "#" . $pos1 . "#" . $pos2 . "#" . $fetDevice[di_deviceName] . "#" . $data3[3];
     }
     //$d = explode("-",$_GET[date_offline]);
     //$result_pt = $fetDevice[di_deviceId]."#".$fetDevice[di_imeiId]."#"."00ff00"."#0#".$_GET[sessionid]."#".$d[0]."#".$d[1]."#".$d[2]."#".$fetDevice[di_imeiId]."####".$fetDevice[di_deviceName]."#-1";
     //$result_pt = $fetDevice[di_deviceId]."#".$fetDevice[di_imeiId]."#"."ff0000"."#"."n"."#".$fetDevice[di_deviceName];
     //exit;
     if ($tmpId != $fetDevice[ci_clientName]) {
         $tmpId = $fetDevice[ci_clientName];
         $destArr[$tmpId] = $result_pt;
     } else {
         foreach ($destArr as $key => $value) {
             // echo "Key: $key; Value: $value<br />\n";
             if ($key == $tmpId) {
Ejemplo n.º 17
0
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;
}
Ejemplo n.º 18
0
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);
    }
}
Ejemplo n.º 19
0
function storeData($data, $km, $devName, $sTime2, $eTime2)
{
    //echo $data;
    $latnlong_values = "";
    //$xml = '<gps geoData="'.$latnlong_values.'" geoPointName="'.$point_names.'">';
    $km = explode("#", $km);
    $totKm += $km[0];
    $totPath .= $km[1];
    //print_r($km);
    //exit;
    $xml = '<gps>';
    $timeArr = array();
    $totalDistance = 0;
    $ct = 0;
    $j1 = 0;
    $data1 = explode("#", $data);
    $data2 = explode("@", $data1[count($data1) - 2]);
    if (count($data2) > 1) {
        $data3 = explode(",", $data2[1]);
        //print_r($data3);
        $date = $data3[8] / 1000;
        $date = $data3[8] . " " . $data3[9];
        $geodate = $data3[8] . " " . $data3[9];
        $geoTime = $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;
                }
                $mph = $data3[3];
                $direction = $data3[4];
                $altitute = $data3[5];
                $deviceIMEI = $data3[0];
                $sessionID = $_GET["sessionID"];
                $accuracy = $data3[6];
                $extraInfo = $data3[6];
                $devModel = getDeviceModel($data3[0]);
                $xml .= '<locations latitude="' . $pos1 . '" longitude="' . $pos2 . '" speed="' . $mph . '" direction="' . $direction . '" altitute="' . $altitute . '" curTime = "' . $curTime . '" distance="' . round($totalDistance) . '" gpsTime="' . date("h:i A", strtotime($geoTime)) . '" geodate="' . $geodate . '" deviceIMEI="' . $deviceIMEI . '" deviceName="' . $devName . '" sessionID="' . $sessionID . '" fuel=3 extraInfo="' . $extraInfo . '"  deviceModel="' . $devModel . '" route="' . $rtName . '" other="' . $data3[7] . '"/>';
            }
        }
    }
    array_push($timeArr, $geoTime);
    //}
    $xml .= '<OtherData totPt="' . $totPath . '" geoData="" geoPointName="" totalDist="' . $totKm . '" />';
    $xml .= '</gps>';
    header('Content-Type: text/xml');
    echo $xml;
}