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_start_table(array("Current Poll [ "
- ."Show All ]"));
-html_start_row();
-print(" ");
-show_poll(get_recent_poll());
-print(" ");
-html_end_row();
-html_end_table();
+ ."");
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(" ");
+html_end_row();
+html_end_table();
+
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"
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 @@
//
-// "$Id: links.php,v 1.1 2004/05/20 12:31:54 mike Exp $"
+// "$Id: links.php,v 1.2 2004/05/20 15:45:55 mike Exp $"
//
// Hierarchical link interface.
//
@@ -13,8 +13,8 @@
// Include necessary headers...
//
-include "data/html.php";
-include "data/common.php";
+include "phplib/html.php";
+include "phplib/common.php";
//
@@ -127,59 +127,89 @@ else
$op = 'L';
}
-// Check command-line...
-$redirect = 0;
+// Get command-line options...
+//
+// Usage: links.php [operation] [options]
+//
+// Operations:
+//
+// LA = List all links
+// LC = List links by category
+// LU = List unpublished links
+// R# = Rate listing #
+// SH# = Show homepage for listing #
+// SD# = Show download for listing #
+// UC = Add new category
+// UC# = Modify category #
+// UL = Add new listing
+// UL# = Modify listing #
+// V# = View listing #
+// X# = Delete category or listing #
+//
+// Options:
+//
+// P# = Set parent ID
+// Qtext = Set search text
+
+$search = "";
+$op = "L";
+$listtype = "C";
for ($i = 0; $i < $argc; $i ++)
{
switch ($argv[$i][0])
{
- case 'F' : // Form
- case 'U' : // Update/add
- $op = $argv[$i][0];
- $type = $argv[$i][1];
- $id = (int)substr($argv[$i], 2);
- break;
-
case 'L' : // List or search
$op = 'L';
- if (strlen($argv[$i]) > 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");
-}
-
-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("");
- 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 \n");
- }
+ print("All Categories \n");
else
- {
- print("Categories in $category \n");
- }
+ print("Categories in $category \n");
+
+ print("\n");
while ($row = db_next($result))
{
- print("$row['name ");
+ $id = $row["id"];
+ $name = htmlspecialchars($row["name"]);
+
+ print("$name ");
- if ($LOGIN_USER)
+ if ($LOGIN_LEVEL >= AUTH_DEVEL || $LOGIN_USER == $row["create_user"])
{
- print(" [ Edit |"
- ." Delete ]");
+ print(" [ Edit |"
+ ." Delete ]");
}
print(" \n");
}
- print("[ Add New Category ]
\n");
-
print(" \n");
+ html_start_links();
+ html_link("Submit New Category", "$PHP_SELF?FC+P$parent_id$options");
+ html_end_links();
+
db_free($result);
// Then show the listings...
if ($query != "")
$result = db_query("SELECT * FROM link "
- ."WHERE is_published = 1 AND is_category = 0 AND "
- ."($query) "
- ."ORDER BY name");
+ ."WHERE ${ispublished}is_category = 0 AND "
+ ."($query) "
+ ."ORDER BY name");
else if ($parent_id >= 0)
$result = db_query("SELECT * FROM link "
- ."WHERE is_published = 1 AND is_category = 0 AND "
- ."parent_id = $parent_id "
- ."ORDER BY name");
+ ."WHERE ${ispublished}is_category = 0 AND "
+ ."parent_id = $parent_id "
+ ."ORDER BY name");
else
$result = db_query("SELECT * FROM link "
- ."WHERE is_published = 1 AND is_category = 0 "
- ."ORDER BY name");
+ ."WHERE ${ispublished}is_category = 0 "
+ ."ORDER BY name");
if ($parent_id < 0)
- {
- print("All Listings \n");
- }
+ print("All Listings \n");
else
- {
- print("Listings in $category \n");
- }
+ print("Listings in $category \n");
+
+ print("\n");
+ html_start_links();
+ html_link("Submit New Listing", "$PHP_SELF?UL+P$parent_id$options");
+ html_end_links();
+
db_free($result);
+
+ html_footer();
break;
case 'U' : // Add or update category or listing...
- global $IS_PUBLISHED;
- global $PARENT_ID;
- global $NAME;
- global $OWNER_EMAIL;
- global $OWNER_PASSWORD;
- global $NEW_PASSWORD;
- global $NEW_PASSWORD2;
- global $VERSION;
- global $LICENSE;
- global $EMAIL;
- global $HOMEPAGE;
- global $DOWNLOAD;
- global $DESCRIPTION;
- global $NEWS;
- global $AUTHOR;
-
- $parent_id = (int)$PARENT_ID;
- $name = mysql_escape_string($NAME);
- $version = mysql_escape_string($VERSION);
- $license = mysql_escape_string($LICENSE);
- $author = mysql_escape_string($AUTHOR);
- $owner_email = mysql_escape_string($OWNER_EMAIL);
- $email = mysql_escape_string($EMAIL);
- $homepage = mysql_escape_string($HOMEPAGE);
- $download = mysql_escape_string($DOWNLOAD);
- $description = mysql_escape_string($DESCRIPTION);
- $date = time();
-
- if ($type == 'C')
- $typename = 'Category';
- else
- $typename = 'Listing';
-
- if ($id > 0)
- $opname = 'Updated';
- else
- $opname = 'Added';
-
if ($id > 0)
{
+ // Get current link data from database...
$result = db_query("SELECT * FROM link WHERE id = $id");
- $row = db_next($result);
+ if (db_count($result) != 1)
+ {
+ // Link doesn't exist!
+ db_free($result);
+ header("Location: $PHP_SELF");
+ exit();
+ }
+
+ $row = db_next($result);
+
+ if ($LOGIN_LEVEL < AUTH_DEVEL && $LOGIN_USER != $row["create_user"])
+ {
+ // No permission!
+ db_free($result);
+ header("Location: $PHP_SELF");
+ exit();
+ }
- $is_category = $row['is_category;
- $owner_password = $row['owner_password;
+ $is_category = $row['is_category'];
+ $is_published = $row['is_published'];
+ $name = $row['name'];
+ $version = $row['version'];
+ $license = $row['license'];
+ $author = $row['author'];
+ $email = $row['email'];
+ $homepage_url = $row['homepage_url'];
+ $download_url = $row['download_url'];
+ $description = $row['description'];
db_free($result);
}
else
{
+ // Use default information for type...
if ($type == 'C')
$is_category = 1;
else
$is_category = 0;
- $owner_password = "";
+ if ($LOGIN_LEVEL >= AUTH_DEVEL)
+ $is_published = 1;
+ else
+ $is_published = 0;
+
+ $name = "";
+ $version = "";
+ $license = "";
+ $author = "";
+ $email = "";
+ $homepage_url = "http://";
+ $download_url = "ftp://";
+ $description = "";
}
- if ($owner_email == "")
- {
- print("$typename '$NAME' Not $opname \n");
- print("The owner email address cannot be empty!
\n");
- break;
- }
+ $announcement = "";
- if ($owner_password != "" && $owner_password != $OWNER_PASSWORD &&
- !$LOGIN_USER)
+ if ($REQUEST_METHOD == "POST")
{
- print("$typename '$NAME' Not $opname \n");
- print("The password you supplied does not match the "
- ."current password!
\n");
- break;
- }
+ if (array_key_exists("PARENT_ID", $_POST))
+ $parent_id = (int)$_POST["PARENT_ID"];
- if ($NEW_PASSWORD != "" && $NEW_PASSWORD != $NEW_PASSWORD2)
- {
- print("$typename '$NAME' Not $opname \n");
- print("The passwords you supplied do not match!
\n");
- break;
- }
+ if ($LOGIN_LEVEL >= AUTH_DEVEL &&
+ array_key_exists("IS_PUBLISHED", $_POST))
+ $is_published = (int)$_POST["IS_PUBLISHED"];
- if ($NEW_PASSWORD == "" && $owner_password == "")
- {
- print("$typename '$NAME' Not $opname \n");
- print("You must supply a password!
\n");
- break;
- }
+ if (array_key_exists("NAME", $_POST))
+ $name = $_POST["NAME"];
- if ($NEW_PASSWORD != "")
- {
- $owner_password = $NEW_PASSWORD;
+ if (array_key_exists("VERSION", $_POST))
+ $version = $_POST["VERSION"];
+
+ if (array_key_exists("LICENSE", $_POST))
+ $license = $_POST["LICENSE"];
+
+ if (array_key_exists("AUTHOR", $_POST))
+ $author = $_POST["AUTHOR"];
+
+ if (array_key_exists("EMAIL", $_POST))
+ $email = $_POST["EMAIL"];
+
+ if (array_key_exists("HOMEPAGE_URL", $_POST))
+ $homepage_url = $_POST["HOMEPAGE_URL"];
+
+ if (array_key_exists("DOWNLOAD_URL", $_POST))
+ $download_url = $_POST["DOWNLOAD_URL"];
+
+ if (array_key_exists("DESCRIPTION", $_POST))
+ $description = $_POST["DESCRIPTION"];
+
+ if (array_key_exists("ANNOUNCEMENT", $_POST))
+ $announcement = $_POST["ANNOUNCEMENT"];
+
+ if ($name != "" &&
+ ($is_category ||
+ ($version != "" && $license != "" &&
+ $author != "" && $description != "" &&
+ $homepage_url != "http://" && $download_url != "ftp://")))
+ $havedata = 1;
+ else
+ $havedata = 0;
}
+ else
+ $havedata = 0;
+
+ if ($type == 'C')
+ $typename = 'Category';
+ else
+ $typename = 'Listing';
- if ($id == 0)
+ if ($id > 0)
+ $opname = 'Update';
+ else
+ $opname = 'Create';
+
+ $heading = htmlspecialchars("$opname $typename $name");
+ html_header($heading);
+
+ 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("$heading \n");
+
+ if ($havedata)
{
- // Insert a new record...
- db_query("INSERT INTO link VALUES(0,$parent_id,"
- ."$is_category,$IS_PUBLISHED,"
- ."'$name','$version','$license',"
- ."'$author','$owner_email','$owner_password',"
- ."'$email','$homepage','$download',"
- ."'$description',$date,$date,5,1,0,0)");
-
- $id = db_insertID();
+ $name = db_escape($name);
+ $version = db_escape($version);
+ $license = db_escape($license);
+ $author = db_escape($author);
+ $email = db_escape($email);
+ $homepage_url = db_escape($homepage_url);
+ $download_url = db_escape($download_url);
+ $user = db_escape($LOGIN_USER);
+ $date = time();
+
+ if ($id == 0)
+ {
+ // Insert a new record...
+ db_query("INSERT INTO link VALUES(NULL,$parent_id,"
+ ."$is_category,$is_published,"
+ ."'$name','$version','$license',"
+ ."'$author','$email','$homepage_url','$download_url',"
+ ."'$description',5,1,0,0,$date,'$user',$date,'$user')");
+
+ $id = db_insert_id();
+ }
+ else
+ {
+ // Modify the existing record...
+ db_query("UPDATE link SET is_published=$is_published,"
+ ."parent_id=$parent_id,"
+ ."name='$name',version='$version',license='$license',"
+ ."author='$author',email='$email',"
+ ."homepage_url='$homepage_url',download_url='$download_url',"
+ ."description='$description',modify_date=$date,"
+ ."modify_user='$user' "
+ ."WHERE id=$id");
+ }
+
+ if ($announcement != "")
+ {
+ $abstract = db_escape(abbreviate($announcement, 80));
+ $announcement = db_escape("[ "
+ ."More Info ]
\n"
+ . $announcement);
+
+ db_query("INSERT INTO article VALUES(NULL,$is_published,"
+ ."'$name $version','$abstract','$announcement',$date,"
+ ."'$user',$date,'$user')");
+
+ $article_id = db_insert_id();
+
+ //
+ mail($PROJECT_EMAIL, "$PROJECT_NAME Article #$id $what",
+ wordwrap("$row[create_user] has $what an article titled, "
+ ."'$row[title]' with the following abstract:\n\n"
+ ." $row[abstract]\n\n"
+ ."Please approve or delete this article via the following "
+ ."page:\n\n"
+ ." $PHP_URL?L$id\n"),
+ "From: noreply@easysw.com\r\n");
+ }
+
+ print("$typename '$NAME' $opname \n");
+
+ if ($is_published == 0)
+ {
+ // Send email to moderators...
+ $what = strtolower("${opname}d");
+ $message = wordwrap("'$name' has been $what on the $PROJECT_NAME "
+ ."links page and requires your approval before "
+ ."it will be made visible on the $PROJECT_NAME "
+ ."site. Please go to the following link to "
+ ."process the submission:\n\n"
+ ." $PHP_URL?U$type$id\n");
+
+ mail($PROJECT_EMAIL, "$PROJECT_NAME $typename $opname",
+ $message, "From: noreply@easysw.com\r\n");
+
+ // Let the user know that the moderator must approve it...
+ print("Your submission will be made visible as soon as one of "
+ ."moderators approves it.
\n");
+ }
+ else
+ print("Thank you, your submission is now visible on the site.
\n");
+
+ html_start_links();
+ html_link("Return to Listing", "$PHP_SELF?L+P$parent_id");
+ html_end_links();
}
else
{
- // Modify the existing record...
- db_query("UPDATE link SET is_published=$IS_PUBLISHED,"
- ."parent_id=$parent_id,"
- ."name='$name',version='$version',license='$license',"
- ."author='$author',owner_email='$owner_email',"
- ."owner_password='$owner_password',email='$email',"
- ."homepage='$homepage',download='$download',"
- ."description='$description',modify_date=$date "
- ."WHERE id=$id");
- }
+ if ($REQUEST_METHOD == "POST")
+ {
+ $what = strtolower($typename);
- if ($NEWS != "")
- {
- $news = mysql_escape_string($NEWS);
+ print("Error: Please fill in the fields marked in "
+ ."bold red below and resubmit "
+ ."your $what.
\n");
- if ($homepage)
- $nhp = "links.php?SH$id";
+ $hstart = "";
+ $hend = " ";
+ }
else
- $nhp = "";
+ {
+ $hstart = "";
+ $hend = "";
+ }
- if ($download)
- $ndl = "links.php?SD$id";
+ $name = htmlspecialchars($name, ENT_QUOTES);
+ $version = htmlspecialchars($version, ENT_QUOTES);
+ $license = htmlspecialchars($license, ENT_QUOTES);
+ $author = htmlspecialchars($author, ENT_QUOTES);
+ $email = htmlspecialchars($email, ENT_QUOTES);
+ $homepage_url = htmlspecialchars($homepage_url, ENT_QUOTES);
+ $download_url = htmlspecialchars($download_url, ENT_QUOTES);
+ $abstract = htmlspecialchars($announcement, ENT_QUOTES);
+
+ print(" \n"
+ ."\n");
+
+ if ($LOGIN_LEVEL >= AUTH_DEVEL)
+ {
+ print("Published: ");
+ select_is_published($is_published);
+ print(" \n");
+ }
else
- $ndl = "";
+ {
+ print(" \n");
+ }
- db_query("INSERT INTO news VALUES(0,$id,'$name $version',$date,"
- ."'$author','$news','$nhp','$ndl',$date,'$email',"
- ."0,'','PENDING')");
- }
+ if ($name == "")
+ print("${hstart}Name:${hend} ");
+ else
+ print("Name: ");
+ print(" "
+ ." \n");
- print("$typename '$NAME' $opname \n");
+ print("Category: ");
+ select_category($parent_id, $is_category);
+ print(" \n");
- if ($opname == "Added")
- {
- // Send email to moderators...
- mail("cups-link", "New $typename Added to CUPS Links",
- "'$name' has been added to the CUPS links page\n"
- ."and requires your approval before it will be made visible on\n"
- ."the CUPS site.\n"
- ."\n"
- ." http://www.cups.org/private/links.php\n");
-
- // Let the user know that the moderator must approve it...
- print("Your addition will be made visible as soon as one of "
- ."moderators approves it.
\n");
- }
+ if (!$is_category)
+ {
+ if ($version == "")
+ print("${hstart}Version:${hend} ");
+ else
+ print("Version: ");
+ print(" \n");
+
+ if ($license == "")
+ print("${hstart}License:${hend} ");
+ else
+ print("License: ");
+ print(" \n");
+
+ if ($author == "")
+ print("${hstart}Author:${hend} ");
+ else
+ print("Author: ");
+ print(" \n");
+
+ if (!validate_email($email) && $email != "")
+ print("${hstart}EMail:${hend} ");
+ else
+ print("EMail: ");
+ print(" \n");
+
+ if ($homepage_url == "http://")
+ print("${hstart}Home Page URL:${hend} ");
+ else
+ print("Home Page URL: ");
+ print(" \n");
+
+ if ($download_url == "ftp://")
+ print("${hstart}Download URL:${hend} ");
+ else
+ print("Download URL: ");
+ print(" \n");
+
+ if ($description == "")
+ print("${hstart}Description:${hend} ");
+ else
+ print("Description: ");
+ print("$description \n");
+ }
- if ($NEWS != "")
- {
- // Send email to moderators...
- mail("cups-link", "$name $version Posted to CUPS News",
- "An announcement for '$name $version' has been posted\n"
- ."from the CUPS links page and requires your approval before it\n"
- ."will be made visible on the CUPS site.\n"
- ."\n"
- ." http://www.cups.org/private/news.php\n");
-
- // Let the user know that the moderator must approve it...
- print("Your news announcement will be made visible as soon as one of "
- ."moderators approves it.
\n");
+ print("Announcment: ");
+ print(""
+ ."$announcement \n");
+ print(" "
+ ." "
+ ." \n");
+ print("
\n");
+ print(" ");
}
- print("Return to listing.
\n");
+ html_footer();
break;
case 'V' : // View a listing...
$result = db_query("SELECT * FROM link WHERE id = $id");
- $row = db_next($result);
+ if (db_count($result) != 1)
+ {
+ db_free($result);
+ header("Location: $PHP_SELF");
+ exit();
+ }
- $create_date = date("M d, Y", $row['create_date);
- $modify_date = date("M d, Y", $row['modify_date);
- $category = get_category($row['parent_id);
- $rating = (int)(100 * $row['rating_total / $row['rating_count) * 0.01;
- $email = sanitize_email($row['email);
+ $row = db_next($result);
- if (($row['homepage_visits + $row['download_visits) > 0)
+ if ($row["is_published"] == 0 && $LOGIN_LEVEL < AUTH_DEVEL &&
+ $LOGIN_USER != $row["create_user"])
+ {
+ // No permission!
+ db_free($result);
+ header("Location: $PHP_SELF");
+ exit();
+ }
+
+ $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_url = htmlspecialchars($row['homepage_url'], ENT_QUOTES);
+ $download_url = htmlspecialchars($row['download_url'], ENT_QUOTES);
+ $description = format_text($row['description']);
+ $create_date = date("M d, Y", $row['create_date']);
+ $modify_date = date("M d, Y", $row['modify_date']);
+ $category = get_category($row['parent_id']);
+ $rating = (int)(100 * $row['rating_total'] /
+ $row['rating_count']) * 0.01;
+ $email = sanitize_email($row['email']);
+
+ if (($row['homepage_visits'] + $row['download_visits']) > 0)
{
$visits = db_query("SELECT MAX(homepage_visits), "
- ."MAX(download_visits) FROM link");
+ ."MAX(download_visits) FROM link");
$visrow = db_next($visits);
- $maxhpv = "MAX(homepage_visits)";
- $maxdlv = "MAX(download_visits)";
-
- $popularity = (int)(100 *
- ($row['homepage_visits + $row['download_visits) /
- ($visrow->$maxhpv + $visrow->$maxdlv));
+ $popularity = (int)(100 * ($row['homepage_visits'] +
+ $row['download_visits']) /
+ ($visrow['MAX(homepage_visits)'] +
+ $visrow['MAX(download_visits)']));
if ($popularity < 0)
$popularity = 0;
@@ -713,22 +805,26 @@ switch ($op)
$popularity = "???";
}
+ html_header("$name $version");
- print("[ "
- ."Return to Listings "
- ." | "
- ."Comments "
- ." | "
- ."Edit This Listing "
- ." | "
- ."Delete This Listing ]
\n");
+ html_start_links(1);
+ html_link("Back To Listings", "$PHP_SELF?L+P$parent_id$options");
+ html_link("Show Comments", "#_USER_COMMENTS");
+ if ($LOGIN_LEVEL >= AUTH_DEVEL || $LOGIN_USER == $row["create_user"])
+ {
+ html_link("Delete Listing", "$PHP_SELF?X$id$options");
+ html_link("Edit Listing", "$PHP_SELF?UL$id$options");
+ }
+ html_end_links();
+
+ print("$name $version \n");
print("\n");
print(""
."Category: "
."$category "
."Rating: "
- ."$rating "
+ ."$rating "
.""
."0 - Worst "
."1 "
@@ -747,49 +843,52 @@ switch ($op)
." \n");
print(""
."Name: "
- ."$row['name "
+ ."$name "
."Popularity: "
."$popularity% "
." \n");
print(""
."Version: "
- ."$row['version "
+ ."$version "
."License: "
- ."$row['license "
+ ."$license "
." \n");
print(""
."Author: "
- ."$row['author "
+ ."$author "
."EMail: "
."$email "
." \n");
print(""
."Home Page: "
- ."$row['homepage ($row['homepage_visits visits) "
+ ."$homepage_url "
+ ."($row[homepage_visits] visits) "
." \n");
print(""
."Download: "
- ."$row['download ($row['download_visits visits) "
+ ."$download_url "
+ ."($row[download_visits] visits) "
." \n");
print(""
."Description: "
- ."$row['description "
+ ."$description "
." \n");
print("
\n");
db_free($result);
print(" \n"
- ."\n");
+ ."\n");
+ html_start_links();
+ html_link("Submit Comment", "comment.php?r0+plinks.php_V$id");
+ html_end_links();
show_comments("links.php_V$id");
+ html_footer();
break;
case 'X' : // Delete listing...
- global $OWNER_EMAIL;
- global $OWNER_PASSWORD;
-
+/*
if ($id <= 0)
{
print("Error \n"
@@ -862,95 +961,55 @@ switch ($op)
print("Deleted $name \n");
print("Return to listing.
\n");
+*/
break;
- case 'Z' : // List new...
- print("[ Show Listings ]
\n");
-
- // Show the categories...
- $result = db_query("SELECT * FROM link "
- ."WHERE is_published = 0 AND is_category = 1 "
- ."ORDER BY name");
-
- print("New Categories \n");
-
- while ($row = db_next($result))
+ case 'R' : // Rate this entry...
+ if (array_key_exists("RATING", $_POST))
{
- $create_date = date("M d, Y", $row['create_date);
- $category = get_category($row['parent_id, 1);
-
- print("$row['name "
- ." in $category"
- ." (Created $create_date)"
- ." [ Edit "
- ." | Delete "
- ." ] \n");
- }
+ $rating = (int)$_POST("RATING");
- print(" \n");
-
- db_free($result);
-
- // Then show the listings...
- $result = db_query("SELECT * FROM link "
- ."WHERE is_published = 0 AND is_category = 0 "
- ."ORDER BY name");
+ if ($rating < 0)
+ $rating = 0;
+ else if ($rating > 10)
+ $rating = 10;
- print("New Listings \n"
- ."\n");
-
- while ($row = db_next($result))
- {
- if ($row['is_category)
- continue;
-
- $create_date = date("M d, Y", $row['create_date);
- $category = get_category($row['parent_id, 1);
-
- print("$row['name "
- ." in $category"
- ." (Created $create_date)"
- ." [ Edit "
- ." | Delete "
- ." ] \n");
- }
-
- print(" \n");
-
- db_free($result);
- break;
-
- case 'r' : // Rate this entry...
- global $RATING;
-
- if ($RATING != "")
if (db_query("INSERT INTO vote VALUES('link_${id}_${REMOTE_ADDR}')"))
db_query("UPDATE link SET rating_count = rating_count + 1, "
- ."rating_total = rating_total + $RATING WHERE id = $id");
+ ."rating_total = rating_total + $rating WHERE id = $id");
+ }
- header("Location: $PHP_SELF?V$id");
+ header("Location: $PHP_SELF?V$id$options");
break;
case 'S' : // Show home or download page...
$result = db_query("SELECT * FROM link WHERE id = $id");
- $row = db_next($result);
- if ($type == 'H')
+ if (db_count($result) != 1)
+ {
+ db_free($result);
+ header("Location: $PHP_SELF?L$options");
+ exit();
+ }
+
+ $row = db_next($result);
+
+ if ($type == 'H' && $row["homepage_url"] != "")
{
db_query("UPDATE link SET homepage_visits = homepage_visits + 1 "
."WHERE id = $id");
- header("Location: $row[homepage]");
+ header("Location: $row[homepage_url]");
}
- else if ($type == 'D')
+ else if ($type == 'D' && $row["download_url"] != "")
{
db_query("UPDATE link SET download_visits = download_visits + 1 "
."WHERE id = $id");
- header("Location: $row[download]");
+ header("Location: $row[download_url]");
}
else
- header("Location: $PHP_SELF?V$id");
+ header("Location: $PHP_SELF?V$id$options");
db_free($result);
break;
@@ -958,6 +1017,8 @@ switch ($op)
db_close();
-if (!$redirect)
- html_footer();
+
+//
+// End of "$Id: links.php,v 1.2 2004/05/20 15:45:55 mike Exp $".
+//
?>
diff --git a/www/phplib/globals.php b/www/phplib/globals.php
index 44e04ed..af6df25 100644
--- a/www/phplib/globals.php
+++ b/www/phplib/globals.php
@@ -1,6 +1,6 @@
diff --git a/www/phplib/html.php b/www/phplib/html.php
index 07c41ad..1e9db50 100644
--- a/www/phplib/html.php
+++ b/www/phplib/html.php
@@ -1,6 +1,6 @@
Articles | "
."Documentation | "
."Download | "
+ ."Links | "
+ ."Polls | "
."Support ]"
."[ ");
diff --git a/www/poll.php b/www/poll.php
index a180be4..ed84aa6 100644
--- a/www/poll.php
+++ b/www/poll.php
@@ -1,6 +1,6 @@
Polls\n");
- html_start_table(array("ID", "Question::2"));
-
- while ($row = db_next($result))
+ if (db_count($result) == 0)
{
- $id = $row['id'];
- $votes = $row['votes'];
- $question = htmlspecialchars($row['question']);
- $ccount = count_comments("poll.php_r$id");
-
- if ($ccount == 1)
- $ccount .= " comment";
- else
- $ccount .= " comments";
-
- html_start_row();
- print(" #$row[id] "
- ."$question");
- if (!$row['is_published'])
- print(" ");
- print(" Vote | "
- ."Results ");
-
- if ($LOGIN_LEVEL > AUTH_USER)
- print(" | Edit ");
-
- print(" ($votes total votes, $ccount) ");
- html_end_row();
+ print("No polls found.
\n");
}
+ else
+ {
+ html_start_table(array("ID", "Question::2"));
- html_end_table();
+ while ($row = db_next($result))
+ {
+ $id = $row['id'];
+ $votes = $row['votes'];
+ $question = htmlspecialchars($row['question']);
+ $ccount = count_comments("poll.php_r$id");
+
+ if ($ccount == 1)
+ $ccount .= " comment";
+ else
+ $ccount .= " comments";
+
+ html_start_row();
+ print("#$row[id] "
+ ."$question");
+ if (!$row['is_published'])
+ print(" ");
+ print(" Vote | "
+ ."Results ");
+
+ if ($LOGIN_LEVEL > AUTH_USER)
+ print(" | Edit ");
+
+ print(" ($votes total votes, $ccount) ");
+ html_end_row();
+ }
+
+ html_end_table();
+ }
db_free($result);
@@ -383,6 +390,6 @@ switch ($op)
db_close();
//
-// End of "$Id: poll.php,v 1.2 2004/05/20 12:31:54 mike Exp $".
+// End of "$Id: poll.php,v 1.3 2004/05/20 15:45:55 mike Exp $".
//
?>