|
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
|
|
|
* @copyright {@link https://xoops.org/ XOOPS Project} |
|
14
|
|
|
* @license {@link https://www.gnu.org/licenses/gpl-2.0.html GNU GPL 2 or later} |
|
15
|
|
|
* @author XOOPS Development Team |
|
16
|
|
|
*/ |
|
17
|
|
|
|
|
18
|
|
|
use Xmf\Request; |
|
|
|
|
|
|
19
|
|
|
use XoopsModules\News; |
|
20
|
|
|
use XoopsModules\News\NewsStory; |
|
21
|
|
|
|
|
22
|
|
|
require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
|
23
|
|
|
|
|
24
|
|
|
/** @var News\Helper $helper */ |
|
25
|
|
|
$helper = News\Helper::getInstance(); |
|
26
|
|
|
|
|
27
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
|
28
|
|
|
|
|
29
|
|
|
// We verify that the user can post comments ********************************** |
|
30
|
|
|
if (null === $helper->getModule()) { |
|
31
|
|
|
exit(); |
|
32
|
|
|
} |
|
33
|
|
|
|
|
34
|
|
|
if (0 == $helper->getConfig('com_rule')) { // Comments are deactivated |
|
35
|
|
|
exit(); |
|
36
|
|
|
} |
|
37
|
|
|
|
|
38
|
|
|
if (0 == $helper->getConfig('com_anonpost') && !is_object($xoopsUser)) { // Anonymous users can't post |
|
39
|
|
|
exit(); |
|
40
|
|
|
} |
|
41
|
|
|
// **************************************************************************** |
|
42
|
|
|
|
|
43
|
|
|
$com_itemid = Request::getInt('com_itemid', 0, 'GET'); |
|
44
|
|
|
if ($com_itemid > 0) { |
|
45
|
|
|
$article = new NewsStory($com_itemid); |
|
46
|
|
|
if ($article->storyid > 0) { |
|
47
|
|
|
$com_replytext = _POSTEDBY . ' <b>' . $article->uname() . '</b> ' . _DATE . ' <b>' . formatTimestamp($article->published(), News\Utility::getModuleOption('dateformat')) . '</b><br><br>' . $article->hometext(); |
|
48
|
|
|
$bodytext = $article->bodytext(); |
|
49
|
|
|
if ('' !== $bodytext) { |
|
50
|
|
|
$com_replytext .= '<br><br>' . $bodytext; |
|
51
|
|
|
} |
|
52
|
|
|
$com_replytitle = $article->title(); |
|
53
|
|
|
require XOOPS_ROOT_PATH . '/include/comment_new.php'; |
|
54
|
|
|
} else { |
|
55
|
|
|
exit; |
|
56
|
|
|
} |
|
57
|
|
|
} |
|
58
|
|
|
|
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: