\n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
User ID:
Password:
Register as new user.
$user->ublock
\n"; $output .= "\n"; return $output; } function showAccess() { global $user, $access; foreach ($access as $key=>$value) if ($user->access & $value) $result .= "$key
"; return $result; } function showUser($uname) { global $user, $theme; if ($user && $uname && $user->userid == $uname) { $output .= "

Welcome $user->userid! This is your user info page. There are many more, but this one is yours. You are probably most interested in editing something, but if you need to kill some time, this place is as good as any other place.

\n"; $output .= "\n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; if ($user->access > 0) $output .= "\n"; $output .= " \n"; $output .= " \n"; $output .= "
User ID:$user->userid
Name:$user->name
E-mail:femail\">$user->femail
URL:url\">$user->url
Access:". showAccess() ."
Bio:$user->bio
Signature:$user->signature
\n"; ### Display account information: $theme->header(); $theme->box("User information", $output); $theme->footer(); } elseif ($uname && $account = account_getUser($uname)) { $output .= "\n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= " \n"; $output .= "
User ID:$account->userid
E-mail:femail\">$account->femail
URL:url\">$account->url
Bio:$account->bio
Signature:$account->signature
\n"; ### Display account information: $theme->header(); $theme->box("User information", $output); $theme->footer(); } else { ### Display login form: $theme->header(); $theme->box("Login", showLogin($userid)); $theme->footer(); } } function newUser($user = "", $error="") { global $theme; $output .= "
\n"; $output .= "\n"; if (!empty($error)) $output .= "\n"; $output .= "\n"; $output .= "\n"; $output .= "\n"; $output .= "\n"; $output .= "
$error
Name:
User ID:
E-mail:
\n"; $output .= "
\n"; $theme->header(); $theme->box("Register as new user", $output); $theme->footer(); } function validateUser($user) { include "ban.inc"; ### Verify username and e-mail address: $user[userid] = trim($user[userid]); if (empty($user[email]) || (!eregi("^[_\.0-9a-z-]+@([0-9a-z][0-9a-z-]+\.)+[a-z]{2,3}$", $user[email]))) $rval = "the specified e-mail address is not valid.
"; if (empty($user[userid]) || (ereg("[^a-zA-Z0-9_-]", $user[userid]))) $rval = "the specified username '$new[userid]' is not valid.
"; if (strlen($user[userid]) > 15) $rval = "the specified username is too long: it must be less than 15 characters."; ### Check to see whether the username or e-mail address are banned: if ($ban = ban_match($user[userid], $type2index[usernames])) $rval = "the specified username is banned for the following reason: $ban->reason."; if ($ban = ban_match($user[email], $type2index[addresses])) $rval = "the specified e-mail address is banned for the following reason: $ban->reason."; ### Verify whether username and e-mail address are unique: if (db_num_rows(db_query("SELECT userid FROM users WHERE LOWER(userid)=LOWER('$user[userid]')")) > 0) $rval = "the specified username is already taken."; if (db_num_rows(db_query("SELECT email FROM users WHERE LOWER(email)=LOWER('$user[email]')")) > 0) $rval = "the specified e-mail address is already registered."; return($rval); } function account_makePassword($min_length=6) { mt_srand((double)microtime() * 1000000); $words = array("foo","bar","guy","neo","tux","moo","sun","asm","dot","god","axe","geek","nerd","fish","hack","star","mice","warp","moon","hero","cola","girl","fish","java","perl","boss","dark","sith","jedi","drop","mojo"); while(strlen($password) < $min_length) $password .= $words[mt_rand(0, count($words))]; return $password; } function account_track_comments() { global $user; $output .= "

This page might be helpful in case you want to keep track of your most recent comments in any of the discussions. You are given an overview of your comments in each of the stories you participates in along with the number of replies each comment got.\n

