forked from craig-russell/Log-Hog
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy patherror.php
409 lines (396 loc) · 17.1 KB
/
error.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
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
<?php
$version = "Unknown - Could not find core/php/configStatic.php";
$file = 'core/php/configStatic.php';
if(file_exists($file))
{
if(is_readable($file))
{
try
{
require_once($file);
if(isset($configStatic['version']))
{
$version = $configStatic['version'];
}
else
{
$version = "Config Static was loaded, but errored when loading the version number";
}
}
catch (Exception $e)
{
$version = "Unknown - Error reading core/php/configStatic.php";
}
}
else
{
$version = "Unknown - core/php/configStatic.php is there, but is not readable by this file";
}
}
$coreLoaded = false;
$file = "core/php/class/core.php";
if(file_exists($file))
{
try {
require_once($file);
$coreLoaded = true;
} catch (Exception $e) {
}
if($coreLoaded)
{
$core = new core();
}
}
$sessionLoaded = false;
$file = "core/php/class/session.php";
if(file_exists($file))
{
try
{
require_once($file);
$sessionLoaded = true;
} catch (Exception $e) {}
if($sessionLoaded)
{
$session = new session();
try
{
if(!$session->startSession())
{
$sessionLoaded = false;
}
} catch (Exception $e) {}
}
}
$fileNameArray = array(
"Error" => array(
"name" => "Could not load list of files",
"path" => ""
)
);
$file = 'core/json/listOfFiles.json';
if(file_exists($file))
{
if(is_readable($file))
{
try
{
$jsonFiles = file_get_contents("core/json/listOfFiles.json");
$fileNameArray = json_decode($jsonFiles, true);
}
catch (Exception $e)
{
$fileNameArray = array(
"Error" => array(
"name" => "List of files exists, but cant be loaded",
"path" => ""
)
);
}
}
else
{
$fileNameArray = array(
"Error" => array(
"name" => "List of files exists, but is not readable",
"path" => ""
)
);
}
}
$error = 42;
if(isset($_GET["error"]))
{
$error = $_GET["error"];
}
$page = "";
if(isset($_GET["page"]))
{
$page = $_GET["page"];
}
$errorArray = array(
0 => array(
"firstMessage" => "",
"secondMessage" => ""
),
1 => array(
"firstMessage" => "Watch-List Config Error",
"secondMessage" => "Please remove all reference of double backslash (\\\\) from the watchList var in config.php (Local/default/conf/config.php)"
),
2 => array(
"firstMessage" => "Setup Error",
"secondMessage" => "An error occured when trying to complete the setup process. Please check that the save file has correct access to write to and create a local config file. If that doesn't work: Copy core/conf/config.php to local/default/conf/config.php and change defaultConfig to config."
),
3 => array(
"firstMessage" => "Config Folder Save Error",
"secondMessage" => "An error occured when SettingsSaveAjax tried to save the config file. This file does not have write access to the specific folder (Local/default/conf) to save the updated config file. Please give the correct write access to settingsSaveAjax to save and update the config with the new values."
),
4 => array(
"firstMessage" => "Config File Save Error",
"secondMessage" => "An error occured when SettingsSaveAjax tried to save the config file. This file does not have write access to the specific file (Local/default/conf/config.php) to save the updated config file. Please give the correct write access to settingsSaveAjax to save and update the config with the new values."
),
5 => array(
"firstMessage" => "Config Save Error",
"secondMessage" => "An unknown error occured when SettingsSaveAjax tried to save the config file. This file (Local/default/conf/config.php) could not be updated with the new values."
),
6 => array(
"firstMessage" => "Config Backup Error",
"secondMessage" => "An unknown error occured when SettingsSaveAjax tried to save a backup of the config file."
),
7 => array(
"firstMessage" => "Local Layout File Error",
"secondMessage" => "An error occured when trying to locate the local layout file. Please make sure the file is readable and in the correct folder (local/layout.php)"
),
8 => array(
"firstMessage" => "Core Config File Error",
"secondMessage" => "An error occured when trying to locate the core config file. Please make sure the file is readable and in the correct folder (core/conf/config.php)"
),
9 => array(
"firstMessage" => "Local Layout File Error",
"secondMessage" => "An error occured when loading the layout file. The file loaded does not contain the expected variable. Please check that the local layout file contains the currentSelectedTheme variable, and is defined (probably default) (local/layout.php)"
),
10 => array(
"firstMessage" => "Core Config File Error",
"secondMessage" => "An error occured when loading the core config file. The file loaded does not contain the expected variable. Please check that the local layout file contains the defaultConfig variable, and is defined. If it is empty, re copy it from the repo (core/conf/config.php)"
),
11 => array(
"firstMessage" => "Zip Archive is not installed",
"secondMessage" => "When trying to check for an update, php downloads a Zip file from github. This requires the php module Zip Archive to work. Please install Zip archive to use the update function in log-hog. An example command would be: sudo apt-get install php7.0-zip. If you are unable to install Zip Archive, you can disable automatic update checks under settings. <br><br> <form id=\"formUpdateSave\" ><span class=\"settingsBuffer\" > Auto Check Update: </span><select autocomplete=\"off\" id=\"settingsSelect\" name=\"autoCheckUpdate\"><option selected value=\"true\">True</option><option value=\"false\">False</option></select><br><br></form><button onclick=\"saveAndVerifyMain('formUpdateSave');\" >Save</button><br><br>This could take up to 60 seconds to refresh the config file"
),
12 => array(
"firstMessage" => "Update check failed because of incorrect write permissions",
"secondMessage" => "The file configStatic.php could not be written to by settingsCheckForUpdateAjax.php because of incorrect file write permissions. Please update the settingsCheckForUpdateAjax file with correct file permissions to write to configStatic.php (under core/php). If this is not possible, change the auto check for update settings to false to prevent this message."
),
13 => array(
"firstMessage" => "Update check failed because a temporary directory failed to create",
"secondMessage" => "When checking for updates, a tmp directory is created under update/downloads/versionCheck/extracted/ to hold the zip file and list of versions. This process errored out when trying to check for updates, throwing this error. Please check if settingsCheckForUpdateAjax.php has correct write permissions to create a folder, and that the target directory has enough free space."
),
14 => array(
"firstMessage" => "Session Initialize Error",
"secondMessage" => "Session was not initialized, try again?"
),
15 => array(
"firstMessage" => "Could not load JS file when trying to initialize Log-Hog",
"secondMessage" => "Please make sure your are connected to the server, and the javascript file is present"
),
16 => array(
"firstMessage" => "Update check failed because the downloaded zip file was empty, or the file(s) could not be copied over",
"secondMessage" => "When checking for updates, a zip file is download that contains the new version list. An error occured when trying to copy files from the zip file. This could either be due to a permission error or not enough space in the target directory."
),
17 => array(
"firstMessage" => "Update check failed because it could not open the downloaded zip file",
"secondMessage" => "When checking for updates, a zip file is download that contains the new version list. An error occured when trying to open the zip file. This could either be due to a permission error or not enough space in the target directory."
),
18 => array(
"firstMessage" => "Invalid Form Key",
"secondMessage" => "The formkey sent with the post request was invalid. Please try and reload Log-Hog to generate a new session."
),
42 => array(
"firstMessage" => "General Error",
"secondMessage" => "A general error occured, or you navigated to this page directly."
),
43 => array(
"firstMessage" => "General Update Error",
"secondMessage" => "A general error occured when trying to check for an update."
),
550 => array(
"firstMessage" => "File Permission Error",
"secondMessage" => "Make sure the file permissions are set correctly for all of the files within loghog."
),
1072 => array(
"firstMessage" => "File Is Readable Error",
"secondMessage" => "This error occured when a file tried to read another file. Please ensure that the file permissions of the file allow it to be read / read other files. (is_readable check) "
),
1073 => array(
"firstMessage" => "File Is Writable Error",
"secondMessage" => "This error occured when a file tried to write to it. Please ensure that the file permissions of the file allow it to be written to, and that the file trying to write has permission to do so. (is_writable check) "
),
1074 => array(
"firstMessage" => "File Is Accessable Error",
"secondMessage" => "This error occured when a file is trying to be accessed, but cant be found. (file_exists check) "
),
);
if(!isset($errorArray[$error]))
{
$error = 42;
}
$jsForResetToDefaultLoaded = false;
$file = 'core/js/resetSettingsJs.js';
if(file_exists($file))
{
if(is_readable($file))
{
$jsForResetToDefaultLoaded = true;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Error Page</title>
<script src="core/js/jquery.js?v=<?php echo rand(5, 15); ?>"></script>
<link rel="stylesheet" type="text/css" href="core/template/error.css?v=<?php echo rand(5, 15); ?>">
<script type="text/javascript" src="core/js/error.js?v=<?php echo rand(5, 15); ?>" ></script>
<script type="text/javascript" src="core/js/errorHandle.js?v=<?php echo rand(5, 15); ?>" ></script>
<?php if($jsForResetToDefaultLoaded): ?>
<script type="text/javascript" src="core/js/resetSettingsJs.js?v=<?php echo rand(5, 15); ?>" ></script>
<?php endif;?>
<script type="text/javascript" >
<?php if($sessionLoaded){
echo $session->outputFormKey();
}?>
</script>
</head>
<body>
<?php if($error != 0): ?>
<div class="errorMessage" >
<table>
<tr>
<td rowspan="2"><img class="warningImage" src="core/img/redWarning.png" height="120px"></td>
<td><h1>Error <?php echo $error ?></h1></td>
<td rowspan="2"><img class="warningImage" src="core/img/redWarning.png" height="120px"></td>
</tr>
<tr>
<td><h3><?php echo $page ?></h3></td>
</tr>
</table>
</div>
<?php endif; ?>
<table>
<tr class="tableRow">
<td width="33%">
<h3> More Info: </h3>
<h2><?php echo $errorArray[$error]["firstMessage"]; ?></h2>
<?php echo $errorArray[$error]["secondMessage"]; ?>
<h2> Version: </h2>
<?php echo $version; ?>
<h2> PHP Version: </h2>
<?php echo phpversion(); ?>
<?php if (!$sessionLoaded): ?>
<h2>Session NOT loaded</h2>
<?php endif; ?>
<br>
<br>
<?php
try
{
$currentSelectedTheme = "default";
if(is_file("local/layout.php"))
{
@include("local/layout.php");
}
$config = array();
if(is_file("local/profiles/".$currentSelectedTheme."/conf/config.php"))
{
@include("local/profiles/".$currentSelectedTheme."/conf/config.php");
}
$arrayOfModules = array();
$moduleFolders = array_diff(scandir("Modules/"), array('..', '.'));
foreach($moduleFolders as $moduleFolder)
{
$moduleDir = "Modules/" . $moduleFolder;
if(is_dir($moduleDir))
{
$filePath = $moduleDir . "/module.json";
if(file_exists($filePath))
{
$moduleData = json_decode(file_get_contents($filePath), true);
$arrayOfModules[] = array(
"key" => $moduleData["key"],
"name" => $moduleData["name"],
"id" => $moduleData["key"]
);
}
}
}
echo "<h3>Modules:</h3><table>";
foreach ($arrayOfModules as $value)
{
$status = "Enabled?";
if(!empty($config))
{
$status = "Enabled";
if(isset($config["moduleDisabledList"]))
{
$modules = json_decode($config["moduleDisabledList"], true);
if(in_array($value["key"], $modules))
{
$status = "Disabled";
}
}
}
echo "<tr><td> ".$value["name"]." </td><td> ".$status."</td>";
}
echo "</table>";
}
catch (Exception $e)
{
echo "Could not load module status";
}
?>
</td>
<td width="33%">
<h3> Actions: </h3>
<ul class="list">
<?php
if(file_exists("setup/step1.php")): ?>
<li>
<a href="setup/step1.php" class="link">Re-do Setup</a>
</li>
<?php
endif;
if(file_exists("restore/restore.php")): ?>
<li>
<a href="restore/restore.php" class="link">Revert Version</a>
</li>
<?php
endif;
if(file_exists("settings/editFiles.php")): ?>
<li>
<a class="link" href="settings/editFiles.php" >View Files</a>
</li>
<?php
endif;
if(file_exists("core/php/loadVars.php") && file_exists("core/conf/config.php") && $jsForResetToDefaultLoaded):
?>
<li>
<a onclick="toggleReset();" class="link">Reset Settings back to Default</a>
</li>
<?php
endif;
if(file_exists("core/php/post/resetUpdateFilesToDefault.php")):
?>
<li>
<a onclick="resetUpdateSettings();" class="link"> Reset Update Progress back to default </a>
</li>
<?php
endif;
?>
<li>
<div id="popup">
<div id="popupContentInnerHTMLDiv">
</div>
</div>
</li>
</ul>
</td>
<td width="33%">
<h3> File Permissions: </h3>
<table>
<?php
foreach ($fileNameArray as $key => $value)
{
$info = "";
if($coreLoaded)
{
$info = $core->filePermsDisplay($value["path"]);
}
echo "<tr><td>".$value["name"]."</td><td>".$info."</td></tr><tr><td colspan=\"2\">".$value["path"]."</td></tr>";
}
?>
</table>
</td>
</tr>
</table>
</body>
</html>