These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | /** |
||
3 | * |
||
4 | * Module: Lexikon - glossary module |
||
5 | * Version: v 1.00 |
||
6 | * Release Date: 8 May 2004 |
||
7 | * Author: hsalazar |
||
8 | * Licence: GNU |
||
9 | */ |
||
10 | |||
11 | include __DIR__ . '/header.php'; |
||
12 | $GLOBALS['xoopsOption']['template_main'] = 'lx_letter.tpl'; |
||
13 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
14 | include_once XOOPS_ROOT_PATH . '/modules/lexikon/include/common.inc.php'; |
||
15 | |||
16 | global $xoTheme, $xoopsUser; |
||
17 | $myts = MyTextSanitizer::getInstance(); |
||
18 | |||
19 | $init = isset($_GET['init']) ? $_GET['init'] : 0; |
||
20 | $xoopsTpl->assign('firstletter', $init); |
||
21 | include_once XOOPS_ROOT_PATH . '/class/pagenav.php'; |
||
22 | $start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
||
23 | |||
24 | $publishedwords = LexikonUtility::countWords(); |
||
25 | $xoopsTpl->assign('publishedwords', $publishedwords); |
||
26 | |||
27 | //permissions |
||
28 | $gpermHandler = xoops_getHandler('groupperm'); |
||
29 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
30 | $module_id = $xoopsModule->getVar('mid'); |
||
31 | $allowed_cats = $gpermHandler->getItemIds('lexikon_view', $groups, $module_id); |
||
32 | $catids = implode(',', $allowed_cats); |
||
33 | $catperms = " AND categoryID IN ($catids) "; |
||
34 | |||
35 | $xoopsTpl->assign('multicats', (int)$xoopsModuleConfig['multicats']); |
||
36 | |||
37 | View Code Duplication | if (!function_exists('mb_ucfirst') && function_exists('mb_substr')) { |
|
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. ![]() |
|||
38 | function mb_ucfirst($string) { |
||
0 ignored issues
–
show
The function
mb_ucfirst() has been defined more than once; this definition is ignored, only the first definition in index.php (L43-47) is considered.
This check looks for functions that have already been defined in other files. Some Codebases, like WordPress, make a practice of defining functions multiple times. This
may lead to problems with the detection of function parameters and types. If you really
need to do this, you can mark the duplicate definition with the /**
* @ignore
*/
function getUser() {
}
function getUser($id, $realm) {
}
See also the PhpDoc documentation for @ignore. ![]() |
|||
39 | $string = mb_ereg_replace("^[\ ]+","", $string); |
||
40 | $string = mb_strtoupper(mb_substr($string, 0, 1, "UTF-8"), "UTF-8").mb_substr($string, 1, mb_strlen($string), "UTF-8" ); |
||
41 | return $string; |
||
42 | } |
||
43 | } |
||
44 | // To display the linked letter list |
||
45 | $alpha = LexikonUtility::getAlphaArray(); |
||
46 | $xoopsTpl->assign('alpha', $alpha); |
||
47 | |||
48 | list($howmanyother) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '#' AND offline ='0' " . $catperms . '')); |
||
49 | $xoopsTpl->assign('totalother', $howmanyother); |
||
50 | |||
51 | // To display the list of categories |
||
52 | View Code Duplication | if ($xoopsModuleConfig['multicats'] == 1) { |
|
53 | $xoopsTpl->assign('block0', LexikonUtility::getCategoryArray()); |
||
54 | $xoopsTpl->assign('layout', CONFIG_CATEGORY_LAYOUT_PLAIN); |
||
55 | if (LexikonUtility::getModuleOption('useshots')) { |
||
56 | $xoopsTpl->assign('show_screenshot', true); |
||
57 | $xoopsTpl->assign('logo_maximgwidth', $xoopsModuleConfig['logo_maximgwidth']); |
||
58 | $xoopsTpl->assign('lang_noscreenshot', _MD_LEXIKON_NOSHOTS); |
||
59 | } else { |
||
60 | $xoopsTpl->assign('show_screenshot', false); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | // No initial: we need to see all letters |
||
65 | if (!$init) { |
||
66 | $entriesarray = []; |
||
67 | $pagetype = 0; |
||
68 | |||
69 | // How many entries will we show in this page? |
||
70 | //$queryA = "SELECT w. * , c.name AS catname FROM ".$xoopsDB -> prefix( 'lxentries' )." w LEFT JOIN ".$xoopsDB -> prefix( 'lxcategories' )." c ON w.categoryID = c.categoryID WHERE w.submit = '0' AND w.offline = '0' ORDER BY w.term ASC"; |
||
71 | //$resultA = $xoopsDB -> query ($queryA, $xoopsModuleConfig['indexperpage'], $start ); |
||
72 | $queryA = 'SELECT * FROM ' |
||
73 | . $xoopsDB->prefix('lxentries') |
||
74 | . " WHERE offline = '0' AND submit = '0' " |
||
75 | . $catperms |
||
76 | . ' ORDER BY term ASC'; |
||
77 | $resultA = $xoopsDB->query($queryA, $xoopsModuleConfig['indexperpage'], $start); |
||
78 | |||
79 | $allentries = $xoopsDB->query('SELECT entryID FROM ' |
||
80 | . $xoopsDB->prefix('lxentries') |
||
81 | . " WHERE submit ='0' AND offline = '0' " |
||
82 | . $catperms |
||
83 | . ' ORDER BY term ASC '); |
||
84 | $totalentries = $xoopsDB->getRowsNum($allentries); |
||
85 | $xoopsTpl->assign('totalentries', $totalentries); |
||
86 | |||
87 | while (list($entryID, $categoryID, $term, $init, $definition, $ref, $url, $uid, $submit, $datesub, $counter, $html, $smiley, $xcodes, $breaks, $block, $offline, $comments) = $xoopsDB->fetchRow($resultA)) { |
||
88 | $eachentry = []; |
||
89 | $xoopsModule = XoopsModule::getByDirname('lexikon'); |
||
90 | $eachentry['dir'] = $xoopsModule->dirname(); |
||
91 | |||
92 | View Code Duplication | if ($xoopsModuleConfig['multicats'] == 1) { |
|
93 | $eachentry['catid'] = (int)$categoryID; |
||
94 | $resultF = $xoopsDB->query('SELECT name FROM ' |
||
95 | . $xoopsDB->prefix('lxcategories') |
||
96 | . " WHERE categoryID = $categoryID ORDER BY name ASC"); |
||
97 | while (list($name) = $xoopsDB->fetchRow($resultF)) { |
||
98 | $eachentry['catname'] = $myts->htmlSpecialChars($name); |
||
99 | } |
||
100 | } |
||
101 | |||
102 | $eachentry['id'] = (int)$entryID; |
||
103 | $eachentry['term'] = mb_ucfirst($myts->htmlSpecialChars($term)); |
||
104 | |||
105 | View Code Duplication | if (($xoopsModuleConfig['com_rule'] != 0) || (($xoopsModuleConfig['com_rule'] != 0) && is_object($xoopsUser))) { |
|
106 | if ($comments != 0) { |
||
107 | $eachentry['comments'] = "<a href='entry.php?entryID=" |
||
108 | . $eachentry['id'] |
||
109 | . "'>" |
||
110 | . $comments |
||
111 | . ' ' |
||
112 | . _COMMENTS |
||
113 | . '</a>'; |
||
114 | } else { |
||
115 | $eachentry['comments'] = ''; |
||
116 | } |
||
117 | } |
||
118 | |||
119 | View Code Duplication | if (!XOOPS_USE_MULTIBYTES) { |
|
120 | $eachentry['definition'] = $myts->displayTarea($definition, $html, $smiley, $xcodes, 1, $breaks); |
||
121 | } |
||
122 | |||
123 | // Functional links |
||
124 | $microlinks = LexikonUtility::getServiceLinks($eachentry); |
||
125 | $eachentry['microlinks'] = $microlinks; |
||
126 | |||
127 | $entriesarray['single'][] = $eachentry; |
||
128 | } |
||
129 | $pagenav = new XoopsPageNav($totalentries, $xoopsModuleConfig['indexperpage'], $start, 'start'); |
||
130 | $entriesarray['navbar'] = '<div style="text-align:right;">' |
||
131 | . $pagenav->renderNav(6) |
||
132 | . '</div>'; |
||
133 | |||
134 | $xoopsTpl->assign('entriesarray', $entriesarray); |
||
135 | $xoopsTpl->assign('pagetype', '0'); |
||
136 | $xoopsTpl->assign('pageinitial', _MD_LEXIKON_ALL); |
||
137 | |||
138 | LexikonUtility::createPageTitle($myts->htmlSpecialChars(_MD_LEXIKON_BROWSELETTER . ' - ' . _MD_LEXIKON_ALL)); |
||
139 | } else { // $init does exist |
||
140 | $pagetype = 1; |
||
141 | // There IS an initial letter, so we want to show just that letter's terms |
||
142 | $entriesarray2 = array(); |
||
143 | |||
144 | // How many entries will we show in this page? |
||
145 | if ($init == _MD_LEXIKON_OTHER) { |
||
146 | $queryB = 'SELECT entryID, categoryID, term, definition, uid, html, smiley, xcodes, breaks, comments FROM ' |
||
147 | . $xoopsDB->prefix('lxentries') |
||
148 | . " WHERE submit ='0' AND offline = '0' AND init = '#' " |
||
149 | . $catperms |
||
150 | . ' ORDER BY term ASC'; |
||
151 | $resultB = $xoopsDB->query($queryB, $xoopsModuleConfig['indexperpage'], $start); |
||
152 | } else { |
||
153 | $queryB = 'SELECT entryID, categoryID, term, definition, uid, html, smiley, xcodes, breaks, comments FROM ' |
||
154 | . $xoopsDB->prefix('lxentries') |
||
155 | . " WHERE submit ='0' AND offline = '0' AND init = '$init' AND init != '#' " |
||
156 | . $catperms |
||
157 | . ' ORDER BY term ASC'; |
||
158 | $resultB = $xoopsDB->query($queryB, $xoopsModuleConfig['indexperpage'], $start); |
||
159 | } |
||
160 | |||
161 | $entrieshere = $xoopsDB->getRowsNum($resultB); |
||
162 | if ($entrieshere == 0) { |
||
163 | redirect_header('javascript:history.go(-1)', 1, _MD_LEXIKON_NOTERMSINLETTER); |
||
164 | } |
||
165 | |||
166 | if ($init == _MD_LEXIKON_OTHER) { |
||
167 | $allentries = $xoopsDB->query('SELECT entryID FROM ' |
||
168 | . $xoopsDB->prefix('lxentries') |
||
169 | . " WHERE init = '#' AND submit ='0' AND offline = '0' " |
||
170 | . $catperms |
||
171 | . ' ORDER BY term ASC '); |
||
172 | } else { |
||
173 | $allentries = $xoopsDB->query('SELECT entryID FROM ' |
||
174 | . $xoopsDB->prefix('lxentries') |
||
175 | . " WHERE init = '$init' AND init != '#' AND submit ='0' AND offline = '0' " |
||
176 | . $catperms |
||
177 | . ' ORDER BY term ASC '); |
||
178 | } |
||
179 | $totalentries = $xoopsDB->getRowsNum($allentries); |
||
180 | $xoopsTpl->assign('totalentries', $totalentries); |
||
181 | LexikonUtility::createPageTitle($myts->htmlSpecialChars(_MD_LEXIKON_BROWSELETTER . (isset($init['init']) ? (' - ' . $init['init']) : ''))); |
||
182 | |||
183 | while (list($entryID, $categoryID, $term, $definition, $uid, $html, $smiley, $xcodes, $breaks, $comments) = $xoopsDB->fetchRow($resultB)) { |
||
184 | $eachentry = array(); |
||
185 | $xoopsModule = XoopsModule::getByDirname('lexikon'); |
||
186 | $eachentry['dir'] = $xoopsModule->dirname(); |
||
187 | |||
188 | View Code Duplication | if ($xoopsModuleConfig['multicats'] == 1) { |
|
189 | $eachentry['catid'] = (int)$categoryID; |
||
190 | $resultF = $xoopsDB->query('SELECT name FROM ' |
||
191 | . $xoopsDB->prefix('lxcategories') |
||
192 | . " WHERE categoryID = $categoryID ORDER BY name ASC"); |
||
193 | while (list($name) = $xoopsDB->fetchRow($resultF)) { |
||
194 | $eachentry['catname'] = $myts->htmlSpecialChars($name); |
||
195 | } |
||
196 | } |
||
197 | $eachentry['id'] = (int)$entryID; |
||
198 | $eachentry['term'] = mb_ucfirst($myts->htmlSpecialChars($term)); |
||
199 | if ($init === '#') { |
||
200 | $eachentry['init'] = _MD_LEXIKON_OTHER; |
||
201 | } else { |
||
202 | $eachentry['init'] = $init; |
||
203 | } |
||
204 | |||
205 | View Code Duplication | if (($xoopsModuleConfig['com_rule'] != 0) || (($xoopsModuleConfig['com_rule'] != 0) && is_object($xoopsUser))) { |
|
206 | if ($comments != 0) { |
||
207 | $eachentry['comments'] = "<a href='entry.php?entryID=" |
||
208 | . $eachentry['id'] |
||
209 | . "'>" |
||
210 | . $comments |
||
211 | . ' ' |
||
212 | . _COMMENTS |
||
213 | . '</a>'; |
||
214 | } else { |
||
215 | $eachentry['comments'] = ''; |
||
216 | } |
||
217 | } |
||
218 | View Code Duplication | if (!XOOPS_USE_MULTIBYTES) { |
|
219 | $eachentry['definition'] = $myts->displayTarea($definition, $html, $smiley, $xcodes, 1, $breaks); |
||
220 | } |
||
221 | |||
222 | // Functional links |
||
223 | $microlinks = LexikonUtility::getServiceLinks($eachentry); |
||
224 | $eachentry['microlinks'] = $microlinks; |
||
225 | |||
226 | $entriesarray2['single'][] = $eachentry; |
||
227 | } |
||
228 | $pagenav = new XoopsPageNav($totalentries, $xoopsModuleConfig['indexperpage'], $start, 'init=' . $eachentry['init'] . '&start'); |
||
229 | $entriesarray2['navbar'] = '<div style="text-align:right;">' |
||
230 | . $pagenav->renderNav(6) |
||
231 | . '</div>'; |
||
232 | |||
233 | $xoopsTpl->assign('entriesarray2', $entriesarray2); |
||
234 | $xoopsTpl->assign('pagetype', '1'); |
||
235 | if ($eachentry['init'] === '#') { |
||
236 | $xoopsTpl->assign('pageinitial', _MD_LEXIKON_OTHER); |
||
237 | LexikonUtility::createPageTitle($myts->htmlSpecialChars(_MD_LEXIKON_BROWSELETTER . ' - ' . _MD_LEXIKON_OTHER)); |
||
238 | } else { |
||
239 | $xoopsTpl->assign('pageinitial', mb_ucfirst($eachentry['init'])); |
||
240 | } |
||
241 | } |
||
242 | |||
243 | $xoopsTpl->assign('lang_modulename', $xoopsModule->name()); |
||
244 | $xoopsTpl->assign('lang_moduledirname', $xoopsModule->getVar('dirname')); |
||
245 | $xoopsTpl->assign('alpha', $alpha); |
||
246 | if ($xoopsModuleConfig['syndication'] == 1) { |
||
247 | $xoopsTpl->assign('syndication', true); |
||
248 | } |
||
249 | if ($xoopsUser) { |
||
250 | $xoopsTpl->assign('syndication', true); |
||
251 | } |
||
252 | // Meta data |
||
253 | if ($publishedwords = 0) { |
||
254 | $meta_description = xoops_substr(LexikonUtility::convertHtml2text($eachentry['definition']), 0, 150); |
||
255 | if ($xoopsModuleConfig['multicats'] == 1) { |
||
256 | LexikonUtility::extractKeywords($xoopsModule->name() . ' ,' . $eachentry['term'] . ', ' . $meta_description); |
||
257 | LexikonUtility::getMetaDescription($myts->htmlSpecialChars($xoopsModule->name()) . ' ' . $eachentry['catname'] . ' ' . $eachentry['term']); |
||
258 | } else { |
||
259 | LexikonUtility::extractKeywords($myts->htmlSpecialChars($xoopsModule->name()) . ', ' . $eachentry['term'] . ', ' . $meta_description); |
||
260 | LexikonUtility::getMetaDescription($myts->htmlSpecialChars($xoopsModule->name()) . ' ' . $eachentry['term'] . ' ' . $meta_description); |
||
261 | } |
||
262 | } |
||
263 | |||
264 | $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="assets/css/style.css" />'); |
||
265 | |||
266 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
267 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.