\n"; ### Perform query: $sresult = db_query("SELECT s.id, s.subject, COUNT(s.id) as count FROM comments c LEFT JOIN stories s ON c.sid = s.id WHERE c.author = $user->id GROUP BY s.id DESC LIMIT 5"); while ($story = db_fetch_object($sresult)) { $output .= "

  • ". format_plural($story->count, comment, comments) ." in story `id\">$story->subject`:
  • \n"; $output .= " \n"; } return $output; } switch ($op) { case "Login": session_start(); $user = new User($userid, $passwd); if ($user && user_valid()) { session_register("user"); watchdog(1, "session opened for user `$user->userid'."); } else { watchdog(2, "failed login for user `$userid'."); } showUser($user->userid); break; case "new": newUser(); break; case "view": showUser($name); break; case "discussion": $theme->header(); $theme->box("Track your comments", account_track_comments()); $theme->footer(); break; case "logout": watchdog(1, "session closed for user `$user->userid'."); session_unset(); session_destroy(); unset($user); showUser(); break; case "Register": if ($rval = validateUser($new)) { newUser($new, "Error: $rval"); } else { ### Generate new password: $new[passwd] = account_makePassword(); dbsave("users", $new); if ($system == 1) { ### Display account information: $theme->header(); $theme->box("Account details", "Your password is: $new[passwd]
    Login to change your personal settings."); $theme->footer(); } else { ### Send e-mail with account details: mail($new[email], "Account details for $sitename", "$user->name,\n\nyour $sitename member account has been created succesfully. To be able to use it, you must login using the information below. Please save this mail for further reference.\n\n username: $new[userid]\n e-mail: $new[email]\n password: $new[passwd]\n\nThis password is generated by a randomizer. It is recommended that you change this password immediately.\n\n$contact_signature", "From: $contact_email\nX-Mailer: PHP/" . phpversion()); ### Display account information: $theme->header(); $theme->box("Account details", "Your member account has been created and the details necessary to login have been sent to your e-mail account $new[email]. Once you received the account confirmation, hit this link to login."); $theme->footer(); } watchdog(1, "new user `$new[userid]' registered with e-mail address `$new[email]'"); } break; case "user": if ($user->id && user_valid()) { ### Generate output/content: $output .= "
    \n"; $output .= "Real name:
    \n"; $output .= "name\">
    \n"; $output .= "Optional.

    \n"; $output .= "Real e-mail address:
    \n"; $output .= "email\">
    \n"; $output .= "Required, but never displayed publicly: needed in case you lose your password.

    \n"; $output .= "Fake e-mail address:
    \n"; $output .= "femail\">
    \n"; $output .= "Optional, and displayed publicly by your comments. You may spam proof it if you want.

    \n"; $output .= "URL of homepage:
    \n"; $output .= "url\">
    \n"; $output .= "Optional, but make sure you enter fully qualified URLs only. That is, remember to include \"http://\".

    \n"; $output .= "Bio: (255 char. limit)
    \n"; $output .= "
    \n"; $output .= "Optional. This biographical information is publicly displayed on your user page.

    \n"; $output .= "User block: (255 char. limit)
    \n"; $output .= "
    \n"; $output .= "ublockon == 1 ? " CHECKED" : "") ."> Enable user block
    \n"; $output .= "Enable the checkbox and whatever you enter below will appear on your costum main page.

    \n"; $output .= "Password:
    \n"; $output .= "
    \n"; $output .= "Enter your new password twice if you want to change your current password or leave it blank if you are happy with your current password.

    \n"; $output .= "
    \n"; $output .= "

    \n"; ### Display output/content: $theme->header(); $theme->box("Edit your information", $output); $theme->footer(); } else { $theme->header(); $theme->box("Login", showLogin($userid)); $theme->footer(); } break; case "page": if ($user && user_valid()) { ### Generate output/content: $output .= "
    \n"; $output .= "Theme:
    \n"; ### Loop (dynamically) through all available themes: $handle = opendir("themes"); while ($file = readdir($handle)) if(!ereg("^\.",$file) && file_exists("themes/$file/theme.class.php")) $options .= ""; closedir($handle); if ($userinfo[theme]=="") $userinfo[theme] = $cfg_theme; $output .= "
    \n"; $output .= "Selecting a different theme will change the look and feel of the site.

    \n"; $output .= "Maximum number of stories:
    \n"; $output .= "storynum\">

    \n"; $output .= "The maximum number of stories that will be displayed on the main page.

    \n"; $options = ""; $options .= ""; $options .= ""; $output .= "Comment display mode:
    \n"; $output .= "

    \n"; $options = ""; $options .= ""; $options .= ""; $output .= "Comment sort order:
    \n"; $output .= "

    \n"; $options = ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $output .= "Comment threshold:
    \n"; $output .= "
    \n"; $output .= "Comments that scored less than this setting will be ignored. Anonymous comments start at 0, comments of people logged on start at 1 and moderators can add and subtract points.

    \n"; $output .= "Singature: (255 char. limit)
    \n"; $output .= "
    \n"; $output .= "Optional. This information will be publicly displayed at the end of your comments.

    \n"; $output .= "
    \n"; $output .= "

    \n"; ### Display output/content: $theme->header(); $theme->box("Customize your page", $output); $theme->footer(); } else { $theme->header(); $theme->box("Login", showLogin($userid)); $theme->footer(); } break; case "Save user information": if ($user && user_valid()) { $data[name] = $edit[name]; $data[email] = $edit[email]; $data[femail] = $edit[femail]; $data[url] = $edit[url]; $data[bio] = $edit[bio]; $data[ublock] = $edit[ublock]; $data[ublockon] = $edit[ublockon]; if ($edit[pass1] == $edit[pass2] && !empty($edit[pass1])) { $data[passwd] = $edit[pass1]; } dbsave("users", $data, $user->id); user_rehash(); } showUser($user->userid); break; case "Save page settings": if ($user && user_valid()) { $data[theme] = $edit[theme]; $data[storynum] = $edit[storynum]; $data[umode] = $edit[umode]; $data[uorder] = $edit[uorder]; $data[thold] = $edit[thold]; $data[signature] = $edit[signature]; dbsave("users", $data, $user->id); user_rehash(); } showUser($user->userid); break; default: showUser($user->userid); } ?>