Changeset 226620
- Timestamp:
- 04/08/2010 07:40:46 PM (16 years ago)
- Location:
- wp-download-codes/trunk
- Files:
-
- 5 edited
-
README.txt (modified) (2 diffs)
-
dc_administration.php (modified) (5 diffs)
-
dc_functions.php (modified) (1 diff)
-
dc_template.php (modified) (1 diff)
-
wp-download-codes.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
wp-download-codes/trunk/README.txt
r193347 r226620 4 4 Tags: download, download code, code generator 5 5 Requires at least: 2.5 6 Tested up to: 2.9. 07 Stable tag: 1. 16 Tested up to: 2.9.2 7 Stable tag: 1.2 8 8 9 9 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. … … 48 48 == Changelog == 49 49 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 = 51 54 * Added functionality to edit list of allowed file types. 52 55 * Added annotation to documentation about folder protection to avoid unauthorized downloading. -
wp-download-codes/trunk/dc_administration.php
r193347 r226620 63 63 delete_option( 'dc_msg_max_downloads_reached' ); 64 64 delete_option( 'dc_msg_max_attempts_reached' ); 65 delete_option( 'dc_file_location' ); 65 66 delete_option( 'dc_file_types' ); 66 67 … … 101 102 // Overwrite existing options 102 103 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'] ) ); 104 105 $dc_max_attempts = $_POST['dc_max_attempts']; 105 106 106 107 // 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 ); 113 114 } 114 115 … … 140 141 echo '<table class="form-table">'; 141 142 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 155 176 echo '</tr>'; 156 177 … … 281 302 echo '<tr valign="top">'; 282 303 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 . '" />'; 284 305 echo '</tr>'; 285 306 286 307 // Get zip files in download folder 287 $files = scandir( dc_ zip_location() );308 $files = scandir( dc_file_location() ); 288 309 289 310 echo '<tr valign="top">'; 290 311 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">'; 292 313 foreach ($files as $filename) { 293 314 if ( in_array(strtolower( substr($filename,-3) ), dc_file_types() ) ) { … … 547 568 echo '</div>'; 548 569 549 550 570 } 551 571 } -
wp-download-codes/trunk/dc_functions.php
r193347 r226620 48 48 49 49 /** 50 * Returns the full path of the ziplocation.50 * Returns the full path of the download file location. 51 51 */ 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' ); 52 function 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 } 60 74 } 61 75 else { 62 return $wp_upload_dir['basedir'] . '/' . get_option( 'dc_zip_location' );76 return ( !substr( $upload_path, 0, 1) == "/" ? "/" : "") . $upload_path . '/' . $dc_file_location; 63 77 } 64 78 } 65 else {66 return ( !substr( $upload_path, 0, 1) == "/" ? "/" : "") . $upload_path . '/' . get_option( 'dc_zip_location' );67 }68 79 } 69 80 -
wp-download-codes/trunk/dc_template.php
r182030 r226620 124 124 // Store details in session variables 125 125 $_SESSION['dc_filename'] = $release->filename; 126 $_SESSION['dc_location'] = dc_ zip_location() . $release->filename;126 $_SESSION['dc_location'] = dc_file_location() . $release->filename; 127 127 128 128 // Redirect to download page -
wp-download-codes/trunk/wp-download-codes.php
r193347 r226620 6 6 Description: 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. 7 7 8 Version: 1. 18 Version: 1.2 9 9 Author: misanthrop 10 10 Author URI: http://www.misantropolis.de
Note: See TracChangeset
for help on using the changeset viewer.