Commit ef43f485 authored by Dries's avatar Dries
Browse files

A bunch of internal changes:
 - better organisation of include files
 - renamed a few function to make more sense
 - small bugfix in the user account registration
 - ...
parent da9675ef
......@@ -176,7 +176,7 @@ function account_user($uname) {
$output .= "<TABLE BORDER=\"0\" CELLPADDING=\"2\" CELLSPACING=\"2\">\n";
$output .= " <TR><TD ALIGN=\"right\"><B>User ID:</B></TD><TD>$user->userid</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Name:</B></TD><TD>". format_data($user->name) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>E-mail:</B></TD><TD>". format_email_address($user->fake_email) ."</A></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>E-mail:</B></TD><TD>". format_email($user->fake_email) ."</A></TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>URL:</B></TD><TD>". format_url($user->url) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Bio:</B></TD><TD>". format_data($user->bio) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\" VALIGN=\"top\"><B>Signature:</B></TD><TD>". format_data($user->signature) ."</TD></TR>\n";
......@@ -190,7 +190,7 @@ function account_user($uname) {
elseif ($uname && $account = account_get_user($uname)) {
$box1 .= "<TABLE BORDER=\"0\" CELLPADDING=\"1\" CELLSPACING=\"1\">\n";
$box1 .= " <TR><TD ALIGN=\"right\"><B>Username:</B></TD><TD>$account->userid</TD></TR>\n";
$box1 .= " <TR><TD ALIGN=\"right\"><B>E-mail:</B></TD><TD>". format_email_address($account->fake_email) ."</TD></TR>\n";
$box1 .= " <TR><TD ALIGN=\"right\"><B>E-mail:</B></TD><TD>". format_email($account->fake_email) ."</TD></TR>\n";
$box1 .= " <TR><TD ALIGN=\"right\"><B>URL:</B></TD><TD>". format_url($account->url) ."</TD></TR>\n";
$box1 .= " <TR><TD ALIGN=\"right\"><B>Bio:</B></TD><TD>". format_data($account->bio) ."</TD></TR>\n";
$box1 .= "</TABLE>\n";
......@@ -288,9 +288,9 @@ function account_register_submit($new) {
user_save($new);
$link = "http://". getenv("HOSTNAME") ."/account.php?op=confirm&name=$new[userid]&hash=$new[hash]";
$message = "$new[userid],\n\n\nsomeone signed up for a user account on $sitename and supplied this email address as their contact. If it wasn't you, don't get your panties in a knot and simply ignore this mail.\n\nIf this was you, you have to activate your account first before you can login. You can activate your account by visiting the URL below:\n\n $link\n\nVisiting this URL will automatically activate your account. Once activated you can login using the following information:\n\n username: $new[userid]\n password: $new[passwd]\n\n\n-- $sitename crew\n";
// mail($new[real_email], "Account details for $sitename", $message, "From: noreply@$sitename");
print "<PRE>$message</PRE>\n";
$message = "$new[userid],\n\n\nsomeone signed up for a user account on $sitename and supplied this email address as their contact. If it wasn't you, don't get your panties in a knot and simply ignore this mail.\n\nIf this was you, you have to activate your account first before you can login. You can do so simply by visiting the URL below:\n\n $link\n\nVisiting this URL will automatically activate your account. Once activated you can login using the following information:\n\n username: $new[userid]\n password: $new[passwd]\n\n\n-- $sitename crew\n";
mail($new[real_email], "Account details for $sitename", $message, "From: noreply@$sitename");
watchdog(1, "new user `$new[userid]' &lt;$new[real_email]&gt;");
......
......@@ -40,7 +40,7 @@ function account_display($order = "username") {
foreach ($show as $key=>$value) {
switch($value) {
case "real_email":
$output .= " <TD>". format_email_address($account[$value]) ."</TD>\n";
$output .= " <TD>". format_email($account[$value]) ."</TD>\n";
break;
case "last_access":
$output .= " <TD>". format_date($account[$value]) ."</TD>\n";
......@@ -91,7 +91,7 @@ function account_view($name) {
$output .= " <TR><TD ALIGN=\"right\"><B>ID:</B></TD><TD>$account->id</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 e-mail address:</B></TD><TD>". format_email_address($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>URL of homepage:</B></TD><TD>". format_url($account->url) ."</TD></TR>\n";
$output .= " <TR><TD ALIGN=\"right\"><B>Last access:</B></TD><TD>". format_date($account->last_access) ." from $account->last_host</TD></TR>\n";
......
......@@ -287,7 +287,7 @@ function comment_post($pid, $sid, $subject, $comment) {
$subject = ($subject) ? $subject : substr($comment, 0, 29);
### Add comment to database:
db_insert("INSERT INTO comments (pid, sid, author, subject, comment, hostname, timestamp) VALUES ($pid, $sid, $user->id, '". addslashes($subject) ."', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
db_insert("INSERT INTO comments (pid, sid, author, subject, comment, hostname, timestamp) VALUES ($pid, $sid, '$user->id', '". addslashes($subject) ."', '". addslashes($comment) ."', '". getenv("REMOTE_ADDR") ."', '". time() ."')");
### Compose header:
header("Location: discussion.php?id=$sid");
......
<?
include "includes/database.inc";
include "includes/watchdog.inc";
function id2story($id) {
### Perform query:
$result = db_query("SELECT s.*, u.userid FROM stories s LEFT JOIN users u ON s.author = u.id WHERE s.id = $id");
......@@ -69,7 +66,7 @@ function format_username($username, $admin = 0) {
else { global $anonymous; return $anonymous; }
}
function format_email_address($address) {
function format_email($address) {
return ($address) ? "<A HREF=\"mailto:$address\">$address</A>" : format_data($address);
}
......
<?
include "includes/user.inc";
function display_morelink($theme, $story) {
return ($story->article) ? "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\"><B>read more</B></FONT></A> | ". strlen($story->article) ." bytes | <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]" : "[ <A HREF=\"discussion.php?id=$story->id\"><FONT COLOR=\"$theme->hlcolor2\">". format_plural($story->comments, "comment", "comments") ."</FONT></A> ]";
......@@ -61,7 +60,7 @@ function display_old_headlines($theme, $num = 10) {
function display_comment_moderation($id, $author, $score, $votes) {
global $user, $comment_votes;
if ($user->userid && $user->userid != $author && !user_getHistory($user->history, "c$id")) {
if ($user->id && $user->userid != $author && !user_getHistory($user->history, "c$id")) {
$output .= "<SELECT NAME=\"moderate[$id]\">\n";
foreach ($comment_votes as $key=>$value) $output .= " <OPTION VALUE=\"$value\">$key</OPTION>\n";
$output .= "</SELECT>\n";
......@@ -106,7 +105,8 @@ function display_calendar($theme, $date) {
function display_account($theme) {
global $user;
if ($user && $user->userid) {
if ($user->id) {
function submission_number() {
$result = db_query("SELECT COUNT(id) FROM stories WHERE status = 1");
return ($result) ? db_result($result, 0) : 0;
......
<?
include "includes/config.inc";
include "includes/database.inc";
include "includes/watchdog.inc";
include "includes/function.inc";
include "includes/template.inc";
include "includes/user.inc";
global $user;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment