diff options
Diffstat (limited to 'App.php')
-rw-r--r-- | App.php | 27 |
1 files changed, 14 insertions, 13 deletions
@@ -79,10 +79,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; @@ -92,14 +93,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); @@ -114,7 +107,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 */ @@ -137,7 +138,7 @@ class App } $fh = fopen($file, "a+"); - fwrite($fh, $msg); + fwrite($fh, trim($msg) . "\n"); fclose($fh); } @@ -146,7 +147,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); } |