Issues (212)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

view.blogs.php (9 issues)

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
use XoopsModules\Planet;
29
/** @var Planet\Helper $helper */
30
$helper = Planet\Helper::getInstance();
31
32
include __DIR__ . '/header.php';
33
34 View Code Duplication
if (preg_match("/\/notification_update\.php/i", Request::getUrl('REQUEST_URI', '', 'SERVER'), $matches)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
35
    include XOOPS_ROOT_PATH . '/include/notification_update.php';
36
    exit();
37
}
38
39 View Code Duplication
if ($REQUEST_URI_parsed = PlanetUtility::planetParseArguments($args_num, $args, $args_str)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
40
    $args['start'] = @$args_num[0];
41
    $args['sort']  = @$args_str[0];
42
}
43
44
/* Start */
45
$start = Request::getInt('start', @$args['start'], 'GET'); //(int)(empty($_GET['start']) ? @$args['start'] : $_GET['start']);
46
/* Specified Category */
47
$category_id = Request::getInt('category', @$args['category'], 'GET'); //(int)(empty($_GET['category']) ? @$args['category'] : $_GET['category']);
48
/* Specified Bookmar(Favorite) UID */
49
$uid = Request::getInt('uid', @$args['uid'], 'GET'); //(int)(empty($_GET['uid']) ? @$args['uid'] : $_GET['uid']);
50
/* Sort by term */
51
$sort = Request::getString('sort', @$args['sort'], 'GET'); // empty($_GET['sort']) ? @$args['sort'] : $_GET['sort'];
52
/* Display as list */
53
$list = Request::getInt('list', @$args['list'], 'GET'); //(int)(empty($_GET['list']) ? @$args['list'] : $_GET['list']);
54
/*
55
// restore $_SERVER['REQUEST_URI']
56
if (!empty($REQUEST_URI_parsed)) {
57
    $args_REQUEST_URI = array();
58
    $_args =array("start", "sort", "uid", "list");
59
    foreach ($_args as $arg) {
60
        if (!empty(${$arg})) {
61
            $args_REQUEST_URI[] = $arg ."=". ${$arg};
62
        }
63
    }
64
    if (!empty($category_id)) {
65
        $args_REQUEST_URI[] = "category=". $category_id;
66
    }
67
    $_SERVER['REQUEST_URI'] = XOOPS_URL."/modules/".$GLOBALS["moddirname"]."/view.blogs.php".
68
        (empty($args_REQUEST_URI)?"":"?".implode("&",$args_REQUEST_URI));
69
}
70
*/
71
72
$xoopsOption['xoops_pagetitle'] = $xoopsModule->getVar('name') . ' - ' . planet_constant('MD_BLOGS');
73
$xoopsOption['template_main']   = PlanetUtility::planetGetTemplate('blogs');
74
require_once XOOPS_ROOT_PATH . '/header.php';
75
include XOOPS_ROOT_PATH . '/modules/' . $xoopsModule->getVar('dirname') . '/include/vars.php';
76
77
// Following part will not be executed after cache
78
$categoryHandler = xoops_getModuleHandler('category', $GLOBALS['moddirname']);
79
$blogHandler     = xoops_getModuleHandler('blog', $GLOBALS['moddirname']);
80
81
$limit = empty($list) ? $helper->getConfig('articles_perpage') : $helper->getConfig('list_perpage');
82
83
$query_type  = '';
84
$criteria    = new \CriteriaCompo();
85
$blog_prefix = '';
86
/* Specific category */
87 View Code Duplication
if ($category_id > 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
88
    $category_obj = $categoryHandler->get($category_id);
89
    $criteria->add(new \Criteria('bc.cat_id', $category_id));
90
    $uid           = 0;
91
    $blog_id       = 0;
92
    $category_data = ['id' => $category_id, 'title' => $category_obj->getVar('cat_title')];
93
    $query_type    = 'category';
94
    $blog_prefix   = 'b.';
95
}
96
97
/* User bookmarks(favorites) */
98 View Code Duplication
if ($uid > 0) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
99
    $criteria->add(new \Criteria('bm.bm_uid', $uid));
100
    $category_id     = 0;
