xmlout.php

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

PHP
1,314 行
字号
    	//-----------------------------------------    	    	$name = $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['name'] ) );    	   		$name = $this->convert_unicode( $name );   				if( strtolower($this->ipsclass->vars['gb_char_set']) != 'iso-8859-1' &&			strtolower($this->ipsclass->vars['gb_char_set']) != 'utf-8' )   		{	   		if ( array_key_exists( strtolower($this->ipsclass->vars['gb_char_set']), $this->decode_charsets ) )	   		{		   		$this->ipsclass->vars['gb_char_set'] = $this->decode_charsets[strtolower($this->ipsclass->vars['gb_char_set'])];		   		$name = html_entity_decode( $name, ENT_NOQUOTES, $this->ipsclass->vars['gb_char_set'] );	   		}   		}        	    	    	//--------------------------------------------		// Load extra db cache file		//--------------------------------------------				$this->ipsclass->DB->load_cache_file( ROOT_PATH.'sources/sql/'.SQL_DRIVER.'_extra_queries.php', 'sql_extra_queries' );		    	//-----------------------------------------    	// Check length    	//-----------------------------------------    	    	if ( strlen( $name ) < 3 )    	{    		$this->return_null();    	}    	    	//-----------------------------------------    	// Try query...    	//-----------------------------------------    	    	$this->ipsclass->DB->cache_add_query( 'member_display_name_lookup', array( 'name' => $name, 'field' => 'members_display_name' ), 'sql_extra_queries' );		$this->ipsclass->DB->cache_exec_query();		    	//-----------------------------------------    	// Got any results?    	//-----------------------------------------    	    	if ( ! $this->ipsclass->DB->get_num_rows() ) 		{    		$this->return_null();    	}    	    	$names = array();		$ids   = array();				while( $r = $this->ipsclass->DB->fetch_row() )		{			$names[] = '"'.$r['members_display_name'].'"';			$ids[]   = intval($r['id']);		}				print "returnSearch( '".str_replace( "'", "", $name )."', new Array(".implode( ",", $names )."), new Array(".implode( ",", $ids ).") );";    }        /*-------------------------------------------------------------------------*/	// Get new posts	/*-------------------------------------------------------------------------*/          function get_new_messages( $return=0 )    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$count = intval( $_REQUEST['count'] );    	$count = $count ? $count : 5;    	    	$this->ipsclass->load_template( 'skin_msg' );    	$this->ipsclass->load_language( 'lang_msg' );    	    	//-----------------------------------------    	// Check...    	//-----------------------------------------    	    	if ( ! $this->ipsclass->member['id'] )		{			return $this->error_handler();		}				//-----------------------------------------		// Get message list		//-----------------------------------------				$this->ipsclass->DB->cache_add_query( 'msg_get_folder_list',											  array( 'mid' => $this->ipsclass->member['id'], 'vid' => 'in', 'sort' => 'mt_date DESC', 'limita' => 0, 'limitb' => $count ) ); 		$this->ipsclass->DB->simple_exec(); 		 		if ( ! $this->ipsclass->DB->get_num_rows() ) 		{ 			//$this->error_handler("No messages"); 		} 		 		//----------------------------------------- 		// Start output 		//----------------------------------------- 				while( $r = $this->ipsclass->DB->fetch_row() )		{			//-----------------------------------------			// We only want 10 rows, but the 11th will			// tell us if there are more to come			//-----------------------------------------						$r['date'] = $this->ipsclass->get_date( $r['mt_date'] , 'TINY', 0, 1 );			$r['icon'] = $r['mt_read'] == 1 ? "<img src='{$this->ipsclass->vars['img_url']}/f_norm_no.gif' border='0' />"											: "<img src='{$this->ipsclass->vars['img_url']}/f_norm.gif' border='0' />";														$r['_mini'] = $this->ipsclass->txt_truncate( $r['mt_title'] , 30 );						$html .= $this->ipsclass->compiled_templates['skin_msg']->xmlout_msgs_row( $r );		}				//-----------------------------------------		// Check count...		//-----------------------------------------				if ( ! $return )		{			@header( "Content-type: text/plain;charset={$this->ipsclass->vars['gb_char_set']}" );			$this->print_nocache_headers();			print $this->ipsclass->compiled_templates['skin_msg']->xmlout_msgs_wrapper( $html );			exit();		}		else		{			return $this->ipsclass->compiled_templates['skin_msg']->xmlout_msgs_wrapper( $html );		}	}	        /*-------------------------------------------------------------------------*/	// Get new posts	/*-------------------------------------------------------------------------*/          function mark_forum_as_read()    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$forum_id = intval( $_REQUEST['fid'] );    	$sf       = intval( $_REQUEST['sf'] );    	    	//-----------------------------------------    	// Check...    	//-----------------------------------------    	    	if ( ! $this->ipsclass->member['id'] )		{			return $this->error_handler();		}				if ( ! $forum_id )		{			return $this->error_handler();		}				//-----------------------------------------		// OK - do the magic!!		//-----------------------------------------		        if ( $sf )        {        	$children = $this->ipsclass->forums->forums_get_children( $forum_id );        				if ( is_array( $children ) and count($children) )			{				foreach( $children as $id )				{					$this->ipsclass->member['members_forum_markers'][ $id ] = time();				}			}        }        		$this->ipsclass->member['members_forum_markers'][ $forum_id ] = time();				$this->ipsclass->DB->do_update( 'members', array( 'members_forum_markers' => addslashes(serialize( $this->ipsclass->member['members_forum_markers'] ) ) ), 'id='.intval($this->ipsclass->member['id']) );    	    	$this->xml_output = $this->xml_header . "\r\n<done><val>1</val></done>";    	print $this->xml_output;    	exit();    }    	/*-------------------------------------------------------------------------*/	// Get new posts	/*-------------------------------------------------------------------------*/          function get_new_posts( $return=0 )    {    	//-----------------------------------------    	// INIT    	//-----------------------------------------    	    	$count     = 0;    	$st        = intval( $_REQUEST['st'] );    	$next      = 0;    	$previous  = 0;    	$html      = '';    	    	$this->ipsclass->load_template( 'skin_search' );    	$this->ipsclass->load_language( 'lang_search' );    	    	//-----------------------------------------    	// Check...    	//-----------------------------------------    	    	if ( ! $this->ipsclass->member['id'] )		{			return $this->error_handler();		}				//-----------------------------------------		// Get search lib		//-----------------------------------------				require_once( ROOT_PATH.'sources/action_public/search.php' );		$this->search = new search();		$this->search->ipsclass =& $this->ipsclass;				//-----------------------------------------		// Do we have any forums to search in?		//-----------------------------------------				$this->ipsclass->input['forums'] = 'all';		$this->ipsclass->input['CODE']  = 'getnew';		 		$forums = $this->search->get_searchable_forums();				if ( $forums == "" )		{			return $this->error_handler();		}				//-----------------------------------------		// Work out the "last time"		//-----------------------------------------				$last_time = $this->ipsclass->member['last_visit'];				if ( $this->ipsclass->member['members_markers']['board'] > $last_time )		{			$last_time = $this->ipsclass->member['members_markers']['board'];		}				//-----------------------------------------		// Get query		//-----------------------------------------				$this->ipsclass->DB->simple_construct( array( 'select' => 't.*, t.title as topic_title',													  'from'   => 'topics t',													  'where'  => "t.forum_id IN($forums) AND t.last_post > {$last_time} AND t.approved=1 AND t.pinned IN (0,1)",													  'order'  => "t.last_post DESC",													  'limit'  => array( $st, 11 ) ) );		$this->ipsclass->DB->simple_exec();				while( $r = $this->ipsclass->DB->fetch_row() )		{			//-----------------------------------------			// We only want 10 rows, but the 11th will			// tell us if there are more to come			//-----------------------------------------						$count++;						if ( $count == 11 )			{				break;			}						$mini_title = $this->ipsclass->txt_truncate( $r['title'] , 30 );			$mini_name  = $this->ipsclass->txt_truncate( $r['last_poster_name'] , 25 );			$date       = $this->ipsclass->get_date( $r['last_post'], 'TINY', 0, 1 );						$html .= $this->ipsclass->compiled_templates['skin_search']->xmlout_gnp_row($r['tid'], $mini_title, $r['title'], $date );		}				//-----------------------------------------		// Check count...		//-----------------------------------------				if ( $count )		{			if ( $count > 10 )			{				$next = $st + 10;			}						if ( $st )			{				$previous = $st - 10;			}		}		else		{			$html = "<center><em>{$this->ipsclass->lang['xml_nopost']}</em></center>";		}				if ( ! $return )		{			@header( "Content-type: text/plain;charset={$this->ipsclass->vars['gb_char_set']}" );			$this->print_nocache_headers();			print $this->ipsclass->compiled_templates['skin_search']->xmlout_gnp_wrapper( $html, $previous, $next, $st );			exit();		}		else		{			return $this->ipsclass->compiled_templates['skin_search']->xmlout_gnp_wrapper( $html, $previous, $next, $st );		}	} 	 	/*-------------------------------------------------------------------------*/ 	// make string XML safe 	/*-------------------------------------------------------------------------*/ 	 	function _make_safe_for_xml( $t ) 	{ 		return str_replace( '&amp;#39;', '&#39;', htmlspecialchars( $t ) ); 	}				/*-------------------------------------------------------------------------*/    // Error handler    /*-------------------------------------------------------------------------*/        function error_handler()    {    	@header( "Content-type: text/xml" );    	$this->print_nocache_headers();    	$this->xml_output = $this->xml_header."\r\n<errors>\r\n";    	$this->xml_output .= "<error><message>You must be logged in to access this feature</message></error>\r\n";    	$this->xml_output .= "</errors>";		print $this->xml_output;		exit();    }        /*-------------------------------------------------------------------------*/    // Return NOTHING :o    /*-------------------------------------------------------------------------*/        function return_null($val=0)    {    	@header( "Content-type: text/xml" );    	$this->print_nocache_headers();    	print $this->xml_header."\r\n<null>{$val}</null>";    	exit();    }        /*-------------------------------------------------------------------------*/    // Return string    /*-------------------------------------------------------------------------*/        function return_string($string)    {    	@header( "Content-type: text/plain" );    	$this->print_nocache_headers();    	print $string;    	exit();    }        /*-------------------------------------------------------------------------*/    // Print no cache headers    /*-------------------------------------------------------------------------*/        function print_nocache_headers()    {    	header("HTTP/1.0 200 OK");		header("HTTP/1.1 200 OK");    	header("Cache-Control: no-cache, must-revalidate, max-age=0");		header("Expires: 0");		header("Pragma: no-cache");	}		/*-------------------------------------------------------------------------*/    // Convert decimal character references to UTF-8    /*-------------------------------------------------------------------------*/    	function dec_char_ref_to_utf8($int=0)	{		$return = '';		if ( $int < 0 )		{			return chr(0);		}		else if ( $int <= 0x007f )		{			$return .= chr($int);		}		else if ( $int <= 0x07ff )		{			$return .= chr(0xc0 | ($int >> 6));			$return .= chr(0x80 | ($int & 0x003f));		}		else if ( $int <= 0xffff )		{			$return .= chr(0xe0 | ($int  >> 12));			$return .= chr(0x80 | (($int >> 6) & 0x003f));			$return .= chr(0x80 | ($int  & 0x003f));		}		else if ( $int <= 0x10ffff )		{			$return .= chr(0xf0 | ($int  >> 18));			$return .= chr(0x80 | (($int >> 12) & 0x3f));			$return .= chr(0x80 | (($int >> 6) & 0x3f));			$return .= chr(0x80 | ($int  &  0x3f));		}		else		{ 			return chr(0);		}				return $return;	}	/*-------------------------------------------------------------------------*/	// Convert Ajax unicode	/*-------------------------------------------------------------------------*/		function convert_unicode($t)	{		if ( strtolower($this->ipsclass->vars['gb_char_set']) == 'utf-8' )		{			return preg_replace( '#%u([0-9A-F]{1,4})#ie', "\$this->dec_char_ref_to_utf8(hexdec('\\1'))", utf8_encode($t) );		}		else		{			return preg_replace( '#%u([0-9A-F]{1,4})#ie', "'&#' . hexdec('\\1') . ';'", $t );		}	}        }?>

⌨️ 快捷键说明

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