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\Files; |
20
|
|
|
use XoopsModules\News\NewsStory; |
21
|
|
|
|
22
|
|
|
require_once \dirname(__DIR__, 2) . '/mainfile.php'; |
23
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/news/class/class.sfiles.php'; |
24
|
|
|
// require_once XOOPS_ROOT_PATH . '/modules/news/class/class.newsstory.php'; |
25
|
|
|
|
26
|
|
|
$fileid = Request::getInt('fileid', 0, 'GET'); |
27
|
|
|
if (empty($fileid)) { |
28
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _ERRORS); |
29
|
|
|
} |
30
|
|
|
$myts = \MyTextSanitizer::getInstance(); // MyTextSanitizer object |
31
|
|
|
$sfiles = new Files($fileid); |
32
|
|
|
|
33
|
|
|
// Do we have the right to see the file ? |
34
|
|
|
$article = new NewsStory($sfiles->getStoryid()); |
35
|
|
|
// and the news, can we see it ? |
36
|
|
|
if (0 == $article->published() || $article->published() > time()) { |
37
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
38
|
|
|
} |
39
|
|
|
// Expired |
40
|
|
|
if (0 != $article->expired() && $article->expired() < time()) { |
41
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 2, _NW_NOSTORY); |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
/** @var \XoopsGroupPermHandler $grouppermHandler */ |
45
|
|
|
$grouppermHandler = xoops_getHandler('groupperm'); |
46
|
|
|
if (is_object($xoopsUser)) { |
47
|
|
|
$groups = $xoopsUser->getGroups(); |
48
|
|
|
} else { |
49
|
|
|
$groups = XOOPS_GROUP_ANONYMOUS; |
50
|
|
|
} |
51
|
|
|
if (!$grouppermHandler->checkRight('news_view', $article->topicid(), $groups, $xoopsModule->getVar('mid'))) { |
52
|
|
|
redirect_header(XOOPS_URL . '/modules/news/index.php', 3, _NOPERM); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
$sfiles->updateCounter(); |
56
|
|
|
$url = XOOPS_UPLOAD_URL . '/' . $sfiles->getDownloadname(); |
57
|
|
|
if (!preg_match('/^ed2k*:\/\//i', $url)) { |
58
|
|
|
header("Location: $url"); |
59
|
|
|
} |
60
|
|
|
echo '<html><head><meta http-equiv="Refresh" content="0; URL=' . htmlspecialchars($url, ENT_QUOTES | ENT_HTML5) . '"></meta></head><body></body></html>'; |
61
|
|
|
exit(); |
62
|
|
|
|
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: