summaryrefslogtreecommitdiff
path: root/register.php
blob: 4c7ae105073436328c5665fddc48b7d200a9f3e6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
/**
 * $Header: /cvsroot/bitweaver/_bit_users/register.php,v 1.11 2006/03/01 18:35:20 spiderr Exp $
 *
 * Copyright (c) 2004 bitweaver.org
 * Copyright (c) 2003 tikwiki.org
 * Copyright (c) 2002-2003, Luis Argerich, Garland Foster, Eduardo Polidor, et. al.
 * All Rights Reserved. See copyright.txt for details and a complete list of authors.
 * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details
 *
 * $Id: register.php,v 1.11 2006/03/01 18:35:20 spiderr Exp $
 * @package users
 * @subpackage functions
 */

/**
 * required setup
 */
// Avoid user hell
if( isset( $_REQUEST['tk'] ) ) {
	unset( $_REQUEST['tk'] );
}

require_once( '../bit_setup_inc.php' );
require_once( KERNEL_PKG_PATH.'BitBase.php' );
include_once( KERNEL_PKG_PATH.'notification_lib.php' );

// Permission: needs p_register
$gBitSystem->verifyFeature( 'allow_register' );

if( isset( $_REQUEST["register"] ) ) {
	$reg = $_REQUEST;
	// novalidation is set to yes if a user confirms his email is correct after tiki fails to validate it
	if( $gBitSystem->isFeatureActive( 'rnd_num_reg' ) ) {
		if( (empty( $reg['novalidation'] ) || $reg['novalidation'] != 'yes')
			&& (!isset( $_SESSION['random_number'] ) || $_SESSION['random_number']!=$reg['regcode'])) {
			$errors['rnd_num_reg'] = "Wrong registration code";
		}
	}

	// Check the mode
	if( $gBitSystem->isFeatureActive( 'use_register_passcode' ) ) {
		if( $reg["passcode"] != $gBitSystem->getConfig( "register_passcode",md5( $gBitUser->genPass() ) ) ) {
			$errors['passcode'] = 'Wrong passcode! You need to know the passcode to register at this site';
		}
	}

	if( empty( $errors ) ) {
		$newUser = new BitPermUser();
		if( $newUser->register( $reg ) ) {
			if( $gBitSystem->isFeatureActive( 'validate_user' ) ) {
				$gBitSmarty->assign('msg',tra('You will receive an email with information to login for the first time into this site'));
				$gBitSmarty->assign('showmsg','y');
			} else {
				$url = $newUser->login( $reg['login'], $reg['password'], FALSE, FALSE );
				header( 'Location: '.$url );
				exit;
			}
		} else {
			$gBitSmarty->assign_by_ref( 'errors', $newUser->mErrors );
		}
	} else {
		$gBitSmarty->assign_by_ref( 'errors', $errors );
	}
	$gBitSmarty->assign_by_ref( 'reg', $reg );

} else {
	if( $gBitSystem->isFeatureActive( 'custom_user_fields' ) ) {
		$fields= explode( ',', $gBitSystem->getConfig( 'custom_user_fields' )  );
		trim_array( $fields );
		$gBitSmarty->assign('customFields', $fields);
	}
}

$languages = array();
$languages = $gBitLanguage->listLanguages();
$gBitSmarty->assign_by_ref('languages', $languages);
$gBitSmarty->assign_by_ref('gBitLanguage', $gBitLanguage);

// Get flags here
$flags = array();
$h = opendir( USERS_PKG_PATH.'icons/flags/' );
while ($file = readdir($h)) {
	if (strstr($file, ".gif")) {
		$parts = explode('.', $file);
		$flags[] = $parts[0];
	}
}
closedir ($h);
sort ($flags);
$gBitSmarty->assign('flags', $flags);

$gBitSystem->display('bitpackage:users/register.tpl', 'Register' );

?>