1 | <?php |
||||||
2 | |||||||
3 | altsys_set_module_config(); |
||||||
4 | |||||||
5 | function altsys_set_module_config() |
||||||
6 | { |
||||||
7 | global $altsysModuleConfig, $altsysModuleId; |
||||||
8 | |||||||
9 | $module_handler = xoops_getHandler('module'); |
||||||
10 | $module = $module_handler->getByDirname('altsys'); |
||||||
11 | if (is_object($module)) { |
||||||
12 | $config_handler = xoops_getHandler('config'); |
||||||
13 | $altsysModuleConfig = $config_handler->getConfigList($module->getVar('mid')); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
14 | $altsysModuleId = $module->getVar('mid'); |
||||||
15 | } else { |
||||||
16 | $altsysModuleConfig = array(); |
||||||
17 | $altsysModuleId = 0; |
||||||
18 | } |
||||||
19 | } |
||||||
20 | |||||||
21 | function altsys_include_mymenu() |
||||||
22 | { |
||||||
23 | global $xoopsModule, $xoopsConfig, $mydirname, $mydirpath, $mytrustdirname, $mytrustdirpath, $mymenu_fake_uri; |
||||||
24 | |||||||
25 | $mymenu_find_paths = array( |
||||||
26 | $mydirpath . '/admin/mymenu.php', |
||||||
27 | $mydirpath . '/mymenu.php', |
||||||
28 | $mytrustdirpath . '/admin/mymenu.php', |
||||||
29 | $mytrustdirpath . '/mymenu.php'); |
||||||
30 | |||||||
31 | foreach ($mymenu_find_paths as $mymenu_find_path) { |
||||||
32 | if (file_exists($mymenu_find_path)) { |
||||||
33 | include $mymenu_find_path; |
||||||
34 | include_once __DIR__ . '/adminmenu_functions.php'; |
||||||
35 | altsys_adminmenu_insert_mymenu($xoopsModule); |
||||||
0 ignored issues
–
show
The function
altsys_adminmenu_insert_mymenu was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
36 | altsys_adminmenu_hack_ft(); |
||||||
0 ignored issues
–
show
The function
altsys_adminmenu_hack_ft was not found. Maybe you did not declare it correctly or list all dependencies?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
37 | break; |
||||||
38 | } |
||||||
39 | } |
||||||
40 | } |
||||||
41 | |||||||
42 | /** |
||||||
43 | * @param $type |
||||||
44 | */ |
||||||
45 | function altsys_include_language_file($type) |
||||||
46 | { |
||||||
47 | $mylang = $GLOBALS['xoopsConfig']['language']; |
||||||
48 | |||||||
49 | if (file_exists(XOOPS_ROOT_PATH . '/modules/altsys/language/' . $mylang . '/' . $type . '.php')) { |
||||||
50 | include_once XOOPS_ROOT_PATH . '/modules/altsys/language/' . $mylang . '/' . $type . '.php'; |
||||||
51 | } elseif (file_exists(XOOPS_TRUST_PATH . '/libs/altsys/language/' . $mylang . '/' . $type . '.php')) { |
||||||
52 | include_once XOOPS_TRUST_PATH . '/libs/altsys/language/' . $mylang . '/' . $type . '.php'; |
||||||
53 | } elseif (file_exists(XOOPS_ROOT_PATH . '/modules/altsys/language/english/' . $type . '.php')) { |
||||||
54 | include_once XOOPS_ROOT_PATH . '/modules/altsys/language/english/' . $type . '.php'; |
||||||
55 | } elseif (file_exists(XOOPS_TRUST_PATH . '/libs/altsys/language/english/' . $type . '.php')) { |
||||||
56 | include_once XOOPS_TRUST_PATH . '/libs/altsys/language/english/' . $type . '.php'; |
||||||
57 | } |
||||||
58 | } |
||||||
59 | |||||||
60 | define('ALTSYS_CORE_TYPE_X20', 1); // 2.0.0-2.0.13 and 2.0.x-JP |
||||||
61 | define('ALTSYS_CORE_TYPE_X20S', 2); // 2.0.14- from xoops.org Skalpa's "S" |
||||||
62 | define('ALTSYS_CORE_TYPE_ORE', 4); // ORETEKI by marijuana |
||||||
63 | define('ALTSYS_CORE_TYPE_X22', 8); // 2.2 from xoops.org |
||||||
64 | define('ALTSYS_CORE_TYPE_XC21L', 16); // XOOPS Cube 2.1 Legacy |
||||||
65 | |||||||
66 | /** |
||||||
67 | * @return int |
||||||
68 | */ |
||||||
69 | function altsys_get_core_type() |
||||||
70 | { |
||||||
71 | if (defined('XOOPS_ORETEKI')) { |
||||||
72 | return ALTSYS_CORE_TYPE_ORE; |
||||||
73 | } elseif (defined('XOOPS_CUBE_LEGACY')) { |
||||||
74 | return ALTSYS_CORE_TYPE_XC21L; |
||||||
75 | } elseif (strstr(XOOPS_VERSION, 'JP')) { |
||||||
76 | return ALTSYS_CORE_TYPE_X20; |
||||||
77 | } else { |
||||||
78 | $versions = array_map('intval', explode('.', preg_replace('/[^0-9.]/', '', XOOPS_VERSION))); |
||||||
79 | if ($versions[0] == 2 && $versions[1] == 2) { |
||||||
80 | return ALTSYS_CORE_TYPE_X22; |
||||||
81 | } elseif ($versions[0] == 2 && ($versions[1] > 2 || $versions[2] > 13)) { |
||||||
82 | return ALTSYS_CORE_TYPE_X20S; |
||||||
83 | } else { |
||||||
84 | return ALTSYS_CORE_TYPE_X20; |
||||||
85 | } |
||||||
86 | } |
||||||
87 | } |
||||||
88 | |||||||
89 | /** |
||||||
90 | * @param $mid |
||||||
91 | * @param $coretype |
||||||
92 | * @return null|string |
||||||
93 | */ |
||||||
94 | function altsys_get_link2modpreferences($mid, $coretype) |
||||||
95 | { |
||||||
96 | switch ($coretype) { |
||||||
97 | case ALTSYS_CORE_TYPE_X20: |
||||||
98 | case ALTSYS_CORE_TYPE_X20S: |
||||||
99 | case ALTSYS_CORE_TYPE_ORE: |
||||||
100 | case ALTSYS_CORE_TYPE_X22: |
||||||
101 | return XOOPS_URL . '/modules/system/admin.php?fct=preferences&op=showmod&mod=' . $mid; |
||||||
102 | case ALTSYS_CORE_TYPE_XC21L: |
||||||
103 | return XOOPS_URL . '/modules/legacy/admin/index.php?action=PreferenceEdit&confmod_id=' . $mid; |
||||||
104 | } |
||||||
105 | |||||||
106 | return null; |
||||||
107 | } |
||||||
108 | |||||||
109 | /** |
||||||
110 | * @param $tpl_id |
||||||
111 | */ |
||||||
112 | function altsys_template_touch($tpl_id) |
||||||
113 | { |
||||||
114 | if (altsys_get_core_type() == ALTSYS_CORE_TYPE_X20S) { |
||||||
115 | // need to delete all files under templates_c/ |
||||||
116 | altsys_clear_templates_c(); |
||||||
117 | } else { |
||||||
118 | // just touch the template |
||||||
119 | xoops_template_touch($tpl_id); |
||||||
120 | } |
||||||
121 | } |
||||||
122 | |||||||
123 | function altsys_clear_templates_c() |
||||||
124 | { |
||||||
125 | $dh = opendir(XOOPS_COMPILE_PATH); |
||||||
126 | while ($file = readdir($dh)) { |
||||||
0 ignored issues
–
show
It seems like
$dh can also be of type false ; however, parameter $dir_handle of readdir() does only seem to accept resource , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
127 | if (substr($file, 0, 1) === '.') { |
||||||
128 | continue; |
||||||
129 | } |
||||||
130 | if (substr($file, -4) !== '.php') { |
||||||
131 | continue; |
||||||
132 | } |
||||||
133 | @unlink(XOOPS_COMPILE_PATH . '/' . $file); |
||||||
0 ignored issues
–
show
It seems like you do not handle an error condition for
unlink() . This can introduce security issues, and is generally not recommended.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
If you suppress an error, we recommend checking for the error condition explicitly: // For example instead of
@mkdir($dir);
// Better use
if (@mkdir($dir) === false) {
throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
![]() |
|||||||
134 | } |
||||||
135 | closedir($dh); |
||||||
0 ignored issues
–
show
It seems like
$dh can also be of type false ; however, parameter $dir_handle of closedir() does only seem to accept resource , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
136 | } |
||||||
137 |