users
[ class tree: users ] [ index: users ] [ all elements ]

Source for file register.php

Documentation is available at register.php

  1. <?php
  2. /**
  3.  * $Header: /cvsroot/bitweaver/_bit_users/register.php,v 1.28 2006/10/12 06:01:50 spiderr Exp $
  4.  *
  5.  * Copyright (c) 2004 bitweaver.org
  6.  * Copyright (c) 2003 tikwiki.org
  7.  * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
  8.  * All Rights Reserved. See copyright.txt for details and a complete list of authors.
  9.  * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
  10.  *
  11.  * $Id: register.php,v 1.28 2006/10/12 06:01:50 spiderr Exp $
  12.  * @package users
  13.  * @subpackage functions
  14.  */
  15.  
  16. /**
  17.  * required setup
  18.  */
  19. // Avoid user hell
  20. ifisset$_REQUEST['tk') ) {
  21.     unset$_REQUEST['tk');
  22. }
  23.  
  24. require_once'../bit_setup_inc.php' );
  25. require_onceKERNEL_PKG_PATH.'BitBase.php' );
  26. include_onceKERNEL_PKG_PATH.'notification_lib.php' );
  27.  
  28. // Permission: needs p_register
  29. $gBitSystem->verifyFeature'users_allow_register' );
  30.  
  31. require_onceUSERS_PKG_PATH.'BaseAuth.php' );
  32.  
  33. if$gBitUser->isRegistered() ) {
  34.     $url $gBitSystem->getDefaultPage();
  35.     header'Location: '.$url );
  36.     exit;
  37. }
  38.  
  39. ifisset$_REQUEST["register") ) {
  40.     $reg $_REQUEST;
  41.     // novalidation is set to yes if a user confirms his email is correct after tiki fails to validate it
  42.     if$gBitSystem->isFeatureActive'users_random_number_reg' ) ) {
  43.         if( ( empty$reg['novalidation'|| $reg['novalidation'!= 'yes' )
  44.             &&!isset$_SESSION['captcha'|| $_SESSION['captcha'!= md5$reg['captcha') ) )
  45.         {
  46.             $errors['captcha'"Wrong registration code";
  47.         }
  48.     }
  49.  
  50.     // Check the mode
  51.     if$gBitSystem->isFeatureActive'users_register_require_passcode' ) ) {
  52.         if$reg["passcode"!= $gBitSystem->getConfig"users_register_passcode",md5$gBitUser->genPass() ) ) ) {
  53.             $errors['passcode''Wrong passcode! You need to know the passcode to register at this site';
  54.         }
  55.     }
  56.     ifempty$errors ) ) {
  57.         $newUser new BitPermUser();
  58.         if$newUser->register$reg ) ) {
  59.             $gBitUser->mUserId $newUser->mUserId;
  60.         
  61.             if !empty$_REQUEST['group') ) {
  62.                 $groupInfo $gBitUser->getGroupInfo$_REQUEST['group');
  63.                 if empty($groupInfo|| $groupInfo['is_public'!= 'y' {
  64.                     $errors["You can't use this group";
  65.                     $gBitSmarty->assign_by_ref'errors'$errors );
  66.                 else {
  67.                     $userId $newUser->getUserId();
  68.                     $gBitUser->addUserToGroup$userId$_REQUEST['group');
  69.                     $gBitUser->storeUserDefaultGroup$userId$_REQUEST['group');
  70.                 }
  71.             }
  72.  
  73.             if$gBitSystem->isFeatureActive'users_validate_user' ) ) {
  74.                 $gBitSmarty->assign('msg',tra('You will receive an email with information to login for the first time into this site'));
  75.                 $gBitSmarty->assign('showmsg','y');
  76.             else {
  77.                 if!empty$_SESSION['loginfrom') ) {
  78.                     unset$_SESSION['loginfrom');
  79.                 }
  80.                 // registration login, fake the cookie so the session gets updated properly.
  81.                 ifempty($_COOKIE[$user_cookie_site) ) {
  82.                     $_COOKIE[$user_cookie_sitesession_id();
  83.                 }
  84.                 $url $newUser->login$reg['login']$reg['password']FALSEFALSE );
  85.                 if !empty$_REQUEST['group'&& !empty$groupInfo['after_registration_page') ) {
  86.                     if $newUser->verifyId$groupInfo['after_registration_page') ) {
  87.                         $url BIT_ROOT_URL."index.php?content_id=".$groupInfo['after_registration_page'];
  88.                     elseifstrpos$groupInfo['after_registration_page']'/' === FALSE {
  89.                         $url BitPage::getDisplayUrl$groupInfo['after_registration_page');
  90.                     else {
  91.                         $url $groupInfo['after_registration_page'];
  92.                     }
  93.                 }
  94.                 header'Location: '.$url );
  95.                 exit;
  96.             }
  97.         else {
  98.             $gBitSmarty->assign_by_ref'errors'$newUser->mErrors );
  99.         }
  100.     else {
  101.         $gBitSmarty->assign_by_ref'errors'$errors );
  102.     }
  103.     $gBitSmarty->assign_by_ref'reg'$reg );
  104.  
  105. else {
  106.     if$gBitSystem->isFeatureActive'custom_user_fields' ) ) {
  107.         $fieldsexplode','$gBitSystem->getConfig'custom_user_fields' )  );
  108.         trim_array$fields );
  109.         $gBitSmarty->assign('customFields'$fields);
  110.     }
  111.     for ($i=0;$i<BaseAuth::getAuthMethodCount();$i++{
  112.         $instance BaseAuth::init($i);
  113.         if ($instance && $instance->canManageAuth()) {
  114.             $auth_reg_fields $instance->getRegistrationFields();
  115.             foreach (array_keys($auth_reg_fieldsas $auth_field{
  116.                 $auth_reg_fields[$auth_field]['value'$auth_reg_fields[$auth_field]['default'];
  117.             }
  118.             $gBitSmarty->assign('auth_reg_fields'$auth_reg_fields);
  119.             break;
  120.         }
  121.     }
  122. }
  123.  
  124. $languages array();
  125. $languages $gBitLanguage->listLanguages();
  126. $gBitSmarty->assign_by_ref('languages'$languages);
  127. $gBitSmarty->assign_by_ref('gBitLanguage'$gBitLanguage);
  128.  
  129. // Get flags here
  130. $flags array();
  131. $h opendirUSERS_PKG_PATH.'icons/flags/' );
  132. while ($file readdir($h)) {
  133.     if (strstr($file".gif")) {
  134.         $parts explode('.'$file);
  135.         $flags[$parts[0];
  136.     }
  137. }
  138. closedir ($h);
  139. sort ($flags);
  140. $gBitSmarty->assign('flags'$flags);
  141.  
  142. $listHash array'is_public'=>'y''sort_mode'=>array('is_default_asc' 'group_desc_asc') );
  143. $groupList $gBitUser->getAllGroups$listHash );
  144. if $groupList['cant'{
  145.     $gBitSmarty->assign_by_ref'groupList'$groupList['data');
  146. }
  147.  
  148. $gBitSystem->display('bitpackage:users/register.tpl''Register' );
  149.  
  150. ?>

Documentation generated on Thu, 15 Feb 2007 20:48:11 +0000 by phpDocumentor 1.3.0