WeakWiki


modules\ussm\ussm.include.php



/********************************************************************************
WeakWiki (WeakWiki ussm include file: ussm.include.php)
Copyright (C) 2010 Alexander Lang

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 3 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, see .

Project Home: http://weakwiki.robnet.wmweb.at/
Contact:      robbiblubber@robnet.wmweb.at
********************************************************************************/



$error = null;
$page  = "register";

if(isset($_GET['page'])) { $page = $_GET['page']; }


if(!USSM_REGISTER_USERS)
{
	if(($page == "register") || ($page == "verify") || ($page == "send"))
	{
		return false;
	} 
}

$pm = new PageMenu();
		
$pm->add("" . _L_USSM_0010 . "");
$pm->write();

echo("
"); switch($page) { case "details": echo("

"); echo($this->getDetails()); break; case "verify": $time = $_GET['t']; $time += 172800; if($time < time()) { jwrite('user **' . $_GET['uid'] . '** failed validation (expired)'); $m = new MessageBox(_L_USSM_0044, _L_USSM_0045, MSG_ERROR); $m->write(); } else if(!file_exists(_PATH_USERS . $_GET['uid'] . ".user.php")) { $m = new MessageBox(_L_USSM_0044, _L_USSM_0046, MSG_ERROR); $m->write(); } else { $n = file_get_contents(_PATH_USERS . $_GET['uid'] . ".user.php"); $n = str_replace(".&&inactive?" . $_GET['id'] . "." . $_GET['t'], "", $n); file_put_contents(_PATH_USERS . $_GET['uid'] . ".user.php", $n); jwrite('user **' . $_GET['uid'] . '** has been validated'); $m = new MessageBox(_L_USSM_0047, _L_USSM_0048, MSG_SUCCESS); echo("

" . _L_USSM_0049 . "" . _L_USSM_004a . "" . _L_USSM_004b . "
\n"); } break; case "send": if(trim($_POST['uid']) == "") { $error = new MessageBox(_L_USSM_0039, _L_USSM_003f, MSG_ERROR); } if(userExists($_POST['uid'])) { $error = new MessageBox(_L_USSM_0039, _L_USSM_003a, MSG_ERROR); } else if($_POST['password'] != $_POST['rpassword']) { $error = $error = new MessageBox(_L_USSM_0039, _L_USSM_003b, MSG_ERROR); } else if($_POST['password'] == "") { $error = new MessageBox(_L_USSM_0039, _L_USSM_003c, MSG_ERROR); } else if(strpos($_POST['email'], "@") === false) { $error = new MessageBox(_L_USSM_0039, _L_USSM_003d, MSG_ERROR); } else if(getUserByEMail($_POST['email']) != null) { $error = new MessageBox(_L_USSM_0039, _L_USSM_003e, MSG_ERROR); } else { $m = new MessageBox(_L_USSM_0042, _L_USSM_0043, MSG_SUCCESS); $lvl = $_POST['level']; $uid = $_POST['uid']; $fname = $_POST['fname']; $email = $_POST['email']; $password = $_POST['password']; $rpassword = $_POST['rpassword']; if(USSM_VERIFY_EMAIL) { $ucode = md5(time()) . md5($email . $uid); $time = time(); $n = $time % 97; $ctime = date("Y-m-d H:i:s"); $u = new User(); $u->__setValues($uid, $lvl, $fname, $email, $comment); $password = md5($uid . "*" . $password) . ".&&inactive?" . $ucode . "." . $time; file_put_contents(_PATH_USERS . $uid . ".user.php", $u->serialize($password, _UC_HASHED)); $link = "http://" . $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?action=ussm&page=verify&uid=" . $uid . "&id=" . $ucode . "&t=" . $time . "&n=" . $n; mail($email, USSM_EMAIL_TITLE, str_replace('%NAME%', $fname, USSM_EMAIL_BODY) . $link . USSM_EMAIL_SIGNATURE, USSM_EMAIL_ADDHEADERS); echo("

\n"); echo(_L_USSM_0040 . "
\n"); echo(_L_USSM_0041); } else { $u = new User(); $u->__setValues($uid, $lvl, $fname, $email, $comment); $password = md5($uid . "*" . $password) . ".&&inactive?" . $ucode . "." . $time; file_put_contents(_PATH_USERS . $uid . ".user.php", $u->serialize($password, _UC_FULL)); } jwrite('user **' . $uid . '** has registered'); break; } case "register": if($error != null) { $error->write(); } echo("

\n" . _L_USSM_0020 . "

"); echo(_L_USSM_0021 . "" . _L_USSM_0022 . "" . _L_USSM_0023 . "

"); $lvl = (USSM_ALLOW_WRITE ? 1 : 0); $uid = ""; $fname = ""; $email = ""; $password = ""; $rpassword = ""; if(isset($_POST['level'])) { $lvl = $_POST['level']; $uid = $_POST['uid']; $fname = $_POST['fname']; $email = $_POST['email']; $password = $_POST['password']; $rpassword = $_POST['rpassword']; } echo("
\n"); echo("\n"); echo("\n"); echo("\n"); echo("\n"); echo("\n"); echo("\n"); echo("\n"); echo("\n"); echo("
  " . _L_USSM_0030 . "  
  " . _L_USSM_0031 . "  
  " . _L_USSM_0032 . "  
  " . _L_USSM_0033 . "  
  " . _L_USSM_0034 . "  
  " . _L_USSM_0035 . "  

" . _L_USSM_0038 . "  \n"); echo("" . _L_USSM_0022 . "
\n"); echo("
\n"); if(USSM_PASSWORD_RESET) { echo("

\n"); echo(_L_USSM_0050); echo("" . _L_USSM_0051 . "\n"); } break; case "sendpassword": $u = getUserByEMail($_POST['email']); if($u == null) { $error = "

" . _L_USSM_0039 . "
" . _L_USSM_0064 . "

"; } else { echo("

" . _L_USSM_0065 . "
" . _L_USSM_0066 . "

\n"); $password = substr(md5(rand()), 2, 12); file_put_contents(_PATH_USERS . $u->getUID() . ".user.php", $u->serialize($password, _UC_FULL)); mail($_POST['email'], USSM_PASSWD_EMAIL_TITLE, str_replace('%PASSWD%', $password, str_replace('%NAME%', $u->getFullName(), USSM_PASSWD_EMAIL_BODY)) . USSM_EMAIL_SIGNATURE, USSM_EMAIL_ADDHEADERS); jwrite('user **' . $_GET['uid'] . '** has requested new password (sent)'); echo("

\n"); echo(_L_USSM_0067 . "
\n"); break; } case "resetpassword": echo($error); echo("

\n" . _L_USSM_0060 . "

"); echo(_L_USSM_0061 . "" . _L_USSM_0062 . "" . _L_USSM_0063 . "

"); $email = ""; if(isset($_POST['email'])) { $email = $_POST['email']; } echo("
\n"); echo("\n"); echo("\n"); echo("\n"); echo("
  " . _L_USSM_0031 . "  

" . _L_USSM_0038 . "  \n"); echo("" . _L_USSM_0022 . "
\n"); echo("
\n"); break; } ?>

WeakWiki