Completed
Push — master ( 931dfe...44faa0 )
by Michael
04:53 queued 02:24
created

index.php (5 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
 * Module: Soapbox
5
 * Version: v 1.5
6
 * Release Date: 23 August 2004
7
 * Author: hsalazar
8
 * Licence: GNU
9
 */
10
11
use Xmf\Request;
12
13
require_once __DIR__ . '/header.php';
14
$op = '';
15
if (is_object($xoopsUser)) {
16
    $xoopsConfig['module_cache'] = 0; //disable caching since the URL will be the same, but content different from one user to another
17
}
18
$GLOBALS['xoopsOption']['template_main'] = 'sb_index.tpl';
19
require_once XOOPS_ROOT_PATH . '/header.php';
20
21
$moduleDirName = basename(__DIR__);
22
23
//$moduleDirName =  & $myts->htmlSpecialChars(basename(__DIR__));
0 ignored issues
show
Unused Code Comprehensibility introduced by
56% 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...
24
//if ($moduleDirName !== "soapbox" && $moduleDirName !== "" && !preg_match('/^(\D+)(\d*)$/', $moduleDirName)) {
25
//    echo("invalid dirname: " . htmlspecialchars($moduleDirName, ENT_QUOTES));
26
//}
27
28
//---GET view sort --
29
$sortname = isset($_GET['sortname']) ? strtolower(trim(strip_tags($myts->stripSlashesGPC($_GET['sortname'])))) : 'datesub';
30
if (!in_array($sortname, array('datesub', 'weight', 'counter', 'rating', 'headline'))) {
31
    $sortname = 'datesub';
32
}
33
$sortorder = isset($_GET['sortorder']) ? strtoupper(trim(strip_tags($myts->stripSlashesGPC($_GET['sortorder'])))) : 'DESC';
34
if (!in_array($sortorder, array('ASC', 'DESC'))) {
35
    $sortorder = 'DESC';
36
}
37
//---------------
38
require_once XOOPS_ROOT_PATH . '/class/pagenav.php';
39
$start = Request::getInt('start', 0, 'GET'); //$start = isset($_GET['start']) ? (int)($_GET['start']) : 0;
0 ignored issues
show
Unused Code Comprehensibility introduced by
68% 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...
40
//---------------
41
42
$columna = array();
43
// Options
44
switch ($op) {
45
    case 'default':
46
    default:
47
        //-------------------------------------
48
        $entrydataHandler = xoops_getModuleHandler('entryget', $moduleDirName);
49
        //-------------------------------------
50
51
        $author = isset($_GET['author']) ? (int)$_GET['author'] : 0;
52
        //get category object
53
        if (!empty($author)) {
54
            $categoryobArray = $entrydataHandler->getColumnsByAuthor($author, true, (int)$xoopsModuleConfig['colsperindex'], $start, 'weight', 'ASC');
55
            $totalcols       = $entrydataHandler->total_getColumnsByAuthor;
56
        } else {
57
            //get category object
58
            $categoryobArray = $entrydataHandler->getColumnsAllPermcheck((int)$xoopsModuleConfig['colsperindex'], $start, true, 'weight', 'ASC', null, null, true, false);
59
            $totalcols       = $entrydataHandler->total_getColumnsAllPermcheck;
60
        }
61
        $xoopsTpl->assign('lang_mainhead', $myts->htmlSpecialChars($xoopsModuleConfig['introtitle']));
62
        $xoopsTpl->assign('lang_maintext', $myts->htmlSpecialChars($xoopsModuleConfig['introtext']));
63
        $xoopsTpl->assign('lang_modulename', $xoopsModule->name());
64
        $xoopsTpl->assign('lang_moduledirname', $moduleDirName);
65
        $xoopsTpl->assign('imgdir', $myts->htmlSpecialChars($xoopsModuleConfig['sbimgdir']));
66
        $xoopsTpl->assign('uploaddir', $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']));
67
68
        //----------------------------
69
        if ($totalcols === 0) {
70
            $xoopsTpl->assign('lang_nothing', _MD_SOAPBOX_NOTHING);
71
        }
72
        //----------------------------
73
        foreach ($categoryobArray as $_categoryob) {
74
            //----------------------------
75
            $category = $_categoryob->toArray(); //all assign
76
            //-------------------------------------
77
            //get author
78
            $category['authorname'] = SoapboxUtility::getAuthorName($category['author']);
79
            //-------------------------------------
80
            if ($category['colimage'] !== '') {
81
                $category['imagespan'] = '<span class="picleft"><img class="pic" src="' . XOOPS_URL . '/' . $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']) . '/' . $category['colimage'] . '" /></span>';
82
            } else {
83
                $category['imagespan'] = '';
84
            }
85
            //-------------------------------------
86
            $_entryob_arr          = $entrydataHandler->getArticlesAllPermcheck(1, 0, true, true, 0, 0, null, $sortname, $sortorder, $_categoryob, null, true, false);
87
            $totalarts             = $entrydataHandler->total_getArticlesAllPermcheck;
88
            $category['totalarts'] = $totalarts;
89
            //------------------------------------------------------
90
            foreach ($_entryob_arr as $_entryob) {
91
                //-----------
92
                unset($articles);
93
                $articles = array();
94
                //get vars
95
                $articles            = $_entryob->toArray();
96
                $articles['id']      = $articles['articleID'];
97
                $articles['datesub'] = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $xoopsModuleConfig['dateformat']));
98
                //        $articles['poster'] = XoopsUserUtility::getUnameFromId( $articles['uid'] );
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% 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...
99
                $articles['poster']   = SoapboxUtility::getLinkedUnameFromId($category['author']);
100
                $articles['bodytext'] = xoops_substr($articles['bodytext'], 0, 255);
101
                //--------------------
102 View Code Duplication
                if ($articles['submit'] !== 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...
103
                    $articles['headline'] = '[' . _MD_SOAPBOX_SELSUBMITS . ']' . $articles['headline'];
104
                    $articles['teaser']   = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
105
                    $articles['lead']     = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
106
                } elseif (0 === $_entryob->getVar('datesub') || $_entryob->getVar('datesub') > time()) {
107
                    $articles['headline'] = '[' . _MD_SOAPBOX_SELWAITEPUBLISH . ']' . $articles['headline'];
108
                    $articles['teaser']   = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
109
                    $articles['lead']     = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC;
110
                }
111
112
                // Functional links
113
                $articles['adminlinks'] = $entrydataHandler->getadminlinks($_entryob, $_categoryob);
114
                $articles['userlinks']  = $entrydataHandler->getuserlinks($_entryob);
115
                //loop tail
116
                $category['content'][] = $articles;
117
            }
118
119
            $category['total']  = $totalcols;
120
            $pagenav            = new XoopsPageNav($category['total'], (int)$xoopsModuleConfig['colsperindex'], $start, 'start', '');
121
            $category['navbar'] = '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>';
122
123
            $xoopsTpl->append_by_ref('cols', $category);
124
            unset($category);
125
        }
126
}
127
//$xoopsTpl->assign("xoops_module_header", '<link rel="stylesheet" type="text/css" href="style.css" />');
0 ignored issues
show
Unused Code Comprehensibility introduced by
80% 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...
128
$xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/style.css" />');
129
130
include XOOPS_ROOT_PATH . '/footer.php';
131