PluginProbe
CryptX / 2.6.6
CryptX v2.6.6
4.2.1 4.2.0 4.1.1 trunk 1.0 1.1 1.2 1.3 1.4 1.5 1.6 1.7 1.9 2.0 2.1 2.2 2.3 2.3.1 2.3.2 2.3.3 2.4.0 2.4.1 2.4.2 2.4.3 2.4.4 All 93 releases
← All changes | cryptx.php +352 -88 2.4.12.6.6 View file →
@@ -2,11 +2,12 @@
2 2 /*
3 3 Plugin Name: CryptX
4 4 Plugin URI: http://weber-nrw.de/wordpress/cryptx/
5 5 Description: No more SPAM by spiders scanning you site for email adresses. With CryptX you can hide all your email adresses, with and without a mailto-link, by converting them using javascript or UNICODE. Although you can choose to add a mailto-link to all unlinked email adresses with only one klick at the settings. That's great, isn't it?
6 -Version: 2.4.1
6 +Version: 2.6.6
7 7 Author: Ralf Weber
8 8 Author URI: http://weber-nrw.de/
9 +Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696
9 10 */
10 11
11 12 /////////////////////////////////////////////////////////////////////////////
12 13
@@ -22,10 +23,14 @@
22 23 */
23 24 if (!class_exists('cryptX')) {
24 25
25 26 /////////////////////////////////////////////////////////////////////////////
27 +// plugin definitions
28 +define( 'CRYPTX_BASENAME', plugin_basename( __FILE__ ) );
29 +define( 'CRYPTX_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) );
30 +define( 'CRYPTX_FILENAME', str_replace( CRYPTX_BASEFOLDER.'/', '', plugin_basename(__FILE__) ) );
26 31
27 -load_plugin_textdomain('cryptx', PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . '/languages');
32 +load_plugin_textdomain('cryptx', sprintf('%s/cryptx/languages', PLUGINDIR ));
28 33
29 34 $cryptX_var = (array) get_option('cryptX');
30 35
31 36 /**
@@ -44,9 +49,9 @@
44 49 * This constructor attaches the needer plugin hook callbacks
45 50 */
46 51 function cryptX() {
47 52
48 - global $cryptX_var;
53 + global $cryptX_var, $wp_version;
49 54
50 55 // attach the converstion handlers
51 56 //
52 57 if (@$cryptX_var[theContent]) {
@@ -57,8 +62,11 @@
57 62 }
58 63 if (@$cryptX_var[commentText]) {
59 64 $this->filter('comment_text');
60 65 }
66 + if (@$cryptX_var[widgetText]) {
67 + $this->filter('widget_text');
68 + }
61 69
62 70 // attach to admin menu
63 71 //
64 72 if (is_admin()) {
@@ -82,56 +90,161 @@
82 90
83 91 // attach javascript to Header
84 92 //
85 93 if (@$cryptX_var[java]) {
86 - add_action(
87 - 'wp_head',
88 - array(&$this, 'header')
89 - );
94 + if (@$cryptX_var[load_java]) {
95 + add_action(
96 + 'wp_footer',
97 + array(&$this, 'header'),
98 + 9
99 + );
100 + } else {
101 + add_action(
102 + 'wp_head',
103 + array(&$this, 'header'),
104 + 9
105 + );
90 106 }
107 + }
91 108
92 - add_action('admin_menu',
93 - array(&$this, 'cryptx_meta_box')
94 - );
109 + if (@$cryptX_var[metaBox]) {
110 + add_action('admin_menu',
111 + array(&$this, 'cryptx_meta_box')
112 + );
113 +
114 + add_action('wp_insert_post',
115 + array(&$this, 'cryptx_insert_post')
116 + );
117 + add_action('wp_update_post',
118 + array(&$this, 'cryptx_insert_post')
119 + );
120 + }
121 +
122 + // Add FAQ and support information
123 + if ( version_compare( $wp_version, '2.8', '>' ) ) {
124 + add_filter( 'plugin_row_meta', array($this, 'init_row_meta'), 10, 2 ); // only 2.8 and higher
125 + } else {
126 + add_filter( 'plugin_action_links', array($this, 'init_row_meta'), 10, 2 );
127 + }
128 +
129 + // Add tinyurl for image action
130 + add_filter( 'init', array($this, 'init_tinyurl'));
131 + } // End function
95 132
96 - add_action('wp_insert_post',
97 - array(&$this, 'cryptx_insert_post')
98 - );
99 - add_action('wp_update_post',
100 - array(&$this, 'cryptx_insert_post')
101 - );
133 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
102 134
103 - } // End function
135 + function init_tinyurl() {
136 + global $cryptX_var;
137 + // check TinyURl
138 + $url = $_SERVER["REQUEST_URI"];
139 + $params = explode( '/', $url );
140 + if ( count( $params ) > 1 ) {
141 + $tiny_url = $params[count( $params ) -2];
142 + if ( $tiny_url == md5( get_bloginfo('url') ) ) {
143 + // define vars
144 + $font = $cryptX_var[c2i_font];
145 + $msg = $params[count( $params ) -1];
146 + $size = $cryptX_var[c2i_fontSize];
147 + $pad = 1;
148 + $transparent = 1;
149 + $red = hexdec(substr($cryptX_var[c2i_fontRGB],0,2));
150 + $grn = hexdec(substr($cryptX_var[c2i_fontRGB],2,2));
151 + $blu = hexdec(substr($cryptX_var[c2i_fontRGB],4,2));
152 + $bg_red = 255 - $red;
153 + $bg_grn = 255 - $grn;
154 + $bg_blu = 255 - $blu;
155 + $width = 0;
156 + $height = 0;
157 + $offset_x = 0;
158 + $offset_y = 0;
159 + $bounds = array();
160 + $image = "";
161 + // get the font height.
162 + $bounds = ImageTTFBBox($size, 0, $font, "W");
163 + if ($rot < 0)
164 + {
165 + $font_height = abs($bounds[7]-$bounds[1]);
166 + }
167 + else if ($rot > 0)
168 + {
169 + $font_height = abs($bounds[1]-$bounds[7]);
170 + }
171 + else
172 + {
173 + $font_height = abs($bounds[7]-$bounds[1]);
174 + }
175 + // determine bounding box.
176 + $bounds = ImageTTFBBox($size, 0, $font, $msg);
177 + $width = abs($bounds[4]-$bounds[6]);
178 + $height = abs($bounds[7]-$bounds[1]);
179 + $offset_y = $font_height+abs(($height - $font_height)/2)-1;
180 + $offset_x = 0;
181 + $image = imagecreatetruecolor($width+($pad*2),$height+($pad*2));
182 + imagesavealpha($image, true);
183 + //$background = ImageColorAllocate($image, $bg_red, $bg_grn, $bg_blu);
184 + $foreground = ImageColorAllocate($image, $red, $grn, $blu);
185 + $background = imagecolorallocatealpha($image, 0, 0, 0, 127);
186 + imagefill($image, 0, 0, $background);
187 + // render the image
188 + ImageTTFText($image, $size, 0, $offset_x+$pad, $offset_y+$pad, $foreground, $font, $msg);
189 + // output PNG object.
190 + Header("Content-type: image/png");
191 + imagePNG($image);
192 + die;
193 + }
194 + }
195 + }
104 196
105 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
197 + function init_row_meta($links, $file) {
198 + if (CRYPTX_BASENAME == $file) {
199 + return array_merge(
200 + $links,
201 + array(
202 + sprintf(
203 + '<a href="options-general.php?page=%s">%s</a>',
204 + CRYPTX_BASENAME,
205 + __('Settings')
206 + )
207 + ),
208 + array(
209 + sprintf(
210 + '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696">%s</a>',
211 + __('Donate', 'cryptx')
212 + )
213 + )
214 + );
215 + }
216 + return $links;
217 + }
106 218
107 219 function filter($apply)
108 220 {
109 - global $cryptX_var;
110 -
221 + global $cryptX_var, $post, $shortcode_tags;
222 +
111 223 if (@$cryptX_var[autolink]) {
112 - add_filter($apply,
113 - array(&$this, 'autolink'),
114 - 5);
224 + add_filter($apply, array(&$this, 'autolink'), 5);
225 + if (!empty($shortcode_tags) || is_array($shortcode_tags)) {
226 + add_filter($apply, array(&$this, 'autolink'), 11);
227 + }
115 228 }
116 -
117 - add_filter($apply, array($this, 'encryptx'), 11);
118 - add_filter($apply, array($this, 'linktext'), 12);
229 + add_filter($apply, array($this, 'encryptx'), 12);
230 + add_filter($apply, array($this, 'linktext'), 13);
119 231 }
120 232
121 233 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
122 234
123 -
235 + function _excluded($ID) {
236 + global $cryptX_var;
237 + $return = false;
238 + $exIDs = explode(",", $cryptX_var[excludedIDs]);
239 + if(in_array($ID, $exIDs) > 0 ) $return = true;
240 + return $return;
241 + }
242 +
124 243 function linktext($content)
125 244 {
126 245 global $post;
127 - $cryptxoff = false;
128 - $cryptxoffmeta = get_post_meta($post->ID,'cryptxoff',true);
129 - if ($cryptxoffmeta == "true") {
130 - $cryptxoff = true;
131 - }
132 - echo "<!-- linktext: $cryptxoff / $cryptxoffmeta -->";
133 - if ($cryptxoff == false) {
246 + if (!$this->_excluded($post->ID)) {
134 247 $content = preg_replace_callback("/([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/i", array(get_class($this), '_Linktext'), $content );
135 248 }
136 249 return $content;
137 250 }
@@ -145,14 +258,14 @@
145 258 $linktext = $cryptX_var[alt_linktext];
146 259 break;
147 260
148 261 case 2: // alternative image for mail link
149 - $linktext = "<img src=\"" . $cryptX_var[alt_linkimage] . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[alt_linkimage_title] . "\" title=\"" . $cryptX_var[alt_linkimage_title] . "\">";
262 + $linktext = "<img src=\"" . $cryptX_var[alt_linkimage] . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[alt_linkimage_title] . "\" title=\"" . $cryptX_var[alt_linkimage_title] . "\" />";
150 263 break;
151 264
152 265 case 3: // uploaded image for mail link
153 - $imgurl = "/" . PLUGINDIR . "/" . dirname(plugin_basename (__FILE__)) . "/images/" . $cryptX_var[alt_uploadedimage];
154 - $linktext = "<img src=\"" . $imgurl . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[http_linkimage_title] . "\" title=\"" . $cryptX_var[http_linkimage_title] . "\">";
266 + $imgurl = $cryptX_var[alt_uploadedimage];
267 + $linktext = "<img src=\"" . $imgurl . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[http_linkimage_title] . "\" title=\"" . $cryptX_var[http_linkimage_title] . "\" />";
155 268 break;
156 269
157 270 case 4: // text scrambled by antispambot
158 271 $linktext = antispambot($Match[1]);
@@ -157,8 +270,12 @@
157 270 case 4: // text scrambled by antispambot
158 271 $linktext = antispambot($Match[1]);
159 272 break;
160 273
274 + case 5: // convert to image
275 + $linktext = "<img src=\"" . get_bloginfo('url') . "/" . md5( get_bloginfo('url') ) . "/" . antispambot($Match[1]) . "\" class=\"cryptxImage\" style=\"vertical-align:text-bottom\" alt=\"" . antispambot($Match[1]) . "\" title=\"" . antispambot($Match[1]) . "\" />";
276 + break;
277 +
161 278 default:
162 279 $linktext = str_replace( "@", $cryptX_var[at], $Match[1]);
163 280 $linktext = str_replace( ".", $cryptX_var[dot], $linktext);
164 281
@@ -169,15 +286,13 @@
169 286 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
170 287
171 288 function _dirImages()
172 289 {
173 - $dir = $_SERVER["DOCUMENT_ROOT"].'/'.PLUGINDIR.'/'.dirname(plugin_basename (__FILE__)).'/images';
174 - echo "<!-- cryptximgdir: $dir -->";
175 - $fh = opendir($dir); //Verzeichnis
290 + $dir = plugin_dir_path( __FILE__ ).'images';
291 + $fh = opendir($dir);
176 292 $verzeichnisinhalt = array();
177 293 while (true == ($file = readdir($fh)))
178 294 {
179 - echo "<!-- BILD: $file -->";
180 295 if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif"))
181 296 {
182 297 $verzeichnisinhalt[] = $file;
183 298 }
@@ -184,20 +299,30 @@
184 299 }
185 300 return $verzeichnisinhalt;
186 301 }
187 302
303 + function _dirFonts()
304 + {
305 + $dir = plugin_dir_path( __FILE__ ).'fonts';
306 + $fh = opendir($dir);
307 + $verzeichnisinhalt = array();
308 + while (true == ($file = readdir($fh)))
309 + {
310 + if ((substr(strtolower($file), -3)=="ttf") or (substr(strtolower($file), -3)=="ttf"))
311 + {
312 + $verzeichnisinhalt[] = $file;
313 + }
314 + }
315 + return $verzeichnisinhalt;
316 + }
317 +
188 318 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
189 319
190 320 function encryptx($content)
191 321 {
192 322 global $post;
193 - $cryptxoff = false;
194 - $cryptxoffmeta = get_post_meta($post->ID,'cryptxoff',true);
195 - if ($cryptxoffmeta == "true") {
196 - $cryptxoff = true;
197 - }
198 - echo "<!-- encryptx: $cryptxoff / $cryptxoffmeta -->";
199 - if ($cryptxoff == false) {
323 +
324 + if (!$this->_excluded($post->ID)) {
200 325 $content = preg_replace_callback('/<a (.*?)(href=("|\')mailto:(.*?)("|\')(.*?)|)>(.*?)<\/a>/i', array(get_class($this), 'mailtocrypt'), $content );
201 326 }
202 327 return $content;
203 328 }
@@ -206,8 +331,10 @@
206 331 {
207 332 global $cryptX_var;
208 333 $return = $Match[0];
209 334 $mailto = "mailto:" . $Match[4];
335 + //* If mailto contains no email adress, like a link from "Sociable" do nothing *//
336 + if (substr($Match[4], 0, 9) =="?subject=") return $return;
210 337 if (@$cryptX_var[java]) {
211 338 $crypt = '';
212 339 $ascii = 0;
213 340 for ($i = 0; $i < strlen( $Match[4] ); $i++) {
@@ -228,23 +355,27 @@
228 355
229 356 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
230 357
231 358 function autolink($content) {
232 -
359 + global $post;
360 + if ($this->_excluded($post->ID)) return $content;
233 361 $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
234 362 $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si";
363 + $src[]="/(\()([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(\))/si";
364 + $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))([\s])/si";
365 + $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si";
235 366 $src[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
236 367 $src[]="/(<a[^>]*>)<a[^>]*>/";
237 368 $src[]="/(<\/A>)<\/A>/i";
238 -
239 369 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>";
240 370 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
371 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
372 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
373 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
241 374 $tar[]="<a href=\"mailto:\\0\">\\0</a>";
242 375 $tar[]="\\1";
243 376 $tar[]="\\1";
244 -
245 377 $content = preg_replace($src,$tar,$content);
246 -
247 378 return $content;
248 379 }
249 380
250 381 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -250,8 +381,11 @@
250 381 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
251 382
252 383
253 384 function install() {
385 + global $cryptX_var, $wpdb;
386 + $firstImage = $this->_dirImages();
387 + $firstFont = $this->_dirFonts();
254 388 add_option(
255 389 'cryptX',
256 390 array(
257 391 'at' => ' [at] ',
@@ -258,13 +392,47 @@
258 392 'dot' => ' [dot] ',
259 393 'theContent' => 1,
260 394 'theExcerpt' => 0,
261 395 'commentText' => 1,
396 + 'widgetText' => 0,
262 397 'java' => 1,
263 398 'opt_linktext' => 0,
399 + 'autolink' => 1,
400 + 'excludedIDs' => '',
401 + 'metaBox' => 1,
402 + 'alt_uploadedimage' => plugins_url('cryptx/images/').$firstImage[0],
403 + 'c2i_font' => plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0],
404 + 'c2i_fontSize' => 10,
405 + 'c2i_fontRGB' => '000000',
264 406 )
265 407 );
408 + $cryptX_var = (array) get_option('cryptX'); // reread Options
409 + if ($cryptX_var[excludedIDs] == "") {
410 + $tmp = array();
411 + $excludes = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff' AND meta_value = 'true'");
412 + if(count($excludes) > 0) {
413 + foreach ($excludes as $exclude) {
414 + $tmp[] = $exclude->post_id;
415 + }
416 + sort($tmp);
417 + $cryptX_var[excludedIDs] = implode(",", $tmp);
418 + update_option( 'cryptX', $cryptX_var);
419 + $cryptX_var = (array) get_option('cryptX'); // reread Options
420 + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff'");
421 + }
266 422 }
423 + if (empty($cryptX_var[c2i_font])) {
424 + $cryptX_var[c2i_font] = plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0];
425 + }
426 + if (empty($cryptX_var[c2i_fontSize])) {
427 + $cryptX_var[c2i_fontSize] = 10;
428 + }
429 + if (empty($cryptX_var[c2i_fontRGB])) {
430 + $cryptX_var[c2i_fontRGB] = '000000';
431 + }
432 + update_option( 'cryptX', $cryptX_var);
433 + $cryptX_var = (array) get_option('cryptX'); // reread Options
434 + }
267 435
268 436 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
269 437
270 438 /**
@@ -271,9 +439,9 @@
271 439 * Attach the menu page to the `Options` tab
272 440 */
273 441 function header()
274 442 {
275 - $cryptX_script.= "<script type=\"text/javascript\" src=\"" . get_option('siteurl') . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n";
443 + $cryptX_script.= "<script type=\"text/javascript\" src=\"" . site_url() . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n";
276 444 print($cryptX_script);
277 445 }
278 446
279 447 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
@@ -280,30 +448,20 @@
280 448
281 449
282 450 function cryptx_meta() {
283 451 global $post;
284 - $cryptxoff = false;
285 - $cryptxoffmeta = get_post_meta($post->ID,'cryptxoff',true);
286 - if ($cryptxoffmeta == "true") {
287 - $cryptxoff = true;
288 - }
289 452 ?>
290 - <input type="checkbox" name="cryptxoff" <?php if ($cryptxoff) { echo 'checked="checked"'; } ?>/> Disable CryptX
453 + <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
291 454 <?php
292 455 }
293 456
294 457 function cryptx_option() {
295 458 global $post;
296 - $cryptxoff = false;
297 - $cryptxoffmeta = get_post_meta($post->ID,'cryptxoff',true);
298 - if ($cryptxoffmeta == "true") {
299 - $cryptxoff = true;
300 - }
301 459 if ( current_user_can('edit_posts') ) { ?>
302 460 <fieldset id="cryptxoption" class="dbx-box">
303 461 <h3 class="dbx-handle">CryptX</h3>
304 462 <div class="dbx-content">
305 - <input type="checkbox" name="cryptxon" <?php if ($cryptxoff) { echo 'checked="checked"'; } ?>/> CryptX disabled?
463 + <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
306 464 </div>
307 465 </fieldset>
308 466 <?php
309 467 }
@@ -322,19 +480,28 @@
322 480
323 481 //add_action('admin_menu', 'cryptx_meta_box');
324 482
325 483 function cryptx_insert_post($pID) {
326 - if (isset($_POST['cryptxoff'])) {
327 - add_post_meta($pID,'cryptxoff',"true", true) or update_post_meta($pID, 'cryptxoff', "true");
328 - } else {
329 - add_post_meta($pID,'cryptxoff',"false", true) or update_post_meta($pID, 'cryptxoff', "false");
484 + global $cryptX_var, $post;
485 +
486 + $rev = wp_is_post_revision($pID);
487 + if($rev) $pID = $rev;
488 + $b = explode(",", $cryptX_var[excludedIDs]);
489 + if($b[0] == '') unset($b[0]);
490 + foreach($b as $x=>$y) {
491 + if($y == $pID) {
492 + unset($b[$x]);
493 + break;
494 + }
330 495 }
496 + if (isset($_POST['cryptxoff'])) $b[] = $pID;
497 + $b = array_unique($b);
498 + sort($b);
499 + $cryptX_var[excludedIDs] = implode(",", $b);
500 + update_option( 'cryptX', $cryptX_var);
501 + $cryptX_var = (array) get_option('cryptX'); // reread Options
331 502 }
332 - //add_action('wp_insert_post', array(&$this, 'cryptx_insert_post'));
333 503
334 -
335 -
336 -
337 504 /**
338 505 * Attach the menu page to the `Options` tab
339 506 */
340 507 function menu() {
@@ -348,8 +515,9 @@
348 515 '_submenu'
349 516 )
350 517 );
351 518 }
519 +
352 520
353 521 /**
354 522 * Handles and renders the menu page
355 523 */
@@ -379,9 +547,9 @@
379 547
380 548 <?php wp_nonce_field('cryptX') ?>
381 549
382 550 <div id="poststuff" class="ui-sortable">
383 - <div id="wp_seo_about_wpseo" class="postbox">
551 + <div class="postbox">
384 552
385 553 <h3><?php _e("Presentation",'cryptx'); ?></h3>
386 554
387 555 <div class="inside">
@@ -413,31 +581,59 @@
413 581 </tr>
414 582 <tr valign="top">
415 583 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext4" value="3" <?php echo ($cryptX_var[opt_linktext] == 3) ? 'checked="checked"' : ''; ?>/></td>
416 584 <th><label for="cryptX_var[alt_uploadedimage]"><?php _e("Select image from folder",'cryptx'); ?></label></th>
417 - <td><select name="cryptX_var[alt_uploadedimage]" onchange="cryptX_bild_wechsel(this)">
585 + <td> <select name="cryptX_var[alt_uploadedimage]" onchange="cryptX_bild_wechsel(this)">
418 586 <?php foreach($this->_dirImages() as $image) {
419 - $FirstIMG = (!isset($FirstIMG))? plugins_url('cryptx/images/').$image : ($cryptX_var[alt_uploadedimage] == plugins_url('cryptx/images/').$image) ? plugins_url('cryptx/images/').$image : $FirstIMG;
420 587 ?>
421 588 <option value="<?php echo plugins_url('cryptx/images/').$image; ?>" <?php echo ($cryptX_var[alt_uploadedimage] == plugins_url('cryptx/images/').$image) ? 'selected' : ''; ?> ><?php echo $image; ?></option>
422 589 <?php } ?>
423 - </select>&nbsp;&nbsp;<img src="<?php echo $FirstIMG; ?>" id="cryptXmailTo"></td>
590 + </select>
591 + <br/><?php _e("the selected image: ",'cryptx'); ?><img src="<?php echo $cryptX_var[alt_uploadedimage]; ?>" id="cryptXmailTo" align="top" style="padding: 3px;"><br/>
592 + <span class="setting-description"><?php echo sprintf( __("Upload your favorite email-image to '%s'. Only .jpg and .gif Supported!",'cryptx'), plugin_dir_path( __FILE__ ).'images/' ); ?></span></td>
424 593 </tr>
425 594 <tr valign="top">
426 595 <td>&nbsp;</td>
427 596 <th><label for="cryptX_var[alt_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th>
428 - <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptX_var[alt_linkimage_title]; ?>" type="text" class="regular-text" />
429 - <span class="setting-description"><?php _e("Upload your favorite email-image to ../plugins/cryptx/images. Only .jpg and .gif Supported!",'cryptx'); ?></span></td>
597 + <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptX_var[alt_linkimage_title]; ?>" type="text" class="regular-text" /></td>
430 598 </tr>
431 599 <tr valign="top">
432 - <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext" value="4" <?php echo ($cryptX_var[opt_linktext] == 4) ? 'checked="checked"' : ''; ?>/></td>
600 + <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext4" value="4" <?php echo ($cryptX_var[opt_linktext] == 4) ? 'checked="checked"' : ''; ?>/></td>
433 601 <th colspan="2"><?php _e("Text scrambled by AntiSpamBot (<small>Try it and look at your site and check the html source!</small>)",'cryptx'); ?></th>
434 602 </tr>
603 + <tr valign="top">
604 + <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext5" value="5" <?php echo ($cryptX_var[opt_linktext] == 5) ? 'checked="checked"' : ''; ?>/></td>
605 + <th><?php _e("Convert Email to PNG-image",'cryptx'); ?></th>
606 + <td><?php _e("Example with the saved options: ",'cryptx'); ?><img src="<?php echo get_bloginfo('url'); ?>/<?php echo md5( get_bloginfo('url') ); ?>/<?php echo antispambot("test@example.com"); ?>" align="absmiddle" alt="<?php echo antispambot("test@example.com"); ?>" title="<?php echo antispambot("test@example.com"); ?>"></td>
607 + </tr>
608 + <tr valign="top">
609 + <td>&nbsp;</td>
610 + <th><label for="cryptX_var[c2i_font]"><?php _e("Choose a Font",'cryptx'); ?></label></th>
611 + <td><select name="cryptX_var[c2i_font]">
612 + <?php foreach($this->_dirFonts() as $font) { ?>
613 + <option value="<?php echo plugin_dir_path( __FILE__ ).'fonts/'.$font; ?>" <?php echo ($cryptX_var[c2i_font] == plugin_dir_path( __FILE__ ).'fonts/'.$font) ? 'selected' : ''; ?> ><?php echo $font; ?></option>
614 + <?php } ?>
615 + </select><br/>
616 + <span class="setting-description"><?php echo sprintf( __("Upload your favorite font to '%s'. Only .ttf is Supported!",'cryptx'), plugin_dir_path( __FILE__ ).'fonts/' ); ?></span>
617 + </td>
618 + </tr>
619 + <tr valign="top">
620 + <td>&nbsp;</td>
621 + <th><label for="cryptX_var[c2i_fontSize]"><?php _e("Font size (pixel)",'cryptx'); ?></label></th>
622 + <td><input name="cryptX_var[c2i_fontSize]" value="<?php echo $cryptX_var[c2i_fontSize]; ?>" type="text" class="regular-text" /></td>
623 + </tr>
624 + <tr valign="top">
625 + <td>&nbsp;</td>
626 + <th><label for="cryptX_var[c2i_fontRGB]"><?php _e("Font color (RGB)",'cryptx'); ?></label></th>
627 + <td><input name="cryptX_var[c2i_fontRGB]" value="<?php echo $cryptX_var[c2i_fontRGB]; ?>" type="text" class="regular-text" /></td>
628 + </tr>
435 629 </table>
436 630 </div>
437 631 </div>
438 632
439 - <div id="wp_seo_about_wpseo" class="postbox">
633 + <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
634 +
635 + <div class="postbox">
440 636
441 637 <h3><?php _e("General",'cryptx'); ?></h3>
442 638
443 639 <div class="inside">
@@ -443,18 +639,30 @@
443 639 <div class="inside">
444 640 <table class="form-table">
445 641 <tr valign="top">
446 642 <th scope="row"><?php _e("Apply CryptX to...",'cryptx'); ?></th>
447 - <td><input name="cryptX_var[theContent]" <?php echo ($cryptX_var[theContent]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Content",'cryptx'); ?><br/>
643 + <td><input name="cryptX_var[theContent]" <?php echo ($cryptX_var[theContent]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Content",'cryptx'); ?> <?php _e("(<i>this can be disabled per Post by an Option</i>)",'cryptx'); ?><br/>
448 644 <input name="cryptX_var[theExcerpt]" <?php echo ($cryptX_var[theExcerpt]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Excerpt",'cryptx'); ?><br/>
449 - <input name="cryptX_var[commentText]" <?php echo ($cryptX_var[commentText]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Comments",'cryptx'); ?></td>
645 + <input name="cryptX_var[commentText]" <?php echo ($cryptX_var[commentText]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Comments",'cryptx'); ?><br/>
646 + <input name="cryptX_var[widgetText]" <?php echo ($cryptX_var[widgetText]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Widgets",'cryptx'); ?> <?php _e("(<i>works only on all widgets, not on a single widget</i>!)",'cryptx'); ?></td>
450 647 </tr>
451 648 <tr valign="top">
649 + <th scope="row"><?php _e("Excluded ID's...",'cryptx'); ?></th>
650 + <td><input name="cryptX_var[excludedIDs]" value="<?php echo $cryptX_var[excludedIDs]; ?>" type="text" class="regular-text" />
651 + <br/><span class="setting-description"><?php _e("Enter all Page/Post ID's to exclude from CryptX as comma seperated list.",'cryptx'); ?></span>
652 + <br/><input name="cryptX_var[metaBox]" <?php echo ($cryptX_var[metaBox]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Enable the CryptX Widget on editing a post or page.",'cryptx'); ?></td>
653 + </tr>
654 + <tr valign="top">
452 655 <th scope="row"><?php _e("Type of decryption",'cryptx'); ?></th>
453 656 <td><input name="cryptX_var[java]" <?php echo ($cryptX_var[java]) ? 'checked="checked"' : ''; ?> type="radio" value="1" />&nbsp;&nbsp;<?php _e("Use javascript to hide the Email-Link.",'cryptx'); ?><br/>
454 657 <input name="cryptX_var[java]" <?php echo (!$cryptX_var[java]) ? 'checked="checked"' : ''; ?> type="radio" value="0" />&nbsp;&nbsp;<?php _e("Use Unicode to hide the Email-Link.",'cryptx'); ?></td>
455 658 </tr>
456 659 <tr valign="top">
660 + <th scope="row"><?php _e("Where to load the needed javascript...",'cryptx'); ?></th>
661 + <td><input name="cryptX_var[load_java]" <?php echo (!$cryptX_var[load_java]) ? 'checked="checked"' : ''; ?> type="radio" value="0" />&nbsp;&nbsp;<?php _e("Load the javascript in the <b>header</b> of the page.",'cryptx'); ?><br/>
662 + <input name="cryptX_var[load_java]" <?php echo ($cryptX_var[load_java]) ? 'checked="checked"' : ''; ?> type="radio" value="1" />&nbsp;&nbsp;<?php _e("Load the javascript in the <b>footer</b> of the page.",'cryptx'); ?></td>
663 + </tr>
664 + <tr valign="top">
457 665 <th scope="row" colspan="2"><input name="cryptX_var[autolink]" <?php echo ($cryptX_var[autolink]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Add mailto to all unlinked email addresses",'cryptx'); ?></th>
458 666 </tr>
459 667 </table>
460 668
@@ -460,10 +668,70 @@
460 668
461 669 </div>
462 670 </div>
463 671 <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
672 +
673 + <div class="postbox">
674 +
675 + <h3><?php _e("How to use CryptX in your Template",'cryptx'); ?></h3>
676 +
677 + <div class="inside">
678 + <table class="form-table">
679 + <tr>
680 + <td>In your Template you can use the following function to encrypt a email address:
681 + <p style="border:1px solid #000; background-color: #e9e9e9;padding: 10px;">
682 + <i>
683 + &lt;?php <br/>
684 + &nbsp;&nbsp;&nbsp;&nbsp; $mail="name@example.com"; <br/>
685 + &nbsp;&nbsp;&nbsp;&nbsp; $text="Contact"; <br/>
686 + &nbsp;&nbsp;&nbsp;&nbsp; $css ="email"; <br/>
687 + &nbsp;&nbsp;&nbsp;&nbsp; if (function_exists('cryptx')) { <br/>
688 + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cryptx($mail, $text, $css, 1); <br/>
689 + &nbsp;&nbsp;&nbsp;&nbsp; } else { <br/>
690 + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo sprintf('&lt;a href="mailto:%s" class="%s"&gt;%s&lt;/a&gt;', $mail, $css, ($text != "" ? $text : $mail)); <br/>
691 + &nbsp;&nbsp;&nbsp;&nbsp; } <br/>
692 + ?&gt;
693 + </i></p>
694 + <ol><li>parameter is the email address.</li>
695 + <li>parameter is the linktext. If none given the email address is used.</li>
696 + <li>parameter is a css class added to the link.</li>
697 + <li>parameter is 1 for echo the encrypted email address or 0 to return the redult to a variable.</li></ol></td>
698 + </tr>
699 + </table>
700 +
464 701 </div>
702 + </div>
703 +
704 + <div class="postbox">
465 705
706 + <h3><?php _e("Information",'cryptx'); ?></h3>
707 +
708 + <div class="inside">
709 + <table class="form-table">
710 + <tr>
711 + <td><?php
712 + $data = get_plugin_data(__FILE__);
713 + echo sprintf(
714 + '%1$s: %2$s | %3$s: %4$s | %5$s: <a href="http://weber-nrw.de" target="_blank">Ralf Weber</a> | <a href="http://twitter.com/Weber_NRW" target="_blank">%6$s</a> | <a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696">%7$s</a><br />',
715 + __('Plugin'),
716 + 'CryptX',
717 + __('Version'),
718 + $data['Version'],
719 + __('Author'),
720 + __('Follow on Twitter', 'cryptx'),
721 + __('Donate', 'cryptx')
722 + );
723 + ?>
724 + Please support me by translating CryptX into other languages. You can download the cryptx.pot file from my <a href="http://weber-nrw.de/wordpress/cryptx/downloads/">site</a> and mail me the zipped language files. Thanks for it.
725 + </td>
726 + </tr>
727 + </table>
728 +
729 + </div>
730 + </div>
731 +
732 + </div>
733 +
466 734 </form>
467 735
468 736 <script type="text/javascript">
469 737 <!--
@@ -502,15 +770,12 @@
502 770 */
503 771 function cryptx( $content, $text="", $css="", $echo=1 )
504 772 {
505 773 global $cryptX_var;
506 -
507 774 $cryptX = new cryptX;
508 -
509 775 $content = $cryptX->autolink( $content );
510 -
511 776 $content = $cryptX->encryptx( $content );
512 -
777 + $content = $cryptX->linktext( $content );
513 778 if("" != $text) {
514 779 $content = preg_replace( "/(<a[^>]*>)(.*)(<\/a>)/i", '$1'.$text.'$3', $content );
515 780 }
516 781 if("" != $css) {
@@ -516,8 +781,7 @@
516 781 if("" != $css) {
517 782 $content = preg_replace( "/(<a[^>]*)(>)/i", '$1 class="'.$css.'"$2', $content );
518 783 }
519 784 if(1 == $echo) echo $content;
520 -
521 785 return $content;
522 786 }
523 787 ?>