| [ Index ] |
PHP Cross Reference of Xoops v2.3.1 |
|
[Global whois Lookup] [Ranchi, Jharkhand, India website] [Hindi Magazine] [Desi Community website in tristate area] [B 4 Bollywood] [Internet nation of India] |
|
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: register.php 2085 2008-09-14 15:43:37Z phppp $ 3 // ------------------------------------------------------------------------ // 4 // XOOPS - PHP Content Management System // 5 // Copyright (c) 2000 XOOPS.org // 6 // <http://www.xoops.org/> // 7 // ------------------------------------------------------------------------ // 8 // This program is free software; you can redistribute it and/or modify // 9 // it under the terms of the GNU General Public License as published by // 10 // the Free Software Foundation; either version 2 of the License, or // 11 // (at your option) any later version. // 12 // // 13 // You may not change or alter any portion of this comment or credits // 14 // of supporting developers from this source code or any supporting // 15 // source code which is considered copyrighted (c) material of the // 16 // original comment or credit authors. // 17 // // 18 // This program is distributed in the hope that it will be useful, // 19 // but WITHOUT ANY WARRANTY; without even the implied warranty of // 20 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // 21 // GNU General Public License for more details. // 22 // // 23 // You should have received a copy of the GNU General Public License // 24 // along with this program; if not, write to the Free Software // 25 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // 26 // ------------------------------------------------------------------------ // 27 28 //$xoopsOption['pagetype'] = 'user'; 29 30 include 'mainfile.php'; 31 $module_handler = xoops_gethandler('module'); 32 $profile_module = $module_handler->getByDirname('profile'); 33 if ($profile_module && $profile_module->getVar('isactive')) { 34 header("location: ./modules/profile/register.php" . (empty($_SERVER['QUERY_STRING']) ? "" : "?" . $_SERVER['QUERY_STRING']) ); 35 exit(); 36 } 37 38 xoops_loadLanguage('user'); 39 xoops_load("userUtility"); 40 41 $myts =& MyTextSanitizer::getInstance(); 42 43 $config_handler =& xoops_gethandler('config'); 44 $xoopsConfigUser = $config_handler->getConfigsByCat(XOOPS_CONF_USER); 45 46 if (empty($xoopsConfigUser['allow_register'])) { 47 redirect_header('index.php', 6, _US_NOREGISTER); 48 exit(); 49 } 50 51 52 function userCheck($uname, $email, $pass, $vpass) 53 { 54 trigger_error("Function " . __FUNCTION__ . " is deprecated, use XoopsUserUtility::validate() instead", E_USER_WARNING); 55 return XoopsUserUtility::validate($uname, $email, $pass, $vpass); 56 } 57 58 $op = isset($_POST['op']) ? $_POST['op'] : ( isset($_GET["op"]) ? $_GET["op"] : 'register' ); 59 $uname = isset($_POST['uname']) ? $myts->stripSlashesGPC($_POST['uname']) : ''; 60 $email = isset($_POST['email']) ? trim($myts->stripSlashesGPC($_POST['email'])) : ''; 61 $url = isset($_POST['url']) ? trim($myts->stripSlashesGPC($_POST['url'])) : ''; 62 $pass = isset($_POST['pass']) ? $myts->stripSlashesGPC($_POST['pass']) : ''; 63 $vpass = isset($_POST['vpass']) ? $myts->stripSlashesGPC($_POST['vpass']) : ''; 64 $timezone_offset = isset($_POST['timezone_offset']) ? intval($_POST['timezone_offset']) : $xoopsConfig['default_TZ']; 65 $user_viewemail = (isset($_POST['user_viewemail']) && intval($_POST['user_viewemail'])) ? 1 : 0; 66 $user_mailok = (isset($_POST['user_mailok']) && intval($_POST['user_mailok'])) ? 1 : 0; 67 $agree_disc = (isset($_POST['agree_disc']) && intval($_POST['agree_disc'])) ? 1 : 0; 68 69 switch ( $op ) { 70 case 'newuser': 71 include 'header.php'; 72 $stop = ''; 73 if (!$GLOBALS['xoopsSecurity']->check()) { 74 $stop .= implode('<br />', $GLOBALS['xoopsSecurity']->getErrors())."<br />"; 75 } 76 if ($xoopsConfigUser['reg_dispdsclmr'] != 0 && $xoopsConfigUser['reg_disclaimer'] != '') { 77 if (empty($agree_disc)) { 78 $stop .= _US_UNEEDAGREE.'<br />'; 79 } 80 } 81 $stop .= XoopsUserUtility::validate($uname, $email, $pass, $vpass); 82 if (empty($stop)) { 83 echo _US_USERNAME.": ".$myts->htmlSpecialChars($uname)."<br />"; 84 echo _US_EMAIL.": ".$myts->htmlSpecialChars($email)."<br />"; 85 if ($url != '') { 86 $url = formatURL($url); 87 echo _US_WEBSITE.': '.$myts->htmlSpecialChars($url).'<br />'; 88 } 89 $f_timezone = ($timezone_offset < 0) ? 'GMT '.$timezone_offset : 'GMT +'.$timezone_offset; 90 echo _US_TIMEZONE.": $f_timezone<br />"; 91 echo "<form action='register.php' method='post'>"; 92 xoops_load("XoopsFormCaptcha"); 93 $cpatcha = new XoopsFormCaptcha(); 94 echo "<br />".$cpatcha->getCaption().": ".$cpatcha->render(); 95 echo " 96 <input type='hidden' name='uname' value='".$myts->htmlSpecialChars($uname)."' /> 97 <input type='hidden' name='email' value='".$myts->htmlSpecialChars($email)."' />"; 98 echo "<input type='hidden' name='user_viewemail' value='".$user_viewemail."' /> 99 <input type='hidden' name='timezone_offset' value='".(float)$timezone_offset."' /> 100 <input type='hidden' name='url' value='".$myts->htmlSpecialChars($url)."' /> 101 <input type='hidden' name='pass' value='".$myts->htmlSpecialChars($pass)."' /> 102 <input type='hidden' name='vpass' value='".$myts->htmlSpecialChars($vpass)."' /> 103 <input type='hidden' name='user_mailok' value='".$user_mailok."' /> 104 <br /><br /><input type='hidden' name='op' value='finish' />".$GLOBALS['xoopsSecurity']->getTokenHTML()."<input type='submit' value='". _US_FINISH ."' /></form>"; 105 } else { 106 echo "<span style='color:#ff0000;'>$stop</span>"; 107 include 'include/registerform.php'; 108 $reg_form->display(); 109 } 110 include 'footer.php'; 111 break; 112 113 case 'finish': 114 include 'header.php'; 115 $stop = XoopsUserUtility::validate($uname, $email, $pass, $vpass); 116 if (!$GLOBALS['xoopsSecurity']->check()) { 117 $stop .= implode('<br />', $GLOBALS['xoopsSecurity']->getErrors()) . "<br />"; 118 } 119 xoops_load("captcha"); 120 $xoopsCaptcha = XoopsCaptcha::getInstance(); 121 if( !$xoopsCaptcha->verify() ) { 122 $stop .= $xoopsCaptcha->getMessage()."<br />"; 123 } 124 if ( empty($stop) ) { 125 $member_handler =& xoops_gethandler('member'); 126 $newuser =& $member_handler->createUser(); 127 $newuser->setVar('user_viewemail',$user_viewemail, true); 128 $newuser->setVar('uname', $uname, true); 129 $newuser->setVar('email', $email, true); 130 if ($url != '') { 131 $newuser->setVar('url', formatURL($url), true); 132 } 133 $newuser->setVar('user_avatar','blank.gif', true); 134 $actkey = substr(md5(uniqid(mt_rand(), 1)), 0, 8); 135 $newuser->setVar('actkey', $actkey, true); 136 $newuser->setVar('pass', md5($pass), true); 137 $newuser->setVar('timezone_offset', $timezone_offset, true); 138 $newuser->setVar('user_regdate', time(), true); 139 $newuser->setVar('uorder',$xoopsConfig['com_order'], true); 140 $newuser->setVar('umode',$xoopsConfig['com_mode'], true); 141 $newuser->setVar('user_mailok',$user_mailok, true); 142 if ($xoopsConfigUser['activation_type'] == 1) { 143 $newuser->setVar('level', 1, true); 144 } else { 145 $newuser->setVar('level', 0, true); 146 } 147 if (!$member_handler->insertUser($newuser)) { 148 echo _US_REGISTERNG; 149 include 'footer.php'; 150 exit(); 151 } 152 $newid = $newuser->getVar('uid'); 153 if (!$member_handler->addUserToGroup(XOOPS_GROUP_USERS, $newid)) { 154 echo _US_REGISTERNG; 155 include 'footer.php'; 156 exit(); 157 } 158 if ($xoopsConfigUser['activation_type'] == 1) { 159 XoopsUserUtility::sendWelcome($newuser); 160 redirect_header('index.php', 4, _US_ACTLOGIN); 161 exit(); 162 } 163 // Sending notification email to user for self activation 164 if ($xoopsConfigUser['activation_type'] == 0) { 165 $xoopsMailer =& xoops_getMailer(); 166 $xoopsMailer->useMail(); 167 $xoopsMailer->setTemplate('register.tpl'); 168 $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); 169 $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); 170 $xoopsMailer->assign('SITEURL', XOOPS_URL."/"); 171 $xoopsMailer->setToUsers(new XoopsUser($newid)); 172 $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); 173 $xoopsMailer->setFromName($xoopsConfig['sitename']); 174 $xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $uname)); 175 if ( !$xoopsMailer->send() ) { 176 echo _US_YOURREGMAILNG; 177 } else { 178 echo _US_YOURREGISTERED; 179 } 180 // Sending notification email to administrator for activation 181 } elseif ($xoopsConfigUser['activation_type'] == 2) { 182 $xoopsMailer =& xoops_getMailer(); 183 $xoopsMailer->useMail(); 184 $xoopsMailer->setTemplate('adminactivate.tpl'); 185 $xoopsMailer->assign('USERNAME', $uname); 186 $xoopsMailer->assign('USEREMAIL', $email); 187 $xoopsMailer->assign('USERACTLINK', XOOPS_URL.'/register.php?op=actv&id='.$newid.'&actkey='.$actkey); 188 $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); 189 $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); 190 $xoopsMailer->assign('SITEURL', XOOPS_URL."/"); 191 $member_handler =& xoops_gethandler('member'); 192 $xoopsMailer->setToGroups($member_handler->getGroup($xoopsConfigUser['activation_group'])); 193 $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); 194 $xoopsMailer->setFromName($xoopsConfig['sitename']); 195 $xoopsMailer->setSubject(sprintf(_US_USERKEYFOR, $uname)); 196 if ( !$xoopsMailer->send() ) { 197 echo _US_YOURREGMAILNG; 198 } else { 199 echo _US_YOURREGISTERED2; 200 } 201 } 202 if ($xoopsConfigUser['new_user_notify'] == 1 && !empty($xoopsConfigUser['new_user_notify_group'])) { 203 $xoopsMailer =& xoops_getMailer(); 204 $xoopsMailer->useMail(); 205 $member_handler =& xoops_gethandler('member'); 206 $xoopsMailer->setToGroups($member_handler->getGroup($xoopsConfigUser['new_user_notify_group'])); 207 $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); 208 $xoopsMailer->setFromName($xoopsConfig['sitename']); 209 $xoopsMailer->setSubject(sprintf(_US_NEWUSERREGAT,$xoopsConfig['sitename'])); 210 $xoopsMailer->setBody(sprintf(_US_HASJUSTREG, $uname)); 211 $xoopsMailer->send(); 212 } 213 } else { 214 echo "<span style='color:#ff0000; font-weight:bold;'>$stop</span>"; 215 include 'include/registerform.php'; 216 $reg_form->display(); 217 } 218 include 'footer.php'; 219 break; 220 221 case 'actv': 222 case 'activate': 223 $id = intval($_GET['id']); 224 $actkey = trim($_GET['actkey']); 225 if (empty($id)) { 226 redirect_header('index.php', 1, ''); 227 exit(); 228 } 229 $member_handler =& xoops_gethandler('member'); 230 $thisuser =& $member_handler->getUser($id); 231 if (!is_object($thisuser)) { 232 exit(); 233 } 234 if ($thisuser->getVar('actkey') != $actkey) { 235 redirect_header('index.php', 5, _US_ACTKEYNOT); 236 } else { 237 if ($thisuser->getVar('level') > 0 ) { 238 redirect_header( 'user.php', 5, _US_ACONTACT, false ); 239 } else { 240 if (false != $member_handler->activateUser($thisuser)) { 241 $config_handler =& xoops_gethandler('config'); 242 $xoopsConfigUser = $config_handler->getConfigsByCat(XOOPS_CONF_USER); 243 if ($xoopsConfigUser['activation_type'] == 2) { 244 $myts =& MyTextSanitizer::getInstance(); 245 $xoopsMailer =& xoops_getMailer(); 246 $xoopsMailer->useMail(); 247 $xoopsMailer->setTemplate('activated.tpl'); 248 $xoopsMailer->assign('SITENAME', $xoopsConfig['sitename']); 249 $xoopsMailer->assign('ADMINMAIL', $xoopsConfig['adminmail']); 250 $xoopsMailer->assign('SITEURL', XOOPS_URL."/"); 251 $xoopsMailer->setToUsers($thisuser); 252 $xoopsMailer->setFromEmail($xoopsConfig['adminmail']); 253 $xoopsMailer->setFromName($xoopsConfig['sitename']); 254 $xoopsMailer->setSubject(sprintf(_US_YOURACCOUNT,$xoopsConfig['sitename'])); 255 include 'header.php'; 256 if ( !$xoopsMailer->send() ) { 257 printf(_US_ACTVMAILNG, $thisuser->getVar('uname')); 258 } else { 259 printf(_US_ACTVMAILOK, $thisuser->getVar('uname')); 260 } 261 include 'footer.php'; 262 } else { 263 redirect_header( 'user.php', 5, _US_ACTLOGIN, false ); 264 } 265 } else { 266 redirect_header('index.php',5,'Activation failed!'); 267 } 268 } 269 } 270 break; 271 272 case 'register': 273 default: 274 include 'header.php'; 275 include 'include/registerform.php'; 276 $reg_form->display(); 277 include 'footer.php'; 278 break; 279 } 280 ?>
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
|
[ Xoops] [PhpNuke] [PostNuke] [Joomla] [Drupal] [E107] [NucleusCms] |
|||
|
[Php-Fusion] [PhpBB] [WordPress] [Typo3] |
|||
| Generated: Mon Oct 27 11:51:45 2008 | |||