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 | include __DIR__ . '/header.php'; |
||
14 | $op = ''; |
||
15 | //HACK for cache by domifara |
||
16 | if (is_object($xoopsUser)) { |
||
17 | $xoopsConfig['module_cache'] = 0; //disable caching since the URL will be the same, but content different from one user to another |
||
18 | } |
||
19 | |||
20 | $GLOBALS['xoopsOption']['template_main'] = 'sb_column.tpl'; |
||
21 | require_once XOOPS_ROOT_PATH . '/header.php'; |
||
22 | |||
23 | $moduleDirName = $myts->htmlSpecialChars(basename(__DIR__)); |
||
24 | View Code Duplication | if ($moduleDirName !== 'soapbox' && $moduleDirName !== '' && !preg_match('/^(\D+)(\d*)$/', $moduleDirName)) { |
|
0 ignored issues
–
show
|
|||
25 | echo('invalid dirname: ' . htmlspecialchars($moduleDirName, ENT_QUOTES)); |
||
26 | } |
||
27 | |||
28 | $columnID = Request::getInt('columnID', 0, 'GET'); |
||
29 | //---GET view sort -- |
||
30 | $sortname = isset($_GET['sortname']) ? strtolower(trim(strip_tags($myts->stripSlashesGPC($_GET['sortname'])))) : 'datesub'; |
||
31 | if (!in_array($sortname, array('datesub', 'weight', 'counter', 'rating', 'headline'))) { |
||
32 | $sortname = 'datesub'; |
||
33 | } |
||
34 | $sortorder = isset($_GET['sortorder']) ? strtoupper(trim(strip_tags($myts->stripSlashesGPC($_GET['sortorder'])))) : 'DESC'; |
||
35 | if (!in_array($sortorder, array('ASC', 'DESC'))) { |
||
36 | $sortorder = 'DESC'; |
||
37 | } |
||
38 | //--------------- |
||
39 | require_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
40 | $start = Request::getInt('start', 0, 'GET'); |
||
41 | |||
42 | //------------------------------------- |
||
43 | $entrydataHandler = xoops_getModuleHandler('entryget', $xoopsModule->dirname()); |
||
44 | //------------------------------------- |
||
45 | $_entryob_arr = $entrydataHandler->getArticlesAllPermcheck((int)$xoopsModuleConfig['indexperpage'], $start, true, true, 0, 0, null, $sortname, $sortorder, $columnID, null, true, false); |
||
46 | $totalarts = $entrydataHandler->total_getArticlesAllPermcheck; |
||
47 | if (empty($_entryob_arr) || $totalarts === 0) { |
||
48 | redirect_header(XOOPS_URL . '/modules/' . $moduleDirName . '/index.php', 1, _MD_SOAPBOX_MAINNOTOPICS); |
||
49 | } |
||
50 | //get category object |
||
51 | $_categoryob = $_entryob_arr[0]->_sbcolumns; |
||
52 | //get vars |
||
53 | |||
54 | $category = array(); |
||
55 | $category = $_categoryob->toArray(); //all assign |
||
56 | |||
57 | $category['colid'] = $columnID; |
||
58 | $category['author'] = SoapboxUtility::getLinkedUnameFromId($category['author'], 0); |
||
59 | $category['authorname'] = SoapboxUtility::getAuthorName($category['author']); |
||
60 | $category['image'] = $category['colimage']; |
||
61 | $category['total'] = $totalarts; |
||
62 | $xoopsTpl->assign('category', $category); |
||
63 | |||
64 | //------------------------------------------------------ |
||
65 | foreach ($_entryob_arr as $_entryob) { |
||
66 | //----------- |
||
67 | unset($articles); |
||
68 | $articles = array(); |
||
69 | //get vars |
||
70 | $articles = $_entryob->toArray(); |
||
71 | //-------------------- |
||
72 | $articles['id'] = $articles['articleID']; |
||
73 | $articles['datesub'] = $myts->htmlSpecialChars(formatTimestamp($articles['datesub'], $xoopsModuleConfig['dateformat'])); |
||
74 | // $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. ![]() |
|||
75 | $articles['poster'] = SoapboxUtility::getLinkedUnameFromId($category['author']); |
||
76 | $articles['bodytext'] = xoops_substr($articles['bodytext'], 0, 255); |
||
77 | //-------------------- |
||
78 | 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. ![]() |
|||
79 | $articles['headline'] = '[' . _MD_SOAPBOX_SELSUBMITS . ']' . $articles['headline']; |
||
80 | $articles['teaser'] = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC; |
||
81 | $articles['lead'] = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC; |
||
82 | } elseif ($_entryob->getVar('datesub') === 0 || $_entryob->getVar('datesub') > time()) { |
||
83 | $articles['headline'] = '[' . _MD_SOAPBOX_SELWAITEPUBLISH . ']' . $articles['headline']; |
||
84 | $articles['teaser'] = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC; |
||
85 | $articles['lead'] = $xoopsUser->getVar('uname') . _MD_SOAPBOX_SUB_SNEWNAMEDESC; |
||
86 | } |
||
87 | //-------------------- |
||
88 | if (!empty($articles['artimage']) && $articles['artimage'] !== 'blank.png' |
||
89 | && file_exists(XOOPS_ROOT_PATH . '/' . $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']) . '/' . $articles['artimage'])) { |
||
90 | $articles['image'] = XOOPS_URL . '/' . $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir']) . '/' . $articles['artimage']; |
||
91 | } else { |
||
92 | $articles['image'] = ''; |
||
93 | } |
||
94 | |||
95 | if ($xoopsModuleConfig['includerating'] === 1) { |
||
96 | $xoopsTpl->assign('showrating', 1); |
||
97 | $rating = $articles['rating']; |
||
98 | $votes = $articles['votes']; |
||
99 | if ($rating != 0.00) { |
||
100 | $articles['rating'] = _MD_SOAPBOX_RATING . ': ' . $myts->htmlSpecialChars(number_format($rating, 2)); |
||
101 | $articles['votes'] = _MD_SOAPBOX_VOTES . ': ' . $myts->htmlSpecialChars($votes); |
||
102 | } else { |
||
103 | $articles['rating'] = _MD_SOAPBOX_RATING . ': 0.00'; |
||
104 | $articles['votes'] = _MD_SOAPBOX_VOTES . ': 0'; |
||
105 | } |
||
106 | } |
||
107 | //-------------------- |
||
108 | // Functional links |
||
109 | $articles['adminlinks'] = $entrydataHandler->getadminlinks($_entryob, $_categoryob); |
||
110 | $articles['userlinks'] = $entrydataHandler->getuserlinks($_entryob); |
||
111 | |||
112 | $xoopsTpl->append('articles', $articles); |
||
113 | } |
||
114 | |||
115 | $pagenav = new XoopsPageNav($totalarts, (int)$xoopsModuleConfig['indexperpage'], $start, 'start', 'columnID=' . $articles['columnID'] . '&sortname=' . $sortname . '&sortorder=' . $sortorder); |
||
116 | $category['navbar'] = '<div style="text-align:right;">' . $pagenav->renderNav() . '</div>'; |
||
117 | |||
118 | $xoopsTpl->assign('xoops_pagetitle', $category['name']); |
||
119 | $xoopsTpl->assign('category', $category); |
||
120 | |||
121 | $xoopsTpl->assign('lang_modulename', $xoopsModule->name()); |
||
122 | $xoopsTpl->assign('lang_moduledirname', $moduleDirName); |
||
123 | $xoopsTpl->assign('imgdir', $myts->htmlSpecialChars($xoopsModuleConfig['sbimgdir'])); |
||
124 | $xoopsTpl->assign('uploaddir', $myts->htmlSpecialChars($xoopsModuleConfig['sbuploaddir'])); |
||
125 | |||
126 | $xoopsTpl->assign('sortname', $sortname); |
||
127 | $xoopsTpl->assign('sortorder', $sortorder); |
||
128 | |||
129 | $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="' . XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/style.css" />'); |
||
130 | |||
131 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
132 |
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.