예제 #1
0
파일: index.php 프로젝트: jfrehner/tracemap
                $temp['message'] = $line;
                array_push($out['data'], $temp);
            }
        }
    }
    fclose($traceFileHandle);
    if (!$out['inProgress']) {
        // If the traceroute command is not running anymore, we can update the db
        // and delete the files
        $db->updateTracerouteFinished($id);
        unlink('traceroutes/' . $id . '.pid');
        unlink('traceroutes/' . $id . '.txt');
    }
    // Insert all the parsed information into the db
    foreach ($out['data'] as $key => $value) {
        $db->insertTraceroute($id, $value);
    }
    // Read the data we just inserted and return it to the client
    $result = $db->getTraceroute($id);
    $out['data'] = $result;
    echo json_encode($out);
});
/**
 * Get-request to /api/info/basic gets the basic stats for all the executed
 * and saved traceroutes so far.
 *
 * @return {json}       Returns the basic info-data in a json-object.
 */
$app->get('/api/info/basic', function () {
    $db = new Database();
    $timesResults = $db->getAverageHopTime();