-
Notifications
You must be signed in to change notification settings - Fork 0
/
register.php
191 lines (163 loc) · 6.74 KB
/
register.php
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<?php
/**
* Pos-Tracker2
*
* Pos-Tracker register page
*
* PHP version 5
*
* LICENSE: This file is part of POS-Tracker2.
* POS-Tracker2 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, version 3 of the License.
*
* POS-Tracker2 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 POS-Tracker2. If not, see <http://www.gnu.org/licenses/>.
*
* @author Stephen Gulickk <stephenmg12@gmail.com>
* @author DeTox MinRohim <eve@onewayweb.com>
* @author Andy Snowden <forumadmin@eve-razor.com>
* @copyright 2007-2009 (C) Stephen Gulick, DeTox MinRohim, and Andy Snowden
* @license http://www.gnu.org/licenses/gpl-3.0.html GPL 3.0
* @package POS-Tracker2
* @version SVN: $Id: register.php 219 2011-11-19 08:05:39Z frozenice2525 $
* @link https://sourceforge.net/projects/pos-tracker2/
* @link http://www.eve-online.com/
*/
if (isset($_REQUEST['viewSource'])) {
highlight_file(__FILE__);
exit();
};
include_once 'includes/dbfunctions.php';
EveDBInit();
include_once 'includes/eveclass.php';
include_once 'includes/class.pos.php';
include_once 'includes/eveRender.class.php';
include_once 'eveconfig/config.php';
$eveRender = New eveRender($config, $mod, false);
$colors = $eveRender->themeconfig;
$pID = 'register';
$eveRender->Assign('pID', $pID);
$eveRender->Assign('config', $config);
$eve = New Eve();
$posmgmt = New POSMGMT();
$userinfo = $eve->GetUserVars();
$action = $eve->VarCleanFromInput('action');
$api_userid = $eve->VarCleanFromInput('api_userid');
$api_key = $eve->VarCleanFromInput('api_key');
if ($action == 'getchars') {
if (empty($api_key) || empty($api_userid)) {
$eve->SessionSetVar('errormsg', 'Missing API Information!');
$eve->RedirectUrl('register.php');
}
$characters = $posmgmt->API_GetCharacters($api_userid, $api_key);
if (!$characters) {
$eve->SessionSetVar('errormsg', 'API ERROR or No Character on provided API Information!');
$eve->RedirectUrl('register.php');
}
foreach($characters as $key => $char) {
$apicorp = $posmgmt->API_GetCorpInfo($char['corporationID']);
$characters[$key]['alliance'] = $apicorp;
}
//echo '<pre>';print_r($characters);echo '</pre>';exit;
$eveRender->Assign('action', $action);
$eveRender->Assign('api_userid', $api_userid);
$eveRender->Assign('api_key', $api_key);
$eveRender->Assign('characters', $characters);
$eveRender->Display('register.tpl');
exit;
} else if ($action == 'getuserinfo') {
$charname = $eve->VarCleanFromInput('charname');
$characterID = $eve->VarCleanFromInput('characterID');
$corporationName = $eve->VarCleanFromInput('corporationName');
$corporationID = $eve->VarCleanFromInput('corporationID');
$allianceName = $eve->VarCleanFromInput('allianceName');
$allianceID = $eve->VarCleanFromInput('allianceID');
$eveRender->Assign('action', $action);
$eveRender->Assign('api_userid', $api_userid);
$eveRender->Assign('api_key', $api_key);
$eveRender->Assign('charname', $charname);
$eveRender->Assign('characterID', $characterID);
$eveRender->Assign('corporationName', $corporationName);
$eveRender->Assign('corporationID', $corporationID);
$eveRender->Assign('allianceName', $allianceName);
$eveRender->Assign('allianceID', $allianceID);
$eveRender->Display('register.tpl');
exit;
} else if ($action == 'saveaccount') {
$charname = $eve->VarCleanFromInput('charname');
$characterID = $eve->VarCleanFromInput('characterID');
$corporationName = $eve->VarCleanFromInput('corporationName');
$corporationID = $eve->VarCleanFromInput('corporationID');
$allianceName = $eve->VarCleanFromInput('allianceName');
$allianceID = $eve->VarCleanFromInput('allianceID');
$email = $eve->VarCleanFromInput('email');
$pass = $eve->VarCleanFromInput('pass');
$pass2 = $eve->VarCleanFromInput('pass2');
$eveRender->Assign('api_userid', $api_userid);
$eveRender->Assign('api_key', $api_key);
$eveRender->Assign('charname', $charname);
$eveRender->Assign('characterID', $characterID);
$eveRender->Assign('corporationName', $corporationName);
$eveRender->Assign('corporationID', $corporationID);
$eveRender->Assign('allianceName', $allianceName);
$eveRender->Assign('allianceID', $allianceID);
$eveRender->Assign('email', $email);
if (empty($pass) || empty($pass2) || empty($email)) {
$eve->SessionSetVar('errormsg', 'Fill all the fields smartass!');
$eveRender->Assign('action', 'getuserinfo');
$eveRender->Display('register.tpl');
exit;
}
if ($pass != $pass2) {
$eve-SessionSetVar('errormsg', 'Password missmatch, you need to redo it!');
$eveRender->Assign('action', 'getuserinfo');
$eveRender->Display('register.tpl');
exit;
}
if ( $allianceID = 0 || empty($allianceName) ) {
unset($allianceID);
unset($allianceName);
};
$time = time();
//Password Hash
$password = $posmgmt->newpasswordhash($pass); //New Password hashing method
// Is a User with the same characterID already registered?
$sql = "SELECT * FROM ".TBL_PREFIX."user WHERE eve_id = ".$characterID;
$result = mysql_query($sql) or die('Could not look for already existing User;' . mysql_error());
if (mysql_num_rows($result) != 0) {
// Update Userinfo
$sql = "UPDATE ".TBL_PREFIX."user
SET name = '" . $eve->VarPrepForStore($charname) . "',
pass = '" . $eve->VarPrepForStore($password) . "',
corp = '" . $eve->VarPrepForStore($corporationName) . "',
email= '" . $eve->VarPrepForStore($email) . "',
alliance_id = '" . $eve->VarPrepForStore($allianceID) . "',
datetime = '" . $time . "'
WHERE eve_id = ".$characterID;
$result = mysql_query($sql) or die('Could not update user;' . mysql_error());
$eve->SessionSetVar('errormsg', 'You are already registered! updating Userinfo for '.$charname.'!');
$eve->RedirectUrl('login.php');
}
// Create new User.
$sql = "INSERT INTO ".TBL_PREFIX."user (`eve_id`, `name`, `pass`, `corp`, `alliance_id`, `email`, `access`, `datetime`)
VALUES (
'" . $eve->VarPrepForStore($characterID) . "',
'" . $eve->VarPrepForStore($charname) . "',
'" . $eve->VarPrepForStore($password) . "',
'" . $eve->VarPrepForStore($corporationName) . "',
'" . $eve->VarPrepForStore($allianceID) . "',
'" . $eve->VarPrepForStore($email) . "',
0,
'" . $time . "')";
$result = mysql_query($sql) or die('Could not create user;' . mysql_error());
$eve->SessionSetVar('statusmsg', 'User Created - Welcome '.$charname);
$eve->RedirectUrl('login.php');
}
$eveRender->Display('register.tpl');
?>