- W pliku index.php inlcuduję pliki klas db (bazy) i get_cfg (config strony)
- Tworzę nowy obiekt klasy get_cfg i wywołuję funkcję cfg
- W contruct klasy get_cfg tworzę obiekt klasy db
- W funkcji cfg pobieram z bazy zawartość komórki theme
- Includuję pliki z folderu template/pobrana_wartość/
Przeglądarka zwraca błąd, że pliki template//... (... -> odpowiedni plik) nie istnieje
index.php
<? $user = 'sys'; if($_SESSION['user']) $user = $_SESSION['user']; include 'class/db.class.php'; include 'class/get_cfg.class.php'; $cfg = new get_cfg; $temp = $cfg->cfg($user); include 'template/'.$temp.'/head.tpl'; include 'template/'.$temp.'/register.tpl'; include 'template/'.$temp.'/foot.tpl'; ?>
class/db.class.php
<? class db { private $query = ''; private $connect = ''; private $db_name = ''; private $go_query = ''; function __construct() { $this->connect = $this->connect(); } function __destruct() { $this->close(); } private function connect() { $this->db_name = $db['mysql']['name']; } public function query($query) { $this->query = $query; } public function go_query() { } public function assoc() { } public function row() { } } ?>
class/get_cfg.class.php
<? class get_cfg { private $db = ''; function __construct() { $this->db = new db; } public function cfg($user) { $query = $this->db->query("SELECT * FROM cfg WHERE user = '$user'"); $go = $this->db->go_query(); $assoc = $this->db->assoc(); $temp = $this->db->assoc['theme']; return $temp; } } ?>