Plugin Directory

Changeset 671064


Ignore:
Timestamp:
02/21/2013 08:04:41 AM (13 years ago)
Author:
ewwink
Message:

fix redirect image thumbnails

Location:
google-break-dance
Files:
4 added
2 edited

Legend:

Unmodified
Added
Removed
  • google-break-dance/trunk/google-break-dance.php

    r670785 r671064  
    44Plugin URI: http://wordpress.org/extend/plugins/google-break-dance/
    55Description: Image tidak lagi terindek Google? <a href="http://wordpress.org/extend/plugins/google-break-dance/" target="_blank">EDIT .htaccess menjadi seperti ini</a>. Redirect Visitor dari Google image ke langsung halaman Post, jangan lupa edit file <b>.htaccess</b> sebelum menggunakan Plugin ini. Oh iya klo berguna, kapan2 jgn lupa cendolnya buat <strong><a href="http://www.cekpr.com">cekPR.com</a></strong> heheh...
    6 Version: 0.4
     6Version: 0.5
    77Author: ewwink
    88Author URI: http://www.cekpr.com/
     
    1717        $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='" . $image_url . "';"));
    1818    }
     19    if(!isset($attachment[0])){
     20      $tryImage = preg_replace('/(-[0-9]{1,3})x[0-9]{1,3}\.(jpe?g|gif|png|ico)/i',".$2",$image_url);
     21      $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts WHERE guid=%s;", $tryImage));
     22      if(!$attachment){
     23        $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts" . " WHERE guid='" . $tryImage . "';"));
     24      }
     25    }
    1926    return $attachment[0];
    2027}
     28
    2129function Google_Image_Dance(){
    2230 if(preg_match('/get_image?.*\.(jpe?g|gif|png|ico)$/i',$_SERVER['REQUEST_URI'])){
    23   $getImg = str_ireplace('get_image?','',$_SERVER['REQUEST_URI']);
     31   $getImg = str_ireplace('get_image?','',$_SERVER['REQUEST_URI']);
     32   echo get_site_url().$getImg;
    2433  if(cekpr_image_id(get_site_url().$getImg)){
    2534    $GattachId = get_permalink(cekpr_image_id(get_site_url().$getImg));
    26     $GoriUrl = get_site_url().$getImg;
    2735    $GpId = cekpr_image_id(get_site_url().$getImg);
    2836    $GaUrl = get_post($GpId);
    2937    $GPostId = get_permalink($GaUrl->post_parent);
    30     if($GPostId){
     38    if(isset($GPostId)){
    3139      header("HTTP/1.1 301 Moved Permanently");
    3240      header("Location: $GPostId");
     
    3442    }
    3543    else{
    36       if($GattachId){
    37         header("HTTP/1.1 301 Moved Permanently");
    38         header("Location: $GattachId");
    39         exit;
    40       }
    41       else{
    42         header("HTTP/1.1 301 Moved Permanently");
    43         header("Location: $GoriUrl");
    44         exit;
    45       }
     44      header("HTTP/1.1 301 Moved Permanently");
     45      header("Location: $GattachId");
     46      exit;
    4647    }
    4748  }
     49  }
    4850}
    49 
    5051add_action('init','Google_Image_Dance',1);
    5152
  • google-break-dance/trunk/readme.txt

    r670832 r671064  
    1616Saat visitor klik link "Lihat Gambar Asli" di halaman Google search image maka URLnya akan dialihkan / Redirect langsung halaman Post dimana image tersebut berada.
    1717sebelum menginstall plugin ini jangan lupa  masukan baris text berikut ke paling atas file <b>.htaccess</b>  : <br /><br />
     18= v 0.5 =
     19- fix no referer, no redirect
     20- tidak redirect thumbnail dihalaman google search
     21- fix redirect untuk gambar yg non full size seperti, http://blog/uploads/image-100x100.png
    1822
    19 = *** Penting: untuk v 0.4 edit lagi .htaccess menjadi seperti dibawah supaya BOT tidak diredirect ke post dan menghilangkan error ketika tidak ada referer =
     23= *** Penting: untuk v 0.5 edit lagi .htaccess menjadi seperti dibawah =
    2024
    2125<code>
     
    2428RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|jpeg|png)$ [NC]
    2529RewriteCond %{HTTP_USER_AGENT} !.*bot.* [NC]
     30RewriteCond %{HTTP_REFERER} !^$ [NC]
     31RewriteCond %{HTTP_REFERER} !^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/blank.html$ [NC]
    2632RewriteCond %{HTTP_REFERER} !^http://(www.)?cekpr.com/.*$ [NC]
    2733RewriteRule ^(.*)$ /get_image?$1 [R=302,L]
     
    5258RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|jpeg|png)$ [NC]
    5359RewriteCond %{HTTP_USER_AGENT} !.*bot.* [NC]
     60RewriteCond %{HTTP_REFERER} !^$ [NC]
     61RewriteCond %{HTTP_REFERER} !^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/blank.html$ [NC]
    5462RewriteCond %{HTTP_REFERER} !^http://(www.)?cekpr.com/.*$ [NC]
    5563RewriteRule ^(.*)$ /get_image?$1 [R=302,L]
     
    6977*<i>ganti cekpr.com dengan nama domain ente</i>
    7078
    71 = Perubahan versi Plugin =
    72 
    73 = 0.4 =
    74 perubahan pada .htaccess supaya jangan redirect Bot ke post, tambahkan <br  />
    75 <strong>RewriteCond %{HTTP_USER_AGENT} !.\*bot.\* [NC]</strong>
    76 = 0.3 =
    77 Fix $wpdb Compability
    78 = 0.2 =
    79 fix $wpdb
    80 = 0.1 =
    81 test release
    82 
    8379
    8480== Frequently Asked Questions ==
     
    9591
    9692== Changelog ==
    97 
     93= 0.5 =
     94- fix no referer, no redirect
     95- tidak redirect thumbnail dihalaman google search
     96- fix redirect untuk gambar yg non full size seperti, http://blog/uploads/image-100x100.png
    9897= 0.4 =
    9998perubahan pada .htaccess supaya jangan redirect Bot Bot ke post, tambahkan <br  />
Note: See TracChangeset for help on using the changeset viewer.