1
<?php
2
/**
3
 *   File functions:
4
 *   Register new players
5
 *
6
 *   @name                 : register.php                            
7
 *   @copyright            : (C) 2005,2006 Vallheru Team based on Gamers-Fusion ver 2.5
8
 *   @author               : thindil <thindil@users.sourceforge.net>
9
 *   @version              : 1.2
10
 *   @since                : 14.07.2006
11
 *
12
 */
13
14
//
15
//
16
//       This program is free software; you can redistribute it and/or modify
17
//   it under the terms of the GNU General Public License as published by
18
//   the Free Software Foundation; either version 2 of the License, or
19
//   (at your option) any later version.
20
//
21
//   This program is distributed in the hope that it will be useful,
22
//   but WITHOUT ANY WARRANTY; without even the implied warranty of
23
//   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
//   GNU General Public License for more details.
25
//
26
//   You should have received a copy of the GNU General Public License
27
//   along with this program; if not, write to the Free Software
28
//   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
29
//
30
// $Id: register.php 479 2006-07-14 18:57:16Z thindil $
31
32
require_once ('includes/main/base.php');
33
require_once ('includes/sessions.php');
34
require_once ('includes/getlang.php');
35
GetLang ();
36
GetLoc ('mainpage');
37
GetLoc ('register');
38
39
RegistrationCloseRoutine ();
40
41
42
require_once ('includes/main/online.php');
43
require_once ('includes/main/record.php');
44
require_once ('includes/main/counter.php');
45
require_once ('includes/main/usersever.php');
46
47
require_once ('includes/right.php');
48
49
$smarty -> assign(array("Pagetitle" => REGISTER));
50
51
if (!isset($_GET['action']))
52
{
53
    $chars = 'acefghijkmrstvwxyz1234578';
54
    $charcount = strlen($chars) - 1;
55
    $code = '';
56
    for ($i=0;$i<10;$i++)
57
    {
58
        $code .= $chars[rand(0,$charcount)];
59
    }
60
    $_SESSION['imagecode'] = $code;
61
    $smarty -> assign(array("Lang" => $arrLanguage));
62
}
63
64
if (isset ($_GET['action']) && $_GET['action'] == 'register') 
65
{
66
/**
67
* Check imagecode
68
*/
69
    if (!isset($_SESSION['imagecode']) || !isset($_POST['imagecode']) || $_POST['imagecode'] != $_SESSION['imagecode']) 
70
    {
71
        $smarty -> assign ("Error", ERROR_IMAGECODE.RET);
72
        $smarty -> display ('error.tpl');
73
        exit;
74
    }
75
    unset($_SESSION['imagecode']);
76
77
/**
78
* Check for empty fields
79
*/
80
    if (!$_POST['user'] || !$_POST['email'] || !$_POST['vemail'] || !$_POST['pass'] ) 
81
    {
82
        $smarty -> assign ("Error", EMPTY_FIELDS);
83
        $smarty -> display ('error.tpl');
84
        exit;
85
    }
86
    
87
/**
88
* Email adress validation
89
*/       
90
    require_once('includes/verifymail.php');
91
    if (MailVal($_POST['email'], 2)) 
92
    {
93
        $smarty -> assign ("Error", BAD_EMAIL);
94
        $smarty -> display ('error.tpl');
95
        exit;
96
    }
97
    require_once('includes/verifypass.php');
98
    verifypass($_POST['pass'],'register');
99
100
/**
101
* Check nick
102
*/
103
	if (strlen($_POST['user']) > 15)
104
	{
105
        $smarty -> assign ("Error", LONG_NICK);
106
        $smarty -> display ('error.tpl');
107
        exit;
108
	}
109
110
    $strUser = $db -> qstr($_POST['user'], get_magic_quotes_gpc());
111
    $query = $db -> Execute("SELECT id FROM players WHERE user=".$strUser);
112
    $dupe1 = $query -> RecordCount();
113
    $query -> Close();  
114
    if ($dupe1 > 0) 
115
    {
116
        $smarty -> assign ("Error", BAD_NICK);
117
        $smarty -> display ('error.tpl');
118
        exit;
119
    }
120
121
	require_once ('includes/limits.php');
122
	if (!ValidNick (stripslashes ($_POST['user']))) {
123
		$smarty->assign ('Error', INVALID_NICK);
124
		$smarty->display ('error.tpl');
125
		exit;
126
	}
127
128
/**
129
* Check mail adress in database
130
*/   
131
  
132
   $strEmail = $db -> qstr($_POST['email'], get_magic_quotes_gpc());
133
   $query = $db -> Execute("SELECT id FROM players WHERE email=".$strEmail);
134
   $dupe2 = $query -> RecordCount();
135
   $query -> Close();
136
137
138
    $NumberActSameMail = 0;
139
    $ListActSameMail = $db->Execute ("SELECT id FROM aktywacja WHERE email=".$strEmail);
140
    if (!empty($ListActSameMail))
141
	{
142
    	$NumberActSameMail = $ListActSameMail -> RecordCount();
143
        $ListActSameMail -> Close();
144
	}
145
146
147
   if ($dupe2 > 0 or $NumberActSameMail > 0)
148
   {
149
       $smarty -> assign ("Error", EMAIL_HAVE);
150
       $smarty -> display ('error.tpl');
151
       exit;
152
   }
153
154
/**
155
* Check email adress writed on registration
156
*/ 
157
    if ($_POST['email'] != $_POST['vemail']) 
158
    {
159
        $smarty -> assign ("Error", EMAIL_MISS);
160
        $smarty -> display ('error.tpl');
161
        exit;
162
    }
163
    
164
    $_POST['lang'] = strip_tags($_POST['lang']);
165
    if (!in_array($_POST['lang'], $arrLanguage))
166
    {
167
        exit;
168
    }
169
    $_POST['user'] = strip_tags($_POST['user']);
170
    $strUser = $db -> qstr($_POST['user'], get_magic_quotes_gpc());
171
    $_POST['email'] = strip_tags($_POST['email']);
172
    $strEmail = $db -> qstr($_POST['email'], get_magic_quotes_gpc());
173
    $_POST['pass'] = strip_tags($_POST['pass']);
174
    $aktw = rand(1,10000000);
175
    $data = date("y-m-d");
176
    $strDate = $db -> DBDate($data);
177
    $ip = $HTTP_SERVER_VARS['REMOTE_ADDR'];
178
    $message = WELCOME_TO." ".$gamename.YOUR_LINK."  ".$gameadress.ACTIV_LINK.$aktw.NICE_PLAYING." ".$gamename.". ".$adminname;
179
    $adress = $_POST['email'];
180
    $subject = SUBJECT." ".$gamename;
181
    require_once('mailer/mailerconfig.php');
182
    if (!$mail -> Send()) 
183
    {
184
        $smarty -> assign("Error", EMAIL_ERROR.$mail -> ErrorInfo);
185
        $smarty -> display('error.tpl');
186
        exit;
187
    }
188
    $strPass = MD5($_POST['pass']);
189
    $db -> Execute("INSERT INTO aktywacja (user, email, pass, aktyw, data, ip, lang) VALUES(".$strUser.", ".$strEmail.", '".$strPass."', ".$aktw.", ".$strDate." , '".$ip."' ,'".$_POST['lang']."')") or die($db -> ErrorMsg());
190
191
    /**
192
    * Players they`ve ever been registered there
193
    */ 
194
    include("counter/usersever.php");
195
    $plik=fopen("counter/usersever.php","w+");
196
    fputs($plik,'<?php $ilosc='.(++$ilosc).' ?>');
197
    fclose($plik);
198
}
199
200
/**
201
* Initialization of variable
202
*/
203
if (!isset($_GET['action'])) 
204
{
205
    $_GET['action'] = '';
206
}
207
208
/**
209
* Assign variables and display page
210
*/
211
$smarty -> assign(array("Action" => $_GET['action'], "Meta" => ''));
212
$smarty -> display('register.tpl');
213
214
$db -> Close();
215
?>