* * $Id: register.php,v 1.12 2001/02/10 18:59:27 haakon Exp $ * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ include ".sipsconfig.php"; function printForm() { global $username, $email; print("

" .i18n("All fields are required.")); print("

\n\n"); print("\n"); print("\n"); print("\n"); print("\n"); print("
" .i18n("Username") .":
" .i18n("Password") .":
" .i18n("Repeat password") .":
" .i18n("Real Email") .": (" .i18n("Not public. Needed if you lose your password.") .")
\n\n\n
\n"); } function errorReg($msg) { printTop(i18n("error registering")); print("$msg\n"); printForm(); } if ($action == "register") { if ($password != $password2) { errorReg(i18n("#B#Your two passwords don't match.#/B# Try again to be sure of the password!")); } else if ($password == "") { errorReg("" .i18n("You have to set a password!") ."\n"); } else { $username = strtolower($username); if (strlen($username) > 12) { errorReg(i18n("#B#Username must be 12 characters or less!#/B#")); } else if (!eregi("^([0-9a-z])*$", $username)) { errorReg(i18n("#B#Username contains illegal characters!#/B# Please use only alpha-numeric characters.")); } else if (file_exists($config["sipssys"] ."/users/$username[0]/$username/user")) { errorReg(i18n("#B#This username is already in use!#/B# Please try another one.")); } else { $email = cleanStr($email); if ($email == "") { errorReg("" .i18n("You have to set "Real Email" to your real email address!") .""); } else if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$", $email)) { print("" .i18n("That doesn't look like your real e-mail address! Try again - use a valid address.") .""); } else { // Ok to go! Ok t-to g-g-g-ooo-oooo! if (!file_exists($config["sipssys"] ."/users/$username[0]")) { mkdir($config["sipssys"] ."/users/$username[0]", 0777); chmod($config["sipssys"] ."/users/$username[0]", 0777); } mkdir($config["sipssys"] ."/users/$username[0]/$username", 0777); touch($config["sipssys"] ."/users/$username[0]/$username/user"); $cryptpass = md5($password); setUserValue($username, "Password", $cryptpass); setUserValue($username, "Email", $email); if ($config["defaultboxes"] != "") setUserValue($username, "Boxes", $config["defaultboxes"]); setUserValue($username, "Theme", getUserValue("default", "Theme")); // new users inherit default's theme setUserValue($username, "Timezone", getUserValue("default", "Timezone")); // new users inherit default's timezone setcookie("user", "$username:$cryptpass", time() + ($config["cookietime"] * 86400)); printTop(i18n("register")); print(i18n("#B#You have been registered!#/B# Welcome to #SITENAME#. To tune the service to your liking, go to #2#preferences#3#!", "", "")); } } } } else { printTop("register"); print("

" .i18n("Register for an account with #1#!", $config["sitename"]) ."

"); printForm(); } printBottom(); ?>