· 9 years ago · May 29, 2017, 02:12 AM
1<?php
2/*
3This script was written by Wizkid.
4All rights reserved. Any support can be requested via RageZone.
5
6You're allowed to edit this script and modify the template.
7However, you are NOT allowed to remove and/or edit my copyright.
8
9Removing this copyright will be your death.
10*/
11
12//Edit to fit YOUR requirements.
13$servername = "LegendGamers";
14$accounttable = "Account";
15$logintable = "Login";
16
17//Edit these variables. If not, no regpage for you. (Or you're fuxpro with the same logins as me.)
18$host = "PETER-C31A91FEC\SQLEXPRESS";
19$user = "SA";
20$pass = "";
21$dbname = "GunzDB";
22
23$connect = odbc_connect("Driver={SQL Server};Server={$host}; Database={$dbname}", $user, $pass) or die("Can't connect the MSSQL server.");
24
25//The well-known antisql injection. Bad enough, it's needed.
26function antisql($sql) {
27$sql = preg_replace(sql_regcase("/(from|select|insert|delete|where|drop table|show tables|#|--|\\\\)/"),"",$sql);
28$sql = trim($sql);
29$sql = strip_tags($sql);
30$sql = addslashes($sql);
31return $sql;
32}
33
34//My favorite function. Get The Fuck Off. (Nothing personally :].)
35function gtfo($wut) {
36echo "<center><table width='500' cellpadding='5' cellspacing='0' border='0' style='border: 1px ;'>
37<tr>
38<td align=center width='100%' style='border-bottom: 1px solid black;'><b>Error</b></td>
39</tr>
40<tr>
41<td width='100%'><center>$wut</center></td>
42</tr>
43</table>";
44die();
45}
46
47//Check email function. This to prevent fake emails. (Remember the time YOU doing that?)
48function checkemail($address) {
49list($local, $host) = explode("@", $address);
50$pattern_local = "^([0-9a-z]*([-|_]?[0-9a-z]+)*)(([-|_]?)\.([-|_]?)[0-9a-z]*([-|_]?[0-9a-z]+)+)*([-|_]?)$";
51$pattern_host = "^([0-9a-z]+([-]?[0-9a-z]+)*)(([-]?)\.([-]?)[0-9a-z]*([-]?[0-9a-z]+)+)*\.[a-z]{2,4}$";
52$match_local = eregi($pattern_local, $local);
53$match_host = eregi($pattern_host, $host);
54if($match_local && $match_host) {
55return 1;
56}
57else {
58return 0;
59}
60}
61
62//The num_rows() function for ODBC since the default one always returns -1.
63function num_rows(&$rid) {
64
65//We can try it at least, right?
66$num= odbc_num_rows($rid);
67if ($num >= 0) {
68return $num;
69}
70
71if (!odbc_fetch_row($rid, 1)) {
72odbc_fetch_row($rid, 0);
73return 0;
74}
75
76if (!odbc_fetch_row($rid, 2)) {
77odbc_fetch_row($rid, 0);
78return 1;
79}
80
81$lo= 2;
82$hi= 8192000;
83
84while ($lo < ($hi - 1)) {
85$mid= (int)(($hi + $lo) / 2);
86if (odbc_fetch_row($rid, $mid)) {
87$lo= $mid;
88} else {
89$hi= $mid;
90}
91}
92$num= $lo;
93odbc_fetch_row($rid, 0);
94return $num;
95}
96?>
97<html>
98<head>
99<title><?=$servername?> Registration</title>
100</head>
101<body>
102<center>
103<?php
104//Oh well. Let's create the variable $ip to start with.
105$ip = antisql($_SERVER['REMOTE_ADDR']);
106
107/*
108An extra feature. This is NOT enabled before you remove this + the comment thingy's.
109
110To ban 1 IP it will be:
111if ($ip == "xxxxxx")
112{
113gtfo("Your IP is blacklisted.");
114}
115
116For multiple IP's, use this way:
117if ($ip == "xxxxxx" OR $ip == "xxxxxx")
118{
119gtfo("Your IP is blacklisted.");
120}
121*/
122
123//Get the AID out of the Login table (defined at the top of this file) where LastIP is the visitors IP.
124$query1 = odbc_exec($connect,"SELECT AID FROM $logintable WHERE LastIP = '$ip'");
125
126//Understable for the real people. Editing this without knowledge will be the death of your regpage.
127$i=1;
128while (odbc_fetch_row($query1, $i)){
129$aid = odbc_result($query1, 'AID');
130
131$query2 = odbc_exec($connect,"SELECT UGradeID FROM $accounttable WHERE AID = '$aid'");
132odbc_fetch_row($query2);
133$ugradeid = odbc_result($query2, 1);
134
135if ($ugradeid == "253")
136{
137//Get the fuck off.
138gtfo("You have one or more accounts banned here. You're not welcome anymore.");
139}
140
141$i++;
142}
143
144//The doreg part.
145if (isset($_GET['act']) AND $_GET['act'] == "doreg")
146{
147
148//Check for any shit.
149if (!is_numeric($_POST['age']) OR !checkemail($_POST['email']) OR empty($_POST['username']) OR empty($_POST['password']) OR empty($_POST['email']) OR empty($_POST['name']) OR empty($_POST['age']))
150{
151gtfo("You're not funny.");
152}
153
154//Check if the username exists already.
155$query1 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE UserID = '" . antisql($_POST['username']) . "'");
156$count1 = num_rows($query1);
157
158if ($count1 >= 1)
159{
160gtfo("Username in use.");
161}
162
163//Check if the Email is in use.
164$query2 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE Email = '" . antisql($_POST['email']) . "'");
165$count2 = num_rows($query2);
166
167if ($count2 >= 1)
168{
169gtfo("Email address in use.");
170}
171
172//Regdate
173$regdate = date("Y-m-d H:i:s");
174
175//Time for the real work. Editing this will be the end of your regpage.
176$query3 = odbc_exec($connect, "INSERT INTO $accounttable (UserID, UGradeID, PGradeID, RegDate, Email, Age, Name) VALUES ('".antisql($_POST['username'])."', '0', '0', '$regdate', '".antisql($_POST['email'])."', '".antisql($_POST['age'])."', '".antisql($_POST['name'])."')");
177
178$query4 = odbc_exec($connect, "SELECT AID FROM $accounttable WHERE UserID = '" . antisql($_POST['username']) . "'");
179odbc_fetch_row($query4);
180$aid = odbc_result($query4, 1);
181
182//If no results comes back. (Registration failed.)
183if (!$aid)
184{
185gtfo("Shit happened. Please report this bug at our forums.");
186}
187
188odbc_exec($connect, "INSERT INTO $logintable (UserID, AID, Password) VALUES ('".antisql($_POST['username'])."', '$aid', '".antisql($_POST['password'])."')");
189
190//When everything is done, show the username/password to the visitor.
191gtfo("Your account has been created.<br><br>
192Username: $_POST[username]<br>
193Password: $_POST[password]<br><br>
194Have fun at $servername!");
195}
196
197//Here the party begins. Feel free to edit this.
198echo "<table width='350'>
199<form action='" . $_SERVER['PHP_SELF'] . "?act=doreg' method='POST'>
200<b>Register an account at $servername.</b><br><br>
201<tr>
202<td width='50%'><b>Username:</b></td>
203<td width='50%'><input type='text' name='username'></td>
204</tr>
205<tr>
206<td width='50%'><b>Password:</b></td>
207<td width='50%'><input type='password' name='password'></td>
208</tr>
209<tr>
210<td width='50%'><b>E-mail:</b></td>
211<td width='50%'><input type='text' name='email'></td>
212</tr>
213<tr>
214<td width='50%'><b>Name:</b></td>
215<td width='50%'><input type='text' name='name'></td>
216</tr>
217<tr>
218<td width='50%'><b>Age:</b></td>
219<td width='50%'><input type='text' name='age'></td>
220</tr>
221<tr>
222<td width='50%'><b></b></td>
223<td width='50%'><input type='submit' value='Register'></td>
224</tr>
225</table>";
226?>
227<br>
228<!-- No you don't remove it. -->
229<font size="1">Copyright 2008 Wizkid - <?=$servername?>.</font>
230<!-- See? -->
231</center>
232</body>
233</html>