aboutsummaryrefslogtreecommitdiffstats
path: root/App.php
diff options
context:
space:
mode:
authorFilipp Lepalaan <filipp@mekanisti.fi>2009-10-26 15:41:40 +0200
committerFilipp Lepalaan <filipp@mekanisti.fi>2009-10-26 15:41:40 +0200
commitc217e77f2540085922b4483c99670eca06923799 (patch)
tree0476b8eb54b666e28905978b8cb3b00a73bd18b0 /App.php
parent1038b52baf3e67c024527eb27f7493d9cbcae438 (diff)
downloadmain-c217e77f2540085922b4483c99670eca06923799.tar.gz
main-c217e77f2540085922b4483c99670eca06923799.tar.bz2
main-c217e77f2540085922b4483c99670eca06923799.zip
Bug fixes
Diffstat (limited to 'App.php')
-rw-r--r--App.php31
1 files changed, 16 insertions, 15 deletions
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);
}