Plugin Directory

Changeset 517231


Ignore:
Timestamp:
03/10/2012 02:45:10 PM (14 years ago)
Author:
ihacklog
Message:

corrected the logic to check if a url is remote or not.

Location:
hacklog-remote-image-autosave/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • hacklog-remote-image-autosave/trunk/hacklog-remote-image-autosave.php

    r517177 r517231  
    22/*
    33Plugin Name: Hacklog Remote Image Autosave
    4 Version: 2.0.3
     4Version: 2.0.4
    55Plugin URI: http://ihacklog.com/?p=5087
    66Description: save remote images in the posts to local server and add it as an attachment to the post.
     
    2525class hacklog_remote_image_autosave
    2626{
    27     const VERSION = 'Hacklog Remote Image Autosave 2.0.3';
     27    const VERSION = 'Hacklog Remote Image Autosave 2.0.4';
    2828    const textdomain = 'hacklog_remote_image_autosave';
    2929    const opt = 'hacklog_ria_auto_down';
  • hacklog-remote-image-autosave/trunk/readme.txt

    r517176 r517231  
    55Requires at least: 3.2.1
    66Tested up to: 3.3.1
    7 Stable tag: 2.0.3
     7Stable tag: 2.0.4
    88
    99save remote images in the posts to local server and add it as an attachment to the post.
     
    4444== Changelog ==
    4545
     46= 2.0.4 =
     47* fixed: corrected the logic to check if a url is remote or not.
     48
    4649= 2.0.3 =
    4750* improved: get PHP execution timeout errors being caught.
  • hacklog-remote-image-autosave/trunk/util.class.php

    r517176 r517231  
    3232    }
    3333   
     34    /**
     35     * check if the url is a remote image resource.
     36     * @param unknown_type $url
     37     */
    3438    static function is_remote_file($url) {
    35         $home_url = home_url ( '/' );
    36         $is_remote_file = FALSE;
     39        $upload_dir = wp_upload_dir();
     40        $local_baseurl = $upload_dir['baseurl'];
    3741        $my_remote_baseurl = '';
    3842        // Compatible with Hacklog Remote Attachment plugin
     
    4145            $my_remote_baseurl = $hacklogra_opt ['remote_baseurl'];
    4246        }
     47        //Hacklog Remote Attachment upyun
     48        if (class_exists ( 'hacklogra_upyun' )) {
     49            $hacklogra_opt = get_option ( hacklogra_upyun::opt_primary );
     50            $my_remote_baseurl = $hacklogra_opt ['remote_baseurl'];
     51        }       
    4352        // var_dump( ( 0 !== stripos($url,$home_url) ) );
    44         if (0 !== stripos ( $url, $home_url )) {
    45             $is_remote_file = TRUE;
    46         } elseif (! empty ( $my_remote_baseurl ) && (stripos ( $url, $my_remote_baseurl ) === FALSE)) {
    47             $is_remote_file = TRUE;
    48         }
    49         return $is_remote_file;
     53        if( 0 === stripos ( $url, $local_baseurl ) )
     54        {
     55            return FALSE;
     56        }
     57       
     58        if( !empty( $my_remote_baseurl ) && ( 0 === stripos( $url, $my_remote_baseurl ) ) )
     59        {
     60            return FALSE;
     61        }
     62        return TRUE;
    5063    }
    5164   
Note: See TracChangeset for help on using the changeset viewer.