aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--App.php27
-rw-r--r--Controller.php9
-rw-r--r--Db.php2
3 files changed, 22 insertions, 16 deletions
diff --git a/App.php b/App.php
index 42f8b4c..70b1554 100644
--- a/App.php
+++ b/App.php
@@ -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);
}
diff --git a/Controller.php b/Controller.php
index 432ae93..22dccc6 100644
--- a/Controller.php
+++ b/Controller.php
@@ -35,6 +35,11 @@ class Controller
return $this->find(array('id' => $id));
}
+ public function db()
+ {
+ return Db::getInstance();
+ }
+
/**
* The New Find
*/
@@ -107,7 +112,7 @@ class Controller
$sql .= " LIMIT $limit";
}
- $result = DB::fetch($sql, $values);
+ $result = Db::fetch($sql, $values);
for ($i=0; $i < count($result); $i++)
{
@@ -283,7 +288,7 @@ class Controller
$sql = "UPDATE `{$this->table}` SET $query WHERE `$col` = :$col";
- return DB::query($sql, $values);
+ return Db::query($sql, $values);
}
diff --git a/Db.php b/Db.php
index 730fcdf..f961614 100644
--- a/Db.php
+++ b/Db.php
@@ -47,7 +47,7 @@ class Db
*/
public function __clone()
{
- trigger_error("Hello, ich name was Singleton. Cloning is not allowed", E_USER_ERROR);
+ trigger_error("Cloning not work is", E_USER_ERROR);
}
/**