Ejemplo n.º 1
0
if ($args['op'] == 'a') {
    // Check what's active
    $row = dbgetrow("select task, time_start, adjusted_hours from times where time_start is not null and duration_hours is null");
    if ($row) {
        if ($row[2] > 0) {
            echo "Active: " . $row[0] . ": " . $row[1] . " (-" . $row[2] . ") -";
        } else {
            echo "Active: " . $row[0] . ": " . $row[1] . " -";
        }
    } else {
        echo "None active.";
    }
} else {
    if ($args['op'] == 'd') {
        // How much time have we spent on what in the last 24 hours?
        $row = dbgetarray("select task, time_start, duration_hours - adjusted_hours from times where time_start is not null and to_days(time_start) == to_days(now)");
        print_r($row);
    } else {
        if ($args['op'] == '/') {
            // start, stop, or swap
            if ($args['start']) {
                dbquery("update times set duration_hours = timestampdiff(minute, time_start, %s) / 60 where time_start is not null and duration_hours is null", $args['start']);
            } else {
                dbquery("update times set duration_hours = timestampdiff(minute, time_start, now()) / 60 where time_start is not null and duration_hours is null");
            }
            $had_active = mysql_affected_rows();
            if ($args['task']) {
                if ($args['start']) {
                    dbquery("insert into times (task, time_start) values (%s, %s)", $args['task'], $args['start']);
                } else {
                    dbquery("insert into times (task, time_start) values (%s, now())", $args['task']);
Ejemplo n.º 2
0
<?php

require_once '/home/jrising/common/base.php';
require_once comdir("sql/dbfuncs.php");
$dbc = dbconnect("memoir", "ignore");
$rows = dbgetarray("select id, task, UNIX_TIMESTAMP(time_start), duration_hours - adjusted_hours, UNIX_TIMESTAMP(last_updated) from times");
$ical = "BEGIN:VCALENDAR\nVERSION:2.0\nPRODID:-//hacksw/handcal//NONSGML v1.0//EN\n";
foreach ($rows as $row) {
    if (!$row[3]) {
        continue;
    }
    $ical .= "BEGIN:VEVENT\nUID:memoir-times-" . md5($row[0]) . "@existencia.org\nDTSTAMP:" . gmdate('Ymd', $row[4]) . 'T' . gmdate('His', $row[4]) . "Z\nDTSTART:" . gmdate('Ymd', $row[2]) . 'T' . gmdate('His', $row[2]) . "Z\nDTEND:" . gmdate('Ymd', $row[2] + $row[3] * 3600) . 'T' . gmdate('His', $row[2] + $row[3] * 3600) . "Z\nSUMMARY:" . $row[1] . "\nEND:VEVENT\n";
}
$ical .= "\nEND:VCALENDAR";
//set correct content-type-header
header('Content-type: text/calendar; charset=utf-8');
header('Content-Disposition: inline; filename=calendar.ics');
echo $ical;
Ejemplo n.º 3
0
<?php

require_once "config.php";
require_once "dbfuncs.php";
$args = array_merge($_POST, $_GET);
if ($args['op'] == 'get') {
    $links = dbgetarray("select name, url from links where user_id = %d", $args['user_id']);
    foreach ($links as $name => $url) {
        echo $name . "," . $url . "\n";
    }
} else {
    if ($args['op'] == 'post') {
        dbquery("insert into links (user_id, name, url) values (%d, %s, %s) on duplicate key update url = %s", $args['user_id'], $args['name'], $args['url'], $args['url']);
        echo "DONE";
    } else {
        if ($args['op'] == 'delete') {
            dbquery("delete from links where user_id = %d and name = %s", $args['user_id'], $args['name']);
            echo "DONE";
        }
    }
}