search.php

来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 1,763 行 · 第 1/4 页

PHP
1,763
字号
			// Get any old search results..						$this->ipsclass->DB->simple_construct( array( 'select' => 'id',										 				  'from'   => 'search_results',										 				  'where'  => "(member_id='".$this->ipsclass->member['id']."' OR ip_address='".$this->ipsclass->input['IP_ADDRESS']."') AND search_date > '$flood_time'" ) );			$this->ipsclass->DB->simple_exec();						if ( $this->ipsclass->DB->get_num_rows() )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_flood', 'EXTRA' => $this->ipsclass->member['g_search_flood']) );			}		}				$last_time = $this->ipsclass->member['last_visit'];				if ( $this->ipsclass->member['members_markers']['board'] > $last_time )		{			$last_time = $this->ipsclass->member['members_markers']['board'];		}				//-----------------------------------------		// Are we getting 'active topics'?		//-----------------------------------------				if ( $this->ipsclass->input['active'] )		{			if ( $this->ipsclass->input['lastdate'] )			{				$last_time = time() - intval($this->ipsclass->input['lastdate']);			}			else			{				$last_time = time() - 86400;			}		}				$this->ipsclass->input['forums'] = 'all';		$this->ipsclass->input['nav']    = 'lv';				$forums = $this->get_searchable_forums();				//-----------------------------------------		// Do we have any forums to search in?		//-----------------------------------------				if ($forums == "")		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );		}				//-----------------------------------------		// Get the topic ID's to serialize and store into		// the database		//-----------------------------------------				$this->ipsclass->DB->simple_construct( array( 'select' => 'count(*) as count', 'from' => 'topics', 'where' => "approved=1 AND state != 'link' AND forum_id IN($forums) AND last_post > '".$last_time."'" ) );		$this->ipsclass->DB->simple_exec();				$row = $this->ipsclass->DB->fetch_row();				$results = intval($row['count']);				//-----------------------------------------		// Do we have any results?		//-----------------------------------------				if ( ! $results )		{			//$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );		}				//-----------------------------------------		// Cache query		//-----------------------------------------				$this->ipsclass->DB->simple_construct( array( 'select' => 't.*, t.title as topic_title',													  'from'   => 'topics t',													  'where'  => "t.approved=1 AND t.state != 'link' AND t.forum_id IN($forums) AND t.last_post > {$last_time}",													  'order'  => "t.last_post DESC" ) );						$query_to_cache = $this->ipsclass->DB->cur_query;		$this->ipsclass->DB->flush_query();				//-----------------------------------------		// If we are still here, store the data into the database...		//-----------------------------------------				$unique_id = md5(uniqid(microtime(),1));				$this->ipsclass->DB->do_insert( 'search_results', array (												 'id'          => $unique_id,												 'search_date' => time(),												 'post_max'    => $results,												 'sort_key'    => $this->sort_key,												 'sort_order'  => $this->sort_order,												 'member_id'   => $this->ipsclass->member['id'],												 'ip_address'  => $this->ipsclass->input['IP_ADDRESS'],												 'query_cache' => $query_to_cache										)        );				$this->ipsclass->boink_it( $this->ipsclass->base_url."act=Search&nav=lv&CODE=show&searchid=$unique_id&search_in=topics&result_type=topics&lastdate={$this->ipsclass->input['lastdate']}" );	} 	 	/*-------------------------------------------------------------------------*/ 	// Last 10 posts 	/*-------------------------------------------------------------------------*/ 	 	function get_last_ten() 	{		//-----------------------------------------		// Do we have flood control enabled?		//-----------------------------------------				if ($this->ipsclass->member['g_search_flood'] > 0)		{			$flood_time = time() - $this->ipsclass->member['g_search_flood'];						// Get any old search results..						$this->ipsclass->DB->simple_construct( array( 'select' => 'id',										  'from'   => 'search_results',										  'where'  => "(member_id='".$this->ipsclass->member['id']."' OR ip_address='".$this->ipsclass->input['IP_ADDRESS']."') AND search_date > '$flood_time'" ) );			$this->ipsclass->DB->simple_exec();						if ( $this->ipsclass->DB->get_num_rows() )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_flood', 'EXTRA' => $this->ipsclass->member['g_search_flood']) );			}		}				$this->ipsclass->input['forums'] = 'all';				$forums = $this->get_searchable_forums();				$mid    = $this->ipsclass->member['id'];				//-----------------------------------------		// Do we have any forums to search in?		//-----------------------------------------				if ($forums == "")		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );		}				//-----------------------------------------		// Cache query		//-----------------------------------------				$this->ipsclass->DB->cache_add_query( 'search_get_last_ten', array( 'mid' => $mid, 'forums' => $forums ) );				$query_to_cache = $this->ipsclass->DB->cur_query;		$this->ipsclass->DB->flush_query();				//-----------------------------------------		// If we are still here, store the data into the database...		//-----------------------------------------				$unique_id = md5(uniqid(microtime(),1));				$this->ipsclass->DB->do_insert( 'search_results', array (												 'id'          => $unique_id,												 'search_date' => time(),												 'post_max'    => 10,												 'sort_key'    => $this->sort_key,												 'sort_order'  => $this->sort_order,												 'member_id'   => $this->ipsclass->member['id'],												 'ip_address'  => $this->ipsclass->input['IP_ADDRESS'],												 'query_cache' => $query_to_cache										)        );				$this->ipsclass->boink_it( $this->ipsclass->base_url."act=Search&nav=au&CODE=show&searchid=$unique_id&search_in=posts&result_type=posts" );	} 	 	/*-------------------------------------------------------------------------*/ 	// Get all replies 	/*-------------------------------------------------------------------------*/ 	 	function get_replies() 	{		//-----------------------------------------		// Do we have flood control enabled?		//-----------------------------------------				if ($this->ipsclass->member['g_search_flood'] > 0)		{			$flood_time = time() - $this->ipsclass->member['g_search_flood'];						// Get any old search results..						$this->ipsclass->DB->simple_construct( array( 'select' => 'id',										  'from'   => 'search_results',										  'where'  => "(member_id='".$this->ipsclass->member['id']."' OR ip_address='".$this->ipsclass->input['IP_ADDRESS']."') AND search_date > '$flood_time'" ) );			$this->ipsclass->DB->simple_exec();						if ( $this->ipsclass->DB->get_num_rows() )			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_flood', 'EXTRA' => $this->ipsclass->member['g_search_flood']) );			}		}				$this->ipsclass->input['forums'] = 'all';		$this->ipsclass->input['nav']    = 'lv';				$forums = $this->get_searchable_forums();				if ( $this->ipsclass->forum_read[0] > $this->ipsclass->member['last_visit'] )		{			$this->ipsclass->member['last_visit'] = $this->ipsclass->forum_read[0];		}					//-----------------------------------------		// Do we have any forums to search in?		//-----------------------------------------				if ($forums == "")		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_forum') );		}			//-----------------------------------------		// Get the topic ID's to serialize and store into		// the database		//-----------------------------------------				$this->ipsclass->DB->simple_construct( array( 'select' => 'tid',									  'from'   => 'topics',									  'where'  => "starter_id={$this->ipsclass->member['id']} AND last_post > {$this->ipsclass->member['last_visit']} AND forum_id IN($forums) AND approved=1" ) );		$this->ipsclass->DB->simple_exec();				$max_hits = $this->ipsclass->DB->get_num_rows();				$topics  = "";				while ($row = $this->ipsclass->DB->fetch_row() )		{			$topics .= $row['tid'].",";		}			$this->ipsclass->DB->free_result();				$topics  = preg_replace( "/,$/", "", $topics );				//-----------------------------------------		// Do we have any results?		//-----------------------------------------				if ($topics == "")		{			$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );		}				//-----------------------------------------		// If we are still here, store the data into the database...		//-----------------------------------------				$unique_id = md5(uniqid(microtime(),1));				$this->ipsclass->DB->do_insert( 'search_results', 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'  => $this->ipsclass->member['id'],												 'ip_address' => $this->ipsclass->input['IP_ADDRESS'],										)        );				$this->ipsclass->print->redirect_screen( $this->ipsclass->lang['search_redirect'] , "act=Search&nav=gr&CODE=show&searchid=$unique_id&search_in=posts&result_type=topics" );		exit();	}		/*-------------------------------------------------------------------------*/	// Show pop-up window	/*-------------------------------------------------------------------------*/		function show_boolean_explain() 	{		$this->ipsclass->print->pop_up_window( $this->ipsclass->lang['be_link'], $this->ipsclass->compiled_templates['skin_search']->boolean_explain_page() ); 	}		/*-------------------------------------------------------------------------*/	// Show main form	/*-------------------------------------------------------------------------*/ 	 	function show_form() 	{		$the_html = $this->ipsclass->forums->forums_forum_jump(1, 1);				if ( ! $this->ipsclass->input['f'] )		{			$init_sel = ' selected="selected"';		}				$forums   = "<select name='forums[]' class='forminput' size='10' multiple='multiple'>\n"		           ."<option value='all'".$init_sel.">".$this->ipsclass->lang['all_forums']."</option>"		           . $the_html		           . "</select>";				if ( $this->ipsclass->input['mode'] == 'simple' )		{			if ( $this->ipsclass->vars['search_sql_method'] == 'ftext' )			{				$this->output = $this->ipsclass->compiled_templates['skin_search']->simple_form($forums);			}			else			{				$this->output = $this->ipsclass->compiled_templates['skin_search']->Form($forums);			}		}		else if ( $this->ipsclass->input['mode'] == 'adv' )		{			$this->output = $this->ipsclass->compiled_templates['skin_search']->Form($forums);						if ( $this->ipsclass->vars['search_sql_method'] == 'ftext' )			{				$this->output = str_replace( "<!--IBF.SIMPLE_BUTTON-->", $this->ipsclass->compiled_templates['skin_search']->form_simple_button(), $this->output );			}		}		else		{			// No mode specified..						if ( $this->ipsclass->vars['search_default_method'] == 'simple' )			{				if ( $this->ipsclass->vars['search_sql_method'] == 'ftext' )				{					$this->output = $this->ipsclass->compiled_templates['skin_search']->simple_form($forums);				}				else				{					$this->output = $this->ipsclass->compiled_templates['skin_search']->Form($forums);				}			}			else			{				// Default..								$this->output = $this->ipsclass->compiled_templates['skin_search']->Form($forums);								if ( $this->ipsclass->vars['search_sql_method'] == 'ftext' )				{					$this->output = str_replace( "<!--IBF.SIMPLE_BUTTON-->", $this->ipsclass->compiled_templates['skin_search']->form_simple_button(), $this->output );				}			}		}				if ( ( $this->ipsclass->DB->sql_can_fulltext_boolean() == TRUE ) AND $this->ipsclass->vars['search_sql_method'] == 'ftext' )		{			$this->output = str_replace( "<!--IBF.BOOLEAN_EXPLAIN-->", $this->ipsclass->compiled_templates['skin_search']->boolean_explain_link(), $this->output );		}				$this->page_title = $this->ipsclass->lang['search_title'];		$this->nav        = array( $this->ipsclass->lang['search_form'] ); 	} 	 	/*-------------------------------------------------------------------------*/ 	// DO MAIN SEARCH 	/*-------------------------------------------------------------------------*/	function do_search()	{		//-----------------------------------------		// Un-urlencode first		//-----------------------------------------			if( $this->ipsclass->input['xml'] )		{			require_once (ROOT_PATH."sources/action_public/xmlout.php");			$xml_convert = new xmlout();			$xml_convert->ipsclass =& $this->ipsclass;						$this->ipsclass->input['keywords'] = $xml_convert->convert_unicode($this->ipsclass->input['keywords']);		}					//-----------------------------------------		// Do we have flood control enabled?		//-----------------------------------------				if ($this->ipsclass->member['g_search_flood'] > 0)		{			$flood_time = time() - $this->ipsclass->member['g_search_flood'];						// Get any old search results..						$this->ipsclass->DB->simple_construct( array( 'select' => 'id',														  'from'   => 'search_results',														  'where'  => "(member_id='".$this->ipsclass->member['id']."' OR ip_address='".$this->ipsclass->input['IP_ADDRESS']."') AND search_date > '$flood_time'" ) );			$this->ipsclass->DB->simple_exec();						if ( $this->ipsclass->DB->get_num_rows() )			{				if ( $this->xml_out )				{					print sprintf( $this->ipsclass->lang['xml_flood'], $this->ipsclass->member['g_search_flood'] );					exit();				}				else				{					$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'search_flood', 'EXTRA' => $this->ipsclass->member['g_search_flood']) );				}			}		}		//-----------------------------------------		// init main search		//-----------------------------------------				$result = $this->lib->do_main_search();				//-----------------------------------------		// Do we have any results?		//-----------------------------------------				if ($result['topic_id'] == "" and $result['post_id'] == "")		{			if ( $this->xml_out )			{				print sprintf( $this->ipsclass->lang['xml_nomatches'], $result['keywords'] );				exit();			}			else			{				$this->ipsclass->Error( array( 'LEVEL' => 1, 'MSG' => 'no_search_results' ) );			}		}				//-----------------------------------------		// If we are still here, store the data into the database...		//-----------------------------------------				$unique_id = md5(uniqid(microtime(),1));		$url       = "act=Search&CODE=show&searchid=$unique_id&search_in=".$this->search_in."&result_type=".$this->result_type."&highlite=".urlencode(trim($result['keywords']));				$this->ipsclass->DB->do_insert( 'search_results', array (																   'id'          => $unique_id,																   'search_date' => time(),																   'topic_id'    => $result['topic_id'],																   'topic_max'   => $result['topic_max'],																   'sort_key'    => $this->sort_key,

⌨️ 快捷键说明

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