Plugin Directory

Changeset 186967


Ignore:
Timestamp:
12/25/2009 04:55:52 AM (16 years ago)
Author:
Phoenixheart
Message:

+ Version 1.1.2

  • Fix bug with custom ports
Location:
free-cdn
Files:
8 added
2 edited

Legend:

Unmodified
Added
Removed
  • free-cdn/trunk/free_cdn.php

    r180166 r186967  
    44Plugin URI: http://www.phoenixheart.net/wp-plugins/free-cdn
    55Description: This plugin rewrites your static files' URL's (JavaScripts, CSS, images etc.) so that they are served from <a href="http://www.coralcdn.org/">CoralCDN</a> - a free P2P Content Delivery Network - instead of your own server, thus saves lots of bandwidth and improves availability. REQUIRES PHP >= 5
    6 Version: 1.1.1
     6Version: 1.1.2
    77Author: Phoenixheart
    88Author URI: http://www.phoenixheart.net
     
    1414    {
    1515        var $name = 'free-cdn';
    16         var $version = '1.0.0';
     16        var $version = '1.0.2';
    1717        var $default_options = array(
    18             'version'   => '1.0.1',
     18            'version'   => '1.0.2',
    1919            'apply' => array(
    2020                'css'   => true,
     
    278278            {
    279279                // a candidate to rewrite
    280                 $current_domain = $this->get_url_domain($rewritten_url);
    281                 list($domain, $rest) = explode($current_domain, $rewritten_url, 2);
     280                $parts = parse_url($rewritten_url);
     281   
     282                if (isset($parts['port']))
     283                {
     284                    $parts['host'] .= ".$parts[port].nyud.net";
     285                    unset($parts['port']);
     286                }
     287                else
     288                {
     289                    $parts['host'] .= '.nyud.net';
     290                }
    282291               
    283                 $rewritten_url = "$current_domain.nyud.net$rest";
     292                $rewritten_url = $this->glue_url($parts);
     293               
    284294                if ($this->options['debug'])
    285295                {
     
    294304                       
    295305            return $original_url; // the url is not a candidate
    296         }
    297        
    298         /**
    299         * @desc     Gets the domain (http://www.example.com)
    300         *           from an url (http:///www.example.com/dir/file.html?q)
    301         */
    302         function get_url_domain($url)
    303         {
    304             $parts = parse_url($url);
    305             return $parts['scheme'] . '://' . $parts['host'];
    306306        }
    307307       
     
    357357            return $url;
    358358        }
     359       
     360        /**
     361        * @author ilja at radusch dot com
     362        * @param mixed $parsed
     363        */
     364        function glue_url($parsed)
     365        {
     366            if (!is_array($parsed))
     367            {
     368                return false;
     369            }
     370
     371            $uri = isset($parsed['scheme']) ? $parsed['scheme'].':'.((strtolower($parsed['scheme']) == 'mailto') ? '' : '//') : '';
     372            $uri .= isset($parsed['user']) ? $parsed['user'].(isset($parsed['pass']) ? ':'.$parsed['pass'] : '').'@' : '';
     373            $uri .= isset($parsed['host']) ? $parsed['host'] : '';
     374            $uri .= isset($parsed['port']) ? ':'.$parsed['port'] : '';
     375
     376            if (isset($parsed['path']))
     377            {
     378                $uri .= (substr($parsed['path'], 0, 1) == '/') ?
     379                    $parsed['path'] : ((!empty($uri) ? '/' : '' ) . $parsed['path']);
     380            }
     381
     382            $uri .= isset($parsed['query']) ? '?'.$parsed['query'] : '';
     383            $uri .= isset($parsed['fragment']) ? '#'.$parsed['fragment'] : '';
     384
     385            return $uri;
     386        }
    359387       
    360388        /**
  • free-cdn/trunk/readme.txt

    r180166 r186967  
    55Requires at least: 2.2
    66Tested up to: 3.0
    7 Stable tag: 1.1.1
     7Stable tag: 1.1.2
Note: See TracChangeset for help on using the changeset viewer.