1: <?php
2: /*
3: You may not change or alter any portion of this comment or credits
4: of supporting developers from this source code or any supporting source code
5: which is considered copyrighted (c) material of the original comment or credit authors.
6:
7: This program is distributed in the hope that it will be useful,
8: but WITHOUT ANY WARRANTY; without even the implied warranty of
9: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10: */
11:
12: use Xoops\Core\PreloadItem;
13:
14: /**
15: * Protector
16: *
17: * @copyright XOOPS Project (http://xoops.org)
18: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
19: * @package protector
20: * @since 2.4.0
21: * @author trabis <lusopoemas@gmail.com>
22: * @version $Id$
23: */
24:
25: /**
26: * Protector core preloads
27: *
28: * @copyright XOOPS Project (http://xoops.org)
29: * @license GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
30: * @author trabis <lusopoemas@gmail.com>
31: */
32: class ProtectorCorePreload extends PreloadItem
33: {
34: /**
35: * @static
36: *
37: * @param $args
38: */
39: static function eventCoreIncludeCommonStart($args)
40: {
41: $xoops = Xoops::getInstance();
42: include $xoops->path('modules/protector/include/precheck.inc.php');
43: }
44:
45: /**
46: * @static
47: *
48: * @param $args
49: */
50: static function eventCoreIncludeCommonEnd($args)
51: {
52: $xoops = Xoops::getInstance();
53: include $xoops->path('modules/protector/include/postcheck.inc.php');
54: }
55:
56: /**
57: * @static
58: *
59: * @param $args
60: */
61: static function eventCoreClassDatabaseDatabasefactoryConnection($args)
62: {
63: // Protector class
64: require_once dirname(__DIR__) . '/class/protector.php';
65:
66: // Protector object
67: $protector = Protector::getInstance();
68: $conf = $protector->getConf();
69: // "DB Layer Trapper"
70: $force_override = strstr(@$_SERVER['REQUEST_URI'], 'protector/admin/index.php?page=advisory') ? true : false;
71: //$force_override = true ;
72: if ($force_override || !empty($conf['enable_dblayertrap'])) {
73: @define('PROTECTOR_ENABLED_ANTI_SQL_INJECTION', 1);
74: $protector->dblayertrap_init($force_override);
75: }
76: if (defined('XOOPS_DB_ALTERNATIVE') && class_exists(XOOPS_DB_ALTERNATIVE)) {
77: $args[0] = XOOPS_DB_ALTERNATIVE;
78: }
79: }
80: }
81: