Commit db554e85 authored by Dries's avatar Dries
Browse files

- initial import of the preliminary translation code.
- added timer.inc for benchmarking purpose
- bugfix for php-clean
- bugfix for account.php
- removed redundant format_data
- ...
parent 3ba9cb5d
This diff is collapsed.
...@@ -108,6 +108,12 @@ CREATE TABLE layout ( ...@@ -108,6 +108,12 @@ CREATE TABLE layout (
block varchar(64) DEFAULT '' NOT NULL block varchar(64) DEFAULT '' NOT NULL
); );
CREATE TABLE locales (
id int(11) DEFAULT '0' NOT NULL auto_increment,
english TEXT DEFAULT '' NOT NULL,
PRIMARY KEY (id)
);
CREATE TABLE modules ( CREATE TABLE modules (
name varchar(64) DEFAULT '' NOT NULL, name varchar(64) DEFAULT '' NOT NULL,
PRIMARY KEY (name) PRIMARY KEY (name)
......
...@@ -205,7 +205,7 @@ function comment_moderation($comment) { ...@@ -205,7 +205,7 @@ function comment_moderation($comment) {
$output .= "</SELECT>\n"; $output .= "</SELECT>\n";
} }
else { else {
$output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". format_data($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". format_data($comment->votes) ."</TR></TABLE>\n"; $output .= "<TABLE BORDER=\"0\" CELLSPACING=\"1\" CELLPADDING=\"1\"><TR><TD>score:</TD><TD>". check_output($comment->score) ."</TD></TR><TR><TD>votes:</TD><TD>". check_output($comment->votes) ."</TR></TABLE>\n";
} }
return $output; return $output;
......
<? <?
$na = "<I>na</I>";
function check_textfield($message) { function check_textfield($message) {
global $allowed_html; global $allowed_html;
return strip_tags(str_replace("\"", "&quot;", stripslashes($message)), $allowed_html); return strip_tags(str_replace("\"", "&quot;", stripslashes($message)), $allowed_html);
...@@ -20,13 +22,16 @@ function check_code($message) { ...@@ -20,13 +22,16 @@ function check_code($message) {
} }
function check_output($message, $nl2br = 0) { function check_output($message, $nl2br = 0) {
global $allowed_html; global $allowed_html, $na;
if ($nl2br == 1) return nl2br(strip_tags(stripslashes($message), $allowed_html)); if ($message) {
else return strip_tags(stripslashes($message), $allowed_html); if ($nl2br == 1) return nl2br(strip_tags(stripslashes($message), $allowed_html));
else return strip_tags(stripslashes($message), $allowed_html);
}
else return $na;
} }
function format_plural($count, $singular, $plural) { function format_plural($count, $singular, $plural) {
return ($count == 1) ? "$count $singular" : "$count $plural"; return ($count == 1) ? "$count ". t($singular) : "$count ". t($plural);
} }
function format_interval($timestamp) { function format_interval($timestamp) {
...@@ -72,9 +77,6 @@ function format_date($timestamp, $type = "medium") { ...@@ -72,9 +77,6 @@ function format_date($timestamp, $type = "medium") {
return $date; return $date;
} }
function format_data($field, $replacement = "<I>na</I>") {
return ($field) ? $field : $replacement;
}
function format_username($username) { function format_username($username) {
global $user; global $user;
...@@ -83,16 +85,14 @@ function format_username($username) { ...@@ -83,16 +85,14 @@ function format_username($username) {
} }
function format_email($address) { function format_email($address) {
return ($address) ? "<A HREF=\"mailto:$address\">$address</A>" : format_data($address); global $na;
return ($address) ? "<A HREF=\"mailto:$address\">$address</A>" : $na;
} }
function format_url($address, $description = "") { function format_url($address, $description = "") {
// POSSIBLE EXTENSIONS: global $na;
// 1. add `http://' in case it's missing.
// 2. add a trailing `/' in case it's missing.
// 3. remove any parameters in the URI.
$description = ($description) ? $description : $address; $description = ($description) ? $description : $address;
return ($address) ? "<A HREF=\"$address\">$description</A>" : format_data($address); return ($address) ? "<A HREF=\"$address\">$description</A>" : $na;
} }
?> ?>
<? <?
function t($string) { function t($string) {
$result = db_query("SELECT id FROM locales WHERE english = '". addslashes($string) ."'");
if (!db_fetch_object($result)) db_query("INSERT INTO locales (english) VALUES ('". addslashes($string) ."')");
return $string; return $string;
} }
......
...@@ -21,7 +21,7 @@ function search_data($keys, $type) { ...@@ -21,7 +21,7 @@ function search_data($keys, $type) {
} }
if (!$output) { if (!$output) {
$output .= "<P><SMALL>Your search yielded no results:</P><UL><LI>try using fewer words.</LI><LI>try using more general keywords.</LI><LI>try using different keywords.</LI></UL></SMALL>\n"; $output .= t("Your search yielded no results.");
} }
return $output; return $output;
......
...@@ -30,15 +30,13 @@ function menu($name, $module) { ...@@ -30,15 +30,13 @@ function menu($name, $module) {
module_iterate("menu"); module_iterate("menu");
// Display account settings: // Display account settings:
$content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">track your comments</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=track&topic=comments\">". t("track your comments") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=stories\">track your stories</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=track&topic=stories\">". t("track your stories") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=track&topic=site\">track $site_name</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=track&topic=site\">". t("track") ." $site_name</A></LI>\n";
$content .= "<P>\n"; $content .= "<P>\n";
$content .= "<LI><A HREF=\"submission.php\">submission queue</A> (<FONT COLOR=\"red\">". submission_number() ."</FONT>)</LI>\n"; $content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">". t("edit your information") ."</A></LI>\n";
$content .= "<P>\n"; $content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">". t("edit your preferences") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=user\">edit your information</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=edit&topic=content\">". t("edit your content") ."</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=site\">edit your preferences</A></LI>\n";
$content .= "<LI><A HREF=\"account.php?op=edit&topic=content\">edit your content</A></LI>\n";
$content .= "<P>\n"; $content .= "<P>\n";
if (user_permission($user)) { if (user_permission($user)) {
...@@ -46,26 +44,29 @@ function menu($name, $module) { ...@@ -46,26 +44,29 @@ function menu($name, $module) {
$content .= "<P>\n"; $content .= "<P>\n";
} }
$content .= "<LI><A HREF=\"submission.php\">". t("submission queue") ."</A> (<FONT COLOR=\"red\">". submission_number() ."</FONT>)</LI>\n";
$content .= "<P>\n";
if ($menu && ksort($menu)) { if ($menu && ksort($menu)) {
foreach ($menu as $link=>$url) $content .= "<LI><A HREF=\"$url\">$link</A></LI>\n"; foreach ($menu as $link=>$url) $content .= "<LI><A HREF=\"$url\">". t($link) ."</A></LI>\n";
$content .= "<P>\n"; $content .= "<P>\n";
} }
$content .= "<LI><A HREF=\"account.php?op=logout\">logout</A></LI>\n"; $content .= "<LI><A HREF=\"account.php?op=logout\">". t("logout") ."</A></LI>\n";
$theme->box("$user->userid's configuration", "$content"); $theme->box(strtr(t("%s's configuration"), array("%s" => $user->userid)), "$content");
} }
else { else {
$output .= "<CENTER>\n"; $output .= "<CENTER>\n";
$output .= " <FORM ACTION=\"account.php?op=Login\" METHOD=\"post\">\n"; $output .= " <FORM ACTION=\"account.php?op=Login\" METHOD=\"post\">\n";
$output .= " <P><B>Username:</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"></P>\n"; $output .= " <P><B>". t("Username") .":</B><BR><INPUT NAME=\"userid\" SIZE=\"15\"></P>\n";
$output .= " <P><B>Password:</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"></P>\n"; $output .= " <P><B>". t("Password") .":</B><BR><INPUT NAME=\"passwd\" SIZE=\"15\" TYPE=\"password\"></P>\n";
$output .= " <P><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Login\"></P>\n"; $output .= " <P><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Login\"></P>\n";
$output .= " <P><A HREF=\"account.php\">REGISTER</A></P>\n"; $output .= " <P><A HREF=\"account.php\">". t("REGISTER") ."</A></P>\n";
$output .= " </FORM>\n"; $output .= " </FORM>\n";
$output .= "</CENTER>\n"; $output .= "</CENTER>\n";
$theme->box("Login", $output); $theme->box(t("Login"), $output);
} }
} }
...@@ -84,7 +85,7 @@ function theme_blocks($region, $theme) { ...@@ -84,7 +85,7 @@ function theme_blocks($region, $theme) {
else $result = db_query("SELECT * FROM blocks WHERE status = 2 ORDER BY weight"); else $result = db_query("SELECT * FROM blocks WHERE status = 2 ORDER BY weight");
while ($block = db_fetch_object($result)) { while ($block = db_fetch_object($result)) {
$blocks = module_execute($block->module, "block"); $blocks = module_execute($block->module, "block");
$theme->box($blocks[$block->offset]["subject"], $blocks[$block->offset]["content"]); $theme->box(t($blocks[$block->offset]["subject"]), $blocks[$block->offset]["content"]);
} }
break; break;
} }
......
<?
$timer = 0;
function timer_print() {
global $timer;
$stop = explode(" ", microtime());
$diff = $timer[0] - $stop[0];
print "<PRE>execution time: $diff ms</PRE>";
}
function timer_start() {
global $timer;
$timer = explode(" ", microtime());
}
?>
\ No newline at end of file
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
function account_cron_ratings() { function account_cron_ratings() {
$period = 5184000; // 60 days $period = 5184000; // 60 days
$number = 30; // 30 comments $number = 30; // 30 comments
$offset = 5; // 5 comments
$r1 = db_query("SELECT id, userid FROM users"); $r1 = db_query("SELECT id, userid FROM users");
while ($account = db_fetch_object($r1)) { while ($account = db_fetch_object($r1)) {
...@@ -27,7 +28,7 @@ function account_cron_ratings() { ...@@ -27,7 +28,7 @@ function account_cron_ratings() {
$votes += $weight * $comment->votes; $votes += $weight * $comment->votes;
} }
if ($weight > 5 && $votes > 0) { if ($weight >= $offset && $votes > 0) {
$value = ($score + $weight) / $votes + $bonus; $value = ($score + $weight) / $votes + $bonus;
db_query("UPDATE users SET rating = '$value' WHERE id = $account->id"); db_query("UPDATE users SET rating = '$value' WHERE id = $account->id");
} }
...@@ -121,7 +122,7 @@ function account_display($order = "username") { ...@@ -121,7 +122,7 @@ function account_display($order = "username") {
$output .= " <TD ALIGN=\"center\">". $perm[$account[$value]] ."</TD>\n"; $output .= " <TD ALIGN=\"center\">". $perm[$account[$value]] ."</TD>\n";
break; break;
case "timezone": case "timezone":
$output .= " <TD ALIGN=\"center\">". format_data($account[$value] / 3600) ."</TD>\n"; $output .= " <TD ALIGN=\"center\">". check_output($account[$value] / 3600) ."</TD>\n";
break; break;
case "url": case "url":
$output .= " <TD>". format_url($account[$value]) ."</TD>\n"; $output .= " <TD>". format_url($account[$value]) ."</TD>\n";
...@@ -130,7 +131,7 @@ function account_display($order = "username") { ...@@ -130,7 +131,7 @@ function account_display($order = "username") {
$output .= " <TD>". format_username($account[$value]) ."</TD>\n"; $output .= " <TD>". format_username($account[$value]) ."</TD>\n";
break; break;
default: default:
$output .= " <TD>". format_data($account[$value]) ."</TD>\n"; $output .= " <TD>". check_output($account[$value]) ."</TD>\n";
} }
} }
$output .= " <TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=view&name=$account[userid]\">view</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=edit&name=$account[userid]\">edit</A></TD>\n"; $output .= " <TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=view&name=$account[userid]\">view</A></TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=account&op=edit&name=$account[userid]\">edit</A></TD>\n";
...@@ -144,7 +145,7 @@ function account_display($order = "username") { ...@@ -144,7 +145,7 @@ function account_display($order = "username") {
function account_blocks($id) { function account_blocks($id) {
$result = db_query("SELECT * FROM layout WHERE user = $id"); $result = db_query("SELECT * FROM layout WHERE user = $id");
while ($layout = db_fetch_object($result)) { while ($layout = db_fetch_object($result)) {
$output .= "<LI>". check_output($layout->block) ."</LI>\n"; $output .= "<LI>$layout->block</LI>\n";
} }
return $output; return $output;
} }
...@@ -152,7 +153,7 @@ function account_blocks($id) { ...@@ -152,7 +153,7 @@ function account_blocks($id) {
function account_stories($id) { function account_stories($id) {
$result = db_query("SELECT * FROM stories WHERE author = $id ORDER BY timestamp DESC"); $result = db_query("SELECT * FROM stories WHERE author = $id ORDER BY timestamp DESC");
while ($story = db_fetch_object($result)) { while ($story = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"story.php?id=$story->id\">". check_output($story->subject) ."</A></LI>\n"; $output .= "<LI><A HREF=\"story.php?id=$story->id\">$story->subject</A></LI>\n";
} }
return $output; return $output;
} }
...@@ -160,7 +161,7 @@ function account_stories($id) { ...@@ -160,7 +161,7 @@ function account_stories($id) {
function account_comments($id) { function account_comments($id) {
$result = db_query("SELECT * FROM comments WHERE link = 'story' AND author = $id ORDER BY timestamp DESC"); $result = db_query("SELECT * FROM comments WHERE link = 'story' AND author = $id ORDER BY timestamp DESC");
while ($comment = db_fetch_object($result)) { while ($comment = db_fetch_object($result)) {
$output .= "<LI><A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">". check_output($comment->subject) ."</A></LI>\n"; $output .= "<LI><A HREF=\"story.php?id=$comment->lid&cid=$comment->cid&pid=$comment->pid#$comment->cid\">$comment->subject</A></LI>\n";
} }
return $output; return $output;
} }
...@@ -196,20 +197,20 @@ function account_edit($name) { ...@@ -196,20 +197,20 @@ function account_edit($name) {
$output .= " <TR><TD ALIGN=\"right\"><B>ID:</B></TD><TD>$account->id</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>ID:</B></TD><TD>$account->id</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Status:</B></TD><TD>$stat</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Status:</B></TD><TD>$stat</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Username:</B></TD><TD>$account->userid</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Username:</B></TD><TD>$account->userid</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Real name:</B></TD><TD>". format_data($account->name) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Real name:</B></TD><TD>". check_output($account->name) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Real e-mail address:</B></TD><TD>". format_email($account->real_email) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Real e-mail address:</B></TD><TD>". format_email($account->real_email) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Fake e-mail address:</B></TD><TD><INPUT NAME=\"edit[fake_email]\" SIZE=\"55\" VALUE=\"$account->fake_email\"></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Fake e-mail address:</B></TD><TD><INPUT NAME=\"edit[fake_email]\" SIZE=\"55\" VALUE=\"$account->fake_email\"></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>URL of homepage:</B></TD><TD><INPUT NAME=\"edit[url]\" SIZE=\"55\" VALUE=\"$account->url\"></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>URL of homepage:</B></TD><TD><INPUT NAME=\"edit[url]\" SIZE=\"55\" VALUE=\"$account->url\"></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Permissions:</B></TD><TD>$perm</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Permissions:</B></TD><TD>$perm</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Last access:</B></TD><TD>". format_date($account->last_access) ." from ". format_data($account->last_host) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Last access:</B></TD><TD>". format_date($account->last_access) ." from ". check_output($account->last_host) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>User rating:</B></TD><TD>". format_data($account->rating) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>User rating:</B></TD><TD>". check_output($account->rating) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Bio information:</B></TD><TD><TEXTAREA NAME=\"edit[bio]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$account->bio</TEXTAREA></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Bio information:</B></TD><TD><TEXTAREA NAME=\"edit[bio]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$account->bio</TEXTAREA></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Signature:</B></TD><TD><TEXTAREA NAME=\"edit[signature]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$account->signature</TEXTAREA></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Signature:</B></TD><TD><TEXTAREA NAME=\"edit[signature]\" COLS=\"35\" ROWS=\"5\" WRAP=\"virtual\">$account->signature</TEXTAREA></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Theme:</B></TD><TD>". format_data($account->theme) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Theme:</B></TD><TD>". check_output($account->theme) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Timezone:</B></TD><TD>". format_data($account->timezone / 3600) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Timezone:</B></TD><TD>". check_output($account->timezone / 3600) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Selected blocks:</B></TD><TD>". format_data(account_blocks($account->id)) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Selected blocks:</B></TD><TD>". check_output(account_blocks($account->id)) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted stories:</B></TD><TD>". format_data(account_stories($account->id)) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted stories:</B></TD><TD>". check_output(account_stories($account->id)) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted comments:</B></TD><TD>". format_data(account_comments($account->id)) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted comments:</B></TD><TD>". check_output(account_comments($account->id)) ."</TD></TR>\n";
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";
$output .= "<INPUT NAME=\"name\" TYPE=\"hidden\" VALUE=\"$account->userid\">\n"; $output .= "<INPUT NAME=\"name\" TYPE=\"hidden\" VALUE=\"$account->userid\">\n";
$output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save account\">\n"; $output .= "<INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Save account\">\n";
...@@ -229,20 +230,20 @@ function account_view($name) { ...@@ -229,20 +230,20 @@ function account_view($name) {
$output .= " <TR><TD ALIGN=\"right\"><B>ID:</B></TD><TD><A HREF=\"admin.php?mod=account&op=edit&name=$account->userid\">$account->id</A></TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>ID:</B></TD><TD><A HREF=\"admin.php?mod=account&op=edit&name=$account->userid\">$account->id</A></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Status:</B></TD><TD>". $status[$account->status] ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Status:</B></TD><TD>". $status[$account->status] ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Username:</B></TD><TD>$account->userid</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Username:</B></TD><TD>$account->userid</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Real name:</B></TD><TD>". format_data($account->name) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Real name:</B></TD><TD>". check_output($account->name) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Real e-mail address:</B></TD><TD>". format_email($account->real_email) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Real e-mail address:</B></TD><TD>". format_email($account->real_email) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Fake e-mail address:</B></TD><TD>". format_data($account->fake_email) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Fake e-mail address:</B></TD><TD>". check_output($account->fake_email) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>URL of homepage:</B></TD><TD>". format_url($account->url) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>URL of homepage:</B></TD><TD>". format_url($account->url) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Permissions:</B></TD><TD>". $permissions[$account->permissions] ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Permissions:</B></TD><TD>". $permissions[$account->permissions] ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Last access:</B></TD><TD>". format_date($account->last_access) ." from ". format_data($account->last_host) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Last access:</B></TD><TD>". format_date($account->last_access) ." from ". check_output($account->last_host) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>User rating:</B></TD><TD>". format_data($account->rating) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>User rating:</B></TD><TD>". check_output($account->rating) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Bio information:</B></TD><TD>". format_data($account->bio) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Bio information:</B></TD><TD>". check_output($account->bio) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Signature:</B></TD><TD>". format_data($account->signature) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Signature:</B></TD><TD>". check_output($account->signature) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Theme:</B></TD><TD>". format_data($account->theme) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Theme:</B></TD><TD>". check_output($account->theme) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Timezone:</B></TD><TD>". format_data($account->timezone / 3600) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\"><B>Timezone:</B></TD><TD>". check_output($account->timezone / 3600) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Selected blocks:</B></TD><TD>". format_data(account_blocks($account->id)) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Selected blocks:</B></TD><TD>". check_output(account_blocks($account->id)) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted stories:</B></TD><TD>". format_data(account_stories($account->id)) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted stories:</B></TD><TD>". check_output(account_stories($account->id)) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted comments:</B></TD><TD>". format_data(account_comments($account->id)) ."</TD></TR>\n"; $output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Submitted comments:</B></TD><TD>". check_output(account_comments($account->id)) ."</TD></TR>\n";
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";
print "$output"; print "$output";
} }
...@@ -254,7 +255,7 @@ function account_block() { ...@@ -254,7 +255,7 @@ function account_block() {
$content .= "<TABLE CELLPADDING=\"2\" CELLSPACING=\"2\">\n"; $content .= "<TABLE CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$content .= "<TR><TH>Username</TH><TH>Rating</TH></TR>\n"; $content .= "<TR><TH>Username</TH><TH>Rating</TH></TR>\n";
while ($account = db_fetch_object($result)) { while ($account = db_fetch_object($result)) {
$content .= "<TR><TD>". format_username($account->userid) ."</TD><TD>". format_data($account->rating) ."</TD></TR>"; $content .= "<TR><TD>". format_username($account->userid) ."</TD><TD>". check_output($account->rating) ."</TD></TR>";
} }
$content .= "</TABLE>\n"; $content .= "</TABLE>\n";
......
...@@ -71,7 +71,7 @@ function affiliate_admin_display() { ...@@ -71,7 +71,7 @@ function affiliate_admin_display() {
$output .= " <TR><TH>name</TH><TH>link</TH><TH>contact</TH><TH>operations</TH></TR>\n"; $output .= " <TR><TH>name</TH><TH>link</TH><TH>contact</TH><TH>operations</TH></TR>\n";
while ($affiliate = db_fetch_object($result)) { while ($affiliate = db_fetch_object($result)) {
$output .= " <TR><TD>$affiliate->name</TD><TD>". format_url($affiliate->link) ."</TD><TD>". format_email($affiliate->contact) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=affiliate-site&op=delete&id=$affiliate->id\">delete</A></TD></TR>\n"; $output .= " <TR><TD>". check_output($affiliate->name) ."</TD><TD>". format_url($affiliate->link) ."</TD><TD>". format_email($affiliate->contact) ."</TD><TD ALIGN=\"center\"><A HREF=\"admin.php?mod=affiliate-site&op=delete&id=$affiliate->id\">delete</A></TD></TR>\n";
} }
$output .= " <TR><TD><INPUT TYPE=\"text\" NAME=\"name\"></TD><TD><INPUT TYPE=\"text\" NAME=\"url\"></TD><TD><INPUT TYPE=\"text\" NAME=\"contact\"></TD><TD><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Add affiliate site\"></TD></TR>\n"; $output .= " <TR><TD><INPUT TYPE=\"text\" NAME=\"name\"></TD><TD><INPUT TYPE=\"text\" NAME=\"url\"></TD><TD><INPUT TYPE=\"text\" NAME=\"contact\"></TD><TD><INPUT NAME=\"op\" TYPE=\"submit\" VALUE=\"Add affiliate site\"></TD></TR>\n";
......
...@@ -55,10 +55,10 @@ function box_admin_display() { ...@@ -55,10 +55,10 @@ function box_admin_display() {
while ($block = db_fetch_object($result)) { while ($block = db_fetch_object($result)) {
$output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n"; $output .= "<TABLE BORDER=\"1\" CELLPADDING=\"3\" CELLSPACING=\"0\">\n";
$output .= " <TR><TH>Subject:</TH><TD>". format_data($block->subject) ."</TD></TR>\n"; $output .= " <TR><TH>Subject:</TH><TD>". check_output($block->subject) ."</TD></TR>\n";
$output .= " <TR><TH>Content:</TH><TD>". nl2br(htmlentities($block->content)) ."</TD></TR>\n"; $output .= " <TR><TH>Content:</TH><TD>". nl2br(htmlentities($block->content)) ."</TD></TR>\n";
$output .= " <TR><TH>Type:</TH><TD>". $type[$block->type] ."</TD></TR>\n"; $output .= " <TR><TH>Type:</TH><TD>". $type[$block->type] ."</TD></TR>\n";
$output .= " <TR><TH>Description:</TH><TD>". format_data($block->info) ."</TD></TR>\n"; $output .= " <TR><TH>Description:</TH><TD>". check_output($block->info) ."</TD></TR>\n";
$output .= " <TR><TH>Link:</TH><TD>". format_url($block->link) ."</TD></TR>\n"; $output .= " <TR><TH>Link:</TH><TD>". format_url($block->link) ."</TD></TR>\n";
$output .= " <TR><TH>Operations:</TH><TD><A HREF=\"admin.php?mod=box&op=edit&id=$block->id\">edit</A>, <A HREF=\"admin.php?mod=box&op=delete&id=$block->id\">delete</A></TD></TR>\n"; $output .= " <TR><TH>Operations:</TH><TD><A HREF=\"admin.php?mod=box&op=edit&id=$block->id\">edit</A>, <A HREF=\"admin.php?mod=box&op=delete&id=$block->id\">delete</A></TD></TR>\n";
$output .= "</TABLE>\n"; $output .= "</TABLE>\n";
......
...@@ -33,23 +33,21 @@ function diary_page_overview($num = 20) { ...@@ -33,23 +33,21 @@ function diary_page_overview($num = 20) {
$result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY d.timestamp DESC LIMIT $num"); $result = db_query("SELECT d.*, u.userid FROM diaries d LEFT JOIN users u ON d.author = u.id ORDER BY d.timestamp DESC LIMIT $num");
$output .= "<P>This part of the website is dedicated to provide easy-to-write and easy-to-read online diaries or journals filled with daily thoughts, poetry, boneless blabber, spiritual theories, intimate details, valuable experiences, cynical rants, semi-coherent comments, writing experiments, artistic babblings, critics on current facts, fresh insights, diverse dreams, chronicles and mumbling madness available for public consumption.</P>";
while ($diary = db_fetch_object($result)) { while ($diary = db_fetch_object($result)) {
if ($time != date("F jS", $diary->timestamp)) { if ($time != date("F jS", $diary->timestamp)) {
$output .= "<B>". date("l, F jS", $diary->timestamp) ."</B>\n"; $output .= "<B>". date("l, F jS", $diary->timestamp) ."</B>\n";
$time = date("F jS", $diary->timestamp); $time = date("F jS", $diary->timestamp);
} }
$output .= "<DL>\n"; $output .= "<DL>\n";
$output .= " <DD><P><B>$diary->userid wrote:</B></P></DD>\n"; $output .= " <DD><P><B>$diary->userid ". t("wrote") .":</B></P></DD>\n";
$output .= " <DL>\n"; $output .= " <DL>\n";
$output .= " <DD><P>". check_output($diary->text, 1) ."</P><P>[ <A HREF=\"module.php?mod=diary&op=view&name=$diary->userid\">more</A> ]</P></DD>\n"; $output .= " <DD><P>". check_output($diary->text, 1) ."</P><P>[ <A HREF=\"module.php?mod=diary&op=view&name=$diary->userid\">". t("more") ."</A> ]</P></DD>\n";
$output .= " </DL>\n"; $output .= " </DL>\n";
$output .= "</DL>\n"; $output .= "</DL>\n";
} }
$theme->header(); $theme->header();
$theme->box("Online diary", $output); $theme->box(t("Online diary"), $output);
$theme->footer(); $theme->footer();
} }
...@@ -58,7 +56,7 @@ function diary_page_entry($timestamp, $text, $id = 0) { ...@@ -58,7 +56,7 @@ function diary_page_entry($timestamp, $text, $id = 0) {
if ($id) { if ($id) {
$output .= "<DL>\n"; $output .= "<DL>\n";
$output .= " <DT><B>". date("l, F jS", $timestamp) .":</B> </DT>\n"; $output .= " <DT><B>". date("l, F jS", $timestamp) .":</B> </DT>\n";
$output .= " <DD><P>[ <A HREF=\"module.php?mod=diary&op=edit&id=$id\">edit</A> ]</P><P>". check_output($text, 1) ."</P></DD>\n"; $output .= " <DD><P>[ <A HREF=\"module.php?mod=diary&op=edit&id=$id\">". t("edit") ."</A> ]</P><P>". check_output($text, 1) ."</P></DD>\n";
$output .= "</DL>\n"; $output .= "</DL>\n";
} }
else { else {
...@@ -82,12 +80,12 @@ function diary_page_display($username) { ...@@ -82,12 +80,12 @@ function diary_page_display($username) {
while ($diary = db_fetch_object($result)) $output .= diary_page_entry($diary->timestamp, $diary->text, $diary->id); while ($diary = db_fetch_object($result)) $output .= diary_page_entry($diary->timestamp, $diary->text, $diary->id);
} }
else { else {
$output .= "<P>". format_username($username) ."'s diary:</P>\n"; $output .= "<B>". t("Username") .":</B> ". format_username($username);
while ($diary = db_fetch_object($result)) $output .= diary_page_entry($diary->timestamp, $diary->text); while ($diary = db_fetch_object($result)) $output .= diary_page_entry($diary->timestamp, $diary->text);
} }
$theme->header(); $theme->header();
$theme->box("$username's online diary", $output); $theme->box(t("Online diary"), $output);
$theme->footer(); $theme->footer();
} }
...@@ -97,9 +95,8 @@ function diary_page_add() { ...@@ -97,9 +95,8 @@ function diary_page_add() {
$output .= "<FORM ACTION=\"module.php?mod=diary\" METHOD=\"post\">\n"; $output .= "<FORM ACTION=\"module.php?mod=diary\" METHOD=\"post\">\n";
$output .= "<P>\n"; $output .= "<P>\n";
$output .= " <B>Enter new diary entry:</B><BR>\n"; $output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"text\"></TEXTAREA><BR>\n";
$output .= " <TEXTAREA WRAP=\"virtual\" COLS=\"50\" ROWS=\"15\" NAME=\"text\" MAXLENGTH=\"20\"></TEXTAREA><BR>\n"; $output .= " <SMALL><I>". t("Allowed HTML tags") .": ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
$output .= " <SMALL><I>Allowed HTML tags: ". htmlspecialchars($allowed_html) .".</I></SMALL>\n";
$output .= "</P>\n"; $output .= "</P>\n";
$output .= "<P>\n"; $output .= "<P>\n";
...@@ -109,7 +106,7 @@ function diary_page_add() { ...@@ -109,7 +106,7 @@ function diary_page_add() {
$output .= "</FORM>\n";