Plugin Directory

Changeset 161722


Ignore:
Timestamp:
10/09/2009 01:29:29 AM (16 years ago)
Author:
reaperhulk
Message:

0.93. fixes for relative/absolute pathing

Location:
cdn-tools
Files:
4 edited
1 copied

Legend:

Unmodified
Added
Removed
  • cdn-tools/tags/0.93/cdntools.php

    r160603 r161722  
    55Description: CDN Tools is a plugin designed to help you drastically speed up your blog's load time by loading content onto a distribution network.  You can use a commercial CDN or just load some of your larger JS libraries for free from Google's servers!  At this time Cloud Files is the only supported CDN.
    66Author: Paul Kehrer
    7 Version: 0.92
     7Version: 0.93
    88Author URI: http://langui.sh/
    99*/
     
    2828set_time_limit(300); //5 minutes max...
    2929
    30 define('CDNTOOLS_VERSION','0.92');
     30define('CDNTOOLS_VERSION','0.93');
    3131
    3232$dir_array = explode('/',dirname(__FILE__));
     
    138138                [height] => 150
    139139            )*/
    140         if(isset($metadata['sizes'])) {
     140        if(is_array($metadata) && isset($metadata['sizes'])) {
    141141            $file_array = explode('/',$metadata['file']);
    142142            foreach($metadata['sizes'] as $data) {
    143                 $file_array[2] = $data['file'];
    144                 $filepath = $this->wp_upload_basedir.'/'.implode('/',$file_array);
     143                array_pop($file_array);
     144                array_push($file_array,$data['file']);
     145                $filepath = $this->file_path(implode('/',$file_array));
    145146                $this->cdn_attachment_upload(0,$filepath); //pass a zero post_id since we don't know it and it doesn't matter.  post_id can't be removed from the function though since the hook passes it
    146147            }
     
    170171   
    171172    function cdn_media_url_rewrite($data) {
    172         if($this->cdntools_sideload_uploads == 1 && !empty($this->cdntools_baseuris)) {
    173             //only rewrite if the pref is set and the baseuris array isn't empty
     173        if($this->cdntools_sideload_uploads == 1 && !empty($this->cdntools_baseuris) && ($this->cdntools_primarycdn) ) {
     174            //only rewrite if the pref is set and the baseuris array isn't empty and they have a CDN selected
    174175            $file_upload_url = $this->wp_upload_url_path.'/';
    175176            $file_upload_url = str_replace('/','\/',str_replace('://','://(www.)?',$file_upload_url));
     
    241242            echo 'true';
    242243        }
     244    }
     245   
     246    //this function is mostl stolen from get_attached_file in post.php in wordpress.  it attempts to correct for absolute vs relative paths.
     247    //if the if conditional is met it's a relative path
     248    function file_path($file) {
     249        if ( 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) ) {
     250            $file = $uploads['basedir'] . "/$file";
     251        }
     252        return $file;
    243253    }
    244254
     
    270280                            $file_array = explode('/',$metadata['file']);
    271281                            foreach($metadata['sizes'] as $data) {
    272                                 $file_array[2] = $data['file'];
    273                                 $filepath = $this->wp_upload_basedir.'/'.implode('/',$file_array);
     282                                array_pop($file_array);
     283                                array_push($file_array,$data['file']);
     284                                $filepath = $this->file_path(implode('/',$file_array));
    274285                                $files_to_delete[] = $filepath;
    275286                            }
     
    298309        foreach($result as $attachment) {
    299310            //we only need the basedir from our upload info var
    300             $fullpath = $this->wp_upload_basedir.'/'.$attachment->meta_value;
     311            $fullpath = $this->file_path($attachment->meta_value);
    301312            $uploadinfo[] = array('post_id'=>$attachment->post_id,'path'=>$fullpath);
    302313           
     
    306317                $file_array = explode('/',$metadata['file']);
    307318                foreach($metadata['sizes'] as $data) {
    308                     $file_array[2] = $data['file'];
    309                     $filepath = $this->wp_upload_basedir.'/'.implode('/',$file_array);
     319                    array_pop($file_array);
     320                    array_push($file_array,$data['file']);
     321                    $filepath = $this->file_path(implode('/',$file_array));
    310322                    $uploadinfo[] = array('post_id'=>$attachment->post_id,'path'=>$filepath);
    311323                }
  • cdn-tools/tags/0.93/readme.txt

    r160815 r161722  
    55Requires at least: 2.7
    66Tested up to: 2.8.4
    7 Stable tag: 0.92
     7Stable tag: 0.93
    88
    99CDN Tools is a plugin designed to help you drastically speed up your blog's load time by loading data onto a content distribution network (CDN).
     
    1313[CDN Tools](http://swearingscience.com/cdn-tools/ "CDN Tools Home") is a WordPress plugin that allows you to load javascript and media files to an external server to drastically speed page loads.  You can sideload data to a commercial CDN or just load your larger JS libraries (prototype, jquery) for **free** from Google's servers.  CDN Tools has been designed to be as easy to use as possible, so give it a shot!  Your blog's readers will thank you.  At this time the only commercial CDN supported is Cloud Files.  Check out the plugin homepage to view a screencast.
    1414
    15 New in 0.92
    16 
    17 *Major upgrade to support WP 2.8.  If you are a previous user of CDN Tools you <b>MUST</b> unload files and then load them again.  Please let me know if you have issues because several major changes were made.  See http://langui.sh/cdn-tools for more details.
     15= New in 0.92/0.93 =
     16* A partial fix for issues with customers who have full file paths stored in their postmeta table.  This is not a complete fix, but should help some (most?) users.
     17* Major upgrade to support WP 2.8.  If you are a previous user of CDN Tools you _MUST_ unload files and then load them again.  Please let me know if you have issues because several major changes were made.  See http://langui.sh/cdn-tools for more details.
    1818
    1919[View complete changelog](http://swearingscience.com/cdn-tools/ "CDN Tools Home").
     
    4646
    4747== Changelog ==
    48 =0.92 – 10/5/2009=
    49 *Major upgrade to support WP 2.8. If you are a previous user of CDN Tools you MUST unload files and then load them again. Please let me know if you have issues because several major changes were made.
     48= 0.93 - 10/8/2009 =
     49* A partial fix for issues with customers who have full file paths stored in their postmeta table.  This is not a complete fix, but should help some (most?) users.
    5050
    51 =0.81 – 5/17/2009=
    52 *Major upgrade to the initial load for attachments. Now done via AJAX with percentage progress.
    53 *Additional exception handling (this is still incomplete)
    54 *Upgrade to CF API 1.3.0.
    55 *Wordpress MU compatible (credit John Keyes)
     51= 0.92 – 10/5/2009 =
     52* Major upgrade to support WP 2.8. If you are a previous user of CDN Tools you MUST unload files and then load them again. Please let me know if you have issues because several major changes were made.
    5653
    57 =0.72 – 2/25/2009=
    58 *First public release, no changes from previous.
     54= 0.81 – 5/17/2009 =
     55* Major upgrade to the initial load for attachments. Now done via AJAX with percentage progress.
     56* Additional exception handling (this is still incomplete)
     57* Upgrade to CF API 1.3.0.
     58* Wordpress MU compatible (credit John Keyes)
    5959
    60 =0.72 – 2/22/2009=
    61 *Small bugfixes
    62 *WP Super Cache compatibility.
     60= 0.72 – 2/25/2009 =
     61* First public release, no changes from previous.
    6362
    64 =0.71 – 2/22/2009=
    65 *Workaround for a MIME/PHP bug on RHEL4.
     63= 0.72 – 2/22/2009 =
     64* Small bugfixes
     65* WP Super Cache compatibility.
    6666
    67 =0.7 – 2/17/2009=
    68 *Nearing completion of initial feature set.
    69 *UI rework (again)
     67= 0.71 – 2/22/2009 =
     68* Workaround for a MIME/PHP bug on RHEL4.
    7069
    71 =0.6 – 2/15/2009=
    72 *Huge improvements on all fronts
     70= 0.7 – 2/17/2009 =
     71* Nearing completion of initial feature set.
     72* UI rework (again)
    7373
    74 =0.4 – 2/8/2009=
    75 *Initial sideload support.
     74= 0.6 – 2/15/2009 =
     75* Huge improvements on all fronts
    7676
    77 =0.2 – 2/7/2009=
    78 *First release outside of my own work (seeded to Major Hayden).
    79 *GoogleAJAX for Prototype, jQuery, Dojo, and mootools (free for anyone to use)
    80 *Uploading JS to CloudFiles (only supported CDN presently)
    81 *Supports opting out of CDN’ing wp-admin scripts.
     77= 0.4 – 2/8/2009 =
     78* Initial sideload support.
     79
     80= 0.2 – 2/7/2009 =
     81* First release outside of my own work (seeded to Major Hayden).
     82* GoogleAJAX for Prototype, jQuery, Dojo, and mootools (free for anyone to use)
     83* Uploading JS to CloudFiles (only supported CDN presently)
     84* Supports opting out of CDN’ing wp-admin scripts.
    8285
    8386
  • cdn-tools/trunk/cdntools.php

    r160603 r161722  
    55Description: CDN Tools is a plugin designed to help you drastically speed up your blog's load time by loading content onto a distribution network.  You can use a commercial CDN or just load some of your larger JS libraries for free from Google's servers!  At this time Cloud Files is the only supported CDN.
    66Author: Paul Kehrer
    7 Version: 0.92
     7Version: 0.93
    88Author URI: http://langui.sh/
    99*/
     
    2828set_time_limit(300); //5 minutes max...
    2929
    30 define('CDNTOOLS_VERSION','0.92');
     30define('CDNTOOLS_VERSION','0.93');
    3131
    3232$dir_array = explode('/',dirname(__FILE__));
     
    138138                [height] => 150
    139139            )*/
    140         if(isset($metadata['sizes'])) {
     140        if(is_array($metadata) && isset($metadata['sizes'])) {
    141141            $file_array = explode('/',$metadata['file']);
    142142            foreach($metadata['sizes'] as $data) {
    143                 $file_array[2] = $data['file'];
    144                 $filepath = $this->wp_upload_basedir.'/'.implode('/',$file_array);
     143                array_pop($file_array);
     144                array_push($file_array,$data['file']);
     145                $filepath = $this->file_path(implode('/',$file_array));
    145146                $this->cdn_attachment_upload(0,$filepath); //pass a zero post_id since we don't know it and it doesn't matter.  post_id can't be removed from the function though since the hook passes it
    146147            }
     
    170171   
    171172    function cdn_media_url_rewrite($data) {
    172         if($this->cdntools_sideload_uploads == 1 && !empty($this->cdntools_baseuris)) {
    173             //only rewrite if the pref is set and the baseuris array isn't empty
     173        if($this->cdntools_sideload_uploads == 1 && !empty($this->cdntools_baseuris) && ($this->cdntools_primarycdn) ) {
     174            //only rewrite if the pref is set and the baseuris array isn't empty and they have a CDN selected
    174175            $file_upload_url = $this->wp_upload_url_path.'/';
    175176            $file_upload_url = str_replace('/','\/',str_replace('://','://(www.)?',$file_upload_url));
     
    241242            echo 'true';
    242243        }
     244    }
     245   
     246    //this function is mostl stolen from get_attached_file in post.php in wordpress.  it attempts to correct for absolute vs relative paths.
     247    //if the if conditional is met it's a relative path
     248    function file_path($file) {
     249        if ( 0 !== strpos($file, '/') && !preg_match('|^.:\\\|', $file) && ( ($uploads = wp_upload_dir()) && false === $uploads['error'] ) ) {
     250            $file = $uploads['basedir'] . "/$file";
     251        }
     252        return $file;
    243253    }
    244254
     
    270280                            $file_array = explode('/',$metadata['file']);
    271281                            foreach($metadata['sizes'] as $data) {
    272                                 $file_array[2] = $data['file'];
    273                                 $filepath = $this->wp_upload_basedir.'/'.implode('/',$file_array);
     282                                array_pop($file_array);
     283                                array_push($file_array,$data['file']);
     284                                $filepath = $this->file_path(implode('/',$file_array));
    274285                                $files_to_delete[] = $filepath;
    275286                            }
     
    298309        foreach($result as $attachment) {
    299310            //we only need the basedir from our upload info var
    300             $fullpath = $this->wp_upload_basedir.'/'.$attachment->meta_value;
     311            $fullpath = $this->file_path($attachment->meta_value);
    301312            $uploadinfo[] = array('post_id'=>$attachment->post_id,'path'=>$fullpath);
    302313           
     
    306317                $file_array = explode('/',$metadata['file']);
    307318                foreach($metadata['sizes'] as $data) {
    308                     $file_array[2] = $data['file'];
    309                     $filepath = $this->wp_upload_basedir.'/'.implode('/',$file_array);
     319                    array_pop($file_array);
     320                    array_push($file_array,$data['file']);
     321                    $filepath = $this->file_path(implode('/',$file_array));
    310322                    $uploadinfo[] = array('post_id'=>$attachment->post_id,'path'=>$filepath);
    311323                }
  • cdn-tools/trunk/readme.txt

    r160815 r161722  
    55Requires at least: 2.7
    66Tested up to: 2.8.4
    7 Stable tag: 0.92
     7Stable tag: 0.93
    88
    99CDN Tools is a plugin designed to help you drastically speed up your blog's load time by loading data onto a content distribution network (CDN).
     
    1313[CDN Tools](http://swearingscience.com/cdn-tools/ "CDN Tools Home") is a WordPress plugin that allows you to load javascript and media files to an external server to drastically speed page loads.  You can sideload data to a commercial CDN or just load your larger JS libraries (prototype, jquery) for **free** from Google's servers.  CDN Tools has been designed to be as easy to use as possible, so give it a shot!  Your blog's readers will thank you.  At this time the only commercial CDN supported is Cloud Files.  Check out the plugin homepage to view a screencast.
    1414
    15 New in 0.92
    16 
    17 *Major upgrade to support WP 2.8.  If you are a previous user of CDN Tools you <b>MUST</b> unload files and then load them again.  Please let me know if you have issues because several major changes were made.  See http://langui.sh/cdn-tools for more details.
     15= New in 0.92/0.93 =
     16* A partial fix for issues with customers who have full file paths stored in their postmeta table.  This is not a complete fix, but should help some (most?) users.
     17* Major upgrade to support WP 2.8.  If you are a previous user of CDN Tools you _MUST_ unload files and then load them again.  Please let me know if you have issues because several major changes were made.  See http://langui.sh/cdn-tools for more details.
    1818
    1919[View complete changelog](http://swearingscience.com/cdn-tools/ "CDN Tools Home").
     
    4646
    4747== Changelog ==
    48 =0.92 – 10/5/2009=
    49 *Major upgrade to support WP 2.8. If you are a previous user of CDN Tools you MUST unload files and then load them again. Please let me know if you have issues because several major changes were made.
     48= 0.93 - 10/8/2009 =
     49* A partial fix for issues with customers who have full file paths stored in their postmeta table.  This is not a complete fix, but should help some (most?) users.
    5050
    51 =0.81 – 5/17/2009=
    52 *Major upgrade to the initial load for attachments. Now done via AJAX with percentage progress.
    53 *Additional exception handling (this is still incomplete)
    54 *Upgrade to CF API 1.3.0.
    55 *Wordpress MU compatible (credit John Keyes)
     51= 0.92 – 10/5/2009 =
     52* Major upgrade to support WP 2.8. If you are a previous user of CDN Tools you MUST unload files and then load them again. Please let me know if you have issues because several major changes were made.
    5653
    57 =0.72 – 2/25/2009=
    58 *First public release, no changes from previous.
     54= 0.81 – 5/17/2009 =
     55* Major upgrade to the initial load for attachments. Now done via AJAX with percentage progress.
     56* Additional exception handling (this is still incomplete)
     57* Upgrade to CF API 1.3.0.
     58* Wordpress MU compatible (credit John Keyes)
    5959
    60 =0.72 – 2/22/2009=
    61 *Small bugfixes
    62 *WP Super Cache compatibility.
     60= 0.72 – 2/25/2009 =
     61* First public release, no changes from previous.
    6362
    64 =0.71 – 2/22/2009=
    65 *Workaround for a MIME/PHP bug on RHEL4.
     63= 0.72 – 2/22/2009 =
     64* Small bugfixes
     65* WP Super Cache compatibility.
    6666
    67 =0.7 – 2/17/2009=
    68 *Nearing completion of initial feature set.
    69 *UI rework (again)
     67= 0.71 – 2/22/2009 =
     68* Workaround for a MIME/PHP bug on RHEL4.
    7069
    71 =0.6 – 2/15/2009=
    72 *Huge improvements on all fronts
     70= 0.7 – 2/17/2009 =
     71* Nearing completion of initial feature set.
     72* UI rework (again)
    7373
    74 =0.4 – 2/8/2009=
    75 *Initial sideload support.
     74= 0.6 – 2/15/2009 =
     75* Huge improvements on all fronts
    7676
    77 =0.2 – 2/7/2009=
    78 *First release outside of my own work (seeded to Major Hayden).
    79 *GoogleAJAX for Prototype, jQuery, Dojo, and mootools (free for anyone to use)
    80 *Uploading JS to CloudFiles (only supported CDN presently)
    81 *Supports opting out of CDN’ing wp-admin scripts.
     77= 0.4 – 2/8/2009 =
     78* Initial sideload support.
     79
     80= 0.2 – 2/7/2009 =
     81* First release outside of my own work (seeded to Major Hayden).
     82* GoogleAJAX for Prototype, jQuery, Dojo, and mootools (free for anyone to use)
     83* Uploading JS to CloudFiles (only supported CDN presently)
     84* Supports opting out of CDN’ing wp-admin scripts.
    8285
    8386
Note: See TracChangeset for help on using the changeset viewer.