Exemplo n.º 1
0
 /** 发送表单验证
  * input_send function.
  *
  * @access public
  * @return void
  */
 function input_send()
 {
     if (!fn_token("chk")) {
         //令牌
         return array("alert" => "x030206");
     }
     $_arr_pmTitle = validateStr(fn_post("pm_title"), 0, 90);
     switch ($_arr_pmTitle["status"]) {
         case "too_long":
             return array("alert" => "x110202");
             break;
         case "ok":
             $this->pmSubmit["pm_title"] = $_arr_pmTitle["str"];
             break;
     }
     $_arr_pmContent = validateStr(fn_post("pm_content"), 1, 900);
     switch ($_arr_pmContent["status"]) {
         case "too_short":
             return array("alert" => "x110201");
             break;
         case "too_long":
             return array("alert" => "x110203");
             break;
         case "ok":
             $this->pmSubmit["pm_content"] = $_arr_pmContent["str"];
             break;
     }
     if (!$this->pmSubmit["pm_title"]) {
         $this->pmSubmit["pm_title"] = fn_substr_utf8($this->pmSubmit["pm_content"], 0, 30);
     }
     $_arr_pmTo = validateStr(fn_post("pm_to"), 1, 0);
     switch ($_arr_pmTo["status"]) {
         case "too_short":
             return array("alert" => "x110205");
             break;
         case "ok":
             $this->pmSubmit["pm_to"] = $_arr_pmTo["str"];
             break;
     }
     $this->pmSubmit["alert"] = "ok";
     return $this->pmSubmit;
 }
Exemplo n.º 2
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;
 }