xmlout.php
来自「sabreipb 2.1.6 utf-8中文版本!」· PHP 代码 · 共 234 行
PHP
234 行
<?php
/*
+--------------------------------------------------------------------------
| Invision Power Board v2.1.5
| =============================================
| by Matthew Mecham
| (c) 2001 - 2005 Invision Power Services, Inc.
|
| =============================================
| Web:
| Time: Wed, 01 Mar 2006 19:11:27 GMT
| Release:
| Licence Info:
+---------------------------------------------------------------------------
| > $Date: 2006-3-6
| > $Revision: 23 $
| > $Author: matt $
+---------------------------------------------------------------------------
|
| > XML OUT Functions for XmlHttpRequest functions
| > Module written by Matt Mecham
| > Date started: Friday 18th March 2005
|
| > Module Version Number: 1.1.0
+--------------------------------------------------------------------------
*/
if ( ! defined( 'IN_IPB' ) )
{
print "<h1>Incorrect access</h1>You cannot access this file directly. If you have recently upgraded, make sure you upgraded all the relevant files.";
exit();
}
class ad_xmlout
{
# Classes
var $ipsclass;
var $search;
var $xml_output;
var $xml_header;
/*-------------------------------------------------------------------------*/
// Constructor
/*-------------------------------------------------------------------------*/
function xmlout()
{
$this->xml_header = '<?xml version="1.0" encoding="ISO-8859-1"?'.'>';
}
/*-------------------------------------------------------------------------*/
// Auto run
/*-------------------------------------------------------------------------*/
function auto_run()
{
//-----------------------------------------
// INIT
//-----------------------------------------
if ( $this->ipsclass->input['j_do'] )
{
$this->ipsclass->input['do'] = $this->ipsclass->input['j_do'];
}
//-----------------------------------------
// What shall we do?
//-----------------------------------------
switch( $this->ipsclass->input['do'] )
{
case 'get-template-names':
$this->get_template_names();
break;
case 'get-member-names':
$this->get_member_names();
break;
}
}
/*-------------------------------------------------------------------------*/
// Get new posts
/*-------------------------------------------------------------------------*/
function get_member_names()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$name = $this->ipsclass->parse_clean_value( rawurldecode( $_REQUEST['name'] ) );
//--------------------------------------------
// 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 ).") );";
exit();
}
/*-------------------------------------------------------------------------*/
// Get template names
/*-------------------------------------------------------------------------*/
function get_template_names()
{
//-----------------------------------------
// INIT
//-----------------------------------------
$name = $this->ipsclass->parse_clean_value( urldecode( $_REQUEST['name'] ) );
$id = intval( $_REQUEST['id'] );
//-----------------------------------------
// Get $skin_names stuff
//-----------------------------------------
require_once( ROOT_PATH.'sources/lib/skin_info.php' );
//-----------------------------------------
// Check length
//-----------------------------------------
if ( strlen( $name ) < 3 )
{
$this->return_null();
}
//-----------------------------------------
// Try query...
//-----------------------------------------
$this->ipsclass->DB->build_query( array( 'select' => "suid,set_id,group_name,func_name",
'from' => 'skin_templates',
'where' => "set_id=1 AND LOWER(func_name) LIKE '{$name}%'",
'order' => 'LENGTH(func_name) ASC',
'limit' => array( 0,20 ) ) );
$this->ipsclass->DB->exec_query();
$names = array();
$ids = array();
while( $r = $this->ipsclass->DB->fetch_row() )
{
$names[] = '"'.$r['func_name'].' ('.$r['group_name'].')"';
$ids[] = intval($r['suid']);
}
print "returnSearch( '".str_replace( "'", "", $name )."', new Array(".implode( ",", $names )."), new Array(".implode( ",", $ids ).") );";
exit();
}
/*-------------------------------------------------------------------------*/
// make string XML safe
/*-------------------------------------------------------------------------*/
function _make_safe_for_xml( $t )
{
return str_replace( '&#39;', ''', htmlspecialchars( $t ) );
}
/*-------------------------------------------------------------------------*/
// Error handler
/*-------------------------------------------------------------------------*/
function error_handler()
{
@header( "Content-type: text/xml" );
$this->xml_output = $this->xml_header."\r\n<errors>\r\n";
$this->xml_output .= "<error><message>鎮ㄥ繀椤诲厛鐧诲綍</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" );
print $this->xml_header."\r\n<null>{$val}</null>"; exit();
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?