$realPath = realpath(dirname(__FILE__));
$maxine = substr($realPath, 0, strrpos($realPath, DIRECTORY_SEPARATOR));
$rootaccess = substr($maxine, 0, strrpos($maxine, DIRECTORY_SEPARATOR) + 1);
define("BASE", $rootaccess);
include_once BASE . "basefunctions/localdefines.php";
include_once BASE . "basefunctions/dbcontrols.php";
include_once BASE . "basefunctions/baseapis/manapi.php";
include_once BASE . "Maxine/api/maxineapi.php";
require_once BASE . "basefunctions/baseapis/fleetDayHandler.php";
$link = mysqli_connect(DB_HOST, DB_USER, DB_PASS, DB_SCHEMA) or die(mysqli_error($link));
//: End
$fleetdayobj = new fleetDayHandler();
$today = date("d");
$customday = 0;
if ($customday > 0) {
    $fleetscore = $fleetdayobj->pullFleetDayT24($customday);
    $fleetdayobj->saveFleetDay($fleetscore);
    print "<pre style='font-family:verdana;font-size:13'>";
    print_r($fleetscore);
    print "</pre>";
} else {
    print "Pulling today." . PHP_EOL;
    $fleetscore = $fleetdayobj->pullFleetDayT24($today);
    if ($fleetscore === FALSE) {
        //: broken
        print "No data recieved" . PHP_EOL;
        exit;
    }
    $fleetdayobj->saveFleetDay($fleetscore);
    if ($today > 1) {
        print "Pulling yesterday." . PHP_EOL;