This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||||||
2 | |||||||
3 | declare(strict_types=1); |
||||||
4 | |||||||
5 | /* |
||||||
6 | You may not change or alter any portion of this comment or credits |
||||||
7 | of supporting developers from this source code or any supporting source code |
||||||
8 | which is considered copyrighted (c) material of the original comment or credit authors. |
||||||
9 | |||||||
10 | This program is distributed in the hope that it will be useful, |
||||||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
||||||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
||||||
13 | */ |
||||||
14 | |||||||
15 | /** |
||||||
16 | * wgFileManager module for xoops |
||||||
17 | * |
||||||
18 | * @copyright 2021 XOOPS Project (https://xoops.org) |
||||||
19 | * @license GPL 2.0 or later |
||||||
20 | * @package wgfilemanager |
||||||
21 | * @author Goffy - Wedega - Email:[email protected] - Website:https://xoops.wedega.com |
||||||
22 | */ |
||||||
23 | |||||||
24 | use Xmf\Request; |
||||||
0 ignored issues
–
show
|
|||||||
25 | use XoopsModules\Wgfilemanager; |
||||||
26 | use XoopsModules\Wgfilemanager\Constants; |
||||||
27 | use XoopsModules\Wgfilemanager\Common; |
||||||
28 | |||||||
29 | require __DIR__ . '/header.php'; |
||||||
30 | $GLOBALS['xoopsOption']['template_main'] = 'wgfilemanager_directory.tpl'; |
||||||
31 | require_once \XOOPS_ROOT_PATH . '/header.php'; |
||||||
32 | |||||||
33 | $op = Request::getCmd('op', 'list'); |
||||||
34 | $dirId = Request::getInt('id'); |
||||||
35 | $parentId = Request::getInt('parent_id'); |
||||||
36 | $start = Request::getInt('start'); |
||||||
37 | $limit = Request::getInt('limit', $helper->getConfig('userpager')); |
||||||
38 | $GLOBALS['xoopsTpl']->assign('start', $start); |
||||||
39 | $GLOBALS['xoopsTpl']->assign('limit', $limit); |
||||||
40 | |||||||
41 | // Define Stylesheet |
||||||
42 | foreach ($styles as $style) { |
||||||
43 | $GLOBALS['xoTheme']->addStylesheet($style, null); |
||||||
44 | } |
||||||
45 | $GLOBALS['xoTheme']->addStylesheet(\WGFILEMANAGER_URL . '/assets/css/default.css'); |
||||||
46 | // Paths |
||||||
47 | $GLOBALS['xoopsTpl']->assign('xoops_icons32_url', \XOOPS_ICONS32_URL); |
||||||
48 | $GLOBALS['xoopsTpl']->assign('wgfilemanager_url', \WGFILEMANAGER_URL); |
||||||
49 | // Keywords |
||||||
50 | $keywords = []; |
||||||
51 | // Breadcrumbs |
||||||
52 | $xoBreadcrumbs[] = ['title' => \_MA_WGFILEMANAGER_INDEX, 'link' => 'index.php']; |
||||||
53 | // Permissions |
||||||
54 | $permCreate = $permissionsHandler->getPermSubmitDirectory($parentId); |
||||||
55 | $permEdit = $permissionsHandler->getPermSubmitDirectory($dirId); |
||||||
56 | $GLOBALS['xoopsTpl']->assign('permCreate', $permCreate); |
||||||
57 | $GLOBALS['xoopsTpl']->assign('permEdit', $permEdit); |
||||||
58 | |||||||
59 | $GLOBALS['xoopsTpl']->assign('showItem', $dirId > 0); |
||||||
60 | |||||||
61 | switch ($op) { |
||||||
62 | case 'list': |
||||||
63 | default: |
||||||
64 | // Breadcrumbs |
||||||
65 | $xoBreadcrumbs[] = ['title' => \_MA_WGFILEMANAGER_DIRECTORY_LIST]; |
||||||
66 | $dirList = $directoryHandler->getDirList(0, $dirId); |
||||||
67 | $GLOBALS['xoopsTpl']->assign('directoryCount', \count($dirList)); |
||||||
68 | $GLOBALS['xoopsTpl']->assign('directory_list', $dirList); |
||||||
69 | $GLOBALS['xoopsTpl']->assign('table_type', $helper->getConfig('table_type')); |
||||||
70 | $GLOBALS['xoopsTpl']->assign('panel_type', $helper->getConfig('panel_type')); |
||||||
71 | $GLOBALS['xoopsTpl']->assign('wgfilemanager_icon_bi_url', \WGFILEMANAGER_ICONS_URL . '/bootstrap/'); |
||||||
72 | |||||||
73 | $directoryStyle = $helper->getConfig('directorystyle'); |
||||||
74 | if ('sortable' === $directoryStyle) { |
||||||
75 | $GLOBALS['xoTheme']->addScript(\WGFILEMANAGER_URL . '/assets/js/jquery-ui.min.js'); |
||||||
76 | $GLOBALS['xoTheme']->addScript(\WGFILEMANAGER_URL . '/assets/js/sortable.js'); |
||||||
77 | $GLOBALS['xoTheme']->addScript(\WGFILEMANAGER_URL . '/assets/js/jquery.mjs.nestedSortable.js'); |
||||||
78 | $GLOBALS['xoTheme']->addStylesheet(\WGFILEMANAGER_URL . '/assets/css/nestedsortable.css'); |
||||||
79 | $GLOBALS['xoTheme']->addStylesheet(\WGFILEMANAGER_URL . '/assets/css/sortabledir.css'); |
||||||
80 | } |
||||||
81 | $GLOBALS['xoopsTpl']->assign('directoryStyle', $directoryStyle); |
||||||
82 | break; |
||||||
83 | case 'save': |
||||||
84 | // Security Check |
||||||
85 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
86 | \redirect_header('directory.php', 3, \implode(',', $GLOBALS['xoopsSecurity']->getErrors())); |
||||||
87 | } |
||||||
88 | // Check permissions |
||||||
89 | if (!$permissionsHandler->getPermGlobalSubmit()) { |
||||||
90 | \redirect_header('directory.php?op=list', 3, \_NOPERM); |
||||||
91 | } |
||||||
92 | if ($dirId > 0) { |
||||||
93 | $directoryObj = $directoryHandler->get($dirId); |
||||||
94 | } else { |
||||||
95 | $directoryObj = $directoryHandler->create(); |
||||||
96 | } |
||||||
97 | $dirParentId = Request::getInt('parent_id'); |
||||||
98 | $dirParentIdOld = Request::getInt('parent_id_old'); |
||||||
99 | $dirName = Request::getString('name'); |
||||||
100 | $dirNameOld = Request::getString('name_old'); |
||||||
101 | $dirDescription = Request::getText('description'); |
||||||
102 | $dirWeight = Request::getInt('weight'); |
||||||
103 | $moveDir = false; |
||||||
104 | $renameDir = false; |
||||||
105 | if ($dirId > 1) { |
||||||
106 | $moveDir = $dirParentId !== $dirParentIdOld; |
||||||
107 | $renameDir = $dirName !== $dirNameOld; |
||||||
108 | } |
||||||
109 | // get full path |
||||||
110 | $dirBasePath = '/'; |
||||||
111 | $dirFullPath = $dirBasePath; |
||||||
112 | if ($dirParentId > 0) { |
||||||
113 | $path = $directoryHandler->getFullPath($dirParentId); |
||||||
114 | if ('' !== $path) { |
||||||
115 | $dirBasePath .= $path . '/'; |
||||||
116 | } |
||||||
117 | $dirFullPath = $dirBasePath . \mb_strtolower($dirName); |
||||||
118 | } |
||||||
119 | $dirFullPathOld = ''; |
||||||
120 | if ($moveDir) { |
||||||
121 | $dirBasePathOld = '/'; |
||||||
122 | if ($dirParentIdOld > 1) { |
||||||
123 | $dirBasePathOld .= $directoryHandler->getFullPath($dirParentIdOld); |
||||||
124 | $dirBasePathOld .= '/'; |
||||||
125 | } |
||||||
126 | $dirFullPathOld = $dirBasePathOld . \mb_strtolower($dirNameOld); |
||||||
127 | } |
||||||
128 | //check whether directory exist |
||||||
129 | $dirExists = $directoryHandler->existDirectory($dirFullPath); |
||||||
130 | //if new or move dir or rename dir then check that folder doesn't exist |
||||||
131 | if ((0 === $dirId || $moveDir || $renameDir) && $dirExists) { |
||||||
132 | $templateMain = 'wgfilemanager_admin_directory.tpl'; |
||||||
133 | $directoryObj->setVar('parent_id', $dirParentId); |
||||||
134 | $directoryObj->setVar('name', $dirName); |
||||||
135 | $directoryObj->setVar('description', $dirDescription); |
||||||
136 | $directoryObj->setVar('weight', $dirWeight); |
||||||
137 | $form = $directoryObj->getForm(); |
||||||
138 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
139 | $GLOBALS['xoopsTpl']->assign('error', \_MA_WGFILEMANAGER_DIRECTORY_ERROR_EXISTS); |
||||||
140 | } else { |
||||||
141 | // Set Vars |
||||||
142 | $directoryObj->setVar('parent_id', $dirParentId); |
||||||
143 | $directoryObj->setVar('name', $dirName); |
||||||
144 | $directoryObj->setVar('description', $dirDescription); |
||||||
145 | $directoryObj->setVar('fullpath', $dirFullPath); |
||||||
146 | $directoryObj->setVar('weight', $dirWeight); |
||||||
147 | $directoryDate_createdObj = \DateTime::createFromFormat(\_SHORTDATESTRING, Request::getString('date_created')); |
||||||
148 | $directoryObj->setVar('date_created', $directoryDate_createdObj->getTimestamp()); |
||||||
149 | $directoryObj->setVar('submitter', Request::getInt('submitter')); |
||||||
150 | // Insert Data |
||||||
151 | if ($directoryHandler->insert($directoryObj)) { |
||||||
152 | if ($moveDir) { |
||||||
153 | $directoryHandler->moveDirectory($dirFullPathOld, $dirFullPath); |
||||||
154 | } else if ($renameDir) { |
||||||
155 | $directoryHandler->renameDirectory($dirBasePath . $dirNameOld, $dirFullPath); |
||||||
156 | } else if (!$dirExists) { |
||||||
157 | $directoryHandler->createDirectory($dirFullPath); |
||||||
158 | } |
||||||
159 | if ('directory' === $helper->getConfig('permission_type')) { |
||||||
160 | $newDirId = $directoryObj->getNewInsertedId(); |
||||||
161 | $permId = isset($_REQUEST['id']) ? $dirId : $newDirId; |
||||||
162 | $grouppermHandler = \xoops_getHandler('groupperm'); |
||||||
163 | $mid = $GLOBALS['xoopsModule']->getVar('mid'); |
||||||
164 | // Permission to view_directory |
||||||
165 | $grouppermHandler->deleteByModule($mid, 'wgfilemanager_view_directory', $permId); |
||||||
0 ignored issues
–
show
The method
deleteByModule() does not exist on XoopsObjectHandler . Did you maybe mean delete() ?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces. This is most likely a typographical error or the method has been renamed. ![]() |
|||||||
166 | if (isset($_POST['groups_view_directory'])) { |
||||||
167 | foreach ($_POST['groups_view_directory'] as $onegroupId) { |
||||||
168 | $grouppermHandler->addRight('wgfilemanager_view_directory', $permId, $onegroupId, $mid); |
||||||
0 ignored issues
–
show
The method
addRight() does not exist on XoopsObjectHandler . It seems like you code against a sub-type of XoopsObjectHandler such as XoopsGroupPermHandler or XoopsPersistableObjectHandler .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
169 | } |
||||||
170 | } |
||||||
171 | // Permission to submit_directory |
||||||
172 | $grouppermHandler->deleteByModule($mid, 'wgfilemanager_submit_directory', $permId); |
||||||
173 | if (isset($_POST['groups_submit_directory'])) { |
||||||
174 | foreach ($_POST['groups_submit_directory'] as $onegroupId) { |
||||||
175 | $grouppermHandler->addRight('wgfilemanager_submit_directory', $permId, $onegroupId, $mid); |
||||||
176 | } |
||||||
177 | } |
||||||
178 | // Permission to approve_directory |
||||||
179 | $grouppermHandler->deleteByModule($mid, 'wgfilemanager_approve_directory', $permId); |
||||||
180 | if (isset($_POST['groups_approve_directory'])) { |
||||||
181 | foreach ($_POST['groups_approve_directory'] as $onegroupId) { |
||||||
182 | $grouppermHandler->addRight('wgfilemanager_approve_directory', $permId, $onegroupId, $mid); |
||||||
183 | } |
||||||
184 | } |
||||||
185 | } |
||||||
186 | $directoryHandler->setDirWeight($dirParentId); |
||||||
187 | \redirect_header('directory.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGFILEMANAGER_FORM_OK); |
||||||
188 | } |
||||||
189 | $GLOBALS['xoopsTpl']->assign('error', $directoryObj->getHtmlErrors()); |
||||||
190 | } |
||||||
191 | break; |
||||||
192 | case 'new': |
||||||
193 | // Breadcrumbs |
||||||
194 | $xoBreadcrumbs[] = ['title' => \_MA_WGFILEMANAGER_DIRECTORY_ADD]; |
||||||
195 | // Check permissions |
||||||
196 | if (!$permissionsHandler->getPermGlobalSubmit()) { |
||||||
197 | \redirect_header('directory.php?op=list', 3, \_NOPERM); |
||||||
198 | } |
||||||
199 | // Form Create |
||||||
200 | $directoryObj = $directoryHandler->create(); |
||||||
201 | $directoryObj->setVar('parent_id', $parentId); |
||||||
202 | $form = $directoryObj->getForm(); |
||||||
203 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
204 | break; |
||||||
205 | case 'edit': |
||||||
206 | // Breadcrumbs |
||||||
207 | $xoBreadcrumbs[] = ['title' => \_MA_WGFILEMANAGER_DIRECTORY_EDIT]; |
||||||
208 | // Check permissions |
||||||
209 | if (!$permissionsHandler->getPermGlobalSubmit()) { |
||||||
210 | \redirect_header('directory.php?op=list', 3, \_NOPERM); |
||||||
211 | } |
||||||
212 | // Check params |
||||||
213 | if (0 === $dirId) { |
||||||
214 | \redirect_header('directory.php?op=list', 3, \_MA_WGFILEMANAGER_INVALID_PARAM); |
||||||
215 | } |
||||||
216 | // Get Form |
||||||
217 | $directoryObj = $directoryHandler->get($dirId); |
||||||
218 | $directoryObj->start = $start; |
||||||
219 | $directoryObj->limit = $limit; |
||||||
220 | $form = $directoryObj->getForm(); |
||||||
221 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
222 | break; |
||||||
223 | case 'clone': |
||||||
224 | // Breadcrumbs |
||||||
225 | $xoBreadcrumbs[] = ['title' => \_MA_WGFILEMANAGER_DIRECTORY_CLONE]; |
||||||
226 | // Check permissions |
||||||
227 | if (!$permissionsHandler->getPermGlobalSubmit()) { |
||||||
228 | \redirect_header('directory.php?op=list', 3, \_NOPERM); |
||||||
229 | } |
||||||
230 | // Request source |
||||||
231 | $dirIdSource = Request::getInt('id_source'); |
||||||
232 | // Check params |
||||||
233 | if (0 === $dirIdSource) { |
||||||
234 | \redirect_header('directory.php?op=list', 3, \_MA_WGFILEMANAGER_INVALID_PARAM); |
||||||
235 | } |
||||||
236 | // Get Form |
||||||
237 | $directoryObjSource = $directoryHandler->get($dirIdSource); |
||||||
238 | $directoryObj = $directoryObjSource->xoopsClone(); |
||||||
239 | $form = $directoryObj->getForm(); |
||||||
240 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
241 | break; |
||||||
242 | case 'delete': |
||||||
243 | // Breadcrumbs |
||||||
244 | $xoBreadcrumbs[] = ['title' => \_MA_WGFILEMANAGER_DIRECTORY_DELETE]; |
||||||
245 | // Check permissions |
||||||
246 | if (!$permissionsHandler->getPermGlobalSubmit()) { |
||||||
247 | \redirect_header('directory.php?op=list', 3, \_NOPERM); |
||||||
248 | } |
||||||
249 | // Check params |
||||||
250 | if (0 === $dirId) { |
||||||
251 | \redirect_header('directory.php?op=list', 3, \_MA_WGFILEMANAGER_INVALID_PARAM); |
||||||
252 | } |
||||||
253 | $directoryObj = $directoryHandler->get($dirId); |
||||||
254 | $dirName = $directoryObj->getVar('name'); |
||||||
255 | if (isset($_REQUEST['ok']) && 1 == $_REQUEST['ok']) { |
||||||
256 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||||||
257 | \redirect_header('directory.php', 3, \implode(', ', $GLOBALS['xoopsSecurity']->getErrors())); |
||||||
258 | } |
||||||
259 | $dirFullPath = $directoryObj->getVar('fullpath'); |
||||||
260 | if ($directoryHandler->delete($directoryObj)) { |
||||||
261 | if ($directoryHandler->deleteDirectory($dirFullPath)) { |
||||||
262 | if ($directoryHandler->deleteSubDirData($dirId)) { |
||||||
263 | \redirect_header('directory.php', 3, \_AM_WGFILEMANAGER_FORM_DELETE_OK); |
||||||
264 | } else { |
||||||
265 | \redirect_header('directory.php', 3, \_MA_WGFILEMANAGER_DIRECTORY_ERROR_DELETE_SUBDIRDATA); |
||||||
266 | } |
||||||
267 | } else { |
||||||
268 | \redirect_header('directory.php', 3, \_MA_WGFILEMANAGER_DIRECTORY_ERROR_DELETE); |
||||||
269 | } |
||||||
270 | |||||||
271 | } else { |
||||||
272 | $GLOBALS['xoopsTpl']->assign('error', $directoryObj->getHtmlErrors()); |
||||||
273 | } |
||||||
274 | } else { |
||||||
275 | $confirmText = \sprintf(\_MA_WGFILEMANAGER_DIRECTORY_DELETE_SINGLE, $dirName); |
||||||
276 | if ($directoryHandler->dirIsParent($dirId)) { |
||||||
277 | $confirmText .= \sprintf(\_MA_WGFILEMANAGER_DIRECTORY_DELETE_ISPARENT, $dirName); |
||||||
278 | } |
||||||
279 | $customConfirm = new Common\Confirm( |
||||||
280 | ['ok' => 1, 'id' => $dirId, 'start' => $start, 'limit' => $limit, 'op' => 'delete'], |
||||||
281 | $_SERVER['REQUEST_URI'], |
||||||
282 | $confirmText); |
||||||
283 | $form = $customConfirm->getFormConfirm(); |
||||||
284 | $GLOBALS['xoopsTpl']->assign('form', $form->render()); |
||||||
285 | } |
||||||
286 | break; |
||||||
287 | case 'favorite_pin': |
||||||
288 | //check perms |
||||||
289 | if (!$permissionsHandler->getPermGlobalSubmit()) { |
||||||
290 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||||
291 | } |
||||||
292 | // Check params |
||||||
293 | if (0 === $dirId) { |
||||||
294 | \redirect_header('index.php?op=list', 3, \_MA_WGFILEMANAGER_INVALID_PARAM); |
||||||
295 | } |
||||||
296 | //get current user |
||||||
297 | $userUid = 0; |
||||||
298 | if (isset($GLOBALS['xoopsUser']) && \is_object($GLOBALS['xoopsUser'])) { |
||||||
299 | $userUid = $GLOBALS['xoopsUser']->uid(); |
||||||
300 | } |
||||||
301 | if (0 === $userUid) { |
||||||
302 | \redirect_header('index.php?op=list', 3, \_MA_WGFILEMANAGER_INVALID_PARAM); |
||||||
303 | } |
||||||
304 | $favoriteObj = $favoriteHandler->create(); |
||||||
305 | $favoriteObj->setVar('directory_id', $dirId); |
||||||
306 | $favoriteObj->setVar('date_created', \time()); |
||||||
307 | $favoriteObj->setVar('submitter', $userUid); |
||||||
308 | if ($favoriteHandler->insert($favoriteObj)) { |
||||||
309 | \redirect_header('index.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGFILEMANAGER_FORM_OK); |
||||||
310 | } else { |
||||||
311 | \redirect_header('index.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGFILEMANAGER_FAVORITE_ERROR_SET); |
||||||
312 | } |
||||||
313 | break; |
||||||
314 | case 'favorite_unpin': |
||||||
315 | //check perms |
||||||
316 | if (!$permissionsHandler->getPermGlobalSubmit()) { |
||||||
317 | \redirect_header('index.php?op=list', 3, \_NOPERM); |
||||||
318 | } |
||||||
319 | // Check params |
||||||
320 | if (0 === $dirId) { |
||||||
321 | \redirect_header('index.php?op=list', 3, \_MA_WGFILEMANAGER_INVALID_PARAM); |
||||||
322 | } |
||||||
323 | $favoriteId = Request::getInt('favorite_id'); |
||||||
324 | if (0 === $favoriteId) { |
||||||
325 | \redirect_header('index.php?op=list', 3, \_MA_WGFILEMANAGER_INVALID_PARAM); |
||||||
326 | } |
||||||
327 | $favoriteObj = $favoriteHandler->get($favoriteId); |
||||||
328 | if ($favoriteHandler->delete($favoriteObj, true)) { |
||||||
329 | \redirect_header('index.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_AM_WGFILEMANAGER_FORM_OK); |
||||||
330 | } else { |
||||||
331 | \redirect_header('index.php?op=list&start=' . $start . '&limit=' . $limit, 2, \_MA_WGFILEMANAGER_FAVORITE_ERROR_SET); |
||||||
332 | } |
||||||
333 | break; |
||||||
334 | /* case 'order': |
||||||
335 | $aorder = Request::getArray('menuItem'); |
||||||
336 | $i = 0; |
||||||
337 | $moveDir = false; |
||||||
338 | $moveDirId = 0; |
||||||
339 | $dirExists = false; |
||||||
340 | $dirFullPath = ''; |
||||||
341 | $dirFullPathOld = ''; |
||||||
342 | // first check folders |
||||||
343 | foreach (\array_keys($aorder) as $key) { |
||||||
344 | $dirParentId = (int)$aorder[$key]; |
||||||
345 | $directoryObj = $directoryHandler->get($key); |
||||||
346 | $dirName = $directoryObj->getVar('name'); |
||||||
347 | $dirParentIdOld = $directoryObj->getVar('parent_id'); |
||||||
348 | // check whether folder is moved to other parent |
||||||
349 | $moveDir = ($dirParentIdOld !== $dirParentId); |
||||||
350 | if ($moveDir) { |
||||||
351 | $moveDirId = $key; |
||||||
352 | $dirFullPathOld = $directoryObj->getVar('fullpath'); |
||||||
353 | $directoryObjNew = $directoryHandler->get($dirParentId); |
||||||
354 | $dirFullPath = ''; |
||||||
355 | if ($dirParentId > 0) { |
||||||
356 | $dirFullPath .= $directoryObjNew->getVar('fullpath'); |
||||||
357 | } |
||||||
358 | if (!\str_ends_with($dirFullPath, '/')) { |
||||||
359 | $dirFullPath .= '/'; |
||||||
360 | } |
||||||
361 | $dirFullPath .= \mb_strtolower($dirName); |
||||||
362 | //check whether directory exist |
||||||
363 | $dirExists = $directoryHandler->existDirectory($dirFullPath); |
||||||
364 | } |
||||||
365 | unset($directoryObj); |
||||||
366 | } |
||||||
367 | if ($dirExists) { |
||||||
368 | XoopsLoad::load('xoopslogger'); |
||||||
369 | $xoopsLogger = XoopsLogger::getInstance(); |
||||||
370 | $xoopsLogger->activated = false; |
||||||
371 | header('Content-Type: application/json'); |
||||||
372 | echo json_encode(['status'=>'error','message'=>\_MA_WGFILEMANAGER_DIRECTORY_ERROR_EXISTS_JS]); |
||||||
373 | die; |
||||||
374 | } else { |
||||||
375 | // if no troubles save data and move folder if necessary |
||||||
376 | foreach (\array_keys($aorder) as $key) { |
||||||
377 | $dirParentId = (int)$aorder[$key]; |
||||||
378 | $directoryObj = $directoryHandler->get($key); |
||||||
379 | $dirName = $directoryObj->getVar('name'); |
||||||
380 | $directoryObj->setVar('parent_id', $dirParentId); |
||||||
381 | if ($moveDirId > 0 && $moveDirId == $key) { |
||||||
382 | $directoryObj->setVar('fullpath', $dirFullPath); |
||||||
383 | $directoryHandler->moveDirectory($dirFullPathOld, $dirFullPath); |
||||||
384 | } |
||||||
385 | $directoryObj->setVar('weight', $i + 1); |
||||||
386 | $directoryHandler->insert($directoryObj); |
||||||
387 | unset($directoryObj); |
||||||
388 | $i++; |
||||||
389 | } |
||||||
390 | } |
||||||
391 | |||||||
392 | break;*/ |
||||||
393 | } |
||||||
394 | |||||||
395 | // Keywords |
||||||
396 | wgfilemanagerMetaKeywords($helper->getConfig('keywords') . ', ' . \implode(',', $keywords)); |
||||||
397 | unset($keywords); |
||||||
398 | |||||||
399 | $GLOBALS['xoopsTpl']->assign('xoops_mpageurl', \WGFILEMANAGER_URL.'/directory.php'); |
||||||
400 | $GLOBALS['xoopsTpl']->assign('wgfilemanager_upload_url', \WGFILEMANAGER_UPLOAD_URL); |
||||||
401 | |||||||
402 | require __DIR__ . '/footer.php'; |
||||||
403 | |||||||
404 |
Let?s assume that you have a directory layout like this:
and let?s assume the following content of
Bar.php
:If both files
OtherDir/Foo.php
andSomeDir/Foo.php
are loaded in the same runtime, you will see a PHP error such as the following:PHP Fatal error: Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php
However, as
OtherDir/Foo.php
does not necessarily have to be loaded and the error is only triggered if it is loaded beforeOtherDir/Bar.php
, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias: