Plugin Directory

Changeset 226620


Ignore:
Timestamp:
04/08/2010 07:40:46 PM (16 years ago)
Author:
misanthrop
Message:

Version 1.2

Location:
wp-download-codes/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • wp-download-codes/trunk/README.txt

    r193347 r226620  
    44Tags: download, download code, code generator
    55Requires at least: 2.5
    6 Tested up to: 2.9.0
    7 Stable tag: 1.1
     6Tested up to: 2.9.2
     7Stable tag: 1.2
    88
    99The plugin enables to generation and management of download codes for .zip files. It was written to enable the free download of records and CDs with dedicated codes printed on the cover of the releases or on separate download cards.
     
    4848== Changelog ==
    4949
    50 = 1.1 =
     50= 1.2 =
     51* Added possibility to specify the absolute path for the download file location in 'Settings'. This should help if in your wordpress installation the upload folder cannot be determined.
     52
     53= 1.1 =
    5154* Added functionality to edit list of allowed file types.
    5255* Added annotation to documentation about folder protection to avoid unauthorized downloading.
  • wp-download-codes/trunk/dc_administration.php

    r193347 r226620  
    6363    delete_option( 'dc_msg_max_downloads_reached' );
    6464    delete_option( 'dc_msg_max_attempts_reached' );
     65    delete_option( 'dc_file_location' );
    6566    delete_option( 'dc_file_types' );
    6667   
     
    101102    // Overwrite existing options
    102103    if ( isset( $_POST['submit'] ) ) {
    103         $dc_zip_location = trim($_POST['dc_zip_location']);
     104        $dc_file_location = trim( ( '' != trim($_POST['dc_file_location_abs']) ? $_POST['dc_file_location_abs'] : $_POST['dc_file_location'] ) );
    104105        $dc_max_attempts = $_POST['dc_max_attempts'];
    105106       
    106107        // Update zip location
    107         if ( $dc_zip_location != '' ) {
    108             if ( substr( $dc_zip_location, -1 ) != '/') {
    109                 $dc_zip_location .= '/';
    110             }
    111 
    112             update_option( 'dc_zip_location', $dc_zip_location );
     108        if ( $dc_file_location != '' ) {
     109            if ( substr( $dc_file_location, -1 ) != '/') {
     110                $dc_file_location .= '/';
     111            }
     112
     113            update_option( 'dc_file_location', $dc_file_location );
    113114        }
    114115       
     
    140141    echo '<table class="form-table">';
    141142
    142     // Get subfolders of upload directory
    143     $wp_upload_dir = wp_upload_dir();
    144     $files = scandir( $wp_upload_dir['basedir'] );
    145        
    146     echo '<tr valign="top">';
    147     echo '<th scope="row">File</th>';
    148     echo '<td>' . get_option( 'upload_path' ) . '/ <select name="dc_zip_location" id="dc_zip_location">';
    149     foreach ($files as $folder) {
    150         if ( is_dir( $wp_upload_dir['basedir'] . '/' . $folder ) && $folder != '.' && $folder != '..' ) {
    151             echo '<option' . ( $folder . '/' == get_option( 'dc_zip_location' ) ? ' selected="selected"' : '' ) . '>' . $folder . '</option>';
    152         }
    153     }
    154     echo '</select></td>';
     143    /**
     144     * Location of download files
     145     */
     146   
     147    echo '<tr valign="top">';
     148    echo '<th scope="row">Location of download files</th>';
     149   
     150    if ( '' == get_option( 'dc_file_location' ) || ( '' != get_option( 'dc_file_location' ) && '/' != substr( get_option( 'dc_file_location' ), 0, 1 ) ) ) {
     151        // If current location of download files is empty or relative, try to locate the upload folder
     152        $wp_upload_dir = wp_upload_dir();
     153        $files = scandir( $wp_upload_dir['basedir'] ); 
     154       
     155        echo '<td>' . $wp_upload_dir['basedir']  . '/ <select name="dc_file_location" id="dc_file_location">';
     156        foreach ($files as $folder) {
     157            if ( is_dir( $wp_upload_dir['basedir'] . '/' . $folder ) && $folder != '.' && $folder != '..' ) {
     158                echo '<option' . ( $folder . '/' == get_option( 'dc_file_location' ) ? ' selected="selected"' : '' ) . '>' . $folder . '</option>';
     159            }
     160        }
     161        echo '</select>';
     162       
     163        // Provide possibility to define upload path directly
     164        echo '<br /><br />';
     165        echo 'If the upload folder cannot be determined or if the release management does not work somehow, or if you want to have another download file location, you can specify the absolute path of the download file location here:<br />';
     166        echo '<input type="text" name="dc_file_location_abs" size="100" / >';
     167       
     168        echo '</td>';
     169    }
     170    else {
     171        echo '<td><input type="text" name="dc_file_location" size="100" value="' . get_option( 'dc_file_location' ) . '" />';
     172        echo '<br />Provide the absolute path to your download file location.';
     173        echo '</td>';
     174    }
     175   
    155176    echo '</tr>';
    156177   
     
    281302        echo '<tr valign="top">';
    282303        echo '<th scope="row">Title</th>';
    283         echo '<td><input type="text" name="title" value="' . $release->title . '" />';
     304        echo '<td><input type="text" name="title" size="100" value="' . $release->title . '" />';
    284305        echo '</tr>';
    285306       
    286307        // Get zip files in download folder
    287         $files = scandir( dc_zip_location() );
     308        $files = scandir( dc_file_location() );
    288309       
    289310        echo '<tr valign="top">';
    290311        echo '<th scope="row">File</th>';
    291         echo '<td>' . dc_zip_location( 'short' ) . ' <select name="filename">';
     312        echo '<td>' . dc_file_location( 'short' ) . ' <select name="filename">';
    292313        foreach ($files as $filename) {
    293314            if ( in_array(strtolower( substr($filename,-3) ), dc_file_types() ) ) {
     
    547568            echo '</div>';
    548569   
    549            
    550570        }
    551571    }   
  • wp-download-codes/trunk/dc_functions.php

    r193347 r226620  
    4848
    4949/**
    50  * Returns the full path of the zip location.
     50 * Returns the full path of the download file location.
    5151 */
    52 function dc_zip_location( $str_mode = 'full' ) {
    53    
    54     $wp_upload_dir = wp_upload_dir();
    55     $upload_path = get_option( 'upload_path' );
    56    
    57     if ( 'full' == $str_mode ) {
    58         if ( substr( $wp_upload_dir['basedir'], 0, strlen( $upload_path ) ) == $upload_path ) {
    59             return  $upload_path . '/' . get_option( 'dc_zip_location' );
     52function dc_file_location( $str_mode = 'full' ) {
     53
     54    // Get location of download file
     55    $dc_file_location = ( '' == get_option( 'dc_file_location' ) ? get_option( 'dc_zip_location' ) : get_option( 'dc_file_location' ) );
     56
     57    // Check if location is an absolute or relative path
     58    if ( strlen( $dc_file_location ) > 0 && '/' == substr( $dc_file_location, 0, 1) ) {
     59        // Absolute locations are returned directly
     60        return $dc_file_location;
     61    }
     62    else {
     63        // Relative locations are returned with the respective upload path directory
     64        $wp_upload_dir = wp_upload_dir();
     65        $upload_path = get_option( 'upload_path' );
     66       
     67        if ( 'full' == $str_mode ) {
     68            if ( substr( $wp_upload_dir['basedir'], 0, strlen( $upload_path ) ) == $upload_path ) {
     69                return  $upload_path . '/' . $dc_file_location;
     70            }
     71            else {
     72                return $wp_upload_dir['basedir'] . '/' . $dc_file_location;
     73            }
    6074        }
    6175        else {
    62             return $wp_upload_dir['basedir'] . '/' . get_option( 'dc_zip_location' );
     76            return ( !substr( $upload_path, 0, 1) == "/" ? "/" : "") . $upload_path . '/' . $dc_file_location;
    6377        }
    6478    }
    65     else {
    66         return ( !substr( $upload_path, 0, 1) == "/" ? "/" : "") . $upload_path . '/' . get_option( 'dc_zip_location' );
    67     }   
    6879}
    6980
  • wp-download-codes/trunk/dc_template.php

    r182030 r226620  
    124124        // Store details in session variables
    125125        $_SESSION['dc_filename'] = $release->filename;
    126         $_SESSION['dc_location'] = dc_zip_location() . $release->filename;
     126        $_SESSION['dc_location'] = dc_file_location() . $release->filename;
    127127       
    128128        // Redirect to download page
  • wp-download-codes/trunk/wp-download-codes.php

    r193347 r226620  
    66Description: The plugin enables to generation and management of download codes for .zip files. It was written to enable the free download of records and CDs with dedicated codes printed on the cover of the releases or on separate download cards.
    77
    8 Version: 1.1
     8Version: 1.2
    99Author: misanthrop
    1010Author URI: http://www.misantropolis.de
Note: See TracChangeset for help on using the changeset viewer.