No Right Click Images Plugin - Version 2.1

Version Description

  • Added option so that logged in users are allowed to copy images. Disables the plugin for logged in users. Captured copy to clipboard events to prevent another way of copying in some browsers. Fixed a problem in image replacement that prevented an image from being restored when another image was right clicked before the image times out.

=

Download this release

Release Info

Developer kpgraham
Plugin Icon wp plugin No Right Click Images Plugin
Version 2.1
Comparing to
See all releases

Code changes from version 2.0 to 2.1

no-right-click-images-plugin.php CHANGED
@@ -3,7 +3,7 @@
3
  Plugin Name: No Right Click Images Plugin
4
  Plugin URI: http://www.BlogsEye.com/
5
  Description: Uses Javascript to prevent right clicking of images to help keep leaches from copying images
6
- Version: 2.0
7
  Author: Keith P. Graham
8
  Author URI: http://www.BlogsEye.com/
9
 
@@ -25,12 +25,13 @@ function kpg_no_rc_img_fixup() {
25
  if (empty($options)||!is_array($options)) $options=array();
26
  $replace='N';
27
  $drag='Y';
 
28
  extract($options);
29
  if ($replace!='Y') $replace='N';
30
  if ($drag!='Y') $drag='N';
31
-
32
- // get the full url of the image
33
-
34
  $dir = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
35
  $img = addslashes($dir.'not.gif');
36
  $js = addslashes($dir.'no-right-click-images.js');
@@ -45,10 +46,12 @@ function kpg_no_rc_img_control() {
45
  if (empty($options)||!is_array($options)) $options=array();
46
  $replace='N';
47
  $drag='Y';
 
48
  extract($options);
49
  if ($replace!='Y') $replace='N';
50
  if (empty($drag)) $drag='Y';
51
  if ($drag!='Y') $drag='N';
 
52
  if (array_key_exists('kpg_no_rc_nonce',$_POST)&&wp_verify_nonce($_POST['kpg_no_rc_nonce'],'kpg_no_rc')) {
53
  // need to update replace
54
  if (array_key_exists('kpg_replace_image',$_POST)) {
@@ -61,10 +64,17 @@ function kpg_no_rc_img_control() {
61
  } else {
62
  $drag='N';
63
  }
 
 
 
 
 
64
  if ($replace!='Y') $replace='N';
65
  if ($drag!='Y') $drag='N';
 
66
  $options['replace']=$replace;
67
  $options['drag']=$drag;
 
68
  update_option('kpg_no_right_click_image', $options);
69
 
70
  }
@@ -113,6 +123,12 @@ function kpg_no_rc_img_control() {
113
  <td>Users may be able to drag an image to the desktop. If you wish to prevent this, check the box. If this conflicts with a plugin that uses drag and drop, you may wish to uncheck this.
114
  </td>
115
  </tr>
 
 
 
 
 
 
116
  </table>
117
  <p>
118
  <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
3
  Plugin Name: No Right Click Images Plugin
4
  Plugin URI: http://www.BlogsEye.com/
5
  Description: Uses Javascript to prevent right clicking of images to help keep leaches from copying images
6
+ Version: 2.1
7
  Author: Keith P. Graham
8
  Author URI: http://www.BlogsEye.com/
9
 
25
  if (empty($options)||!is_array($options)) $options=array();
26
  $replace='N';
27
  $drag='Y';
28
+ $allowforlogged='Y';
29
  extract($options);
30
  if ($replace!='Y') $replace='N';
31
  if ($drag!='Y') $drag='N';
32
+ if ($allowforlogged!='Y') $allowforlogged='N';
33
+ // if the user is logged in and the option is set, let them copy images
34
+ if ($allowforlogged=='Y' && is_user_logged_in() ) { return; }
35
  $dir = WP_PLUGIN_URL.'/'.str_replace(basename( __FILE__),"",plugin_basename(__FILE__));
36
  $img = addslashes($dir.'not.gif');
37
  $js = addslashes($dir.'no-right-click-images.js');
46
  if (empty($options)||!is_array($options)) $options=array();
47
  $replace='N';
48
  $drag='Y';
49
+ $allowforlogged='Y';
50
  extract($options);
51
  if ($replace!='Y') $replace='N';
52
  if (empty($drag)) $drag='Y';
53
  if ($drag!='Y') $drag='N';
54
+ if ($allowforlogged!='Y') $allowforlogged='N';
55
  if (array_key_exists('kpg_no_rc_nonce',$_POST)&&wp_verify_nonce($_POST['kpg_no_rc_nonce'],'kpg_no_rc')) {
56
  // need to update replace
57
  if (array_key_exists('kpg_replace_image',$_POST)) {
64
  } else {
65
  $drag='N';
66
  }
67
+ if (array_key_exists('kpg_allowforlogged',$_POST)) {
68
+ $allowforlogged=stripslashes($_POST['kpg_allowforlogged']);
69
+ } else {
70
+ $allowforlogged='N';
71
+ }
72
  if ($replace!='Y') $replace='N';
73
  if ($drag!='Y') $drag='N';
74
+ if ($allowforlogged!='Y') $allowforlogged='N';
75
  $options['replace']=$replace;
76
  $options['drag']=$drag;
77
+ $options['allowforlogged']=$allowforlogged;
78
  update_option('kpg_no_right_click_image', $options);
79
 
80
  }
123
  <td>Users may be able to drag an image to the desktop. If you wish to prevent this, check the box. If this conflicts with a plugin that uses drag and drop, you may wish to uncheck this.
124
  </td>
125
  </tr>
126
+ <tr>
127
+ <td>Allow for Logged Users</td>
128
+ <td><input type="checkbox" <?php if ($allowforlogged=='Y') {echo 'checked="true"';} ?>value="Y" name="kpg_allowforlogged"></td>
129
+ <td>You may wish to allow logged in users to copy images. You can do this by checking this box.
130
+ </td>
131
+ </tr>
132
  </table>
133
  <p>
134
  <input type="submit" name="Submit" class="button-primary" value="<?php _e('Save Changes') ?>" />
no-right-click-images.js CHANGED
@@ -1,6 +1,6 @@
1
  /**************************************************************************
2
  This javascript is used by the no-right-click-images plugin for wordpress.
3
- Version 2.0
4
  Please give credit as no-right-click-images.js by Keith P. Graham
5
  http://www.blogseye.com
6
  **************************************************************************/
@@ -145,7 +145,12 @@ function kpg_nrc1_mousedownAll(event) {
145
  return true;
146
  }
147
  function kpg_nrci_replace(targ) {
148
- if (kpg_nrci_targImg!=null && kpg_nrci_targImg.src==kpg_nrci_notimage.src) return;
 
 
 
 
 
149
  kpg_nrci_targImg=targ;
150
  if (kpg_nrci_extra!='Y') return;
151
  var w=targ.width+'';
@@ -182,10 +187,12 @@ function kpg_nrci_action(event) {
182
  try {
183
  document.onmousedown=function(event) { return kpg_nrc1_mousedownAll(event);}
184
  document.oncontextmenu=function(event) { return kpg_nrci_contextAll(event);}
 
185
  if (kpg_nrci_drag=='Y') document.ondragstart=function(event) { return kpg_nrci_dragdropAll(event);}
186
  var b=document.getElementsByTagName("IMG");
187
  for (var i = 0; i < b.length; i++) {
188
  b[i].oncontextmenu=function(event) { return kpg_nrci_context(event);}
 
189
  b[i].onmousedown=function(event) { return kpg_nrc1_mousedown(event);}
190
  if (kpg_nrci_drag=='Y') b[i].ondragstart=function(event) { return kpg_nrci_dragdrop(event);}
191
  }
@@ -208,6 +215,6 @@ if (typeof(kpg_nrci_image) == 'undefined' || kpg_nrci_image=='' || typeof(kpg_nr
208
  oldFunc();
209
  }
210
  kpg_nrci_action('load');
211
- };
212
  }
213
  }
1
  /**************************************************************************
2
  This javascript is used by the no-right-click-images plugin for wordpress.
3
+ Version 2.1
4
  Please give credit as no-right-click-images.js by Keith P. Graham
5
  http://www.blogseye.com
6
  **************************************************************************/
145
  return true;
146
  }
147
  function kpg_nrci_replace(targ) {
148
+ if (kpg_nrci_targImg!=null && kpg_nrci_targImg.src==kpg_nrci_notimage.src) {
149
+ // restore the old image before hiding this one
150
+ kpg_nrci_targImg.src=kpg_nrci_targSrc;
151
+ kpg_nrci_targImg=null;
152
+ kpg_nrci_targSrc=null;
153
+ }
154
  kpg_nrci_targImg=targ;
155
  if (kpg_nrci_extra!='Y') return;
156
  var w=targ.width+'';
187
  try {
188
  document.onmousedown=function(event) { return kpg_nrc1_mousedownAll(event);}
189
  document.oncontextmenu=function(event) { return kpg_nrci_contextAll(event);}
190
+ document.oncopy=function(event) { return kpg_nrci_contextAll(event);}
191
  if (kpg_nrci_drag=='Y') document.ondragstart=function(event) { return kpg_nrci_dragdropAll(event);}
192
  var b=document.getElementsByTagName("IMG");
193
  for (var i = 0; i < b.length; i++) {
194
  b[i].oncontextmenu=function(event) { return kpg_nrci_context(event);}
195
+ b[i].oncopy=function(event) { return kpg_nrci_context(event);}
196
  b[i].onmousedown=function(event) { return kpg_nrc1_mousedown(event);}
197
  if (kpg_nrci_drag=='Y') b[i].ondragstart=function(event) { return kpg_nrci_dragdrop(event);}
198
  }
215
  oldFunc();
216
  }
217
  kpg_nrci_action('load');
218
+ };
219
  }
220
  }
readme.txt CHANGED
@@ -2,9 +2,9 @@
2
  Tags: images, image, right click, stealing
3
  Donate link: http://www.amazon.com/gp/product/1456336584?ie=UTF8&tag=thenewjt30page&linkCode=as2&camp=1789&creative=390957&creativeASIN=1456336584
4
  Requires at least: 2.8
5
- Tested up to: 3.2.1
6
  Contributors: Keith Graham
7
- Stable tag: 2.0
8
 
9
  Disables right click context menu on images to help deter leeches from glomming images.
10
 
@@ -40,6 +40,9 @@ It is impossible to keep people from stealing images that appear in web pages, b
40
  = 2.0 =
41
  * Separated javascript into a loadable file. Added an option to replace images on right click in order to thwart FireFox users who choose to block javascript from controlling the context menu. Made drag and drop blocking optional.
42
 
 
 
 
43
  == Support ==
44
  This plugin is free and I expect nothing in return. Please rate the plugin at http://wordpress.org/extend/plugins/stop-spammer-registrations-plugin/.
45
  If you wish to support my programming, please buy my Science Fiction book. The Kindle version is less thana buck.
2
  Tags: images, image, right click, stealing
3
  Donate link: http://www.amazon.com/gp/product/1456336584?ie=UTF8&tag=thenewjt30page&linkCode=as2&camp=1789&creative=390957&creativeASIN=1456336584
4
  Requires at least: 2.8
5
+ Tested up to: 3.4beta
6
  Contributors: Keith Graham
7
+ Stable tag: 2.1
8
 
9
  Disables right click context menu on images to help deter leeches from glomming images.
10
 
40
  = 2.0 =
41
  * Separated javascript into a loadable file. Added an option to replace images on right click in order to thwart FireFox users who choose to block javascript from controlling the context menu. Made drag and drop blocking optional.
42
 
43
+ = 2.1 =
44
+ * Added option so that logged in users are allowed to copy images. Disables the plugin for logged in users. Captured copy to clipboard events to prevent another way of copying in some browsers. Fixed a problem in image replacement that prevented an image from being restored when another image was right clicked before the image times out.
45
+
46
  == Support ==
47
  This plugin is free and I expect nothing in return. Please rate the plugin at http://wordpress.org/extend/plugins/stop-spammer-registrations-plugin/.
48
  If you wish to support my programming, please buy my Science Fiction book. The Kindle version is less thana buck.