[561cde]: web / htdocs / app / bootstrap.php Maximize Restore History

Download this file

bootstrap.php    66 lines (55 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<?php
//set config from ini
$config=parse_ini_file('../config.ini',1);
//extract config settings
extract($config['settings']);
//setup
date_default_timezone_set($timezone);
//database
require 'db.php';
$db=new db($dbfile);
if (filesize($dbfile)==0) { $db->setup('data/db.sql'); }
//route
require 'route.php';
$route=new route('home');
$basepath=$route->basepath;
$path=$route->path;
//do we need to redirect?
$newpath=$route->checkpath($path);
if ($path != $newpath) { $route->redirect($basepath.$newpath); }
//backwards compat
if ($path == 'frontpage') { $route->redirect($basepath); }
if (isset($_GET['page'])) { $route->redirect($basepath.htmlspecialchars($_GET['page'])); }
//set title
$pagetitle=isset($config['title'][$path])?$config['title'][$path]:ucwords(str_replace('-',' ',$path));
//view
require 'view.php';
$view=new view();
$view->viewpath=DIR_APP.DIRSEP;
/*data*/
//define empty data array
$data=array();
//settings
$view->data+=$config['data'];
//add the logic data
$file=DIR_APP.DIRSEP.$path;
if (file_exists($file.'.php')) { include $file.'.php'; }
$data['config']=&$config;
$data['db']=&$db;
$data['path']=$path;
$data['content']='';
//add data to view
$view->data+=$data;
unset($data);
//no contents?
$content=$view->getcontents($path);
if (!$content) {
$path='notfound';
$pagetitle=isset($config['title'][$path])?$config['title'][$path]:ucwords(str_replace('-',' ',$path));
$content=$view->getcontents($path);
}
$pagetitle=$sitename.' :: '.$pagetitle;
$view->set('pagetitle',$pagetitle);
//include the layout
include 'layout.html.php';
//eof