Version 3.1.4

This commit is contained in:
Neo committed 2025-12-19 00:32:22 -08:00
1 parent 1d4720f3e2
commit ae5c01cc78
2563 files changed
+283048 -240689

No files matched your search

+81 -42
View File
@@ -1,18 +1,20 @@
<?php
/**
* <pre>
* Invision Power Services
* IP.Board v3.0.5
* IP.Board v3.1.4
* AJAX input parsing and handling
* Last Updated: $Date: 2009-10-23 21:23:15 -0400 (Fri, 23 Oct 2009) $
* Last Updated: $Date: 2010-10-14 13:11:17 -0400 (Thu, 14 Oct 2010) $
* </pre>
*
* @author $Author: bfarber $
* @author $Author: ips_terabyte $
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
* @license http://www.iinvisionpower.com/community/board/license.html
* @package Invision Power Services Kernel
* @link http://www.iinvisionpower.com
* @license http://www.invisionpower.com/community/board/license.html
* @package IP.Board
* @subpackage Kernel
* @link http://www.invisionpower.com
* @since Friday 19th May 2006 17:33
* @version $Revision: 341 $
* @version $Revision: 477 $
*/
@@ -22,7 +24,6 @@ class classAjax
* XML output
*
* @var string Output
* @access public
*/
public $xml_output;
@@ -30,7 +31,6 @@ class classAjax
* XML Header
*
* @var string XML doctype
* @access public
*/
public $xml_header;
@@ -38,9 +38,8 @@ class classAjax
* Character sets
*
* @var array Charsets supported by html_entity_decode
* @access private
*/
private $decodeCharsets = array( 'iso-8859-1' => 'ISO-8859-1',
private $decodeCharsets = array('iso-8859-1' => 'ISO-8859-1',
'iso8859-1' => 'ISO-8859-1',
'iso-8859-15' => 'ISO-8859-15',
'iso8859-15' => 'ISO-8859-15',
@@ -67,7 +66,6 @@ class classAjax
/**
* Constructor
*
* @access public
* @return void
*/
public function __construct()
@@ -78,10 +76,18 @@ class classAjax
}
$this->xml_header = "<?xml version=\"1.0\" encoding=\"" . IPS_DOC_CHAR_SET . "\"?".'>';
/* Convert incoming $_POST fields */
array_walk_recursive( $_POST, create_function( '&$value, $key', '$value = IPSText::convertUnicode($value);' ) );
array_walk_recursive( $_POST, create_function( '&$value, $key', '$value = IPSText::convertCharsets( IPSText::convertUnicode($value), "utf-8", "' . IPS_DOC_CHAR_SET . '" );' ) );
//-----------------------------------------
// Using this code allows characters that ARE supported
// within the character set to be recoded properly, instead
// of as HTML entities when submitted via AJAX. The problem is,
// any characters NOT supported in the charset are corrupted. :-\
//-----------------------------------------
//array_walk_recursive( $_POST, create_function( '&$value, $key', '$value = IPSText::convertCharsets( IPSText::convertUnicode($value, true), "utf-8", "' . IPS_DOC_CHAR_SET . '" );' ) );
// We use $_REQUEST in a lot of places, so we might need to do this, but based on the below comments I'll leave this
// commented out for now...
//array_walk_recursive( $_REQUEST, create_function( '&$value, $key', '$value = IPSText::convertUnicode($value);' ) );
@@ -94,7 +100,6 @@ class classAjax
/**
* Convert and make safe an incoming string
*
* @access public
* @param string Raw input string
* @param boolean Run through parse_incoming routine
* @return string Cleaned string
@@ -102,6 +107,18 @@ class classAjax
public function convertAndMakeSafe( $value, $parse_incoming=true )
{
$value = rawurldecode( $value );
//-----------------------------------------
// \ char is passed as %5C so it won't be double
// escaped if magic quotes is on - do it manually
// @link http://community.invisionpower.com/tracker/issue-24971-status-update-issue/
//-----------------------------------------
if( IPS_MAGIC_QUOTES )
{
$value = str_replace( "\\", "\\\\", $value );
}
$value = $this->convertUnicode( $value );
$value = $this->convertHtmlEntities( $value );
@@ -112,11 +129,29 @@ class classAjax
return $value;
}
/**
* Cleans output so it is suitable for printing
*
* @param string Output data
* @return string Output data with parsed macros
*/
public function cleanOutput( $string )
{
if ( ! IN_ACP )
{
$string = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $string );
}
$string = ipsRegistry::getClass('output')->replaceMacros( $string );
return $string;
}
/**
* Print an error
*
* @access public
* @return void [Outputs XML document and exits]
*/
public function returnGenericError()
@@ -135,7 +170,6 @@ class classAjax
/**
* Return a NULL result
*
* @access public
* @param mixed Value to send
* @return void [Outputs XML document and exits]
*/
@@ -144,6 +178,8 @@ class classAjax
@header( "Content-type: text/xml" );
$this->printNocacheHeaders();
$val = $this->parseAndCleanHooks( $val );
print $this->xml_header . "\r\n<null>{$val}</null>";
exit();
}
@@ -151,7 +187,6 @@ class classAjax
/**
* Return a string
*
* @access public
* @param string String to output
* @return void [Outputs plaintext string]
*/
@@ -159,31 +194,21 @@ class classAjax
{
@header( "Content-type: text/plain;charset=" . IPS_DOC_CHAR_SET );
$this->printNocacheHeaders();
print $string;
echo $this->parseAndCleanHooks( $string );
exit();
}
/**
* Return a JSON error message
*
* @access public
* @param string Error message
* @return void [Outputs JSON string and exits]
*/
public function returnJsonError( $message )
{
$message = addslashes( $message );
@header( "Content-type: application/json;charset=" . IPS_DOC_CHAR_SET );
$this->printNocacheHeaders();
print <<<EOF
{
'error' : "{$message}"
}
EOF;
exit();
/* Just alias it... */
$this->returnJsonArray( array( 'error' => $message ) );
}
/**
@@ -210,7 +235,6 @@ EOF;
/**
* Return HTML content
*
* @access public
* @param string HTML to output
* @return void [Outputs HTML and exits]
*/
@@ -219,9 +243,8 @@ EOF;
//-----------------------------------------
// Stop one from removing cookie protection
//-----------------------------------------
$string = ( $string ) ? $string : '<!--nothing-->';
$string = str_ireplace( "htmldocument.prototype", "HTMLDocument_prototype", $string );
// Fix IE bugs
$string = str_ireplace( "&sect", "&amp;sect", $string );
@@ -231,9 +254,14 @@ EOF;
$string = str_replace( "ì", "&#8220;", $string );
$string = str_replace( "î", "&#8221;", $string );
}
// Other stuff
$string = ipsRegistry::getClass('output')->replaceMacros( $string );
if ( ! IN_ACP )
{
$string = $this->parseAndCleanHooks( $string );
}
@header( "Content-type: text/html;charset=" . IPS_DOC_CHAR_SET );
$this->printNocacheHeaders();
@@ -242,10 +270,23 @@ EOF;
exit();
}
/**
* Run hooks and remove hook comments
*
* @param string $string
* @return string
*/
public function parseAndCleanHooks( $string )
{
$string = ipsRegistry::getClass('output')->templateHooks( $string );
$string = preg_replace( '#<!--hook\.([^\>]+?)-->#', '', $string );
return $string;
}
/**
* Print nocache headers
*
* @access public
* @return void [Outputs headers]
*/
public function printNocacheHeaders()
@@ -267,7 +308,6 @@ EOF;
/**
* Convert AJAX unicode to standard char codes
*
* @access public
* @param string Input to convert
* @return string UTF-8 Converted content
*/
@@ -282,7 +322,6 @@ EOF;
/**
* Convert HTML entities into raw characters
*
* @access public
* @param string Input to convert
* @return string HTML entity decoded content
*/
@@ -292,7 +331,7 @@ EOF;
// Try and fix up HTML entities with missing ;
//-----------------------------------------
$t = preg_replace( "/&#(\d+?)([^\d;])/i", "&#\\1;\\2", $t );
$t = preg_replace( '/&#(\d+?)([^\d;])/i', "&#\\1;\\2", $t );
//-----------------------------------------
// Continue...
@@ -332,4 +371,4 @@ EOF;
return $t;
}
}
}