Example #1
0
 function ctl_article()
 {
     $_num_articleId = fn_getSafe(fn_get("article_id"), "int", 0);
     if ($_num_articleId == 0) {
         return array("alert" => "x120212");
         exit;
     }
     $_arr_articleRow = $this->mdl_article->mdl_read($_num_articleId);
     //读取文章
     if ($_arr_articleRow["alert"] != "y120102") {
         return $_arr_articleRow;
         exit;
     }
     if (!isset($this->adminLogged["groupRow"]["group_allow"]["article"]["edit"]) && !isset($this->adminLogged["admin_allow_cate"][$_arr_articleRow["article_cate_id"]]["edit"]) && $_arr_articleRow["article_admin_id"] != $this->adminLogged["admin_id"] || !isset($this->adminLogged["groupRow"]["group_allow"]["attach"]["browse"])) {
         //判断权限
         return array("alert" => "x120303");
         exit;
     }
     $_arr_cateRow = $this->mdl_cate->mdl_read($_arr_articleRow["article_cate_id"]);
     $_arr_markRow = $this->mdl_mark->mdl_read($_arr_articleRow["article_mark_id"]);
     $_arr_attachIds = fn_getAttach($_arr_articleRow["article_content"]);
     $_arr_attachRows = array();
     $_arr_page = fn_page(0);
     if ($_arr_attachIds) {
         $_num_attachCount = $this->mdl_attach->mdl_count("", "", "", "", 0, "normal", $_arr_attachIds);
         $_arr_page = fn_page($_num_attachCount);
         $_arr_attachRows = $this->mdl_attach->mdl_list(BG_DEFAULT_PERPAGE, $_arr_page["except"], "", "", "", "", 0, "normal", $_arr_attachIds);
         foreach ($_arr_attachRows as $_key => $_value) {
             if ($_value["attach_type"] == "image") {
                 $_arr_attachRows[$_key]["attach_thumb"] = $this->mdl_attach->thumb_process($_value["attach_id"], $_value["attach_time"], $_value["attach_ext"]);
             }
             $_arr_attachRows[$_key]["adminRow"] = $this->mdl_admin->mdl_read($_value["attach_admin_id"]);
         }
     }
     $_arr_tpl = array("attach_ids" => implode("|", $_arr_attachIds), "pageRow" => $_arr_page, "markRow" => $_arr_markRow, "cateRow" => $_arr_cateRow, "attachRows" => $_arr_attachRows, "articleRow" => $_arr_articleRow);
     $_arr_tplData = array_merge($this->tplData, $_arr_tpl);
     $this->obj_tpl->tplDisplay("attach_article.tpl", $_arr_tplData);
     return array("alert" => "y120102");
 }
Example #2
0
 function ajax_article()
 {
     if ($this->adminLogged["alert"] != "y020102") {
         //未登录,抛出错误信息
         $this->obj_ajax->halt_alert($this->adminLogged["alert"]);
     }
     if (!isset($this->adminLogged["groupRow"]["group_allow"]["attach"]["browse"])) {
         $this->obj_ajax->halt_alert("x070301");
     }
     $_num_articleId = fn_getSafe(fn_get("article_id"), "int", 0);
     if ($_num_articleId == 0) {
         $this->obj_ajax->halt_alert("x120212");
     }
     $_arr_articleRow = $this->mdl_article->mdl_read($_num_articleId);
     //读取文章
     if ($_arr_articleRow["alert"] != "y120102") {
         $this->obj_ajax->halt_alert($_arr_articleRow["alert"]);
     }
     $_num_perPage = 8;
     $_arr_attachIds = fn_getAttach($_arr_articleRow["article_content"]);
     $_arr_attachRows = array();
     if ($_arr_attachIds) {
         $_num_attachCount = $this->mdl_attach->mdl_count("", "", "", "", 0, "normal", $_arr_attachIds);
         $_arr_page = fn_page($_num_attachCount, $_num_perPage);
         $_arr_attachRows = $this->mdl_attach->mdl_list($_num_perPage, $_arr_page["except"], "", "", "", "", 0, "normal", $_arr_attachIds);
         foreach ($_arr_attachRows as $_key => $_value) {
             if ($_value["attach_type"] == "image") {
                 $_arr_attachRows[$_key]["attach_thumb"] = $this->mdl_attach->thumb_process($_value["attach_id"], $_value["attach_time"], $_value["attach_ext"]);
             }
             $_arr_attachRows[$_key]["adminRow"] = $this->mdl_admin->mdl_read($_value["attach_admin_id"]);
         }
     }
     //print_r($_arr_page);
     $_arr_tpl = array("pageRow" => $_arr_page, "attachRows" => $_arr_attachRows);
     exit(json_encode($_arr_tpl));
 }