101
    $blog_id         = 0;
102
    $bookmarkHandler = xoops_getModuleHandler('bookmark', $GLOBALS['moddirname']);
103
    $user_data       = [
104
        'uid'   => $uid,
105
        'name'  => XoopsUser::getUnameFromId($uid),
106
        'marks' => $bookmarkHandler->getCount(new \Criteria('bm_uid', $uid))
107
    ];
108
    $query_type      = 'bookmark';
109
    $blog_prefix     = 'b.';
110
}
111
112
$criteria->add(new \Criteria($blog_prefix . 'blog_status', 0, '>'));
113
114
/* Sort */
115
$order = 'DESC';
116
$sort  = empty($sort) ? 'default' : $sort;
117
switch ($sort) {
118
    case 'marks':
119
        $sortby = $blog_prefix . 'blog_marks';
120
        break;
121
    case 'rating':
122
        $sortby = $blog_prefix . 'blog_rating';
123
        break;
124
    case 'time':
125
        $sortby = $blog_prefix . 'blog_time';
126
        break;
127
    case 'default':
128
    default:
129
        $sort   = 'default';
130
        $sortby = $blog_prefix . 'blog_id';
131
        break;
132
}
133
$criteria->setSort($sortby);
134
$criteria->setOrder($order);
135
$criteria->setStart($start);
136
$criteria->setLimit($limit);
137
138
$tags = empty($list) ? '' : [$blog_prefix . 'blog_title', $blog_prefix . 'blog_time'];
139 View Code Duplication
switch ($query_type) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
140
    case 'category':
141
        $blogs_obj  = $blogHandler->getByCategory($criteria, $tags);
142
        $count_blog = $blogHandler->getCountByCategory($criteria);
143
        break;
144
    case 'bookmark':
145
        $blogs_obj  = $blogHandler->getByBookmark($criteria, $tags);
146
        $count_blog = $blogHandler->getCountByBookmark($criteria);
147
        break;
148
    default:
149
        $blogs_obj  = $blogHandler->getAll($criteria, $tags);
150
        $count_blog = $blogHandler->getCount($criteria);
151
        break;
152
}
153
154
/* Objects to array */
155
$blogs = [];
156
foreach (array_keys($blogs_obj) as $id) {
157
    $_blog = [
158
        'id'    => $id,
159
        'title' => $blogs_obj[$id]->getVar('blog_title'),
160
        'time'  => $blogs_obj[$id]->getTime()
161
    ];
162
    if (empty($list)) {
163
        $_blog = array_merge($_blog, [
164
            'image' => $blogs_obj[$id]->getImage(),
165
            'feed'  => $blogs_obj[$id]->getVar('blog_feed'),
166
            'link'  => $blogs_obj[$id]->getVar('blog_link'),
167
            'desc'  => $blogs_obj[$id]->getVar('blog_desc'),
168
            'star'  => $blogs_obj[$id]->getStar(),
169
            'rates' => $blogs_obj[$id]->getVar('blog_rates'),
170
            'marks' => $blogs_obj[$id]->getVar('blog_marks')
171
        ]);
172
    }
173
    $blogs[] = $_blog;
174
    unset($_blog);
175
}
176
unset($blogs_obj);
177
178
if ($count_blog > $limit) {
179
    include XOOPS_ROOT_PATH . '/class/pagenav.php';
180
    $start_link = [];
181
    if ($sort) {
182
        $start_link[] = 'sort=' . $sort;
183
    }
184
    if ($category_id) {
185
        $start_link[] = 'category=' . $category_id;
186
    }
187
    if ($list) {
188
        $start_link[] = 'list=' . $list;
189
    }
190
    $nav     = new \XoopsPageNav($count_blog, $limit, $start, 'start', implode('&amp;', $start_link));
191
    $pagenav = $nav->renderNav(4);
192
} else {
193
    $pagenav = '';
194
}
195
196
$xoopsTpl->assign('xoops_pagetitle', $xoopsOption['xoops_pagetitle']);
197
$xoopsTpl->assign('link_home', '<a href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php" title="' . planet_constant('MD_HOME') . '" target="_self">' . planet_constant('MD_HOME') . '</a>');
198
199
if ($category_id || $uid) {
200
    $xoopsTpl->assign('link_index', '<a href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php" title="' . planet_constant('MD_INDEX') . '" target="_self">' . planet_constant('MD_INDEX') . '</a>');
201
202
    $link_articles = '<a href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/index.php' . (empty($category_id) ? '' : '/c' . $category_id) . (empty($uid) ? '' : '/u' . $uid) . '" title="' . planet_constant('MD_ARTICLES') . '">' . planet_constant('MD_ARTICLES') . '</a>';
203
    $xoopsTpl->assign('link_articles', $link_articles);
204
}
205
206
$link_switch = '<a href="'
207
               . XOOPS_URL
