diff --git a/www/index.php b/www/index.php index 6e8cabc..a460c39 100644 --- a/www/index.php +++ b/www/index.php @@ -1,6 +1,6 @@ Mini-XML Home Page"); print("

\n" - .""); -html_end_row(); -html_end_table(); + .""); +html_end_row(); +html_end_table(); + print("" - ."\n" html_footer(); // -// End of "$Id: index.php,v 1.5 2004/05/20 03:38:42 mike Exp $". +// End of "$Id: index.php,v 1.6 2004/05/20 15:45:55 mike Exp $". // ?> diff --git a/www/links.php b/www/links.php index 789ba77..51cba12 100644 --- a/www/links.php +++ b/www/links.php @@ -1,6 +1,6 @@ 1 && $argv[$i][1] == 'A') - $parent_id = -1; + + if (strlen($argv[$i]) > 1) + { + $listtype = $argv[$i][1]; + + if ($listtype == 'A') + $parent_id = -1; + } break; case 'P' : // Parent $parent_id = (int)substr($argv[$i], 1); break; - case 'V' : // View - $op = 'V'; - $id = (int)substr($argv[$i], 1); + case 'Q' : // Set search text + $search = $option; + $i ++; + while ($i < $argc) + { + $search .= " $argv[$i]"; + $i ++; + } break; - case 'X' : // Delete - $op = 'X'; + case 'R' : // Rate + $op = $argv[$i][0]; $id = (int)substr($argv[$i], 1); break; - case 'Z' : // List new entries - $op = 'Z'; + case 'S' : // Show web or download page + $op = $argv[$i][0]; + $type = $argv[$i][1]; + $id = (int)substr($argv[$i], 2); break; - case 'r' : // Rate - $op = $argv[$i][0]; - $id = (int)substr($argv[$i], 1); - $redirect = 1; + case 'U' : // Update/add + $op = $argv[$i][0]; + $type = $argv[$i][1]; + $id = (int)substr($argv[$i], 2); break; - case 'S' : // Show web or download page - if (strncmp($argv[$i], "SEARCH", 6)) - { - // Don't treat SEARCH as a show command... - $op = $argv[$i][0]; - $type = $argv[$i][1]; - $id = (int)substr($argv[$i], 2); - $redirect = 1; - } + case 'V' : // View + $op = 'V'; + $id = (int)substr($argv[$i], 1); + break; + + case 'X' : // Delete + $op = 'X'; + $id = (int)substr($argv[$i], 1); break; default : @@ -188,520 +218,582 @@ for ($i = 0; $i < $argc; $i ++) } } -// Check for form search data... -if (array_key_exists("SEARCH", $_GET)) - $SEARCH = $_GET["SEARCH"]; -else if (array_key_exists("SEARCH", $_POST)) - $SEARCH = $_POST["SEARCH"]; -else - $SEARCH = ""; - -if (!$redirect) -{ - html_header("Links"); - print("

Links

\n"); - print("\n" - ."
" - ."" - ."" - ."
\n" - ."\n" - ."
\n"); -} - -if ($SEARCH) -{ - // Yes, construct a query... - $op = 'L'; - $search_string = $SEARCH; - $search_string = str_replace("'", " ", $search_string); - $search_string = str_replace("\"", " ", $search_string); - $search_string = str_replace("\\", " ", $search_string); - $search_string = str_replace("%20", " ", $search_string); - $search_string = str_replace("%27", " ", $search_string); - $search_string = str_replace(" ", " ", $search_string); - $search_words = explode(' ', $search_string); - - // Loop through the array of words, adding them to the - $prefix = ""; - $next = "OR"; - - reset($search_words); - while ($keyword = current($search_words)) - { - next($search_words); - $keyword = ltrim(rtrim($keyword)); +if (array_key_exists("SEARCH", $_POST)) + $search = $_POST["SEARCH"]; - if (strcasecmp($keyword, 'or') == 0) - { - $next = 'OR'; - if ($prefix != '') - $prefix = 'OR'; - } - else if (strcasecmp($keyword, 'and') == 0) - { - $next = 'AND'; - if ($prefix != '') - $prefix = 'AND'; - } - else - { - $query = "$query $prefix name LIKE '%$keyword%'"; - $prefix = $next; - } - } -} +// Encode the search parameters so they can be propagated... +$options = "+Q" . urlencode($search); +// Now do operation.. switch ($op) { - case 'F' : // Form... - if ($type == 'C') - $typename = 'Category'; - else - $typename = 'Listing'; - - if ($id > 0) - $opname = 'Update'; - else - $opname = 'Add'; - - print("

$opname $typename

