Удалил json.php
This commit is contained in:
parent
c13777d7e3
commit
651a841187
8 changed files with 0 additions and 116 deletions
|
|
@ -1,10 +0,0 @@
|
|||
HTTP/1.1 200 OK
|
||||
Date: Mon, 31 Mar 2008 12:38:37 GMT
|
||||
Server: Apache/2.0.61 (Win32) SVN/1.4.3 mod_python/3.3.1 Python/2.4.3 PHP/5.2.5 DAV/2
|
||||
X-Powered-By: PHP/5.2.5
|
||||
Expires: Thu, 19 Nov 1981 08:52:00 GMT
|
||||
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
|
||||
Pragma: no-cache
|
||||
Content-Length: 6232
|
||||
Connection: close
|
||||
Content-Type: text/html; charset=windows-1251
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
|
||||
require_once 'core/safecollection.php';
|
||||
require_once 'core/json.php';
|
||||
require_once 'core/session.php';
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -1,97 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* http://phptunes.blogspot.com/2007/01/phpjson.html
|
||||
*/
|
||||
class json
|
||||
{
|
||||
static $DEFAULT_ENCODING = 'windows-1251//IGNORE';
|
||||
static $INTERNAL_ENCODING = 'utf-8';
|
||||
|
||||
static function encode($var)
|
||||
{
|
||||
return php2js($var); //json_encode(self::prepare($var, array('self', 'unicode_encode')));
|
||||
}
|
||||
|
||||
// Преобразование json в массив
|
||||
static function decode($var, $encoding = 'utf-8', $is_array = false)
|
||||
{
|
||||
if ($encoding != 'utf-8') $var = iconv($encoding, self::$INTERNAL_ENCODING, $var);
|
||||
return self::prepare(json_decode($var, $is_array), array('self', 'unicode_decode'));
|
||||
}
|
||||
|
||||
static function ident($var)
|
||||
{
|
||||
return $var;
|
||||
}
|
||||
|
||||
/* windows-1251 -> utf-8 */
|
||||
static function unicode_encode($var)
|
||||
{
|
||||
return @iconv(self::$DEFAULT_ENCODING, self::$INTERNAL_ENCODING, $var);
|
||||
}
|
||||
|
||||
/* utf-8 -> windows-1251 */
|
||||
static function unicode_decode($var)
|
||||
{
|
||||
return @iconv(self::$INTERNAL_ENCODING, self::$DEFAULT_ENCODING, $var);
|
||||
}
|
||||
|
||||
static function prepare($var, $encode)
|
||||
{
|
||||
if (is_array($var)) {
|
||||
$new = array();
|
||||
foreach ($var as $k => $v) {
|
||||
$new[self::prepare($k, $encode)] = self::prepare($v, $encode);
|
||||
}
|
||||
$var = $new;
|
||||
} elseif (is_object($var)) {
|
||||
// Было преобразование типа для отображения !!
|
||||
$vars = get_object_vars($var);
|
||||
foreach ($vars as $m => $v) {
|
||||
$var->$m = self::prepare($var->$m, $encode);
|
||||
}
|
||||
} elseif (is_string($var)) {
|
||||
$var = call_user_func($encode, $var);
|
||||
}
|
||||
return $var;
|
||||
}
|
||||
}
|
||||
|
||||
function php2js($a = false) {
|
||||
if (is_null($a)) return 'null';
|
||||
if ($a === false) return 'false';
|
||||
if ($a === true) return 'true';
|
||||
if (is_scalar($a)) {
|
||||
if (is_float($a)) {
|
||||
// Always use "." for floats.
|
||||
$a = str_replace(",", ".", strval($a));
|
||||
} else if (is_int($a)) {
|
||||
return $a;
|
||||
}
|
||||
// All scalars are converted to strings to avoid indeterminism.
|
||||
// PHP's "1" and 1 are equal for all PHP operators, but
|
||||
// JS's "1" and 1 are not. So if we pass "1" or 1 from the PHP backend,
|
||||
// we should get the same result in the JS frontend (string).
|
||||
// Character replacements for JSON.
|
||||
static $jsonReplaces = array(
|
||||
array("\\", "/", "\n", "\t", "\r", "\b", "\f", '"'),
|
||||
array('\\\\', '\\/', '\\n', '\\t', '\\r', '\\b', '\\f', '\"'));
|
||||
return '"' . str_replace($jsonReplaces[0], $jsonReplaces[1], $a) . '"';
|
||||
}
|
||||
$isList = true;
|
||||
for ($i = 0, reset($a);$i < count($a);$i++, next($a)) {
|
||||
if (key($a) !== $i) {
|
||||
$isList = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
$result = array();
|
||||
if ($isList) {
|
||||
foreach($a as $v) $result[] = php2js($v);
|
||||
return '[' . join(',', $result) . ']';
|
||||
} else {
|
||||
foreach($a as $k => $v) $result[] = php2js($k) . ':' . php2js($v);
|
||||
return '{' . join(',', $result) . '}';
|
||||
}
|
||||
}
|
||||
|
|
@ -315,5 +315,3 @@ class Path
|
|||
return implode(self::SEPARATOR, $args);
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -21,5 +21,3 @@ class Registry extends Settings
|
|||
return self::$instance;
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -33,4 +33,3 @@ class SafeCollection extends Collection
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -55,4 +55,3 @@ class Shortcut
|
|||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
@ -32,5 +32,3 @@ function phptal_time ($e)
|
|||
{
|
||||
return date ("H:i", $e);
|
||||
}
|
||||
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue