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

📄 forums.php

📁 泛微协同办公系统标准版E-office V5.5的源代码内含泛微办公系统V5.5自动注册文件。
💻 PHP
📖 第 1 页 / 共 2 页
字号:
<?php

class forums
{

	var $output = "";
	var $base_url = "";
	var $html = "";
	var $moderator = array( );
	var $forum = array( );
	var $mods = array( );
	var $show_dots = "";
	var $nav_extra = "";
	var $read_array = array( );
	var $board_html = "";
	var $sub_output = "";
	var $pinned_print = 0;
	var $announce_print = 0;

	function forums( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $print;
		global $skin_universal;
		$ibforums->input['f'] = intval( $ibforums->input['f'] );
		$ibforums->lang = $std->load_words( $ibforums->lang, "lang_forum", $ibforums->lang_id );
		$this->html = $std->load_template( "skin_forum" );
		$DB->query( "SELECT f.*, c.id as cat_id, c.name as cat_name\n        \t\t\tFROM ibf_forums f\n        \t\t\t  LEFT JOIN ibf_categories c ON (c.id=f.category)\n        \t\t\tWHERE f.id=".$ibforums->input['f'] );
		$this->forum = $DB->fetch_row( );
		if ( !$this->forum['id'] )
		{
			$std->error( array( 1, "missing_files" ) );
		}
		if ( 0 < $this->forum['parent_id'] )
		{
			$DB->query( "SELECT f.id as forum_id, f.name as forum_name, c.id, c.name FROM ibf_forums f, ibf_categories c WHERE f.id='".$this->forum['parent_id']."' AND c.id=f.category" );
			$row = $DB->fetch_row( );
			$this->forum['cat_id'] = $row['id'];
			$this->forum['cat_name'] = $row['name'];
			$this->nav_extra = "<a href='".$ibforums->base_url."&act=SF&f={$row['forum_id']}'>{$row['forum_name']}</a>";
		}
		$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
		$this->forum['FORUM_JUMP'] = $std->build_forum_jump( );
		$this->forum['FORUM_JUMP'] = preg_replace( "!#Forum Jump#!", $ibforums->lang['forum_jump'], $this->forum['FORUM_JUMP'] );
		if ( $ibforums->input['act'] == "SR" )
		{
			$this->show_rules( );
		}
		else if ( $this->forum['subwrap'] == 1 )
		{
			$this->show_subforums( );
			if ( $this->forum['sub_can_post'] )
			{
				$this->show_forum( );
			}
			else
			{
				$this->output = $this->sub_output;
				$this->sub_output = "";
			}
		}
		else
		{
			$this->show_forum( );
		}
		if ( $this->sub_output != "" )
		{
			$this->output = str_replace( "<!--IBF.SUBFORUMS-->", $this->sub_output, $this->output );
		}
		if ( 0 < $ibforums->member['id'] )
		{
			$this->output = str_replace( "<!--IBF.SUB_FORUM_LINK-->", $this->html->show_sub_link( $this->forum['id'] ), $this->output );
		}
		$print->add_output( $this->output );
		$print->do_output( array(
			"TITLE" => $ibforums->vars['board_name']." -> ".$this->forum['name'],
			"JS" => 0,
			"NAV" => array(
				"<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
				$this->nav_extra,
				"<a href='".$this->base_url."&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>"
			)
		) );
	}

