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

📄 mod_cp.php

📁 极限网络智能办公系统—MYOA26—100%—源程序。
💻 PHP
📖 第 1 页 / 共 4 页
字号:
			$pass = 1;
		}
		else
		{
			$pass = 0;
		}
		if ( $pass == 0 )
		{
			$this->mod_error( "cp_no_perms" );
		}
		else
		{
			$dest_id = intval( $ibforums->input['df'] );
			$source_id = $this->forum['id'];
			if ( $source_id == "" )
			{
				$this->mod_error( "cp_error_move" );
			}
			else if ( $dest_id == "" || $dest_id == -1 )
			{
				$this->mod_error( "cp_error_move" );
			}
			else if ( $source_id == $dest_id )
			{
				$this->mod_error( "cp_error_move" );
			}
			else
			{
				$DB->query( "SELECT id, subwrap, sub_can_post, name FROM ibf_forums WHERE id IN(".$source_id.",".$dest_id.")" );
				if ( $DB->get_num_rows( ) != 2 )
				{
					$this->mod_error( "cp_error_move" );
				}
				else
				{
					$source_name = "";
					$dest_name = "";
					while ( $f = $DB->fetch_row( ) )
					{
						if ( $f['id'] == $source_id )
						{
							$source_name = $f['name'];
						}
						else
						{
							$dest_name = $f['name'];
						}
						if ( $f['subwrap'] == 1 && $f['sub_can_post'] != 1 )
						{
							$this->mod_error( "cp_error_move" );
							return;
						}
					}
					$source = $source_id;
					$moveto = $dest_id;
					$tid = implode( ",", $this->tids );
					$DB->query( "UPDATE ibf_topics SET forum_id='{$moveto}' WHERE forum_id='{$source}' AND tid IN({$tid})" );
					$DB->query( "UPDATE ibf_posts SET forum_id='{$moveto}' WHERE forum_id='{$source}' AND topic_id IN({$tid})" );
					$DB->query( "UPDATE ibf_polls SET forum_id='{$moveto}' WHERE forum_id='{$source}' AND tid IN({$tid})" );
					$this->moderate_log( "Moved topics from {$source_name} to {$dest_name}" );
					$this->recount( $source );
					$this->recount( $moveto );
					$print->redirect_screen( $ibforums->lang['cp_redirect_topics'], "act=modcp&CODE=showtopics&f=".$source_id );
				}
			}
		}
	}

	function start_checked_move( )
	{
		global $std;
		global $ibforums;
		global $DB;
		global $print;
		$pass = 0;
		if ( $ibforums->member['g_is_supmod'] == 1 )
		{
			$pass = 1;
		}
		else if ( $this->moderator['move_topic'] == 1 )
		{
			$pass = 1;
		}
		else
		{
			$pass = 0;
		}
		if ( $pass == 0 )
		{
			$this->mod_error( "cp_no_perms" );
		}
		else
		{
			$jump_html = $std->build_forum_jump( "no_html" );
			$this->output .= $this->html->move_checked_form_start( $this->forum['name'], $this->forum['id'] );
			$DB->query( "SELECT title, tid FROM ibf_topics WHERE forum_id=".$this->forum['id']." AND tid IN(".implode( ",", $this->tids ).")" );
			while ( $row = $DB->fetch_row( ) )
			{
				$this->output .= $this->html->move_checked_form_entry( $row['tid'], $row['title'] );
			}
			$this->output .= $this->html->move_checked_form_end( $jump_html );
		}
	}

	function delete_topics( )
	{
		global $std;
		global $ibforums;
		global $DB;
		global $print;
		$pass = 0;
		if ( $ibforums->member['g_is_supmod'] == 1 )
		{
			$pass = 1;
		}
		else if ( $this->moderator['delete_topic'] == 1 )
		{
			$pass = 1;
		}
		else
		{
			$pass = 0;
		}
		if ( $pass == 0 )
		{
			$this->mod_error( "cp_no_perms" );
		}
		else
		{
			$tid_string = implode( ",", $this->tids );
			$DB->query( "DELETE FROM ibf_topics WHERE forum_id=".$this->forum['id']." AND tid IN({$tid_string})" );
			$DB->query( "DELETE FROM ibf_polls WHERE tid IN({$tid_string})" );
			$DB->query( "DELETE FROM ibf_voters WHERE tid IN({$tid_string})" );
			$DB->query( "SELECT attach_id, attach_hits, attach_file FROM ibf_posts WHERE attach_id <> '' AND topic_id IN({$tid_string})" );
			while ( $DB->get_num_rows( ) && ( $r = $DB->fetch_row( ) ) )
			{
				if ( is_file( $this->upload_dir."/".$r['attach_id'] ) )
				{
					@unlink( $this->upload_dir."/".$r['attach_id'] );
				}
			}
			$DB->query( "DELETE FROM ibf_posts WHERE topic_id IN({$tid_string})" );
			$this->recount( );
			$print->redirect_screen( $ibforums->lang['cp_redirect_topics'], "act=modcp&CODE=showtopics&f=".$this->forum['id'] );
		}
	}

	function alter_topics( $mod_action = "", $sql = "" )
	{
		global $std;
		global $ibforums;
		global $DB;
		global $print;
		if ( $mod_action == "" || $sql == "" )
		{
			$this->mod_error( "cp_no_perms" );
		}
		else
		{
			$pass = 0;
			if ( $ibforums->member['g_is_supmod'] == 1 )
			{
				$pass = 1;
			}
			else if ( $this->moderator[$mod_action] == 1 )
			{
				$pass = 1;
			}
			else
			{
				$pass = 0;
			}
			if ( $pass == 0 )
			{
				$this->mod_error( "cp_no_perms" );
			}
			else
			{
				$DB->query( "UPDATE ibf_topics SET {$sql} WHERE forum_id=".$this->forum['id']." AND tid IN(".implode( ",", $this->tids ).")" );
				$print->redirect_screen( $ibforums->lang['cp_redirect_topics'], "act=modcp&CODE=showtopics&f=".$this->forum['id'] );
			}
		}
	}

	function show_topics( )
	{
		global $std;
		global $ibforums;
		global $DB;
		global $print;
		$ibforums->lang = $std->load_words( $ibforums->lang, "lang_forum", $ibforums->lang_id );
		$this->load_forum( );
		$pass = 0;
		if ( $this->forum['read_perms'] == "*" )
		{
			$pass = 1;
		}
		else if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $this->forum['read_perms'] ) )
		{
			$pass = 1;
		}
		if ( $pass == 0 )
		{
			$this->mod_error( "cp_err_no_p" );
		}
		else
		{
			$DB->query( "SELECT COUNT(tid) as max FROM ibf_topics WHERE forum_id='".$this->forum['id']."' and approved='1'" );
			$total_possible = $DB->fetch_row( );
			$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=modcp&CODE=showtopics&f=".$this->forum['id']
			) );
			$this->output .= $this->html->start_topics( $pages, $this->forum );
			if ( $total_possible['max'] < 1 )
			{
				$this->output .= $this->html->show_no_topics( );
			}
			$first = intval( $ibforums->input['st'] );
			if ( $first < 1 )
			{
				$first = 0;
			}
			$query = "SELECT * from ibf_topics WHERE forum_id='".$this->forum['id']."' and approved=1 ORDER BY pinned DESC, last_post DESC LIMIT {$first},".$ibforums->vars['display_max_topics'];
			$DB->query( $query );
			while ( $topic = $DB->fetch_row( ) )
			{
				$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']." ";
				}
				$topic['folder_img'] = $std->folder_icon( $topic );
				$topic['topic_icon'] = $topic['icon_id'] ? "<img src=\"".$ibforums->vars['img_url']."/icon".$topic['icon_id'].".gif\" border=\"0\" alt=\"\">" : "&nbsp;";
				$topic['start_date'] = $std->get_date( $topic['start_date'], "LONG" );
				if ( $topic['posts'] < 0 )
				{
					$topic['posts'] = 0;
				}
				$topic['last_post'] = $std->get_date( $topic['last_post'], "SHORT" );
				$topic['real_tid'] = $topic['tid'];
				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'] = "";
				}
				if ( $topic['pinned'] == 1 )
				{
					$topic['prefix'] = $ibforums->vars['pre_pinned'];
					$topic['topic_icon'] = "<{B_PIN}>";
				}
				$this->output .= $this->html->topic_row( $topic );
			}
			$this->output .= $this->html->topics_end( $this->forum );
		}
	}

	function show_forums( )
	{
		global $std;
		global $ibforums;
		global $DB;
		global $print;
		$ibforums->lang = $std->load_words( $ibforums->lang, "lang_boards", $ibforums->lang_id );
		$forum_ids = array( );
		if ( !$ibforums->member['g_is_supmod'] )
		{
			$DB->query( "SELECT forum_id FROM ibf_moderators WHERE member_id={$ibforums->member['id']} OR group_id={$ibforums->member['mgroup']}" );
			while ( $r = $DB->fetch_row( ) )
			{
				$forum_ids[] = $r['forum_id'];
			}
		}
		else
		{
			$DB->query( "SELECT id, read_perms FROM ibf_forums" );
			while ( $r = $DB->fetch_row( ) )
			{
				if ( $r['read_perms'] == "*" || preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $r['read_perms'] ) )
				{
					$forum_ids[] = $r['id'];
				}
			}
		}
		if ( count( $forum_ids ) < 1 )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "me_no_forum" ) );
		}
		$fids = implode( ",", $forum_ids );
		$queued_posts = array( );
		$DB->query( "SELECT COUNT(pid) as qued, forum_id FROM ibf_posts\n\t\t\t\t\tWHERE queued=1 AND new_topic <> 1 AND forum_id IN ({$fids})\n\t\t\t\t\tGROUP BY forum_id ORDER BY forum_id" );
		while ( $q = $DB->fetch_row( ) )
		{
			$this->queued_posts[$q['forum_id']] = $q['qued'];
		}
		$queued_topics = array( );
		$DB->query( "SELECT COUNT(tid) as qued, forum_id FROM ibf_topics\n\t\t\t\t\tWHERE approved <> 1 AND forum_id IN ({$fids})\n\t\t\t\t\tGROUP BY forum_id ORDER BY forum_id" );
		while ( $q = $DB->fetch_row( ) )
		{
			$this->queued_topics[$q['forum_id']] = $q['qued'];
		}
		$DB->query( "SELECT f.*, c.id as cat_id, c.name as cat_name\n\t\t            FROM ibf_forums f\n \t\t             LEFT JOIN ibf_categories c ON (c.id=f.category)\n \t\t            WHERE f.id IN ({$fids})\n \t\t            ORDER BY c.position, f.position" );
		$last_c_id = -1;
		while ( $r = $DB->fetch_row( ) )
		{
			if ( $last_c_id != $r['cat_id'] )
			{
				$this->cats[$r['cat_id']] = array(
					"id" => $r['cat_id'],
					"position" => $r['cat_position'],
					"state" => $r['cat_state'],
					"name" => $r['cat_name']
				);
				$last_c_id = $r['cat_id'];
			}
			if ( 0 < $r['parent_id'] )
			{
				$this->children[$r['parent_id']][$r['id']] = $r;
			}
			else
			{
				$this->forums[$r['id']] = $r;
			}
		}
		$cid = array( );
		if ( 0 < count( $this->children ) )
		{
			foreach ( $this->children as $id => $d )
			{
				$cid[] = $id;
			}
		}
		if ( 0 < count( $cid ) )
		{
			$DB->query( "SELECT f.*, c.id as cat_id, c.name as cat_name\n\t\t\t\t\t\tFROM ibf_forums f\n\t\t\t\t\t\t LEFT JOIN ibf_categories c ON (c.id=f.category)\n\t\t\t\t\t\tWHERE f. id IN (".implode( ",", $cid ).") AND f.id NOT IN ({$fids})\n\t\t\t\t\t\tORDER BY c.position, f.position" );
			while ( $c_q = $DB->fetch_row( ) )
			{
				$this->forums[$c_q['id']] = $c_q;
				$this->forums[$c_q['id']]['no_mod'] = 1;
				$this->cats[$c_q['cat_id']] = array(
					"id" => $r['cat_id'],
					"position" => $r['cat_position'],
					"state" => $r['cat_state'],
					"name" => $r['cat_name']
				);
			}
		}
		$this->output .= $this->html->forum_page_start( );
		foreach ( $this->cats as $cat_id => $cat_data )
		{
			$this->output .= $this->html->cat_row( $cat_data['name'] );
			foreach ( $this->forums as $forum_id => $forum )
			{
				if ( $forum['category'] == $cat_id )
				{
					$this->output .= $this->html->forum_row( $this->do_forum( $forum ) );
					if ( 0 < count( $this->children[$forum['id']] ) )
					{
						foreach ( $this->children[$forum['id']] as $idx => $subforum )
						{
							$this->output .= $this->html->subforum_row( $this->do_forum( $subforum ) );
						}
					}
				}
			}
		}
		$this->output .= $this->html->forum_page_end( );
		$this->nav[] = "<a href='{$this->base_url}&act=modcp'>{$ibforums->lang['cp_modcp_home']}</a>";
		$this->nav[] = $ibforums->lang['menu_forums'];
	}

	function do_forum( $forum )
	{
		global $DB;
		global $std;
		global $ibforums;
		global $print;
		$forum['q_posts'] = 0;
		if ( $this->queued_posts[$forum['id']] )
		{
			$forum['q_posts'] = "<span class='highlight'>".$this->queued_posts[$forum['id']]."</span>";
		}
		$forum['q_topics'] = 0;
		if ( $this->queued_topics[$forum['id']] )
		{
			$forum['q_topics'] = "<span class='highlight'>".$this->queued_topics[$forum['id']]."</span>";
		}
		$forum['n_posts'] = $forum['posts'] + $forum['topics'];
		$forum['last_post'] = $std->get_date( $forum['last_post'], "LONG" );
		$forum['last_topic'] = $ibforums->lang['f_none'];
		$forum['last_title'] = str_replace( "&#33;", "!", $forum['last_title'] );
		$forum['last_title'] = str_replace( "&quot;", "\"", $forum['last_title'] );
		if ( 30 < strlen( $forum['last_title'] ) )
		{
			$forum['last_title'] = substr( $forum['last_title'], 0, 27 )."...";
			$forum['last_title'] = preg_replace( "/&(#(\\d+;?)?)?\\.\\.\\.\$/", "...", $forum['last_title'] );
		}
		if ( $forum['password'] != "" )
		{
			$forum['last_topic'] = $ibforums->lang['f_none'];
		}
		else
		{
			$forum['last_topic'] = "<a href='{$ibforums->base_url}&act=ST&f={$forum['id']}&t={$forum['last_id']}&view=getlastpost'>{$forum['last_title']}</a>";
		}
		if ( isset( $forum['last_poster_name'] ) )
		{
			$forum['last_poster'] = $forum['last_poster_id'] ? "<a href='{$ibforums->base_url}&act=Profile&CODE=03&MID={$forum['last_poster_id']}'>{$forum['last_poster_name']}</a>" : $forum['last_poster_name'];
		}
		else
		{
			$forum['last_poster'] = $ibforums->lang['f_none'];
		}
		$forum['folder_icon'] = $std->forum_new_posts( $forum );
		if ( $forum['no_mod'] == 1 )
		{
			$forum['select_button'] = "&nbsp;";
		}
		else
		{
			$forum['select_button'] = "<input type='radio' name='f' value='{$forum['id']}'>";
		}
		return $forum;
	}

	function approve_all( )
	{
		global $std;
		global $ibforums;
		global $DB;
		global $print;
		$this->load_forum( );
		$DB->query( "UPDATE ibf_posts SET queued=0 WHERE topic_id='".$ibforums->input['tid']."'" );
		$DB->query( "SELECT COUNT(pid) as posts FROM ibf_posts WHERE new_topic <> 1 and topic_id='".$ibforums->input['tid']."'" );
		$count = $DB->fetch_row( );
		$DB->query( "UPDATE ibf_topics SET posts=".$count['posts']." WHERE tid='".$ibforums->input['tid']."'" );
		$DB->query( "SELECT author_id FROM ibf_posts WHERE topic_id='".$ibforums->input['tid']."'" );
		$mems = array( );
		while ( $r = $DB->fetch_row( ) )
		{
			if ( 0 < $r['author_id'] )
			{

⌨️ 快捷键说明

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