\n"); - - if ($id > 0) - { - $result = db_query("SELECT * FROM link WHERE id = $id"); - $row = db_next($result); - - $parent_id = $row['parent_id']; - $is_category = $row['is_category']; - $is_published = $row['is_published']; - $name = htmlspecialchars($row['name'], ENT_QUOTES); - $version = htmlspecialchars($row['version'], ENT_QUOTES); - $license = htmlspecialchars($row['license'], ENT_QUOTES); - $author = htmlspecialchars($row['author'], ENT_QUOTES); - $email = htmlspecialchars($row['email'], ENT_QUOTES); - $homepage = htmlspecialchars($row['homepage'], ENT_QUOTES); - $download = htmlspecialchars($row['download'], ENT_QUOTES); - $description = htmlspecialchars($row['description'], ENT_QUOTES); - $create_date = $row['create_date']; - $modify_date = $row['modify_date']; - - db_free($result); - } - else - { - if ($type == 'C') - $is_category = 1; - else - $is_category = 0; - - $is_published = 0; - $name = ""; - $version = ""; - $license = ""; - $author = ""; - $owner_email = ""; - $owner_password = ""; - $email = ""; - $homepage = "http://"; - $download = "ftp://"; - $description = ""; - $create_date = time(); - $modify_date = time(); - } - - print("\n" - ."
"); - -html_start_table(array("Current Poll [ " - ."Show All ]")); -html_start_row(); -print(""); -show_poll(get_recent_poll()); -print("
"); html_start_table(array("Quick Info"), "100%", "100%"); html_start_row(); @@ -56,13 +47,22 @@ print("" html_end_row(); html_end_table(); +html_start_table(array("Current Poll [ " + ."Show All ]")); +html_start_row(); +print(""); +show_poll(get_recent_poll()); +print("    " + ."" ."

Recent Articles [ Show All" ." ]

\n"); $result = db_query("SELECT * FROM article WHERE is_published = 1 " - ."ORDER BY modify_date DESC LIMIT 4"); + ."ORDER BY modify_date DESC LIMIT 8"); $count = db_count($result); if ($count == 0) @@ -97,6 +97,6 @@ print("
\n"); + case 'L' : // List... + html_header("Links"); + html_start_links(1); + html_link("Show All Listings", "$PHP_SELF?LA$options"); + html_link("Show Listings By Category", "$PHP_SELF?LC$options"); if ($LOGIN_LEVEL >= AUTH_DEVEL) + html_link("Show Unpublished Listings", "$PHP_SELF?LU$options"); + html_end_links(); + + print("

Links

\n"); + print("\n" + ."
" + ."" + ."" + ."
\n" + ."\n" + ."
\n"); + + if ($search != "") { - print("\n"); - } - else - { - print("\n"); - } - - print("" - ."" - ."" - ."\n"); - - print("\n"); - - if (!$is_category) - { - print("" - ."" - ."" - ."\n"); - - print("" - ."" - ."" - ."\n"); - - print("" - ."" - ."" - ."\n"); - - print("" - ."" - ."" - ."\n"); - - print("" - ."" - ."" - ."\n"); - - print("" - ."" - ."" - ."\n"); - - print("" - ."" - ."" - ."\n"); + // Construct a query... + + $search_string = $search; + $search_string = str_replace("'", " ", $search_string); + $search_string = str_replace("\"", " ", $search_string); + $search_string = str_replace("\\", " ", $search_string); + $search_string = str_replace("%20", " ", $search_string); + $search_string = str_replace("%27", " ", $search_string); + $search_string = str_replace(" ", " ", $search_string); + $search_words = explode(' ', $search_string); + + // Loop through the array of words, adding them to the + $prefix = ""; + $next = "OR"; + + reset($search_words); + while ($keyword = current($search_words)) + { + next($search_words); + $keyword = ltrim(rtrim($keyword)); + + if (strcasecmp($keyword, 'or') == 0) + { + $next = 'OR'; + if ($prefix != '') + $prefix = 'OR'; + } + else if (strcasecmp($keyword, 'and') == 0) + { + $next = 'AND'; + if ($prefix != '') + $prefix = 'AND'; + } + else + { + $query = "$query $prefix name LIKE '%$keyword%'"; + $prefix = $next; + } + } } - print("" - ."" - ."" - ."\n"); - print("" - ."" - ."" - ."\n"); - - print("
Published:"); - select_is_published($is_published); - print("
Name:
Category:"); - select_category($parent_id, $is_category); - print("
Version:
License:
Author:
EMail:
Home Page URL:
Download URL:
Description:
Announcment:
\n"); - print(""); - break; - - case 'L' : // List... - print("

Show All Listings | " - ."Show Listings by " - ."Category ]

\n"); - - if ($SEARCH == "") + if ($search == "") $category = get_category($parent_id); else $category = "Search"; + if ($listtype == 'U') + $is_published = "is_published = 0 AND "; + else if ($LOGIN_LEVEL >= AUTH_DEVEL) + $is_published = ""; + else + $is_published = "is_published = 1 AND "; + // Show the categories... if ($query != "") $result = db_query("SELECT * FROM link " - ."WHERE is_published = 1 AND is_category = 1 AND " - ."($query) " - ."ORDER BY name"); + ."WHERE ${ispublished}is_category = 1 AND " + ."($query) " + ."ORDER BY name"); else if ($parent_id >= 0) $result = db_query("SELECT * FROM link " - ."WHERE is_published = 1 AND is_category = 1 AND " - ."parent_id = $parent_id " - ."ORDER BY name"); + ."WHERE ${ispublished}is_category = 1 AND " + ."parent_id = $parent_id " + ."ORDER BY name"); else $result = db_query("SELECT * FROM link " - ."WHERE is_published = 1 AND is_category = 1 " - ."ORDER BY name"); + ."WHERE ${ispublished}is_category = 1 " + ."ORDER BY name"); if ($parent_id < 0) - { - print("

All Categories