Changeset 675697
- Timestamp:
- 03/03/2013 04:18:18 PM (13 years ago)
- Location:
- google-break-dance
- Files:
-
- 6 added
- 2 edited
-
assets/screenshot-1.png (added)
-
assets/screenshot-2.png (added)
-
tags/0.8 (added)
-
tags/0.8/google-break-dance.php (added)
-
tags/0.8/index.php (added)
-
tags/0.8/readme.txt (added)
-
trunk/google-break-dance.php (modified) (4 diffs)
-
trunk/readme.txt (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
google-break-dance/trunk/google-break-dance.php
r673679 r675697 4 4 Plugin URI: http://wordpress.org/extend/plugins/google-break-dance/ 5 5 Description: 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. 76 Version: 0.8 7 7 Author: ewwink 8 8 Author URI: http://www.cekpr.com/ … … 18 18 } 19 19 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); 21 21 $attachment = $wpdb->get_col($wpdb->prepare("SELECT ID FROM " . $prefix . "posts WHERE guid=%s;", $tryImage)); 22 22 if(!$attachment){ … … 29 29 print <<<HTML 30 30 <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> 32 32 HTML; 33 33 } … … 43 43 return $title; 44 44 } 45 function 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 45 86 function 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']); 48 94 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; 49 97 $GpId = cekpr_image_id(get_site_url().$getImg); 50 98 $GaUrl = get_post($GpId); 51 99 $GPostId = get_permalink($GaUrl->post_parent); 52 if( isset($GPostId)){100 if($GPostId){ 53 101 header("HTTP/1.1 301 Moved Permanently"); 54 102 header("Location: $GPostId"); 55 103 exit; 56 104 } 105 if($GattachId){ 106 header("HTTP/1.1 301 Moved Permanently"); 107 header("Location: $GattachId"); 108 exit; 109 } 57 110 } 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(); 62 114 } 63 115 } 64 add_action('init','Google_Image_Dance',1); 116 } 117 function gbd_create_menu() { 118 add_menu_page('GBD htaccess Editor', 'GBD htaccess Editor', 'administrator', __FILE__, 'gbd_editor', ''); 119 } 120 function 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 139 register_activation_hook( __FILE__, 'gbd_activate' ); 140 141 function add_htaccess($rule) { 142 $htaccess_file = ABSPATH.'.htaccess'; 143 return insert_with_markers($htaccess_file, 'Google Break Dance', (array) $rule); 144 } 145 146 register_deactivation_hook( __FILE__, 'gbd_deactivate' ); 147 148 function gbd_deactivate() { 149 $htaccess_file = ABSPATH.'.htaccess'; 150 insert_with_markers($htaccess_file, 'Google Break Dance', ""); 151 } 152 153 if (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 168 function 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 } 194 add_action('admin_menu', 'gbd_create_menu'); 195 add_action('init','Google_Image_Dance'); 65 196 add_action('wp_head', 'break_frames_js'); 66 197 67 68 198 ?> -
google-break-dance/trunk/readme.txt
r674420 r675697 16 16 Saat visitor klik link "Lihat Gambar Asli" di halaman Google search image maka URLnya akan dialihkan / Redirect langsung halaman Post dimana image tersebut berada. 17 17 sebelum 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 27 25 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 29 32 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 30 37 <code> 31 RewriteEngine On32 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 40 38 # BEGIN WordPress 41 39 <IfModule mod_rewrite.c> … … 48 46 </IfModule> 49 47 # END WordPress 48 49 # BEGIN Google Break Dance 50 RewriteEngine on 51 RewriteBase / 52 RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|png)$ [NC] 53 RewriteCond %{HTTP_REFERER} ^http://www.google.[a-z]{2,4}(.[a-z]{2,4})?/blank.html$ [NC] 54 RewriteCond %{HTTP_REFERER} !^$ [NC] 55 RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC] 56 RewriteRule ^(wp-content.*)$ /gbd_watermark?$1 [R=302,L] 57 58 RewriteCond %{REQUEST_URI} wp-content/uploads/.*\.(gif|jpg|png|ico)$ [NC] 59 RewriteCond %{HTTP_REFERER} !^$ [NC] 60 RewriteCond %{HTTP_REFERER} !^http://www.nama-domain-ente.com/.*$ [NC] 61 RewriteCond %{HTTP_USER_AGENT} !(.*bot.*|slurp) [NC] 62 RewriteRule ^(wp-content.*)$ /get_image?$1 [R=302,L] 63 # END Google Break Dance 50 64 </code> 51 65 52 = Instruksi singkat =53 - Ganti <strong>cekpr.com</strong> dengan nama domain ente54 66 - 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 56 77 == Installation == 57 78 … … 94 115 95 116 == Screenshots == 117 /assets/screenshot-1.png 118 <br >* Tampilan di Google Image Search 96 119 97 nda ada 120 /assets/screenshot-2.png 121 <br >* tampilan GBD .htaccess Editor 122 98 123 == Upgrade Notice == 99 124 ganti semua filenya dengan yg terbaru. 100 125 101 126 == 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 102 132 = 0.7 = 103 133 - ditambahkan Google Frame Breaker karena Gogle eropa masih menggunakan Layout lama
Note: See TracChangeset
for help on using the changeset viewer.