From c217e77f2540085922b4483c99670eca06923799 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Mon, 26 Oct 2009 15:41:40 +0200 Subject: Bug fixes --- App.php | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) (limited to 'App.php') diff --git a/App.php b/App.php index e1428d4..c8b93cf 100644 --- a/App.php +++ b/App.php @@ -21,8 +21,6 @@ class App if (empty($param)) { $action = "index"; } - -// $conf['basedir'] = dirname(dirname(__FILE__) . "/system"); if (!$controller) { $controller = "user"; @@ -81,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; @@ -94,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 +105,15 @@ class App self::json($msg); 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 */ @@ -123,19 +122,21 @@ class App if (is_array($msg)) { $msg = print_r($msg, true); } + $c = self::conf("app.error_log"); $file = realpath(__FILE__."/../../../../data/$c"); if (!$file) { return false; } + $fh = fopen($file, "a+"); - fwrite($fh, $msg); + fwrite($fh, trim($msg) . "\n"); fclose($fh); } 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); } -- cgit v1.2.3