XoopsModules25x /
suico
| 1 | <?php declare(strict_types=1); |
||
| 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 | /** |
||
| 13 | * @category Module |
||
| 14 | * @copyright {@link https://xoops.org/ XOOPS Project} |
||
| 15 | * @license GNU GPL 2.0 or later (https://www.gnu.org/licenses/gpl-2.0.html) |
||
| 16 | * @author Marcello Brandão aka Suico, Mamba, LioMJ <https://xoops.org> |
||
| 17 | */ |
||
| 18 | |||
| 19 | use Xmf\Request; |
||
|
0 ignored issues
–
show
|
|||
| 20 | use XoopsModules\Suico\{ |
||
| 21 | NotesHandler |
||
| 22 | }; |
||
| 23 | |||
| 24 | require __DIR__ . '/header.php'; |
||
| 25 | /** |
||
| 26 | * Modules class includes |
||
| 27 | */ |
||
| 28 | //require_once __DIR__ . '/class/Notes.php'; |
||
| 29 | /** |
||
| 30 | * Factories of groups |
||
| 31 | */ |
||
| 32 | $notesFactory = new NotesHandler($xoopsDB); |
||
| 33 | /** |
||
| 34 | * Verify Token |
||
| 35 | */ |
||
| 36 | if (!$GLOBALS['xoopsSecurity']->check()) { |
||
| 37 | redirect_header(Request::getString('HTTP_REFERER', '', 'SERVER'), 3, _MD_SUICO_TOKENEXPIRED); |
||
| 38 | } |
||
| 39 | $myts = \MyTextSanitizer::getInstance(); |
||
| 40 | $notebook_uid = Request::getInt('uid', 0, 'POST'); |
||
| 41 | $noteText = $myts->displayTarea(Request::getText('text', '', 'POST'), 0, 1, 1, 1, 1); |
||
| 42 | $mainform = !empty($_POST['mainform']) ? 1 : 0; |
||
| 43 | $noteObj = $notesFactory->create(); |
||
| 44 | $noteObj->setVar('note_text', $noteText); |
||
| 45 | $noteObj->setVar('note_from', $xoopsUser->getVar('uid')); |
||
| 46 | $noteObj->setVar('note_to', $notebook_uid); |
||
| 47 | $noteObj->setVar('date_created', time()); |
||
| 48 | $notesFactory->insert2($noteObj); |
||
| 49 | $noteId = $xoopsDB->getInsertId(); |
||
| 50 | $extra_tags['X_OWNER_NAME'] = $xoopsUser::getUnameFromId($notebook_uid); |
||
| 51 | $extra_tags['X_OWNER_UID'] = $notebook_uid; |
||
| 52 | /** @var \XoopsNotificationHandler $notificationHandler */ |
||
| 53 | $notificationHandler = xoops_getHandler('notification'); |
||
| 54 | $notificationHandler->triggerEvent('Note', $xoopsUser->getVar('uid'), 'new_Note', $extra_tags); |
||
| 55 | if (1 == $mainform) { |
||
| 56 | redirect_header('notebook.php?uid=' . $notebook_uid . '#' . $noteId, 1, _MD_SUICO_NOTE_SENT); |
||
| 57 | } else { |
||
| 58 | redirect_header('notebook.php?uid=' . $xoopsUser->getVar('uid'), 1, _MD_SUICO_NOTE_SENT); |
||
| 59 | } |
||
| 60 | /** |
||
| 61 | * Close page |
||
| 62 | */ |
||
| 63 | require \dirname(__DIR__, 2) . '/footer.php'; |
||
| 64 |
Let?s assume that you have a directory layout like this:
. |-- OtherDir | |-- Bar.php | `-- Foo.php `-- SomeDir `-- Foo.phpand let?s assume the following content of
Bar.php:If both files
OtherDir/Foo.phpandSomeDir/Foo.phpare 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.phpHowever, as
OtherDir/Foo.phpdoes 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: