Passed
Push — master ( 6ae33d...022918 )
by Michael
03:45 queued 02:16
created

index.php (3 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
 * About
4
 *
5
 * You may not change or alter any portion of this comment or credits
6
 * of supporting developers from this source code or any supporting source code
7
 * which is considered copyrighted (c) material of the original comment or credit authors.
8
 * This program is distributed in the hope that it will be useful,
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
11
 *
12
 * @copyright      The XOOPS Co.Ltd. http://www.xoops.com.cn
13
 * @copyright      XOOPS Project (https://xoops.org)
14
 * @license        GNU GPL 2 or later (http://www.gnu.org/licenses/gpl-2.0.html)
15
 * @package        about
16
 * @since          1.0.0
17
 * @author         Mengjue Shao <[email protected]>
18
 * @author         Susheng Yang <[email protected]>
19
 */
20
21
require_once __DIR__ . '/header.php';
22
require_once __DIR__ . '/include/functions.render.php';
23
24
$page_id      = Xmf\Request::getInt('page_id', 0);
25
//$page_id      = isset($_REQUEST['page_id']) ? $_REQUEST['page_id'] : '';
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
26
$pageHandler = $abtHelper->getHandler('page');
27
28
$myts = MyTextSanitizer::getInstance();
29
30
// Menu
31
$menu_criteria = new CriteriaCompo();
32
$menu_criteria->add(new Criteria('page_status', AboutConstants::PUBLISHED), 'AND');
33
$menu_criteria->add(new Criteria('page_menu_status', AboutConstants::IN_MENU), 'AND');
34
$menu_criteria->setSort('page_order');
35
$menu_criteria->order = 'ASC';
36
$fields = array(
37
    'page_id',
38
    'page_pid',
39
    'page_menu_title',
40
    'page_blank',
41
    'page_menu_status',
42
    'page_status',
43
    'page_text'
44
);
45
$menu   = $pageHandler->getAll($menu_criteria, $fields, false);
46
foreach ($menu as $k => $v) {
47
    $page_text = trim($v['page_text']);
48
    $menu[$k]['page_text'] = false;
49
    if (preg_match('/https?\:\/\//', $page_text)) {
50
        $menu[$k]['page_text'] = true;
51
    }
52
//    $menu[$k]['page_text'] = trim($v['page_text']) === 'http://' ? true : false;
0 ignored issues
show
Unused Code Comprehensibility introduced by
62% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
53
}
54
$page_menu = $pageHandler->menuTree($menu);
55
56
// Display
57
if (AboutConstants::PAGE == $abtHelper->getConfig('display', AboutConstants::PAGE) || !empty($page_id)) {
58
    // Fun menu display
59
    $criteria = new CriteriaCompo();
60
    if (!empty($page_id)) {
61
        $criteria->add(new Criteria('page_id', $page_id));
62
    } else {
63
        $criteria->add(new Criteria('page_index', AboutConstants::DEFAULT_INDEX));
64
    }
65
    $criteria->add(new Criteria('page_status', AboutConstants::PUBLISHED));
66
67
    $criteria->setSort('page_order');
68
    $criteria->order = 'ASC';
69
    $page = current($pageHandler->getObjects($criteria, null, false, false));
70
    if (!empty($page)) {
71
        $xoopsOption['xoops_pagetitle'] = $myts->htmlSpecialChars($page['page_title'] . ' - ' . $abtHelper->getModule()->name());
72
        $xoopsOption['template_main']   = about_getTemplate('page', $page['page_tpl']);
73
    } else {
74
        $xoopsOption['xoops_pagetitle'] = $myts->htmlSpecialChars(_MD_ABOUT_INDEX . ' - ' . $abtHelper->getModule()->name());
75
        $xoopsOption['template_main']   = about_getTemplate();
76
    }
77
78
    include XOOPS_ROOT_PATH . '/header.php';
79
    $GLOBALS['xoTheme']->addStylesheet("modules/{$moduleDirName}/assets/css/style.css");
80
    $GLOBALS['xoTheme']->addStylesheet("modules/{$moduleDirName}/assets/js/jquery-treeview/jquery.treeview.css");
81
    $GLOBALS['xoTheme']->addScript('browse.php?Frameworks/jquery/jquery.js');
82
    $GLOBALS['xoTheme']->addScript("modules/{$moduleDirName}/assets/js/jquery-treeview/jquery.treeview.js");
83
84
    if (!empty($page)) {
85
        $page['page_text'] = $myts->undoHtmlSpecialChars($page['page_text']);
86
        if (AboutConstants::PAGE_TYPE_LINK == $page['page_type']) {
87
            header('location: ' . $page['page_text']);
88
        }
89
        /** @var xos_opal_Theme $xoTheme */
90
        $xoTheme->addMeta('meta', 'description', $myts->htmlSpecialChars($page['page_menu_title']));
91
        $xoopsTpl->assign('pagemenu', $page_menu);
92
        $xoopsTpl->assign('page', $page);
93
    }
94
} else {
95
    // List (Category) display
0 ignored issues
show
Unused Code Comprehensibility introduced by
38% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
96
    $xoopsOption['xoops_pagetitle'] = $abtHelper->getModule()->name();
97
    $xoopsOption['template_main']   = about_getTemplate('list');
98
    include XOOPS_ROOT_PATH . '/header.php';
99
    $GLOBALS['xoTheme']->addStylesheet("modules/{$moduleDirName}/assets/css/style.css");
100
101
    $criteria = new CriteriaCompo();
102
    $criteria->add(new Criteria('page_status', AboutConstants::PUBLISHED));
103
    $criteria->setSort('page_order');
104
    $criteria->order = 'ASC';
105
    $list = $pageHandler->getAll($criteria, null, false);
106
    foreach ($list as $k => $v) {
107
        $text                      = strip_tags($myts->undoHtmlSpecialChars($v['page_text']));
108
        $list[$k]['page_text']     = xoops_substr($text, 0, $abtHelper->getConfig('str_ereg', AboutConstants::DEFAULT_EREG));
109
        $list[$k]['page_pushtime'] = formatTimestamp($v['page_pushtime'], _SHORTDATESTRING);
110
    }
111
    $xoopsTpl->assign('list', $list);
112
}
113
114
// get bread
115
if (!empty($bread)) {
116
$bread = array_reverse($pageHandler->getBread($menu, $page_id), true);
117
    foreach ($bread as $k => $v) {
118
        if ($k != $page_id) {
119
            $xoBreadcrumbs[] = array('title' => $v, 'link' => $abtHelper->url("index.php?page_id={$k}"));
120
        } else {
121
            $xoBreadcrumbs[] = array('title' => $v);
122
        }
123
        $tree_open[$k] = $k;
124
    }
125
    $xoopsTpl->assign('tree_open', $tree_open);
126
}
127
$xoopsTpl->assign('page_id', $page_id);
128
129
require_once __DIR__ . '/footer.php';
130