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

📄 search.php

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

class search
{

	var $output = "";
	var $page_title = "";
	var $nav = array( );
	var $html = "";
	var $first = 0;
	var $search_type = "posts";
	var $sort_order = "desc";
	var $sort_key = "last_post";
	var $search_in = "posts";
	var $prune = "30";
	var $st_time = array( );
	var $end_time = array( );
	var $st_stamp = "";
	var $end_stamp = "";
	var $result_type = "topics";
	var $parser = "";

	function search( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $print;
		if ( !$ibforums->vars['allow_search'] )
		{
			$std->error( array( 1, "search_off" ) );
		}
		if ( $ibforums->member['g_use_search'] != 1 )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_permission" ) );
		}
		if ( $ibforums->input['CODE'] == "" )
		{
			$ibforums->input['CODE'] = "00";
		}
		$ibforums->lang = $std->load_words( $ibforums->lang, "lang_search", $ibforums->lang_id );
		$ibforums->lang = $std->load_words( $ibforums->lang, "lang_forum", $ibforums->lang_id );
		$this->html = $std->load_template( "skin_search" );
		$this->base_url = "{$ibforums->vars['board_url']}/index.{$ibforums->vars['php_ext']}?s={$ibforums->session_id}";
		if ( isset( $ibforums->input['st'] ) )
		{
			$this->first = $ibforums->input['st'];
		}
		if ( !isset( $ibforums->member['g_use_search'] ) )
		{
			$std->error( array( 1, "cant_use_feature" ) );
		}
		switch ( $ibforums->input['CODE'] )
		{
		case "01" :
			$this->do_search( );
			break;
		case "getnew" :
			$this->get_new_posts( );
			break;
		case "getactive" :
			$this->get_active( );
			break;
		case "show" :
			$this->show_results( );
			break;
		case "getreplied" :
			$this->get_replies( );
			break;
		case "lastten" :
			$this->get_last_ten( );
			break;
		case "getalluser" :
			$this->get_all_user( );
			break;
		default :
			$this->show_form( );
			break;
		}
		$print->add_output( "{$this->output}" );
		$print->do_output( array(
			"TITLE" => $this->page_title,
			"JS" => 0,
			NAV => $this->nav
		) );
	}

	function get_all_user( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $HTTP_POST_VARS;
		global $print;
		if ( 0 < $ibforums->member['g_search_flood'] )
		{
			$flood_time = time( ) - $ibforums->member['g_search_flood'];
			$DB->query( "SELECT id FROM ibf_search_results WHERE (member_id='".$ibforums->member['id']."' OR ip_address='".$ibforums->input['IP_ADDRESS']."') AND search_date > '{$flood_time}'" );
			if ( $DB->get_num_rows( ) )
			{
				$std->error( array(
					"LEVEL" => 1,
					"MSG" => "search_flood",
					"EXTRA" => $ibforums->member['g_search_flood']
				) );
			}
		}
		$ibforums->input['forums'] = "all";
		$forums = $this->get_searchable_forums( );
		$mid = intval( $ibforums->input['mid'] );
		if ( $forums == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_forum" ) );
		}
		if ( $mid == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_results" ) );
		}
		$DB->query( "SELECT pid FROM ibf_posts WHERE queued <> 1 AND forum_id IN({$forums}) AND author_id={$mid}" );
		$max_hits = $DB->get_num_rows( );
		$posts = "";
		while ( $row = $DB->fetch_row( ) )
		{
			$posts .= $row['pid'].",";
		}
		$DB->free_result( );
		$posts = preg_replace( "/,\$/", "", $posts );
		if ( $posts == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_results" ) );
		}
		$unique_id = md5( uniqid( microtime( ), 1 ) );
		$str = $DB->compile_db_insert_string( array(
			"id" => $unique_id,
			"search_date" => time( ),
			"post_id" => $posts,
			"post_max" => $max_hits,
			"sort_key" => $this->sort_key,
			"sort_order" => $this->sort_order,
			"member_id" => $ibforums->member['id'],
			"ip_address" => $ibforums->input['IP_ADDRESS']
		) );
		$DB->query( "INSERT INTO ibf_search_results ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})" );
		$print->redirect_screen( $ibforums->lang['search_redirect'], "act=Search&nav=lv&CODE=show&searchid={$unique_id}&search_in=posts&result_type=posts" );
		exit( );
	}

	function get_new_posts( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $HTTP_POST_VARS;
		global $print;
		if ( 0 < $ibforums->member['g_search_flood'] )
		{
			$flood_time = time( ) - $ibforums->member['g_search_flood'];
			$DB->query( "SELECT id FROM ibf_search_results WHERE (member_id='".$ibforums->member['id']."' OR ip_address='".$ibforums->input['IP_ADDRESS']."') AND search_date > '{$flood_time}'" );
			if ( $DB->get_num_rows( ) )
			{
				$std->error( array(
					"LEVEL" => 1,
					"MSG" => "search_flood",
					"EXTRA" => $ibforums->member['g_search_flood']
				) );
			}
		}
		$ibforums->input['forums'] = "all";
		$ibforums->input['nav'] = "lv";
		$forums = $this->get_searchable_forums( );
		if ( $forums == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_forum" ) );
		}
		$DB->query( "SELECT topic_id FROM ibf_posts WHERE queued <> 1 AND forum_id IN({$forums}) AND post_date > '".$ibforums->member['last_visit']."'" );
		$max_hits = $DB->get_num_rows( );
		$posts = "";
		while ( $row = $DB->fetch_row( ) )
		{
			$posts .= $row['topic_id'].",";
		}
		$DB->free_result( );
		$posts = preg_replace( "/,\$/", "", $posts );
		if ( $posts == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_results" ) );
		}
		$unique_id = md5( uniqid( microtime( ), 1 ) );
		$str = $DB->compile_db_insert_string( array(
			"id" => $unique_id,
			"search_date" => time( ),
			"topic_id" => $posts,
			"topic_max" => $max_hits,
			"sort_key" => $this->sort_key,
			"sort_order" => $this->sort_order,
			"member_id" => $ibforums->member['id'],
			"ip_address" => $ibforums->input['IP_ADDRESS']
		) );
		$DB->query( "INSERT INTO ibf_search_results ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})" );
		$print->redirect_screen( $ibforums->lang['search_redirect'], "act=Search&nav=lv&CODE=show&searchid={$unique_id}&search_in=topics&result_type=topics" );
		exit( );
	}

	function get_last_ten( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $HTTP_POST_VARS;
		global $print;
		$ibforums->input['forums'] = "all";
		$forums = $this->get_searchable_forums( );
		if ( $forums == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_forum" ) );
		}
		if ( $read = $std->my_getcookie( "topicsread" ) )
		{
			$this->read_array = unserialize( stripslashes( $read ) );
		}
		$DB->query( "SELECT p.*, t.*, f.id as forum_id, f.name as forum_name FROM ibf_forums f, ibf_posts p, ibf_topics t WHERE p.queued <> 1 AND p.forum_id IN({$forums}) AND p.author_id='".$ibforums->member['id']."' AND t.tid=p.topic_id AND f.id=p.forum_id ORDER BY p.post_date DESC LIMIT 0,10" );
		if ( $DB->get_num_rows( ) )
		{
			require( "./sources/lib/post_parser.php" );
			$this->parser = new post_parser( );
			$this->output .= $this->html->start_as_post( array(
				"SHOW_PAGES" => $links
			) );
			while ( $row = $DB->fetch_row( ) )
			{
				$row['keywords'] = $url_words;
				$row['post_date'] = $std->get_date( $row['post_date'], "LONG" );
				$this->output .= $this->html->renderpostrow( $this->parse_entry( $row, 1 ) );
			}
			$this->output .= $this->html->end_as_post( array(
				"SHOW_PAGES" => $links
			) );
		}
		else
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_results" ) );
		}
		$DB->free_result( );
		$this->page_title = $ibforums->lang['nav_lt'];
		$this->nav = array(
			$ibforums->lang['nav_lt']
		);
	}

	function get_replies( )
	{
		global $ibforums;
		global $DB;
		global $std;
		global $HTTP_POST_VARS;
		global $print;
		if ( 0 < $ibforums->member['g_search_flood'] )
		{
			$flood_time = time( ) - $ibforums->member['g_search_flood'];
			$DB->query( "SELECT id FROM ibf_search_results WHERE (member_id='".$ibforums->member['id']."' OR ip_address='".$ibforums->input['IP_ADDRESS']."') AND search_date > '{$flood_time}'" );
			if ( $DB->get_num_rows( ) )
			{
				$std->error( array(
					"LEVEL" => 1,
					"MSG" => "search_flood",
					"EXTRA" => $ibforums->member['g_search_flood']
				) );
			}
		}
		$ibforums->input['forums'] = "all";
		$ibforums->input['nav'] = "lv";
		$forums = $this->get_searchable_forums( );
		if ( $forums == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_forum" ) );
		}
		$DB->query( "SELECT tid FROM ibf_topics WHERE starter_id='".$ibforums->member['id']."' AND last_post > ".$ibforums->member['last_visit']." AND forum_id IN({$forums}) AND approved=1" );
		$max_hits = $DB->get_num_rows( );
		$topics = "";
		while ( $row = $DB->fetch_row( ) )
		{
			$topics .= $row['tid'].",";
		}
		$DB->free_result( );
		$topics = preg_replace( "/,\$/", "", $topics );
		if ( $topics == "" )
		{
			$std->error( array( "LEVEL" => 1, "MSG" => "no_search_results" ) );
		}
		$unique_id = md5( uniqid( microtime( ), 1 ) );
		$str = $DB->compile_db_insert_string( array(
			"id" => $unique_id,
			"search_date" => time( ),
			"topic_id" => $topics,
			"topic_max" => $max_hits,
			"sort_key" => $this->sort_key,
			"sort_order" => $this->sort_order,
			"member_id" => $ibforums->member['id'],
			"ip_address" => $ibforums->input['IP_ADDRESS']
		) );
		$DB->query( "INSERT INTO ibf_search_results ({$str['FIELD_NAMES']}) VALUES ({$str['FIELD_VALUES']})" );
		$print->redirect_screen( $ibforums->lang['search_redirect'], "act=Search&nav=gr&CODE=show&searchid={$unique_id}&search_in=posts&result_type=topics" );
		exit( );
	}

	function show_form( )
	{
		global $DB;
		global $std;
		global $ibforums;
		$last_cat_id = -1;
		$the_hiddens = "";
		$db_cats = array( );
		$db_children = array( );
		$db_forums = array( );
		$DB->query( "SELECT f.id as forum_id, f.name as forum_name, f.position, f.read_perms, f.parent_id, f.subwrap, c.id as cat_id, c.name as cat_name from ibf_forums f, ibf_categories c where c.id=f.category ORDER BY c.position, f.position" );
		$forums = "<select name='forums' class='forminput' onChange='chooseForum()'>\n<option value='all'>&gt;&gt;所有论坛栏目";
		$cats = "<select name='cats' class='forminput' onChange='chooseCat()'>\n<option value='all'>&gt;&gt;所有论坛分类";
		while ( $r = $DB->fetch_row( ) )
		{
			if ( $last_cat_id != $r['cat_id'] )
			{
				$db_cats[$r['cat_id']] = array(
					"id" => $r['cat_id'],
					"name" => $r['cat_name']
				);
				$last_cat_id = $r['cat_id'];
			}
			if ( 0 < $r['parent_id'] )
			{
				$db_children[$r['parent_id']][$r['forum_id']] = $r;
			}
			else
			{
				$db_forums[$r['forum_id']] = $r;
			}
		}
		foreach ( $db_cats as $thunder => $cat )
		{
			$cats .= "<option value='{$cat['id']}'>{$cat['name']}</option>\n";
		}
		$last_cat_id = -1;
		foreach ( $db_forums as $an_eye_for_an => $i )
		{
			$selected = "";
			$is_sub = "";
			if ( $last_cat_id != $i['cat_id'] )
			{
				$forums .= "<option value=\"\">--------------------------</option>\n";
				$last_cat_id = $i['cat_id'];
			}
			if ( isset( $ibforums->input['f'] ) && $ibforums->input['f'] == $i['forum_id'] )
			{
				$selected = " selected";
			}
			if ( $i['subwrap'] == 1 )
			{
				$is_sub = $ibforums->lang['is_sub'];
			}
			if ( $i['read_perms'] == "*" )
			{
				$forums .= "<option value=\"{$i['forum_id']}\"{$selected}>{$i['forum_name']}{$is_sub}\n";
			}
			else
			{
				if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $i['read_perms'] ) )
				{
					$forums .= "<option value='{$i['forum_id']}'{$selected}>{$i['forum_name']}{$is_sub}\n";
				}
			}
			if ( $i['subwrap'] == 1 && 0 < count( $db_children[$i['forum_id']] ) )
			{
				foreach ( $db_children[$i['forum_id']] as $idx => $cdata )
				{
					if ( $cdata['read_perms'] == "*" )
					{
						$forums .= "<option value=\"{$cdata['forum_id']}\"{$selected}> +---- {$cdata['forum_name']}\n";
					}
					else if ( preg_match( "/(^|,)".$ibforums->member['mgroup']."(,|\$)/", $cdata['read_perms'] ) )
					{

⌨️ 快捷键说明

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