$value) { if ($key == "passwd") { $query .= "$key=PASSWORD('". addslashes($value) ."'), "; } else { $query .= "$key='". addslashes($value) ."', "; } } $query = substr($query, 0, -2); dbconnect(); if (!empty($id)) { mysql_query("UPDATE $dbase SET $query WHERE id=$id") or die(mysql_error()); return $id; } else { mysql_query("INSERT INTO $dbase SET $query") or die(mysql_error()); return mysql_insert_id(); } } function showLogin($userid = "") { print("
\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("
User ID:
Password:
Register as new user.
$user->ublock
\n"); print("
\n"); } function showAccess() { global $user, $access; foreach ($access as $key=>$value) if ($user->access & $value) $result .= "$key
"; return $result; } function showUser() { include('theme.inc'); $theme->header(); if (!empty($user->userid)) { print("

Welcome $user->name! 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"); print("\n"); print("\n"); print("\n"); print("\n"); if ($user->access > 0) print("\n"); print("\n"); print("\n"); print("
Name:$user->name
User ID:$user->userid
E-mail:$user->email
Access:". showAccess() ."
Bio:$user->bio
$user->ublock
\n"); } else { showLogin($userid); } $theme->footer(); } function newUser($user = "", $error="") { include('theme.inc'); $theme->header(); print("
\n"); print("\n"); if (!empty($error)) { print("\n"); } print("\n"); print("\n"); print("\n"); print("\n"); print("
$error
Name:
User ID:
E-mail:
\n"); print("
\n"); $theme->footer(); } function validateUser($user) { ### 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 '$uname' is not valid.
"; if (strlen($user[userid]) > 15) $rval = "the specified username is too long: it must be less than 15 characters."; if (eregi("^((root)|(httpd)|(operator)|(admin)|(administrator)|(news)|(deamon)|(nobody)|(ftp))$", $user[userid])) $rval = "the specified username is reserved."; ### Verify whether username and e-mail address are uniqua: dbconnect(); if (mysql_num_rows(mysql_query("SELECT userid FROM testusers WHERE LOWER(userid)=LOWER('$user[userid]')")) > 0) $rval = "the specified username is already taken."; if (mysql_num_rows(mysql_query("SELECT email FROM testusers WHERE LOWER(email)=LOWER('$user[email]')")) > 0) $rval = "the specified e-mail address is already registered."; return($rval); } function makePassword($min_length=6) { mt_srand((double)microtime() * 1000000); $words = array("foo","bar","guy","neo","geek","nerd","fish","hack","star","moon","hero","cola","girl","fish","java","boss"); while(strlen($password) < $min_length) { $password .= $words[mt_rand(0, count($words))]; } return $password; } switch ($op) { case "Login": session_start(); $user = new User($userid,$passwd); if ($user->valid()) { session_register("user"); } showUser(); break; case "new": newUser(); break; case "logout": session_start(); session_destroy(); unset($user); showUser(); break; case "Register": if ($rval = validateUser($new)) { newUser($new, "Error: $rval"); } else { include('theme.inc'); $new[passwd] = makePassword(); dbsave("testusers", $new); $theme->header(); if ($system == 1) { print("Your password is: $new[passwd]
"); print("Login to change your personal settings."); } else { $message = "Your $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: $newu[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"; $subject = "Account details for $sitename"; mail($new[email], $subject, $message, "From: $contact_email\nX-Mailer: PHP/" . phpversion()); print("Your member account has been created and the details necessary to login have been sent to your e-mail account $email. Once you received the account confirmation, hit this link to login."); } $theme->footer(); } break; case "edituser": if ($user->valid() == 0) { showLogin(); } include('theme.inc'); $theme->header(); print("
\n"); print("Real name:
\n"); print("name\">
\n"); print("Optional.

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

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

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

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

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

\n"); print("Password:
\n"); print("
\n"); print("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"); print("
\n"); print("

\n"); $theme->footer(); break; case "editpage": include('theme.inc'); $theme->header(); print("
\n"); print("Theme:
\n"); include "themes/list.php"; for ($i = 0; $i < count($themelist); $i++) { if ($themelist[$i] != "") { $options .= ""; } } if ($userinfo[theme]=="") $userinfo[theme] = "default"; print("
\n"); print("Changes the look and feel of the site.

\n"); print("Maximum number of stories:
\n"); print("storynum\">

\n"); $options = ""; $options .= ""; $options .= ""; $options .= ""; print("Display mode:
\n"); print("

\n"); $options = ""; $options .= ""; $options .= ""; print("Sort order:
\n"); print("

\n"); $options = ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; $options .= ""; print("Threshold:
\n"); print("
\n"); print("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"); print("Singature: (255 char limit)
\n"); print("
\n"); print("Optional. This information will be publicly displayed at the end of your comments.

\n"); print("
\n"); print("

\n"); $theme->footer(); break; case "Save user information": if ($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("testusers", $data, $user->id); $user->update(); } showUser(); break; case "Save page settings": if ($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("testusers", $data, $user->id); $user->update(); } showUser(); break; default: showUser(); } ?>