XoopsModules25x /
xoopsmembers
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.
| 1 | <?php |
||
| 2 | // Author: Lio MJ |
||
| 3 | // Website: https://www.github.com/liomj/ |
||
| 4 | |||
| 5 | if (!defined('XOOPS_ROOT_PATH')) { |
||
| 6 | exit; |
||
| 7 | } |
||
| 8 | |||
| 9 | /** |
||
| 10 | * @param $options |
||
| 11 | * @return array |
||
| 12 | */ |
||
| 13 | function show_memberslastlogin_block($options) |
||
| 14 | { |
||
| 15 | $x = 0; |
||
| 16 | $now = time(); |
||
| 17 | $hours = 24; |
||
| 18 | $time = ((int)$hours > 0) ? time() - ((int)$hours * 3600) : (time() - 24 * 3600); |
||
| 19 | $block = []; |
||
| 20 | $sql = 'SELECT distinct uid, name, uname, user_avatar, last_login FROM ' . $GLOBALS['xoopsDB']->prefix('users') . " WHERE level > 0 AND last_login >= '" . $time . "' ORDER BY last_login DESC LIMIT " . $options[3] . ''; |
||
| 21 | $result = $GLOBALS['xoopsDB']->query($sql); |
||
| 22 | while (list($uid, $name, $uname, $user_avatar, $last_login) = $GLOBALS['xoopsDB']->fetchRow($result)) { |
||
| 23 | $sincelastlogin = ' ' . timeDifference($last_login, $now, _MB_XOOPSMEMBERS_HOURS) . ' ' . _MB_XOOPSMEMBERS_AGO; |
||
| 24 | $x++; |
||
| 25 | |||
| 26 | $recentlogin = []; |
||
| 27 | $recentlogin['uid'] = $uid; |
||
| 28 | if ('' != $name && '1' == $options[2]) { |
||
| 29 | $recentlogin['name'] = htmlspecialchars($name, ENT_QUOTES); |
||
| 30 | } else { |
||
| 31 | $recentlogin['name'] = $uname; |
||
| 32 | } |
||
| 33 | $recentlogin['user_avatar'] = $user_avatar; |
||
| 34 | $recentlogin['last_login'] = $last_login; |
||
| 35 | $recentlogin['sincelastlogin'] = $sincelastlogin; |
||
| 36 | |||
| 37 | $block['recentlogin'][] = $recentlogin; |
||
| 38 | unset($recentlogin); |
||
| 39 | } |
||
| 40 | |||
| 41 | $block['showrecentloginname'] = $options[0]; |
||
| 42 | $block['showrecentloginavatar'] = $options[1]; |
||
| 43 | $block['userealname'] = $options[2]; |
||
| 44 | $block['memberdisplay'] = $options[3]; |
||
| 45 | return $block; |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @param $start |
||
| 50 | * @param $end |
||
| 51 | * @param string $return |
||
| 52 | * @return string |
||
| 53 | */ |
||
| 54 | function timeDifference($start, $end, $return = 'days') |
||
| 55 | { |
||
| 56 | //change times to Unix timestamp. |
||
| 57 | //$start = strtotime($start); |
||
| 58 | //$end = strtotime($end); |
||
| 59 | //subtract dates |
||
| 60 | $difference = max($end, $start) - min($end,$start); |
||
| 61 | $time = null; |
||
| 62 | //24 hours equal to 86400 |
||
| 63 | //calculate time difference. |
||
| 64 | switch($return) { |
||
| 65 | case 'days': |
||
| 66 | $days = floor($difference/86400); |
||
| 67 | $difference = $difference % 86400; |
||
| 68 | $time['days'] = $days; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
Loading history...
|
|||
| 69 | case 'hours': |
||
| 70 | $hours = floor($difference/3600); |
||
| 71 | $difference = $difference % 3600; |
||
| 72 | $time['hours'] = $hours; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
| 73 | case 'minutes': |
||
| 74 | $minutes = floor($difference/60); |
||
| 75 | $difference = $difference % 60; |
||
| 76 | $time['minutes'] = $minutes; |
||
|
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
|
|||
| 77 | case 'seconds': |
||
| 78 | $seconds = $difference; |
||
| 79 | $time['seconds'] = $seconds; |
||
| 80 | } |
||
| 81 | |||
| 82 | $output = []; |
||
| 83 | if(is_array($time)) { |
||
|
0 ignored issues
–
show
|
|||
| 84 | $showSec = true; |
||
| 85 | if(isset($time['hours']) && $time['hours'] > 0) { |
||
| 86 | $output[] = $time['hours']. ' ' . _MB_XOOPSMEMBERS_HOUR; |
||
| 87 | $showSec = false; |
||
| 88 | } |
||
| 89 | |||
| 90 | if(isset($time['minutes']) && $time['minutes'] > 0) { |
||
| 91 | $output[] = $time['minutes']. ' ' . _MB_XOOPSMEMBERS_MINUTES; |
||
| 92 | $showSec = false; |
||
| 93 | } |
||
| 94 | |||
| 95 | if (isset($time['seconds']) && true === $showSec) { |
||
| 96 | return $time['seconds']. ' ' . _MB_XOOPSMEMBERS_SECONDS; |
||
| 97 | } |
||
| 98 | return implode(', ',$output); |
||
| 99 | } |
||
| 100 | } |
||
| 101 | |||
| 102 | /** |
||
| 103 | * @param $options |
||
| 104 | * @return string |
||
| 105 | */ |
||
| 106 | function memberslastlogin_edit($options) |
||
| 107 | { |
||
| 108 | $form = _MB_XOOPSMEMBERS_SHOWRECENTLOGINNAME . ' '; |
||
| 109 | $chk = ''; |
||
| 110 | if (1 == $options[0]) { |
||
| 111 | $chk = " checked"; |
||
| 112 | } |
||
| 113 | $form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' > ' . _YES . ''; |
||
| 114 | $chk = ''; |
||
| 115 | if (0 == $options[0]) { |
||
| 116 | $chk = " checked"; |
||
| 117 | } |
||
| 118 | $form .= " <input type='radio' name='options[0]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||
| 119 | |||
| 120 | $form .= _MB_XOOPSMEMBERS_SHOWRECENTLOGINAVATAR . ' '; |
||
| 121 | if (1 == $options[1]) { |
||
| 122 | $chk = " checked"; |
||
| 123 | } |
||
| 124 | $form .= "<input type='radio' name='options[1]' value='1'" . $chk . ' > ' . _YES . ''; |
||
| 125 | $chk = ''; |
||
| 126 | if (0 == $options[1]) { |
||
| 127 | $chk = " checked"; |
||
| 128 | } |
||
| 129 | $form .= " <input type='radio' name='options[1]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||
| 130 | |||
| 131 | $form .= _MB_XOOPSMEMBERS_USEREALNAME . ' '; |
||
| 132 | if (1 == $options[2]) { |
||
| 133 | $chk = " checked"; |
||
| 134 | } |
||
| 135 | $form .= "<input type='radio' name='options[2]' value='1'" . $chk . ' > ' . _YES . ''; |
||
| 136 | $chk = ''; |
||
| 137 | if (0 == $options[2]) { |
||
| 138 | $chk = " checked"; |
||
| 139 | } |
||
| 140 | $form .= " <input type='radio' name='options[2]' value='0'" . $chk . ' >' . _NO . '<br>'; |
||
| 141 | |||
| 142 | $form .= _MB_XOOPSMEMBERS_MEMBERDISPLAY . ' '; |
||
| 143 | $form .= "<input type='text' name='options[3]' value='" . $options[3] . "'>"; |
||
| 144 | return $form; |
||
| 145 | } |
||
| 146 | |||
| 147 | |||
| 148 |