Ejemplo n.º 1
0
    die('Not logged in');
}
$logfileRaw = $_POST['logfileRaw'];
$postHash = $_POST['hash'];
$postIp = $_POST['ip'];
$postTimestamp = $_POST['timestamp'];
if (isset($logfileRaw, $postHash, $postIp, $postTimestamp)) {
    $matches = array();
    if (preg_match("/^[-\\+#]\\[(\\d{4}-\\d{2}-\\d{2}\\w\\d{2}:\\d{2}:\\d{2})\\]\\s.*/", $logfileRaw, $matches)) {
        $curmonth = date("Ym", strtotime($matches[1]));
    }
    if ($postHash != $timetrack->hash || $postIp != $_SERVER['REMOTE_ADDR']) {
        $msg = "Something went wrong. Security Information did not match.";
    } else {
        if (time() - $postTimestamp < 5) {
            $msg = "Flash Gordon was here. Try to breathe in and out and give yourself more time to edit.";
        } else {
            if (!$timetrack->writeFile($logfileRaw, $curmonth)) {
                $msg = "Update not successful";
            } else {
                $msg = '';
                header('Location: show.php?m=' . $curmonth);
            }
        }
    }
    die($msg);
}
if (isset($_GET['m'])) {
    $timetrack->setMonth($_GET['m']);
}
include "views/editor.phtml";
Ejemplo n.º 2
0
{
    $tt->parseData();
    $ld = $tt->getLastDay();
    //print_r($ld);
    echo (isset($ld['diff']) ? $ld['diff'] : 0) . "\n";
    echo (isset($ld['monthdiff']) ? $ld['monthdiff'] : 0) . "\n";
    echo (isset($ld['laststateIn']) ? (int) $ld['laststateIn'] : 0) . "\n";
    echo (isset($ld['start']) ? $ld['start'] : 0) . "\n";
    echo (isset($ld['pause']) ? $ld['pause'] : 0) . "\n";
}
error_reporting(E_ALL);
ini_set("display_errors", 1);
$action = isset($_GET['a']) ? $_GET['a'] : '';
$hash = isset($_GET['h']) ? $_GET['h'] : '';
if (!$tt->login(null, null, $hash)) {
    die('INVALID LOGIN');
}
$curmonth = date("Ym");
if (isset($_GET['m'])) {
    $curmonth = $_GET['m'];
}
$tt->setMonth($curmonth);
if ($action == "times") {
    getTimes($tt);
}
if ($action == "login") {
    getTimes($tt);
}
if ($action == "logout") {
    getTimes($tt);
}
Ejemplo n.º 3
0
$oldend = $_POST['oldend'];
if (isset($formsend, $newstart, $newend, $oldstart, $oldend)) {
    $success = true;
    if ($oldstart != $newstart) {
        $success = $timetrack->updateFile($oldstart, $newstart);
    }
    if ($oldend != $newend) {
        $success = $timetrack->updateFile($oldend, $newend);
    }
    if (!$success) {
        die("Update not successful");
    } else {
        $forward = true;
    }
}
if (isset($_POST['daysize']) && isset($_POST['date'])) {
    $timetrack->changeDailyWorkingTimeForADay($_POST['date'], $_POST['daysize']);
    $oldstart = strtotime($_POST['date']);
    $forward = true;
}
if ($forward === true) {
    $month = date("Ym", $oldstart);
    header('Location: show.php?m=' . $month);
}
$timetrack->setMonth(date("Ym", strtotime($curdate)));
$data = $timetrack->parseData();
$day = $data['days'][$curdate];
if (!isset($day)) {
    die('Day not found!');
}
include "views/correct.phtml";
Ejemplo n.º 4
0
#!/usr/bin/php
<?php 
if (php_sapi_name() !== "cli") {
    die("This script is for command line use only");
}
include "../TimeTrack.class.php";
$dir = dirname(dirname(__FILE__));
$files = glob($dir . '/logs/*/options.ini');
$core = new TimeTrack();
$core->setMonth(date("Ym"));
foreach ($files as $optionFileName) {
    $options = json_decode(file_get_contents($optionFileName));
    $hash = basename(dirname($optionFileName));
    if (isset($options->notifications)) {
        writeLog("'{$hash}': Found notification");
        if (!isset($options->notifications->when) || !isset($options->notifications->what) || !isset($options->notifications->how)) {
            writeLog("'{$hash}': Notification settings are incomplete. Skipping.");
            continue;
        }
        if (!isset($options->notifications->enabled) || $options->notifications->enabled == false) {
            writeLog("'{$hash}': Notification is disabled. Skipping.");
            continue;
        }
        $core->login(null, null, $hash);
        $core->parseData();
        $lastdayData = $core->getLastDay();
        if (date('Y-m-d') != $lastdayData['date']) {
            writeLog('Last day is not today, skipping');
            continue;
        }
        $compareDate = $core->getNormalDayEnd();