Example #1
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;
    }
}
Example #2
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);
    }
}
Example #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;
    }
}
Example #4
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;
}
                $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]));
                            if ($pos1 > 0 && $pos2 > 0) {
                                if (!in_array($geoTime, $timeArr)) {
                                    if ($data3[9] > $row[gti_max_speed]) {
                                        //echo $data3[11];
                                        $res = simpleGeocode($pos1, $pos2);
                                        //print_r($res);
                                        $res = str_replace('"', "", $res);
                                        //echo $res."<br>";
                                        $outData .= $geodate . ',' . $data3[0] . ',' . $geoTime . ',' . $res . ',' . round($data3[9]) . ',' . $row[gti_max_speed];
                                        $outData .= "@";
                                        ?>
	  
      <tr <?php 
                                        if ($cnt % 2 == 0) {
                                            echo 'class="odd_row"';
                                        } else {
                                            echo 'class="even_row"';
                                        }
                                        ?>
 >
Example #6
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;
}