Completed
Push — master ( 937117...931dfe )
by Michael
05:45 queued 02:42
created

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