comparison index.php @ 1:d91abe5f6214

Support for evaluated configuration files.
author Tom Fredrik "BFG" Klaussen <bfg@blenning.no>
date Tue, 10 May 2011 14:45:45 +0200
parents d2da64705bce
children 238c5127b78c
comparison
equal deleted inserted replaced
0:d2da64705bce 1:d91abe5f6214
41 break; 41 break;
42 } 42 }
43 } 43 }
44 } 44 }
45 45
46 $body=loadFile("${lang}/${name}.html"); 46 $title="Dummy title";
47 if(floatval($body)<0) { 47 $header="header.html";
48 $footer="footer.html";
49 $body="body.html";
50
51 $config=loadFile("${lang}/${name}.cfg");
52
53 eval($config);
54 $body_content=loadFile("${lang}/${body}");
55 if(floatval($body_content)<0) {
48 header('HTTP/1.0 404 Not Found'); 56 header('HTTP/1.0 404 Not Found');
49 $body='<div id="page"><h1>Resource not found</h1></div>'; 57 $body_content='<div id="page"><h1>Resource not found</h1></div>';
50 } 58 }
51 if (!file_exists($lang)) { 59 if (!file_exists($lang)) {
52 $lang=no; 60 $lang=no;
53 header('HTTP/1.0 404 Not Found'); 61 header('HTTP/1.0 404 Not Found');
54 $body='<div id="page"><h1>Language is not available</h1></div>'; 62 $body_content='<div id="page"><h1>Language is not available</h1></div>';
55 } 63 }
56 64
57 print '<?xml version="1.0" encoding="UTF-8"?>'; 65 print '<?xml version="1.0" encoding="UTF-8"?>';
58 ?> 66 ?>
59 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" 67 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
60 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> 68 "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
61 <html xmlns="http://www.w3.org/1999/xhtml"> 69 <html xmlns="http://www.w3.org/1999/xhtml">
62 <head> 70 <head>
63 <title>BFG Consult</title> 71 <title>
64 <link type="text/css" href="/css/reset.css" rel="stylesheet" media="screen" /> 72 <?php
65 <link type="text/css" href="/css/bfggroup.css" rel="stylesheet" media="screen" /> 73 print "$title";
74 ?>
75 </title>
76 <?php
77 print "$css";
78 ?>
66 </head> 79 </head>
67 <body> 80 <body>
68 <div id="container"> 81 <div id="container">
69 82
70 <?php 83 <?php
71 $header=loadFile("${lang}/header.html"); 84 $header_content=loadFile("${lang}/${header}");
72 $footer=loadFile("${lang}/footer.html"); 85 $footer_content=loadFile("${lang}/${footer}");
73 86
74 $pattern = "/<li id=\"${name}\"\s?([^>]*)>/is"; 87 $pattern = "/<li id=\"${name}\"\s?([^>]*)>/is";
75 $replacement = "<li id=\"${name}\" class=\"active\" $1>"; 88 $replacement = "<li id=\"${name}\" class=\"active\" $1>";
76 $header= preg_replace($pattern, $replacement, $header); 89 $header_content= preg_replace($pattern, $replacement, $header_content);
77 90
78 $pattern = '/<li id="([^"]+)"\s?([^>]*)>(.*?)<\/li>/is'; 91 $pattern = '/<li id="([^"]+)"\s?([^>]*)>(.*?)<\/li>/is';
79 $replacement = "<li id=\"\$1\" \$2><a href=\"?name=$1&lang=${lang}\">\$3</a></li>"; 92 $replacement = "<li id=\"\$1\" \$2><a href=\"?name=$1&lang=${lang}\">\$3</a></li>";
80 $header=preg_replace($pattern, $replacement, $header); 93 $header_content=preg_replace($pattern, $replacement, $header_content);
81 94
82 print $header; 95 print $header_content;
83 print $body; 96 print $body_content;
84 print $footer; 97 print $footer_content;
85 98
86 99
87 ?> 100 ?>
88 101
89 </div> 102 </div>