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: 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 | |||
13 | $GLOBALS['xoopsOption']['template_main'] = 'lx_index.tpl'; |
||
14 | include_once XOOPS_ROOT_PATH . '/header.php'; |
||
15 | include_once XOOPS_ROOT_PATH . '/modules/lexikon/include/common.inc.php'; |
||
16 | global $xoTheme, $xoopsUser; |
||
17 | $myts = MyTextSanitizer::getInstance(); |
||
18 | |||
19 | // Disable cache since content differs for each user |
||
20 | //$xoopsConfig["module_cache"][$xoopsModule->getVar("mid")] = 0; |
||
21 | |||
22 | LexikonUtility::calculateTotals(); |
||
23 | $xoopsTpl->assign('multicats', (int)$xoopsModuleConfig['multicats']); |
||
24 | $rndlength = !empty($xoopsModuleConfig['rndlength']) ? (int)$xoopsModuleConfig['rndlength'] : 150; |
||
25 | |||
26 | //permissions |
||
27 | $gpermHandler = xoops_getHandler('groupperm'); |
||
28 | $groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; |
||
29 | $module_id = $xoopsModule->getVar('mid'); |
||
30 | $perm_itemid = isset($categoryID) ? (int)$categoryID : 0; |
||
31 | if (!$gpermHandler->checkRight('lexikon_view', $perm_itemid, $groups, $module_id)) { |
||
32 | redirect_header('javascript:history.go(-1)', 2, _NOPERM); |
||
33 | } |
||
34 | $allowed_cats = $gpermHandler->getItemIds('lexikon_view', $groups, $module_id); |
||
35 | if (count($allowed_cats) > 0) { |
||
36 | $catids = implode(',', $allowed_cats); |
||
37 | $catperms = " AND categoryID IN ($catids) "; |
||
38 | } else { |
||
39 | return '0'; |
||
40 | } |
||
41 | |||
42 | // Counts |
||
43 | $xoopsTpl->assign('multicats', (int)$xoopsModuleConfig['multicats']); |
||
44 | if ($xoopsModuleConfig['multicats'] == 1) { |
||
45 | $xoopsTpl->assign('totalcats', (int)LexikonUtility::countCats()); |
||
46 | } |
||
47 | $publishedwords = LexikonUtility::countWords(); |
||
48 | $xoopsTpl->assign('publishedwords', $publishedwords); |
||
49 | |||
50 | // If there's no entries yet in the system... |
||
51 | if ($publishedwords == 0) { |
||
52 | $xoopsTpl->assign('empty', '1'); |
||
53 | } |
||
54 | |||
55 | // To display the search form |
||
56 | $xoopsTpl->assign('searchform', LexikonUtility::showSearchForm()); |
||
57 | |||
58 | // To display the linked letter list |
||
59 | $alpha = LexikonUtility::getAlphaArray(); |
||
60 | $xoopsTpl->assign('alpha', $alpha); |
||
61 | |||
62 | list($howmanyother) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE init = '#' AND offline ='0' " . $catperms . '')); |
||
63 | $xoopsTpl->assign('totalother', $howmanyother); |
||
64 | |||
65 | // To display the tree of categories |
||
66 | View Code Duplication | if ($xoopsModuleConfig['multicats'] == 1) { |
|
67 | $xoopsTpl->assign('block0', LexikonUtility::getCategoryArray()); |
||
68 | $xoopsTpl->assign('layout', CONFIG_CATEGORY_LAYOUT_PLAIN); |
||
69 | if ($xoopsModuleConfig['useshots'] == 1) { |
||
70 | $xoopsTpl->assign('show_screenshot', true); |
||
71 | $xoopsTpl->assign('logo_maximgwidth', $xoopsModuleConfig['logo_maximgwidth']); |
||
72 | $xoopsTpl->assign('lang_noscreenshot', _MD_LEXIKON_NOSHOTS); |
||
73 | } else { |
||
74 | $xoopsTpl->assign('show_screenshot', false); |
||
75 | } |
||
76 | } |
||
77 | // To display the recent entries block |
||
78 | $block1 = array(); |
||
79 | $result05 = $xoopsDB->query('SELECT entryID, categoryID, term, datesub FROM ' |
||
80 | . $xoopsDB->prefix('lxentries') |
||
81 | . ' WHERE datesub < ' |
||
82 | . time() |
||
83 | . " AND datesub > 0 AND submit = '0' AND offline = '0' AND request = '0' " |
||
84 | . $catperms |
||
85 | . ' ORDER BY datesub DESC', (int)$xoopsModuleConfig['blocksperpage'], 0); |
||
86 | View Code Duplication | if ($publishedwords > 0) { // If there are definitions |
|
87 | //while (list( $entryID, $term, $datesub ) = $xoopsDB->fetchRow($result05)) { |
||
88 | while (list($entryID, $categoryID, $term, $datesub) = $xoopsDB->fetchRow($result05)) { |
||
89 | $newentries = array(); |
||
90 | $xoopsModule = XoopsModule::getByDirname('lexikon'); |
||
91 | $linktext = ucfirst($myts->htmlSpecialChars($term)); |
||
92 | $newentries['linktext'] = $linktext; |
||
93 | $newentries['id'] = $entryID; |
||
94 | $newentries['date'] = formatTimestamp($datesub, 's'); |
||
95 | |||
96 | $block1['newstuff'][] = $newentries; |
||
97 | } |
||
98 | $xoopsTpl->assign('block', $block1); |
||
99 | } |
||
100 | |||
101 | // To display the most read entries block |
||
102 | $block2 = array(); |
||
103 | $result06 = $xoopsDB->query('SELECT entryID, term, counter FROM ' |
||
104 | . $xoopsDB->prefix('lxentries') |
||
105 | . ' WHERE datesub < ' |
||
106 | . time() |
||
107 | . " AND datesub > 0 AND submit = '0' AND offline = '0' AND request = '0' " |
||
108 | . $catperms |
||
109 | . ' ORDER BY counter DESC', (int)$xoopsModuleConfig['blocksperpage'], 0); |
||
110 | // If there are definitions |
||
111 | View Code Duplication | if ($publishedwords > 0) { |
|
0 ignored issues
–
show
|
|||
112 | while (list($entryID, $term, $counter) = $xoopsDB->fetchRow($result06)) { |
||
113 | $popentries = array(); |
||
114 | $xoopsModule = XoopsModule::getByDirname('lexikon'); |
||
115 | $linktext = ucfirst($myts->htmlSpecialChars($term)); |
||
116 | $popentries['linktext'] = $linktext; |
||
117 | $popentries['id'] = $entryID; |
||
118 | $popentries['counter'] = (int)$counter; |
||
119 | |||
120 | $block2['popstuff'][] = $popentries; |
||
121 | } |
||
122 | $xoopsTpl->assign('block2', $block2); |
||
123 | } |
||
124 | |||
125 | // To display the random term block |
||
126 | list($numrows) = $xoopsDB->fetchRow($xoopsDB->query('SELECT COUNT(*) FROM ' . $xoopsDB->prefix('lxentries') . " WHERE submit = 'O' AND offline = '0' " . $catperms . ' ')); |
||
127 | View Code Duplication | if ($numrows > 1) { |
|
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. ![]() |
|||
128 | --$numrows; |
||
129 | mt_srand((double)microtime() * 1000000); |
||
130 | $entrynumber = mt_rand(0, $numrows); |
||
131 | } else { |
||
132 | $entrynumber = 0; |
||
133 | } |
||
134 | |||
135 | $resultZ = $xoopsDB->query('SELECT entryID, categoryID, term, definition, html, smiley, xcodes, breaks FROM ' |
||
136 | . $xoopsDB->prefix('lxentries') |
||
137 | . " WHERE submit = 'O' AND offline = '0' " |
||
138 | . $catperms |
||
139 | . " LIMIT $entrynumber, 1"); |
||
140 | |||
141 | $zerotest = $xoopsDB->getRowsNum($resultZ); |
||
142 | if ($zerotest != 0) { |
||
143 | while ($myrow = $xoopsDB->fetchArray($resultZ)) { |
||
144 | $random = array(); |
||
145 | $random['id'] = $myrow['entryID']; |
||
146 | $random['term'] = ucfirst($myrow['term']); |
||
147 | |||
148 | if (!XOOPS_USE_MULTIBYTES) { |
||
149 | $random['definition'] = $myts->displayTarea(xoops_substr($myrow['definition'], 0, $rndlength - 1), $myrow['html'], $myrow['smiley'], $myrow['xcodes'], 1, $myrow['breaks']); |
||
150 | } |
||
151 | |||
152 | View Code Duplication | if ($xoopsModuleConfig['multicats'] == 1) { |
|
153 | $random['categoryID'] = $myrow['categoryID']; |
||
154 | |||
155 | $resultY = $xoopsDB->query('SELECT categoryID, name FROM ' . $xoopsDB->prefix('lxcategories') . ' WHERE categoryID = ' . $myrow['categoryID'] . ' '); |
||
156 | list($categoryID, $name) = $xoopsDB->fetchRow($resultY); |
||
157 | $random['categoryname'] = $myts->displayTarea($name); |
||
158 | } |
||
159 | } |
||
160 | $microlinks = LexikonUtility::getServiceLinks($random); |
||
161 | $xoopsTpl->assign('random', $random); |
||
162 | } |
||
163 | |||
164 | if ($xoopsUser && $xoopsUser->isAdmin()) { |
||
165 | // To display the submitted and requested terms box |
||
166 | $xoopsTpl->assign('userisadmin', 1); |
||
167 | |||
168 | $blockS = array(); |
||
169 | $resultS = $xoopsDB->query('SELECT entryID, term FROM ' |
||
170 | . $xoopsDB->prefix('lxentries') |
||
171 | . ' WHERE datesub < ' |
||
172 | . time() |
||
173 | . " AND datesub > 0 AND submit = '1' AND offline = '1' AND request = '0' ORDER BY term"); |
||
174 | $totalSwords = $xoopsDB->getRowsNum($resultS); |
||
175 | |||
176 | View Code Duplication | if ($totalSwords > 0) { // If there are definitions |
|
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. ![]() |
|||
177 | while (list($entryID, $term) = $xoopsDB->fetchRow($resultS)) { |
||
178 | $subentries = array(); |
||
179 | $xoopsModule = XoopsModule::getByDirname('lexikon'); |
||
180 | $linktext = ucfirst($myts->htmlSpecialChars($term)); |
||
181 | $subentries['linktext'] = $linktext; |
||
182 | $subentries['id'] = $entryID; |
||
183 | |||
184 | $blockS['substuff'][] = $subentries; |
||
185 | } |
||
186 | $xoopsTpl->assign('blockS', $blockS); |
||
187 | $xoopsTpl->assign('wehavesubs', 1); |
||
188 | } else { |
||
189 | $xoopsTpl->assign('wehavesubs', 0); |
||
190 | } |
||
191 | |||
192 | $blockR = array(); |
||
193 | $resultR = $xoopsDB->query('SELECT entryID, term FROM ' . $xoopsDB->prefix('lxentries') . ' WHERE datesub < ' . time() . " AND datesub > 0 AND request = '1' ORDER BY term"); |
||
194 | $totalRwords = $xoopsDB->getRowsNum($resultR); |
||
195 | |||
196 | View Code Duplication | if ($totalRwords > 0) { // If there are definitions |
|
197 | while (list($entryID, $term) = $xoopsDB->fetchRow($resultR)) { |
||
198 | $reqentries = array(); |
||
199 | $xoopsModule = XoopsModule::getByDirname('lexikon'); |
||
200 | $linktext = ucfirst($myts->htmlSpecialChars($term)); |
||
201 | $reqentries['linktext'] = $linktext; |
||
202 | $reqentries['id'] = $entryID; |
||
203 | |||
204 | $blockR['reqstuff'][] = $reqentries; |
||
205 | } |
||
206 | $xoopsTpl->assign('blockR', $blockR); |
||
207 | $xoopsTpl->assign('wehavereqs', 1); |
||
208 | } else { |
||
209 | $xoopsTpl->assign('wehavereqs', 0); |
||
210 | } |
||
211 | } else { |
||
212 | $xoopsTpl->assign('userisadmin', 0); |
||
213 | $blockR = array(); |
||
214 | $resultR = $xoopsDB->query('SELECT entryID, term FROM ' . $xoopsDB->prefix('lxentries') . ' WHERE datesub < ' . time() . " AND datesub > 0 AND request = '1' " . $catperms . ' ORDER BY term'); |
||
215 | $totalRwords = $xoopsDB->getRowsNum($resultR); |
||
216 | |||
217 | View Code Duplication | if ($totalRwords > 0) { // If there are definitions |
|
218 | while (list($entryID, $term) = $xoopsDB->fetchRow($resultR)) { |
||
219 | $reqentries = array(); |
||
220 | $xoopsModule = XoopsModule::getByDirname('lexikon'); |
||
221 | $linktext = ucfirst($myts->htmlSpecialChars($term)); |
||
222 | $reqentries['linktext'] = $linktext; |
||
223 | $reqentries['id'] = $entryID; |
||
224 | |||
225 | $blockR['reqstuff'][] = $reqentries; |
||
226 | } |
||
227 | $xoopsTpl->assign('blockR', $blockR); |
||
228 | $xoopsTpl->assign('wehavereqs', 1); |
||
229 | } else { |
||
230 | $xoopsTpl->assign('wehavereqs', 0); |
||
231 | } |
||
232 | } |
||
233 | // Various strings |
||
234 | $xoopsTpl->assign('lang_modulename', $xoopsModule->name()); |
||
235 | $xoopsTpl->assign('lang_moduledirname', $xoopsModule->getVar('dirname')); |
||
236 | if ($publishedwords != 0) { |
||
237 | $xoopsTpl->assign('microlinks', $microlinks); |
||
238 | $xoopsTpl->assign('showdate', (int)$xoopsModuleConfig['showdate']); |
||
239 | $xoopsTpl->assign('showcount', (int)$xoopsModuleConfig['showcount']); |
||
240 | } |
||
241 | $xoopsTpl->assign('alpha', $alpha); |
||
242 | $xoopsTpl->assign('teaser', LexikonUtility::getModuleOption('teaser')); |
||
243 | if ($xoopsModuleConfig['syndication'] == 1) { |
||
244 | $xoopsTpl->assign('syndication', true); |
||
245 | } |
||
246 | if ($xoopsUser) { |
||
247 | $xoopsTpl->assign('syndication', true); |
||
248 | } |
||
249 | $xoopsTpl->assign('xoops_pagetitle', $myts->htmlSpecialChars($xoopsModule->name())); |
||
250 | |||
251 | // Meta data |
||
252 | $meta_description = $myts->htmlSpecialChars($xoopsModule->name()); |
||
253 | if (isset($xoTheme) && is_object($xoTheme)) { |
||
254 | $xoTheme->addMeta('meta', 'description', $meta_description); |
||
255 | } else { |
||
256 | $xoopsTpl->assign('xoops_meta_description', $meta_description); |
||
257 | } |
||
258 | $xoopsTpl->assign('xoops_module_header', '<link rel="stylesheet" type="text/css" href="assets/css/style.css" />'); |
||
259 | |||
260 | include XOOPS_ROOT_PATH . '/footer.php'; |
||
261 |
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.