2004-05-17 20:28:52 +00:00
|
|
|
<?php
|
|
|
|
//
|
2004-05-20 21:37:57 +00:00
|
|
|
// "$Id: articles.php,v 1.11 2004/05/20 21:37:57 mike Exp $"
|
2004-05-17 20:28:52 +00:00
|
|
|
//
|
2004-05-18 12:02:02 +00:00
|
|
|
// Web form for the article table...
|
2004-05-17 20:28:52 +00:00
|
|
|
//
|
2004-05-19 21:17:47 +00:00
|
|
|
// Contents:
|
|
|
|
//
|
|
|
|
// notify_users() - Notify users of new/updated articles...
|
|
|
|
//
|
2004-05-17 20:28:52 +00:00
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-17 20:28:52 +00:00
|
|
|
//
|
|
|
|
// Include necessary headers...
|
|
|
|
//
|
|
|
|
|
|
|
|
include_once "phplib/html.php";
|
2004-05-18 12:02:02 +00:00
|
|
|
include_once "phplib/common.php";
|
|
|
|
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
//
|
|
|
|
// 'notify_users()' - Notify users of new/updated articles...
|
|
|
|
//
|
|
|
|
|
|
|
|
function
|
|
|
|
notify_users($id, // I - Article #
|
|
|
|
$what = "created") // I - Reason for notification
|
|
|
|
{
|
|
|
|
global $PHP_URL, $PROJECT_EMAIL, $PROJECT_NAME;
|
|
|
|
|
|
|
|
|
|
|
|
$result = db_query("SELECT * FROM article WHERE id = $id");
|
|
|
|
if (db_count($result) == 1)
|
|
|
|
{
|
|
|
|
$row = db_next($result);
|
|
|
|
|
|
|
|
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"),
|
2004-05-20 21:37:57 +00:00
|
|
|
"From: $PROJECT_EMAIL\r\n");
|
2004-05-19 21:17:47 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
// Get command-line options...
|
|
|
|
//
|
2004-05-18 19:58:35 +00:00
|
|
|
// Usage: article.php [operation] [options]
|
2004-05-18 12:02:02 +00:00
|
|
|
//
|
|
|
|
// Operations:
|
|
|
|
//
|
2004-05-19 00:57:33 +00:00
|
|
|
// B - Batch update selected articles
|
2004-05-18 19:58:35 +00:00
|
|
|
// D# - Delete article
|
2004-05-18 12:02:02 +00:00
|
|
|
// L = List all
|
2004-05-18 19:58:35 +00:00
|
|
|
// L# = List article #
|
|
|
|
// M# = Modify article #
|
|
|
|
// N = Create new article
|
|
|
|
//
|
|
|
|
// Options:
|
|
|
|
//
|
|
|
|
// I# = Set first article
|
|
|
|
// Qtext = Set search text
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
$search = "";
|
|
|
|
$index = 0;
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
if ($argc)
|
|
|
|
{
|
|
|
|
$op = $argv[0][0];
|
|
|
|
$id = (int)substr($argv[0], 1);
|
|
|
|
|
2004-05-19 00:57:33 +00:00
|
|
|
if ($op != 'D' && $op != 'L' && $op != 'M' && $op != 'N' && $op != 'B')
|
2004-05-18 12:02:02 +00:00
|
|
|
{
|
|
|
|
html_header("Article Error");
|
|
|
|
print("<p>Bad command '$op'!\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (($op == 'D' || $op == 'M') && !$id)
|
|
|
|
{
|
|
|
|
html_header("Article Error");
|
|
|
|
print("<p>Command '$op' requires an ID!\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if ($op == 'B' && $LOGIN_LEVEL < AUTH_DEVEL)
|
2004-05-18 19:58:35 +00:00
|
|
|
{
|
|
|
|
html_header("Article Error");
|
2004-05-19 14:02:38 +00:00
|
|
|
print("<p>You don't have permission to use command '$op'!\n");
|
2004-05-18 19:58:35 +00:00
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if (($op == 'D' || $op == 'M') && $LOGIN_LEVEL < AUTH_DEVEL)
|
|
|
|
{
|
|
|
|
$result = db_query("SELECT * FROM article WHERE id = $id");
|
|
|
|
if (db_count($result) != 1)
|
|
|
|
{
|
|
|
|
db_free($result);
|
|
|
|
|
|
|
|
html_header("Article Error");
|
|
|
|
print("<p>Article #$id does not exist!\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$row = db_next($result);
|
|
|
|
|
|
|
|
if ($row['create_user'] != $LOGIN_USER &&
|
|
|
|
$row['create_user'] != $LOGIN_EMAIL)
|
|
|
|
{
|
|
|
|
db_free($result);
|
|
|
|
|
|
|
|
html_header("Article Error");
|
|
|
|
print("<p>You don't have permission to use command '$op'!\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
db_free($result);
|
|
|
|
}
|
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
if ($op == 'N' && $id)
|
|
|
|
{
|
|
|
|
html_header("Article Error");
|
|
|
|
print("<p>Command '$op' may not have an ID!\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
2004-05-18 19:58:35 +00:00
|
|
|
|
|
|
|
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("<p>Bad option '$argv[$i]'!</p>\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2004-05-18 12:02:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$op = 'L';
|
|
|
|
$id = 0;
|
|
|
|
}
|
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
if ($REQUEST_METHOD == "POST")
|
|
|
|
{
|
|
|
|
if (array_key_exists("SEARCH", $_POST))
|
|
|
|
$search = $_POST["SEARCH"];
|
|
|
|
}
|
|
|
|
|
|
|
|
$options = "+I$index+Q" . urlencode($search);
|
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
switch ($op)
|
|
|
|
{
|
2004-05-19 00:57:33 +00:00
|
|
|
case 'B' : // Batch update selected articles
|
|
|
|
if ($REQUEST_METHOD != "POST")
|
|
|
|
{
|
|
|
|
header("Location: $PHP_SELF?L$options");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (array_key_exists("IS_PUBLISHED", $_POST) &&
|
|
|
|
$_POST["IS_PUBLISHED"] != "")
|
|
|
|
{
|
|
|
|
$modify_date = time();
|
|
|
|
$modify_user = db_escape($LOGIN_USER);
|
|
|
|
$is_published = (int)$_POST["IS_PUBLISHED"];
|
|
|
|
|
|
|
|
$query = "is_published = $is_published, modify_date = $modify_date, "
|
|
|
|
."modify_user = '$modify_user'";
|
|
|
|
|
|
|
|
db_query("BEGIN TRANSACTION");
|
|
|
|
|
|
|
|
reset($_POST);
|
|
|
|
while (list($key, $val) = each($_POST))
|
|
|
|
if (substr($key, 0, 3) == "ID_")
|
|
|
|
{
|
|
|
|
$id = (int)substr($key, 3);
|
|
|
|
|
|
|
|
db_query("UPDATE article SET $query WHERE id = $id");
|
|
|
|
}
|
|
|
|
|
|
|
|
db_query("COMMIT TRANSACTION");
|
|
|
|
}
|
|
|
|
|
|
|
|
header("Location: $PHP_SELF?L$options");
|
|
|
|
break;
|
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
case 'D' : // Delete Article
|
|
|
|
if ($REQUEST_METHOD == "POST")
|
|
|
|
{
|
|
|
|
db_query("DELETE FROM article WHERE id = $id");
|
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
header("Location: $PHP_SELF?L$options");
|
2004-05-18 12:02:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = db_query("SELECT * FROM article WHERE id = $id");
|
|
|
|
if (db_count($result) != 1)
|
|
|
|
{
|
|
|
|
print("<p><b>Error:</b> Article #$id was not found!</p>\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$row = db_next($result);
|
|
|
|
|
|
|
|
html_header("Delete Article #$id");
|
|
|
|
|
|
|
|
html_start_links(1);
|
2004-05-18 19:58:35 +00:00
|
|
|
html_link("Return to Articles", "$PHP_SELF?L$options");
|
|
|
|
html_link("View Article #$id</A>", "$PHP_SELF?L$id$options");
|
|
|
|
html_link("Modify Article #$id</A>", "$PHP_SELF?M$id$options");
|
2004-05-18 12:02:02 +00:00
|
|
|
html_end_links();
|
|
|
|
|
|
|
|
print("<h1>Delete Article #$id</h1>\n");
|
|
|
|
print("<form method='post' action='$PHP_SELF?D$id'>"
|
|
|
|
."<p><table width='100%' cellpadding='5' cellspacing='0' border='0'>\n");
|
|
|
|
|
|
|
|
if (!$row['is_published'])
|
2004-05-19 21:17:47 +00:00
|
|
|
print("<tr><th align='center' colspan='2'>This article is "
|
2004-05-18 12:02:02 +00:00
|
|
|
."currently hidden from public view.</td></tr>\n");
|
|
|
|
|
|
|
|
$temp = htmlspecialchars($row["title"]);
|
|
|
|
print("<tr><th align='right'>Title:</th><td class='left'>$temp</td></tr>\n");
|
|
|
|
|
|
|
|
$temp = htmlspecialchars($row["abstract"]);
|
|
|
|
print("<tr><th align='right'>Abstract:</th><td class='left'>$temp</td></tr>\n");
|
|
|
|
|
2004-05-20 21:37:57 +00:00
|
|
|
$temp = fomat_text($row["contents"]);
|
2004-05-18 12:02:02 +00:00
|
|
|
print("<tr><th align='right'>Contents:</th><td class='left'>$temp</td></tr>\n");
|
|
|
|
|
|
|
|
print("<tr><th colspan='2'>"
|
|
|
|
."<input type='submit' value='Confirm Delete Article'></th></tr>\n");
|
|
|
|
print("</table></p></form>\n");
|
|
|
|
|
|
|
|
html_footer();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'L' : // List (all) Article(s)
|
|
|
|
if ($id)
|
|
|
|
{
|
|
|
|
$result = db_query("SELECT * FROM article WHERE id = $id");
|
|
|
|
if (db_count($result) != 1)
|
|
|
|
{
|
2004-05-19 16:34:55 +00:00
|
|
|
html_header("Article Error");
|
2004-05-18 12:02:02 +00:00
|
|
|
print("<p><b>Error:</b> Article #$id was not found!</p>\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
$row = db_next($result);
|
|
|
|
$title = htmlspecialchars($row['title']);
|
|
|
|
$abstract = htmlspecialchars($row['abstract']);
|
|
|
|
$contents = format_text($row['contents']);
|
|
|
|
$create_user = sanitize_email($row['create_user']);
|
|
|
|
$date = date("H:i M d, Y", $row['modify_date']);
|
2004-05-19 16:34:55 +00:00
|
|
|
|
|
|
|
html_header("Article #$id: $title");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
html_start_links(1);
|
2004-05-18 19:58:35 +00:00
|
|
|
html_link("Return to Articles", "$PHP_SELF?L$options");
|
2004-05-18 21:26:52 +00:00
|
|
|
html_link("Show Comments", "#_USER_COMMENTS");
|
2004-05-19 21:17:47 +00:00
|
|
|
html_link("Submit Comment", "comment.php?r0+particles.php_L$id");
|
|
|
|
|
|
|
|
if ($LOGIN_LEVEL >= AUTH_DEVEL ||
|
|
|
|
$row['create_user'] == $LOGIN_USER)
|
2004-05-18 19:58:35 +00:00
|
|
|
{
|
|
|
|
html_link("Modify Article</A>", "$PHP_SELF?M$id$options");
|
2004-05-19 16:34:55 +00:00
|
|
|
html_link("Delete Article</A>", "$PHP_SELF?D$id$options");
|
2004-05-18 19:58:35 +00:00
|
|
|
}
|
2004-05-18 12:02:02 +00:00
|
|
|
html_end_links();
|
|
|
|
|
|
|
|
if (!$row['is_published'])
|
2004-05-19 21:17:47 +00:00
|
|
|
print("<p align='center'><b>This article is currently hidden from "
|
|
|
|
."public view.</b></p>\n");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-19 16:34:55 +00:00
|
|
|
print("<h1>Article #$id: $title</h1>\n"
|
2004-05-19 21:17:47 +00:00
|
|
|
."<p><i>$date by $create_user</i><br />$abstract</p>\n"
|
|
|
|
."<hr noshade/>\n"
|
|
|
|
."$contents\n"
|
|
|
|
."<hr noshade/>\n"
|
|
|
|
."<h2><a name='_USER_COMMENTS'>Comments</a></h2>\n");
|
|
|
|
|
|
|
|
html_start_links();
|
|
|
|
html_link("Submit Comment", "comment.php?r0+particles.php_L$id");
|
|
|
|
html_end_links();
|
2004-05-18 21:26:52 +00:00
|
|
|
|
|
|
|
show_comments("articles.php_L$id");
|
2004-05-19 21:17:47 +00:00
|
|
|
|
|
|
|
db_free($result);
|
2004-05-18 12:02:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-05-18 19:58:35 +00:00
|
|
|
html_header("Articles");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
html_start_links(1);
|
2004-05-19 14:02:38 +00:00
|
|
|
html_link("Submit Article", "$PHP_SELF?N$options");
|
2004-05-18 12:02:02 +00:00
|
|
|
html_end_links();
|
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
print("<h1>Articles</h1>\n");
|
|
|
|
|
|
|
|
print("<form method='POST' action='$PHP_SELF'><p align='center'>"
|
|
|
|
."Search Words: <input type='text' size='60' "
|
|
|
|
."name='SEARCH' value='$search'>"
|
|
|
|
."<input type='submit' value='Search Articles'></p></form>\n");
|
|
|
|
|
|
|
|
print("<hr noshade/>\n");
|
|
|
|
|
|
|
|
$query = "";
|
|
|
|
$prefix = "WHERE ";
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($LOGIN_LEVEL < AUTH_DEVEL)
|
2004-05-18 19:58:35 +00:00
|
|
|
{
|
2004-05-19 21:17:47 +00:00
|
|
|
$query .= "${prefix}(is_published = 1 OR create_user = '"
|
|
|
|
. db_escape($LOGIN_USER) . "')";
|
2004-05-18 19:58:35 +00:00
|
|
|
$prefix = " AND ";
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($search)
|
|
|
|
{
|
|
|
|
$search_string = str_replace("'", " ", $search);
|
|
|
|
$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
|
|
|
|
$query .= "${prefix}(";
|
|
|
|
$prefix = "";
|
|
|
|
$next = " OR";
|
|
|
|
$logic = "";
|
|
|
|
|
|
|
|
reset($search_words);
|
|
|
|
while ($keyword = current($search_words))
|
|
|
|
{
|
|
|
|
next($search_words);
|
|
|
|
$keyword = db_escape(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 if (strcasecmp($keyword, 'not') == 0)
|
|
|
|
{
|
|
|
|
$logic = ' NOT';
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2004-05-19 00:57:33 +00:00
|
|
|
if ($keyword == (int)$keyword)
|
|
|
|
$idsearch = " OR id = " . (int)$keyword;
|
|
|
|
else
|
|
|
|
$idsearch = "";
|
|
|
|
|
|
|
|
$query .= "$prefix$logic (title LIKE \"%$keyword%\"$idsearch"
|
2004-05-18 19:58:35 +00:00
|
|
|
." OR abstract LIKE \"%$keyword%\""
|
|
|
|
." OR contents LIKE \"%$keyword%\")";
|
|
|
|
$prefix = $next;
|
|
|
|
$logic = '';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$query .= ")";
|
|
|
|
}
|
|
|
|
|
|
|
|
$result = db_query("SELECT * FROM article $query "
|
2004-05-20 21:37:57 +00:00
|
|
|
."ORDER BY modify_date DESC");
|
2004-05-18 12:02:02 +00:00
|
|
|
$count = db_count($result);
|
|
|
|
|
|
|
|
if ($count == 0)
|
|
|
|
{
|
|
|
|
print("<p>No Articles found.</p>\n");
|
|
|
|
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
if ($index >= $count)
|
2004-05-19 00:57:33 +00:00
|
|
|
$index = $count - ($count % $PAGE_MAX);
|
2004-05-18 19:58:35 +00:00
|
|
|
if ($index < 0)
|
|
|
|
$index = 0;
|
|
|
|
|
|
|
|
$start = $index + 1;
|
2004-05-19 00:57:33 +00:00
|
|
|
$end = $index + $PAGE_MAX;
|
2004-05-18 19:58:35 +00:00
|
|
|
if ($end > $count)
|
|
|
|
$end = $count;
|
|
|
|
|
2004-05-19 00:57:33 +00:00
|
|
|
$prev = $index - $PAGE_MAX;
|
2004-05-18 19:58:35 +00:00
|
|
|
if ($prev < 0)
|
|
|
|
$prev = 0;
|
2004-05-19 00:57:33 +00:00
|
|
|
$next = $index + $PAGE_MAX;
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
print("<p>$count article(s) found, showing $start to $end:</p>\n");
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($LOGIN_LEVEL >= AUTH_DEVEL)
|
2004-05-19 00:57:33 +00:00
|
|
|
print("<form method='POST' action='$PHP_SELF?B$options'>\n");
|
|
|
|
|
|
|
|
if ($count > $PAGE_MAX)
|
2004-05-18 19:58:35 +00:00
|
|
|
{
|
|
|
|
print("<p><table border='0' cellspacing='0' cellpadding='0' "
|
|
|
|
."width='100%'>\n");
|
|
|
|
|
|
|
|
print("<tr><td>");
|
|
|
|
if ($index > 0)
|
|
|
|
print("[ <a href='$PHP_SELF?L+I$prev+Q" . urlencode($search)
|
2004-05-19 00:57:33 +00:00
|
|
|
."'>Previous $PAGE_MAX</a> ]");
|
2004-05-18 19:58:35 +00:00
|
|
|
print("</td><td align='right'>");
|
|
|
|
if ($end < $count)
|
|
|
|
{
|
2004-05-19 00:57:33 +00:00
|
|
|
$next_count = min($PAGE_MAX, $count - $end);
|
2004-05-18 19:58:35 +00:00
|
|
|
print("[ <a href='$PHP_SELF?L+I$next+Q" . urlencode($search)
|
|
|
|
."'>Next $next_count</a> ]");
|
|
|
|
}
|
|
|
|
print("</td></tr>\n");
|
|
|
|
print("</table></p>\n");
|
|
|
|
}
|
|
|
|
|
2004-05-18 21:26:52 +00:00
|
|
|
html_start_table(array("ID","Title","Last Modified", "Comment(s)"));
|
2004-05-18 19:58:35 +00:00
|
|
|
|
|
|
|
db_seek($result, $index);
|
2004-05-19 00:57:33 +00:00
|
|
|
for ($i = 0; $i < $PAGE_MAX && $row = db_next($result); $i ++)
|
2004-05-18 12:02:02 +00:00
|
|
|
{
|
|
|
|
html_start_row();
|
|
|
|
|
2004-05-19 00:57:33 +00:00
|
|
|
$id = $row['id'];
|
|
|
|
$link = "<a href='$PHP_SELF?L$id$options' alt='Article #$id'>";
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-19 02:57:18 +00:00
|
|
|
print("<td nowrap>");
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($LOGIN_LEVEL >= AUTH_DEVEL)
|
2004-05-19 00:57:33 +00:00
|
|
|
print("<input type='checkbox' name='ID_$row[id]'>");
|
|
|
|
print("$link$id</a></td>");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
$temp = htmlspecialchars($row['title']);
|
2004-05-19 00:57:33 +00:00
|
|
|
if ($row['is_published'] == 0)
|
|
|
|
$temp .= " <img src='images/private.gif' width='16' height='16' "
|
|
|
|
."border='0' align='middle' alt='Private'/>";
|
|
|
|
|
|
|
|
print("<td align='center' width='67%'>$link$temp</a></td>");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
$temp = date("M d, Y", $row['modify_date']);
|
2004-05-19 00:57:33 +00:00
|
|
|
print("<td align='center'>$link$temp</a></td>");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
$ccount = count_comments("articles.php_L$id");
|
|
|
|
print("<td align='center'>$link$ccount</a></td>");
|
2004-05-18 21:26:52 +00:00
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
html_end_row();
|
2004-05-18 19:58:35 +00:00
|
|
|
|
|
|
|
html_start_row();
|
|
|
|
$temp = htmlspecialchars($row['abstract']);
|
2004-05-18 21:26:52 +00:00
|
|
|
print("<td></td><td colspan='3'>$temp</td>");
|
2004-05-18 19:58:35 +00:00
|
|
|
html_end_row();
|
2004-05-18 12:02:02 +00:00
|
|
|
}
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($LOGIN_LEVEL > 0)
|
2004-05-19 00:57:33 +00:00
|
|
|
{
|
|
|
|
html_start_row("header");
|
|
|
|
|
2004-05-19 02:57:18 +00:00
|
|
|
print("<th colspan='4'> <br />Published: ");
|
2004-05-19 00:57:33 +00:00
|
|
|
select_is_published();
|
|
|
|
print("<input type='submit' value='Modify Selected Articles'/></th>\n");
|
|
|
|
|
|
|
|
html_end_row();
|
|
|
|
}
|
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
html_end_table();
|
2004-05-18 19:58:35 +00:00
|
|
|
|
2004-05-19 00:57:33 +00:00
|
|
|
if ($count > $PAGE_MAX)
|
2004-05-18 19:58:35 +00:00
|
|
|
{
|
|
|
|
print("<p><table border='0' cellspacing='0' cellpadding='0' "
|
|
|
|
."width='100%'>\n");
|
|
|
|
|
|
|
|
print("<tr><td>");
|
|
|
|
if ($index > 0)
|
|
|
|
print("[ <a href='$PHP_SELF?L+I$prev+Q" . urlencode($search)
|
2004-05-19 00:57:33 +00:00
|
|
|
."'>Previous $PAGE_MAX</a> ]");
|
2004-05-18 19:58:35 +00:00
|
|
|
print("</td><td align='right'>");
|
|
|
|
if ($end < $count)
|
|
|
|
{
|
2004-05-19 00:57:33 +00:00
|
|
|
$next_count = min($PAGE_MAX, $count - $end);
|
2004-05-18 19:58:35 +00:00
|
|
|
print("[ <a href='$PHP_SELF?L+I$next+Q" . urlencode($search)
|
|
|
|
."'>Next $next_count</a> ]");
|
|
|
|
}
|
|
|
|
print("</td></tr>\n");
|
|
|
|
print("</table></p>\n");
|
|
|
|
}
|
2004-05-19 21:17:47 +00:00
|
|
|
|
|
|
|
print("<p><img src='images/private.gif' width='16' height='16' "
|
|
|
|
."align='middle' alt='private'/> = hidden from public view</p>\n");
|
2004-05-18 12:02:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'M' : // Modify Article
|
|
|
|
if ($REQUEST_METHOD == "POST")
|
|
|
|
{
|
2004-05-19 21:17:47 +00:00
|
|
|
if ($LOGIN_LEVEL < AUTH_DEVEL)
|
|
|
|
$is_published = 0;
|
|
|
|
else if (array_key_exists("IS_PUBLISHED", $_POST))
|
2004-05-19 00:57:33 +00:00
|
|
|
$is_published = (int)$_POST["IS_PUBLISHED"];
|
|
|
|
else
|
|
|
|
$is_published = 0;
|
|
|
|
|
|
|
|
if (array_key_exists("TITLE", $_POST))
|
|
|
|
$title = $_POST["TITLE"];
|
|
|
|
else
|
|
|
|
$title = "";
|
|
|
|
|
|
|
|
if (array_key_exists("ABSTRACT", $_POST))
|
|
|
|
$abstract = $_POST["ABSTRACT"];
|
|
|
|
else
|
|
|
|
$abstract = "";
|
|
|
|
|
|
|
|
if (array_key_exists("CONTENTS", $_POST))
|
|
|
|
$contents = $_POST["CONTENTS"];
|
|
|
|
else
|
|
|
|
$contents = "";
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if (($is_published == 0 || $LOGIN_LEVEL >= AUTH_DEVEL) &&
|
|
|
|
$title != "" && $abstract != "" && $contents != "")
|
2004-05-19 00:57:33 +00:00
|
|
|
$havedata = 1;
|
|
|
|
else
|
|
|
|
$havedata = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$result = db_query("SELECT * FROM article WHERE id = $id");
|
|
|
|
if (db_count($result) != 1)
|
|
|
|
{
|
|
|
|
print("<p><b>Error:</b> Article #$id was not found!</p>\n");
|
|
|
|
html_footer();
|
|
|
|
exit();
|
|
|
|
}
|
|
|
|
|
|
|
|
$row = db_next($result);
|
|
|
|
|
|
|
|
$is_published = $row["is_published"];
|
|
|
|
$title = $row["title"];
|
|
|
|
$abstract = $row["abstract"];
|
|
|
|
$contents = $row["contents"];
|
|
|
|
|
|
|
|
db_free($row);
|
|
|
|
|
|
|
|
$havedata = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($havedata)
|
|
|
|
{
|
|
|
|
$title = db_escape($title);
|
|
|
|
$abstract = db_escape($abstract);
|
|
|
|
$contents = db_escape($contents);
|
|
|
|
$modify_date = time();
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
db_query("UPDATE article SET "
|
|
|
|
."is_published = $is_published, "
|
|
|
|
."title = '$title', "
|
|
|
|
."abstract = '$abstract', "
|
|
|
|
."contents = '$contents', "
|
2004-05-19 00:57:33 +00:00
|
|
|
."modify_date = $modify_date, "
|
2004-05-18 12:02:02 +00:00
|
|
|
."modify_user = '$LOGIN_USER' "
|
|
|
|
."WHERE id = $id");
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if (!$is_published)
|
|
|
|
notify_users($id, "modified");
|
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
header("Location: $PHP_SELF?L$id$options");
|
2004-05-18 12:02:02 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
html_header("Modify Article #$id");
|
|
|
|
|
|
|
|
html_start_links(1);
|
2004-05-18 19:58:35 +00:00
|
|
|
html_link("Return to Articles", "$PHP_SELF?L$options");
|
|
|
|
html_link("Article #$id", "$PHP_SELF?L$id$options");
|
2004-05-18 12:02:02 +00:00
|
|
|
html_end_links();
|
|
|
|
|
|
|
|
print("<h1>Modify Article #$id</h1>\n");
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if ($REQUEST_METHOD == "POST")
|
|
|
|
{
|
|
|
|
print("<p><b>Error:</b> Please fill in the fields marked in "
|
|
|
|
."<b><font color='red'>bold red</font></b> below and resubmit "
|
|
|
|
."your article.</p><hr noshade/>\n");
|
|
|
|
|
|
|
|
$hstart = "<font color='red'>";
|
|
|
|
$hend = "</font>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$hstart = "";
|
|
|
|
$hend = "";
|
|
|
|
}
|
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
print("<form method='post' action='$PHP_SELF?M$id$options'>"
|
2004-05-18 12:02:02 +00:00
|
|
|
."<p><table width='100%' cellpadding='5' cellspacing='0' border='0'>\n");
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if ($LOGIN_LEVEL >= AUTH_DEVEL)
|
|
|
|
{
|
|
|
|
print("<tr><th align='right'>Published:</th><td>");
|
|
|
|
select_is_published($is_published);
|
|
|
|
print("</td></tr>\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
print("<input type='hidden' name='IS_PUBLISHED' value='0'/>\n");
|
|
|
|
|
|
|
|
$title = htmlspecialchars($title, ENT_QUOTES);
|
|
|
|
|
|
|
|
if ($title == "")
|
|
|
|
print("<tr><th align='right'>${hstart}Title:${hend}</th>");
|
|
|
|
else
|
|
|
|
print("<tr><th align='right'>Title:</th>");
|
|
|
|
print("<td><input type='text' name='TITLE' "
|
|
|
|
."size='80' value='$title'/></td></tr>\n");
|
|
|
|
|
|
|
|
$abstract = htmlspecialchars($abstract, ENT_QUOTES);
|
|
|
|
|
|
|
|
if ($abstract == "")
|
|
|
|
print("<tr><th align='right'>${hstart}Abstract:${hend}</th>");
|
|
|
|
else
|
|
|
|
print("<tr><th align='right'>Abstract:</th>");
|
|
|
|
print("<td><input type='text' name='ABSTRACT' "
|
|
|
|
."size='80' value='$abstract'/></td></tr>\n");
|
|
|
|
|
|
|
|
$contents = htmlspecialchars($contents, ENT_QUOTES);
|
|
|
|
|
|
|
|
if ($contents == "")
|
|
|
|
print("<tr><th align='right' valign='top'>${hstart}Contents:${hend}</th>");
|
|
|
|
else
|
|
|
|
print("<tr><th align='right' valign='top'>Contents:</th>");
|
|
|
|
print("<td><textarea name='CONTENTS' "
|
2004-05-20 21:37:57 +00:00
|
|
|
."cols='72' rows='12' wrap='virtual'>"
|
2004-05-19 21:17:47 +00:00
|
|
|
."$contents</textarea>\n"
|
|
|
|
."<p>The contents of the article may contain the following "
|
|
|
|
."HTML elements: <tt>A</tt>, <tt>B</tt>, <tt>BLOCKQUOTE</tt>, "
|
|
|
|
."<tt>CODE</tt>, <tt>EM</tt>, <tt>H1</tt>, <tt>H2</tt>, "
|
|
|
|
."<tt>H3</tt>, <tt>H4</tt>, <tt>H5</tt>, <tt>H6</tt>, <tt>I</tt>, "
|
|
|
|
."<tt>IMG</tt>, <tt>LI</tt>, <tt>OL</tt>, <tt>P</tt>, <tt>PRE</tt>, "
|
|
|
|
."<tt>TT</tt>, <tt>U</tt>, <tt>UL</tt></p></td></tr>\n");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
print("<tr><th colspan='2'>"
|
2004-05-19 21:17:47 +00:00
|
|
|
."<input type='submit' value='Motify Article'/></th></tr>\n");
|
2004-05-18 12:02:02 +00:00
|
|
|
print("</table></p></form>\n");
|
|
|
|
|
|
|
|
html_footer();
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case 'N' : // Post new Article
|
|
|
|
if ($REQUEST_METHOD == "POST")
|
|
|
|
{
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($LOGIN_LEVEL < AUTH_DEVEL)
|
|
|
|
$is_published = 0;
|
|
|
|
else if (array_key_exists("IS_PUBLISHED", $_POST))
|
2004-05-19 00:57:33 +00:00
|
|
|
$is_published = (int)$_POST["IS_PUBLISHED"];
|
|
|
|
else
|
|
|
|
$is_published = 0;
|
|
|
|
|
|
|
|
if (array_key_exists("TITLE", $_POST))
|
|
|
|
$title = $_POST["TITLE"];
|
|
|
|
else
|
|
|
|
$title = "";
|
|
|
|
|
|
|
|
if (array_key_exists("ABSTRACT", $_POST))
|
|
|
|
$abstract = $_POST["ABSTRACT"];
|
|
|
|
else
|
|
|
|
$abstract = "";
|
|
|
|
|
|
|
|
if (array_key_exists("CONTENTS", $_POST))
|
|
|
|
$contents = $_POST["CONTENTS"];
|
|
|
|
else
|
|
|
|
$contents = "";
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if ($LOGIN_USER != "" && $LOGIN_LEVEL < AUTH_DEVEL)
|
|
|
|
$create_user = $LOGIN_USER;
|
|
|
|
else if (array_key_exists("CREATE_USER", $_POST))
|
2004-05-19 00:57:33 +00:00
|
|
|
$create_user = $_POST["CREATE_USER"];
|
|
|
|
else
|
|
|
|
$create_user = "";
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if (($is_published == 0 || $LOGIN_LEVEL >= AUTH_DEVEL) &&
|
2004-05-19 21:17:47 +00:00
|
|
|
$title != "" && $abstract != "" && $contents != "" &&
|
|
|
|
$create_user != "")
|
2004-05-19 00:57:33 +00:00
|
|
|
$havedata = 1;
|
|
|
|
else
|
|
|
|
$havedata = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
$is_published = 0;
|
|
|
|
$title = "";
|
|
|
|
$abstract = "";
|
|
|
|
$contents = "";
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if ($LOGIN_USER != "")
|
|
|
|
$create_user = $LOGIN_USER;
|
|
|
|
else if (array_key_exists("FROM", $_COOKIE))
|
2004-05-19 00:57:33 +00:00
|
|
|
$create_user = $_COOKIE["FROM"];
|
|
|
|
else
|
|
|
|
$create_user = "";
|
|
|
|
|
|
|
|
$havedata = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ($havedata)
|
|
|
|
{
|
|
|
|
$title = db_escape($title);
|
|
|
|
$abstract = db_escape($abstract);
|
|
|
|
$contents = db_escape($contents);
|
|
|
|
$create_date = time();
|
|
|
|
$create_user = db_escape($create_user);
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
db_query("INSERT INTO article VALUES(NULL,"
|
2004-05-19 00:57:33 +00:00
|
|
|
."$is_published,'$title','$abstract','$contents',"
|
|
|
|
."$create_date,'$create_user',$create_date,'$create_user')");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
$id = db_insert_id();
|
|
|
|
|
2004-05-19 21:17:47 +00:00
|
|
|
if (!$is_published)
|
|
|
|
notify_users($id);
|
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
header("Location: $PHP_SELF?L$id$options");
|
2004-05-18 12:02:02 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
html_header("Submit Article");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
html_start_links(1);
|
2004-05-18 19:58:35 +00:00
|
|
|
html_link("Return to Articles", "$PHP_SELF?L$options");
|
2004-05-18 12:02:02 +00:00
|
|
|
html_end_links();
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
print("<h1>Submit Article</h1>\n");
|
2004-05-19 00:57:33 +00:00
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($REQUEST_METHOD == "POST")
|
|
|
|
{
|
|
|
|
print("<p><b>Error:</b> Please fill in the fields marked in "
|
|
|
|
."<b><font color='red'>bold red</font></b> below and resubmit "
|
|
|
|
."your article.</p><hr noshade/>\n");
|
|
|
|
|
|
|
|
$hstart = "<font color='red'>";
|
|
|
|
$hend = "</font>";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
print("<p>Please use this form to post announcements, how-to's, "
|
2004-05-19 21:17:47 +00:00
|
|
|
."examples, and case studies showing how you use $PROJECT_NAME. "
|
2004-05-19 14:02:38 +00:00
|
|
|
."We will proofread your article, and if we determine it is "
|
|
|
|
."appropriate for the site, we will make the article public "
|
2004-05-19 21:17:47 +00:00
|
|
|
."on the site. <i>Thank you</i> for supporting $PROJECT_NAME!</p>\n"
|
2004-05-19 14:02:38 +00:00
|
|
|
."<hr noshade/>\n");
|
|
|
|
|
|
|
|
$hstart = "";
|
|
|
|
$hend = "";
|
|
|
|
}
|
2004-05-19 00:57:33 +00:00
|
|
|
|
2004-05-18 19:58:35 +00:00
|
|
|
print("<form method='post' action='$PHP_SELF?N$options'>"
|
2004-05-18 12:02:02 +00:00
|
|
|
."<p><table width='100%' cellpadding='5' cellspacing='0' border='0'>\n");
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($LOGIN_LEVEL >= AUTH_DEVEL)
|
2004-05-18 19:58:35 +00:00
|
|
|
{
|
|
|
|
print("<tr><th align='right'>Published:</th><td>");
|
2004-05-19 00:57:33 +00:00
|
|
|
select_is_published($is_published);
|
2004-05-18 19:58:35 +00:00
|
|
|
print("</td></tr>\n");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
print("<input type='hidden' name='IS_PUBLISHED' value='0'/>\n");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-19 00:57:33 +00:00
|
|
|
$title = htmlspecialchars($title, ENT_QUOTES);
|
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($title == "")
|
|
|
|
print("<tr><th align='right'>${hstart}Title:${hend}</th>");
|
|
|
|
else
|
|
|
|
print("<tr><th align='right'>Title:</th>");
|
|
|
|
print("<td><input type='text' name='TITLE' "
|
2004-05-19 21:17:47 +00:00
|
|
|
."size='80' value='$title'/></td></tr>\n");
|
2004-05-19 00:57:33 +00:00
|
|
|
|
|
|
|
$abstract = htmlspecialchars($abstract, ENT_QUOTES);
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($abstract == "")
|
|
|
|
print("<tr><th align='right'>${hstart}Abstract:${hend}</th>");
|
|
|
|
else
|
|
|
|
print("<tr><th align='right'>Abstract:</th>");
|
|
|
|
print("<td><input type='text' name='ABSTRACT' "
|
2004-05-19 21:17:47 +00:00
|
|
|
."size='80' value='$abstract'/></td></tr>\n");
|
2004-05-19 00:57:33 +00:00
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
$create_user = htmlspecialchars($create_user, ENT_QUOTES);
|
2004-05-19 00:57:33 +00:00
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($create_user == "")
|
|
|
|
print("<tr><th align='right'>${hstart}Author:${hend}</th>");
|
|
|
|
else
|
|
|
|
print("<tr><th align='right'>Author:</th>");
|
2004-05-19 21:17:47 +00:00
|
|
|
|
|
|
|
if ($LOGIN_USER != "" && $LOGIN_LEVEL < AUTH_DEVEL)
|
|
|
|
print("<td><input type='hidden' name='CREATE_USER' "
|
|
|
|
."value='$create_user'/>$create_user</td></tr>\n");
|
|
|
|
else
|
|
|
|
print("<td><input type='text' name='CREATE_USER' "
|
|
|
|
."size='40' value='$create_user'/></td></tr>\n");
|
2004-05-19 00:57:33 +00:00
|
|
|
|
|
|
|
$contents = htmlspecialchars($contents, ENT_QUOTES);
|
2004-05-18 12:02:02 +00:00
|
|
|
|
2004-05-19 14:02:38 +00:00
|
|
|
if ($contents == "")
|
|
|
|
print("<tr><th align='right' valign='top'>${hstart}Contents:${hend}</th>");
|
|
|
|
else
|
|
|
|
print("<tr><th align='right' valign='top'>Contents:</th>");
|
|
|
|
print("<td><textarea name='CONTENTS' "
|
2004-05-20 21:37:57 +00:00
|
|
|
."cols='72' rows='12' wrap='virtual'>"
|
2004-05-19 00:57:33 +00:00
|
|
|
."$contents</textarea>\n"
|
|
|
|
."<p>The contents of the article may contain the following "
|
|
|
|
."HTML elements: <tt>A</tt>, <tt>B</tt>, <tt>BLOCKQUOTE</tt>, "
|
|
|
|
."<tt>CODE</tt>, <tt>EM</tt>, <tt>H1</tt>, <tt>H2</tt>, "
|
|
|
|
."<tt>H3</tt>, <tt>H4</tt>, <tt>H5</tt>, <tt>H6</tt>, <tt>I</tt>, "
|
|
|
|
."<tt>IMG</tt>, <tt>LI</tt>, <tt>OL</tt>, <tt>P</tt>, <tt>PRE</tt>, "
|
|
|
|
."<tt>TT</tt>, <tt>U</tt>, <tt>UL</tt></p></td></tr>\n");
|
2004-05-18 12:02:02 +00:00
|
|
|
|
|
|
|
print("<tr><th colspan='2'>"
|
2004-05-19 21:17:47 +00:00
|
|
|
."<input type='submit' value='Submit Article'/></th></tr>\n");
|
2004-05-18 12:02:02 +00:00
|
|
|
print("</table></p></form>\n");
|
2004-05-17 20:28:52 +00:00
|
|
|
|
2004-05-18 12:02:02 +00:00
|
|
|
html_footer();
|
|
|
|
break;
|
|
|
|
}
|
2004-05-17 20:28:52 +00:00
|
|
|
|
|
|
|
|
|
|
|
//
|
2004-05-20 21:37:57 +00:00
|
|
|
// End of "$Id: articles.php,v 1.11 2004/05/20 21:37:57 mike Exp $".
|
2004-05-17 20:28:52 +00:00
|
|
|
//
|
|
|
|
?>
|