Plugin Directory

Changeset 675697


Ignore:
Timestamp:
03/03/2013 04:18:18 PM (13 years ago)
Author:
ewwink
Message:

upgrade 0.8

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

Legend:

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

    r673679 r675697  
    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.7
     6Version: 0.8
    77Author: ewwink
    88Author URI: http://www.cekpr.com/
     
    1818    }
    1919    if(!$attachment){
    20       $tryImage = preg_replace('/(-[0-9]{1,3})x[0-9]{1,3}\.(jpe?g|gif|png|ico)/i',".$2",$image_url);
     20      $tryImage = preg_replace('/(-[0-9]{1,3})x[0-9]{1,3}\.(jpe?g|gif|png)/i',".$2",$image_url);
    2121      $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts WHERE guid=%s;", $tryImage));
    2222      if(!$attachment){
     
    2929print <<<HTML
    3030<meta http-equiv="refresh" content="2;url=/">
    31 <script language="JavaScript" type="text/javascript">var t=setTimeout(function(){window.location=window.location.href.replace('get_image?','');},2000);</script>
     31<script language="JavaScript" type="text/javascript">var t=setTimeout(function(){window.location='http://'+window.location.hostname;},2000);</script>
    3232HTML;
    3333}
     
    4343  return $title;
    4444}
     45function gbdWatermark($fn){
     46  $m = getimagesize($fn);
     47  $mime = $m['mime'];
     48  $watermark = imagecreatefrompng(dirname(__FILE__).'/w.png');
     49  list($w, $h) = getimagesize($fn);
     50
     51  switch ($mime){
     52  case "image/jpeg":    $type = 'jpeg'; break;
     53  case "image/gif":     $type = 'gif';  break;
     54  case "image/png":     $type = 'png';  break;
     55  default:              $type = "jpeg";
     56  }
     57  $imageFrom = 'imagecreatefrom'.$type;
     58  $thumb = $imageFrom($fn)
     59  or die('Cannot Initialize new GD image stream');
     60
     61
     62  $createIM = 'imagecreatefrom'.$type;
     63  $readIM =  'image'.$type;
     64  $source = $createIM($fn);
     65  $newFN = basename($fn);
     66  $wmark = $createIM($fn);
     67  header("content-type: image/$type");
     68  header("Expires: 1 Jan 1990 00:00:00 GMT");
     69  header("Pragma: no-cache");
     70  header("Cache-control: no-cache");
     71  header("Cache-control: no-store");
     72  header("Cache-control: max-age=0, must-revalidate");
     73  header("Cache-control: pre-check=0,post-check=0", false);
     74  imagecopyresampled($wmark, $watermark, 0, 0, 0, 0, $w, $h, 400, 400);
     75  imagecopymerge($thumb, $wmark, 0, 0, 0, 0, $w, $h, 60);
     76  //$readIM($thumb,ABSPATH.'wp-content/gbd_cache/'.basename($fn));
     77  $readIM($thumb);
     78  imagedestroy($thumb);
     79  imagedestroy($wmark);
     80  imagedestroy($watermark);
     81 exit;
     82  //readfile(ABSPATH.'wp-content/gbd_cache/'.basename($fn));
     83
     84}
     85
    4586function Google_Image_Dance(){
    46  if(preg_match('/get_image?.*\.(jpe?g|gif|png|ico)$/i',$_SERVER['REQUEST_URI'])){
    47    $getImg = str_ireplace('get_image?','',$_SERVER['REQUEST_URI']);
     87  if(preg_match('/gbd_watermark\?.*\.(jpe?g|gif|png)$/i',$_SERVER['REQUEST_URI'])){
     88    if (!is_dir(ABSPATH.'wp-content/gbd_cache')){mkdir((ABSPATH.'wp-content/gbd_cache'));}
     89    $wImage =  ABSPATH.str_ireplace('/gbd_watermark?','',$_SERVER['REQUEST_URI']);
     90    gbdWatermark($wImage);
     91  }
     92   if(preg_match('/get_image?.*\.(jpe?g|gif|png)$/i',$_SERVER['REQUEST_URI'])){
     93  $getImg = str_ireplace('wp2/get_image?','',$_SERVER['REQUEST_URI']);
    4894  if(cekpr_image_id(get_site_url().$getImg)){
     95    $GattachId = get_permalink(cekpr_image_id(get_site_url().$getImg));
     96    $GoriUrl = get_site_url().$getImg;
    4997    $GpId = cekpr_image_id(get_site_url().$getImg);
    5098    $GaUrl = get_post($GpId);
    5199    $GPostId = get_permalink($GaUrl->post_parent);
    52     if(isset($GPostId)){
     100    if($GPostId){
    53101      header("HTTP/1.1 301 Moved Permanently");
    54102      header("Location: $GPostId");
    55103      exit;
    56104    }
     105    if($GattachId){
     106      header("HTTP/1.1 301 Moved Permanently");
     107      header("Location: $GattachId");
     108      exit;
     109      }
    57110  }
    58     else{
    59       add_filter('wp_title', 'GID_not_found');
    60       meta_redir();
    61     }
     111  else{
     112    add_filter('wp_title', 'GID_not_found');
     113    meta_redir();
    62114  }
    63115}
    64 add_action('init','Google_Image_Dance',1);
     116}
     117function gbd_create_menu() {
     118  add_menu_page('GBD htaccess Editor', 'GBD htaccess Editor', 'administrator', __FILE__, 'gbd_editor', '');
     119}
     120function gbd_activate(){
     121  $rules = array();
     122  $rules[] = 'RewriteEngine on';
     123  $rules[] = 'RewriteBase /';
     124  $rules[] = 'RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|png)$ [NC]';
     125  $rules[] = 'RewriteCond %{HTTP_REFERER} ^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/blank.html$ [NC]';
     126  $rules[] = 'RewriteCond %{HTTP_REFERER} !^$ [NC]';
     127  $rules[] = 'RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC]';
     128  $rules[] = 'RewriteRule ^(wp-content.*)$ /gbd_watermark?$1 [R=302,L]';
     129  $rules[] = '';
     130  $rules[] = 'RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|png)$ [NC]';
     131  $rules[] = 'RewriteCond %{HTTP_REFERER} !^$ [NC]';
     132  $rules[] = 'RewriteCond %{HTTP_REFERER} !^'.site_url().'/.*$ [NC]';
     133  $rules[] = 'RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC]';
     134  $rules[] = 'RewriteRule ^(wp-content.*)$ /get_image?$1 [R=302,L]';
     135
     136  add_htaccess($rules);
     137}
     138
     139register_activation_hook( __FILE__, 'gbd_activate' );
     140
     141function add_htaccess($rule) {
     142    $htaccess_file = ABSPATH.'.htaccess';
     143    return insert_with_markers($htaccess_file, 'Google Break Dance', (array) $rule);
     144}
     145
     146register_deactivation_hook( __FILE__, 'gbd_deactivate' );
     147
     148function gbd_deactivate() {
     149    $htaccess_file = ABSPATH.'.htaccess';
     150    insert_with_markers($htaccess_file, 'Google Break Dance', "");
     151}
     152
     153if (is_admin()){
     154  if(isset($_POST['htaccess'])){
     155    $htFile = ABSPATH.'.htaccess';
     156    if (get_magic_quotes_gpc()){
     157      $htContent = stripslashes($_POST['htaccess']);
     158    }
     159    else{
     160      $htContent = $_POST['htaccess'];
     161    }
     162    $handle = fopen($htFile, 'w') or die('Cannot open file:  '.$htFile);
     163    fwrite($handle, $htContent);
     164    fclose($handle);
     165  }
     166}
     167
     168function gbd_editor() {
     169$htaccess = ABSPATH.'.htaccess';
     170$handle = fopen($htaccess, 'r');
     171$data = fread($handle,filesize($htaccess));
     172?>
     173<div class="wrap">
     174<h2>GBD .htaccess Editor</h2>
     175<?php if (!is_writable($htaccess)){
     176  echo '<p style="font-weight:bold;color:red;">.htaccess is not writable!</p>';
     177  }
     178  else{
     179    echo "be careful editing .htaccess can make your system error, use at your own risk.";
     180  }
     181?>
     182<form method="post" action="">
     183<textarea style="width: 650px; height: 450px;" name="htaccess" <?php if (!is_writable($htaccess)){echo 'disabled="disabled"';} ?>>
     184<?php echo $data; ?>
     185</textarea>
     186    <p class="submit">
     187    <input type="submit" class="button-primary" value="Save Changes" />
     188    </p>
     189</form>
     190
     191</div>
     192
     193<?php }
     194add_action('admin_menu', 'gbd_create_menu');
     195add_action('init','Google_Image_Dance');
    65196add_action('wp_head', 'break_frames_js');
    66197
    67 
    68198?>
  • google-break-dance/trunk/readme.txt

    r674420 r675697  
    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.7 =
    19 - ditambahkan JS Google Frame Breaker karena Gogle eropa masih menggunakan Layout lama.
    20 - fix headers already sent, sori ada yg lupa kehapus hehe...
    21 = v 0.6 =
    22 - fix headers already sent
    23 = v 0.5 =
    24 - fix no referer, no redirect.
    25 - tidak redirect thumbnail dihalaman google search
    26 - fix redirect untuk gambar yg non full size seperti, http://blog/uploads/image-100x100.png
     18= FITUR =
     19- Redirect otomatis gambar ukuran full, medium, smalll ke postingan
     20- Menambahkan Watermark dihalaman google image search
     21- Frame Breaker untuk Google Image Eropa
     22- GBD htaccess Editor
     23- Tidak Redirect image ke post jika yg akses adalah BOT (Googlebot, Bingbot, slurp, dll..) sehingga gambar bisa di index oleh Bot.
     24- Tidak redirect jika no Referer
    2725
    28 = *** Penting: untuk v 0.7 edit lagi .htaccess menjadi seperti dibawah =
     26= Perubahan terakhir =
     27= 0.8 =
     28- fitur baru, watermark dihalaman google image search
     29- Auto edit htaccess saat diaktifkan
     30- ditambahkan GBD htaccess Editor
     31- fix browser cache
    2932
     33
     34
     35= Instruksi singkat =
     36- Tidak perlu lagi mengedit file .htaccess karena sudah otomatis akan tetapi jika sudah pernah edit .htaccess sebelumnya maka pastikan harus seperti dibawah
    3037<code>
    31 RewriteEngine On
    32 RewriteBase /
    33 RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|jpeg|png)$ [NC]
    34 RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC]
    35 RewriteCond %{HTTP_REFERER} !^$ [NC]
    36 RewriteCond %{HTTP_REFERER} !^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/blank.html$ [NC]
    37 RewriteCond %{HTTP_REFERER} !^http://(www.)?cekpr.com/.*$ [NC]
    38 RewriteRule ^(.*)$ /get_image?$1 [R=302,L]
    39 
    4038# BEGIN WordPress
    4139<IfModule mod_rewrite.c>
     
    4846</IfModule>
    4947# END WordPress
     48
     49# BEGIN Google Break Dance
     50RewriteEngine on
     51RewriteBase /
     52RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|png)$ [NC]
     53RewriteCond %{HTTP_REFERER} ^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/blank.html$ [NC]
     54RewriteCond %{HTTP_REFERER} !^$ [NC]
     55RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC]
     56RewriteRule ^(wp-content.*)$ /gbd_watermark?$1 [R=302,L]
     57
     58RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|png|ico)$ [NC]
     59RewriteCond %{HTTP_REFERER} !^$ [NC]
     60RewriteCond %{HTTP_REFERER} !^http://www.nama-domain-ente.com/.*$ [NC]
     61RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC]
     62RewriteRule ^(wp-content.*)$ /get_image?$1 [R=302,L]
     63# END Google Break Dance
    5064</code>
    5165
    52 = Instruksi singkat =
    53 - Ganti <strong>cekpr.com</strong> dengan nama domain ente
    5466- Klo ingin menambahkan lebih banyak bot yg tidak ingin diredirect ke post atau supaya image di index karena default hanya yg mengandung kata "bot" (Googlebot, Bingbot, dll...) dan yahoo Slurp edit baris <strong>!(.\*bot.\*|slurp)</strong> menjadi seperti <strong>!(.\*bot.\*|slurp|kamu|ente|maneh|anda|lu|sia)</strong>
    55 - Untuk merubah .htaccess melalui Dashboard pake plugin WP Htaccess Editor/
     67- Untuk merubah .htaccess melalui Dashboard bisa pake pake plugin GBD Htaccess Editor
     68
     69= SS =
     70
     71/assets/screenshot-1.png
     72<br >* Tampilan di Google Image Search
     73
     74/assets/screenshot-2.png
     75<br >* tampilan GBD .htaccess Editor
     76
    5677== Installation ==
    5778
     
    94115
    95116== Screenshots ==
     117/assets/screenshot-1.png
     118<br >* Tampilan di Google Image Search
    96119
    97 nda ada
     120/assets/screenshot-2.png
     121<br >* tampilan GBD .htaccess Editor
     122
    98123== Upgrade Notice ==
    99124ganti semua filenya dengan yg terbaru.
    100125
    101126== Changelog ==
     127= 0.8 =
     128- fitur baru, watermark dihalaman google image search
     129- Auto edit htaccess saat diaktifkan
     130- ditambahkan GBD .htaccess Editor
     131- fix browser cache
    102132= 0.7 =
    103133- ditambahkan Google Frame Breaker karena Gogle eropa masih menggunakan Layout lama
Note: See TracChangeset for help on using the changeset viewer.