forked from modi1231/DIC_Text_Based_Mafia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup.php
62 lines (57 loc) · 1.75 KB
/
setup.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
<?php
include ('connect.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Setup DIC TUT</title>
</head>
<body>
<form id="form1" name="form1" method="post" action="">
<table width="500" border="0" align="center" cellpadding="2" cellspacing="0">
<tr>
<td><h1>Create first Admin. </h1></td>
</tr>
<tr>
<td align="left"><?php
if (isset($_POST['Admin'])) {
if (!empty($_POST['admin_name'])) {
if (!ereg('[^A-Za-z0-9]', $_POST['admin_name'])) {
$sql = "SELECT * FROM users WHERE name ='" . mysql_real_escape_string($_POST['admin_name']) . "'";
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
$name = htmlspecialchars($row -> name);
$count = mysql_num_rows($query);
if ($count == 1) {
$sql = "INSERT INTO sitestats SET id = '1', admins='" . mysql_real_escape_string($name) . "'";
$res = mysql_query($sql);
echo $name . " has been set as first admin.";
} else {
echo "Please create your admin account in the game first.";
}
} else {
echo "Invalid Name only A-Z,a-z and 0-9 is allowed.";
}
} else {
echo "You didn't enter a name to be set as admin.";
}
}
?></td>
</tr>
<tr>
<td><input name="admin_name" type="text" id="admin_name" /></td>
</tr>
<tr>
<td align="left"><input name="Admin" type="submit" id="Admin" value="Create." /></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td align="center"><h1>Delete this file after setup. </h1></td>
</tr>
</table>
</form>
</body>
</html>