	function show_subforums( )
	{
		global $std;
		global $DB;
		global $ibforums;
		$ibforums->lang = $std->load_words( $ibforums->lang, "lang_boards", $ibforums->lang_id );
		$this->board_html = $std->load_template( "skin_boards" );
		$fid = $ibforums->input['f'];
		$DB->query( "SELECT f.*, m.member_name as mod_name, m.member_id as mod_id, m.is_group, m.group_id, m.group_name, m.mid\n        \t\t\tFROM ibf_forums f\n        \t\t\t LEFT JOIN ibf_moderators m ON (f.id=m.forum_id)\n        \t\t\tWHERE parent_id='{$fid}'\n        \t\t\tORDER BY position" );
		if ( !$DB->get_num_rows( ) )
		{
			return "";
		}
		while ( $r = $DB->fetch_row( ) )
		{
			$this->forums[$r['id']] = $r;
			if ( $r['mod_id'] != "" )
			{
				$this->mods[$r['id']][$r['mid']] = array(
					"name" => $r['mod_name'],
					"id" => $r['mod_id'],
					"isg" => $r['is_group'],
					"gname" => $r['group_name'],
					"gid" => $r['group_id']
				);
			}
		}
		foreach ( $this->forums as $data )
		{
			$temp_html .= $this->process_forum( $data['id'], $data );
		}
		if ( $temp_html != "" )
		{
			$this->sub_output .= $this->board_html->subheader( );
			$this->sub_output .= $temp_html;
			$this->sub_output .= $this->board_html->end_this_cat( );
		}
		else
		{
			return $this->sub_output;
		}
		unset( $temp_html );
		$this->sub_output .= $this->board_html->end_all_cats( );
	}