Example #3
0
 function input_submit()
 {
     if (!fn_token("chk")) {
         //令牌
         return array("alert" => "x030102");
         exit;
     }
     $this->articleSubmit["article_id"] = fn_getSafe(fn_post("article_id"), "int", 0);
     if ($this->articleSubmit["article_id"] > 0) {
         $_arr_articleRow = $this->mdl_read($this->articleSubmit["article_id"]);
         if ($_arr_articleRow["alert"] != "y120102") {
             return $_arr_articleRow;
             exit;
         }
     }
     $_arr_articleTitle = validateStr(fn_post("article_title"), 1, 300);
     switch ($_arr_articleTitle["status"]) {
         case "too_short":
             return array("alert" => "x120201");
             exit;
             break;
         case "too_long":
             return array("alert" => "x120202");
             exit;
             break;
         case "ok":
             $this->articleSubmit["article_title"] = $_arr_articleTitle["str"];
             break;
     }
     $_arr_articleLink = validateStr(fn_post("article_link"), 0, 900, "str", "url");
     switch ($_arr_articleLink["status"]) {
         case "too_long":
             return array("alert" => "x120204");
             exit;
             break;
         case "format_err":
             return array("alert" => "x120204");
             exit;
             break;
         case "ok":
             $this->articleSubmit["article_link"] = $_arr_articleLink["str"];
             break;
     }
     $_arr_articleStatus = validateStr(fn_post("article_status"), 1, 0);
     switch ($_arr_articleStatus["status"]) {
         case "too_short":
             return array("alert" => "x120208");
             exit;
             break;
         case "ok":
             $this->articleSubmit["article_status"] = $_arr_articleStatus["str"];
             break;
     }
     $_arr_articleBox = validateStr(fn_post("article_box"), 1, 0);
     switch ($_arr_articleBox["status"]) {
         case "too_short":
             return array("alert" => "x120209");
             exit;
             break;
         case "ok":
             $this->articleSubmit["article_box"] = $_arr_articleBox["str"];
             break;
     }
     $_arr_articleTimePub = validateStr(fn_post("article_time_pub"), 1, 0, "str", "datetime");
     switch ($_arr_articleTimePub["status"]) {
         case "too_short":
             return array("alert" => "x120210");
             exit;
             break;
         case "format_err":
             return array("alert" => "x120211");
             exit;
             break;
         case "ok":
             $this->articleSubmit["article_time_pub"] = strtotime($_arr_articleTimePub["str"]);
             break;
     }
     $_arr_articleCateId = validateStr(fn_post("article_cate_id"), 1, 0);
     switch ($_arr_articleCateId["status"]) {
         case "too_short":
             return array("alert" => "x120207");
             exit;
             break;
         case "ok":
             $this->articleSubmit["article_cate_id"] = $_arr_articleCateId["str"];
             break;
     }
     $_is_ids = fn_getSafe(fn_post("cate_ids_checkbox"), "int", 0);
     $this->articleSubmit["cate_ids"] = array();
     if ($_is_ids == 1) {
         $_arr_cateIds = fn_post("cate_ids");
         if (isset($_arr_cateIds) && is_array($_arr_cateIds)) {
             foreach ($_arr_cateIds as $_key => $_value) {
                 $this->articleSubmit["cate_ids"][] = fn_getSafe($_value, "int", 0);
             }
         }
     }
     $this->articleSubmit["cate_ids"][] = $this->articleSubmit["article_cate_id"];
     $this->articleSubmit["cate_ids"] = array_unique($this->articleSubmit["cate_ids"]);
     $this->articleSubmit["article_content"] = fn_post("article_content");
     $_arr_attachIds = fn_getAttach($this->articleSubmit["article_content"]);
     if ($_arr_attachIds) {
         $this->articleSubmit["article_attach_id"] = $_arr_attachIds[0];
     } else {
         $this->articleSubmit["article_attach_id"] = 0;
     }
     $_str_excerptType = fn_getSafe(fn_post("article_excerpt_type"), "txt", "auto");
     switch ($_str_excerptType) {
         case "auto":
             $this->articleSubmit["article_excerpt"] = fn_substr_utf8($this->articleSubmit["article_content"], 0, BG_SITE_EXCERPT);
             break;
         case "txt":
             $_str_articleExcerpt = strip_tags($this->articleSubmit["article_content"]);
             $this->articleSubmit["article_excerpt"] = fn_substr_utf8($_str_articleExcerpt, 0, BG_SITE_EXCERPT);
             break;
         case "none":
             $this->articleSubmit["article_excerpt"] = "";
             break;
         case "manual":
             $_arr_articleExcerpt = validateStr(fn_post("article_excerpt"), 0, 900);
             switch ($_arr_articleExcerpt["status"]) {
                 case "too_long":
                     return array("alert" => "x120205");
                     exit;
                     break;
                 case "ok":
                     $this->articleSubmit["article_excerpt"] = $_arr_articleExcerpt["str"];
                     break;
             }
             break;
     }
     if (!$this->is_magic) {
         $this->articleSubmit["article_content"] = addslashes($this->articleSubmit["article_content"]);
     }
     $this->articleSubmit["article_mark_id"] = fn_getSafe(fn_post("article_mark_id"), "int", 0);
     $this->articleSubmit["article_spec_id"] = fn_getSafe(fn_post("article_spec_id"), "int", 0);
     $_str_articleTags = fn_getSafe(fn_post("hidden-article_tag"), "txt", "");
     $_arr_articleTags = explode(",", $_str_articleTags);
     $this->articleSubmit["article_tags"] = array();
     foreach ($_arr_articleTags as $_key => $_value) {
         $this->articleSubmit["article_tags"][$_key] = fn_getSafe($_value, "txt", "");
     }
     $_arr_articleCustoms = fn_post("article_customs");
     $this->articleSubmit["article_customs"] = array();
     if ($_arr_articleCustoms) {
         foreach ($_arr_articleCustoms as $_key => $_value) {
             $this->articleSubmit["article_customs"][$_key] = fn_getSafe($_value, "txt", "");
         }
     }
     //print_r($_arr_articleCustoms);
     $this->articleSubmit["alert"] = "ok";
     return $this->articleSubmit;
 }