Пример #1
0
{
    function __construct($stringDB)
    {
        //Funktion som öppnar önskad databas.
        $this->open($stringDB);
    }
}
$type = $_REQUEST["type"];
//Läser in variablen type från GET-meddelandet.
if ($type == "getLogs") {
    //Hämta alla loggar	graphLog.php?type=getLogs
    getLogs();
} else {
    if ($type == "loadLog") {
        //Ladda ett loggschema graphLog.php?type=loadLog&date="2015/05/20 10:47"
        loadLog();
    } else {
        if ($type == "deleteLog") {
            //Ta bort en logg 	graphLog.php?type=deleteLog&date="2015/04/22"
            deleteLog();
        } else {
            if ($type == "loadCurrent") {
                //Load the most recent log  graphLog.php?type=loadCurrent
                loadCurrent();
            }
        }
    }
}
function getLogs()
{
    $db = new MyDB("sqltemptime.db");
Пример #2
0
function updateLog($data, $result)
{
    $log = loadLog();
    $log['timestamp_last_check'] = time();
    $log['urls_in_list'] = count($data);
    $log['lookups_since_last_notification'] = $log['lookups_since_last_notification'] + count($data);
    $log['lookups_since_start'] = $log['lookups_since_start'] + count($data);
    $log['errors_last_detected'] = count($result);
    $log['errors_since_last_notification'] = $log['errors_since_last_notification'] + count($result);
    $log['errors_since_start'] = $log['errors_since_start'] + count($result);
    $log['last_detected_urls'] = $result;
    $log['script_execution'] = $log['script_execution'] + 1;
    if ($log['timestamp_last_check'] - $log['timestamp_last_notification'] >= 86400) {
        //if more than 24 hours since last notification
        if (SEND_DAILY_EMAIL) {
            dailyResultsToEmail($log);
        }
        if (SEND_DAILY_SLACK) {
            dailyResultsToSlack($log);
        }
        $log['timestamp_last_notification'] = time();
        $log['lookups_since_last_notification'] = count($data);
        $log['errors_since_last_notification'] = count($result);
    }
    saveLog($log);
}