Completed
Push — master ( 10bab4...a0a78b )
by Michael
02:06
created

view.article.php (1 issue)

Severity

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
//
3
// ------------------------------------------------------------------------ //
4
// This program is free software; you can redistribute it and/or modify     //
5
// it under the terms of the GNU General Public License as published by     //
6
// the Free Software Foundation; either version 2 of the License, or        //
7
// (at your option) any later version.                                      //
8
//                                                                          //
9
// You may not change or alter any portion of this comment or credits       //
10
// of supporting developers from this source code or any supporting         //
11
// source code which is considered copyrighted (c) material of the          //
12
// original comment or credit authors.                                      //
13
//                                                                          //
14
// This program is distributed in the hope that it will be useful,          //
15
// but WITHOUT ANY WARRANTY; without even the implied warranty of           //
16
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            //
17
// GNU General Public License for more details.                             //
18
//                                                                          //
19
// You should have received a copy of the GNU General Public License        //
20
// along with this program; if not, write to the Free Software              //
21
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA //
22
// ------------------------------------------------------------------------ //
23
// Author: phppp (D.J., [email protected])                                  //
24
// URL: https://xoops.org                         //
25
// Project: Article Project                                                 //
26
// ------------------------------------------------------------------------ //
27
use Xmf\Request;
28
29
include __DIR__ . '/header.php';
30
31
/**
32
 * The comment detection scripts should be removed once absolute url is used in comment_view.php
33
 * The notification detection scripts should be removed once absolute url is used in notification_select.php
34
 *
35
 */
36
if (preg_match("/(\/comment_[^\.]*\.php\?.*=.*)/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {//$_SERVER['REQUEST_URI']
37
    header('location: ' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . $matches[1]);
38
    exit();
39
}
40 View Code Duplication
if (preg_match("/\/notification_update\.php/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
41
    include XOOPS_ROOT_PATH . '/include/notification_update.php';
42
    exit();
43
}
44
45 View Code Duplication
if ($REQUEST_URI_parsed = PlanetUtility::planetParseArguments($args_num, $args, $args_str)) {
46
    $args['article'] = @$args_num[0];
47
    $args['blog']    = @$args['blog'];
48
}
49
50
$article_id = Request::getInt('article', @$args['article'], 'POST');//(int)(empty($_GET['article']) ? @$args['article'] : $_GET['article']);
51
$blog_id    = Request::getInt('blog', @$args['blog'], 'POST');//(int)(empty($_GET['blog']) ? @$args['blog'] : $_GET['blog']);
52
53
$articleHandler = xoops_getModuleHandler('article', $GLOBALS['moddirname']);
54
$blogHandler    = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
55
$article_obj    = $articleHandler->get($article_id);
56
$blog_obj       = $blogHandler->get($article_obj->getVar('blog_id'));
57
58
// restore $_SERVER['REQUEST_URI']
59
if (!empty($REQUEST_URI_parsed)) {
60
    $_SERVER['REQUEST_URI'] = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . (empty($article_id) ? '' : '?article=' . $article_id);
61
}
62
63
$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . $article_obj->getVar('art_title');
64
$xoopsOption['template_main']   = PlanetUtility::planetGetTemplate('article');
65
require_once XOOPS_ROOT_PATH . '/header.php';
66
include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
67
68
$article_data = [
69
    'id'       => $article_id,
70
    'title'    => $article_obj->getVar('art_title'),
71
    'content'  => $article_obj->getVar('art_content'),
72
    'author'   => $article_obj->getVar('art_author'),
73
    'time'     => $article_obj->getTime(),
74
    'link'     => $article_obj->getVar('art_link'),
75
    'views'    => $article_obj->getVar('art_views'),
76
    'comments' => $article_obj->getVar('art_comments'),
77
    'star'     => $article_obj->getStar(),
78
    'rates'    => $article_obj->getVar('art_rates'),
79
    'blog'     => ['id' => $article_obj->getVar('blog_id'), 'title' => $blog_obj->getVar('blog_title')]
80
];
81
82
if (!empty($xoopsModuleConfig['do_sibling'])) {
83
    $articles_sibling = $articleHandler->getSibling($article_obj, $blog_id);
84 View Code Duplication
    if (!empty($articles_sibling['previous'])) {
85
        $articles_sibling['previous']['url']   = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $articles_sibling['previous']['id'] . '/b' . $blog_id;
86
        $articles_sibling['previous']['title'] = $articles_sibling['previous']['title'];
87
    }
88 View Code Duplication
    if (!empty($articles_sibling['next'])) {
89
        $articles_sibling['next']['url']   = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.article.php' . URL_DELIMITER . '' . $articles_sibling['next']['id'] . '/b' . $blog_id;
90
        $articles_sibling['next']['title'] = $articles_sibling['next']['title'];
91
    }
92
}
93
94
$xoopsTpl->assign('modulename', $xoopsModule->getVar('name'));
95
96
$xoopsTpl->assign('article', $article_data);
97
$xoopsTpl->assign('sibling', $articles_sibling);
98
99
$xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1));
100
if (empty($xoopsModuleConfig['anonymous_rate']) && !is_object($xoopsUser)) {
0 ignored issues
show
This if statement is empty and can be removed.

This check looks for the bodies of if statements that have no statements or where all statements have been commented out. This may be the result of changes for debugging or the code may simply be obsolete.

These if bodies can be removed. If you have an empty if but statements in the else branch, consider inverting the condition.

if (rand(1, 6) > 3) {
//print "Check failed";
} else {
    print "Check succeeded";
}

could be turned into

if (rand(1, 6) <= 3) {
    print "Check succeeded";
}

This is much more concise to read.

Loading history...
101
} else {
102
    $xoopsTpl->assign('canrate', 1);
103
}
104
105
if ($transferbar = @include XOOPS_ROOT_PATH . '/Frameworks/transfer/bar.transfer.php') {
106
    $xoopsTpl->assign('transfer', $transferbar);
107
}
108
109
// Loading module meta data, NOT THE RIGHT WAY DOING IT
110
$xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']);
111
112
// for comment and notification
113
//$_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.article.php";
114
$_GET['article'] = $article_id;
115
include XOOPS_ROOT_PATH . '/include/comment_view.php';
116
117
require_once __DIR__ . '/footer.php';
118