'', "default" => 0, "layout" => '', "css" => array(), "htmlhead" => '',
"jsonload" => '', "headertext" => '', "maintext" => '', "footertext" => '',
"lefttext" => '', "righttext" => '', "errortext" => '', 'feloginurl' => '' );
if(!isset($_GET["s"])) {
// check if template should be edited
?>
0 then get template info from database
$sql = "UPDATE ".DB_PREPEND."phpwcms_template SET ".
"template_name='".aporeplace($template["name"])."', ".
"template_default=".$template["default"].", ".
"template_var='".aporeplace(serialize($template))."' ".
"WHERE template_id=".$template["id"];
} else {
// if ID = 0 then show create new template form
$sql = "INSERT INTO ".DB_PREPEND."phpwcms_template (".
"template_name, template_default, template_var) VALUES ('".
aporeplace($template["name"])."', ".$template["default"].", '".
aporeplace(serialize($template))."')";
}
// update or insert data entry
@mysql_query($sql, $db) or die("error while updating or inserting template datas");
if(empty($template["id"]) || $createcopy == 1) {
$template["id"] = mysql_insert_id($db);
}
//now proof for default template definition
if($template["default"]) {
mysql_query("UPDATE ".DB_PREPEND."phpwcms_template SET template_default=0 ".
"WHERE template_id != ".$template["id"], $db);
}
update_cache();
headerRedirect(PHPWCMS_URL."phpwcms.php?do=admin&p=11&s=".$template["id"]);
}
if($template["id"]) {
// read the given template datas from db
$sql = "SELECT * FROM ".DB_PREPEND."phpwcms_template WHERE template_id=".$template["id"]." LIMIT 1";
if($result = mysql_query($sql, $db)) {
if($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
unset($template);
$template = unserialize($row["template_var"]);
$template["id"] = $row["template_id"];
$template["default"] = $row["template_default"];
// compatibility for older releases where only
// 1 css file could be stored per template
if(is_string($template['css'])) {
$template['css'] = array($template['css']);
}
}
mysql_free_result($result);
}
}
// show form
?>