⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 forums.php

📁 极限网络智能办公系统—MYOA26—100%—源程序。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
		{
			$this->read_array = unserialize( stripslashes( $read ) );
		}
		if ( $forum = $std->my_getcookie( "fread_".$ibforums->input['f'] ) )
		{
			$ibforums->input['last_visit'] = $ibforums->input['last_visit'] < $forum ? $forum : $ibforums->input['last_visit'];
		}
		$prune_value = $std->select_var( array(
			1 => $ibforums->input['prune_day'],
			2 => $this->forum['prune'],
			3 => "100"
		) );
		$sort_key = $std->select_var( array(
			1 => $ibforums->input['sort_key'],
			2 => $this->forum['sort_key'],
			3 => "last_post"
		) );
		$sort_by = $std->select_var( array(
			1 => $ibforums->input['sort_by'],
			2 => $this->forum['sort_order'],
			3 => "Z-A"
		) );
		$First = $std->select_var( array(
			1 => intval( $ibforums->input['st'] ),
			2 => 0
		) );
		$Prune = $prune_value != 100 ? time( ) - $prune_value * 60 * 60 * 24 : 0;
		$sort_keys = array( "last_post" => "sort_by_date", "title" => "sort_by_topic", "starter_name" => "sort_by_poster", "posts" => "sort_by_replies", "views" => "sort_by_views", "start_date" => "sort_by_start", "last_poster_name" => "sort_by_last_poster" );
		$prune_by_day = array( "1" => "show_today", "5" => "show_5_days", "7" => "show_7_days", "10" => "show_10_days", "15" => "show_15_days", "20" => "show_20_days", "25" => "show_25_days", "30" => "show_30_days", "60" => "show_60_days", "90" => "show_90_days", "100" => "show_all" );
		$sort_by_keys = array( "Z-A" => "descending_order", "A-Z" => "ascending_order" );
		if ( !isset( $sort_keys[$sort_key] ) && !isset( $prune_by_day[$prune_value] ) && !isset( $sort_by_keys[$sort_by] ) )
		{
			$std->error( array( 5, "incorrect_use" ) );
		}
		$r_sort_by = $sort_by == "A-Z" ? "ASC" : "DESC";
		$DB->query( "SELECT COUNT(tid) as max FROM ibf_topics WHERE forum_id='".$this->forum['id']."' and approved='1' and (last_post > {$Prune} or pinned=1)" );
		$total_possible = $DB->fetch_row( );
		$this->forum['SHOW_PAGES'] = $std->build_pagelinks( array(
			"TOTAL_POSS" => $total_possible[max],
			"PER_PAGE" => $ibforums->vars['display_max_topics'],
			"CUR_ST_VAL" => $ibforums->input['st'],
			"L_SINGLE" => $ibforums->lang['single_page_forum'],
			"L_MULTI" => $ibforums->lang['multi_page_forum'],
			"BASE_URL" => $this->base_url."&act=SF&f=".$this->forum['id']."&prune_day={$prune_value}&sort_by={$sort_by}&sort_key={$sort_key}"
		) );
		if ( $this->forum['show_rules'] )
		{
			$DB->query( "SELECT * from ibf_rules WHERE fid='".$this->forum['id']."'" );
			if ( $rules = $DB->fetch_row( ) )
			{
				$rules['title'] = stripslashes( $rules['title'] );
				$rules['body'] = stripslashes( $rules['body'] );
				$this->output .= $rules['show_all'] ? $this->html->show_rules_full( $rules ) : $this->html->show_rules_link( $rules );
			}
		}
		$this->forum['POLL_BUTTON'] = $this->forum['allow_poll'] ? "<a href='".$this->base_url."&act=Post&CODE=10&f=".$this->forum['id']."'><{A_POLL}></a>" : "";
		$this->output .= $this->html->pagetop( $this->forum );
		if ( $ibforums->input['st'] < 1 || !$ibforums->input['st'] )
		{
			$time_now = time( );
			$announce = $DB->query( "SELECT a.*,m.name,m.title FROM ibf_announcements a, ibf_members m WHERE a.a_mid=m.id AND (a.a_forum='".$this->forum['id']."' OR a.a_forum='0') AND ((a.a_start < '".$time_now."' AND a.a_end > '".$time_now."') OR a.a_expire = '0') ORDER by !a.a_forum DESC, a.a_start DESC" );
			$ann_print = "";
			if ( $result = $DB->fetch_row( ) )
			{
				$this->output .= $this->html->announce_start( );
				$this->announce_print = 1;
				$ann_print = "1";
				do
				{
					$this->output .= $this->render_announce( $result );
				} while ( $result = $DB->fetch_row( ) );
			}
		}
		if ( $total_possible['max'] < 1 && !$ann_print )
		{
			$this->output .= $this->html->show_no_matches( );
		}
		$total_topics_printed = 0;
		if ( $ibforums->vars['show_user_posted'] == 1 && $ibforums->member['id'] )
		{
			$query = "SELECT DISTINCT ibf_posts.author_id, ibf_topics.* from ibf_topics LEFT JOIN ibf_posts ON (ibf_topics.tid = ibf_posts.topic_id AND ibf_posts.author_id = '".$ibforums->member['id']."') WHERE ibf_topics.forum_id='".$this->forum['id']."' and (ibf_topics.last_post > '{$Prune}' OR ibf_topics.pinned='1') and ibf_topics.approved='1'";
		}
		else
		{
			$query = "SELECT * from ibf_topics WHERE forum_id='".$this->forum['id']."' and approved='1' and (last_post > '{$Prune}' OR pinned='1')";
		}
		if ( !$ibforums->member['g_other_topics'] )
		{
			$query .= " and starter_id='".$ibforums->member['id']."'";
		}
		$First = $First ? $First : 0;
		$query .= " ORDER BY pinned DESC, {$sort_key} {$r_sort_by} LIMIT {$First},".$ibforums->vars['display_max_topics'];
		$DB->query( $query );
		while ( $topic = $DB->fetch_row( ) )
		{
			$this->output .= $this->render_entry( $topic );
			++$total_topics_printed;
		}
		$ibforums->lang['showing_text'] = preg_replace( "/<#MATCHED_TOPICS#>/", $total_topics_printed, $ibforums->lang['showing_text'] );
		$ibforums->lang['showing_text'] = preg_replace( "/<#TOTAL_TOPICS#>/", $total_possible['max'], $ibforums->lang['showing_text'] );
		$sort_key_html = "<select name='sort_key'  class='forminput'>\n";
		$prune_day_html = "<select name='prune_day' class='forminput'>\n";
		$sort_by_html = "<select name='sort_by'   class='forminput'>\n";
		foreach ( $sort_by_keys as $k => $v )
		{
			$sort_by_html .= $k == $sort_by ? "<option value='{$k}' selected>".$ibforums->lang[$sort_by_keys[$k]]."\n" : "<option value='{$k}'>".$ibforums->lang[$sort_by_keys[$k]]."\n";
		}
		foreach ( $sort_keys as $k => $v )
		{
			$sort_key_html .= $k == $sort_key ? "<option value='{$k}' selected>".$ibforums->lang[$sort_keys[$k]]."\n" : "<option value='{$k}'>".$ibforums->lang[$sort_keys[$k]]."\n";
		}
		foreach ( $prune_by_day as $k => $v )
		{
			$prune_day_html .= $k == $prune_value ? "<option value='{$k}' selected>".$ibforums->lang[$prune_by_day[$k]]."\n" : "<option value='{$k}'>".$ibforums->lang[$prune_by_day[$k]]."\n";
		}
		$ibforums->lang['sort_text'] = preg_replace( "!<#SORT_KEY_HTML#>!", "{$sort_key_html}</select>", $ibforums->lang['sort_text'] );
		$ibforums->lang['sort_text'] = preg_replace( "!<#ORDER_HTML#>!", "{$sort_by_html}</select>", $ibforums->lang['sort_text'] );
		$ibforums->lang['sort_text'] = preg_replace( "!<#PRUNE_HTML#>!", "{$prune_day_html}</select>", $ibforums->lang['sort_text'] );
		$this->output .= $this->html->tableend( $this->forum );
		if ( $ibforums->vars['no_au_forum'] != 1 )
		{
			if ( $this->forum['read_perms'] != "*" )
			{
				$q_extra = " AND s.member_group IN (-2,".$this->forum['read_perms'].") ";
			}
			$cut_off = $ibforums->vars['au_cutoff'] != "" ? $ibforums->vars['au_cutoff'] * 60 : 900;
			$time = time( ) - $cut_off;
			$DB->query( "SELECT s.member_id, s.member_name, s.login_type, s.location, g.suffix, g.prefix\n\t\t\t\t\t    FROM ibf_sessions s\n\t\t\t\t\t     LEFT JOIN ibf_groups g ON (g.g_id=s.member_group)\n\t\t\t\t\t    WHERE s.in_forum='{$this->forum['id']}'\n\t\t\t\t\t    AND s.running_time > '{$time}'".$q_extra."ORDER BY s.running_time DESC" );
			$cached = array( );
			$active = array( "guests" => 0, "anon" => 0, "members" => 0, "names" => "" );
			while ( $result = $DB->fetch_row( ) )
			{
				if ( $result['member_id'] == 0 )
				{
					++$active['guests'];
				}
				else if ( empty( $cached[$result['member_id']] ) )
				{
					$cached[$result['member_id']] = 1;
					if ( $result['login_type'] == 1 )
					{
						if ( $ibforums->member['mgroup'] == $ibforums->vars['admin_group'] && $ibforums->vars['disable_admin_anon'] != 1 )
						{
							$active['names'] .= "<a href='{$ibforums->base_url}&act=Profile&MID={$result['member_id']}'>{$result['prefix']}{$result['member_name']}{$result['suffix']}</a>*, ";
							++$active['anon'];
						}
						else
						{
							++$active['anon'];
						}
					}
					else
					{
						++$active['members'];
						$active['names'] .= "<a href='{$ibforums->base_url}&act=Profile&MID={$result['member_id']}'>{$result['prefix']}{$result['member_name']}{$result['suffix']}</a>, ";
					}
				}
			}
			$active['names'] = preg_replace( "/,\\s+\$/", "", $active['names'] );
			$ibforums->lang['active_users_title'] = sprintf( $ibforums->lang['active_users_title'], $active['members'] + $active['guests'] + $active['anon'] );
			$ibforums->lang['active_users_detail'] = sprintf( $ibforums->lang['active_users_detail'], $active['guests'], $active['anon'] );
			$ibforums->lang['active_users_members'] = sprintf( $ibforums->lang['active_users_members'], $active['members'] );
			$this->output = str_replace( "<!--IBF.FORUM_ACTIVE-->", $this->html->forum_active_users( $active ), $this->output );
		}
		return TRUE;
	}

	function render_entry( $topic )
	{
		global $DB;
		global $std;
		global $ibforums;
		$topic['last_text'] = $ibforums->lang['last_post_by'];
		$topic['last_time'] = $ibforums->lang['last_updated'];
		$topic['last_poster'] = $topic['last_poster_id'] != 0 ? "<b><a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['last_poster_id']}'>{$topic['last_poster_name']}</a></b>" : "-".$topic['last_poster_name']."-";
		$topic['starter'] = $topic['starter_id'] != 0 ? "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['starter_id']}'>{$topic['starter_name']}</a>" : "-".$topic['starter_name']."-";
		if ( $topic['poll_state'] )
		{
			$topic['prefix'] = $ibforums->vars['pre_polls']." ";
		}
		if ( $ibforums->member['id'] && $topic['author_id'] )
		{
			$show_dots = 1;
		}
		$topic['folder_img'] = $std->folder_icon( $topic, $show_dots, $this->read_array[$topic['tid']] );
		$topic['topic_icon'] = $topic['icon_id'] ? "<img src=\"".$ibforums->vars['img_url']."/icon".$topic['icon_id'].".gif\" border=\"0\" alt=\"\">" : "&nbsp;";
		if ( $topic['attached'] == 1 )
		{
			$topic['topic_attach_icon'] = "<img src=\"".$ibforums->vars['img_url']."/clip1.gif\" border=\"0\" alt=\"此主题有一个附件\">&nbsp;";
		}
		else if ( 1 <= $topic['attached'] )
		{
			$topic['topic_attach_icon'] = "<img src=\"".$ibforums->vars['img_url']."/clip2.gif\" border=\"0\" alt=\"此主题有多个附件\">&nbsp;";
		}
		else
		{
			$topic['topic_attach_icon'] = "";
		}
		$topic['start_date'] = $std->get_date( $topic['start_date'], "LONG" );
		$pages = 1;
		if ( $topic['posts'] )
		{
			if ( ( $topic['posts'] + 1 ) % $ibforums->vars['display_max_posts'] == 0 )
			{
				$pages = ( $topic['posts'] + 1 ) / $ibforums->vars['display_max_posts'];
			}
			else
			{
				$number = ( $topic['posts'] + 1 ) / $ibforums->vars['display_max_posts'];
				$pages = ceil( $number );
			}
		}
		if ( 1 < $pages )
		{
			$topic['PAGES'] = "<span class='small'>({$ibforums->lang['topic_sp_pages']} ";
			$i = 0;
			for ( ;	$i < $pages;	++$i	)
			{
				$real_no = $i * $ibforums->vars['display_max_posts'];
				$page_no = $i + 1;
				if ( $page_no == 4 )
				{
					$topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st=".( $pages - 1 ) * $ibforums->vars['display_max_posts']."'>...{$pages} </a>";
					break;
				}
				else
				{
					$topic['PAGES'] .= "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&st={$real_no}'>{$page_no} </a>";
				}
			}
			$topic['PAGES'] .= ")</span>";
		}
		if ( $topic['posts'] < 0 )
		{
			$topic['posts'] = 0;
		}
		$last_time = $ibforums->input['last_visit'] < $this->read_array[$topic['tid']] ? $this->read_array[$topic['tid']] : $ibforums->input['last_visit'];
		if ( $last_time && $last_time < $topic['last_post'] )
		{
			$topic['go_last_page'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getlastpost'><{GO_LAST_ON}></a>";
			$topic['go_new_post'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getnewpost'><{NEW_POST}></a>";
		}
		else
		{
			$topic['go_last_page'] = "<a href='{$this->base_url}&act=ST&f={$this->forum['id']}&t={$topic['tid']}&view=getlastpost'><{GO_LAST_OFF}></a>";
			$topic['go_new_post'] = "";
		}
		$topic['last_post'] = $std->get_date( $topic['last_post'], "SHORT" );
		if ( $topic['state'] == "link" )
		{
			$t_array = explode( "&", $topic['moved_to'] );
			$topic['tid'] = $t_array[0];
			$topic['forum_id'] = $t_array[1];
			$topic['title'] = $topic['title'];
			$topic['views'] = "--";
			$topic['posts'] = "--";
			$topic['prefix'] = $ibforums->vars['pre_moved']." ";
			$topic['go_new_post'] = "";
		}
		else
		{
			$topic['posts'] = $this->html->who_link( $topic['tid'], $topic['posts'] );
		}
		$p_start = "";
		$p_end = "";
		if ( $topic['pinned'] == 1 )
		{
			$this->announce_print = 0;
			$topic['prefix'] = $ibforums->vars['pre_pinned'];
			$topic['topic_icon'] = "<{B_PIN}>";
			if ( $this->pinned_print == 0 )
			{
				$p_start = $this->html->render_pinned_start( );
				$this->pinned_print = 1;
			}
			return $p_start.$this->html->render_pinned_row( $topic );
		}
		else
		{
			if ( $this->announce_print == 1 )
			{
				$p_end = $this->html->render_pinned_end( );
				$this->announce_print = 0;
			}
			if ( $this->pinned_print == 1 )
			{
				$p_end = $this->html->render_pinned_end( );
				$this->pinned_print = 0;
			}
			return $p_end.$this->html->renderrow( $topic );
		}
	}

	function get_last_date( $topic )
	{
		global $ibforums;
		global $std;
		return $std->get_date( $topic['last_post'], "SHORT" );
	}

	function render_announce( $topic )
	{
		global $DB;
		global $std;
		global $ibforums;
		$topic['starter'] = $topic['a_mid'] != 0 ? "<a href='{$this->base_url}&act=Profile&CODE=03&MID={$topic['a_mid']}'>{$topic['name']}</a>" : "-".$topic['name']."-";
		$last_time = $ibforums->input['last_visit'] < $this->read_array["ann_".$topic['a_id']] ? $this->read_array["ann_".$topic['a_id']] : $ibforums->input['last_visit'];
		if ( $last_time && $last_time < $topic['a_start'] )
		{
			$topic['go_new_post'] = "<a href='{$this->base_url}&act=SA&a={$topic['a_id']}'><{NEW_POST}></a>";
		}
		else
		{
			$topic['go_new_post'] = "";
		}
		$topic['folder_img'] = $std->folder_icon( $topic, $show_dots, $this->read_array[$topic['tid']] );
		$topic['topic_icon'] = "<{B_ANN}>";
		$topic['start_date'] = $std->get_date( $topic['a_start'], "ANN" );
		$topic['end_date'] = $topic['a_expire'] ? "<br>{$ibforums->lang['announcement_end']}<B>".$std->get_date( $topic['a_end'], "ANN" )."</B>" : "";
		return $this->html->renderannouncement( $topic );
	}

}

$idx = new forums( );
?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -