Clean up the needs, rename a couple of functions.

This commit is contained in:
Jeff Teunissen 2007-03-22 05:40:12 +00:00
parent 6a8dd8b2ce
commit 32c4145f4b
2 changed files with 18 additions and 6 deletions

View File

@ -27,10 +27,17 @@
have ('html');
function unhtmlentities ($str)
function convertToHTML ($string)
{
$transTable = array_flip (get_html_translation_table (HTML_ENTITIES));
return strtr ($str, $transTable);
$table = array_flip (get_html_translation_table (HTML_ENTITIES));
return strtr ($string, $table);
}
function convertFromHTML ($string)
{
$table = get_html_translation_table (HTML_ENTITIES);
return strtr ($string, $table);
}
?>

View File

@ -27,7 +27,6 @@
*/
have ('news');
need ('sql');
// SQL definition for news table
$createQuery="CREATE TABLE news_main ("
." n_id INT NOT NULL PRIMARY KEY AUTO_INCREMENT,"
@ -49,9 +48,9 @@ function formatNews ($date, $user, $text)
function formatNewsArray ($a)
{
need ("date");
need ('date');
return formatNews (dateFromSQLDateTime ($a['n_date']), $a['n_user'], StripSlashes($a['n_news']));
return formatNews (dateFromSQLDateTime ($a['n_date']), $a['n_user'], stripSlashes($a['n_news']));
}
@ -69,6 +68,8 @@ function printNewsArray ($a)
function latestNews ($max)
{
need ('sql');
$query = 'SELECT n_date, n_user, n_news FROM news_main'
." ORDER BY n_date DESC LIMIT $max";
@ -95,6 +96,8 @@ function printLatestNews ($max)
function monthlyNews ($month, $year)
{
need ('sql');
if (($year < 1999) || ($year > date ('Y'))) { // Sanity checking
$year = date ('Y');
}
@ -126,6 +129,8 @@ function monthlyNews ($month, $year)
function searchNews ($string)
{
need ('sql');
$filler = date ('d M Y');
$search = addSlashes ("%$string%");
$query = 'SELECT n_date, n_user, n_news FROM news_main'