$page['file'], 'uid' => $page['uid']), importxml(@file_get_contents($xmlfile), 'page')); } /* Action */ if ((isset($_POST["action"])) && ($_POST["action"] == "edit")) { /* Load XML associate file */ $attributes = importxml(@file_get_contents($xmlfile), 'page'); $xml_modified = false; /* Fields: - required: title - optional: author, date, description, email, keywords, subtitle */ /* Check title */ if ($_POST["titlename"] != $attributes["title"]) { $page["title"] = $attributes["title"] = $_POST["titlename"]; $xml_modified = true; } /* Check author */ if ($_POST["author"] != $attributes["author"]) { if (empty($_POST["author"])) unset($attributes["author"], $page["author"]); else $page["author"] = $attributes["author"] = $_POST["author"]; $xml_modified = true; } /* Check date */ if ($_POST["date"] != $attributes["date"]) { if (empty($_POST["date"])) unset($attributes["date"], $page["date"]); else $page["date"] = $attributes["date"] = $_POST["date"]; $xml_modified = true; } /* Check description */ if ($_POST["description"] != $attributes["description"]) { if (empty($_POST["description"])) unset($attributes["description"], $page["description"]); else $page["description"] = $attributes["description"] = $_POST["description"]; $xml_modified = true; } /* Check email */ if ($_POST["email"] != $attributes["email"]) { if (empty($_POST["email"])) unset($attributes["email"], $page["email"]); else $page["email"] = $attributes["email"] = $_POST["email"]; $xml_modified = true; } /* Check keywords */ if ($_POST["keywords"] != $attributes["keywords"]) { if (empty($_POST["keywords"])) unset($attributes["keywords"], $page["keywords"]); else $page["keywords"] = $attributes["keywords"] = $_POST["keywords"]; $xml_modified = true; } /* Check subtitle */ if ($_POST["subtitle"] != $attributes["subtitle"]) { if (empty($_POST["subtitle"])) unset($attributes["subtitle"], $page["subtitle"]); else $page["subtitle"] = $attributes["subtitle"] = $_POST["subtitle"]; $xml_modified = true; } /* Check access modification */ switch ($_POST["access"]) { case 0: if (isset($attributes["group"]) || isset($attributes["logged"])) { $xml_modified = true; unset($attributes["group"], $page["group"]); unset($attributes["logged"], $page["logged"]); } break; case -1: if (isset($attributes["group"]) || (!isset($attributes["logged"]))) { $xml_modified = true; unset($attributes["group"], $page["group"]); $page["logged"] = $attributes["logged"] = "logged"; } break; default: if (checkgroup($db, $attributes["group"]) != $_POST["access"]) { $xml_modified = true; unset($attributes["logged"], $page["logged"]); $page["group"] = $attributes["group"] = getgroupname($db, $_POST["access"]); } } /* Create directory if needed (no way to check it 'cause of safe_mode */ $dirname = dirname($filename); @mkdir($dirname, 0755, TRUE); /* Update XML associated file */ if ($xml_modified) if (!($fd = @fopen($xmlfile, "wb"))) $page["status"][] = "Erreur! Impossible de modifier le fichier XML '" . htmlprotect($xmlfilename) . "'."; else { fwrite($fd, exportxml($attributes, "page")); fclose($fd); $page["status"][] = "Fichier XML '" . htmlprotect($xmlfilename) . "' modifié."; } /* Write modified file */ if (!($fd = @fopen($filename, "wb"))) $page["status"][] = "Erreur! Impossible d'écrire la page '" . htmlprotect($page["file"]) . "'."; else { fwrite($fd, $_POST["source"]); fclose($fd); $page["status"][] = "Page '" . htmlprotect($page["file"]) . "' écrite."; } } /* Form */ elseif ((!isset($_GET["action"])) || ($_GET["action"] != "edit")) return; include('forms/edit.php');