| 1: | <?php | 
| 2: |  | 
| 3: |  | 
| 4: |  | 
| 5: |  | 
| 6: |  | 
| 7: |  | 
| 8: |  | 
| 9: |  | 
| 10: |  | 
| 11: |  | 
| 12: |  | 
| 13: |  | 
| 14: |  | 
| 15: |  | 
| 16: |  | 
| 17: |  | 
| 18: |  | 
| 19: |  | 
| 20: | include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); | 
| 21: |  | 
| 22: |  | 
| 23: |  | 
| 24: |  | 
| 25: | function b_system_online_show() | 
| 26: | { | 
| 27: | global $xoopsUser, $xoopsModule; | 
| 28: |  | 
| 29: | $online_handler = xoops_getHandler('online'); | 
| 30: |  | 
| 31: | if (mt_rand(1, 100) < 11) { | 
| 32: | $online_handler->gc(300); | 
| 33: | } | 
| 34: | if (is_object($xoopsUser)) { | 
| 35: | $uid   = $xoopsUser->getVar('uid'); | 
| 36: | $uname = $xoopsUser->getVar('uname'); | 
| 37: | } else { | 
| 38: | $uid   = 0; | 
| 39: | $uname = ''; | 
| 40: | } | 
| 41: | $requestIp = \Xmf\IPAddress::fromRequest()->asReadable(); | 
| 42: | $requestIp = (false === $requestIp) ? '0.0.0.0' : $requestIp; | 
| 43: | if (is_object($xoopsModule)) { | 
| 44: | $online_handler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), $requestIp); | 
| 45: | } else { | 
| 46: | $online_handler->write($uid, $uname, time(), 0, $requestIp); | 
| 47: | } | 
| 48: | $onlines = $online_handler->getAll(); | 
| 49: | if (!empty($onlines)) { | 
| 50: | $total   = count($onlines); | 
| 51: | $block   = array(); | 
| 52: | $guests  = 0; | 
| 53: | $members = ''; | 
| 54: | for ($i = 0; $i < $total; ++$i) { | 
| 55: | if ($onlines[$i]['online_uid'] > 0) { | 
| 56: | $members .= ' <a href="' . XOOPS_URL . '/userinfo.php?uid=' . $onlines[$i]['online_uid'] . '" title="' . $onlines[$i]['online_uname'] . '">' . $onlines[$i]['online_uname'] . '</a>,'; | 
| 57: | } else { | 
| 58: | ++$guests; | 
| 59: | } | 
| 60: | } | 
| 61: | $block['online_total'] = sprintf(_ONLINEPHRASE, $total); | 
| 62: | if (is_object($xoopsModule)) { | 
| 63: | $mytotal = $online_handler->getCount(new Criteria('online_module', $xoopsModule->getVar('mid'))); | 
| 64: | $block['online_total'] .= ' (' . sprintf(_ONLINEPHRASEX, $mytotal, $xoopsModule->getVar('name')) . ')'; | 
| 65: | } | 
| 66: | $block['lang_members']   = _MEMBERS; | 
| 67: | $block['lang_guests']    = _GUESTS; | 
| 68: | $block['online_names']   = $members; | 
| 69: | $block['online_members'] = $total - $guests; | 
| 70: | $block['online_guests']  = $guests; | 
| 71: | $block['lang_more']      = _MORE; | 
| 72: |  | 
| 73: | return $block; | 
| 74: | } else { | 
| 75: | return false; | 
| 76: | } | 
| 77: | } | 
| 78: |  | 
| 79: |  | 
| 80: |  | 
| 81: |  | 
| 82: | function b_system_login_show() | 
| 83: | { | 
| 84: | global $xoopsUser, $xoopsConfig; | 
| 85: | if (!$xoopsUser) { | 
| 86: | $block                     = array(); | 
| 87: | $block['lang_username']    = _USERNAME; | 
| 88: | $block['unamevalue']       = ''; | 
| 89: | $block['lang_password']    = _PASSWORD; | 
| 90: | $block['lang_login']       = _LOGIN; | 
| 91: | $block['lang_lostpass']    = _MB_SYSTEM_LPASS; | 
| 92: | $block['lang_registernow'] = _MB_SYSTEM_RNOW; | 
| 93: |  | 
| 94: | if ($xoopsConfig['use_ssl'] == 1 && $xoopsConfig['sslloginlink'] != '') { | 
| 95: | $block['sslloginlink'] = "<a href=\"javascript:openWithSelfMain('" . $xoopsConfig['sslloginlink'] . "', 'ssllogin', 300, 200);\">" . _MB_SYSTEM_SECURE . '</a>'; | 
| 96: | } elseif ($GLOBALS['xoopsConfig']['usercookie']) { | 
| 97: | $block['lang_rememberme'] = _MB_SYSTEM_REMEMBERME; | 
| 98: | } | 
| 99: |  | 
| 100: | return $block; | 
| 101: | } | 
| 102: |  | 
| 103: | return false; | 
| 104: | } | 
| 105: |  | 
| 106: |  | 
| 107: |  | 
| 108: |  | 
| 109: | function b_system_main_show() | 
| 110: | { | 
| 111: | global $xoopsUser, $xoopsModule; | 
| 112: | $block               = array(); | 
| 113: | $block['lang_home']  = _MB_SYSTEM_HOME; | 
| 114: | $block['lang_close'] = _CLOSE; | 
| 115: | $module_handler      = xoops_getHandler('module'); | 
| 116: | $criteria            = new CriteriaCompo(new Criteria('hasmain', 1)); | 
| 117: | $criteria->add(new Criteria('isactive', 1)); | 
| 118: | $criteria->add(new Criteria('weight', 0, '>')); | 
| 119: | $modules            = $module_handler->getObjects($criteria, true); | 
| 120: |  | 
| 121: | $moduleperm_handler = xoops_getHandler('groupperm'); | 
| 122: | $groups             = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS; | 
| 123: | $read_allowed       = $moduleperm_handler->getItemIds('module_read', $groups); | 
| 124: | $block['modules'] = array(); | 
| 125: | foreach (array_keys($modules) as $i) { | 
| 126: | if (in_array($i, $read_allowed)) { | 
| 127: | $block['modules'][$i]['name']      = $modules[$i]->getVar('name'); | 
| 128: | $block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname'); | 
| 129: | $sublinks                          = $modules[$i]->subLink(); | 
| 130: | if ((!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) { | 
| 131: | $block['modules'][$i]['highlight'] = true; | 
| 132: | $block['nothome']                  = true; | 
| 133: | } | 
| 134: | if ((!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) { | 
| 135: | $block['modules'][$i]['highlight'] = true; | 
| 136: | $block['nothome']                  = true; | 
| 137: | } | 
| 138: | if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) { | 
| 139: | foreach ($sublinks as $sublink) { | 
| 140: | $block['modules'][$i]['sublinks'][] = array( | 
| 141: | 'name' => $sublink['name'], | 
| 142: | 'url'  => XOOPS_URL . '/modules/' . $modules[$i]->getVar('dirname') . '/' . $sublink['url']); | 
| 143: | } | 
| 144: | } else { | 
| 145: | $block['modules'][$i]['sublinks'] = array(); | 
| 146: | } | 
| 147: | } | 
| 148: | } | 
| 149: |  | 
| 150: | return $block; | 
| 151: | } | 
| 152: |  | 
| 153: |  | 
| 154: |  | 
| 155: |  | 
| 156: | function b_system_search_show() | 
| 157: | { | 
| 158: | $block                   = array(); | 
| 159: | $block['lang_search']    = _MB_SYSTEM_SEARCH; | 
| 160: | $block['lang_advsearch'] = _MB_SYSTEM_ADVS; | 
| 161: |  | 
| 162: | return $block; | 
| 163: | } | 
| 164: |  | 
| 165: |  | 
| 166: |  | 
| 167: |  | 
| 168: | function b_system_user_show() | 
| 169: | { | 
| 170: | global $xoopsUser; | 
| 171: | if (!is_object($xoopsUser)) { | 
| 172: | return false; | 
| 173: | } | 
| 174: | $block                       = array(); | 
| 175: | $block['lang_youraccount']   = _MB_SYSTEM_VACNT; | 
| 176: | $block['lang_editaccount']   = _MB_SYSTEM_EACNT; | 
| 177: | $block['lang_notifications'] = _MB_SYSTEM_NOTIF; | 
| 178: | $block['uid']                = $xoopsUser->getVar('uid'); | 
| 179: | $block['lang_logout']        = _MB_SYSTEM_LOUT; | 
| 180: | $criteria                    = new CriteriaCompo(new Criteria('read_msg', 0)); | 
| 181: | $criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid'))); | 
| 182: |  | 
| 183: | $pm_handler = xoops_getHandler('privmessage'); | 
| 184: |  | 
| 185: | $xoopsPreload = XoopsPreload::getInstance(); | 
| 186: | $xoopsPreload->triggerEvent('system.blocks.system_blocks.usershow', array(&$pm_handler)); | 
| 187: |  | 
| 188: | $block['user_avatar']    = $xoopsUser->getVar('user_avatar'); | 
| 189: | $block['uname']          = $xoopsUser->getVar('uname'); | 
| 190: | $block['new_messages']   = $pm_handler->getCount($criteria); | 
| 191: | $block['lang_inbox']     = _MB_SYSTEM_INBOX; | 
| 192: | $block['lang_adminmenu'] = _MB_SYSTEM_ADMENU; | 
| 193: |  | 
| 194: | return $block; | 
| 195: | } | 
| 196: |  | 
| 197: |  | 
| 198: |  | 
| 199: |  | 
| 200: |  | 
| 201: | function b_system_waiting_show() | 
| 202: | { | 
| 203: | global $xoopsUser; | 
| 204: | $xoopsDB        = XoopsDatabaseFactory::getDatabaseConnection(); | 
| 205: |  | 
| 206: | $module_handler = xoops_getHandler('module'); | 
| 207: | $block          = array(); | 
| 208: |  | 
| 209: |  | 
| 210: | if (xoops_isActiveModule('news') && $module_handler->getCount(new Criteria('dirname', 'news'))) { | 
| 211: | $sql    = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('stories') . ' WHERE published=0'; | 
| 212: | $result = $xoopsDB->query($sql); | 
| 213: | if ($xoopsDB->isResultSet($result)) { | 
| 214: | $block['modules'][0]['adminlink'] = XOOPS_URL . '/modules/news/admin/index.php?op=newarticle'; | 
| 215: | list($block['modules'][0]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 216: | $block['modules'][0]['lang_linkname'] = _MB_SYSTEM_SUBMS; | 
| 217: | } | 
| 218: | } | 
| 219: |  | 
| 220: |  | 
| 221: | if (xoops_isActiveModule('mylinks') && $module_handler->getCount(new Criteria('dirname', 'mylinks'))) { | 
| 222: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_links') . ' WHERE status=0'; | 
| 223: | $result = $xoopsDB->query($sql); | 
| 224: | if ($xoopsDB->isResultSet($result)) { | 
| 225: | $block['modules'][1]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/index.php?op=listNewLinks'; | 
| 226: | list($block['modules'][1]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 227: | $block['modules'][1]['lang_linkname'] = _MB_SYSTEM_WLNKS; | 
| 228: | } | 
| 229: |  | 
| 230: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_broken'); | 
| 231: | $result = $xoopsDB->query($sql); | 
| 232: | if ($xoopsDB->isResultSet($result)) { | 
| 233: | $block['modules'][2]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/index.php?op=listBrokenLinks'; | 
| 234: | list($block['modules'][2]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 235: | $block['modules'][2]['lang_linkname'] = _MB_SYSTEM_BLNK; | 
| 236: | } | 
| 237: |  | 
| 238: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mylinks_mod'); | 
| 239: | $result = $xoopsDB->query($sql); | 
| 240: | if ($xoopsDB->isResultSet($result)) { | 
| 241: | $block['modules'][3]['adminlink'] = XOOPS_URL . '/modules/mylinks/admin/index.php?op=listModReq'; | 
| 242: | list($block['modules'][3]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 243: | $block['modules'][3]['lang_linkname'] = _MB_SYSTEM_MLNKS; | 
| 244: | } | 
| 245: | } | 
| 246: |  | 
| 247: |  | 
| 248: | if (xoops_isActiveModule('mydownloads') && $module_handler->getCount(new Criteria('dirname', 'mydownloads'))) { | 
| 249: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_downloads') . ' WHERE status=0'; | 
| 250: | $result = $xoopsDB->query($sql); | 
| 251: | if ($xoopsDB->isResultSet($result)) { | 
| 252: | $block['modules'][4]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listNewDownloads'; | 
| 253: | list($block['modules'][4]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 254: | $block['modules'][4]['lang_linkname'] = _MB_SYSTEM_WDLS; | 
| 255: | } | 
| 256: |  | 
| 257: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_broken') . ''; | 
| 258: | $result = $xoopsDB->query($sql); | 
| 259: | if ($xoopsDB->isResultSet($result)) { | 
| 260: | $block['modules'][5]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listBrokenDownloads'; | 
| 261: | list($block['modules'][5]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 262: | $block['modules'][5]['lang_linkname'] = _MB_SYSTEM_BFLS; | 
| 263: | } | 
| 264: |  | 
| 265: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('mydownloads_mod') . ''; | 
| 266: | $result = $xoopsDB->query($sql); | 
| 267: | if ($xoopsDB->isResultSet($result)) { | 
| 268: | $block['modules'][6]['adminlink'] = XOOPS_URL . '/modules/mydownloads/admin/index.php?op=listModReq'; | 
| 269: | list($block['modules'][6]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 270: | $block['modules'][6]['lang_linkname'] = _MB_SYSTEM_MFLS; | 
| 271: | } | 
| 272: | } | 
| 273: |  | 
| 274: |  | 
| 275: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('xoopscomments') . ' WHERE com_status=1'; | 
| 276: | $result = $xoopsDB->query($sql); | 
| 277: | if ($xoopsDB->isResultSet($result)) { | 
| 278: | $block['modules'][7]['adminlink'] = XOOPS_URL . '/modules/system/admin.php?module=0&status=1&fct=comments'; | 
| 279: | list($block['modules'][7]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 280: | $block['modules'][7]['lang_linkname'] = _MB_SYSTEM_COMPEND; | 
| 281: | } | 
| 282: |  | 
| 283: |  | 
| 284: | if (xoops_isActiveModule('TDMdownloads') && $module_handler->getCount(new Criteria('dirname', 'TDMDownloads'))) { | 
| 285: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('tdmdownloads_downloads') . ' WHERE status=0'; | 
| 286: | $result = $xoopsDB->query($sql); | 
| 287: | if ($xoopsDB->isResultSet($result)) { | 
| 288: | $block['modules'][8]['adminlink'] = XOOPS_URL . '/modules/TDMDownloads/admin/downloads.php?op=list&statut_display=0'; | 
| 289: | list($block['modules'][8]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 290: | $block['modules'][8]['lang_linkname'] = _MB_SYSTEM_TDMDOWNLOADS; | 
| 291: | } | 
| 292: | } | 
| 293: |  | 
| 294: |  | 
| 295: | if (xoops_isActiveModule('extgallery') && $module_handler->getCount(new Criteria('dirname', 'extgallery'))) { | 
| 296: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('extgallery_publicphoto') . ' WHERE photo_approved=0'; | 
| 297: | $result = $xoopsDB->query($sql); | 
| 298: | if ($xoopsDB->isResultSet($result)) { | 
| 299: | $block['modules'][9]['adminlink'] = XOOPS_URL . '/modules/extgallery/admin/photo.php#pending-photo'; | 
| 300: | list($block['modules'][9]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 301: | $block['modules'][9]['lang_linkname'] = _MB_SYSTEM_EXTGALLERY; | 
| 302: | } | 
| 303: | } | 
| 304: |  | 
| 305: |  | 
| 306: | if (xoops_isActiveModule('smartsection') && $module_handler->getCount(new Criteria('dirname', 'smartsection'))) { | 
| 307: | $sql = 'SELECT COUNT(*) FROM ' . $xoopsDB->prefix('smartsection_items') . ' WHERE status=1'; | 
| 308: | $result = $xoopsDB->query($sql); | 
| 309: | if ($xoopsDB->isResultSet($result)) { | 
| 310: | $block['modules'][10]['adminlink'] = XOOPS_URL . '/modules/smartsection/admin/item.php'; | 
| 311: | list($block['modules'][10]['pendingnum']) = $xoopsDB->fetchRow($result); | 
| 312: | $block['modules'][10]['lang_linkname'] = _MB_SYSTEM_SMARTSECTION; | 
| 313: | } | 
| 314: | } | 
| 315: | $GLOBALS['xoopsLogger']->addDeprecated("Block 'Waiting Contents' is deprecated since XOOPS 2.5.11, please use waiting module"); | 
| 316: | return $block; | 
| 317: | } | 
| 318: |  | 
| 319: |  | 
| 320: |  | 
| 321: |  | 
| 322: |  | 
| 323: |  | 
| 324: | function b_system_info_show($options) | 
| 325: | { | 
| 326: | global $xoopsConfig, $xoopsUser; | 
| 327: | $xoopsDB = XoopsDatabaseFactory::getDatabaseConnection(); | 
| 328: | $myts    = \MyTextSanitizer::getInstance(); | 
| 329: | $block   = array(); | 
| 330: | if (!empty($options[3])) { | 
| 331: | $block['showgroups'] = true; | 
| 332: | $sql = 'SELECT u.uid, u.uname, u.email, u.user_viewemail, u.user_avatar, g.name AS groupname FROM ' . $xoopsDB->prefix('groups_users_link') . ' l LEFT JOIN ' . $xoopsDB->prefix('users') . ' u ON l.uid=u.uid LEFT JOIN ' . $xoopsDB->prefix('groups') . " g ON l.groupid=g.groupid WHERE g.group_type='Admin' ORDER BY l.groupid, u.uid"; | 
| 333: | $result = $xoopsDB->query($sql); | 
| 334: | if ($xoopsDB->isResultSet($result) && $xoopsDB->getRowsNum($result) > 0) { | 
| 335: | $prev_caption = ''; | 
| 336: | $i            = 0; | 
| 337: | while (false !== ($userinfo = $xoopsDB->fetchArray($result))) { | 
| 338: | if ($prev_caption != $userinfo['groupname']) { | 
| 339: | $prev_caption                = $userinfo['groupname']; | 
| 340: | $block['groups'][$i]['name'] = $myts->htmlSpecialChars($userinfo['groupname']); | 
| 341: | } | 
| 342: | if (isset($xoopsUser) && is_object($xoopsUser)) { | 
| 343: | $block['groups'][$i]['users'][] = array( | 
| 344: | 'id'      => $userinfo['uid'], | 
| 345: | 'name'    => $myts->htmlSpecialChars($userinfo['uname']), | 
| 346: | 'msglink' => "<a href=\"javascript:openWithSelfMain('" . XOOPS_URL . '/pmlite.php?send2=1&to_userid=' . $userinfo['uid'] . "','pmlite',565,500);\"><img src=\"" . XOOPS_URL . "/images/icons/pm_small.gif\" border=\"0\" width=\"27\" height=\"17\" alt=\"\" /></a>", | 
| 347: | 'avatar'  => XOOPS_UPLOAD_URL . '/' . $userinfo['user_avatar']); | 
| 348: | } else { | 
| 349: | if ($userinfo['user_viewemail']) { | 
| 350: | $block['groups'][$i]['users'][] = array( | 
| 351: | 'id'      => $userinfo['uid'], | 
| 352: | 'name'    => $myts->htmlSpecialChars($userinfo['uname']), | 
| 353: | 'msglink' => '<a href="mailto:' . $userinfo['email'] . '"><img src="' . XOOPS_URL . '/images/icons/em_small.gif" border="0" width="16" height="14" alt="" /></a>', | 
| 354: | 'avatar'  => XOOPS_UPLOAD_URL . '/' . $userinfo['user_avatar']); | 
| 355: | } else { | 
| 356: | $block['groups'][$i]['users'][] = array( | 
| 357: | 'id'      => $userinfo['uid'], | 
| 358: | 'name'    => $myts->htmlSpecialChars($userinfo['uname']), | 
| 359: | 'msglink' => ' ', | 
| 360: | 'avatar'  => XOOPS_UPLOAD_URL . '/' . $userinfo['user_avatar']); | 
| 361: | } | 
| 362: | } | 
| 363: | ++$i; | 
| 364: | } | 
| 365: | } | 
| 366: | } else { | 
| 367: | $block['showgroups'] = false; | 
| 368: | } | 
| 369: | $block['logourl']       = XOOPS_URL . '/images/' . $options[2]; | 
| 370: | $block['recommendlink'] = "<a href=\"javascript:openWithSelfMain('" . XOOPS_URL . '/misc.php?action=showpopups&type=friend&op=sendform&t=' . time() . "','friend'," . $options[0] . ',' . $options[1] . ")\">" . _MB_SYSTEM_RECO . '</a>'; | 
| 371: |  | 
| 372: | return $block; | 
| 373: | } | 
| 374: |  | 
| 375: |  | 
| 376: |  | 
| 377: |  | 
| 378: |  | 
| 379: |  | 
| 380: | function b_system_newmembers_show($options) | 
| 381: | { | 
| 382: | $block    = array(); | 
| 383: | $criteria = new CriteriaCompo(new Criteria('level', 0, '>')); | 
| 384: | $limit    = (!empty($options[0])) ? $options[0] : 10; | 
| 385: | $criteria->setOrder('DESC'); | 
| 386: | $criteria->setSort('user_regdate'); | 
| 387: | $criteria->setLimit($limit); | 
| 388: |  | 
| 389: | $member_handler = xoops_getHandler('member'); | 
| 390: | $newmembers     = $member_handler->getUsers($criteria); | 
| 391: | $count          = count($newmembers); | 
| 392: | for ($i = 0; $i < $count; ++$i) { | 
| 393: | if ($options[1] == 1) { | 
| 394: | $block['users'][$i]['avatar'] = $newmembers[$i]->getVar('user_avatar') !== 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $newmembers[$i]->getVar('user_avatar') : ''; | 
| 395: | } else { | 
| 396: | $block['users'][$i]['avatar'] = ''; | 
| 397: | } | 
| 398: | $block['users'][$i]['id']       = $newmembers[$i]->getVar('uid'); | 
| 399: | $block['users'][$i]['name']     = $newmembers[$i]->getVar('uname'); | 
| 400: | $block['users'][$i]['joindate'] = formatTimestamp($newmembers[$i]->getVar('user_regdate'), 's'); | 
| 401: | } | 
| 402: |  | 
| 403: | return $block; | 
| 404: | } | 
| 405: |  | 
| 406: |  | 
| 407: |  | 
| 408: |  | 
| 409: |  | 
| 410: |  | 
| 411: | function b_system_topposters_show($options) | 
| 412: | { | 
| 413: | $block    = array(); | 
| 414: | $criteria = new CriteriaCompo(new Criteria('level', 0, '>')); | 
| 415: | $criteria->add(new Criteria('posts', 0, '>')); | 
| 416: | $limit    = (!empty($options[0])) ? $options[0] : 10; | 
| 417: | $size     = count($options); | 
| 418: | for ($i = 2; $i < $size; ++$i) { | 
| 419: | $criteria->add(new Criteria('rank', $options[$i], '<>')); | 
| 420: | } | 
| 421: | $criteria->setOrder('DESC'); | 
| 422: | $criteria->setSort('posts'); | 
| 423: | $criteria->setLimit($limit); | 
| 424: |  | 
| 425: | $member_handler = xoops_getHandler('member'); | 
| 426: | $topposters     = $member_handler->getUsers($criteria); | 
| 427: | $count          = count($topposters); | 
| 428: | for ($i = 0; $i < $count; ++$i) { | 
| 429: | $block['users'][$i]['rank'] = $i + 1; | 
| 430: | if ($options[1] == 1) { | 
| 431: | $block['users'][$i]['avatar'] = $topposters[$i]->getVar('user_avatar') !== 'blank.gif' ? XOOPS_UPLOAD_URL . '/' . $topposters[$i]->getVar('user_avatar') : ''; | 
| 432: | } else { | 
| 433: | $block['users'][$i]['avatar'] = ''; | 
| 434: | } | 
| 435: | $block['users'][$i]['id']    = $topposters[$i]->getVar('uid'); | 
| 436: | $block['users'][$i]['name']  = $topposters[$i]->getVar('uname'); | 
| 437: | $block['users'][$i]['posts'] = $topposters[$i]->getVar('posts'); | 
| 438: | } | 
| 439: |  | 
| 440: | return $block; | 
| 441: | } | 
| 442: |  | 
| 443: |  | 
| 444: |  | 
| 445: |  | 
| 446: |  | 
| 447: |  | 
| 448: | function b_system_comments_show($options) | 
| 449: | { | 
| 450: | $block = array(); | 
| 451: | include_once XOOPS_ROOT_PATH . '/include/comment_constants.php'; | 
| 452: | $comment_handler = xoops_getHandler('comment'); | 
| 453: | $criteria        = new CriteriaCompo(new Criteria('com_status', XOOPS_COMMENT_ACTIVE)); | 
| 454: | $criteria->setLimit((int)$options[0]); | 
| 455: | $criteria->setSort('com_created'); | 
| 456: | $criteria->setOrder('DESC'); | 
| 457: |  | 
| 458: |  | 
| 459: | global $xoopsUser; | 
| 460: | $moduleperm_handler = xoops_getHandler('groupperm'); | 
| 461: | $gperm_groupid      = is_object($xoopsUser) ? $xoopsUser->getGroups() : array(XOOPS_GROUP_ANONYMOUS); | 
| 462: | $criteria1          = new CriteriaCompo(new Criteria('gperm_name', 'module_read', '=')); | 
| 463: | $criteria1->add(new Criteria('gperm_groupid', '(' . implode(',', $gperm_groupid) . ')', 'IN')); | 
| 464: | $perms  = $moduleperm_handler->getObjects($criteria1, true); | 
| 465: | $modIds = array(); | 
| 466: | foreach ($perms as $item) { | 
| 467: | $modIds[] = $item->getVar('gperm_itemid'); | 
| 468: | } | 
| 469: | if (count($modIds) > 0) { | 
| 470: | $modIds = array_unique($modIds); | 
| 471: | $criteria->add(new Criteria('com_modid', '(' . implode(',', $modIds) . ')', 'IN')); | 
| 472: | } | 
| 473: |  | 
| 474: |  | 
| 475: | $comments       = $comment_handler->getObjects($criteria, true); | 
| 476: |  | 
| 477: | $member_handler = xoops_getHandler('member'); | 
| 478: |  | 
| 479: | $module_handler = xoops_getHandler('module'); | 
| 480: | $modules        = $module_handler->getObjects(new Criteria('hascomments', 1), true); | 
| 481: | $comment_config = array(); | 
| 482: | foreach (array_keys($comments) as $i) { | 
| 483: | $mid           = $comments[$i]->getVar('com_modid'); | 
| 484: | $com['module'] = '<a href="' . XOOPS_URL . '/modules/' . $modules[$mid]->getVar('dirname') . '/">' . $modules[$mid]->getVar('name') . '</a>'; | 
| 485: | if (!isset($comment_config[$mid])) { | 
| 486: | $comment_config[$mid] = $modules[$mid]->getInfo('comments'); | 
| 487: | } | 
| 488: | $com['id']    = $i; | 
| 489: | $com['title'] = '<a href="' . XOOPS_URL . '/modules/' . $modules[$mid]->getVar('dirname') . '/' . $comment_config[$mid]['pageName'] . '?' . $comment_config[$mid]['itemName'] . '=' . $comments[$i]->getVar('com_itemid') . '&com_id=' . $i . '&com_rootid=' . $comments[$i]->getVar('com_rootid') . '&' . htmlspecialchars($comments[$i]->getVar('com_exparams'), ENT_QUOTES) . '#comment' . $i . '">' . $comments[$i]->getVar('com_title') . '</a>'; | 
| 490: | $com['icon']  = htmlspecialchars($comments[$i]->getVar('com_icon'), ENT_QUOTES); | 
| 491: | $com['icon']  = ($com['icon'] != '') ? $com['icon'] : 'icon1.gif'; | 
| 492: | $com['time']  = formatTimestamp($comments[$i]->getVar('com_created'), 'm'); | 
| 493: | if ($comments[$i]->getVar('com_uid') > 0) { | 
| 494: | $poster = $member_handler->getUser($comments[$i]->getVar('com_uid')); | 
| 495: | if (is_object($poster)) { | 
| 496: | $com['poster'] = '<a href="' . XOOPS_URL . '/userinfo.php?uid=' . $comments[$i]->getVar('com_uid') . '">' . $poster->getVar('uname') . '</a>'; | 
| 497: | } else { | 
| 498: | $com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; | 
| 499: | } | 
| 500: | } else { | 
| 501: | $com['poster'] = $GLOBALS['xoopsConfig']['anonymous']; | 
| 502: | } | 
| 503: | $block['comments'][] =& $com; | 
| 504: | unset($com); | 
| 505: | } | 
| 506: |  | 
| 507: | return $block; | 
| 508: | } | 
| 509: |  | 
| 510: |  | 
| 511: |  | 
| 512: |  | 
| 513: |  | 
| 514: | function b_system_notification_show() | 
| 515: | { | 
| 516: | global $xoopsConfig, $xoopsUser, $xoopsModule; | 
| 517: | include_once XOOPS_ROOT_PATH . '/include/notification_functions.php'; | 
| 518: | include_once XOOPS_ROOT_PATH . '/language/' . $xoopsConfig['language'] . '/notification.php'; | 
| 519: |  | 
| 520: | if (empty($xoopsUser) || !notificationEnabled('block')) { | 
| 521: | return false; | 
| 522: | } | 
| 523: | $notification_handler = xoops_getHandler('notification'); | 
| 524: |  | 
| 525: |  | 
| 526: | $block      = array(); | 
| 527: | $categories =& notificationSubscribableCategoryInfo(); | 
| 528: | if (empty($categories)) { | 
| 529: | return false; | 
| 530: | } | 
| 531: | foreach ($categories as $category) { | 
| 532: | $section['name']        = $category['name']; | 
| 533: | $section['title']       = $category['title']; | 
| 534: | $section['description'] = $category['description']; | 
| 535: | $section['itemid']      = $category['item_id']; | 
| 536: | $section['events']      = array(); | 
| 537: | $subscribed_events      = $notification_handler->getSubscribedEvents($category['name'], $category['item_id'], $xoopsModule->getVar('mid'), $xoopsUser->getVar('uid')); | 
| 538: | foreach (notificationEvents($category['name'], true) as $event) { | 
| 539: | if (!empty($event['admin_only']) && !$xoopsUser->isAdmin($xoopsModule->getVar('mid'))) { | 
| 540: | continue; | 
| 541: | } | 
| 542: | $subscribed                        = in_array($event['name'], $subscribed_events) ? 1 : 0; | 
| 543: | $section['events'][$event['name']] = array( | 
| 544: | 'name'        => $event['name'], | 
| 545: | 'title'       => $event['title'], | 
| 546: | 'caption'     => $event['caption'], | 
| 547: | 'description' => $event['description'], | 
| 548: | 'subscribed'  => $subscribed); | 
| 549: | } | 
| 550: | $block['categories'][$category['name']] = $section; | 
| 551: | } | 
| 552: |  | 
| 553: | $block['target_page'] = 'notification_update.php'; | 
| 554: |  | 
| 555: | $script_url                  = explode('/', $_SERVER['PHP_SELF']); | 
| 556: | $script_name                 = $script_url[count($script_url) - 1]; | 
| 557: | $block['redirect_script']    = $script_name; | 
| 558: | $block['submit_button']      = _NOT_UPDATENOW; | 
| 559: | $block['notification_token'] = $GLOBALS['xoopsSecurity']->createToken(); | 
| 560: |  | 
| 561: | return $block; | 
| 562: | } | 
| 563: |  | 
| 564: |  | 
| 565: |  | 
| 566: |  | 
| 567: |  | 
| 568: |  | 
| 569: | function b_system_comments_edit($options) | 
| 570: | { | 
| 571: | $inputtag = "<input type='text' name='options[]' value='" . (int)$options[0] . "' />"; | 
| 572: | $form     = sprintf(_MB_SYSTEM_DISPLAYC, $inputtag); | 
| 573: |  | 
| 574: | return $form; | 
| 575: | } | 
| 576: |  | 
| 577: |  | 
| 578: |  | 
| 579: |  | 
| 580: |  | 
| 581: |  | 
| 582: | function b_system_topposters_edit($options) | 
| 583: | { | 
| 584: | include_once XOOPS_ROOT_PATH . '/class/xoopslists.php'; | 
| 585: | $inputtag = "<input type='text' name='options[]' value='" . (int)$options[0] . "' />"; | 
| 586: | $form     = sprintf(_MB_SYSTEM_DISPLAY, $inputtag); | 
| 587: | $form .= '<br>' . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'"; | 
| 588: | if ($options[1] == 1) { | 
| 589: | $form .= " checked"; | 
| 590: | } | 
| 591: | $form .= ' /> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'"; | 
| 592: | if ($options[1] == 0) { | 
| 593: | $form .= " checked"; | 
| 594: | } | 
| 595: | $form .= ' /> ' . _NO . ''; | 
| 596: | $form .= '<br>' . _MB_SYSTEM_NODISPGR . "<br><select id='options[]' name='options[]' multiple='multiple'>"; | 
| 597: | $ranks = XoopsLists::getUserRankList(); | 
| 598: | $size  = count($options); | 
| 599: | foreach ($ranks as $k => $v) { | 
| 600: | $sel = ''; | 
| 601: | for ($i = 2; $i < $size; ++$i) { | 
| 602: | if ($k == $options[$i]) { | 
| 603: | $sel = " selected"; | 
| 604: | } | 
| 605: | } | 
| 606: | $form .= "<option value='$k'$sel>$v</option>"; | 
| 607: | } | 
| 608: | $form .= '</select>'; | 
| 609: |  | 
| 610: | return $form; | 
| 611: | } | 
| 612: |  | 
| 613: |  | 
| 614: |  | 
| 615: |  | 
| 616: |  | 
| 617: |  | 
| 618: | function b_system_newmembers_edit($options) | 
| 619: | { | 
| 620: | $inputtag = "<input type='text' name='options[]' value='" . $options[0] . "' />"; | 
| 621: | $form     = sprintf(_MB_SYSTEM_DISPLAY, $inputtag); | 
| 622: | $form .= '<br>' . _MB_SYSTEM_DISPLAYA . " <input type='radio' id='options[]' name='options[]' value='1'"; | 
| 623: | if ($options[1] == 1) { | 
| 624: | $form .= " checked"; | 
| 625: | } | 
| 626: | $form .= ' /> ' . _YES . "<input type='radio' id='options[]' name='options[]' value='0'"; | 
| 627: | if ($options[1] == 0) { | 
| 628: | $form .= " checked"; | 
| 629: | } | 
| 630: | $form .= ' /> ' . _NO . ''; | 
| 631: |  | 
| 632: | return $form; | 
| 633: | } | 
| 634: |  | 
| 635: |  | 
| 636: |  | 
| 637: |  | 
| 638: |  | 
| 639: |  | 
| 640: | function b_system_info_edit($options) | 
| 641: | { | 
| 642: | $form = _MB_SYSTEM_PWWIDTH . ' '; | 
| 643: | $form .= "<input type='text' name='options[]' value='" . $options[0] . "' />"; | 
| 644: | $form .= '<br>' . _MB_SYSTEM_PWHEIGHT . ' '; | 
| 645: | $form .= "<input type='text' name='options[]' value='" . $options[1] . "' />"; | 
| 646: | $form .= '<br>' . sprintf(_MB_SYSTEM_LOGO, XOOPS_URL . '/images/') . ' '; | 
| 647: | $form .= "<input type='text' name='options[]' value='" . $options[2] . "' />"; | 
| 648: | $chk = ''; | 
| 649: | $form .= '<br>' . _MB_SYSTEM_SADMIN . ' '; | 
| 650: | if ($options[3] == 1) { | 
| 651: | $chk = " checked"; | 
| 652: | } | 
| 653: | $form .= "<input type='radio' name='options[3]' value='1'" . $chk . ' /> ' . _YES . ''; | 
| 654: | $chk = ''; | 
| 655: | if ($options[3] == 0) { | 
| 656: | $chk = " checked"; | 
| 657: | } | 
| 658: | $form .= " <input type='radio' name='options[3]' value='0'" . $chk . ' />' . _NO . ''; | 
| 659: |  | 
| 660: | return $form; | 
| 661: | } | 
| 662: |  | 
| 663: |  | 
| 664: |  | 
| 665: |  | 
| 666: |  | 
| 667: |  | 
| 668: | function b_system_themes_show($options) | 
| 669: | { | 
| 670: | global $xoopsConfig; | 
| 671: | $block = array(); | 
| 672: |  | 
| 673: | if (!isset($options[2])) { | 
| 674: | $options[2] = 3; | 
| 675: | } | 
| 676: | $selectSize = ($options[0] == 1) ? 1 : (int) $options[2]; | 
| 677: | $select = new XoopsFormSelect('', 'xoops_theme_select', $xoopsConfig['theme_set'], $selectSize); | 
| 678: | foreach ($xoopsConfig['theme_set_allowed'] as $theme) { | 
| 679: | $select->addOption($theme, $theme); | 
| 680: | } | 
| 681: |  | 
| 682: | if ($options[0] == 1) { | 
| 683: | $themeSelect = '<img vspace="2" id="xoops_theme_img" src="' | 
| 684: | . XOOPS_THEME_URL . '/' . $xoopsConfig['theme_set'] . '/shot.gif" ' | 
| 685: | . ' alt="screenshot" width="' . (int)$options[1] . '" />' | 
| 686: | . '<br>'; | 
| 687: | $select->setExtra(' onchange="showImgSelected(\'xoops_theme_img\', \'xoops_theme_select\', \'themes\', \'/shot.gif\', ' | 
| 688: | .  '\'' . XOOPS_URL . '\');" '); | 
| 689: | $selectTray = new XoopsFormElementTray(''); | 
| 690: | $selectTray->addElement($select); | 
| 691: | $selectTray->addElement(new XoopsFormButton('', 'submit', _GO, 'submit')); | 
| 692: | $themeSelect .= '<div class="form-inline">'; | 
| 693: | $themeSelect .= $selectTray->render(); | 
| 694: | $themeSelect .= '</div>'; | 
| 695: | } else { | 
| 696: | $select->setExtra(' onchange="submit();" '); | 
| 697: | $themeSelect = $select->render(); | 
| 698: | } | 
| 699: |  | 
| 700: | $block['theme_select'] = $themeSelect . '<br>(' . sprintf(_MB_SYSTEM_NUMTHEME, '<strong>' | 
| 701: | . count($xoopsConfig['theme_set_allowed']) . '</strong>') . ')<br>'; | 
| 702: |  | 
| 703: | return $block; | 
| 704: | } | 
| 705: |  | 
| 706: |  | 
| 707: |  | 
| 708: |  | 
| 709: |  | 
| 710: |  | 
| 711: | function b_system_themes_edit($options) | 
| 712: | { | 
| 713: | $chk  = ''; | 
| 714: | $form = _MB_SYSTEM_THSHOW . ' '; | 
| 715: | if (!isset($options[2])) { | 
| 716: | $options[2] = 3; | 
| 717: | } | 
| 718: | if ($options[0] == 1) { | 
| 719: | $chk = " checked"; | 
| 720: | } | 
| 721: | $form .= "<input type='radio' name='options[0]' value='1'" . $chk . ' /> ' . _YES; | 
| 722: | $chk = ''; | 
| 723: | if ($options[0] == 0) { | 
| 724: | $chk = ' checked'; | 
| 725: | } | 
| 726: | $form .= ' <input type="radio" name="options[0]" value="0"' . $chk . ' />' . _NO; | 
| 727: | $form .= '<br>' . _MB_SYSTEM_THWIDTH . ' '; | 
| 728: | $form .= "<input type='text' name='options[1]' value='" . $options[1] . "' />"; | 
| 729: | $form .= '<br>' . _MB_SYSTEM_BLOCK_HEIGHT . ' '; | 
| 730: | $form .= "<input type='text' name='options[2]' value='" . $options[2] . "' />"; | 
| 731: |  | 
| 732: | return $form; | 
| 733: | } | 
| 734: |  |