Example #1
0
});
/**
 * 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();
    $time = round(($timesResults[0]['AVG1'] + $timesResults[0]['AVG2'] + $timesResults[0]['AVG3']) / 3, 3);
    $out = array();
    $out['numTraces'] = $db->getNumberOfTraces()[0]['COUNT(*)'];
    $out['numHops'] = $db->getNumberOfHops()[0]['COUNT(*)'];
    $out['hopTime'] = $time;
    $out['averageHopsPerRoute'] = $db->getAverageHopsPerRoute()[0]['averageHopCount'];
    echo json_encode($out);
});
/**
 * Get-request to /api/info/topTraces gets the topTen traced urls for all the executed
 * and saved traceroutes so far.
 *
 * @return {json}       Returns the topTraces info-data in a json-object.
 */
$app->get('/api/info/topTraces', function () {
    $db = new Database();
    $results = $db->getTopTraces();
    echo json_encode($results);
});
/**
 * Get-request to get all hop times that are stored in the DB.