' . base64_encode( $output ) . '' ); } public static function utf8ize( $mixed) { if (is_array($mixed)) { foreach ($mixed as $key => $value) { $mixed[ $key ] = self::utf8ize($value); } } elseif (is_string($mixed)) { if ( function_exists( 'mb_convert_encoding' )) { return mb_convert_encoding($mixed, 'UTF-8', 'UTF-8'); } } return $mixed; } public static function safe_json_encode( $value, $options = 0, $depth = 512) { $encoded = @json_encode($value, $options, $depth); if ($encoded === false && $value && json_last_error() == JSON_ERROR_UTF8) { $encoded = @json_encode(self::utf8ize($value), $options, $depth); } return $encoded; } static function close_connection( $val = null ) { if (isset( $_REQUEST['json_result'] ) && $_REQUEST['json_result'] == true) : $output = self::safe_json_encode( $val ); else : $output = serialize( $val ); endif; $output = '' . base64_encode( $output ) . ''; // Close browser connection so that it can resume AJAX polling header( 'Content-Length: ' . strlen( $output ) ); header( 'Connection: close' ); header( 'Content-Encoding: none' ); if ( session_id() ) { session_write_close(); } echo $output; if ( ob_get_level() ) { ob_end_flush(); } flush(); } static function error( $error, $code = null ) { $information['error'] = $error; if (null !== $code) { $information['error_code'] = $code; } self::write( $information ); } /** * PARSE * Parses some CSS into an array * CSSPARSER * Copyright (C) 2009 Peter Kröner */ public static function parse_css( $css) { // Remove CSS-Comments $css = preg_replace('/\/\*.*?\*\//ms', '', $css); // Remove HTML-Comments $css = preg_replace('/([^\'"]+?)(\