1 | <?php |
---|
2 | /** |
---|
3 | * technikum29v6 - PHP Subsystem. |
---|
4 | * Haupteinstiegspunkt ("WebStart.php"), welches |
---|
5 | * ohne weiteren Funktionsaufruf alles macht. |
---|
6 | * |
---|
7 | **/ |
---|
8 | |
---|
9 | if(defined('T29')) return false; // no nesting |
---|
10 | define('T29', true); |
---|
11 | |
---|
12 | $lib = dirname(__FILE__); |
---|
13 | $webroot = realpath("$lib/../"); # file path to root of t29 web installation |
---|
14 | |
---|
15 | // early import host specific settings for making low level corrections like Bugfix #32 |
---|
16 | require "$lib/host.php"; |
---|
17 | $host = t29Host::detect(); |
---|
18 | |
---|
19 | $file = substr($_SERVER['SCRIPT_FILENAME'], strlen($_SERVER['DOCUMENT_ROOT'])); # e.g.: "/de/page.php" |
---|
20 | # Bug when DOCUMENT_ROOT ends with trailing slash: make sure $file begins with /: |
---|
21 | if($file{0} != '/') $file = "/$file"; |
---|
22 | |
---|
23 | // exactly define debugging behaviour |
---|
24 | if(isset($_GET['debug'])) { |
---|
25 | $_GET['purge_cache'] = true; |
---|
26 | $_GET['rl_debug'] = true; |
---|
27 | } |
---|
28 | |
---|
29 | // check for url rewriting neccessarity |
---|
30 | if($host->check_url_rewrite()) exit; |
---|
31 | |
---|
32 | $cache_dir = "$webroot/shared/cache"; |
---|
33 | $languages = array( |
---|
34 | // shorthand => array(full name in page, path from webroot) |
---|
35 | "de" => array("Deutsch", "/de"), |
---|
36 | "en" => array("English", "/en"), |
---|
37 | ); |
---|
38 | |
---|
39 | // make sure we have a page title |
---|
40 | if(isset($title)) $titel = $title; |
---|
41 | elseif(isset($titel)) $title = $titel; |
---|
42 | else $titel = $title = false; // to be determined by navigation seiten_id. |
---|
43 | |
---|
44 | // try to determine the language from the file path |
---|
45 | $lang = substr($file, 1, 2); |
---|
46 | if(!in_array($lang, array_keys($languages))) $lang = "de"; # check if language exists |
---|
47 | $lang_path = $languages[$lang][1]; # shorthand, relative to webroot. use "$webroot$lang_path" for local. |
---|
48 | |
---|
49 | require "$lib/cache.php"; |
---|
50 | |
---|
51 | $page_cache = new t29Cache(false, true); // debug, verbose |
---|
52 | $page_cache->set_cache_file($webroot, $file); |
---|
53 | $page_cache->test_files = array( |
---|
54 | __FILE__, |
---|
55 | $_SERVER['SCRIPT_FILENAME'], |
---|
56 | "$lib/template.php", |
---|
57 | "$lib/menu.php", |
---|
58 | "$lib/messages.php", |
---|
59 | "$lib/host.php", |
---|
60 | "$webroot$lang_path/navigation.xml", |
---|
61 | "$webroot$lang_path/news.php", |
---|
62 | ); |
---|
63 | |
---|
64 | // dynamical content: |
---|
65 | $static_page = !isset($dynamischer_inhalt); |
---|
66 | |
---|
67 | if(!$static_page) { |
---|
68 | // Pages with dynamical content: only cache header and footer, seperately. |
---|
69 | // they depend on same test files, so there is only one is_valid check. |
---|
70 | $header_cache = $page_cache; |
---|
71 | $footer_cache = clone $page_cache; |
---|
72 | |
---|
73 | $header_cache->set_cache_file($webroot, $file.'-header'); |
---|
74 | $footer_cache->set_cache_file($webroot, $file.'-footer'); |
---|
75 | } |
---|
76 | |
---|
77 | if($page_cache->shall_use()) { |
---|
78 | if($static_page) |
---|
79 | $page_cache->print_cache_and_exit(); |
---|
80 | else { |
---|
81 | $header_cache->print_cache(true); |
---|
82 | register_shutdown_function(function() use ($footer_cache) { |
---|
83 | $footer_cache->print_cache(true); |
---|
84 | }); |
---|
85 | // now print your dynamical stuff in your page, the |
---|
86 | // footer content will be automatically added afterwards. |
---|
87 | } |
---|
88 | } else { |
---|
89 | // cache missed, rebuild cache |
---|
90 | require "$lib/template.php"; |
---|
91 | $tmpl = new t29Template($GLOBALS); |
---|
92 | if($static_page) |
---|
93 | // rebuild complete site cache |
---|
94 | $tmpl->create_cache($page_cache); |
---|
95 | else |
---|
96 | // rebuild each header and footer cache |
---|
97 | $tmpl->create_separate_caches($header_cache, $footer_cache); |
---|
98 | } |
---|
99 | |
---|
100 | |
---|
101 | // end of technikum29.php |
---|