208
               . '/modules/'
209
               . $GLOBALS['moddirname']
210
               . '/view.blogs.php'
211
               . (empty($category_id) ? '' : '/c' . $category_id)
212
               . (empty($uid) ? '' : '/u' . $uid)
213
               . (empty($list) ? '/l1' : '')
214
               . '" title="'
215
               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))
216
               . '">'
217
               . (empty($list) ? planet_constant('MD_LISTVIEW') : planet_constant('MD_FULLVIEW'))
218
               . '</a>';
219
$xoopsTpl->assign('link_switch', $link_switch);
220
221 View Code Duplication
if (empty($uid) && is_object($xoopsUser)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
222
    $xoopsTpl->assign('link_bookmark', '<a href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER . 'u' . $xoopsUser->getVar('uid') . '" title="' . planet_constant('MD_BOOKMARKS') . '" target="_self">' . planet_constant('MD_BOOKMARKS') . '</a>');
223
}
224
225 View Code Duplication
if (1 == $helper->getConfig('newblog_submit') || is_object($xoopsUser)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
226
    $xoopsTpl->assign('link_submit', '<a href="' . XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/action.blog.php" title="' . _SUBMIT . '" target="_blank">' . _SUBMIT . '</a>');
227
}
228
229
$xoopsTpl->assign('pagetitle', $xoopsModule->getVar('name') . '::' . planet_constant('MD_BLOGS'));
230
$xoopsTpl->assign('category', @$category_data);
231
$xoopsTpl->assign('user', @$user_data);
232
$xoopsTpl->assign('blogs', $blogs);
233
$xoopsTpl->assign('pagenav', $pagenav);
234
$xoopsTpl->assign('count_blog', $count_blog);
235
$xoopsTpl->assign('is_list', !empty($list));
236
237
$xoopsTpl->assign('user_level', !is_object($xoopsUser) ? 0 : ($xoopsUser->isAdmin() ? 2 : 1));
238 View Code Duplication
if (empty($helper->getConfig('anonymous_rate')) && !is_object($xoopsUser)) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
239
} elseif (!$list) {
240
    $xoopsTpl->assign('canrate', 1);
241
}
242
243
$sort_link = XOOPS_URL . '/modules/' . $GLOBALS['moddirname'] . '/view.blogs.php' . URL_DELIMITER;
244
$vars      = [];
245
if (!empty($category_id)) {
246
    $vars[] = 'c' . $category_id;
247
}
248
if (!empty($uid)) {
249
    $vars[] = 'u' . $uid;
250
}
251
if (!empty($list)) {
252
    $vars[] = 'li';
253
}
254
if (!empty($vars)) {
255
    $sort_link .= implode('/', $vars) . '/';
256
}
257
$sortlinks   = [];
258
$valid_sorts = [
259
    'marks'   => planet_constant('MD_BOOKMARKS'),
260
    'rating'  => planet_constant('MD_RATING'),
261
    'time'    => planet_constant('MD_TIME'),
262
    'default' => planet_constant('MD_DEFAULT')
263
];
264 View Code Duplication
foreach ($valid_sorts as $val => $name) {
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
265
    if ($val == $sort) {
266
        continue;
267
    }
268
    $sortlinks[] = '<a href="' . $sort_link . $val . '">' . $name . '</a>';
269
}
270
$xoopsTpl->assign('link_sort', implode(' | ', $sortlinks));
271
272
require_once __DIR__ . '/footer.php';
273