1
|
<?php
|
2
|
|
3
|
$sAppPath = dirname(dirname(__DIR__));
|
4
|
if (is_readable($sAppPath.'/config.php')) {require ($sAppPath.'/config.php');}
|
5
|
if (!class_exists('admin', false)) {require (WB_PATH.'/framework/class.admin.php');}
|
6
|
if (!function_exists('rm_full_dir')){require (WB_PATH.'/framework/functions.php');}
|
7
|
// An associative array that by default contains the contents of $_GET, $_POST and $_COOKIE.
|
8
|
$aRequestVars = $_REQUEST;
|
9
|
$sErrorlogFile = WB_PATH.'/var/logs/php_error.log.php';
|
10
|
$sErrorlogUrl = WB_URL .'/var/logs/php_error.log.php';
|
11
|
$aJsonRespond['url'] = $sErrorlogUrl;
|
12
|
// initialize json_respond array (will be sent back)
|
13
|
$aJsonRespond = array();
|
14
|
$aJsonRespond['content'] = '';
|
15
|
$aJsonRespond['message'] = 'Load operation failed';
|
16
|
$aJsonRespond['success'] = false;
|
17
|
$admin = new admin('##skip##', false, false);
|
18
|
if ( (int)$admin->get_user_id() != 1){ #
|
19
|
$aJsonRespond['message'] = 'illegal file access';
|
20
|
exit(json_encode($aJsonRespond));
|
21
|
}
|
22
|
if(!isset($aRequestVars['action']) )
|
23
|
{
|
24
|
$aJsonRespond['message'] = '"action" was not set';
|
25
|
exit(json_encode($aJsonRespond));
|
26
|
} elseif ($aRequestVars['action']=='show') {
|
27
|
$aJsonRespond['content'] = file_get_contents($sErrorlogFile);
|
28
|
} else {
|
29
|
if (is_writeable($sErrorLogFile)) {
|
30
|
if (!rm_full_dir($sErrorLogFile, true)){
|
31
|
$aJsonRespond['message'] = "can't delete from folder";
|
32
|
exit(json_encode($aJsonRespond));
|
33
|
}
|
34
|
if (!file_exists($sErrorLogFile)) {
|
35
|
$sTmp = '<?php die(\'illegal file access\'); ?>'
|
36
|
. 'created: ['.date('c').']'.PHP_EOL;
|
37
|
if (false === file_put_contents($sErrorLogFile, $sTmp, FILE_APPEND)) {
|
38
|
throw new Exception('unable to create logfile \'/var/logs/php_error.log.php\'');
|
39
|
}
|
40
|
}
|
41
|
if (!is_writeable($sErrorLogFile)) {
|
42
|
throw new Exception('not writeable logfile \'/var/logs/php_error.log.php\'');
|
43
|
}
|
44
|
$aJsonRespond['message'] = 'New php_error.log successfully created';
|
45
|
$aJsonRespond['content'] = file_get_contents($sErrorlogFile);
|
46
|
}
|
47
|
|
48
|
/*
|
49
|
if (!file_exists($sErrorLogFile)) {
|
50
|
file_put_contents($sErrorLogFile, 'created: ['.date('c').']'.PHP_EOL, FILE_APPEND);
|
51
|
}
|
52
|
*/
|
53
|
}
|
54
|
// If the script is still running, set success to true
|
55
|
$aJsonRespond['success'] = 'true';
|
56
|
// and echo the answer as json to the ajax function
|
57
|
echo json_encode($aJsonRespond);
|