示例#1
0
文件: news.php 项目: ygres/sblog
 function editPost()
 {
     $id = intval($_GET["contentID"]);
     if (!$id) {
         return false;
     }
     $doRedirect = false;
     $fill = $_POST;
     if (isset($_POST["slug"]) && $_POST["slug"]) {
         $fill["slug"] = core::generateSlug($_POST["slug"]);
     }
     if (isset($_POST["uploadPicture"])) {
         $uploadedPics = news::uploadOnePicture($fill["slug"]);
     }
     // $fill["poster"] = "";
     if (isset($_FILES["poster"]) && $_FILES["poster"]["error"] == 0) {
         $uploadedPics = news::uploadOnePicture($fill["slug"], "posterImages");
         if (isset($uploadedPics["poster"]) && $uploadedPics["poster"]) {
             $fill["poster"] = serialize($uploadedPics["poster"]);
         }
     }
     if (isset($_POST["savePost"])) {
         if (news::updatePost($id, $fill)) {
             $doRedirect = true;
         }
     }
     news::getAllCats($id);
     system::setParam("page", "editPost");
     $sqlData = news::buildForm("content", array("AND `contentID`={$id}"));
     news::showAttachedPics($sqlData);
     if ($doRedirect) {
         system::redirect("/adm/news/posts");
     }
 }