-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstall.php
executable file
·196 lines (143 loc) · 4.34 KB
/
install.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
192
193
194
195
196
<?php
/* Uncommentthe next line to stop this file from beign used */
//die('Game already installed');
define("INSIDE",true);
function ReadFromFile($filename) {
$content = @file_get_contents ($filename);
return $content;
}
//If the game in installed, and they haven't removed the install dir, try and give them some protection
$info = file('./status');
if(substr($info[0],0,9) == "INSTALLED"){
header("Location: index.php");
die();
}
switch(@$_GET['page']){
case "2":
//Sort out config.php
//Load page
$page = ReadFromFile ('./install/page2.html');
//Output
echo $page;
break;
case "3":
//Sort out database
//Load page
$page = ReadFromFile ('./install/page3.html');
//Output
echo $page;
break;
case "4":
//Sort out admin acount
//Load page
$page = ReadFromFile ('./install/page4.html');
//Output
echo $page;
break;
case "5":
//Sort out admin acount
//Load page
$page = ReadFromFile ('./install/page5.html');
//Output
echo $page;
break;
//Special pages
case "checkconnection":
//Check the database connections
//Get variables
$server = $_GET['server'];
$name = $_GET['name'];
$user = $_GET['user'];
$pass = $_GET['pass'];
//Test connection
@mysql_connect($server, $user, $pass) or die('1');
//Try to make database
@mysql_query('CREATE DATABASE IF NOT EXISTS '.$name);
//Test database
@mysql_select_db($name) or die('3');
//Write to file
$file = '<?php
if(!defined("INSIDE")){ die("attemp hacking"); }
$dbsettings = Array(
"server" => "'.$server.'", // MySQL server name.
"user" => "'.$user.'", // MySQL username.
"pass" => "'.$pass.'", // MySQL password.
"name" => "'.$name.'", // MySQL database name.
"prefix" => "{{~databaseprefix~}}", // Tables prefix.
"secretword" => "{{~cookiename~}}", // Cookies.
"type" => "mysql"); // Database type
?>';
$handle = @fopen("./game/config1.php", 'w') or die("2");
fwrite($handle, $file);
fclose($handle);
die('0');
break;
case "importdatabase":
//Check the database connections
//Get variables
include('./game/config1.php');
$cookies = $_GET['cookies'];
$prefix = $_GET['prefix'];
//Connect
@mysql_connect($dbsettings['server'], $dbsettings['user'], $dbsettings['pass']) or die('1');
//Select database
@mysql_select_db($dbsettings['name']) or die('2');
//Now update database
$sql = @file('./install/database.sql');
//Remove comments and blank lines
foreach($sql as $k => $line){
if (substr($line,0,2) == '--' || $line == "\n" || $line == "\r\n" || $line == "\r"){
$sql[$k] = '';
}
}
$sql = implode('',$sql);
//Check size
if(strlen($sql) < 25){ die('4'); }
//Do some replaces
$sql = str_replace("\r\n","\n",$sql);
$sql = str_replace("{{prefix}}",$prefix,$sql);
$sql = str_replace("{{cookies}}",$cookies,$sql);
//Log
$handle = @fopen("./install/sql.log", 'w');
@fwrite($handle, $sql);
@fclose($handle);
//Sepparate statements
$q = explode(";\n", $sql);
unset($q[sizeof($q) - 1]);
//Update database
foreach ($q as $query){
mysql_query($query) or die('5-'.mysql_error());
}
//Update the config1.php file
$config = ReadFromFile('./game/config1.php');
//Update config
$config = str_replace("{{~databaseprefix~}}",$prefix,$config);
$config = str_replace("{{~cookiename~}}",$cookies,$config);
//Write to file
$handle = @fopen("./game/config1.php", 'w') or die("3");
fwrite($handle, $config);
fclose($handle);
//Update status
$handle = @fopen('./status', 'w') or die("6");
fwrite($handle, 'INSTALLED');
fclose($handle);
die('0');
break;
case "paysys_setup":
//Open the config file
$config = @file("./game/SETUP.PHP") or die('1');
$config[35] = "define('PAYSYSTEM_PUBLIC'\t, '".$_GET['public']."');\n";
$config[36] = "define('PAYSYSTEM_PRIVATE'\t, '".$_GET['private']."');\n";
$config = implode('',$config);
//Edit file
$handle = @fopen("./game/SETUP.PHP", 'w') or die('X');
fwrite($handle, $config) or die('2');
fclose($handle);
die('0');
break;
default:
//Welcome
include('./install/page1.html');
break;
}
?>