本文整理汇总了PHP中UserUtil::isOnline方法的典型用法代码示例。如果您正苦于以下问题:PHP UserUtil::isOnline方法的具体用法?PHP UserUtil::isOnline怎么用?PHP UserUtil::isOnline使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserUtil
的用法示例。
在下文中一共展示了UserUtil::isOnline方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTopicInfo
/**
* 取得帖子的信息
* @param: &$db
* @param: $id
* @param: $pre_page
* @param: $offset_page
* @return: $topic_array
* @access: public
* @static
*/
public static function getTopicInfo(&$db, $id, $pre_page = 10, $offset_page = 0)
{
/*{{{*/
$topic_array = array();
$topic_status = self::getTopicStatus($db, $id);
//如果显示第一页,则必须给出主题
if ($offset_page == 0) {
$sql = 'select title, express, author, content, post_date, is_edit, ' . ' edit_user, edit_time, subject_status, is_best, is_top from bbs_subject where id=?';
$sth = $db->Prepare($sql);
$res = $db->Execute($sth, array($id));
$rows = $res->FetchRow();
$posttime = set_locale_time($rows['post_date']);
$user_name = $rows['author'];
$user_id = UserUtil::getUserId($db, $user_name);
$user_header = UserUtil::getUserHeader($db, $user_id);
$user_info = UserUtil::getUserInfo($db, $user_id);
$register_date = $user_info['register_date'];
$user_level = $user_info['user_level'];
$user_address = $user_info['user_hometown'];
$user_topic_number = $user_info['user_topic'];
$user_sign = ConvertString($user_info['user_sign'], ROOT_URL, IMAGE_URL . 'express/');
$is_edit = 0;
$edit_user = '';
$edit_time = '';
if ($rows['is_edit']) {
$is_edit = 1;
$edit_user = $rows['edit_user'];
$edit_time = $rows['edit_time'];
}
$user_online = UserUtil::isOnline($db, $user_id);
$user_can_be_edit = 0;
if (!$_SESSION['user']['name']) {
$user_can_be_edit = 0;
} else {
if (strtolower($_SESSION['user']['name']) == strtolower($user_name)) {
$user_can_be_edit = 1;
} else {
if (strtolower($_SESSION['user']['name']) != strtolower($user_name)) {
//判断用户是否是这个版块的版主。
$dep = UserUtil::getUserDep($db, $_SESSION['user']['name']);
if ($dep == 1 || $dep == 2) {
$user_can_be_edit = 1;
} else {
if ($dep == 3) {
$temp_layout_id = self::getLayoutId($db, $id);
$user_can_be_edit = UserUtil::isThisLayoutAdmin($db, $id, $temp_layout_id, $_SESSION['user']['name']);
}
}
}
}
}
//判断是否有附件
//如果有附件,则使用代码替换
$content = '';
if ($topic_status == 2) {
$content = TU_TOPIC_WAS_LOCKED;
} else {
$content = $rows['content'] . self::haveAttach($db, $id);
if ($is_edit) {
$attach_string = TU_SUB_TITLE . $edit_user . TU_FROM . $edit_time . TU_EDIT;
$content .= "\n\n" . $attach_string;
}
}
$title = $rows['title'];
$title = htmlspecialchars($title);
if ($rows['is_best']) {
$title = "<font color=red>[" . BEST_LABEL . "]</font>" . $title;
}
if ($rows['is_top']) {
$title = "<font color=red>[" . TOP_LABEL . "]</font>" . $title;
}
$topic_array[] = array('id' => $id, 'posttime' => $posttime, 'sort_number' => 1, 'user_name' => $user_name, 'user_id' => $user_id, 'user_header' => $user_header, 'user_sign' => $user_sign, 'register_date' => $register_date, 'user_level' => $user_level, 'user_address' => $user_address, 'user_topic_number' => $user_topic_number, 'title' => $title, 'content' => ConvertString($content, ROOT_URL, IMAGE_URL . 'express/'), 'online' => $user_online, 'can_be_edit' => $user_can_be_edit, 'is_topic' => 1, 'express' => $rows['express']);
$pre_page = $pre_page - 1;
} else {
if ($offset_page >= 1) {
$offset_page = $offset_page - 1;
}
}
//再查回复的帖子
$sql = 'select id, title, express,author, content, post_date, is_edit, edit_user, ' . ' edit_time, reply_status from bbs_reply where subject_id=? ' . ' order by id asc';
$res = $db->SelectLimit($sql, $pre_page, $offset_page, array($id));
while ($rows = $res->FetchRow()) {
$posttime = set_locale_time($rows['post_date']);
$sort_number = $sort_begin;
$user_name = $rows['author'];
$user_id = UserUtil::getUserId($db, $user_name);
$user_header = UserUtil::getUserHeader($db, $user_id);
$user_info = UserUtil::getUserInfo($db, $user_id);
$register_date = $user_info['register_date'];
$user_level = $user_info['user_level'];
//.........这里部分代码省略.........