summaryrefslogtreecommitdiff
path: root/itjs.class
diff options
context:
space:
mode:
Diffstat (limited to 'itjs.class')
-rw-r--r--itjs.class60
1 files changed, 9 insertions, 51 deletions
diff --git a/itjs.class b/itjs.class
index 702051d..9e3595a 100644
--- a/itjs.class
+++ b/itjs.class
@@ -47,56 +47,6 @@ static function serialize($values)
return json_encode($values, JSON_UNESCAPED_UNICODE | (it::is_devel() ? JSON_PRETTY_PRINT : 0));
}
-/*
- * Encode the result into a javascript array to transfer and eval() in client
- */
-static function encode($values)
-{
- if (!is_array($values))
- return json_encode($values, JSON_UNESCAPED_UNICODE);
-
- static $jskeyword = array("abstract" => 1, "boolean" => 1, "break" => 1, "byte" => 1, "case" => 1, "catch" => 1, "char" => 1, "class" => 1, "const" => 1, "continue" => 1, "debugger" => 1, "default" => 1, "delete" => 1, "do" => 1, "double" => 1, "each" => 1, "else" => 1, "enum" => 1, "export" => 1, "extends" => 1, "false" => 1, "final" => 1, "finally" => 1, "float" => 1, "for" => 1, "function" => 1, "goto" => 1, "if" => 1, "implements" => 1, "import" => 1, "in" => 1, "instanceof" => 1, "int" => 1, "interface" => 1, "long" => 1, "namespace" => 1, "native" => 1, "new" => 1, "null" => 1, "package" => 1, "private" => 1, "protected" => 1, "public" => 1, "return" => 1, "short" => 1, "static" => 1, "super" => 1, "switch" => 1, "synchronized" => 1, "this" => 1, "throw" => 1, "throws" => 1, "transient" => 1, "true" => 1, "try" => 1, "typeof" => 1, "var" => 1, "void" => 1, "volatile" => 1, "while" => 1, "with" => 1, "xml" => 1);
-
- $charset = self::$charset ?: ini_get('default_charset');
- $texts = ($values === array_values($values)) ? "[]0 " : "{}1\n"; # Numerical or associative array
- $result = $texts[0];
-
- foreach ($values as $key => $value)
- {
- $result .= $separator;
-
- if ($texts[2])
- {
- if ($jskeyword[$key] || !preg_match('/^[a-z_]\w*$/i', $key))
- $key = "'" . addslashes($key) . "'";
-
- $result .= "$key:";
- }
-
- if ($value === true)
- $result .= 'true';
- else if ($value === false)
- $result .= 'false';
- else if (!is_array($value))
- {
- $quote = (strval(intval($value)) === strval($value)) ? "" : '"';
- if (strtolower($charset) != "utf-8")
- $value = strtr($value, array("\x84" => '"', "\x93" => '"', "\x94" => '"'));
- $string = strtr($value, array("\0" => '\\0', '"' => '\\"', "</"=>"<\\/", "\n" => '\\n', "\r" => '\\r', "\t" => '\\t', "\\" => '\\\\'));
- $string = $GLOBALS['itjs_defaultconfig']['latin2unicode'] ? preg_replace_callback('/([\xa0-\xff])/', function($m) { return sprintf("\\u%04x", ord($m[1])); }, $string) : $string;
- $result .= $quote . $string . $quote;
- }
- else
- $result .= itjs::encode($value);
-
- $separator = "," . $texts[3];
- }
-
- $result .= $texts[1];
-
- return $result;
-}
-
/**
* Convert UNTRUSTED comma separated filelist string to trusted local filenames. Missing files are ignored.
*/
@@ -106,9 +56,11 @@ static function filenames($filelist)
$local = $GLOBALS['ULTRAHOME'] . "/itjs";
$itjs = "/www/server/phpinclude/itools/itjs";
$libsearch = strlen($GLOBALS['debug_lib']) > 1 ? "/www/lib-" . $GLOBALS['debug_lib'] . ".search.ch" : "/www/lib.search.ch";
- $special = array(
+ $deprecated = array(
"itools" => "$itjs/it.js,$itjs/http.js,$itjs/loader.js,$itjs/state.js,$itjs/timer.js",
"boot.js" => "$itjs/boot.js",
+ );
+ $special = array(
"error.gif" => "$itjs/error.gif",
"search.css" => "$libsearch/doc/search.css",
"prettyprint.css" => "$libsearch/doc/prettyprint.css",
@@ -116,6 +68,12 @@ static function filenames($filelist)
foreach (it::match("[-\w.=?&]+", basename($filelist), array('all' => true)) as $file) # split by comma but ignore illegal chars
{
+ if ($deprecated[$file])
+ {
+ it::error('title' => "Deprecated itjs file '$file' used");
+ continue;
+ }
+
$filenames = $special[$file] ?: (file_exists("$local/" . it::match('^[^?]*', $file)) ? "$local/$file" : "$libsearch/itjs/$file");
foreach (explode(",", $filenames) as $filename)