This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | // $Id: functions.php 11062 2013-02-18 23:44:30Z zyspec $ |
||
3 | // ------------------------------------------------------------------------ // |
||
4 | // XOOPS - PHP Content Management System // |
||
5 | // Copyright (c) 2000 XOOPS.org // |
||
6 | // <http://www.xoops.org/> // |
||
7 | // ------------------------------------------------------------------------ // |
||
8 | // This program is free software; you can redistribute it and/or modify // |
||
9 | // it under the terms of the GNU General Public License as published by // |
||
10 | // the Free Software Foundation; either version 2 of the License, or // |
||
11 | // (at your option) any later version. // |
||
12 | // // |
||
13 | // You may not change or alter any portion of this comment or credits // |
||
14 | // of supporting developers from this source code or any supporting // |
||
15 | // source code which is considered copyrighted (c) material of the // |
||
16 | // original comment or credit authors. // |
||
17 | // // |
||
18 | // This program is distributed in the hope that it will be useful, // |
||
19 | // but WITHOUT ANY WARRANTY; without even the implied warranty of // |
||
20 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // |
||
21 | // GNU General Public License for more details. // |
||
22 | // // |
||
23 | // You should have received a copy of the GNU General Public License // |
||
24 | // along with this program; if not, write to the Free Software // |
||
25 | // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // |
||
26 | // ------------------------------------------------------------------------ // |
||
27 | |||
28 | include_once XOOPS_ROOT_PATH . '/class/tree.php'; |
||
29 | |||
30 | /** |
||
31 | * @param $time |
||
32 | * @param $status |
||
33 | * @return string |
||
34 | */ |
||
35 | function newlinkgraphic($time, $status) |
||
36 | { |
||
37 | $count = 7; |
||
38 | $new = ''; |
||
39 | $startdate = (time() - (86400 * $count)); |
||
40 | |||
41 | if ($startdate < $time) { |
||
42 | if (1 == $status) { |
||
43 | $new = " <img src='" . mylinksGetIconURL('newred.gif') . "' alt='" . _MD_MYLINKS_NEWTHISWEEK . "'>"; |
||
44 | } elseif (2 == $status) { |
||
45 | $new = " <img src='" . mylinksGetIconURL('update.gif') . "' alt='" . _MD_MYLINKS_UPTHISWEEK . "'>"; |
||
46 | } |
||
47 | } |
||
48 | |||
49 | return $new; |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @param $hits |
||
54 | * @return string |
||
55 | */ |
||
56 | function popgraphic($hits) |
||
57 | { |
||
58 | global $xoopsModuleConfig; |
||
59 | $retVal = ''; |
||
60 | |||
61 | if (isset($hits) && ($hits >= $xoopsModuleConfig['popular'])) { |
||
62 | $retVal = " <img src='" . mylinksGetIconURL('pop.gif') . "' alt='" . _MD_MYLINKS_POPULAR . "'>"; |
||
63 | } |
||
64 | |||
65 | return $retVal; |
||
66 | } |
||
67 | |||
68 | /* |
||
69 | * Reusable Link Sorting Functions |
||
70 | * |
||
71 | * @param string orderby is a shortened string for sorting |
||
72 | * @return string returns a dB 'ready' ORDER BY string for dB query |
||
73 | */ |
||
74 | /** |
||
75 | * @param $orderby |
||
76 | * @return string |
||
77 | */ |
||
78 | View Code Duplication | function convertorderbyin($orderby) |
|
79 | { |
||
80 | $orderby = (isset($orderby) && ('' != trim($orderby))) ? trim($orderby) : ''; |
||
81 | switch ($orderby) { |
||
82 | case 'titleA': |
||
83 | $orderby = 'title ASC'; |
||
84 | break; |
||
85 | case 'hitsA': |
||
86 | $orderby = 'hits ASC'; |
||
87 | break; |
||
88 | case 'ratingA': |
||
89 | $orderby = 'rating ASC'; |
||
90 | break; |
||
91 | case 'dateA': |
||
92 | $orderby = 'date ASC'; |
||
93 | break; |
||
94 | case 'titleD': |
||
95 | $orderby = 'title DESC'; |
||
96 | break; |
||
97 | case 'hitsD': |
||
98 | $orderby = 'hits DESC'; |
||
99 | break; |
||
100 | case 'ratingD': |
||
101 | $orderby = 'rating DESC'; |
||
102 | break; |
||
103 | case 'dateD': |
||
104 | default: |
||
105 | $orderby = 'date DESC'; |
||
106 | break; |
||
107 | } |
||
108 | |||
109 | return $orderby; |
||
110 | } |
||
111 | |||
112 | /** |
||
113 | * @param $orderby |
||
114 | * @return string |
||
115 | */ |
||
116 | function convertorderbytrans($orderby) |
||
117 | { |
||
118 | $orderby = (isset($orderby) && ('' != trim($orderby))) ? trim($orderby) : ''; |
||
119 | switch ($orderby) { |
||
120 | case 'title ASC': |
||
121 | $orderbyTrans = '' . _MD_MYLINKS_TITLEATOZ . ''; |
||
122 | break; |
||
123 | case 'hits ASC': |
||
124 | $orderbyTrans = '' . _MD_MYLINKS_POPULARITYLTOM . ''; |
||
125 | break; |
||
126 | case 'rating ASC': |
||
127 | $orderbyTrans = '' . _MD_MYLINKS_RATINGLTOH . ''; |
||
128 | break; |
||
129 | case 'date ASC': |
||
130 | $orderbyTrans = '' . _MD_MYLINKS_DATEOLD . ''; |
||
131 | break; |
||
132 | case 'title DESC': |
||
133 | $orderbyTrans = '' . _MD_MYLINKS_TITLEZTOA . ''; |
||
134 | break; |
||
135 | case 'hits DESC': |
||
136 | $orderbyTrans = '' . _MD_MYLINKS_POPULARITYMTOL . ''; |
||
137 | break; |
||
138 | case 'rating DESC': |
||
139 | $orderbyTrans = '' . _MD_MYLINKS_RATINGHTOL . ''; |
||
140 | break; |
||
141 | case 'date DESC': |
||
142 | default: |
||
143 | $orderbyTrans = '' . _MD_MYLINKS_DATENEW . ''; |
||
144 | break; |
||
145 | } |
||
146 | |||
147 | return $orderbyTrans; |
||
148 | } |
||
149 | |||
150 | /** |
||
151 | * @param $orderby |
||
152 | * @return string |
||
153 | */ |
||
154 | View Code Duplication | function convertorderbyout($orderby) |
|
155 | { |
||
156 | $orderby = (isset($orderby) && ('' != trim($orderby))) ? trim($orderby) : ''; |
||
157 | switch ($orderby) { |
||
158 | case 'title ASC': |
||
159 | $orderby = 'titleA'; |
||
160 | break; |
||
161 | case 'hits ASC': |
||
162 | $orderby = 'hitsA'; |
||
163 | break; |
||
164 | case 'rating ASC': |
||
165 | $orderby = 'ratingA'; |
||
166 | break; |
||
167 | case 'date ASC': |
||
168 | $orderby = 'dateA'; |
||
169 | break; |
||
170 | case 'title DESC': |
||
171 | $orderby = 'titleD'; |
||
172 | break; |
||
173 | case 'hits DESC': |
||
174 | $orderby = 'hitsD'; |
||
175 | break; |
||
176 | case 'rating DESC': |
||
177 | $orderby = 'ratingD'; |
||
178 | break; |
||
179 | case 'date DESC': |
||
180 | default: |
||
181 | $orderby = 'dateD'; |
||
182 | break; |
||
183 | } |
||
184 | |||
185 | return $orderby; |
||
186 | } |
||
187 | |||
188 | /** |
||
189 | * Update rating data for a link in dB link table to keep in sync |
||
190 | * with the vote dB table contents |
||
191 | * @param int $sel_id Listing ID to update |
||
192 | */ |
||
193 | function updaterating($sel_id) |
||
194 | { |
||
195 | global $xoopsDB; |
||
196 | $sel_id = (int)$sel_id; |
||
197 | $sql = 'SELECT COUNT(*), FORMAT(AVG(rating),4) FROM ' . $xoopsDB->prefix('mylinks_votedata') . " WHERE lid={$sel_id}"; |
||
198 | $voteResult = $xoopsDB->query($sql); |
||
199 | if ($voteResult) { |
||
200 | list($votesDB, $finalrating) = $xoopsDB->fetchRow($voteResult); |
||
201 | /* |
||
202 | $query = "SELECT rating FROM " . $xoopsDB->prefix("mylinks_votedata") . " WHERE lid={$sel_id}"; |
||
203 | $voteresult = $xoopsDB->query($query); |
||
204 | $votesDB = $xoopsDB->getRowsNum($voteresult); |
||
205 | $totalrating = 0; |
||
206 | while(list($rating)=$xoopsDB->fetchRow($voteresult)){ |
||
207 | $totalrating += $rating; |
||
208 | } |
||
209 | $finalrating = $totalrating/$votesDB; |
||
210 | $finalrating = number_format($finalrating, 4); |
||
211 | */ |
||
212 | $query = 'UPDATE ' . $xoopsDB->prefix('mylinks_links') . " SET rating={$finalrating}, votes={$votesDB} WHERE lid = {$sel_id}"; |
||
213 | $xoopsDB->query($query) or exit(); |
||
214 | } |
||
215 | } |
||
216 | |||
217 | //returns the total number of items in items table that are accociated with a given table $table id |
||
218 | /** |
||
219 | * @param null $sel_id |
||
220 | * @param string $status |
||
221 | * @param string $oper |
||
222 | * @return mixed |
||
223 | */ |
||
224 | function getTotalItems($sel_id = null, $status = '', $oper = '>') |
||
225 | { |
||
226 | $sel_id = filter_var($sel_id, FILTER_VALIDATE_INT, array('options' => array('default' => 0, 'min_range' => 0))); |
||
227 | $count = 0; |
||
0 ignored issues
–
show
|
|||
228 | $arr = array(); |
||
0 ignored issues
–
show
$arr is not used, you could remove the assignment.
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently. $myVar = 'Value';
$higher = false;
if (rand(1, 6) > 3) {
$higher = true;
} else {
$higher = false;
}
Both the ![]() |
|||
229 | |||
230 | // get XoopsObjectTree for categories |
||
231 | $mylinksCatHandler = xoops_getModuleHandler('category', 'mylinks'); |
||
232 | $catFields = array('cid', 'pid'); |
||
233 | $catObjs = $mylinksCatHandler->getAll(null, $catFields); |
||
234 | $myCatTree = new XoopsObjectTree($catObjs, 'cid', 'pid'); |
||
235 | |||
236 | /* new count routine */ |
||
237 | $childObjArray = $myCatTree->getAllChild($sel_id); |
||
238 | // $whereClause = "`cid`=0"; |
||
239 | $whereClause = "`cid`={$sel_id}"; |
||
240 | if (!empty($childObjArray)) { |
||
241 | $whereClause = "`cid` IN ({$sel_id}"; |
||
242 | foreach ($childObjArray as $childObj) { |
||
243 | $whereClause .= ',' . $childObj->getVar('cid'); |
||
244 | } |
||
245 | $whereClause .= ')'; |
||
246 | } |
||
247 | $query = 'SELECT COUNT(*) FROM ' . $GLOBALS['xoopsDB']->prefix('mylinks_links') . " WHERE {$whereClause}"; |
||
248 | if ('' !== $status) { |
||
249 | $status = (int)$status; |
||
250 | if (preg_match('/^[!]*[<=>]{1}[=>]*$/', $oper, $match)) { |
||
251 | $oper = $match[0]; |
||
252 | } else { |
||
253 | $oper = '>'; |
||
254 | } |
||
255 | // $oper = (0 == intval($status)) ? '=' : '>'; |
||
256 | $query .= " AND status{$oper}{$status}"; |
||
257 | } |
||
258 | $result = $GLOBALS['xoopsDB']->query($query); |
||
259 | list($linkCount) = $GLOBALS['xoopsDB']->fetchRow($result); |
||
260 | |||
261 | return $linkCount; |
||
262 | } |
||
263 | |||
264 | /* |
||
265 | function getTotalItems($sel_id=NULL, $status='', $oper='>') |
||
266 | { |
||
267 | global $xoopsDB, $xoopsModule; |
||
268 | |||
269 | $sel_id = filter_var($sel_id, FILTER_VALIDATE_INT, array( 'options' => array( 'default' => 0, 'min_range' => 0))); |
||
270 | $count = 0; |
||
271 | $arr = array(); |
||
272 | |||
273 | // get XoopsObjectTree for categories |
||
274 | $mylinksCatHandler = xoops_getModuleHandler('category', $xoopsModule->getVar('dirname')); |
||
275 | $catObjs = $mylinksCatHandler->getAll(); |
||
276 | $myCatTree = new XoopsObjectTree($catObjs, 'cid', 'pid'); |
||
277 | |||
278 | // new count routine |
||
279 | $childObjArray = $myCatTree->getAllChild($sel_id); |
||
280 | $catIds = "({$sel_id}"; |
||
281 | foreach ($childObjArray as $childObj) { |
||
282 | $catIds .= ',' . $childObj->getVar('cid'); |
||
283 | } |
||
284 | $catIds .= ')'; |
||
285 | $query = "SELECT COUNT(*) FROM " . $xoopsDB->prefix("mylinks_links") . " WHERE `cid` IN {$catIds}"; |
||
286 | if ( '' !== $status ) { |
||
287 | $status = intval($status); |
||
288 | if ( preg_match($oper, "~^[!]?[<=>]{1}[=>]*$~", $match) ) { |
||
289 | $oper = $match[0]; |
||
290 | } else { |
||
291 | $oper = '>'; |
||
292 | } |
||
293 | // $oper = (0 == intval($status)) ? '=' : '>'; |
||
294 | $query .= " AND status{$oper}{$status}"; |
||
295 | } |
||
296 | $result = $xoopsDB->query($query); |
||
297 | list($linkCount) = $xoopsDB->fetchRow($result); |
||
298 | return $linkCount; |
||
299 | } |
||
300 | */ |
||
301 | //wanikoo |
||
302 | /** |
||
303 | * @param $aFile |
||
304 | * @return string |
||
305 | */ |
||
306 | function mylinksGetStyleURL($aFile) |
||
307 | { |
||
308 | global $mylinks_theme; |
||
309 | $StyleURL = XOOPSMYLINKINCURL . "/{$mylinks_theme}/icons/{$aFile}"; |
||
310 | |||
311 | if (file_exists(XOOPSMYLINKINCPATH . "/{$mylinks_theme}/icons/{$aFile}")) { |
||
312 | return $StyleURL; |
||
313 | } else { |
||
314 | return XOOPSMYLINKINCURL . "/icons/{$aFile}"; |
||
315 | } |
||
316 | } |
||
317 | |||
318 | // |
||
319 | /** |
||
320 | * @param $aFile |
||
321 | * @return string |
||
322 | */ |
||
323 | function mylinksGetIconURL($aFile) |
||
324 | { |
||
325 | global $mylinks_theme; |
||
326 | |||
327 | if (file_exists(XOOPSMYLINKIMGPATH . "/{$mylinks_theme}/icons/{$aFile}")) { |
||
328 | return XOOPSMYLINKIMGURL . "/{$mylinks_theme}/icons/{$aFile}"; |
||
329 | } else { |
||
330 | return XOOPSMYLINKIMGURL . "/icons/{$aFile}"; |
||
331 | } |
||
332 | } |
||
333 | |||
334 | // |
||
335 | /** |
||
336 | * @param $aFile |
||
337 | * @param string $subPath |
||
338 | * @param bool $relPath |
||
339 | * @return string |
||
340 | */ |
||
341 | function mylinksGetStylePath($aFile, $subPath = '', $relPath = true) |
||
0 ignored issues
–
show
|
|||
342 | { |
||
343 | global $mylinks_theme, $xoopsModule; |
||
344 | //sanitize subPath to make sure it's only contains valid path chars |
||
345 | $subPath = (!preg_match('/^(\D+)(\d*)$/', $subPath, $regs)) ? '' : $subPath; |
||
346 | |||
347 | $path = $subPath ? 'modules/' . $xoopsModule->getVar('dirname') : XOOPSMYLINKPATH . '/modules/' . $xoopsModule->getVar('dirname') . '/'; |
||
348 | |||
349 | $subPath = (!empty($subPath)) ? "/{$subPath}" : ''; |
||
350 | $stylePath = "{$path}{$subPath}/{$mylinks_theme}/{$aFile}"; |
||
351 | |||
352 | return file_exists($stylePath) ? $stylePath : "{$path}{$subPath}/{$aFile}"; |
||
353 | } |
||
354 | |||
355 | /** |
||
356 | * @return string |
||
357 | */ |
||
358 | function ml_wfd_letters() |
||
359 | { |
||
360 | global $xoopsDB, $xoopsModule; |
||
361 | |||
362 | xoops_loadLanguage('main', $xoopsModule->getVar('dirname')); |
||
363 | $alphabet = explode(',', _MD_MYLINKS_LTRCHARS); |
||
364 | |||
365 | $result = $xoopsDB->query('SELECT COUNT(*), LEFT(title, 1) AS sletter FROM ' . $xoopsDB->prefix('mylinks_links') . ' WHERE status>0 GROUP BY sletter'); |
||
366 | $letterArray = array(); |
||
367 | while (list($count, $sletter) = $xoopsDB->fetchRow($result)) { |
||
368 | $sletter = mb_strtoupper($sletter); |
||
369 | $letterArray[$sletter] = $count; |
||
370 | } |
||
371 | |||
372 | $letterchoice = "<div class='browsebyletter'>" . _MD_MYLINKS_BROWSETOTOPIC . '</div>'; |
||
373 | $letterchoice .= '[ '; |
||
374 | $num = count($alphabet) - 1; |
||
375 | $halfNum = round($num / 2); |
||
376 | $counter = 0; |
||
377 | foreach ($alphabet as $key => $ltr) { |
||
378 | if (array_key_exists($ltr, $letterArray)) { |
||
379 | $letterchoice .= "<a class='browsebyletter' href='" . XOOPSMYLINKURL . "/viewcat.php?list={$ltr}'>{$ltr}</a>"; |
||
380 | } else { |
||
381 | $letterchoice .= $ltr; |
||
382 | } |
||
383 | if ($counter == $halfNum) { |
||
384 | $letterchoice .= ' ]<br>[ '; |
||
385 | } elseif ($counter != $num) { |
||
386 | $letterchoice .= ' | '; |
||
387 | } |
||
388 | $counter++; |
||
389 | } |
||
390 | $letterchoice .= ' ]'; |
||
391 | |||
392 | return $letterchoice; |
||
393 | } |
||
394 | |||
395 | /** |
||
396 | * @return string |
||
397 | */ |
||
398 | function ml_wfd_toolbar() |
||
399 | { |
||
400 | global $xoopsModule, $xoopsModuleConfig, $xoopsUser; |
||
401 | xoops_loadLanguage('modinfo', $xoopsModule->getVar('dirname')); |
||
402 | $toolbar = "[ <a href='index.php' class='toolbar'>" . _MD_MYLINKS_MAIN . '</a> | '; |
||
403 | if (is_object($xoopsUser) || (!is_object($xoopsUser) && $xoopsModuleConfig['anonpost'])) { |
||
404 | $toolbar .= "<a href='submit.php' class='toolbar'>" . _MI_MYLINKS_SMNAME1 . '</a> | '; |
||
405 | } |
||
406 | $toolbar .= "<a href='topten.php?sort=2' class='toolbar'>" . _MI_MYLINKS_SMNAME2 . "</a> | <a href='topten.php?sort=1' class='toolbar'>" . _MI_MYLINKS_SMNAME3 . "</a> | <a href='topten.php?sort=3' class='toolbar'>" . _MI_MYLINKS_SMNAME4 . '</a> ]'; |
||
407 | |||
408 | return $toolbar; |
||
409 | } |
||
410 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.