diff options
Diffstat (limited to 'App.php')
-rw-r--r-- | App.php | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -81,10 +81,11 @@ class App static function type() { - $last = array_pop(explode("/", @$_GET['url'])); + $tokens = explode("/", $_SERVER['REQUEST_URI']); + $last = array_pop($tokens); $type = ltrim(strrchr($last, "."), "."); - $contentTypes = array('html', 'rss', 'xml', 'tpl', 'pdf', 'jpg'); + $contentTypes = array("html", "rss", "xml", "tpl", "pdf", "jpg"); if (in_array($type, $contentTypes)) { return $type; @@ -94,14 +95,6 @@ class App } - static function json($msg) - { - $json = json_encode($msg); - header("Content-Type: application/json"); - header("Content-Length: " . strlen($json)); - print $json; - } - static function ok($msg) { $ok = array('result' => 'ok', 'msg' => $msg); @@ -116,7 +109,15 @@ class App // And log it locally self::log($msg); } - + + static function json($msg) + { + $json = json_encode($msg); + header("Content-Type: application/json"); + header("Content-Length: " . strlen($json)); + print $json; + } + /** * Log an error to our own logging system */ @@ -140,7 +141,7 @@ class App $msg = trim($msg); $fh = fopen($file, "a+"); - fwrite($fh, "$msg\n"); + fwrite($fh, trim($msg) . "\n"); fclose($fh); } @@ -150,7 +151,7 @@ class App */ static function error_handler($errno, $errstr, $errfile, $errline) { - $str = sprintf("%s\t%s\t%s\t%s\n", date("d.m @ H:i:s"), basename($errfile), $errline, $errstr); + $str = sprintf("%s\t%s\t%s\t%s\n", date("d.m H:i:s"), basename($errfile), $errline, $errstr); self::log($str); } |