- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
// File: /controllers/register.php
//......
$sql = 'INSERT INTO `users` SET `ID`=NULL, `login`="'.mysql_real_escape_string(substr($_POST['login'], 0, 12)).'", `pass`= blah blah blah....';
//......
// File: /templates/default/index.tpl
/*
//...
<td><div>Hello, <b>{LOGIN}</b></div><!---- blah blah blah ---><div>Server time: <?php echo getCurrentTime();?></div>
//
*/
//File: /index.php
//......
$sql = 'SELECT * FROM `users` WHERE `id`=........';
$data = SYS::$db->getDataRow($sql);
if(sizeof($data)>0) {
showTeplate(TEMPLATE_NAME, 'index', $data);
}
//......
//Function showTeplate();
function showTeplate($tpl_name, $file_name, $data) {
$template_code = file_get_contents(TPL_PATH.'/'.$tpl_name.'/'.$file_name.'.'.TPL_EXT);
foreach($data as $name=>$value) {
$template_code = str_replace('{'.strtoupper($name).'}', $value, $template_code);
}
//......
eval($template_code);
//......
}