$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));
// }
$fleetdayobj = new fleetDayHandler();
$today = date("d");
$customday = 0;
if ($customday > 0) {
    $fleetscore = $fleetdayobj->pullFleetDayWithContrib($customday);
    $fleetdayobj->saveFleetDay($fleetscore);
    print "<pre style='font-family:verdana;font-size:13'>";
    print_r($fleetscore);
    print "</pre>";
} else {
    print "Pulling today.<br>";
    $fleetscore = $fleetdayobj->pullFleetDayWithContrib($today);
    $fleetdayobj->saveFleetDay($fleetscore);
    if ($today > 1) {
        print "Pulling yesterday.<br>";
        $fleetscore = $fleetdayobj->pullFleetDayWithContrib($today - 1);
        $fleetdayobj->saveFleetDay($fleetscore);
    }
    $backday = $fleetdayobj->findBackDay($today, "contrib_max");
    print "Backday: " . $backday . ", Today: " . $today . "<br>";