Permalink
Browse files

Initial Commit

  • Loading branch information...
0 parents commit 59f5b5cbd4f0435a5ca9ad27a587808afd1a2145 @Xeoncross Xeoncross committed Sep 26, 2010
Showing with 68 additions and 0 deletions.
  1. +19 −0 classes/controller/home.php
  2. 0 classes/model/.gitignore
  3. +10 −0 config.php
  4. +2 −0 index.php
  5. 0 log/.gitignore
  6. +7 −0 views/404.php
  7. +6 −0 views/error.php
  8. +21 −0 views/layout.php
  9. +3 −0 views/welcome.php
@@ -0,0 +1,19 @@
+<?php function_exists('p') OR die('Forbidden');
+Controller_Home
+{
+ public function index()
+ {
+ $this->content = new View('welcome');
+ }
+
+ /*
+ * Render the content inside the global
+ * theme layout on script end
+ */
+ public function __destruct()
+ {
+ $layout = new View('layout');
+ $layout->content = $this->content;
+ print $layout;
+ }
+}
No changes.
@@ -0,0 +1,10 @@
+<?php
+
+$config = array(
+ 'db.dsn' => 'mysql:host=localhost;port=3306;dbname=database',
+ 'db.user' => 'root',
+ 'db.pass' => ''
+);
+
+
+return $config;
@@ -0,0 +1,2 @@
+<?php
+function p($f){return __DIR__.str_replace('_','/',"/$f.php");}function url($k=-1){static$u;$u=$u?$u:array_slice(explode('/',$_SERVER['REQUEST_URI']),1);return$k!=-1?(isset($u[$k])?$u[$k]:0):$u;}function __autoload($c){require p("classes/$c");}function c($k){static$c;$c=$c?$c:require p('config');return$c[$k];}function _log($m){file_put_contents('log/.'.date('Y-m-d'),date('H:i')." $m\n",FILE_APPEND);}function db($dsn,$u,$p){static$d;return$d=$d?$d:(new PDO($dns,$u,$p));}function q($q,$p=NULL){$s=db()->prepare($q);$s->execute($p);return$s;}set_error_handler(function($c,$e,$f=0,$l=0){$v=new View('error');$v->error=$e;echo$v;_log("$e [$f:$l]");return TRUE;});class View{function View($v){$this->v=p("views/$v");}function __toString(){ob_start();extract((array)$this);require$v;return ob_get_clean();}}$c='controller_'.(($c=url(0))?$c:'home');$m=(($m=url(1))?$m:'index');if(!is_file(p("classes/$c"))||!($c=new$c)||!method_exists($c,$m))exit(new View('404'));call_user_func_array(array($c,$m,array_slice(url(),2)));//
No changes.
@@ -0,0 +1,7 @@
+<?php
+function_exists('p') OR die('Forbidden');
+headers_sent() OR header('HTTP/1.0 404 Page Not Found');
+?>
+<h1>404 Not Found</h1>
+<p>Sorry, we could not find the page you requested.</p>
+<code><?php print implode('/', url());?></code>
@@ -0,0 +1,6 @@
+<?php
+function_exists('p') OR die('Forbidden');
+headers_sent() OR header('HTTP/1.0 500 Internal Server Error');
+?>
+<h1>System Error</h1>
+<p><?php print $error; ?></p>
@@ -0,0 +1,21 @@
+<!DOCTYPE html><?php function_exists('p') OR die('Forbidden');?>
+<html>
+<head>
+ <meta charset="utf-8">
+ <title>1kb MVC Framework</title>
+ <style>
+ body { margin: 0; padding: 0; font: 12px Arial; }
+ #content { margin: 0 auto; width: 500px; }
+ </style>
+</head>
+<body>
+<div id="container">
+ <div id="header">
+ <h1>1kb MVC Framework</h1>
+ </div>
+ <div id="content">
+ <?php print $content; ?>
+ </div>
+</div>
+</body>
+</html>
@@ -0,0 +1,3 @@
+<?php function_exists('p') OR die('Forbidden');?>
+<h3>Welcome!</h3>
+<p>Thanks for trying out the 1kb MVC Framework!</p>

0 comments on commit 59f5b5c

Please sign in to comment.