1
|
|
|
<?php declare(strict_types=1); |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* **************************************************************************** |
5
|
|
|
* - A Project by Developers TEAM For Xoops - ( https://xoops.org ) |
6
|
|
|
* **************************************************************************** |
7
|
|
|
* XHTTPERROR - MODULE FOR XOOPS |
8
|
|
|
* Copyright (c) 2007 - 2012 |
9
|
|
|
* Rota Lucio ( http://luciorota.altervista.org/xoops/ ) |
10
|
|
|
* |
11
|
|
|
* You may not change or alter any portion of this comment or credits |
12
|
|
|
* of supporting developers from this source code or any supporting |
13
|
|
|
* source code which is considered copyrighted (c) material of the |
14
|
|
|
* original comment or credit authors. |
15
|
|
|
* |
16
|
|
|
* This program is distributed in the hope that it will be useful, |
17
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
18
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
19
|
|
|
* GNU General Public License for more details. |
20
|
|
|
* --------------------------------------------------------------------------- |
21
|
|
|
* @copyright Rota Lucio ( http://luciorota.altervista.org/xoops/ ) |
22
|
|
|
* @license GNU General Public License v3.0 |
23
|
|
|
* @package xhttperror |
24
|
|
|
* @author Rota Lucio ( [email protected] ) |
25
|
|
|
* |
26
|
|
|
* $Rev$: Revision of last commit |
27
|
|
|
* $Author$: Author of last commit |
28
|
|
|
* $Date$: Date of last commit |
29
|
|
|
* **************************************************************************** |
30
|
|
|
*/ |
31
|
|
|
|
32
|
|
|
use XoopsModules\Xhttperror\{ |
33
|
|
|
Helper |
34
|
|
|
}; |
35
|
|
|
/** @var Helper $helper */ |
36
|
|
|
|
37
|
|
|
defined('DS') || define('DS', DIRECTORY_SEPARATOR); |
38
|
|
|
|
39
|
|
|
/** |
40
|
|
|
* @return bool |
41
|
|
|
*/ |
42
|
|
|
function xoops_module_pre_install_xhttperror(\XoopsModule $module) |
|
|
|
|
43
|
|
|
{ |
44
|
|
|
// Check if this XOOPS version is supported |
45
|
|
|
$minSupportedVersion = explode('.', '2.5.10'); |
46
|
|
|
$currentVersion = explode('.', mb_substr(XOOPS_VERSION, 6)); |
47
|
|
|
if ($currentVersion[0] > $minSupportedVersion[0]) { |
48
|
|
|
return true; |
49
|
|
|
} elseif ($currentVersion[0] == $minSupportedVersion[0]) { |
50
|
|
|
if ($currentVersion[1] > $minSupportedVersion[1]) { |
51
|
|
|
return true; |
52
|
|
|
} elseif ($currentVersion[1] == $minSupportedVersion[1]) { |
53
|
|
|
if ($currentVersion[2] > $minSupportedVersion[2]) { |
54
|
|
|
return true; |
55
|
|
|
} elseif ($currentVersion[2] == $minSupportedVersion[2]) { |
56
|
|
|
return true; |
57
|
|
|
} |
58
|
|
|
} |
59
|
|
|
} |
60
|
|
|
|
61
|
|
|
return false; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* @return bool|string |
66
|
|
|
*/ |
67
|
|
|
function xoops_module_install_xhttperror(\XoopsObject $module) |
68
|
|
|
{ |
69
|
|
|
xoops_loadLanguage('modinfo', $module->getVar('dirname')); |
|
|
|
|
70
|
|
|
require_once XOOPS_ROOT_PATH . '/modules/' . $module->getVar('dirname') . '/include/functions.php'; |
71
|
|
|
|
72
|
|
|
$ret = true; |
73
|
|
|
$msg = ''; |
74
|
|
|
// load classes |
75
|
|
|
$helper = Helper::getInstance(); |
76
|
|
|
$errorHandler = $helper->getHandler('Error'); |
77
|
|
|
$error = $errorHandler->create(); |
78
|
|
|
$error->setVar('error_title', 'Error 404 - Document Not Found'); |
79
|
|
|
$error->setVar('error_statuscode', '404'); |
80
|
|
|
$error->setVar( |
81
|
|
|
'error_text', |
82
|
|
|
'<p style="font-weight: bold; text-align: center">The page you requested could not be found.</p><p>You may not be able to find the requested page because:</p><ul><li>The page no longer exists.</li><li>The address/page name was mis-typed.</li><li>You followed an incorrect, or out of date link on another site.</li><li>You followed an out of date search engine listing, or personal bookmark/favourite.</li></ul><p>Please try visiting the <a href="/">home page</a>, or use the search function below to find the page you were after.</p>' |
83
|
|
|
); |
84
|
|
|
$error->setVar('error_showme', true); |
85
|
|
|
$error->setVar('error_redirect', false); |
86
|
|
|
$error->setVar('error_redirect_time', 3); |
87
|
|
|
$error->setVar('error_redirect_uri', XOOPS_URL); |
88
|
|
|
if (!$errorHandler->insert($error)) { |
89
|
|
|
$msg = $msg . $error->getHtmlErrors(); |
90
|
|
|
} |
91
|
|
|
unset($error); |
92
|
|
|
$error = $errorHandler->create(); |
93
|
|
|
$error->setVar('error_title', 'Error 500 - Server error'); |
94
|
|
|
$error->setVar('error_statuscode', '500'); |
95
|
|
|
$error->setVar('error_text', '<p style="font-weight: bold; text-align: center;">The server encountered an internal error and was unable to complete your request.</p>'); |
96
|
|
|
$error->setVar('error_showme', true); |
97
|
|
|
$error->setVar('error_redirect', false); |
98
|
|
|
$error->setVar('error_redirect_time', 3); |
99
|
|
|
$error->setVar('error_redirect_uri', XOOPS_URL); |
100
|
|
|
if (!$errorHandler->insert($error)) { |
101
|
|
|
$msg = $msg . $error->getHtmlErrors(); |
102
|
|
|
} |
103
|
|
|
unset($error); |
104
|
|
|
$error = $errorHandler->create(); |
105
|
|
|
$error->setVar('error_title', 'Error 403 - Forbidden'); |
106
|
|
|
$error->setVar('error_statuscode', '403'); |
107
|
|
|
$error->setVar('error_text', '<p style="font-weight: bold; text-align: center;">You do not have permission to access the requested directory/file.</p>'); |
108
|
|
|
$error->setVar('error_showme', true); |
109
|
|
|
$error->setVar('error_redirect', false); |
110
|
|
|
$error->setVar('error_redirect_time', 3); |
111
|
|
|
$error->setVar('error_redirect_uri', XOOPS_URL); |
112
|
|
|
if (!$errorHandler->insert($error)) { |
113
|
|
|
$msg = $msg . $error->getHtmlErrors(); |
114
|
|
|
} |
115
|
|
|
unset($error); |
116
|
|
|
if (empty($msg)) { |
117
|
|
|
return $ret; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
return $msg; |
121
|
|
|
} |
122
|
|
|
|
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.