Bad command '$op'!\n"); html_footer(); exit(); } if (($op == 'D' || $op == 'M') && !$id) { html_header("Article Error"); print("
Command '$op' requires an ID!\n"); html_footer(); exit(); } if (($op == 'D' || $op == 'M') && $LOGIN_USER == "") { html_header("Article Error"); print("
Command '$op' requires a login!\n"); html_footer(); exit(); } if ($op == 'N' && $id) { html_header("Article Error"); print("
Command '$op' may not have an ID!\n"); html_footer(); exit(); } for ($i = 1; $i < $argc; $i ++) { $option = substr($argv[$i], 1); switch ($argv[$i][0]) { case 'Q' : // Set search text $search = $option; $i ++; while ($i < $argc) { $search .= " $argv[$i]"; $i ++; } break; case 'I' : // Set first STR $index = (int)$option; if ($index < 0) $index = 0; break; default : html_header("Article Error"); print("
Bad option '$argv[$i]'!
\n"); html_footer(); exit(); break; } } } else { $op = 'L'; $id = 0; } if ($REQUEST_METHOD == "POST") { if (array_key_exists("SEARCH", $_POST)) $search = $_POST["SEARCH"]; } $options = "+I$index+Q" . urlencode($search); switch ($op) { case 'D' : // Delete Article if ($REQUEST_METHOD == "POST") { db_query("DELETE FROM article WHERE id = $id"); header("Location: $PHP_SELF?L$options"); } else { $result = db_query("SELECT * FROM article WHERE id = $id"); if (db_count($result) != 1) { print("Error: Article #$id was not found!
\n"); html_footer(); exit(); } $row = db_next($result); html_header("Delete Article #$id"); html_start_links(1); html_link("Return to Articles", "$PHP_SELF?L$options"); html_link("View Article #$id", "$PHP_SELF?L$id$options"); html_link("Modify Article #$id", "$PHP_SELF?M$id$options"); html_end_links(); print("Error: Article #$id was not found!
\n"); html_footer(); exit(); } $row = db_next($result); html_start_links(1); html_link("Return to Articles", "$PHP_SELF?L$options"); html_link("Show Comments", "#_USER_COMMENTS"); if ($LOGIN_USER) { html_link("Modify Article", "$PHP_SELF?M$id$options"); html_link("Delete Article #$id", "$PHP_SELF?D$id$options"); } html_end_links(); print("This Article is " ."currently hidden from public view. | |
---|---|
Title: | $temp |
Abstract: | $temp |
Contents: | $temp |
No Articles found.
\n"); html_footer(); exit(); } if ($index >= $count) $index = $count - ($count % $ARTICLE_PAGE_MAX); if ($index < 0) $index = 0; $start = $index + 1; $end = $index + $ARTICLE_PAGE_MAX; if ($end > $count) $end = $count; $prev = $index - $ARTICLE_PAGE_MAX; if ($prev < 0) $prev = 0; $next = $index + $ARTICLE_PAGE_MAX; print("$count article(s) found, showing $start to $end:
\n"); if ($count > $ARTICLE_PAGE_MAX) { print(""); if ($index > 0) print("[ Previous $ARTICLE_PAGE_MAX ]"); print(" | "); if ($end < $count) { $next_count = min($ARTICLE_PAGE_MAX, $count - $end); print("[ Next $next_count ]"); } print(" |
"); if ($index > 0) print("[ Previous $ARTICLE_PAGE_MAX ]"); print(" | "); if ($end < $count) { $next_count = min($ARTICLE_PAGE_MAX, $count - $end); print("[ Next $next_count ]"); } print(" |
Error: Article #$id was not found!
\n"); html_footer(); exit(); } $row = db_next($result); print("\n"); html_footer(); } break; case 'N' : // Post new Article if ($REQUEST_METHOD == "POST") { $date = time(); $is_published = db_escape($_POST["IS_PUBLISHED"]); $title = db_escape($_POST["TITLE"]); $abstract = db_escape($_POST["ABSTRACT"]); $contents = db_escape($_POST["CONTENTS"]); db_query("INSERT INTO article VALUES(NULL," ."$is_published," ."'$title'," ."'$abstract'," ."'$contents'," ."$date,'$LOGIN_USER',$date,'$LOGIN_USER')"); $id = db_insert_id(); header("Location: $PHP_SELF?L$id$options"); break; } html_header("Post New Article"); html_start_links(1); html_link("Return to Articles", "$PHP_SELF?L$options"); html_end_links(); print("