Hits: 5910

 

Absolute path found. Loading as relative.

 

List

Try: ca/tecreations/ViewFile.php -- Online


<?php

require_once $_SERVER['DOCUMENT_ROOT'] . "/tec_SiteRoot.php";

if (isset($_REQUEST['action']) && !empty($_REQUEST['action'])) {

}

global $site_db, $HOME_IP, $CLIENT_IP; 

$site_db->issue("DROP TABLE IF EXISTS tasks");
$site_db->issue("CREATE TABLE IF NOT EXISTS tasks (" .
           "    id INT AUTO_INCREMENT PRIMARY KEY," .
           "    task VARCHAR (4192) NOT NULL," .
           "    added VARCHAR(36) NOT NULL," .
           "    status VARCHAR(128) NOT NULL DEFAULT 'Unstarted'," .
           "    priority INT(10) DEFAULT 0" .

           ")");

function insertTask($task) {
    global $site_db;
    $time = new Time();
    $site_db->issue("INSERT INTO tasks (task,added) VALUES('$task','" . $time->getTimsTime() . "')");
    $priority = (int)$site_db->getVal("SELECT MAX(priority) AS val FROM tasks","val");
    $site_db->issue("UPDATE tasks SET priority='" . ($priority + 1) . "' WHERE task='$task'");
}
insertTask("Tim: Reminder: Contact Metis. Have them respond, when a break comes, ask if I can just send in a bill for address verification or copy of license. It\'s already been done, but whatever.");
insertTask("Praise God, Jesus and the Holy Spirit.");
insertTask("Complete tasks functionality");
insertTask("Test thoroughly -- Prove Correctness");

$result = $site_db->select("SELECT * FROM tasks");
print("<table>\n");
print("     <thead>\n");
print("         <tr>\n");
print("             <td align='center'>Id</td>\n");
print("             <td align='center'>Task</td>\n");
print("             <td align='center'>Added</td>\n");
print("             <td align='center'>Duration</td>\n");
print("             <td align='center'>Status</td>\n");
if ($CLIENT_IP == $HOME_IP || $CLIENT_IP == "207.34.93.1") {
    print("              <td>&nbsp;</td>\n");
    print("              <td align='center'>Priority</td>\n");
    if ($result['count'] > 1) {
        print("              <td align='center'>Down</td>\n");
        print("              <td align='center'>Up</td>\n");
     }
}
print("         </tr>\n");
print("     <thead>\n");

if ($result['count'] == 1) {
    $row = $result['rows'];
    print("    <tr>\n");
    print("        <td>" . $row['id'] . "</td>\n");
    print("        <td>" . $row['task'] . "</td>\n");
    print("        <td>" . $row['added'] . "</td>\n");
    print("        <td>duration</td>\n");
    if ($CLIENT_IP == $HOME_IP || $CLIENT_IP == "207.34.93.1") {
       // options
       print("        <td>");
       print("<select name='status'>");
       print("<option name='Ongoing' value='Ongoing'>");
       print("<option name='Unstarted' value='Unstarted'>");
       print("<option name='Started' value='Started'>");
       print("<option name='Stopped' value='Stopped'>");
       print("<option name='Paused' value='Paused'>");
       print("<option name='Delayed' value='Delayed'>");
       print("<option name='Finished' value='Finished'>");
       print("</select>");
       print("</td>\n");
    } else {
        print("        <td>" . $row['status'] . "</td>\n");
    }
    if ($CLIENT_IP == $HOME_IP || $CLIENT_IP == "207.34.93.1") {
        print("        <td><a href='/$TEC_PREFIX_DIR/index.php?action=delete&id=" . $row['id'] . "'>Delete</a></td>\n");
        print("        <td>" . $row['priority'] . "</td>\n");
        if ($result['count'] > 1) {
            print("        <td><a href='/$TEC_PREFIX_DIR/index.php?action=up&id=" . $row['id'] . "'>Up</a></td>\n");
            print("        <td><a href='/$TEC_PREFIX_DIR/index.php?action=down&id=" . $row['id'] . "'>Down</a></td>\n");
        }
    }
    print("    </tr>\n");
} else {
    $rows = $result['rows'];
    for($i = 0; $i < $result['count'];$i++) {
        $row = $rows[$i];
        print("    <tr>\n");
        print("        <td>" . $row['id'] . "</td>\n");
        print("        <td>" . $row['task'] . "</td>\n");
        print("        <td>" . $row['added'] . "</td>\n");
        print("        <td>duration</td>\n");
        if ($CLIENT_IP == $HOME_IP || $CLIENT_IP == "207.34.93.1") {
           // options
           print("        <td>");
           print("<select name='status'>");
           print("<option name='Ongoing' value='Ongoing'>");
           print("<option name='Unstarted'>Unstarted</option>");
           print("<option name='Started'>Started</option>");
           print("<option name='Stopped'>Stopped</option>");
           print("<option name='Paused'>Paused</option>");
           print("<option name='Delayed'>Delayed</option>");
           print("<option name='Finished'>Finished</option>");
           print("</select>");
           print("</td>\n");
       } else {
            print("        <td>" . $row['status'] . "</td>\n");
        }
        if ($CLIENT_IP == $HOME_IP || $CLIENT_IP == "207.34.93.1") {
            print("        <td><a href='/$TEC_PREFIX_DIR/index.php?action=delete&id=" . $row['id'] . "'>Delete</a></td>\n");
            print("        <td>" . $row['priority'] . "</td>\n");
            print("        <td><a href='/$TEC_PREFIX_DIR/index.php?action=down&id=" . $row['id'] . "'>Down</a></td>\n");
            print("        <td><a href='/$TEC_PREFIX_DIR/index.php?action=up&id=" . $row['id'] . "'>Up</a></td>\n");
        }
        print("    </tr>\n");
    }
}
print("</table>\n");

if ($CLIENT_IP == $HOME_IP || $CLIENT_IP == "207.34.93.1") {
    print("Add<br />");
}