	function process_forum( $forum_id = "", $forum_data = "" )
	{
		global $std;
		global $ibforums;
		if ( $forum_data['read_perms'] != "*" && !preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $forum_data['read_perms'] ) )
		{
			return "";
		}
		$forum_data['img_new_post'] = $std->forum_new_posts( $forum_data );
		$forum_data['last_post'] = $std->get_date( $forum_data['last_post'], "LONG" );
		$forum_data['last_topic'] = $ibforums->lang['f_none'];
		if ( isset( $forum_data['last_title'] ) && $forum_data['last_id'] != "" )
		{
			$forum_data['last_title'] = str_replace( "&#33;", "!", $forum_data['last_title'] );
			$forum_data['last_title'] = str_replace( "&quot;", "\"", $forum_data['last_title'] );
			if ( 30 < strlen( $forum_data['last_title'] ) )
			{
				$forum_data['last_title'] = substr( $forum_data['last_title'], 0, 27 )."...";
				$forum_data['last_title'] = preg_replace( "/&(#(\\d+;?)?)?\\.\\.\\.\$/", "...", $forum_data['last_title'] );
			}
			if ( $forum_data['password'] != "" )
			{
				$forum_data['last_topic'] = $ibforums->lang['f_protected'];
			}
			else
			{
				$forum_data['last_topic'] = "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=ST&f={$forum_data['id']}&t={$forum_data['last_id']}&view=getlastpost'>{$forum_data['last_title']}</a>";
			}
		}
		if ( isset( $forum_data['last_poster_name'] ) )
		{
			$forum_data['last_poster'] = $forum_data['last_poster_id'] ? "<a href='{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}&act=Profile&CODE=03&MID={$forum_data['last_poster_id']}'>{$forum_data['last_poster_name']}</a>" : $forum_data['last_poster_name'];
		}
		else
		{
			$forum_data['last_poster'] = $ibforums->lang['f_none'];
		}
		$forum_data['moderator'] = "";
		if ( isset( $this->mods[$forum_data['id']] ) )
		{
			$forum_data['moderator'] = $ibforums->lang['forum_leader']." ";
			if ( is_array( $this->mods[$forum_data['id']] ) )
			{
				foreach ( $this->mods[$forum_data['id']] as $moderator )
				{
					if ( $moderator['isg'] == 1 )
					{
						$forum_data['moderator'] .= "<a href='{$ibforums->base_url}&act=Members&max_results=30&filter={$moderator['gid']}&sort_order=asc&sort_key=name&st=0'>{$moderator['gname']}</a>, ";
					}
					else
					{
						$forum_data['moderator'] .= "<a href='{$ibforums->base_url}&act=Profile&CODE=03&MID={$moderator['id']}'>{$moderator['name']}</a>, ";
					}
				}
				$forum_data['moderator'] = preg_replace( "!,\\s+\$!", "", $forum_data['moderator'] );
			}
			else if ( $moderator['isg'] == 1 )
			{
				$forum_data['moderator'] .= "<a href='{$ibforums->base_url}&act=Members&max_results=30&filter={$this->mods[$forum_data['id']]['gid']}&sort_order=asc&sort_key=name&st=0'>{$this->mods[$forum_data['id']]['gname']}</a>, ";
			}
			else
			{
				$forum_data['moderator'] .= "<a href='{$ibforums->base_url}&act=Profile&CODE=03&MID={$this->mods[$forum_data['id']]['id']}'>{$this->mods[$forum_data['id']]['name']}</a>";
			}
		}
		return $this->board_html->forumrow( $forum_data );
	}

	function show_rules( )
	{
		global $DB;
		global $ibforums;
		global $std;
		global $print;
		$bad_entry = $this->check_access( );
		if ( $bad_entry == 1 )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_view_topic" ) );
		}
		$DB->query( "SELECT * FROM ibf_rules WHERE fid='".$ibforums->input['f']."'" );
		if ( $rules = $DB->fetch_row( ) )
		{
			$rules['title'] = stripslashes( $rules['title'] );
			$rules['body'] = stripslashes( $rules['body'] );
			$this->output .= $this->html->show_rules( $rules );
			$print->add_output( "{$this->output}" );
			$print->do_output( array(
				"TITLE" => $ibforums->vars['board_name']." -> ".$this->forum['name'],
				"JS" => 0,
				"NAV" => array(
					"<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>"
				)
			) );
		}
		else
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_view_topic" ) );
		}
	}

	function show_forum( )
	{
		global $ibforums;
		$ibforums->input['L'] == 1 ? $this->authenticate_user( ) : $this->render_forum( );
	}

	function authenticate_user( )
	{
		global $std;
		global $ibforums;
		global $print;
		if ( $ibforums->input['f_password'] == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "pass_blank" ) );
		}
		if ( $ibforums->input['f_password'] != $this->forum['password'] )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "wrong_pass" ) );
		}
		$std->my_setcookie( "iBForum".$this->forum['id'], $ibforums->input['f_password'] );
		$print->redirect_screen( $ibforums->lang['logged_in'], "act=SF&f=".$this->forum['id'] );
	}

	function check_access( )
	{
		global $ibforums;
		global $HTTP_COOKIE_VARS;
		$return = 1;
		if ( $this->forum['read_perms'] == "*" )
		{
			$return = 0;
		}
		else if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $this->forum['read_perms'] ) )
		{
			$return = 0;
		}
		if ( $return == 0 && $this->forum['password'] )
		{
			if ( $HTTP_COOKIE_VARS[$ibforums->vars['cookie_id']."iBForum".$this->forum['id']] == $this->forum['password'] )
			{
				$return = 0;
			}
			else
			{
				$this->forum_login( );
			}
		}
		return $return;
	}

	function forum_login( )
	{
		global $ibforums;
		global $std;
		global $DB;
		global $HTTP_COOKIE_VARS;
		global $print;
		if ( empty( $ibforums->member['id'] ) )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_guests" ) );
		}
		$this->output = $this->html->forum_log_in( $this->forum['id'] );
		$print->add_output( "{$this->output}" );
		$print->do_output( array(
			"TITLE" => $ibforums->vars['board_name']." -> ".$this->forum['name'],
			"JS" => 0,
			"NAV" => array(
				"<a href='".$this->base_url."&act=SC&c={$this->forum['cat_id']}'>{$this->forum['cat_name']}</a>",
				"<a href='".$this->base_url."&act=SF&f={$this->forum['id']}'>{$this->forum['name']}</a>"
			)
		) );
	}

	function render_forum( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $print;
		global $HTTP_COOKIE_VARS;
		$bad_entry = $this->check_access( );
		if ( $bad_entry == 1 )
		{
			if ( $this->forum['subwrap'] == 1 )
			{
				$this->output = $this->sub_output;
				$this->sub_output = "";
				return TRUE;
			}
			else
			{
				$std->error( array( 1, "no_permission" ) );
			}
		}
		if ( $read = $std->my_getcookie( "topicsread" ) )

⌨️ 快捷键说明

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