Plugin Directory

Changeset 2969579


Ignore:
Timestamp:
09/21/2023 08:41:47 AM (2 years ago)
Author:
zhengdon
Message:

code refactoring

Location:
keydatas/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • keydatas/trunk/keydatas.php

    r2968537 r2969579  
    44Plugin URI: http://www.keydatas.com/caiji/wordpress-cms-caiji
    55Description: 简数采集器(keydatas.com)是一个通用、简单、智能、在线的网页数据采集器,功能强大,操作简单。支持按关键词采集;集成翻译等服务;图片下载支持存储到阿里云OSS、七牛对象存储、腾讯云对象存储等。
    6 Version: 2.5.1
     6Version: 2.5.2
    77Author: keydatas
    88Author URI: http://www.keydatas.com
     
    2424    $randIP = "".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255).".".mt_rand(0,255);
    2525    return $randIP;
     26}
     27
     28function  keydatas_getPostValSafe($paraName = ""){
     29  $postVal="";
     30    if(isset($_POST[$paraName])){
     31        $postVal=sanitize_text_field($_POST[$paraName]);
     32    }
     33    return $postVal;
    2634}
    2735/**
     
    6270        //$_REQ = keydatas_mergeRequest();
    6371        $kds_password = get_option('keydatas_password', "keydatas.com");
    64         $post_password = sanitize_text_field($_POST['kds_password']);
     72        $post_password = keydatas_getPostValSafe('kds_password');
    6573        if (empty($post_password) || $post_password != $kds_password) {
    6674            keydatas_failRsp(1403, "password error", "提交的发布密码错误");
     
    7078        if ($kds_flag == "post") {
    7179       
    72             $title = sanitize_text_field($_POST["post_title"]);
     80            $title = keydatas_getPostValSafe("post_title");
    7381            if (empty($title)) {
    7482                keydatas_failRsp(1404, "title is empty", "标题不能为空");
    7583            }       
    7684           
    77             $content =wp_kses_post($_POST["post_content"]);
     85            $content='';
     86            if(isset($_POST["post_content"])){
     87                $content =wp_kses_post($_POST["post_content"]);
     88            }
    7889            if (empty($content)) {
    7990                $content='';
     
    8192           
    8293            //文章摘要
    83             $excerpt = sanitize_textarea_field($_POST["post_excerpt"]);
     94            $excerpt = keydatas_getPostValSafe("post_excerpt");
    8495            if (empty($excerpt)) {
    8596                $excerpt='';
    8697            }
    8798            //文章类型
    88             $postType = sanitize_text_field($_POST["post_type"]);
     99            $postType = keydatas_getPostValSafe("post_type");
    89100            if (empty($postType)) {
    90101                $postType = 'post';
     
    96107            }
    97108            */
    98             $postStatus = sanitize_text_field($_POST["post_status"]);
     109            $postStatus = keydatas_getPostValSafe("post_status");
    99110            if (empty($postStatus) || !in_array($postStatus, array('publish', 'draft'))) {
    100111                $postStatus = 'publish';
     
    102113           
    103114            //
    104             $commentStatus = sanitize_text_field($_POST["comment_status"]);
     115            $commentStatus = keydatas_getPostValSafe("comment_status");
    105116            if (empty($commentStatus) || !in_array($commentStatus, array('open', 'closed'))) {
    106117                $commentStatus = 'open';
    107118            }
    108119            //文章密码,文章编辑才可为文章设定一个密码,凭这个密码才能对文章进行重新强加或修改
    109             $postPassword = sanitize_text_field($_POST["post_password"]);
     120            $postPassword = keydatas_getPostValSafe("post_password");
    110121            //if (isset($_POST["post_password"]) && $_POST["post_password"]) {
    111122            if(empty($postPassword)){
     
    132143            }
    133144            //文章别名
    134             $postName = sanitize_text_field($_POST["post_name"]);   
     145            $postName = keydatas_getPostValSafe("post_name");   
    135146            if (!empty($postName)) {
    136147                $my_post['post_name'] = $postName;
     
    138149   
    139150            ///////////////目前主要用于lightsns
    140             $post_parent  = sanitize_text_field($_POST["__kdsExt_post_parent"]);//default 0
     151            $post_parent  = keydatas_getPostValSafe("__kdsExt_post_parent");//default 0
    141152            if(!empty($post_parent)){
    142153                try{
     
    162173                }
    163174            }
    164             $post_date=sanitize_text_field($_POST["post_date"]);
     175            $post_date=keydatas_getPostValSafe("post_date");
    165176            if (!empty($post_date)) {
    166177                $post_date = intval($post_date);
     
    170181            }
    171182
    172             $author = sanitize_text_field($_POST["post_author"]);
     183            $author = keydatas_getPostValSafe("post_author");
    173184            if (!empty($author)) {
    174185                //$author = htmlspecialchars_decode($author);
     
    206217            }//.. post_author end
    207218            //分类目录
    208             $category = sanitize_text_field($_POST["post_category"]);
     219            $category = keydatas_getPostValSafe("post_category");
    209220            if (!empty($category)) {
    210221                $cates = explode(',',$category);
     
    240251            }
    241252
    242             $post_tag = sanitize_text_field($_POST["post_tag"]);
     253            $post_tag = keydatas_getPostValSafe("post_tag");
    243254            if (!empty($post_tag)) {
    244255                $tags = explode(',',$post_tag);
     
    269280            }
    270281            //缩略图处理
    271             $image_url =sanitize_text_field($_POST["__kds_feature_url"]);
     282            $image_url =keydatas_getPostValSafe("__kds_feature_url");
    272283            if (empty($image_url)) {
    273                 $image_url = sanitize_text_field($_POST["post_thumbnail"]);
     284                $image_url = keydatas_getPostValSafe("post_thumbnail");
    274285            }
    275286            if (!empty($post_id) && !empty($image_url)) {
     
    316327            $keydatas_tbk_link_enble = get_option('keydatas_tbk_link_enble', false);
    317328            if($keydatas_tbk_link_enble){
    318                 $tbk_link = sanitize_text_field($_POST["tbk_link"]);
     329                $tbk_link = keydatas_getPostValSafe("tbk_link");
    319330                if (!empty($tbk_link)) {
    320331                    add_post_meta($post_id, 'tbk_link', $tbk_link, true);
     
    339350            //获取分类目录
    340351            $ret = array();
    341             $postType = sanitize_text_field($_POST["type"]);
     352            $postType = keydatas_getPostValSafe("type");
    342353            if (!empty($postType) && $postType === "cate") {
    343354                $cates = get_terms('category', 'orderby=count&hide_empty=0');
     
    363374function  keydatas_downloadImages(){
    364375 try{
    365     $downloadFlag = sanitize_text_field($_POST["__kds_download_imgs_flag"]);
     376    $downloadFlag = keydatas_getPostValSafe("__kds_download_imgs_flag");
    366377    if (!empty($downloadFlag) && $downloadFlag== "true") {
    367         $docImgsStr = sanitize_text_field($_POST["__kds_docImgs"]);
     378        $docImgsStr = keydatas_getPostValSafe("__kds_docImgs");
    368379        if (!empty($docImgsStr)) {
    369380            $docImgs = explode(',',$docImgsStr);
  • keydatas/trunk/readme.txt

    r2968537 r2969579  
    55Author URI: http://www.keydatas.com
    66Plugin URI: http://www.keydatas.com/wordpress-plugin
    7 Stable tag: 2.5.1
     7Stable tag: 2.5.2
    88Requires at least: 4.1
    99Tested up to: 6.3.1
Note: See TracChangeset for help on using the changeset viewer.