This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | set_time_limit(0); |
||
3 | ini_set('memory_limit','512M'); |
||
4 | //header('Content-Encoding: none;'); |
||
5 | header('X-Accel-Buffering: no'); |
||
6 | |||
7 | // Does config exist? |
||
8 | $exists = file_exists($dir . "/../config.php"); |
||
9 | if($exists) |
||
10 | die("Sorry, you cannot install a board that already has a config setup"); |
||
11 | |||
12 | ob_implicit_flush(true); |
||
13 | ob_end_flush(); |
||
14 | |||
15 | output('<!doctype html><html><head><title>zKillboard Installer</title><meta name="viewport" content="width=device-width"><link rel="stylesheet" href="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"/> |
||
16 | <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.3/jquery.min.js" type="text/javascript"></script> |
||
17 | <script src="https://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js" type="text/javascript"></script> |
||
18 | <script type="text/javascript">$(function () { $("[rel=\'tooltip\']").tooltip({placement:"left"});});</script> |
||
19 | <script type="text/javascript">$("#container").animate({ scrollTop: $("#container")[0].scrollHeight}, 1000);</script> |
||
20 | <style>body{margin:40px;}.stepwizard-step p {margin-top: 10px;}.stepwizard-row {display: table-row;}.stepwizard {display: table;width: 100%;position: relative;} |
||
21 | .stepwizard-step button[disabled] {opacity: 1 !important;filter: alpha(opacity=100) !important;}.stepwizard-row:before {top: 14px;bottom: 0;position: absolute; |
||
22 | content: " ";width: 100%;height: 1px;background-color: #ccc;z-order: 0;}.stepwizard-step {display: table-cell;text-align: center;position: relative;} |
||
23 | .btn-circle {width: 30px;height: 30px;text-align: center;padding: 6px 0;font-size: 12px;line-height: 1.428571429;border-radius: 15px;}</style></head> |
||
24 | <body><div class="container"><div class="stepwizard"><div class="stepwizard-row"><div class="stepwizard-step"> |
||
25 | <button type="button" class="btn btn-default btn-circle">1</button><p>Initialization</p></div><div class="stepwizard-step"> |
||
26 | <button type="button" class="btn btn-default btn-circle">2</button><p>Information</p></div><div class="stepwizard-step"> |
||
27 | <button type="button" class="btn btn-primary btn-circle">3</button><p>Installation</p></div><div class="stepwizard-step"> |
||
28 | <button type="button" class="btn btn-default btn-circle">4</button><p>Finalization</p></div></div></div><div class="row setup-content" id="step-3">'); |
||
29 | |||
30 | |||
31 | if($_POST) |
||
32 | { |
||
33 | $settings = array(); |
||
34 | $settings["dbuser"] = post("databaseusername"); |
||
35 | $settings["dbpassword"] = post("databasepassword"); |
||
36 | $settings["dbname"] = post("databasename"); |
||
37 | $settings["dbhost"] = post("databasehost"); |
||
38 | $settings["memcache"] = post("memcachehost"); |
||
39 | $settings["memcacheport"] = post("memcacheport"); |
||
40 | $settings["redis"] = post("redishost"); |
||
41 | $settings["redisport"] = post("redisport"); |
||
42 | $settings["phealcachelocation"] = post("phealcache"); |
||
43 | $settings["baseaddr"] = post("domainname"); |
||
44 | $settings["logfile"] = post("logfile"); |
||
45 | $settings["imageserver"] = post("imageserver"); |
||
46 | $settings["apiserver"] = post("apiserver"); |
||
47 | $settings["cookiesecret"] = post("cookiesecret"); |
||
48 | $adminPassword = post("adminpassword"); |
||
49 | |||
50 | output('<div class="col-xs-12"><div class="col-md-12"><h2>If any part errors, hover over the icon to get full information.</h2><table class="table table-striped"><thead><tr><td></td><td class="col-lg-1"></td></tr></thead><tbody><tr><td>Testing the database connection.</td>'); |
||
51 | |||
52 | $dbSuccess = true; |
||
53 | $reason = ""; |
||
54 | // Test out the db params first.. |
||
55 | $dbname = $settings["dbname"]; |
||
56 | $dbhost = $settings["dbhost"]; |
||
57 | $dsn = "mysql:dbname=" . $settings["dbname"] . ";host=" . $settings["dbhost"]; |
||
58 | try |
||
59 | { |
||
60 | $pdo = new PDO($dsn, $settings["dbuser"], $settings["dbpassword"], array( |
||
61 | PDO::ATTR_TIMEOUT => 10, |
||
62 | PDO::ATTR_EMULATE_PREPARES => false, |
||
63 | PDO::ATTR_PERSISTENT => false, |
||
64 | PDO::MYSQL_ATTR_USE_BUFFERED_QUERY => false |
||
65 | ) |
||
66 | ); |
||
67 | } |
||
68 | catch(Exception $e) |
||
69 | { |
||
70 | $dbSuccess = false; |
||
71 | $reason = $e->getMessage(); |
||
72 | } |
||
73 | |||
74 | if($dbSuccess == false) |
||
0 ignored issues
–
show
|
|||
75 | { |
||
76 | output('<td><button type="button" class="btn btn-danger btn-circle" rel="tooltip" title="'.$reason.'"><i class="glyphicon glyphicon-warning-sign"></i></button></td></tr>'); |
||
77 | die(); |
||
78 | } |
||
79 | else |
||
80 | output('<td><button type="button" class="btn btn-primary btn-circle"><i class="glyphicon glyphicon-ok"></i></button></td></tr>'); |
||
81 | |||
82 | $configCreate = true; |
||
83 | output('</tr><tr><td>Creating the config file</td>'); |
||
84 | |||
85 | // Get default config |
||
86 | $configFile = file_get_contents(__DIR__."/../config.new.php"); |
||
87 | |||
88 | // Replace in the config |
||
89 | foreach($settings as $key => $value) |
||
90 | $configFile = str_replace("%$key%", $value, $configFile); |
||
91 | |||
92 | // Save the config, and try and load it |
||
93 | $configLocation = __DIR__."/../../config.php"; |
||
94 | if(file_put_contents($configLocation, $configFile) === false) |
||
95 | { |
||
96 | $configCreate = false; |
||
97 | $reason = "Error placing the config file. Most likely a write issue."; |
||
98 | } |
||
99 | |||
100 | if($configCreate == false) |
||
0 ignored issues
–
show
|
|||
101 | { |
||
102 | output('<td><button type="button" class="btn btn-danger btn-circle" rel="tooltip" title="'.$reason.'"><i class="glyphicon glyphicon-warning-sign"></i></button></td></tr>'); |
||
103 | die(); |
||
104 | } |
||
105 | else |
||
106 | output('<td><button type="button" class="btn btn-primary btn-circle"><i class="glyphicon glyphicon-ok"></i></button></td></tr>'); |
||
107 | |||
108 | output('</tr><tr><td>Downloading composer</td>'); |
||
109 | |||
110 | // Lets install composer |
||
111 | chdir(__DIR__."/../../"); |
||
112 | exec("php -r \"eval('?>'.file_get_contents('https://getcomposer.org/installer'));\""); |
||
113 | output('<td><button type="button" class="btn btn-primary btn-circle"><i class="glyphicon glyphicon-ok"></i></button></td></tr>'); |
||
114 | |||
115 | output('</tr><tr><td>Installing vendor files</td>'); |
||
116 | chdir(__DIR__."/../../"); |
||
117 | exec("php composer.phar install --optimize-autoloader"); |
||
118 | output('<td><button type="button" class="btn btn-primary btn-circle"><i class="glyphicon glyphicon-ok"></i></button></td></tr>'); |
||
119 | |||
120 | // Vendor is installed, config works, lets load the init! |
||
121 | require_once("$dir/../init.php"); |
||
122 | |||
123 | // Time to import the database ! |
||
124 | output('</tr><tr><td>Installing the database tables</td><td></td></tr>'); |
||
125 | $sqlFiles = scandir(__DIR__."/../../install/sql/"); // Load the SQL files from the old installer dir for now |
||
126 | foreach($sqlFiles as $file) |
||
127 | { |
||
128 | if($file == "." || $file == "..") |
||
129 | continue; |
||
130 | |||
131 | if(stristr($file, ".sql")) |
||
132 | { |
||
133 | $table = str_replace(".sql", "", $file); |
||
134 | $table = str_replace(".gz", "", $table); |
||
135 | $sqlFile = __DIR__."/../../install/sql/$file"; |
||
136 | output('<tr><td>Adding table: <b>'.$table.'</b></td>'); |
||
137 | output('<td>'. loadFile($sqlFile) .'</td></tr>'); |
||
138 | } |
||
139 | } |
||
140 | |||
141 | // Update the CCP Tables |
||
142 | updateCCPData($settings["dbuser"], $settings["dbpassword"], $settings["dbname"], $settings["dbhost"]); |
||
143 | |||
144 | // Add the admin user |
||
145 | output('<tr><td>Adding admin user</b></td><td></td></tr>'); |
||
146 | Db::execute("INSERT INTO zz_users (username, moderator, admin, password) VALUES ('admin', 1, 1, '".$adminPassword."')"); |
||
147 | |||
148 | // Create the cache directories |
||
149 | output('<tr><td>Creating cache directories</td><td></td></tr>'); |
||
150 | @mkdir("$dir/../cache/"); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
151 | @mkdir("$dir/../cache/sessions/"); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
152 | @mkdir("$dir/../cache/pheal/"); |
||
0 ignored issues
–
show
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||
153 | |||
154 | output('<tr><td>Done, click the button below to move onto the final page.</td><td></td></tr>'); |
||
155 | output('<tr><td style="text-align: center !important;"> |
||
156 | <p><a class="btn btn-lg btn-success" href="?step=4">Step 4</a></p> |
||
157 | </td></tr>'); |
||
158 | // Keep at the bottom of the tables.. |
||
159 | output('</tr></tbody></table>'); |
||
160 | } |
||
161 | |||
162 | output('</div></div></body></html>'); |
||
163 | |||
164 | // it has to die, otherwise it'll try and load a template with twig /o\ |
||
165 | die(); |
||
166 | //Grab the post info! |
||
167 | function post($var) |
||
0 ignored issues
–
show
The return type could not be reliably inferred; please add a
@return annotation.
Our type inference engine in quite powerful, but sometimes the code does not
provide enough clues to go by. In these cases we request you to add a ![]() |
|||
168 | { |
||
169 | return isset($_POST[$var]) ? $_POST[$var] : null; |
||
170 | } |
||
171 | |||
172 | // Part function |
||
173 | function part($part = null) |
||
0 ignored issues
–
show
|
|||
174 | { |
||
175 | return isset($_GET["part"]) ? (int) $_GET["part"] : 0; |
||
176 | } |
||
177 | |||
178 | // Output it mothafuckaa |
||
179 | function output($html) |
||
180 | { |
||
181 | echo $html; |
||
182 | flush(); |
||
183 | } |
||
184 | |||
185 | function loadFile($file) |
||
0 ignored issues
–
show
The function
loadFile() has been defined more than once; this definition is ignored, only the first definition in install/install.php (L241-258) is considered.
This check looks for functions that have already been defined in other files. Some Codebases, like WordPress, make a practice of defining functions multiple times. This
may lead to problems with the detection of function parameters and types. If you really
need to do this, you can mark the duplicate definition with the /**
* @ignore
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
186 | { |
||
187 | if (stristr($file, ".gz")) |
||
188 | $handle = gzopen($file, "r"); |
||
189 | else |
||
190 | $handle = fopen($file, "r"); |
||
191 | |||
192 | $query = ""; |
||
193 | while ($buffer = fgets($handle)) |
||
194 | { |
||
195 | $query .= $buffer; |
||
196 | if (strpos($query, ";") !== false) |
||
197 | { |
||
198 | $query = str_replace(";", "", $query); |
||
199 | Db::execute($query); |
||
200 | $query = ""; |
||
201 | } |
||
202 | } |
||
203 | fclose($handle); |
||
204 | } |
||
205 | |||
206 | function updateCCPData($dbUser, $dbPassword, $dbName, $dbHost) |
||
0 ignored issues
–
show
|
|||
207 | { |
||
208 | $url = "https://www.fuzzwork.co.uk/dump/"; |
||
209 | $cacheDir = __DIR__ . "/../../cache/update"; |
||
210 | |||
211 | // If the cache dir doesn't exist, create it |
||
212 | if(!file_exists($cacheDir)) |
||
213 | mkdir($cacheDir); |
||
214 | |||
215 | $dbFiles = array("dgmAttributeCategories", "dgmAttributeTypes", "dgmEffects", "dgmTypeAttributes", "dgmTypeEffects", "invFlags", "invGroups", "invTypes", "mapDenormalize", "mapRegions", "mapSolarSystems"); |
||
216 | $type = ".sql.bz2"; |
||
217 | |||
218 | // Now run through each db table, and insert them ! |
||
219 | foreach($dbFiles as $file) |
||
220 | { |
||
221 | output("</tr><tr><td><b>Updating data in table:</b> {$file}</td>"); |
||
222 | $dataURL = $url . "latest/" . $file . $type; |
||
223 | |||
224 | // Get and extract, it's simpler to use execs for this, than to actually do it with php |
||
225 | exec("wget -q $dataURL -O $cacheDir/$file$type"); |
||
226 | exec("bzip2 -q -d $cacheDir/$file$type"); |
||
227 | |||
228 | // Now get the sql so we can alter a few things |
||
229 | $data = file_get_contents($cacheDir . "/" . $file . ".sql"); |
||
230 | |||
231 | // Systems and regions need to be renamed |
||
232 | if($file == "mapRegions") |
||
233 | $name = "regions"; |
||
234 | if($file == "mapSolarSystems") |
||
235 | $name = "systems"; |
||
236 | |||
237 | if(isset($name)) |
||
238 | $data = str_replace($file, "ccp_$name", $data); |
||
239 | else |
||
240 | $data = str_replace($file, "ccp_$file", $data); |
||
241 | |||
242 | $dataParts = explode(";\n", $data); |
||
243 | |||
244 | foreach($dataParts as $q) |
||
245 | { |
||
246 | $query = $q . ";"; |
||
247 | Db::execute($query); |
||
248 | } |
||
249 | |||
250 | // Delete the .sql file |
||
251 | unlink("$cacheDir/$file.sql"); |
||
252 | |||
253 | // Output html |
||
254 | output('<td><button type="button" class="btn btn-primary btn-circle"><i class="glyphicon glyphicon-ok"></i></button></td></tr>'); |
||
255 | } |
||
256 | } |
||
257 |
When comparing two booleans, it is generally considered safer to use the strict comparison operator.