📄 system_blocks.php
字号:
<?php
// $Id: system_blocks.php,v 1.43.2.1 2004/12/26 21:56:15 mithyt2 Exp $
// ------------------------------------------------------------------------ //
// XOOPS - PHP Content Management System //
// Copyright (c) 2000 XOOPS.org //
// <http://www.xoops.org/> //
// ------------------------------------------------------------------------ //
// This program is free software; you can redistribute it and/or modify //
// it under the terms of the GNU General Public License as published by //
// the Free Software Foundation; either version 2 of the License, or //
// (at your option) any later version. //
// //
// You may not change or alter any portion of this comment or credits //
// of supporting developers from this source code or any supporting //
// source code which is considered copyrighted (c) material of the //
// original comment or credit authors. //
// //
// This program is distributed in the hope that it will be useful, //
// but WITHOUT ANY WARRANTY; without even the implied warranty of //
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
// GNU General Public License for more details. //
// //
// You should have received a copy of the GNU General Public License //
// along with this program; if not, write to the Free Software //
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA //
// ------------------------------------------------------------------------ //
// Author: Kazumi Ono (AKA onokazu) //
// URL: http://www.myweb.ne.jp/, http://www.xoops.org/, http://jp.xoops.org/ //
// Project: The XOOPS Project //
// ------------------------------------------------------------------------- //
function b_system_online_show()
{
global $xoopsUser, $xoopsModule;
$online_handler =& xoops_gethandler('online');
mt_srand((double)microtime()*1000000);
// set gc probabillity to 10% for now..
if (mt_rand(1, 100) < 11) {
$online_handler->gc(300);
}
if (is_object($xoopsUser)) {
$uid = $xoopsUser->getVar('uid');
$uname = $xoopsUser->getVar('uname');
} else {
$uid = 0;
$uname = '';
}
if (is_object($xoopsModule)) {
$online_handler->write($uid, $uname, time(), $xoopsModule->getVar('mid'), $_SERVER['REMOTE_ADDR']);
} else {
$online_handler->write($uid, $uname, time(), 0, $_SERVER['REMOTE_ADDR']);
}
$onlines =& $online_handler->getAll();
if (false != $onlines) {
$total = count($onlines);
$block = array();
$guests = 0;
$members = '';
for ($i = 0; $i < $total; $i++) {
if ($onlines[$i]['online_uid'] > 0) {
$members .= ' <a href="'.XOOPS_URL.'/userinfo.php?uid='.$onlines[$i]['online_uid'].'">'.$onlines[$i]['online_uname'].'</a>,';
} else {
$guests++;
}
}
$block['online_total'] = sprintf(_ONLINEPHRASE, $total);
if (is_object($xoopsModule)) {
$mytotal = $online_handler->getCount(new Criteria('online_module', $xoopsModule->getVar('mid')));
$block['online_total'] .= ' ('.sprintf(_ONLINEPHRASEX, $mytotal, $xoopsModule->getVar('name')).')';
}
$block['lang_members'] = _MEMBERS;
$block['lang_guests'] = _GUESTS;
$block['online_names'] = $members;
$block['online_members'] = $total - $guests;
$block['online_guests'] = $guests;
$block['lang_more'] = _MORE;
return $block;
} else {
return false;
}
}
function b_system_login_show()
{
global $xoopsUser, $xoopsConfig;
if (!$xoopsUser) {
$block = array();
$block['lang_username'] = _USERNAME;
$block['unamevalue'] = "";
if (isset($_COOKIE[$xoopsConfig['usercookie']])) {
$block['unamevalue'] = $_COOKIE[$xoopsConfig['usercookie']];
}
$block['lang_password'] = _PASSWORD;
$block['lang_login'] = _LOGIN;
$block['lang_lostpass'] = _MB_SYSTEM_LPASS;
$block['lang_registernow'] = _MB_SYSTEM_RNOW;
//$block['lang_rememberme'] = _MB_SYSTEM_REMEMBERME;
if ($xoopsConfig['use_ssl'] == 1 && $xoopsConfig['sslloginlink'] != '') {
$block['sslloginlink'] = "<a href=\"javascript:openWithSelfMain('".$xoopsConfig['sslloginlink']."', 'ssllogin', 300, 200);\">"._MB_SYSTEM_SECURE."</a>";
}
return $block;
}
return false;
}
function b_system_main_show()
{
global $xoopsUser,$xoopsModule;
$block = array();
$block['lang_home'] = _MB_SYSTEM_HOME;
$block['lang_close'] = _CLOSE;
$module_handler =& xoops_gethandler('module');
$criteria = new CriteriaCompo(new Criteria('hasmain', 1));
$criteria->add(new Criteria('isactive', 1));
$criteria->add(new Criteria('weight', 0, '>'));
$modules =& $module_handler->getObjects($criteria, true);
$moduleperm_handler =& xoops_gethandler('groupperm');
$groups = is_object($xoopsUser) ? $xoopsUser->getGroups() : XOOPS_GROUP_ANONYMOUS;
$read_allowed =& $moduleperm_handler->getItemIds('module_read', $groups);
foreach (array_keys($modules) as $i) {
if (in_array($i, $read_allowed)) {
$block['modules'][$i]['name'] = $modules[$i]->getVar('name');
$block['modules'][$i]['directory'] = $modules[$i]->getVar('dirname');
$sublinks =& $modules[$i]->subLink();
if ((count($sublinks) > 0) && (!empty($xoopsModule)) && ($i == $xoopsModule->getVar('mid'))) {
foreach($sublinks as $sublink){
$block['modules'][$i]['sublinks'][] = array('name' => $sublink['name'], 'url' => XOOPS_URL.'/modules/'.$modules[$i]->getVar('dirname').'/'.$sublink['url']);
}
} else {
$block['modules'][$i]['sublinks'] = array();
}
}
}
return $block;
}
function b_system_search_show()
{
$block = array();
$block['lang_search'] = _MB_SYSTEM_SEARCH;
$block['lang_advsearch'] = _MB_SYSTEM_ADVS;
return $block;
}
function b_system_user_show()
{
global $xoopsUser;
if (is_object($xoopsUser)) {
$pm_handler =& xoops_gethandler('privmessage');
$block = array();
$block['lang_youraccount'] = _MB_SYSTEM_VACNT;
$block['lang_editaccount'] = _MB_SYSTEM_EACNT;
$block['lang_notifications'] = _MB_SYSTEM_NOTIF;
$block['uid'] = $xoopsUser->getVar('uid');
$block['lang_logout'] = _MB_SYSTEM_LOUT;
$criteria = new CriteriaCompo(new Criteria('read_msg', 0));
$criteria->add(new Criteria('to_userid', $xoopsUser->getVar('uid')));
$block['new_messages'] = $pm_handler->getCount($criteria);
$block['lang_inbox'] = _MB_SYSTEM_INBOX;
$block['lang_adminmenu'] = _MB_SYSTEM_ADMENU;
return $block;
}
return false;
}
// this block is deprecated
function b_system_waiting_show()
{
global $xoopsUser;
$xoopsDB =& Database::getInstance();
$module_handler =& xoops_gethandler('module');
$block = array();
if ($module_handler->getCount(new Criteria('dirname', 'news'))) {
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("stories")." WHERE published=0");
if ( $result ) {
$block['modules'][0]['adminlink'] = XOOPS_URL."/modules/news/admin/index.php?op=newarticle";
list($block['modules'][0]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][0]['lang_linkname'] = _MB_SYSTEM_SUBMS;
}
}
if ($module_handler->getCount(new Criteria('dirname', 'mylinks'))) {
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_links")." WHERE status=0");
if ( $result ) {
$block['modules'][1]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listNewLinks";
list($block['modules'][1]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][1]['lang_linkname'] = _MB_SYSTEM_WLNKS;
}
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_broken"));
if ( $result ) {
$block['modules'][2]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listBrokenLinks";
list($block['modules'][2]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][2]['lang_linkname'] = _MB_SYSTEM_BLNK;
}
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mylinks_mod"));
if ( $result ) {
$block['modules'][3]['adminlink'] = XOOPS_URL."/modules/mylinks/admin/index.php?op=listModReq";
list($block['modules'][3]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][3]['lang_linkname'] = _MB_SYSTEM_MLNKS;
}
}
if ($module_handler->getCount(new Criteria('dirname', 'mydownloads'))) {
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_downloads")." WHERE status=0");
if ( $result ) {
$block['modules'][4]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listNewDownloads";
list($block['modules'][4]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][4]['lang_linkname'] = _MB_SYSTEM_WDLS;
}
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_broken")."");
if ( $result ) {
$block['modules'][5]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listBrokenDownloads";
list($block['modules'][5]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][5]['lang_linkname'] = _MB_SYSTEM_BFLS;
}
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("mydownloads_mod")."");
if ( $result ) {
$block['modules'][6]['adminlink'] = XOOPS_URL."/modules/mydownloads/admin/index.php?op=listModReq";
list($block['modules'][6]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][6]['lang_linkname'] = _MB_SYSTEM_MFLS;
}
}
$result = $xoopsDB->query("SELECT COUNT(*) FROM ".$xoopsDB->prefix("xoopscomments")." WHERE com_status=1");
if ( $result ) {
$block['modules'][7]['adminlink'] = XOOPS_URL."/modules/system/admin.php?module=0&status=1&fct=comments";
list($block['modules'][7]['pendingnum']) = $xoopsDB->fetchRow($result);
$block['modules'][7]['lang_linkname'] =_MB_SYSTEM_COMPEND;
}
return $block;
}
function b_system_info_show($options)
{
global $xoopsConfig, $xoopsUser;
$xoopsDB =& Database::getInstance();
$myts =& MyTextSanitizer::getInstance();
$block = array();
if (!empty($options[3])) {
$block['showgroups'] = true;
$result = $xoopsDB->query("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");
if ($xoopsDB->getRowsNum($result) > 0) {
$prev_caption = "";
$i = 0;
while ($userinfo = $xoopsDB->fetchArray($result)) {
if ($prev_caption != $userinfo['groupname']) {
$prev_caption = $userinfo['groupname'];
$block['groups'][$i]['name'] = $myts->htmlSpecialChars($userinfo['groupname']);
}
if ($xoopsUser != '') {
$block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => "<a href=\"javascript:openWithSelfMain('".XOOPS_URL."/pmlite.php?send2=1&to_userid=".$userinfo['uid']."','pmlite',450,370);\"><img src=\"".XOOPS_URL."/images/icons/pm_small.gif\" border=\"0\" width=\"27\" height=\"17\" alt=\"\" /></a>", 'avatar' => XOOPS_UPLOAD_URL.'/'.$userinfo['user_avatar']);
} else {
if ($userinfo['user_viewemail']) {
$block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => '<a href="mailto:'.$userinfo['email'].'"><img src="'.XOOPS_URL.'/images/icons/em_small.gif" border="0" width="16" height="14" alt="" /></a>', 'avatar' => XOOPS_UPLOAD_URL.'/'.$userinfo['user_avatar']);
} else {
$block['groups'][$i]['users'][] = array('id' => $userinfo['uid'], 'name' => $myts->htmlspecialchars($userinfo['uname']), 'msglink' => ' ', 'avatar' => XOOPS_UPLOAD_URL.'/'.$userinfo['user_avatar']);
}
}
$i++;
}
}
} else {
$block['showgroups'] = false;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -