Completed
Push — master ( 15a86c...ff0242 )
by Michael
03:23
created

functions.ini.php ➔ planet_load_config()   C

Complexity

Conditions 7
Paths 7

Size

Total Lines 30
Code Lines 20

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 0
Metric Value
cc 7
eloc 20
c 4
b 0
f 0
nc 7
nop 0
dl 0
loc 30
rs 6.7272
1
<?php
2
//
3
// ------------------------------------------------------------------------ //
4
// This program is free software; you can redistribute it and/or modify     //
5
// it under the terms of the GNU General Public License as published by     //
6
// the Free Software Foundation; either version 2 of the License, or        //
7
// (at your option) any later version.                                      //
8
//                                                                          //
9
// You may not change or alter any portion of this comment or credits       //
10
// of supporting developers from this source code or any supporting         //
11
// source code which is considered copyrighted (c) material of the          //
12
// original comment or credit authors.                                      //
13
//                                                                          //
14
// This program is distributed in the hope that it will be useful,          //
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
17
// GNU General Public License for more details.                             //
18
//                                                                          //
19
// You should have received a copy of the GNU General Public License        //
20
// along with this program; if not, write to the Free Software              //
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
22
// ------------------------------------------------------------------------ //
23
// Author: phppp (D.J., [email protected])                                  //
24
// URL: http://xoops.org                         //
25
// Project: Article Project                                                 //
26
// ------------------------------------------------------------------------ //
27
28
/*
29
30
The functions loaded on initializtion
31
*/
32
33
// defined('XOOPS_ROOT_PATH') || exit('XOOPS root path not defined');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
34
if (!defined('PLANET_INI')) {
35
    exit();
36
}
37
38
if (!defined('PLANET_FUNCTIONS_INI')):
39
    define('PLANET_FUNCTIONS_INI', 1);
40
41
    /**
42
     * @param $name
43
     * @return mixed
44
     */
45
    function planet_constant($name) {
46
        return mod_constant($name);
47
    }
48
49
    /**
50
     * @param      $name
51
     * @param bool $isRel
52
     * @return string
53
     */
54
    function planet_DB_prefix($name, $isRel = false) {
55
        return mod_DB_prefix($name, $isRel);
56
    }
57
58
    /**
59
     * @return bool
60
     */
61
    function planet_load_object() {
62
        return load_object();
63
    }
64
65
    /**
66
     * @return array|mixed
67
     */
68
    function planet_load_config() {
69
        static $moduleConfig;
70
        if (isset($moduleConfig)) {
71
            return $moduleConfig;
72
        }
73
74
        if (is_object($GLOBALS['xoopsModule'])
75
            && $GLOBALS['xoopsModule']->getVar('dirname') == $GLOBALS['moddirname']
76
        ) {
77
            if (isset($GLOBALS['xoopsModuleConfig'])) {
78
                $moduleConfig = $GLOBALS['xoopsModuleConfig'];
79
            }
80
        } else {
81
            $moduleHandler = xoops_getHandler('module');
82
            $module        = $moduleHandler->getByDirname($GLOBALS['moddirname']);
83
84
            $config_handler = xoops_getHandler('config');
85
            $criteria       = new CriteriaCompo(new Criteria('conf_modid', $module->getVar('mid')));
86
            $configs        = $config_handler->getConfigs($criteria);
87
            foreach (array_keys($configs) as $i) {
88
                $moduleConfig[$configs[$i]->getVar('conf_name')] = $configs[$i]->getConfValueForOutput();
89
            }
90
            unset($configs);
91
        }
92
        if ($customConfig = @include XOOPS_ROOT_PATH . '/modules/' . $GLOBALS['moddirname'] . '/include/plugin.php') {
93
            $moduleConfig = array_merge($moduleConfig, $customConfig);
94
        }
95
96
        return $moduleConfig;
97
    }
98
99
    function planet_define_url_delimiter() {
100
        if (defined('URL_DELIMITER')) {
101
            if (!in_array(URL_DELIMITER, array('?', '/'))) {
102
                die('Exit on security');
103
            }
104
        } else {
105
            $moduleConfig = planet_load_config();
106
            if (empty($moduleConfig['do_urw'])) {
107
                define('URL_DELIMITER', '?');
108
            } else {
109
                define('URL_DELIMITER', '/');
110
            }
111
        }
112
    }
113
114
endif;
115