Description : History : - 5/5/9 inital version */ require_once('actions/opendb.php'); require_once('tools/misc.php'); require_once('tools/xml.php'); debugger (1, 'edit.php'); /* Check association */ if ($page["uid"] != 0) return; debugger (1, 'action'); if (((isset($_POST["action"])) && ($_POST["action"] == "edit")) || ((isset($_GET["action"])) && ($_GET["action"] == "edit") )) { /* Update filename */ $filename = realpath($repos)."/".$page['file']; $xmlfilename = substr($page['file'], 0, strrpos($page['file'], ".")).".xml"; $xmlfile = substr($filename, 0, strrpos($filename, ".")).".xml"; /* Reset page atributes */ $page = array_merge(array('file' => $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["admin"]) || isset($attributes["logged"])) { $xml_modified = true; unset($attributes["admin"], $page["admin"]); unset($attributes["logged"], $page["logged"]); } break; case 1: if (isset($attributes["admin"]) || (!isset($attributes["logged"]))) { $xml_modified = true; unset($attributes["admin"], $page["admin"]); $page["logged"] = $attributes["logged"] = "logged"; } break; case 2: if (!isset($attributes["admin"])) { $xml_modified = true; unset($attributes["logged"], $page["logged"]); $page["admin"] = $attributes["admin"] = "admin"; } } /* 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');