function base_url() { static $base; if (empty($base)) { $base = protocol() . $_SERVER['HTTP_HOST'] . base_uri(); } return $base; }
function route($uri) { $uri = clean_uri($uri); //print_r($uri); //exit; if ($uri == base_uri()) { ////echo "HOME!!!"; require_once 'home.php'; return null; } //pp('URI: ' . $uri); //pp('base_uri: ' . base_uri()); $path = substr($uri, strlen(base_uri())); /////pp('path: ' . $path); //pp('dirname: ' . dirname(__FILE__)); $path = ltrim($path, '/'); $tests = array(); array_push($tests, sprintf('%s/%s/index.php', dirname(__FILE__), $path)); array_push($tests, sprintf('%s/page-%s.php', dirname(__FILE__), $path)); array_push($tests, sprintf('%s/%s.php', dirname(__FILE__), $path)); /** $tests[] = dirname(__FILE__) . $path . '/index.php'; $tests[] = dirname(__FILE__) . $path . '.php'; $tests[] = dirname(__FILE__) . $path . '.php'; ***/ foreach ($tests as $test) { //print_r($test); ///print "<br/>"; if (file_exists($test)) { ///pp('it exists!!!'); include_once $test; return null; ///break; } } require_once '404.php'; }
public function base() { return base_uri($this->get_attribute(0)); }
<?php echo body_tag('id="page-top"'); ?> <section class="container"> <div class="row" style="margin-top: 40px;"> <div class="col-sm-12"> <div class="clearfix"> The touch icon should be seen here: <br /> <img src="<?php echo base_uri('apple-touch-icon-precomposed.png'); ?> " class="thumbnail" /> </div> <div class="page-header"> <h1>Dealing with Legacy Pages Example</h1> </div> <p> This is a sample of an "old legacy page" that is not rewritten in (H)MVC style yet. Sometimes this costs a lot of time. In this case access to the configuration, helper functions, etc. might be useful. This is why the core of the framework initializes at the beginning of the page (using a dummy controller) and destroys itself at the end of the page. Between these two actions you can read framework's configurations options, using asset helper functions, access database and so forth. Please, have a look at PHP source code of this page.