diff --git a/www/articles.php b/www/articles.php index 1efa07c..c6b9ff9 100644 --- a/www/articles.php +++ b/www/articles.php @@ -1,6 +1,6 @@ Command '$op' requires a login!\n"); + html_footer(); + exit(); + } + if ($op == 'N' && $id) { html_header("Article Error"); @@ -55,6 +77,35 @@ if ($argc) 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 { @@ -62,6 +113,14 @@ else $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 @@ -69,7 +128,7 @@ switch ($op) { db_query("DELETE FROM article WHERE id = $id"); - header("Location: $PHP_SELF?L"); + header("Location: $PHP_SELF?L$options"); } else { @@ -86,9 +145,9 @@ switch ($op) html_header("Delete Article #$id"); html_start_links(1); - html_link("Return to Article List", "$PHP_SELF?L"); - html_link("View Article #$id", "$PHP_SELF?L$id"); - html_link("Modify Article #$id", "$PHP_SELF?M$id"); + 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("No Articles found.
\n"); @@ -177,33 +308,95 @@ switch ($op) exit(); } - html_start_table(array("Title","Abstract","Contents")); + if ($index >= $count) + $index = $count - ($count % $ARTICLE_PAGE_MAX); + if ($index < 0) + $index = 0; - while ($row = db_next($result)) + $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(" |