mirror of
https://github.com/michaelrsweet/mxml.git
synced 2024-11-08 13:39:58 +00:00
Articles page with search.
Add format_text() function to convert from plain text to HTML. Drop FAQ page, the articles page will do it.
This commit is contained in:
parent
4216b5f906
commit
207588f1c2
286
www/articles.php
286
www/articles.php
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
//
|
||||
// "$Id: articles.php,v 1.2 2004/05/18 12:02:02 mike Exp $"
|
||||
// "$Id: articles.php,v 1.3 2004/05/18 19:58:34 mike Exp $"
|
||||
//
|
||||
// Web form for the article table...
|
||||
//
|
||||
@ -14,18 +14,32 @@ include_once "phplib/html.php";
|
||||
include_once "phplib/common.php";
|
||||
|
||||
|
||||
//
|
||||
// Maximum number of articles per page...
|
||||
//
|
||||
|
||||
$ARTICLE_PAGE_MAX = 10;
|
||||
|
||||
|
||||
// Get command-line options...
|
||||
//
|
||||
// Usage: article.php [operation]
|
||||
// Usage: article.php [operation] [options]
|
||||
//
|
||||
// Operations:
|
||||
//
|
||||
// D# - Delete Article
|
||||
// D# - Delete article
|
||||
// L = List all
|
||||
// L# = List Article #
|
||||
// M# = Modify Article #
|
||||
// N = Create new Article
|
||||
// L# = List article #
|
||||
// M# = Modify article #
|
||||
// N = Create new article
|
||||
//
|
||||
// Options:
|
||||
//
|
||||
// I# = Set first article
|
||||
// Qtext = Set search text
|
||||
|
||||
$search = "";
|
||||
$index = 0;
|
||||
|
||||
if ($argc)
|
||||
{
|
||||
@ -48,6 +62,14 @@ if ($argc)
|
||||
exit();
|
||||
}
|
||||
|
||||
if (($op == 'D' || $op == 'M') && $LOGIN_USER == "")
|
||||
{
|
||||
html_header("Article Error");
|
||||
print("<p>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("<p>Bad option '$argv[$i]'!</p>\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</A>", "$PHP_SELF?L$id");
|
||||
html_link("Modify Article #$id</A>", "$PHP_SELF?M$id");
|
||||
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");
|
||||
html_end_links();
|
||||
|
||||
print("<h1>Delete Article #$id</h1>\n");
|
||||
@ -132,9 +191,12 @@ switch ($op)
|
||||
$row = db_next($result);
|
||||
|
||||
html_start_links(1);
|
||||
html_link("Return to Article List", "$PHP_SELF?L");
|
||||
html_link("Modify Article</A>", "$PHP_SELF?M$id");
|
||||
html_link("Delete Article #$id</A>", "$PHP_SELF?D$id");
|
||||
html_link("Return to Articles", "$PHP_SELF?L$options");
|
||||
if ($LOGIN_USER)
|
||||
{
|
||||
html_link("Modify Article</A>", "$PHP_SELF?M$id$options");
|
||||
html_link("Delete Article #$id</A>", "$PHP_SELF?D$id$options");
|
||||
}
|
||||
html_end_links();
|
||||
|
||||
print("<h1>Article #$id</h1>\n");
|
||||
@ -146,29 +208,98 @@ switch ($op)
|
||||
."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");
|
||||
print("<tr><th align='right' valign='top'>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");
|
||||
print("<tr><th align='right' valign='top'>Abstract:</th><td class='left'>$temp</td></tr>\n");
|
||||
|
||||
$temp = htmlspecialchars($row['contents']);
|
||||
print("<tr><th align='right'>Contents:</th><td class='left'>$temp</td></tr>\n");
|
||||
$temp = format_text($row['contents']);
|
||||
print("<tr><th align='right' valign='top'>Contents:</th><td class='left'>$temp</td></tr>\n");
|
||||
|
||||
print("</table></p>\n");
|
||||
db_free($result);
|
||||
}
|
||||
else
|
||||
{
|
||||
html_header("Article List");
|
||||
html_header("Articles");
|
||||
|
||||
html_start_links(1);
|
||||
html_link("New Article", "$PHP_SELF?N");
|
||||
html_link("Post New Article", "$PHP_SELF?N$options");
|
||||
html_end_links();
|
||||
|
||||
$result = db_query("SELECT * FROM article");
|
||||
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 ";
|
||||
|
||||
if (!$LOGIN_USER)
|
||||
{
|
||||
$query .= "${prefix}is_published = 1";
|
||||
$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
|
||||
{
|
||||
$query .= "$prefix$logic (title LIKE \"%$keyword%\""
|
||||
." OR abstract LIKE \"%$keyword%\""
|
||||
." OR contents LIKE \"%$keyword%\")";
|
||||
$prefix = $next;
|
||||
$logic = '';
|
||||
}
|
||||
}
|
||||
|
||||
$query .= ")";
|
||||
}
|
||||
|
||||
$result = db_query("SELECT * FROM article $query "
|
||||
."ORDER BY modify_date");
|
||||
$count = db_count($result);
|
||||
|
||||
print("<h1>Article List</h1>\n");
|
||||
if ($count == 0)
|
||||
{
|
||||
print("<p>No Articles found.</p>\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("<p>$count article(s) found, showing $start to $end:</p>\n");
|
||||
|
||||
if ($count > $ARTICLE_PAGE_MAX)
|
||||
{
|
||||
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)
|
||||
."'>Previous $ARTICLE_PAGE_MAX</a> ]");
|
||||
print("</td><td align='right'>");
|
||||
if ($end < $count)
|
||||
{
|
||||
$next_count = min($ARTICLE_PAGE_MAX, $count - $end);
|
||||
print("[ <a href='$PHP_SELF?L+I$next+Q" . urlencode($search)
|
||||
."'>Next $next_count</a> ]");
|
||||
}
|
||||
print("</td></tr>\n");
|
||||
print("</table></p>\n");
|
||||
}
|
||||
|
||||
html_start_table(array("ID","Title","Last Modified"));
|
||||
|
||||
db_seek($result, $index);
|
||||
for ($i = 0; $i < $ARTICLE_PAGE_MAX && $row = db_next($result); $i ++)
|
||||
{
|
||||
html_start_row();
|
||||
|
||||
$id = $row['id'];
|
||||
|
||||
print("<td align='center'><a href='$PHP_SELF?L$id$options' "
|
||||
."alt='Article #$id'>"
|
||||
."$id</a></td>");
|
||||
|
||||
$temp = htmlspecialchars($row['title']);
|
||||
print("<td class='center'><a href='$PHP_SELF?L$id' "
|
||||
print("<td align='center'><a href='$PHP_SELF?L$id$options' "
|
||||
."alt='Article #$id'>"
|
||||
."$temp</a></td>");
|
||||
|
||||
$temp = htmlspecialchars($row['abstract']);
|
||||
print("<td class='center'><a href='$PHP_SELF?L$id' "
|
||||
."alt='Article #$id'>"
|
||||
."$temp</a></td>");
|
||||
|
||||
$temp = htmlspecialchars($row['contents']);
|
||||
print("<td class='center'><a href='$PHP_SELF?L$id' "
|
||||
$temp = date("M d, Y", $row['modify_date']);
|
||||
print("<td align='center'><a href='$PHP_SELF?L$id$options' "
|
||||
."alt='Article #$id'>"
|
||||
."$temp</a></td>");
|
||||
|
||||
html_end_row();
|
||||
|
||||
html_start_row();
|
||||
$temp = htmlspecialchars($row['abstract']);
|
||||
print("<td></td><td colspan='2'>$temp</td>");
|
||||
html_end_row();
|
||||
}
|
||||
|
||||
html_end_table();
|
||||
|
||||
if ($count > $ARTICLE_PAGE_MAX)
|
||||
{
|
||||
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)
|
||||
."'>Previous $ARTICLE_PAGE_MAX</a> ]");
|
||||
print("</td><td align='right'>");
|
||||
if ($end < $count)
|
||||
{
|
||||
$next_count = min($ARTICLE_PAGE_MAX, $count - $end);
|
||||
print("[ <a href='$PHP_SELF?L+I$next+Q" . urlencode($search)
|
||||
."'>Next $next_count</a> ]");
|
||||
}
|
||||
print("</td></tr>\n");
|
||||
print("</table></p>\n");
|
||||
}
|
||||
}
|
||||
|
||||
html_footer();
|
||||
@ -227,15 +420,15 @@ switch ($op)
|
||||
."modify_user = '$LOGIN_USER' "
|
||||
."WHERE id = $id");
|
||||
|
||||
header("Location: $PHP_SELF?L$id");
|
||||
header("Location: $PHP_SELF?L$id$options");
|
||||
}
|
||||
else
|
||||
{
|
||||
html_header("Modify Article #$id");
|
||||
|
||||
html_start_links(1);
|
||||
html_link("Return to Article List", "$PHP_SELF?L");
|
||||
html_link("Article #$id", "$PHP_SELF?L$id");
|
||||
html_link("Return to Articles", "$PHP_SELF?L$options");
|
||||
html_link("Article #$id", "$PHP_SELF?L$id$options");
|
||||
html_end_links();
|
||||
|
||||
print("<h1>Modify Article #$id</h1>\n");
|
||||
@ -249,7 +442,7 @@ switch ($op)
|
||||
|
||||
$row = db_next($result);
|
||||
|
||||
print("<form method='post' action='$PHP_SELF?M$id'>"
|
||||
print("<form method='post' action='$PHP_SELF?M$id$options'>"
|
||||
."<p><table width='100%' cellpadding='5' cellspacing='0' border='0'>\n");
|
||||
|
||||
print("<tr><th align='right'>Published:</th><td>");
|
||||
@ -298,23 +491,28 @@ switch ($op)
|
||||
|
||||
$id = db_insert_id();
|
||||
|
||||
header("Location: $PHP_SELF?L$id");
|
||||
header("Location: $PHP_SELF?L$id$options");
|
||||
break;
|
||||
}
|
||||
|
||||
html_header("New Article");
|
||||
html_header("Post New Article");
|
||||
|
||||
html_start_links(1);
|
||||
html_link("Return to Article List", "$PHP_SELF?L");
|
||||
html_link("Return to Articles", "$PHP_SELF?L$options");
|
||||
html_end_links();
|
||||
|
||||
print("<h1>New Article</h1>\n");
|
||||
print("<form method='post' action='$PHP_SELF?N'>"
|
||||
print("<h1>Post New Article</h1>\n");
|
||||
print("<form method='post' action='$PHP_SELF?N$options'>"
|
||||
."<p><table width='100%' cellpadding='5' cellspacing='0' border='0'>\n");
|
||||
|
||||
print("<tr><th align='right'>Published:</th><td>");
|
||||
select_is_published();
|
||||
print("</td></tr>\n");
|
||||
if ($LOGIN_USER != "")
|
||||
{
|
||||
print("<tr><th align='right'>Published:</th><td>");
|
||||
select_is_published();
|
||||
print("</td></tr>\n");
|
||||
}
|
||||
else
|
||||
print("<input type='hidden' name='IS_PUBLISHED' value='0'/>\n");
|
||||
|
||||
print("<tr><th align='right'>Title:</th>"
|
||||
."<td><input type='text' name='TITLE' "
|
||||
@ -339,6 +537,6 @@ switch ($op)
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: articles.php,v 1.2 2004/05/18 12:02:02 mike Exp $".
|
||||
// End of "$Id: articles.php,v 1.3 2004/05/18 19:58:34 mike Exp $".
|
||||
//
|
||||
?>
|
||||
|
@ -83,6 +83,14 @@ print(" html_footer();\n");
|
||||
print(" exit();\n");
|
||||
print(" }\n");
|
||||
print("\n");
|
||||
print(" if ((\$op == 'D' || \$op == 'M') && \$LOGIN_USER == \"\")\n");
|
||||
print(" {\n");
|
||||
print(" html_header(\"$tname Error\");\n");
|
||||
print(" print(\"<p>Command '\$op' requires a login!\\n\");\n");
|
||||
print(" html_footer();\n");
|
||||
print(" exit();\n");
|
||||
print(" }\n");
|
||||
print("\n");
|
||||
print(" if (\$op == 'N' && \$id)\n");
|
||||
print(" {\n");
|
||||
print(" html_header(\"$tname Error\");\n");
|
||||
@ -214,8 +222,11 @@ while ($row = sqlite_fetch_array($result))
|
||||
default :
|
||||
$name = ucwords(str_replace('_', ' ', $row['name']));
|
||||
|
||||
print(" \$temp = htmlspecialchars(\$row['$row[name]']);\n");
|
||||
print(" print(\"<tr><th align='right'>$name:</th>"
|
||||
if ($row['type'] == "TEXT")
|
||||
print(" \$temp = format_text(\$row['$row[name]']);\n");
|
||||
else
|
||||
print(" \$temp = htmlspecialchars(\$row['$row[name]']);\n");
|
||||
print(" print(\"<tr><th align='right' valign='top'>$name:</th>"
|
||||
."<td class='left'>\$temp</td></tr>\\n\");\n");
|
||||
print("\n");
|
||||
break;
|
||||
@ -245,30 +256,32 @@ print(" html_footer();\n");
|
||||
print(" exit();\n");
|
||||
print(" }\n");
|
||||
print("\n");
|
||||
print(" html_start_table(array(");
|
||||
print(" html_start_table(array(\"ID\"");
|
||||
|
||||
sqlite_seek($result, 0);
|
||||
$firsttime = 1;
|
||||
|
||||
$list_columns = 0;
|
||||
while ($row = sqlite_fetch_array($result))
|
||||
switch ($row['name'])
|
||||
{
|
||||
case "id" :
|
||||
case "create_date" :
|
||||
case "create_user" :
|
||||
case "modify_date" :
|
||||
case "modify_user" :
|
||||
case "is_published" :
|
||||
case "abstract" :
|
||||
case "contents" :
|
||||
break;
|
||||
|
||||
case "modify_date" :
|
||||
print(",\"Last Modified\"");
|
||||
$list_columns ++;
|
||||
break;
|
||||
|
||||
default :
|
||||
$name = ucwords(str_replace('_', ' ', $row['name']));
|
||||
if ($firsttime)
|
||||
{
|
||||
print("\"$name\"");
|
||||
$firsttime = 0;
|
||||
}
|
||||
else
|
||||
print(",\"$name\"");
|
||||
print(",\"$name\"");
|
||||
$list_columns ++;
|
||||
break;
|
||||
}
|
||||
|
||||
@ -285,18 +298,31 @@ while ($row = sqlite_fetch_array($result))
|
||||
{
|
||||
case "id" :
|
||||
print(" \$id = \$row['id'];\n\n");
|
||||
print(" print(\"<td align='center'><a href='\$PHP_SELF?L\$id' \"\n");
|
||||
print(" .\"alt='$tname #\$id'>\"\n");
|
||||
print(" .\"\$id</a></td>\");\n");
|
||||
print("\n");
|
||||
break;
|
||||
|
||||
case "modify_date" :
|
||||
print(" \$temp = date(\"M d, Y\", \$row['modify_date']);\n");
|
||||
print(" print(\"<td align='center'><a href='\$PHP_SELF?L\$id' \"\n");
|
||||
print(" .\"alt='$tname #\$id'>\"\n");
|
||||
print(" .\"\$temp</a></td>\");\n");
|
||||
print("\n");
|
||||
break;
|
||||
|
||||
case "create_date" :
|
||||
case "create_user" :
|
||||
case "modify_date" :
|
||||
case "modify_user" :
|
||||
case "is_published" :
|
||||
case "contents" :
|
||||
case "abstract" :
|
||||
break;
|
||||
|
||||
default :
|
||||
print(" \$temp = htmlspecialchars(\$row['$row[name]']);\n");
|
||||
print(" print(\"<td class='center'><a href='\$PHP_SELF?L\$id' \"\n");
|
||||
print(" print(\"<td align='center'><a href='\$PHP_SELF?L\$id' \"\n");
|
||||
print(" .\"alt='$tname #\$id'>\"\n");
|
||||
print(" .\"\$temp</a></td>\");\n");
|
||||
print("\n");
|
||||
@ -304,6 +330,18 @@ while ($row = sqlite_fetch_array($result))
|
||||
}
|
||||
|
||||
print(" html_end_row();\n");
|
||||
|
||||
sqlite_seek($result, 0);
|
||||
while ($row = sqlite_fetch_array($result))
|
||||
if ($row['name'] == "abstract")
|
||||
{
|
||||
print("\n");
|
||||
print(" html_start_row();\n");
|
||||
print(" \$temp = htmlspecialchars(\$row['abstract']);\n");
|
||||
print(" print(\"<td></td><td colspan='$list_columns'>\$temp</td>\");\n");
|
||||
print(" html_end_row();\n");
|
||||
}
|
||||
|
||||
print(" }\n");
|
||||
print("\n");
|
||||
print(" html_end_table();\n");
|
||||
@ -499,9 +537,14 @@ print(" print(\"<h1>New $tname</h1>\\n\");\n");
|
||||
print(" print(\"<form method='post' action='\$PHP_SELF?N'>\"\n");
|
||||
print(" .\"<p><table width='100%' cellpadding='5' cellspacing='0' border='0'>\\n\");\n");
|
||||
print("\n");
|
||||
print(" print(\"<tr><th align='right'>Published:</th><td>\");\n");
|
||||
print(" select_is_published();\n");
|
||||
print(" print(\"</td></tr>\\n\");\n");
|
||||
print(" if (\$LOGIN_USER != \"\")\n");
|
||||
print(" {\n");
|
||||
print(" print(\"<tr><th align='right'>Published:</th><td>\");\n");
|
||||
print(" select_is_published();\n");
|
||||
print(" print(\"</td></tr>\\n\");\n");
|
||||
print(" }\n");
|
||||
print(" else\n");
|
||||
print(" print(\"<input type='hidden' name='IS_PUBLISHED' value='0'/>\\n\");\n");
|
||||
print("\n");
|
||||
|
||||
sqlite_seek($result, 0);
|
||||
|
@ -1,5 +1,12 @@
|
||||
#!/bin/sh
|
||||
|
||||
if test -f mxml.db; then
|
||||
rm -f mxml.db.old
|
||||
mv mxml.db mxml.db.old
|
||||
fi
|
||||
|
||||
sqlite mxml.db <mxml.sql
|
||||
chmod 666 mxml.db
|
||||
chmod 777 .
|
||||
|
||||
chmod 775 .
|
||||
chmod 664 mxml.db
|
||||
chgrp apache . mxml.db
|
||||
|
20
www/faq.php
20
www/faq.php
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
//
|
||||
// "$Id: faq.php,v 1.1 2004/05/18 12:13:51 mike Exp $"
|
||||
//
|
||||
//
|
||||
|
||||
//
|
||||
// Include necessary headers...
|
||||
//
|
||||
|
||||
include_once "phplib/html.php";
|
||||
|
||||
html_header("Title");
|
||||
|
||||
html_footer();
|
||||
|
||||
//
|
||||
// End of "$Id: faq.php,v 1.1 2004/05/18 12:13:51 mike Exp $".
|
||||
//
|
||||
?>
|
@ -1,11 +1,13 @@
|
||||
<?
|
||||
//
|
||||
// "$Id: common.php,v 1.3 2004/05/18 12:02:02 mike Exp $"
|
||||
// "$Id: common.php,v 1.4 2004/05/18 19:58:35 mike Exp $"
|
||||
//
|
||||
// Common utility functions for PHP pages...
|
||||
//
|
||||
// Contents:
|
||||
//
|
||||
// abbreviate() - Abbreviate long strings...
|
||||
// format_text() - Convert plain text to HTML...
|
||||
// quote_text() - Quote a string...
|
||||
// sanitize_email() - Convert an email address to something a SPAMbot
|
||||
// can't read...
|
||||
@ -73,6 +75,177 @@ abbreviate($text, // I - String
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'format_text()' - Convert plain text to HTML...
|
||||
//
|
||||
|
||||
function // O - Quoted string
|
||||
format_text($text) // I - Original string
|
||||
{
|
||||
$len = strlen($text);
|
||||
$col = 0;
|
||||
$list = 0;
|
||||
$bold = 0;
|
||||
$pre = 0;
|
||||
$ftext = "<p>";
|
||||
|
||||
for ($i = 0; $i < $len; $i ++)
|
||||
{
|
||||
switch ($text[$i])
|
||||
{
|
||||
case '<' :
|
||||
$col ++;
|
||||
$ftext .= "<";
|
||||
break;
|
||||
|
||||
case '>' :
|
||||
$col ++;
|
||||
$ftext .= ">";
|
||||
break;
|
||||
|
||||
case '&' :
|
||||
$col ++;
|
||||
$ftext .= "&";
|
||||
break;
|
||||
|
||||
case "\n" :
|
||||
if (($i + 1) < $len &&
|
||||
($text[$i + 1] == "\n" || $text[$i + 1] == "\r"))
|
||||
{
|
||||
while (($i + 1) < $len &&
|
||||
($text[$i + 1] == "\n" || $text[$i + 1] == "\r"))
|
||||
$i ++;
|
||||
|
||||
if ($pre)
|
||||
{
|
||||
$ftext .= "</pre>";
|
||||
$pre = 0;
|
||||
}
|
||||
|
||||
if (($i + 1) < $len && $text[$i + 1] != '-' && $list)
|
||||
{
|
||||
$ftext .= "\n</ul>\n<p>";
|
||||
$list = 0;
|
||||
}
|
||||
else
|
||||
$ftext .= "\n<p>";
|
||||
}
|
||||
else if (($i + 1) < $len &&
|
||||
($text[$i + 1] == " " || $text[$i + 1] == "\t"))
|
||||
{
|
||||
if ($pre)
|
||||
{
|
||||
$ftext .= "</pre>";
|
||||
$pre = 0;
|
||||
}
|
||||
else
|
||||
$ftext .= "<br />\n";
|
||||
}
|
||||
|
||||
$col = 0;
|
||||
break;
|
||||
|
||||
case "\r" :
|
||||
break;
|
||||
|
||||
case "\t" :
|
||||
if ($col == 0)
|
||||
$ftext .= " ";
|
||||
else
|
||||
$ftext .= " ";
|
||||
break;
|
||||
|
||||
case " " :
|
||||
if ($col == 0 && !pre)
|
||||
{
|
||||
for ($j = $i + 1; $j < $len; $j ++)
|
||||
if ($text[$j] != " " && $text[$j] != "\t")
|
||||
break;
|
||||
|
||||
if ($j < $len && $text[$j] == "%")
|
||||
{
|
||||
$ftext .= "\n<pre>";
|
||||
$pre = 1;
|
||||
}
|
||||
|
||||
$ftext .= " ";
|
||||
}
|
||||
else if ($text[$i + 1] == " ")
|
||||
$ftext .= " ";
|
||||
else
|
||||
$ftext .= " ";
|
||||
|
||||
if ($col > 0)
|
||||
$col ++;
|
||||
break;
|
||||
|
||||
case '*' :
|
||||
if ($bold)
|
||||
$ftext .= "</b>";
|
||||
else
|
||||
$ftext .= "<b>";
|
||||
|
||||
$bold = 1 - $bold;
|
||||
break;
|
||||
|
||||
case '-' :
|
||||
// Possible list...
|
||||
if ($col == 0)
|
||||
{
|
||||
if (!$list)
|
||||
{
|
||||
$ftext .= "\n<ul>";
|
||||
$list = 1;
|
||||
}
|
||||
|
||||
$ftext .= "\n<li>";
|
||||
|
||||
while (($i + 1) < $len && $text[$i + 1] == "-")
|
||||
$i ++;
|
||||
break;
|
||||
}
|
||||
|
||||
$col ++;
|
||||
$ftext .= $text[$i];
|
||||
break;
|
||||
|
||||
case 'f' :
|
||||
case 'h' :
|
||||
if (substr($text, $i, 7) == "http://" ||
|
||||
substr($text, $i, 8) == "https://" ||
|
||||
substr($text, $i, 6) == "ftp://")
|
||||
{
|
||||
// Extract the URL and make this a link...
|
||||
for ($j = $i; $j < $len; $j ++)
|
||||
if ($text[$j] == " " || $text[$j] == "\n" || $text[$j] == "\r" ||
|
||||
$text[$j] == "\t" || $text[$j] == "\'" || $text[$j] == "'")
|
||||
break;
|
||||
|
||||
$count = $j - $i;
|
||||
$url = substr($text, $i, $count);
|
||||
$ftext .= "<a href='$url'>$url</a>";
|
||||
$col += $count;
|
||||
$i = $j - 1;
|
||||
break;
|
||||
}
|
||||
|
||||
default :
|
||||
$col ++;
|
||||
$ftext .= $text[$i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if ($bold)
|
||||
$ftext .= "</b>";
|
||||
|
||||
if ($list)
|
||||
$ftext .= "</ul>";
|
||||
|
||||
return ($ftext);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// 'quote_text()' - Quote a string...
|
||||
//
|
||||
@ -169,7 +342,7 @@ quote_text($text, // I - Original string
|
||||
}
|
||||
}
|
||||
|
||||
return $qtext;
|
||||
return ($qtext);
|
||||
}
|
||||
|
||||
|
||||
@ -216,7 +389,7 @@ sanitize_email($email, // I - Email address
|
||||
}
|
||||
}
|
||||
|
||||
return trim($nemail);
|
||||
return (trim($nemail));
|
||||
}
|
||||
|
||||
|
||||
@ -286,7 +459,7 @@ sanitize_text($text) // I - Original text
|
||||
else
|
||||
$qtext .= quote_text($word);
|
||||
|
||||
return $qtext;
|
||||
return ($qtext);
|
||||
}
|
||||
|
||||
|
||||
@ -313,6 +486,6 @@ select_is_published($is_published = 1) // I - Default state
|
||||
|
||||
|
||||
//
|
||||
// End of "$Id: common.php,v 1.3 2004/05/18 12:02:02 mike Exp $".
|
||||
// End of "$Id: common.php,v 1.4 2004/05/18 19:58:35 mike Exp $".
|
||||
//
|
||||
?>
|
||||
|
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
//
|
||||
// "$Id: html.php,v 1.6 2004/05/18 03:39:38 mike Exp $"
|
||||
// "$Id: html.php,v 1.7 2004/05/18 19:58:35 mike Exp $"
|
||||
//
|
||||
// PHP functions for standardized HTML output...
|
||||
//
|
||||
@ -112,7 +112,6 @@ html_header($title = "") // I - Additional document title
|
||||
."<a href='articles.php'>Articles</a> | "
|
||||
."<a href='documentation.php'>Documentation</a> | "
|
||||
."<a href='software.php'>Download</a> | "
|
||||
."<a href='faq.php'>FAQ</a> | "
|
||||
."<a href='str.php'>Support</a> ]</td>"
|
||||
."<td align='right'>[ ");
|
||||
|
||||
|
34
www/str.php
34
www/str.php
@ -1,6 +1,6 @@
|
||||
<?php
|
||||
//
|
||||
// "$Id: str.php,v 1.5 2004/05/18 01:39:00 mike Exp $"
|
||||
// "$Id: str.php,v 1.6 2004/05/18 19:58:34 mike Exp $"
|
||||
//
|
||||
// Software Trouble Report page...
|
||||
//
|
||||
@ -780,10 +780,13 @@ switch ($op)
|
||||
."'>Previous $STR_PAGE_MAX</a> ]");
|
||||
print("</td><td align='right'>");
|
||||
if ($end < $count)
|
||||
{
|
||||
$next_count = min($STR_PAGE_MAX, $count - $end);
|
||||
print("[ <a href='$PHP_SELF?L+P$priority+S$status+C$scope+I$next+"
|
||||
."E$femail+Q"
|
||||
. urlencode($search)
|
||||
."'>Next $STR_PAGE_MAX</a> ]");
|
||||
."'>Next $next_count</a> ]");
|
||||
}
|
||||
print("</td></tr>\n");
|
||||
print("</table></p>\n");
|
||||
}
|
||||
@ -801,28 +804,28 @@ switch ($op)
|
||||
$prtext = $priority_text[$row['priority']];
|
||||
$sttext = $status_text[$row['status']];
|
||||
$sctext = $scope_text[$row['scope']];
|
||||
$link = "<a href='$PHP_SELF?L$row[id]$options' "
|
||||
."alt='STR #$row[id]: $summary'>";
|
||||
|
||||
html_start_row();
|
||||
|
||||
print("<td nowrap>");
|
||||
if ($LOGIN_USER)
|
||||
print("<input type='checkbox' name='ID_$row[id]'>");
|
||||
print("<a href='$PHP_SELF?L$row[id]$options' alt='STR #$row[id]: $summary'>"
|
||||
."$row[id]</a></td>"
|
||||
."<td align='center'>$prtext</td>"
|
||||
."<td align='center'>$sttext</td>"
|
||||
."<td align='center'>$sctext</td>"
|
||||
."<td align='center'><a href='$PHP_SELF?L$row[id]$options' "
|
||||
."alt='STR #$row[id]: $summary'>$summabbr</a></td>"
|
||||
."<td align='center'>$row[str_version]</td>"
|
||||
."<td align='center'>$date</td>");
|
||||
print("$link$row[id]</a></td>"
|
||||
."<td align='center'>$link$prtext</a></td>"
|
||||
."<td align='center'>$link$sttext</a></td>"
|
||||
."<td align='center'>$link$sctext</a></td>"
|
||||
."<td align='center'>$link$summabbr</a></td>"
|
||||
."<td align='center'>$link$row[str_version]</a></td>"
|
||||
."<td align='center'>$link$date</a></td>");
|
||||
|
||||
if ($row['manager_email'] != "")
|
||||
$email = sanitize_email($row['manager_email']);
|
||||
else
|
||||
$email = "<i>Unassigned</i>";
|
||||
|
||||
print("<td align='center'>$email</td>");
|
||||
print("<td align='center'>$link$email</a></td>");
|
||||
|
||||
html_end_row();
|
||||
|
||||
@ -911,10 +914,13 @@ switch ($op)
|
||||
."'>Previous $STR_PAGE_MAX</a> ]");
|
||||
print("</td><td align='right'>");
|
||||
if ($end < $count)
|
||||
{
|
||||
$next_count = min($STR_PAGE_MAX, $count - $end);
|
||||
print("[ <a href='$PHP_SELF?L+P$priority+S$status+C$scope+I$next+"
|
||||
."E$femail+Q"
|
||||
. urlencode($search)
|
||||
."'>Next $STR_PAGE_MAX</a> ]");
|
||||
."'>Next $next_count</a> ]");
|
||||
}
|
||||
print("</td></tr>\n");
|
||||
print("</table></p>\n");
|
||||
}
|
||||
@ -1842,6 +1848,6 @@ switch ($op)
|
||||
}
|
||||
|
||||
//
|
||||
// End of "$Id: str.php,v 1.5 2004/05/18 01:39:00 mike Exp $".
|
||||
// End of "$Id: str.php,v 1.6 2004/05/18 19:58:34 mike Exp $".
|
||||
//
|
||||
?>
|
||||
|
Loading…
Reference in New Issue
Block a user