1 | <?php |
||
2 | /** |
||
3 | * System functions |
||
4 | * |
||
5 | * LICENSE |
||
6 | * |
||
7 | * You may not change or alter any portion of this comment or credits |
||
8 | * of supporting developers from this source code or any supporting source code |
||
9 | * which is considered copyrighted (c) material of the original comment or credit authors. |
||
10 | * |
||
11 | * @copyright (c) 2000-2016 XOOPS Project (www.xoops.org) |
||
12 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
13 | * @package system |
||
14 | */ |
||
15 | |||
16 | /** |
||
17 | * Get variables passed by GET or POST method |
||
18 | * |
||
19 | * Comment by Taiwen Jiang (a.k.a. phppp): THE METHOD IS NOT COMPLETE AND NOT SAFE. YOU ARE ENCOURAGED TO USE PHP'S NATIVE FILTER_VAR OR FILTER_INPUT FUNCTIONS DIRECTLY BEFORE WE MIGRATE TO XOOPS 3. |
||
20 | * @param $global |
||
21 | * @param $key |
||
22 | * @param string $default |
||
23 | * @param string $type |
||
24 | * @return int|mixed|string |
||
25 | * @deprecated since 2.5.11, please use Xmf\Request |
||
26 | */ |
||
27 | function system_CleanVars(&$global, $key, $default = '', $type = 'int') |
||
28 | { |
||
29 | $GLOBALS['xoopsLogger']->addDeprecated('Function ' . __FUNCTION__ . " is deprecated since XOOPS 2.5.11, please use 'Xmf\Request' instead"); |
||
30 | switch ($type) { |
||
31 | case 'array': |
||
32 | $ret = (isset($global[$key]) && \is_array($global[$key])) ? $global[$key] : $default; |
||
33 | break; |
||
34 | case 'date': |
||
35 | $ret = isset($global[$key]) ? strtotime($global[$key]) : $default; |
||
36 | break; |
||
37 | case 'string': |
||
38 | $ret = isset($global[$key]) ? Xmf\FilterInput::clean($global[$key], 'STRING') : $default; |
||
39 | break; |
||
40 | case 'int': |
||
41 | default: |
||
42 | $ret = isset($global[$key]) ? filter_var($global[$key], FILTER_SANITIZE_NUMBER_INT) : $default; |
||
43 | break; |
||
44 | } |
||
45 | if ($ret === false) { |
||
46 | return $default; |
||
47 | } |
||
48 | |||
49 | return $ret; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * System language loader wrapper |
||
54 | * |
||
55 | * |
||
56 | * @param string $name Name of language file to be loaded, without extension |
||
57 | * @param string $domain Module dirname; global language file will be loaded if $domain is set to 'global' or not specified |
||
58 | * @param string $language Language to be loaded, current language content will be loaded if not specified |
||
59 | * @return boolean |
||
60 | * @todo expand domain to multiple categories, e.g. module:system, framework:filter, etc. |
||
61 | * |
||
62 | */ |
||
63 | function system_loadLanguage($name, $domain = '', $language = null) |
||
64 | { |
||
65 | /** |
||
66 | * We must check later for an empty value. As xoops_getPageOption could be empty |
||
67 | */ |
||
68 | if (empty($name)) { |
||
69 | return false; |
||
70 | } |
||
71 | $language = empty($language) ? $GLOBALS['xoopsConfig']['language'] : $language; |
||
72 | $path = 'modules/' . $domain . '/language/'; |
||
73 | if (file_exists($file = $GLOBALS['xoops']->path($path . $language . '/admin/' . $name . '.php'))) { |
||
74 | $ret = include_once $file; |
||
75 | } else { |
||
76 | $ret = include_once $GLOBALS['xoops']->path($path . 'english/admin/' . $name . '.php'); |
||
77 | } |
||
78 | |||
79 | return $ret; |
||
80 | } |
||
81 | |||
82 | /** |
||
83 | * @param $version |
||
84 | * @param string $value |
||
85 | * |
||
86 | * @return mixed |
||
87 | */ |
||
88 | function system_adminVersion($version, $value = '') |
||
89 | { |
||
90 | static $tblVersion = array(); |
||
91 | if (is_array($tblVersion) && array_key_exists($version . '.' . $value, $tblVersion)) { |
||
92 | return $tblVersion[$version . '.' . $value]; |
||
93 | } |
||
94 | $path = XOOPS_ROOT_PATH . '/modules/system/admin/' . $version . '/xoops_version.php'; |
||
95 | if (file_exists($path)) { |
||
96 | include $path; |
||
97 | |||
98 | $retvalue = $modversion[$value]; |
||
99 | $tblVersion[$version . '.' . $value] = $retvalue; |
||
100 | |||
101 | return $retvalue; |
||
102 | } |
||
103 | |||
104 | return null; |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * @param $img |
||
109 | * |
||
110 | * @return mixed |
||
111 | */ |
||
112 | function system_AdminIcons($img) |
||
113 | { |
||
114 | $style = xoops_getModuleOption('typeicons', 'system'); |
||
0 ignored issues
–
show
Deprecated Code
introduced
by
Loading history...
|
|||
115 | if ($style == '') { |
||
116 | $style = 'default'; |
||
117 | } |
||
118 | |||
119 | $url = $GLOBALS['xoops']->url('modules/system/images/icons/' . $style . '/' . $img); |
||
120 | |||
121 | return $url; |
||
122 | } |
||
123 | |||
124 | /** |
||
125 | * @param $name |
||
126 | */ |
||
127 | function system_loadTemplate($name) |
||
128 | { |
||
129 | global $sysTpl, $xoopsModule; |
||
130 | |||
131 | $path = XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname', 'n') . '/templates/admin/' . $name . '.tpl'; |
||
132 | if (file_exists($path)) { |
||
133 | echo $sysTpl->fetch($path); |
||
134 | } else { |
||
135 | echo 'Unable to read ' . $name; |
||
136 | } |
||
137 | } |
||
138 | |||
139 | /** |
||
140 | * @param $value_chmod |
||
141 | * @param $path_file |
||
142 | * @param $id |
||
143 | * |
||
144 | * @return string |
||
145 | */ |
||
146 | function modify_chmod($value_chmod, $path_file, $id) |
||
147 | { |
||
148 | $chmod = '<div id="loading_' . $id . '" align="center" style="display:none;">' . '<img src="./images/mimetypes/spinner.gif" title="Loading" alt="Loading" width="12px"/></div>' . '<div id="chmod' . $id . '">' . '<select size="1" onChange="filemanager_modify_chmod(\'' . $path_file . '\', \'' . $id . '\')" name="chmod" id="chmod">'; |
||
149 | if ($value_chmod == 777) { |
||
150 | $chmod .= '<option value="777" selected><span style="color:green;">777</span></option>'; |
||
151 | } else { |
||
152 | $chmod .= '<option value="777"><span style="color:green;">777</span></option>'; |
||
153 | } |
||
154 | |||
155 | if ($value_chmod == 776) { |
||
156 | $chmod .= '<option value="776" selected>776</option>'; |
||
157 | } else { |
||
158 | $chmod .= '<option value="776">776</option>'; |
||
159 | } |
||
160 | |||
161 | if ($value_chmod == 766) { |
||
162 | $chmod .= '<option value="766" selected>766</option>'; |
||
163 | } else { |
||
164 | $chmod .= '<option value="766">766</option>'; |
||
165 | } |
||
166 | |||
167 | if ($value_chmod == 666) { |
||
168 | $chmod .= '<option value="666" selected>666</option>'; |
||
169 | } else { |
||
170 | $chmod .= '<option value="666">666</option>'; |
||
171 | } |
||
172 | |||
173 | if ($value_chmod == 664) { |
||
174 | $chmod .= '<option value="664" selected>664</option>'; |
||
175 | } else { |
||
176 | $chmod .= '<option value="664">664</option>'; |
||
177 | } |
||
178 | |||
179 | if ($value_chmod == 644) { |
||
180 | $chmod .= '<option value="644" selected>644</option>'; |
||
181 | } else { |
||
182 | $chmod .= '<option value="644">644</option>'; |
||
183 | } |
||
184 | |||
185 | if ($value_chmod == 444) { |
||
186 | $chmod .= '<option value="444" selected><span style="color:red;">444</span></option>'; |
||
187 | } else { |
||
188 | $chmod .= '<option value="444">444</option>'; |
||
189 | } |
||
190 | |||
191 | if ($value_chmod == 440) { |
||
192 | $chmod .= '<option value="440" selected>440</option>'; |
||
193 | } else { |
||
194 | $chmod .= '<option value="440">440</option>'; |
||
195 | } |
||
196 | |||
197 | if ($value_chmod == 400) { |
||
198 | $chmod .= '<option value="400" selected>400</option>'; |
||
199 | } else { |
||
200 | $chmod .= '<option value="400">400</option>'; |
||
201 | } |
||
202 | $chmod .= '</select>'; |
||
203 | |||
204 | return $chmod; |
||
205 | } |
||
206 |