--- /dev/null
+php_flag register_globals off
+php_flag magic_quotes_gpc off
+Options -MultiViews
+AddDefaultCharset UTF-8
+RewriteEngine on
+RewriteRule ^$ /run.php
+RewriteRule ^[^/]*\.html$ /run.php
+RewriteRule ^[^/.]*$ /run.php
--- /dev/null
+<?php
+
+require_once('code/db_connect.php');
+require_once('code/wfpl/session_messages.php');
--- /dev/null
+<?php
+
+require_once('code/wfpl/db.php');
+
+db_connect('jasonwoof');
--- /dev/null
+<?php
+
+define('TASK_DRAFT', 0);
+define('TASK_NEEDS_CLARIFICATION', 100);
+define('TASK_NEEDS_QUOTE', 200);
+define('TASK_NEEDS_GO_AHEAD', 300);
+define('TASK_QUEUED', 400);
+define('TASK_WORKING', 500);
+define('TASK_BUG', 600);
+define('TASK_NEEDS_TESTING', 700);
+define('TASK_FINISHED', 800);
+
+# switch($state) {
+# case TASK_DRAFT:
+# case TASK_NEEDS_CLARIFICATION:
+# case TASK_NEEDS_QUOTE:
+# case TASK_NEEDS_GO_AHEAD:
+# case TASK_QUEUED:
+# case TASK_WORKING:
+# case TASK_BUG:
+# case TASK_NEEDS_TESTING:
+# case TASK_FINISHED:
+# }
+
+# return true if $state is one where the client must act next
+function needs_client_attention($state) {
+ switch($state) {
+ case TASK_DRAFT:
+ case TASK_NEEDS_CLARIFICATION:
+ case TASK_NEEDS_GO_AHEAD:
+ case TASK_NEEDS_TESTING:
+ return true;
+ default:
+ return false;
+ }
+}
+
+function task_state_pretty($state) {
+ switch($state) {
+ case TASK_DRAFT:
+ return "draft";
+ case TASK_NEEDS_CLARIFICATION:
+ return "needs clarification";
+ case TASK_NEEDS_QUOTE:
+ return "waiting for price from Jason";
+ case TASK_NEEDS_GO_AHEAD:
+ return "waiting for you to approve price";
+ case TASK_QUEUED:
+ return "queued";
+ case TASK_WORKING:
+ return "work in progress";
+ case TASK_BUG:
+ return "investigation in progress";
+ case TASK_NEEDS_TESTING:
+ return "needs testing";
+ case TASK_FINISHED:
+ return "finished";
+ default:
+ return "unknown state #$state";
+ }
+}
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>tasks entry</title>
+ <link rel="stylesheet" href="style.css" type="text/css" />
+</head>
+
+<body>
+ <!--~main_body start~-->
+
+ <h2>Progress</h2>
+
+ <p>This page is for commissioning Jason Woofenden, working out the details of what is to be done and the cost, and managing schedules and priorities.</p>
+
+ <p><a href="tasks?tasks_new=1">Commission a new feature/update</a> • <a href="tasks?tasks_new_bug=1">Report a problem</a><!-- • <a href="pay">Pay Jason</a>--></p>
+
+ <!--~needs_attention start~-->
+ <div class="task_list needs_attention">
+ <h3 class="left">Tasks needing your attention:</h3>
+ <!--~needs_attention_row start~-->
+ <div><a href="tasks?tasks_edit_id=~task_id~">Task #~task_id~: ~task_title.html~</a> (~task_state~)</div>
+ <!--~end~-->
+ <!--~end~-->
+
+ <!--~queue start~-->
+ <div class="task_list queue">
+ <h3>Prioritized queue</h3>
+ <p>Use the arrows on the left to change the order.</p>
+ <!--~queue_row start~-->
+ <div><a href="tasks?id=~task_id~">Task #~task_id~: ~task_title.html~</a> (~task_price.money~)</div>
+ <!--~end~-->
+ <!--~end~-->
+
+ <!--~jason start~-->
+ <div class="task_list jason_working">
+ <h3>Tasks waiting for Jason:</h3>
+ <!--~jason_row start~-->
+ <div><a href="tasks?id=~task_id~">Task #~task_id~: ~task_title.html~</a> (~task_state~)</div>
+ <!--~end~-->
+ <!--~end~-->
+
+ <!--~jason_working start~-->
+ <div class="task_list jason_working">
+ <h3>Jason is currently working on:</h3>
+ <!--~jason_working_row start~-->
+ <div><a href="tasks?id=~task_id~">Task #~task_id~: ~task_title.html~</a> (~task_price.money~)</div>
+ <!--~end~-->
+ <!--~end~-->
+
+ <!--~finished_unpaid start~-->
+ <div class="task_list finished_unpaid">
+ <h3>Finished tasks (unpaid)</h3>
+ <!--~finished_unpaid_row start~-->
+ <div><a href="tasks?id=~task_id~">Task #~task_id~: ~task_title.html~</a> (~task_price.money~)</div>
+ <!--~end~-->
+ <div>Total: ~task_total.money~</div>
+ <!--~end~-->
+
+ <!--~finished_paid start~-->
+ <div class="task_list finished_paid">
+ <h3>Finished and paid for</h3>
+ <!--~finished_paid_row start~-->
+ <div><a href="tasks?id=~task_id~">Task #~task_id~: ~task_title.html~</div>
+ <!--~end~-->
+ <!--~finished_paid_and_more start~-->
+ <div>...</div>
+ <!--~end~-->
+ <!--~end~-->
+
+<!--~end~-->
+</body>
+</html>
--- /dev/null
+<?php
+
+require_once('code/tasks.php');
+
+function enc_money($float) {
+ return format_money($float, $cents = true);
+}
+
+function index_main() {
+ if(!logged_in()) {
+ return './login';
+ }
+ $ret = _index_main();
+ if($ret) {
+ return $ret;
+ }
+ tem_show('main_body');
+}
+
+function task_summary($tem_prefix, $where_clause) {
+ $rows = db_get_rows('tasks', 'id,price,title,state', $where_clause);
+ if($rows) {
+ $total = 0.0;
+ foreach($rows as $row) {
+ list($id, $price, $title, $state) = $row;
+ tem_set('task_id', $id);
+ tem_set('task_title', $title);
+ tem_set('task_price', $price);
+ tem_set('task_state', task_state_pretty($state));
+ tem_show($tem_prefix . '_row');
+ $total += $price;
+ }
+
+ tem_set('task_total', $total);
+
+ tem_show($tem_prefix);
+ }
+}
+
+function _index_main() {
+ task_summary('needs_attention', 'where state=' . TASK_DRAFT . ' || state=' . TASK_NEEDS_CLARIFICATION . ' || state=' . TASK_NEEDS_GO_AHEAD . ' || state=' . TASK_NEEDS_TESTING . ' order by id');
+ task_summary('queue', 'where state=' . TASK_QUEUED . ' || state='. TASK_BUG . ' order by ord');
+ task_summary('jason', 'where state=' . TASK_NEEDS_QUOTE . ' || state=' . TASK_WORKING . ' || state=' . TASK_BUG . ' order by id desc');
+ #task_summary('jason_pricing', 'where state=' . TASK_NEEDS_QUOTE . ' order by id desc');
+ #task_summary('jason_working', 'where state=' . TASK_WORKING . ' order by id desc');
+ task_summary('finished_unpaid', 'where state=' . TASK_FINISHED . ' && paid = 0 order by id desc');
+ task_summary('finished_paid', 'where state=' . TASK_FINISHED . ' && paid = 1 order by id desc');
+ return;
+}
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title></title>
+</head>
+
+<body>
+ <!--~main_body start~-->
+ <h3>Client Login</h3>
+
+ <!--~failed start~-->
+ <h5 style="color: red">Incorrect username and/or password</h5>
+ <!--~end~-->
+
+ <form action="login.html" method="post">
+ <input type="hidden" name="url" value="~url.attr~" />
+
+ <table style="margin-left: 40px" cellspacing="0" cellpadding="4" border="0" summary="">
+ <tr>
+ <td class="caption">Username:</td>
+
+ <td><input type="text" name="username" value="~username.attr~" /></td>
+ </tr>
+
+ <tr>
+ <td class="caption">Password:</td>
+
+ <td><input type="password" name="password" value="~password.attr~" /></td>
+ </tr>
+
+ <tr>
+ <td class="submit_row" colspan="2"><input type="submit" value="Proceed" /></td>
+ </tr>
+ </table>
+ </form>
+ <!--~end~-->
+</body>
+</html>
--- /dev/null
+<?php
+
+function login_get_fields() {
+ $username = format_oneline($_REQUEST['username']);
+ tem_set('username', $username);
+
+ $password = format_oneline($_REQUEST['password']);
+
+ $url = format_unix($_REQUEST['url']);
+ tem_set('url', $url);
+
+ return array($username, $password, $url);
+}
+
+function login_main() {
+ if(isset($GLOBALS['url'])) {
+ $_REQUEST['url'] = $GLOBALS['url'];
+ tem_set('url', $GLOBALS['url']);
+ }
+
+ if(isset($_REQUEST['username'])) {
+ list($username, $password, $url) = login_get_fields();
+
+ if($username == 'test' && $password == 'test') {
+ message("Logged in successfully.");
+ session_new();
+ session_set('auth_username', "admin:$id");
+ if($url) {
+ return $url;
+ } else {
+ return './';
+ }
+ }
+
+ tem_sub('failed');
+ }
+ tem_sub('main_body');
+}
+
+?>
--- /dev/null
+.index_body h3 {
+ text-align: left;
+ margin: 15px 0px 5px;
+}
+
+#badges {
+ margin-top: 30px;
+}
--- /dev/null
+tasks form submitted with the following:
+
+client_id: ~client_id~
+ord: ~ord~
+title: ~title~
+url: ~url~
+description:
+~description.tab~
+state: ~state~
+paid: ~paid~
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>tasks entry</title>
+ <link rel="stylesheet" href="style.css" type="text/css" />
+</head>
+
+<body>
+ <!--~main_body start~-->
+
+<!--~form start~-->
+ <h2><!--~new_msg start~-->Add a new entry<!--~end~--><!--~edit_msg start~-->Edit entry "~client_id.html~"<!--~end~--></h2>
+
+ <form action="tasks" method="post"><!--~editing start~--><input type="hidden" name="tasks_edit_id" value="~tasks_edit_id.attr~" /><!--~end~-->
+ <table cellspacing="0" cellpadding="4" border="0" summary="">
+
+ <tr><td class="caption">Title: </td><td class="field"><input type="text" name="title" value="~title.attr~" /></td></tr>
+
+ <tr><td class="caption">Url: </td><td class="field"><input type="text" name="url" value="~url.attr~" /></td></tr>
+
+ <tr><td class="caption">Description: </td><td class="field"><textarea rows="9" cols="22" name="description">~description.html~</textarea></td></tr>
+
+ <tr><td class="submit_row" colspan="2"><input type="submit" name="save" value="Save" /></td></tr>
+ </table>
+ </form>
+<!--~end~-->
+
+<!--~thankyou start~-->
+ <p>Thank you for taking the time to fill out this form.</p>
+<!--~end~-->
+
+<!--~end~-->
+</body>
+</html>
--- /dev/null
+<?php
+
+require_once('code/tasks.php');
+
+$GLOBALS['tasks_form_recipient'] = "fixme@example.com";
+
+define('TASKS_DB_FIELDS', 'title,url,description,state');
+
+
+require_once('code/wfpl/template.php');
+require_once('code/wfpl/format.php');
+require_once('code/wfpl/messages.php');
+require_once('code/wfpl/email.php');
+require_once('code/db_connect.php');
+
+function tasks_get_fields() {
+ $title = format_oneline($_REQUEST['title']);
+ $url = format_oneline($_REQUEST['url']);
+ $description = format_unix($_REQUEST['description']);
+
+ tasks_tem_sets($title, $url, $description);
+
+ return array($title, $url, $description);
+}
+
+function tasks_tem_sets($title, $url, $description) {
+ tem_set('title', $title);
+ tem_set('url', $url);
+ tem_set('description', $description);
+}
+
+function tasks_main() {
+ $ret = _tasks_main();
+ if($ret) {
+ return $ret;
+ }
+ tem_show('main_body');
+}
+
+function _tasks_main() {
+ $edit_id = format_int($_REQUEST['tasks_edit_id']);
+ unset($_REQUEST['tasks_edit_id']);
+ if($edit_id) {
+ # add hidden field for database id of row we're editing
+ tem_set('tasks_edit_id', $edit_id);
+ tem_show('editing');
+ }
+
+ $delete_id = format_int($_REQUEST['tasks_delete_id']);
+ unset($_REQUEST['tasks_delete_id']);
+ if($delete_id) {
+ db_delete('tasks', 'where id=%i', $delete_id);
+ message('Task deleted.');
+
+ return './tasks.html';
+ }
+
+ if(!$edit_id) {
+ tem_show('new_msg');
+ }
+
+ if(isset($_REQUEST['title'])) {
+ list($title, $url, $description) = tasks_get_fields();
+
+ if("you're happy with the POSTed values") {
+ if($edit_id) {
+ db_update('tasks', 'title,url,description,state', $title, $url, $description, $state, $paid = 0, 'where id=%i', $edit_id);
+ message('Task updated.');
+ } else {
+ # new task
+ $paid = 0;
+ if(isset($_REQUEST['save_draft'])) {
+ $state = TASK_DRAFT;
+ } else {
+ $state = TASK_NEEDS_QUOTE;
+ }
+ $client_id = 4; # FIXME
+ db_insert('tasks', 'client_id,title,url,description,state,paid', $client_id, $title, $url, $description, $state, $paid);
+ message('Task saved.');
+ return './';
+ }
+ if($GLOBALS['tasks_form_recipient'] != "fixme@example.com") {
+ $to = $GLOBALS['tasks_form_recipient'];
+ $from = $to;
+ $reply_to = '';
+ if(isset($_REQUEST['email']) and valid_email($_REQUEST['email'])) {
+ $reply_to = $_REQUEST['email'];
+ if($_REQUEST['name'] and ereg('^[a-zA-Z0-9_\' -]*$', $_REQUEST['name']) !== false) {
+ $reply_to = "$_REQUEST[name] <$reply_to>";
+ }
+ }
+ $subject = 'tasks form submitted';
+ $message = tem_run('tasks.email.txt');
+ $cc = '';
+ $bcc = '';
+ if(email($from, $to, $subject, $message, $reply_to, $cc, $bcc)) {
+ message('Due to an internal error, your message could not be sent. Please try again later.');
+ $error = true;
+ }
+ }
+ if($error !== true) {
+ tem_show('thankyou');
+ return;
+ }
+ }
+ # otherwise, we display the form again. tasks_get_fields() has
+ # already put the posted values back into the template engine, so they will
+ # show up in the form fields. You should add some message asking people to
+ # fix their entry in whatever way you require.
+ } elseif($edit_id) {
+ # we've recieved an edit id, but no data. So we grab the values to be edited from the database
+ list($client_id, $ord, $title, $url, $description, $state, $paid) = db_get_row('tasks', TASKS_DB_FIELDS, 'where id=%i', $edit_id);
+ tasks_tem_sets($client_id, $ord, $title, $url, $description, $state, $paid);
+ } else {
+ # form not submitted, you can set default values like so:
+ #tem_set('client_id', 'Yes');
+ }
+
+ # this has to be later in the file because it requres that client_id be set already
+ if($edit_id) {
+ tem_show('edit_msg');
+ }
+
+ tem_show('form');
+}
+
+?>
--- /dev/null
+drop table if exists tasks;
+create table tasks (
+ id int unique auto_increment,
+ client_id int not null default 0,
+ finished_at varchar(20) not null default "",
+ price varchar(20) not null default "",
+ ord int not null default 0,
+ title varchar(200) not null default "",
+ url varchar(200) not null default "",
+ description text not null default "",
+ state int not null default 0,
+ paid int not null default 0
+);
--- /dev/null
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head>
+ <title>JasonWoof -- Website Services</title>
+ <link rel="stylesheet" href="style3.css" type="text/css" />
+ <link rel="stylesheet" href="tasks.css" type="text/css" />
+ <meta name="robots" content="all" />
+ <link rel="openid.server" href="http://www.myopenid.com/server" /><link rel="openid.delegate" href="http://jasonwoof.myopenid.com/" /><link rel="openid2.local_id" href="http://jasonwoof.myopenid.com" /><link rel="openid2.provider" href="http://www.myopenid.com/server" /><meta http-equiv="X-XRDS-Location" content="http://www.myopenid.com/xrds?username=jasonwoof.myopenid.com" />
+ <meta name="description" content="Web design, web hosting and website creation by Jason Woofenden" />
+ <meta name="keywords" content="Jason Woofenden, JasonWoof, Web design, webdesign, web hosting, webhosting, website, website creation, design, programming, database, databases" />
+</head>
+
+<body>
+ <div id="background"></div>
+ <div id="background2"></div>
+
+ <div id="box0">
+ <div id="box1">
+ <div id="box2">
+ <div id="box3">
+ <p id="logo"></p>
+
+ <div id="body" class="~basename~_body">
+ <!--~message_container start~-->
+ <div style="border: 2px solid red; background: #fbb; padding: 5px; margin: 20px 0px">
+ <!--~message_box start~-->
+ <!--~message_divider start~-->
+ <hr />
+ <!--~end~-->
+ <p style="font-size: 120%; padding: 5px; margin: 0px">~message_text.html~</p>
+ <!--~end~-->
+ </div>
+ <!--~end~-->
+ <!--~main_body~-->
+ </div>
+
+ <div id="badges">
+ <a href="http://www.fsf.org/register_form?referrer=4579" title="Please support the Free Software Foundation"><img width="88" height="31" src="images/fsf4579.png" alt="[FSF Associate Member]" /></a> <a href="http://en.wikinews.org/wiki/Main_Page" title="News by and for the community"><img width="88" height="31" src="images/wikinews_badge.png" alt="[WikiNews]" /></a> <a href="http://endsoftpatents.org/innovating-without-patents" title="Software patents inhibit progress"><img width="88" height="31" src="images/esp-iwp.png" alt="[Innovating Without Patents]" /></a>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+</body>
+</html>