Plugin Directory

Changeset 3421596


Ignore:
Timestamp:
12/17/2025 07:29:15 AM (3 months ago)
Author:
infility
Message:

v2.14.43 (20251217) Ben: 修复导入文件漏洞添加nonce

Location:
infility-global/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • infility-global/trunk/infility_global.php

    r3420635 r3421596  
    44Plugin URI: https://www.infility.cn/
    55Description: Infility公共插件
    6 Version: 2.14.43
     6Version: 2.14.44
    77Author: Infility
    88Author URI: https://www.infility.cn/
     
    138138v2.14.37 (20251203) Ben: 新增古腾堡样式类型
    139139v2.14.43 (20251216) Ben: 修复导入文件漏洞
     140v2.14.43 (20251217) Ben: 修复导入文件漏洞添加nonce
    140141*/
    141142
     
    143144    function __construct()
    144145    {
    145         define( 'INFILITY_GLOBAL_VERSION', '2.14.43' );
     146        define( 'INFILITY_GLOBAL_VERSION', '2.14.44' );
    146147        define( 'INFILITY_GLOBAL_PATH', plugin_dir_path( __FILE__ ) ); // fullpath/wp-content/plugins/infility-global/ // 有斜杠
    147148        define( 'INFILITY_GLOBAL_URL', plugins_url( '/', __FILE__ ) ); // https://the_domain/wp-content/plugins/infility-global/ // 斜杠是自己加的
  • infility-global/trunk/widgets/infility-import-data/include/infility-import-site.php

    r3420609 r3421596  
    10991099
    11001100        $page_format_target = $this->format_target($page_tag);
    1101         $page_tag = $this->getHtmlTag($html,$page_format_target['format'],$page_format_target['type'],['href']);
     1101        $page_tag = $this->getHtmlTag($html,$page_format_target['format'],$page_format_target['type'],['href','class']);
    11021102
    11031103        $sql = "SELECT url FROM $url_table WHERE list_id=$list_id AND `type`='category'";
    11041104        $check_repeat = $wpdb->get_col($sql);
     1105
     1106        $first_page_check = ['1','Page1'];
    11051107
    11061108        $pages = [];
     
    11091111
    11101112            foreach($page_tag as $k=>$v){
    1111                 if(empty($v['link'])){continue;}
     1113                if(empty($v['link'])){
     1114                    if(in_array($v['value'],$first_page_check)){
     1115                        $v['link'] = $url;
     1116                    }else{
     1117                        continue;
     1118                    }
     1119                }
    11121120                if(in_array($v['link'],$check_repeat)){continue;}
    11131121                if(in_array($v['link'],$pages)){continue;}
     
    11161124
    11171125            $last_page_num = $this->getLastPageFromHrefs($pages,$url);
     1126            if(count($pages)!=$last_page_num){return false;}
     1127
    11181128            foreach($pages as $k=>$v){
    11191129                $page_num = $k+1;
     
    11831193        $check_repeat = $wpdb->get_col($sql);
    11841194
     1195        $first_page_check = ['1','Page1'];
     1196
    11851197        $list = [];
    11861198        $repeat_list = [];
    11871199        if(!empty($list_tag)){
    11881200            foreach($list_tag as $k=>$v){
    1189                 if(empty($v['link'])){continue;}
     1201                if(empty($v['link'])){
     1202                    if(in_array($v['value'],$first_page_check)){
     1203                        $v['link'] = $url;
     1204                    }else{
     1205                        continue;
     1206                    }
     1207                }
    11901208                if(in_array($v['link'],$check_repeat)){
    11911209                    $repeat_list[] = $v['link'];
  • infility-global/trunk/widgets/infility-import-data/infility-import-data.php

    r3420635 r3421596  
    335335        $taxonomy_list = get_taxonomies(['public' => true]);
    336336
     337        $nonce = wp_create_nonce('infility_import_data');
     338
    337339        ob_start();
    338340        ?>
     
    387389                <div class="row">
    388390                    <input type="hidden" class="list_id" name="id">
     391                    <input type="hidden" name="nonce" value="<?php echo $nonce;?>">
    389392                    <button class="form_button">开始</button>
    390393                </div>
     
    436439                <div class="row">
    437440                    <input type="hidden" class="list_id" name="id">
     441                    <input type="hidden" name="nonce" value="<?php echo $nonce;?>">
    438442                    <button class="form_button">开始</button>
    439443                </div>
     
    527531                <div class="row">
    528532                    <input type="hidden" class="list_id" name="id">
     533                    <input type="hidden" name="nonce" value="<?php echo $nonce;?>">
    529534                    <button class="form_button">开始</button>
    530535                </div>
     
    550555
    551556    public function import_data(){
    552         if(empty($_POST['type'])){str::e_json(['res'=>'Type is wrong'],1);}       
     557        if(empty($_POST['type'])){str::e_json(['res'=>'Type is wrong'],1);} 
     558        if(empty($_POST['nonce'])){str::e_json(['res'=>'Nonce is wrong'],1);}     
     559        $nonce = $_POST['nonce'];
     560        if(!wp_verify_nonce($nonce, 'infility_import_data')){str::e_json(['res'=>'Nonce is wrong'],1);}
    553561
    554562        $type = $_POST['type'];
     
    889897
    890898    public function get_extract_file(){
     899        if(empty($_POST['nonce'])){str::e_json(['res'=>'Nonce is wrong'],1);}     
     900        $nonce = $_POST['nonce'];
     901        if(!wp_verify_nonce($nonce, 'infility_import_data')){str::e_json(['res'=>'Nonce is wrong'],1);}
     902
    891903        $import_file_class = new infility_import_file();
    892904        $file = [
  • infility-global/trunk/widgets/infility-import-data/js/infility_import_data.js

    r3395561 r3421596  
    106106        let post_type = $("#file_form select[name='post_type']").val();
    107107        if(!post_type){global_obj.win_alert('请先选择post_type');return false;}
    108 
     108       
     109        let nonce = $("#file_form input[name='nonce']").val();
     110        if(!nonce){global_obj.win_alert('请先获取nonce');return false;}
     111       
    109112        let formData = new FormData();
    110113        formData.append('file', file);
    111114        formData.append('post_type',post_type);
     115        formData.append('nonce',nonce);
    112116        formData.append('action','get_extract_file');
    113117        fetch(ajax_object.ajax_url, {
     
    214218
    215219                let id = data.id;
     220                let nonce = form_obj.find("input[name='nonce']").val();
     221                if(!nonce){
     222                    global_obj.win_alert('nonce出错');
     223                    button_obj.attr("is_run","false");
     224                    button_obj.text('继续');
     225                    return false;
     226                }
    216227                if(type==='url'){
    217228                    let page_type = form_obj.find("select[name='page_type']").val();
     
    219230                    let run_data = [];
    220231                    if(page_type==='post'){
    221                         run_data.push({action:'get_post_detail',id:id});//10%
     232                        run_data.push({action:'get_post_detail',id:id,nonce:nonce});//10%
    222233                    }else if(page_type==='category'){
    223                         run_data.push({action:'search_category_page',id:id});//10%
    224                         run_data.push({action:'search_category_post',id:id});//10%
    225                         run_data.push({action:'get_post_detail',id:id});//10%
     234                        run_data.push({action:'search_category_page',id:id,nonce:nonce});//10%
     235                        run_data.push({action:'search_category_post',id:id,nonce:nonce});//10%
     236                        run_data.push({action:'get_post_detail',id:id,nonce:nonce});//10%
    226237                    }
    227238
     
    231242                    let id = data.id;
    232243                    let run_data = [];
    233                     run_data.push({action:'add_excel_post',id:id});//10%
     244                    run_data.push({action:'add_excel_post',id:id,nonce:nonce});//10%
    234245                    form_obj.find(".list_id").val(id);
    235246                    runProcess(run_data,button_obj,$("#import_page .result .progress"),$("#import_page .result .content"));
     
    237248                    let id = data.id;
    238249                    let run_data = [];
    239                     run_data.push({action:'import_main_image',id:id});//10%
     250                    run_data.push({action:'import_main_image',id:id,nonce:nonce});//10%
    240251                    form_obj.find(".list_id").val(id);
    241252                    runProcess(run_data,button_obj,$("#import_page .result .progress"),$("#import_page .result .content"));
Note: See TracChangeset for help on using the changeset viewer.