1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
use XoopsModules\Xhttperror\{ |
4
|
|
|
Helper |
5
|
|
|
}; |
6
|
|
|
/** @var Helper $helper */ |
7
|
|
|
|
8
|
|
|
// inludes and stuff |
9
|
|
|
require_once __DIR__ . '/header.php'; |
10
|
|
|
|
11
|
|
|
$GLOBALS['xoopsOption']['template_main'] = 'xhttperror_index.tpl'; |
12
|
|
|
require_once XOOPS_ROOT_PATH . '/header.php'; |
13
|
|
|
|
14
|
|
|
$helper = Helper::getInstance(); |
15
|
|
|
|
16
|
|
|
//require 'include/functions.php'; |
17
|
|
|
$myts = \MyTextSanitizer::getInstance(); |
18
|
|
|
|
19
|
|
|
// load classes |
20
|
|
|
$errorHandler = $helper->getHandler('Error'); |
21
|
|
|
$reportHandler = $helper->getHandler('Report'); |
22
|
|
|
|
23
|
|
|
if (!isset($_GET['error'])) { |
24
|
|
|
$xoopsTpl->assign('message', 'No error defined.'); |
25
|
|
|
} else { |
26
|
|
|
// Save error info to database |
27
|
|
|
// We may want to turn this off on busy sites. |
28
|
|
|
if (false == $helper->getConfig('error_reporting')) { |
29
|
|
|
if (!$xoopsUser || ($xoopsUser->isAdmin($GLOBALS['xoopsModule']->mid()) && true != $helper->getConfig('ignore_admin'))) { |
30
|
|
|
// create report |
31
|
|
|
$serverVars = []; |
32
|
|
|
$serverVars['HTTP_REFERER'] = xoops_getenv('HTTP_REFERER'); |
33
|
|
|
$serverVars['REMOTE_ADDR'] = xoops_getenv('REMOTE_ADDR'); |
34
|
|
|
//$serverVars[''] = |
35
|
|
|
$referer = $_GET['HTTP_REFERER'] ?? xoops_getenv('HTTP_REFERER'); |
36
|
|
|
$useragent = xoops_getenv('HTTP_USER_AGENT'); |
37
|
|
|
$remoteaddr = $_GET['REMOTE_ADDR'] ?? xoops_getenv('REMOTE_ADDR'); |
38
|
|
|
$requesteduri = $_GET['REQUEST_URI'] ?? xoops_getenv('REQUEST_URI'); |
39
|
|
|
|
40
|
|
|
if (empty($xoopsUser)) { |
41
|
|
|
$uid = 0; // anonymous |
42
|
|
|
} else { |
43
|
|
|
$uid = $xoopsUser->getVar('uid'); |
44
|
|
|
} |
45
|
|
|
$reportObj = $reportHandler->create(); |
46
|
|
|
$reportObj->setVar('report_uid', $uid); |
47
|
|
|
$reportObj->setVar('report_statuscode', $_GET['error']); |
48
|
|
|
$reportObj->setVar('report_date', time()); |
49
|
|
|
$reportObj->setVar('report_referer', $referer); |
50
|
|
|
$reportObj->setVar('report_useragent', $useragent); |
51
|
|
|
$reportObj->setVar('report_remoteaddr', $remoteaddr); |
52
|
|
|
$reportObj->setVar('report_requesteduri', $requesteduri); |
53
|
|
|
if ($reportHandler->insert($reportObj)) { |
54
|
|
|
// NOP |
55
|
|
|
} |
56
|
|
|
// NOP |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
$errorCriteria = new \CriteriaCompo(); |
61
|
|
|
$errorCriteria->add(new \Criteria('error_statuscode', $_GET['error'])); |
62
|
|
|
$errorCriteria->add(new \Criteria('error_showme', true)); |
|
|
|
|
63
|
|
|
$errorObjs = $errorHandler->getObjects($errorCriteria); |
64
|
|
|
if ($errorObjs) { |
|
|
|
|
65
|
|
|
$errorObj = $errorObjs[0]; |
66
|
|
|
$id = $errorObj->getVar('error_id'); |
67
|
|
|
$title = $myts->displayTarea($errorObj->getVar('error_title')); |
68
|
|
|
//$text = $errorObj->getVar('error_text', 'n'); |
69
|
|
|
// displayTarea ($text, $html=0, $smiley=1, $xcode=1, $image=1, $br=1) |
70
|
|
|
$text = $myts->displayTarea($errorObj->getVar('error_text', 'n'), $errorObj->getVar('error_text_html'), $errorObj->getVar('error_text_smiley'), 1, 1, $errorObj->getVar('error_text_breaks')); |
71
|
|
|
|
72
|
|
|
// Add custom title to page title - "<{$xoops_pagetitle}>" - titleaspagetitle |
73
|
|
|
if (1 == $helper->getConfig('title_as_page_title')) { |
74
|
|
|
$GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $GLOBALS['xoopsModule']->getVar('name') . ' - ' . $title); // module name - article title |
75
|
|
|
} |
76
|
|
|
if (2 == $helper->getConfig('title_as_page_title')) { |
77
|
|
|
$GLOBALS['xoopsTpl']->assign('xoops_pagetitle', $title . ' - ' . $GLOBALS['xoopsModule']->getVar('name')); // article title - module name |
78
|
|
|
} |
79
|
|
|
|
80
|
|
|
$GLOBALS['xoopsTpl']->assign('title', $title); |
81
|
|
|
$GLOBALS['xoopsTpl']->assign('text', $text); |
82
|
|
|
$GLOBALS['xoopsTpl']->assign('showsearch', true); // IN PROGRESS: True if show search form in error page |
83
|
|
|
$GLOBALS['xoopsTpl']->assign('redirect', $errorObj->getVar('error_redirect')); |
84
|
|
|
$GLOBALS['xoopsTpl']->assign('redirect_time', (int)$errorObj->getVar('error_redirect_time') * 1000); |
85
|
|
|
$GLOBALS['xoopsTpl']->assign('redirect_uri', $errorObj->getVar('error_redirect_uri')); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
require_once XOOPS_ROOT_PATH . '/footer.php'; |
89
|
|
|
|