FUNCTION template(){
IF(!EMPTY($_COOKIES['uatest_template'])){
$ADDRESS = template_set($_COOKIES['uatest_template']);
IF($ADDRESS==FALSE){
$ADDRESS = template_set('default');
IF($ADDRESS==FALSE){
exit('Template error: template not found.');
} else {
RETURN $ADDRESS;
}
}
} else {
$ADDRESS = template_set('default');
IF($ADDRESS==FALSE){
exit('Template error: template not found.');
} else {
RETURN $ADDRESS;
}
}
}
FUNCTION template_set($directory){
IF($directory=='default'){
IF(is_file($_SERVER['DOCUMENT_ROOT'].'/data/template/default/template.php')){
RETURN ($_SERVER['DOCUMENT_ROOT'].'/data/template/default/template.php');
} else{
RETURN FALSE;
}
} else {
$SQLtemplate = mysql_query("SELECT * FROM `template` WHERE `template_directory` = '".mysql_real_escape_string($directory)."' LIMIT 1");
$TSTtemplate = mysql_fetch_array($SQLtemplate);
IF($TSTtemplate==TRUE){
setcookie("uatest_template", $TSTtemplate['template_directory'], time()+3600, "/");
RETURN ($_SERVER['DOCUMENT_ROOT'].'/data/template/'.$TSTtemplate['template_directory'].'/template.php');
} else {
RETURN FALSE;
}
}
}
а потом
include(template());
echo $TEMPLATE;
_____________
Одесса - мой город!)))