//
// ------------------------------------------------------------------------ //
// 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. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// 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 //
// ------------------------------------------------------------------------ //
$xoopsOption['pagetype'] = 'user';
include 'mainfile.php';
$myts =& MyTextSanitizer::getInstance();
$config_handler =& xoops_gethandler('config');
$xoopsConfigUser =& $config_handler->getConfigsByCat(XOOPS_CONF_USER);
if (empty($xoopsConfigUser['allow_register'])) {
redirect_header('index.php', 6, _US_NOREGISTER);
exit();
}
function userCheck($uname, $email, $pass, $vpass)
{
global $xoopsConfigUser;
$xoopsDB =& Database::getInstance();
$myts =& MyTextSanitizer::getInstance();
$stop = '';
if (!checkEmail($email)) {
$stop .= _US_INVALIDMAIL.'
';
}
foreach ($xoopsConfigUser['bad_emails'] as $be) {
if (!empty($be) && preg_match("/".$be."/i", $email)) {
$stop .= _US_INVALIDMAIL.'
';
break;
}
}
if (strrpos($email,' ') > 0) {
$stop .= _US_EMAILNOSPACES.'
';
}
$uname = xoops_trim($uname);
switch ($xoopsConfigUser['uname_test_level']) {
case 0:
// strict
$restriction = '/[^a-zA-Z0-9\_\-]/';
break;
case 1:
// medium
$restriction = '/[^a-zA-Z0-9\_\-\<\>\,\.\$\%\#\@\!\\\'\"]/';
break;
case 2:
// loose
$restriction = '/[\000-\040]/';
break;
}
if (empty($uname) || preg_match($restriction, $uname)) {
$stop .= _US_INVALIDNICKNAME."
";
}
if (strlen($uname) > $xoopsConfigUser['maxuname']) {
$stop .= sprintf(_US_NICKNAMETOOLONG, $xoopsConfigUser['maxuname'])."
";
}
if (strlen($uname) < $xoopsConfigUser['minuname']) {
$stop .= sprintf(_US_NICKNAMETOOSHORT, $xoopsConfigUser['minuname'])."
";
}
foreach ($xoopsConfigUser['bad_unames'] as $bu) {
if (!empty($bu) && preg_match("/".$bu."/i", $uname)) {
$stop .= _US_NAMERESERVED."
";
break;
}
}
if (strrpos($uname, ' ') > 0) {
$stop .= _US_NICKNAMENOSPACES."
";
}
$sql = sprintf('SELECT COUNT(*) FROM %s WHERE uname = %s', $xoopsDB->prefix('users'), $xoopsDB->quoteString(addslashes($uname)));
$result = $xoopsDB->query($sql);
list($count) = $xoopsDB->fetchRow($result);
if ($count > 0) {
$stop .= _US_NICKNAMETAKEN."
";
}
$count = 0;
if ( $email ) {
$sql = sprintf('SELECT COUNT(*) FROM %s WHERE email = %s', $xoopsDB->prefix('users'), $xoopsDB->quoteString(addslashes($email)));
$result = $xoopsDB->query($sql);
list($count) = $xoopsDB->fetchRow($result);
if ( $count > 0 ) {
$stop .= _US_EMAILTAKEN."
";
}
}
if ( !isset($pass) || $pass == '' || !isset($vpass) || $vpass == '' ) {
$stop .= _US_ENTERPWD.'
';
}
if ( (isset($pass)) && ($pass != $vpass) ) {
$stop .= _US_PASSNOTSAME.'
';
} elseif ( ($pass != '') && (strlen($pass) < $xoopsConfigUser['minpass']) ) {
$stop .= sprintf(_US_PWDTOOSHORT,$xoopsConfigUser['minpass'])."
";
}
return $stop;
}
$op = !isset($_POST['op']) ? 'register' : $_POST['op'];
$uname = isset($_POST['uname']) ? $myts->stripSlashesGPC($_POST['uname']) : '';
$email = isset($_POST['email']) ? trim($myts->stripSlashesGPC($_POST['email'])) : '';
$url = isset($_POST['url']) ? trim($myts->stripSlashesGPC($_POST['url'])) : '';
$pass = isset($_POST['pass']) ? $myts->stripSlashesGPC($_POST['pass']) : '';
$vpass = isset($_POST['vpass']) ? $myts->stripSlashesGPC($_POST['vpass']) : '';
$timezone_offset = isset($_POST['timezone_offset']) ? intval($_POST['timezone_offset']) : $xoopsConfig['default_TZ'];
$user_viewemail = (isset($_POST['user_viewemail']) && intval($_POST['user_viewemail'])) ? 1 : 0;
$user_mailok = (isset($_POST['user_mailok']) && intval($_POST['user_mailok'])) ? 1 : 0;
$agree_disc = (isset($_POST['agree_disc']) && intval($_POST['agree_disc'])) ? 1 : 0;
switch ( $op ) {
case 'newuser':
if (!XoopsSingleTokenHandler::quickValidate('register_newuser')) {
exit();
}
include 'header.php';
$stop = '';
if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') {
if (empty($agree_disc)) {
$stop .= _US_UNEEDAGREE.'
';
}
}
$stop .= userCheck($uname, $email, $pass, $vpass);
if (empty($stop)) {
$token =& XoopsSingleTokenHandler::quickCreate('register_finish');
echo _US_USERNAME.": ".$myts->htmlSpecialChars($uname)."
";
echo _US_EMAIL.": ".$myts->htmlSpecialChars($email)."
";
if ($url != '') {
$url = formatURL($url);
echo _US_WEBSITE.': '.$myts->htmlSpecialChars($url).'
';
}
$f_timezone = ($timezone_offset < 0) ? 'GMT '.$timezone_offset : 'GMT +'.$timezone_offset;
echo _US_TIMEZONE.": $f_timezone
";
echo "