Plugin Directory

Changeset 3364847


Ignore:
Timestamp:
09/20/2025 06:51:34 AM (5 months ago)
Author:
GamerZ
Message:

Deploying wp-downloadmanager from GitHub

Location:
wp-downloadmanager/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • wp-downloadmanager/trunk/download-add.php

    r2343995 r3364847  
    11<?php
    22### Check Whether User Can Manage Downloads
    3 if(!current_user_can('manage_downloads')) {
     3if (!current_user_can('manage_downloads')) {
    44    die('Access Denied');
    55}
     
    77
    88### Variables Variables Variables
    9 $base_name = plugin_basename( 'wp-downloadmanager/download-manager.php' );
    10 $base_page = 'admin.php?page='.$base_name;
     9$base_name = plugin_basename('wp-downloadmanager/download-manager.php');
     10$base_page = 'admin.php?page=' . $base_name;
    1111$file_path = get_option('download_path');
    12 $file_categories = get_option( 'download_categories' );
     12$file_categories = get_option('download_categories');
    1313
    1414
    1515### Form Processing
    16 if( ! empty( $_POST['do'] ) ) {
     16if (! empty($_POST['do'])) {
    1717    check_admin_referer('wp-downloadmanager_add-file');
    1818    // Decide What To Do
    19     switch( $_POST['do'] ) {
     19    switch ($_POST['do']) {
    2020        // Add File
    2121        case __('Add File', 'wp-downloadmanager'):
    22             $file_type = ! empty( $_POST['file_type']) ? intval( $_POST['file_type'] ) : 0;
    23             switch($file_type) {
     22            $file_type = ! empty($_POST['file_type']) ? intval($_POST['file_type']) : 0;
     23            switch ($file_type) {
    2424                case 0:
    25                     $file = ! empty( $_POST['file'] ) ? addslashes( wp_kses_post( trim( $_POST['file'] ) ) ) : '';
     25                    $file = ! empty($_POST['file']) ? addslashes(wp_kses_post(trim($_POST['file']))) : '';
    2626                    $file = download_rename_file($file_path, $file);
    27                     $file_size = filesize($file_path.$file);
     27                    $file_size = filesize($file_path . $file);
    2828                    break;
    2929                case 1:
    30                     if( $_FILES['file_upload']['size'] > get_max_upload_size() ) {
    31                         $text = '<p style="color: red;">'.sprintf(__('File Size Too Large. Maximum Size Is %s', 'wp-downloadmanager'), format_filesize(get_max_upload_size())).'</p>';
     30                    if ($_FILES['file_upload']['size'] > get_max_upload_size()) {
     31                        $text = '<p style="color: red;">' . sprintf(__('File Size Too Large. Maximum Size Is %s', 'wp-downloadmanager'), format_filesize(get_max_upload_size())) . '</p>';
    3232                        break;
    33                     } else {
    34                         if(is_uploaded_file($_FILES['file_upload']['tmp_name'])) {
    35                             $file_upload_to = ! empty( $_POST['file_upload_to'] ) ? $_POST['file_upload_to'] : '';
    36                             if( $file_upload_to !== '/' ) {
    37                                 $file_upload_to = $file_upload_to . '/';
    38                             }
    39                             if(move_uploaded_file($_FILES['file_upload']['tmp_name'], $file_path.$file_upload_to.basename($_FILES['file_upload']['name']))) {
    40                                 $file = $file_upload_to.basename($_FILES['file_upload']['name']);
    41                                 $file = download_rename_file($file_path, $file);
    42                                 $file_size = filesize($file_path.$file);
    43                             } else {
    44                                 $text = '<p style="color: red;">'.__('Error In Uploading File', 'wp-downloadmanager').'</p>';
    45                                 break;
    46                             }
     33                    }
     34                    $file_name = ! empty($_FILES['file_upload']['name']) ? basename( $_FILES['file_upload']['name'] ) : '';
     35                    $validate = wp_check_filetype_and_ext( $_FILES['file_upload']['tmp_name'], $file_name );
     36                    if ( $validate['type'] === false ) {
     37                            $text = '<p style="color: red;">' . __('File type is invalid', 'wp-downloadmanager') . '</p>';
     38                            break;
     39                    }
     40                    if (is_uploaded_file($_FILES['file_upload']['tmp_name'])) {
     41                        $file_upload_to = ! empty($_POST['file_upload_to']) ? $_POST['file_upload_to'] : '';
     42                        if ($file_upload_to !== '/') {
     43                            $file_upload_to = $file_upload_to . '/';
     44                        }
     45                        if (move_uploaded_file($_FILES['file_upload']['tmp_name'], $file_path . $file_upload_to . $file_name)) {
     46                            $file = $file_upload_to . $file_name;
     47                            $file = download_rename_file($file_path, $file);
     48                            $file_size = filesize($file_path . $file);
    4749                        } else {
    48                             $text = '<p style="color: red;">'.__('Error In Uploading File', 'wp-downloadmanager').'</p>';
     50                            $text = '<p style="color: red;">' . __('Error In Uploading File', 'wp-downloadmanager') . '</p>';
    4951                            break;
    5052                        }
     53                    } else {
     54                        $text = '<p style="color: red;">' . __('Error In Uploading File', 'wp-downloadmanager') . '</p>';
     55                        break;
    5156                    }
    5257                    break;
    5358                case 2:
    54                     $file = ! empty( $_POST['file_remote'] ) ? esc_url_raw( $_POST['file_remote'] ) : '';
    55                     if ( is_file_remote_valid( $file ) ) {
    56                         $file_size = remote_filesize( $file );
     59                    $file = ! empty($_POST['file_remote']) ? esc_url_raw($_POST['file_remote']) : '';
     60                    if (is_file_remote_valid($file)) {
     61                        $file_size = remote_filesize($file);
    5762                    } else {
    58                         $text = '<p style="color: red;">' . __( 'There Is An Error Parsing Remote File URL', 'wp-downloadmanager' ) . '</p>';
     63                        $text = '<p style="color: red;">' . __('There Is An Error Parsing Remote File URL', 'wp-downloadmanager') . '</p>';
    5964                    }
    6065                    break;
    6166            }
    62             if ( empty( $text ) ) {
    63                 $file_name = ! empty( $_POST['file_name'] ) ? addslashes( wp_kses_post( trim( $_POST['file_name'] ) ) ) : '';
    64                 if(empty($file_name)) {
     67            if (empty($text)) {
     68                $file_name = ! empty($_POST['file_name']) ? addslashes(wp_kses_post(trim($_POST['file_name']))) : '';
     69                if (empty($file_name)) {
    6570                    $file_name = basename($file);
    6671                }
    67                 $file_des = ! empty( $_POST['file_des'] ) ? addslashes( wp_kses_post( trim( $_POST['file_des'] ) ) ) : '';
    68                 $file_category = ! empty( $_POST['file_cat'] ) ? intval( $_POST['file_cat'] ) : 0;
    69                 if(!empty($_POST['file_size'])) {
    70                     $file_size = ! empty( $_POST['file_size'] ) ? intval( $_POST['file_size'] ) : 0;
     72                $file_des = ! empty($_POST['file_des']) ? addslashes(wp_kses_post(trim($_POST['file_des']))) : '';
     73                $file_category = ! empty($_POST['file_cat']) ? intval($_POST['file_cat']) : 0;
     74                if (!empty($_POST['file_size'])) {
     75                    $file_size = ! empty($_POST['file_size']) ? intval($_POST['file_size']) : 0;
    7176                }
    72                 $file_hits = ! empty( $_POST['file_hits'] ) ? intval( $_POST['file_hits'] ) : 0;
    73                 $file_timestamp_day =    ! empty( $_POST['file_timestamp_day'] ) ? intval( $_POST['file_timestamp_day'] ) : 0;
    74                 $file_timestamp_month =  ! empty( $_POST['file_timestamp_month'] ) ? intval( $_POST['file_timestamp_month'] ) : 0;
    75                 $file_timestamp_year =   ! empty( $_POST['file_timestamp_year'] ) ? intval( $_POST['file_timestamp_year'] ) : 0;
    76                 $file_timestamp_hour =   ! empty( $_POST['file_timestamp_hour'] ) ? intval( $_POST['file_timestamp_hour'] ) : 0;
    77                 $file_timestamp_minute = ! empty( $_POST['file_timestamp_minute'] ) ? intval( $_POST['file_timestamp_minute'] ) : 0;
    78                 $file_timestamp_second = ! empty( $_POST['file_timestamp_second'] ) ? intval( $_POST['file_timestamp_second'] ) : 0;
     77                $file_hits = ! empty($_POST['file_hits']) ? intval($_POST['file_hits']) : 0;
     78                $file_timestamp_day =    ! empty($_POST['file_timestamp_day']) ? intval($_POST['file_timestamp_day']) : 0;
     79                $file_timestamp_month =  ! empty($_POST['file_timestamp_month']) ? intval($_POST['file_timestamp_month']) : 0;
     80                $file_timestamp_year =   ! empty($_POST['file_timestamp_year']) ? intval($_POST['file_timestamp_year']) : 0;
     81                $file_timestamp_hour =   ! empty($_POST['file_timestamp_hour']) ? intval($_POST['file_timestamp_hour']) : 0;
     82                $file_timestamp_minute = ! empty($_POST['file_timestamp_minute']) ? intval($_POST['file_timestamp_minute']) : 0;
     83                $file_timestamp_second = ! empty($_POST['file_timestamp_second']) ? intval($_POST['file_timestamp_second']) : 0;
    7984                $file_date = gmmktime($file_timestamp_hour, $file_timestamp_minute, $file_timestamp_second, $file_timestamp_month, $file_timestamp_day, $file_timestamp_year);
    80                 $file_permission = ! empty( $_POST['file_permission'] ) ? intval( $_POST['file_permission'] ) : 0;
     85                $file_permission = ! empty($_POST['file_permission']) ? intval($_POST['file_permission']) : 0;
    8186                $addfile = $wpdb->query("INSERT INTO $wpdb->downloads VALUES (0, '$file', '$file_name', '$file_des', '$file_size', $file_category, '$file_date', '$file_date', '$file_date', $file_hits, $file_permission)");
    82                 if(!$addfile) {
    83                     $text = '<p style="color: red;">'.sprintf(__('Error In Adding File \'%s (%s)\'', 'wp-downloadmanager'), $file_name, $file).'</p>';
     87                if (!$addfile) {
     88                    $text = '<p style="color: red;">' . sprintf(__('Error In Adding File \'%s (%s)\'', 'wp-downloadmanager'), $file_name, $file) . '</p>';
    8489                } else {
    8590                    $file_id = intval($wpdb->insert_id);
    86                     $text = '<p style="color: green;">'.sprintf(__('File \'%s (%s) (ID: %s)\' Added Successfully', 'wp-downloadmanager'), $file_name, $file, $file_id).'</p>';
     91                    $text = '<p style="color: green;">' . sprintf(__('File \'%s (%s) (ID: %s)\' Added Successfully', 'wp-downloadmanager'), $file_name, $file, $file_id) . '</p>';
    8792                }
    8893            }
     
    9196}
    9297?>
    93 <?php if(!empty($text)) { echo '<!-- Last Action --><div id="message" class="updated fade"><p>'.stripslashes($text).'</p></div>'; } ?>
     98<?php if (!empty($text)) {
     99    echo '<!-- Last Action --><div id="message" class="updated fade"><p>' . stripslashes($text) . '</p></div>';
     100} ?>
    94101<!-- Add A File -->
    95 <form method="post" action="<?php echo admin_url('admin.php?page='.plugin_basename(__FILE__)); ?>" enctype="multipart/form-data">
     102<form method="post" action="<?php echo admin_url('admin.php?page=' . plugin_basename(__FILE__)); ?>" enctype="multipart/form-data">
    96103    <input type="hidden" name="MAX_FILE_SIZE" value="<?php echo get_max_upload_size(); ?>" />
    97104    <?php wp_nonce_field('wp-downloadmanager_add-file'); ?>
     
    136143                    <select name="file_cat" size="1">
    137144                        <?php
    138                         for($i=0; $i<sizeof($file_categories); $i++) {
    139                             if(!empty($file_categories[$i])) {
    140                                 echo '<option value="'.$i.'">'.$file_categories[$i].'</option>'."\n";
     145                        for ($i = 0; $i < sizeof($file_categories); $i++) {
     146                            if (!empty($file_categories[$i])) {
     147                                echo '<option value="' . $i . '">' . $file_categories[$i] . '</option>' . "\n";
    141148                            }
    142149                        }
     
    169176                        <option value="10"><?php _e('At Least Administrator Role', 'wp-downloadmanager'); ?></option>
    170177                    </select>
     178                    <p>
     179                        <?php _e('Note: While role-based authentication is enforced, users who directly guess the file URL may still be able to access the file without authorization.', 'wp-downloadmanager'); ?>
     180                    </p>
    171181                </td>
    172182            </tr>
    173183            <tr>
    174                 <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add File', 'wp-downloadmanager'); ?>"  class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-downloadmanager'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
     184                <td colspan="2" align="center"><input type="submit" name="do" value="<?php _e('Add File', 'wp-downloadmanager'); ?>" class="button" />&nbsp;&nbsp;<input type="button" name="cancel" value="<?php _e('Cancel', 'wp-downloadmanager'); ?>" class="button" onclick="javascript:history.go(-1)" /></td>
    175185            </tr>
    176186        </table>
  • wp-downloadmanager/trunk/readme.txt

    r3294467 r3364847  
    55Requires at least: 4.0 
    66Tested up to: 6.8 
    7 Stable tag: 1.68.11 
     7Stable tag: 1.69  
    88License: GPLv2 
    99
     
    5959
    6060## Changelog
     61### Version 1.69
     62* FIXED: Only allow certain files to be uploaded based on `wp_check_filetype_and_ext()`
     63
     64### Version 1.68.12
     65* FIXED: Add a warning to let user know that if any users manage to guess the direct file URI, he will be able to download the file as well.
     66
    6167### Version 1.68.11
    6268* FIXED: Ensure that Download Path starts only with your wp-content folder for additional security.
  • wp-downloadmanager/trunk/wp-downloadmanager.php

    r3294467 r3364847  
    44Plugin URI: https://lesterchan.net/portfolio/programming/php/
    55Description: Adds a simple download manager to your WordPress blog.
    6 Version: 1.68.11
     6Version: 1.69
    77Author: Lester 'GaMerZ' Chan
    88Author URI: https://lesterchan.net
     
    3131
    3232### Version
    33 define( 'WP_DOWNLOADMANAGER_VERSION', '1.68.11' );
     33define( 'WP_DOWNLOADMANAGER_VERSION', '1.69' );
    3434
    3535### Create text domain for translations
Note: See TracChangeset for help on using the changeset viewer.