This part of the website is dedicated to providing easy to write and easy to read online diaries or journals filled with daily thoughts, poetry, boneless blather, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on actuality, fresh insights, diverse dreams, chronicles and general madness available for general human consumption.

"; while ($diary = db_fetch_object($result)) { if ($time != date("F jS", $diary->timestamp)) { $output .= "". date("l, F jS", $diary->timestamp) ."\n"; $time = date("F jS", $diary->timestamp); } $output .= "
\n"; $output .= "

$diary->userid wrote:

\n"; $output .= "
\n"; $output .= "

". check_output($diary->text, 1) ."

[ userid\">more ]

\n"; $output .= "
\n"; $output .= "
\n"; } $theme->header(); $theme->box("Online diary", $output); $theme->footer(); } function diary_entry($timestamp, $text, $id = 0) { if ($id) { $output .= "
\n"; $output .= "
". date("l, F jS", $timestamp) .":
\n"; $output .= "

[ edit ]

". check_output($text, 1) ."

\n"; $output .= "
\n"; } else { $output .= "
\n"; $output .= "
". date("l, F jS", $timestamp) .":
\n"; $output .= "

". check_output($text, 1) ."

\n"; $output .= "
\n"; } return $output; } function diary_display($username) { global $theme, $user; $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id WHERE u.userid = '$username' ORDER BY timestamp DESC"); if ($username == $user->userid) { $output .= diary_entry(time(), "Add new diary entry!

"); while ($diary = db_fetch_object($result)) $output .= diary_entry($diary->timestamp, $diary->text, $diary->id); } else { $output .= "

". format_username($username) ."'s diary:

\n"; while ($diary = db_fetch_object($result)) $output .= diary_entry($diary->timestamp, $diary->text); } $theme->header(); $theme->box("$username's online diary", $output); $theme->footer(); } function diary_add() { global $theme, $user, $allowed_html; $output .= "
\n"; $output .= "

\n"; $output .= " Enter new diary entry:
\n"; $output .= "
\n"; $output .= " Allowed HTML tags: ". htmlspecialchars($allowed_html) .".\n"; $output .= "

\n"; $output .= "

\n"; $output .= " \n"; $output .= "

\n"; $output .= "
\n"; $theme->header(); $theme->box("Online diary", $output); $theme->footer(); } function diary_edit($id) { global $theme, $user, $allowed_html; $result = db_query("SELECT * FROM diaries WHERE id = $id"); $diary = db_fetch_object($result); $output .= diary_entry($diary->timestamp, $diary->text); $output .= "
\n"; $output .= "

\n"; $output .= " Edit diary entry:
\n"; $output .= "
\n"; $output .= " Allowed HTML tags: ". htmlspecialchars($allowed_html) .".\n"; $output .= "

\n"; $output .= "

\n"; $output .= " id\">\n"; $output .= " timestamp\">\n"; $output .= " \n"; $output .= "

\n"; $output .= "
\n"; $theme->header(); $theme->box("Online diary", $output); $theme->footer(); } function diary_preview($text, $timestamp, $id = 0) { global $theme, $user, $allowed_html; $output .= diary_entry($timestamp, $text); $output .= "
\n"; $output .= "

\n"; $output .= " Preview diary entry:
\n"; $output .= "
\n"; $output .= " Allowed HTML tags: ". htmlspecialchars($allowed_html) .".\n"; $output .= "

\n"; $output .= "

\n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "

\n"; $output .= "
\n"; $theme->header(); $theme->box("Online diary", $output); $theme->footer(); } function diary_submit($text, $id = 0) { global $user, $theme; if ($id) { watchdog("message", "old diary entry updated"); db_query("UPDATE diaries SET text = '". check_input($text) ."' WHERE id = $id"); } else { watchdog("diary", "new diary entry added"); db_query("INSERT INTO diaries (author, text, timestamp) VALUES ('$user->id', '". check_input($text) ."', '". time() ."')"); } header("Location: diary.php?op=view&name=$user->userid"); } ### Security check: if (strstr($id, " ") || strstr($name, " ")) { watchdog("error", "diary: attempt to provide malicious input through URI"); exit(); } switch($op) { case "add": diary_add(); break; case "edit": diary_edit($id); break; case "view": diary_display($name); break; case "Preview diary entry": if ($id) diary_preview($text, $timestamp, $id); else diary_preview($text, time()); break; case "Submit diary entry": if ($id) diary_submit($text, $id); else diary_submit($text); break; default: diary_overview(); } ?>