function install($model) { $app = the::app(); include BASE . '/models/' . $model . "/install.php"; if (!is_array($upgrade)) { return false; } $maxver = count($upgrade); if (array_key_exists(2, $app->uri_segments)) { $version = $app->uri_segments[2]; } else { $version = $maxver; } if ($maxver > $version) { for ($i = $maxver; $i >= $version; $i--) { foreach ($downgrade[$i] as $query) { echo $query; echo '<br>'; mysql_query($query); } } } for ($i = $maxver; $i <= $version; $i++) { foreach ($upgrade[$i] as $query) { echo $query; echo '<br>'; mysql_query($query); } } echo $model . ' install ok <br/>'; }
/** * Advanced code * that is neat and i didnt want to delete it */ function cache() { $app = the::app(); $cache_life = $app->cache_life; $file = md5($app->uri_string); $created_at = false; // this uri never been visited before if (file_exists(BASE . '/../cache/' . $file)) { $created_at = filemtime(BASE . '/../cache/' . $file); } else { if ($app->output != "") { file_put_contents(BASE . '/../cache/' . $file, $app->output); } } if ($created_at) { if (time() - $created_at < $cache_life) { echo file_get_contents(BASE . '/../cache/' . $file); exit; } else { // expire cache unlink(BASE . '/../cache/' . $file); if ($app->output != "") { file_put_contents(BASE . '/../cache/' . $file, $app->output); } } } }
<?php include 'dynamic/controller.php'; $app = the::app(); $app->theme = 'welcome'; $app->default = 'index'; $app->connection('localhost', 'localhost', 'spaghetti', 'root', ''); $app->run();
function route($location) { $p = the::app(); header("Location: " . $p->link_uri . $location); }