Download Monitor - Version 1.4.2

Version Description

  • Fix for site_url -> abspath
  • Check if hash functions are supported before use.
Download this release

Release Info

Developer mikejolley
Plugin Icon 128x128 Download Monitor
Version 1.4.2
Comparing to
See all releases

Code changes from version 1.4.1 to 1.4.2

Files changed (2) hide show
  1. download-monitor.php +28 -20
  2. readme.txt +5 -1
download-monitor.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: Download Monitor
4
  Plugin URI: http://mikejolley.com/projects/download-monitor/
5
  Description: A full solution for managing downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
- Version: 1.4.1
7
  Author: Mike Jolley
8
  Author URI: http://mikejolley.com
9
  Requires at least: 3.8
@@ -37,7 +37,7 @@ class WP_DLM {
37
  global $wpdb;
38
 
39
  // Define constants
40
- define( 'DLM_VERSION', '1.4.1' );
41
 
42
  // Table for logs
43
  $wpdb->download_log = $wpdb->prefix . 'download_log';
@@ -550,25 +550,26 @@ class WP_DLM {
550
  $file_path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file_path );
551
  $file_path = realpath( $file_path );
552
 
553
- } elseif( strpos( $file_path, ABSPATH ) !== false ) {
554
 
555
  /** This is a local file outside of wp-content so figure out the path */
556
  $remote_file = false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
557
 
558
- if ( ! is_multisite() ) {
559
- $file_path = str_replace( site_url( '/', 'https' ), ABSPATH, $file_path );
560
- $file_path = str_replace( site_url( '/', 'http' ), ABSPATH, $file_path );
561
- } else {
562
- // Try to replace network url
563
- $file_path = str_replace( network_admin_url( '/', 'https' ), ABSPATH, $file_path );
564
- $file_path = str_replace( network_admin_url( '/', 'http' ), ABSPATH, $file_path );
565
- // Try to replace upload URL
566
- $upload_dir = wp_upload_dir();
567
- $file_path = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $file_path );
568
- }
569
-
570
- $file_path = realpath( $file_path );
571
-
572
  } elseif ( file_exists( ABSPATH . $file_path ) ) {
573
 
574
  /** Path needs an abspath to work */
@@ -619,9 +620,16 @@ class WP_DLM {
619
  if ( $file_path ) {
620
  list( $file_path, $remote_file ) = $this->parse_file_path( $file_path );
621
 
622
- $md5 = hash_file( 'md5', $file_path );
623
- $sha1 = hash_file( 'sha1', $file_path );
624
- $crc32 = hash_file( 'crc32b', $file_path );
 
 
 
 
 
 
 
625
  }
626
 
627
  return array( 'md5' => $md5, 'sha1' => $sha1, 'crc32' => $crc32 );
3
  Plugin Name: Download Monitor
4
  Plugin URI: http://mikejolley.com/projects/download-monitor/
5
  Description: A full solution for managing downloadable files, monitoring downloads and outputting download links and file information on your WordPress powered site.
6
+ Version: 1.4.2
7
  Author: Mike Jolley
8
  Author URI: http://mikejolley.com
9
  Requires at least: 3.8
37
  global $wpdb;
38
 
39
  // Define constants
40
+ define( 'DLM_VERSION', '1.4.2' );
41
 
42
  // Table for logs
43
  $wpdb->download_log = $wpdb->prefix . 'download_log';
550
  $file_path = str_replace( WP_CONTENT_URL, WP_CONTENT_DIR, $file_path );
551
  $file_path = realpath( $file_path );
552
 
553
+ } elseif( is_multisite() && ( strpos( $file_path, network_admin_url( '/', 'http' ) ) !== false || strpos( $file_path, network_admin_url( '/', 'https' ) ) !== false ) ) {
554
 
555
  /** This is a local file outside of wp-content so figure out the path */
556
  $remote_file = false;
557
+ // Try to replace network url
558
+ $file_path = str_replace( network_admin_url( '/', 'https' ), ABSPATH, $file_path );
559
+ $file_path = str_replace( network_admin_url( '/', 'http' ), ABSPATH, $file_path );
560
+ // Try to replace upload URL
561
+ $upload_dir = wp_upload_dir();
562
+ $file_path = str_replace( $upload_dir['baseurl'], $upload_dir['basedir'], $file_path );
563
+ $file_path = realpath( $file_path );
564
+
565
+ } elseif( strpos( $file_path, site_url( '/', 'http' ) ) !== false || strpos( $file_path, site_url( '/', 'https' ) ) !== false ) {
566
+
567
+ /** This is a local file outside of wp-content so figure out the path */
568
+ $remote_file = false;
569
+ $file_path = str_replace( site_url( '/', 'https' ), ABSPATH, $file_path );
570
+ $file_path = str_replace( site_url( '/', 'http' ), ABSPATH, $file_path );
571
+ $file_path = realpath( $file_path );
572
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
573
  } elseif ( file_exists( ABSPATH . $file_path ) ) {
574
 
575
  /** Path needs an abspath to work */
620
  if ( $file_path ) {
621
  list( $file_path, $remote_file ) = $this->parse_file_path( $file_path );
622
 
623
+ if ( $remote_file && ! ini_get( 'allow_url_fopen' ) ) {
624
+ // We cannot look up a hash
625
+ $md5 = false;
626
+ $sha1 = false;
627
+ $crc32 = false;
628
+ } else {
629
+ $md5 = hash_file( 'md5', $file_path );
630
+ $sha1 = hash_file( 'sha1', $file_path );
631
+ $crc32 = hash_file( 'crc32b', $file_path );
632
+ }
633
  }
634
 
635
  return array( 'md5' => $md5, 'sha1' => $sha1, 'crc32' => $crc32 );
readme.txt CHANGED
@@ -4,7 +4,7 @@ Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=mike.jol
4
  Tags: download, downloads, monitor, hits, download monitor, tracking, admin, count, counter, files, versions, download count, logging
5
  Requires at least: 3.8
6
  Tested up to: 3.8
7
- Stable tag: 1.4.1
8
  License: GPLv3
9
 
10
  Download Monitor is a plugin for uploading and managing downloads, tracking downloads, and displaying links.
@@ -108,6 +108,10 @@ Admin hits are not counted, log out and try!
108
 
109
  == Changelog ==
110
 
 
 
 
 
111
  = 1.4.1 =
112
  * Fix file_exists error in download handlers
113
 
4
  Tags: download, downloads, monitor, hits, download monitor, tracking, admin, count, counter, files, versions, download count, logging
5
  Requires at least: 3.8
6
  Tested up to: 3.8
7
+ Stable tag: 1.4.2
8
  License: GPLv3
9
 
10
  Download Monitor is a plugin for uploading and managing downloads, tracking downloads, and displaying links.
108
 
109
  == Changelog ==
110
 
111
+ = 1.4.2 =
112
+ * Fix for site_url -> abspath
113
+ * Check if hash functions are supported before use.
114
+
115
  = 1.4.1 =
116
  * Fix file_exists error in download handlers
117