Version 3.2.3
This commit is contained in:
1 parent
ae5c01cc78
commit
78706903a2
2641 files changed
+228363
-201264
No files matched your search
@@ -2,19 +2,20 @@
|
||||
/**
|
||||
* <pre>
|
||||
* Invision Power Services
|
||||
* IP.Board v3.1.4
|
||||
* IP.Board v3.2.3
|
||||
* AJAX input parsing and handling
|
||||
* Last Updated: $Date: 2010-10-14 13:11:17 -0400 (Thu, 14 Oct 2010) $
|
||||
* Last Updated: $Date: 2011-09-29 11:44:06 -0400 (Thu, 29 Sep 2011) $
|
||||
* </pre>
|
||||
*
|
||||
* @author $Author: ips_terabyte $
|
||||
* @author $Author: mmecham $
|
||||
* @copyright (c) 2001 - 2009 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/community/board/license.html
|
||||
* @license This is NULLED!
|
||||
* @package IP.Board
|
||||
* @subpackage Kernel
|
||||
* @link http://www.invisionpower.com
|
||||
* @link http://hatynka.in
|
||||
* @since Friday 19th May 2006 17:33
|
||||
* @version $Revision: 477 $
|
||||
* @version $Revision: 9567 $
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
@@ -39,7 +40,7 @@ class classAjax
|
||||
*
|
||||
* @var array Charsets supported by html_entity_decode
|
||||
*/
|
||||
private $decodeCharsets = array('iso-8859-1' => 'ISO-8859-1',
|
||||
protected $decodeCharsets = array('iso-8859-1' => 'ISO-8859-1',
|
||||
'iso8859-1' => 'ISO-8859-1',
|
||||
'iso-8859-15' => 'ISO-8859-15',
|
||||
'iso8859-15' => 'ISO-8859-15',
|
||||
@@ -66,7 +67,7 @@ class classAjax
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @return void
|
||||
* @return @e void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
@@ -78,7 +79,7 @@ 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::convertCharsets( IPSText::convertUnicode($value), "utf-8", "' . IPS_DOC_CHAR_SET . '" );' ) );
|
||||
array_walk_recursive( $_POST, array( $this, 'arrayWalkConvert' ) );
|
||||
|
||||
//-----------------------------------------
|
||||
// Using this code allows characters that ARE supported
|
||||
@@ -96,6 +97,21 @@ class classAjax
|
||||
//array_walk_recursive( $_GET , create_function( '&$value, $key', '$value = IPSText::convertUnicode($value);' ) );
|
||||
//array_walk_recursive( ipsRegistry::$request, create_function( '&$value, $key', '$value = IPSText::convertUnicode($value);' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to convert unicode and charset for AJAX requests
|
||||
*
|
||||
* @param mixed Value
|
||||
* @param string Key
|
||||
* @return void
|
||||
*/
|
||||
public function arrayWalkConvert( &$value, $key )
|
||||
{
|
||||
if( is_string( $value ) )
|
||||
{
|
||||
$value = IPSText::convertCharsets( IPSText::convertUnicode( $value ), "utf-8", IPS_DOC_CHAR_SET );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert and make safe an incoming string
|
||||
@@ -152,7 +168,7 @@ class classAjax
|
||||
/**
|
||||
* Print an error
|
||||
*
|
||||
* @return void [Outputs XML document and exits]
|
||||
* @return @e void [Outputs XML document and exits]
|
||||
*/
|
||||
public function returnGenericError()
|
||||
{
|
||||
@@ -171,7 +187,7 @@ class classAjax
|
||||
* Return a NULL result
|
||||
*
|
||||
* @param mixed Value to send
|
||||
* @return void [Outputs XML document and exits]
|
||||
* @return @e void [Outputs XML document and exits]
|
||||
*/
|
||||
public function returnNull( $val=0 )
|
||||
{
|
||||
@@ -188,7 +204,7 @@ class classAjax
|
||||
* Return a string
|
||||
*
|
||||
* @param string String to output
|
||||
* @return void [Outputs plaintext string]
|
||||
* @return @e void [Outputs plaintext string]
|
||||
*/
|
||||
public function returnString($string)
|
||||
{
|
||||
@@ -203,32 +219,49 @@ class classAjax
|
||||
* Return a JSON error message
|
||||
*
|
||||
* @param string Error message
|
||||
* @return void [Outputs JSON string and exits]
|
||||
* @return @e void [Outputs JSON string and exits]
|
||||
*/
|
||||
public function returnJsonError( $message )
|
||||
public function returnJsonError( $message, $header="application/json" )
|
||||
{
|
||||
/* Just alias it... */
|
||||
$this->returnJsonArray( array( 'error' => $message ) );
|
||||
$this->returnJsonArray( array( 'error' => $message ), false, $header );
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a JSON array
|
||||
*
|
||||
* @param array Single dimensional array of key => value fields
|
||||
* @return void [Outputs JSON string and exits]
|
||||
* @param boolean Clean the data (used when passing HTML)
|
||||
* @param string Optional string (default application/json)
|
||||
* @param array Optional array (template group, bit name) to pass JSON in a custom function
|
||||
* @return @e void [Outputs JSON string and exits]
|
||||
*/
|
||||
public function returnJsonArray( $json=array() )
|
||||
public function returnJsonArray( $json=array(), $cleanData=false, $header="application/json", $templateWrapper=array() )
|
||||
{
|
||||
@header( "Content-type: application/json;charset=" . IPS_DOC_CHAR_SET );
|
||||
@header( "Content-type: " . $header . ";charset=" . IPS_DOC_CHAR_SET );
|
||||
$this->printNocacheHeaders();
|
||||
|
||||
/* Always return as UTF-8 */
|
||||
array_walk_recursive( $json, create_function( '&$value, $key', '$value = IPSText::convertCharsets($value, "' . IPS_DOC_CHAR_SET . '", "UTF-8");' ) );
|
||||
|
||||
array_walk_recursive( $json, array( 'IPSText', 'arrayWalkCallbackConvert' ) );
|
||||
|
||||
if ( $cleanData )
|
||||
{
|
||||
array_walk_recursive( $json, array( $this, 'cleanHtml' ) );
|
||||
}
|
||||
|
||||
$result = json_encode( $json );
|
||||
$result = IPSText::convertCharsets($result, "UTF-8", IPS_DOC_CHAR_SET);
|
||||
print $result;
|
||||
|
||||
/* Print via a wrapper? */
|
||||
if ( is_array( $templateWrapper ) AND count( $templateWrapper ) )
|
||||
{
|
||||
print ipsRegistry::getClass('output')->getTemplate( $templateWrapper[0] )->$templateWrapper[1]( $result );
|
||||
}
|
||||
else
|
||||
{
|
||||
print $result;
|
||||
}
|
||||
|
||||
exit();
|
||||
}
|
||||
|
||||
@@ -236,31 +269,20 @@ class classAjax
|
||||
* Return HTML content
|
||||
*
|
||||
* @param string HTML to output
|
||||
* @return void [Outputs HTML and exits]
|
||||
* @param boolean Convert output on the fly
|
||||
* @return @e void [Outputs HTML and exits]
|
||||
*/
|
||||
public function returnHtml( $string )
|
||||
public function returnHtml( $string, $returnAsUtf8=false )
|
||||
{
|
||||
//-----------------------------------------
|
||||
// Stop one from removing cookie protection
|
||||
//-----------------------------------------
|
||||
|
||||
$string = ( $string ) ? $string : '<!--nothing-->';
|
||||
|
||||
// Fix IE bugs
|
||||
$string = str_ireplace( "§", "&sect", $string );
|
||||
|
||||
if ( strtolower( IPS_DOC_CHAR_SET ) == 'iso-8859-1' )
|
||||
if ( $string )
|
||||
{
|
||||
$string = str_replace( "ì", "“", $string );
|
||||
$string = str_replace( "î", "”", $string );
|
||||
$this->cleanHtml( $string );
|
||||
}
|
||||
|
||||
// Other stuff
|
||||
$string = ipsRegistry::getClass('output')->replaceMacros( $string );
|
||||
|
||||
if ( ! IN_ACP )
|
||||
|
||||
/* Always return as UTF-8 */
|
||||
if ( $returnAsUtf8 )
|
||||
{
|
||||
$string = $this->parseAndCleanHooks( $string );
|
||||
$string = IPSText::convertCharsets( $string, IPS_DOC_CHAR_SET, "UTF-8" );
|
||||
}
|
||||
|
||||
@header( "Content-type: text/html;charset=" . IPS_DOC_CHAR_SET );
|
||||
@@ -287,7 +309,7 @@ class classAjax
|
||||
/**
|
||||
* Print nocache headers
|
||||
*
|
||||
* @return void [Outputs headers]
|
||||
* @return @e void [Outputs headers]
|
||||
*/
|
||||
public function printNocacheHeaders()
|
||||
{
|
||||
@@ -371,4 +393,31 @@ class classAjax
|
||||
|
||||
return $t;
|
||||
}
|
||||
|
||||
/**
|
||||
* Cleans a HTML string
|
||||
* @param string $string
|
||||
* @return string clean
|
||||
*/
|
||||
public function cleanHtml( &$string, $key='' )
|
||||
{
|
||||
// Fix IE bugs
|
||||
$string = str_ireplace( "§", "&sect", $string );
|
||||
|
||||
if ( strtolower( IPS_DOC_CHAR_SET ) == 'iso-8859-1' )
|
||||
{
|
||||
$string = str_replace( "ì", "“", $string );
|
||||
$string = str_replace( "î", "”", $string );
|
||||
}
|
||||
|
||||
// Other stuff
|
||||
$string = ipsRegistry::getClass('output')->replaceMacros( $string );
|
||||
|
||||
if ( ! IN_ACP )
|
||||
{
|
||||
$string = $this->parseAndCleanHooks( $string );
|
||||
}
|
||||
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user