PluginProbe
CryptX / 2.7
CryptX v2.7
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 2.4.5 All 92 releases
cryptx / cryptx.php

cryptx.php in CryptX 2.7, at cryptx.php

806 lines 29.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /*
3 Plugin Name: CryptX
4 Plugin URI: http://weber-nrw.de/wordpress/cryptx/
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.7
7 Author: Ralf Weber
8 Author URI: http://weber-nrw.de/
9 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696
10 */
11
12 /////////////////////////////////////////////////////////////////////////////
13
14 /**
15 * @internal prevent from direct calls
16 */
17 if (!defined('ABSPATH')) {
18 return ;
19 }
20
21 /**
22 * @internal prevent from second inclusion
23 */
24 if (!class_exists('cryptX')) {
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__) ) );
31
32 load_plugin_textdomain('cryptx', sprintf('%s/cryptx/languages', PLUGINDIR ));
33
34 $cryptX_var = (array) get_option('cryptX');
35
36 /**
37 * "CryptX" WordPress Plugin
38 *
39 * @author Ralf Weber <ralf@weber-nrw.de>
40 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
41 */
42 Class cryptX {
43
44 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
45
46 /**
47 * Constructor
48 *
49 * This constructor attaches the needer plugin hook callbacks
50 */
51 function cryptX() {
52
53 global $cryptX_var, $wp_version;
54
55 // attach the converstion handlers
56 //
57 if (@$cryptX_var[theContent]) {
58 $this->filter('the_content');
59 }
60 if (@$cryptX_var[theExcerpt]) {
61 $this->filter('the_excerpt');
62 }
63 if (@$cryptX_var[commentText]) {
64 $this->filter('comment_text');
65 }
66 if (@$cryptX_var[widgetText]) {
67 $this->filter('widget_text');
68 }
69
70 // attach to admin menu
71 //
72 if (is_admin()) {
73 add_action('admin_menu',
74 array(&$this, 'menu')
75 );
76 }
77
78 // attach to plugin installation
79 //
80 add_action(
81 'activate_' . str_replace(
82 DIRECTORY_SEPARATOR, '/',
83 str_replace(
84 realpath(ABSPATH . PLUGINDIR) . DIRECTORY_SEPARATOR,
85 '', __FILE__
86 )
87 ),
88 array(&$this, 'install')
89 );
90
91 // attach javascript to Header
92 //
93 if (@$cryptX_var[java]) {
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 );
106 }
107 }
108
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
132 // Add shortcodes
133 add_shortcode( 'cryptx', array($this, 'cryptx_shortcode'));
134 } // End function
135
136 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
137
138 function cryptx_shortcode( $atts, $content=null) {
139 global $cryptX_var;
140
141 if (@$cryptX_var[autolink]) $content = $this->autolink($content, true);
142 $content = $this->encryptx($content, true);
143 $content = $this->linktext($content, true);
144
145 return $content;
146 }
147
148 function init_tinyurl() {
149 global $cryptX_var;
150 // check TinyURl
151 $url = $_SERVER["REQUEST_URI"];
152 $params = explode( '/', $url );
153 if ( count( $params ) > 1 ) {
154 $tiny_url = $params[count( $params ) -2];
155 if ( $tiny_url == md5( get_bloginfo('url') ) ) {
156 // define vars
157 $font = $cryptX_var[c2i_font];
158 $msg = $params[count( $params ) -1];
159 $size = $cryptX_var[c2i_fontSize];
160 $pad = 1;
161 $transparent = 1;
162 $red = hexdec(substr($cryptX_var[c2i_fontRGB],0,2));
163 $grn = hexdec(substr($cryptX_var[c2i_fontRGB],2,2));
164 $blu = hexdec(substr($cryptX_var[c2i_fontRGB],4,2));
165 $bg_red = 255 - $red;
166 $bg_grn = 255 - $grn;
167 $bg_blu = 255 - $blu;
168 $width = 0;
169 $height = 0;
170 $offset_x = 0;
171 $offset_y = 0;
172 $bounds = array();
173 $image = "";
174 // get the font height.
175 $bounds = ImageTTFBBox($size, 0, $font, "W");
176 if ($rot < 0)
177 {
178 $font_height = abs($bounds[7]-$bounds[1]);
179 }
180 else if ($rot > 0)
181 {
182 $font_height = abs($bounds[1]-$bounds[7]);
183 }
184 else
185 {
186 $font_height = abs($bounds[7]-$bounds[1]);
187 }
188 // determine bounding box.
189 $bounds = ImageTTFBBox($size, 0, $font, $msg);
190 $width = abs($bounds[4]-$bounds[6]);
191 $height = abs($bounds[7]-$bounds[1]);
192 $offset_y = $font_height+abs(($height - $font_height)/2)-1;
193 $offset_x = 0;
194 $image = imagecreatetruecolor($width+($pad*2),$height+($pad*2));
195 imagesavealpha($image, true);
196 //$background = ImageColorAllocate($image, $bg_red, $bg_grn, $bg_blu);
197 $foreground = ImageColorAllocate($image, $red, $grn, $blu);
198 $background = imagecolorallocatealpha($image, 0, 0, 0, 127);
199 imagefill($image, 0, 0, $background);
200 // render the image
201 ImageTTFText($image, $size, 0, $offset_x+$pad, $offset_y+$pad, $foreground, $font, $msg);
202 // output PNG object.
203 Header("Content-type: image/png");
204 imagePNG($image);
205 die;
206 }
207 }
208 }
209
210 function init_row_meta($links, $file) {
211 if (CRYPTX_BASENAME == $file) {
212 return array_merge(
213 $links,
214 array(
215 sprintf(
216 '<a href="options-general.php?page=%s">%s</a>',
217 CRYPTX_BASENAME,
218 __('Settings')
219 )
220 ),
221 array(
222 sprintf(
223 '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696">%s</a>',
224 __('Donate', 'cryptx')
225 )
226 )
227 );
228 }
229 return $links;
230 }
231
232 function filter($apply)
233 {
234 global $cryptX_var, $post, $shortcode_tags;
235
236 if (@$cryptX_var[autolink]) {
237 add_filter($apply, array(&$this, 'autolink'), 5);
238 if (!empty($shortcode_tags) || is_array($shortcode_tags)) {
239 add_filter($apply, array(&$this, 'autolink'), 11);
240 }
241 }
242 add_filter($apply, array($this, 'encryptx'), 12);
243 add_filter($apply, array($this, 'linktext'), 13);
244 }
245
246 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
247
248 function _excluded($ID) {
249 global $cryptX_var;
250 $return = false;
251 $exIDs = explode(",", $cryptX_var[excludedIDs]);
252 if(in_array($ID, $exIDs) > 0 ) $return = true;
253 return $return;
254 }
255
256 function linktext($content, $shortcode=false)
257 {
258 global $post;
259 if (!$this->_excluded($post->ID) OR $shortcode=true) {
260 $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 );
261 }
262 return $content;
263 }
264
265 function _linktext($Match)
266 {
267 global $cryptX_var;
268 switch ($cryptX_var[opt_linktext]) {
269
270 case 1: // alternative text for mail link
271 $linktext = $cryptX_var[alt_linktext];
272 break;
273
274 case 2: // alternative image for mail link
275 $linktext = "<img src=\"" . $cryptX_var[alt_linkimage] . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[alt_linkimage_title] . "\" title=\"" . $cryptX_var[alt_linkimage_title] . "\" />";
276 break;
277
278 case 3: // uploaded image for mail link
279 $imgurl = $cryptX_var[alt_uploadedimage];
280 $linktext = "<img src=\"" . $imgurl . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[http_linkimage_title] . "\" title=\"" . $cryptX_var[http_linkimage_title] . "\" />";
281 break;
282
283 case 4: // text scrambled by antispambot
284 $linktext = antispambot($Match[1]);
285 break;
286
287 case 5: // convert to image
288 $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]) . "\" />";
289 break;
290
291 default:
292 $linktext = str_replace( "@", $cryptX_var[at], $Match[1]);
293 $linktext = str_replace( ".", $cryptX_var[dot], $linktext);
294
295 }
296 return $linktext;
297 }
298
299 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
300
301 function _dirImages()
302 {
303 $dir = plugin_dir_path( __FILE__ ).'images';
304 $fh = opendir($dir);
305 $verzeichnisinhalt = array();
306 while (true == ($file = readdir($fh)))
307 {
308 if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif"))
309 {
310 $verzeichnisinhalt[] = $file;
311 }
312 }
313 return $verzeichnisinhalt;
314 }
315
316 function _dirFonts()
317 {
318 $dir = plugin_dir_path( __FILE__ ).'fonts';
319 $fh = opendir($dir);
320 $verzeichnisinhalt = array();
321 while (true == ($file = readdir($fh)))
322 {
323 if ((substr(strtolower($file), -3)=="ttf") or (substr(strtolower($file), -3)=="ttf"))
324 {
325 $verzeichnisinhalt[] = $file;
326 }
327 }
328 return $verzeichnisinhalt;
329 }
330
331 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
332
333 function encryptx($content, $shortcode=false)
334 {
335 global $post;
336
337 if (!$this->_excluded($post->ID) OR $shortcode=true) {
338 $content = preg_replace_callback('/<a (.*?)(href=("|\')mailto:(.*?)("|\')(.*?)|)>(.*?)<\/a>/i', array(get_class($this), 'mailtocrypt'), $content );
339 }
340 return $content;
341 }
342
343 function mailtocrypt($Match)
344 {
345 global $cryptX_var;
346 $return = $Match[0];
347 $mailto = "mailto:" . $Match[4];
348 //* If mailto contains no email adress, like a link from "Sociable" do nothing *//
349 if (substr($Match[4], 0, 9) =="?subject=") return $return;
350 if (@$cryptX_var[java]) {
351 $crypt = '';
352 $ascii = 0;
353 for ($i = 0; $i < strlen( $Match[4] ); $i++) {
354 $ascii = ord ( substr ( $Match[4], $i ) );
355 if (8364 <= $char) {
356 $ascii = 128;
357 }
358 $crypt .= chr($ascii + 1);
359 }
360 $javascript="javascript:DeCryptX('" . $crypt . "')";
361 $return = str_replace( "mailto:".$Match[4], $javascript, $return);
362 } else {
363 $return = str_replace( $mailto, antispambot($mailto), $return);
364 }
365 return $return;
366 }
367
368
369 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
370
371 function autolink($content, $shortcode=false) {
372 global $post;
373 if ($this->_excluded($post->ID) AND $shortcode=false) return $content;
374 $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
375 $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si";
376 $src[]="/(\()([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(\))/si";
377 $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))([\s])/si";
378 $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si";
379 $src[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
380 $src[]="/(<a[^>]*>)<a[^>]*>/";
381 $src[]="/(<\/A>)<\/A>/i";
382 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>";
383 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
384 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
385 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
386 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
387 $tar[]="<a href=\"mailto:\\0\">\\0</a>";
388 $tar[]="\\1";
389 $tar[]="\\1";
390 $content = preg_replace($src,$tar,$content);
391 return $content;
392 }
393
394 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
395
396
397 function install() {
398 global $cryptX_var, $wpdb;
399 $firstImage = $this->_dirImages();
400 $firstFont = $this->_dirFonts();
401 add_option(
402 'cryptX',
403 array(
404 'at' => ' [at] ',
405 'dot' => ' [dot] ',
406 'theContent' => 1,
407 'theExcerpt' => 0,
408 'commentText' => 1,
409 'widgetText' => 0,
410 'java' => 1,
411 'opt_linktext' => 0,
412 'autolink' => 1,
413 'excludedIDs' => '',
414 'metaBox' => 1,
415 'alt_uploadedimage' => plugins_url('cryptx/images/').$firstImage[0],
416 'c2i_font' => plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0],
417 'c2i_fontSize' => 10,
418 'c2i_fontRGB' => '000000',
419 )
420 );
421 $cryptX_var = (array) get_option('cryptX'); // reread Options
422 if ($cryptX_var[excludedIDs] == "") {
423 $tmp = array();
424 $excludes = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff' AND meta_value = 'true'");
425 if(count($excludes) > 0) {
426 foreach ($excludes as $exclude) {
427 $tmp[] = $exclude->post_id;
428 }
429 sort($tmp);
430 $cryptX_var[excludedIDs] = implode(",", $tmp);
431 update_option( 'cryptX', $cryptX_var);
432 $cryptX_var = (array) get_option('cryptX'); // reread Options
433 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff'");
434 }
435 }
436 if (empty($cryptX_var[c2i_font])) {
437 $cryptX_var[c2i_font] = plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0];
438 }
439 if (empty($cryptX_var[c2i_fontSize])) {
440 $cryptX_var[c2i_fontSize] = 10;
441 }
442 if (empty($cryptX_var[c2i_fontRGB])) {
443 $cryptX_var[c2i_fontRGB] = '000000';
444 }
445 update_option( 'cryptX', $cryptX_var);
446 $cryptX_var = (array) get_option('cryptX'); // reread Options
447 }
448
449 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
450
451 /**
452 * Attach the menu page to the `Options` tab
453 */
454 function header()
455 {
456 $cryptX_script.= "<script type=\"text/javascript\" src=\"" . site_url() . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n";
457 print($cryptX_script);
458 }
459
460 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
461
462
463 function cryptx_meta() {
464 global $post;
465 ?>
466 <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
467 <?php
468 }
469
470 function cryptx_option() {
471 global $post;
472 if ( current_user_can('edit_posts') ) { ?>
473 <fieldset id="cryptxoption" class="dbx-box">
474 <h3 class="dbx-handle">CryptX</h3>
475 <div class="dbx-content">
476 <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
477 </div>
478 </fieldset>
479 <?php
480 }
481 }
482
483 function cryptx_meta_box() {
484 // Check whether the 2.5 function add_meta_box exists, and if it doesn't use 2.3 functions.
485 if ( function_exists('add_meta_box') ) {
486 add_meta_box('cryptx','CryptX', array(&$this, 'cryptx_meta'),'post');
487 add_meta_box('cryptx','CryptX', array(&$this, 'cryptx_meta'),'page');
488 } else {
489 add_action('dbx_post_sidebar', array(&$this, 'cryptx_option'));
490 add_action('dbx_page_sidebar', array(&$this, 'cryptx_option'));
491 }
492 }
493
494 //add_action('admin_menu', 'cryptx_meta_box');
495
496 function cryptx_insert_post($pID) {
497 global $cryptX_var, $post;
498
499 $rev = wp_is_post_revision($pID);
500 if($rev) $pID = $rev;
501 $b = explode(",", $cryptX_var[excludedIDs]);
502 if($b[0] == '') unset($b[0]);
503 foreach($b as $x=>$y) {
504 if($y == $pID) {
505 unset($b[$x]);
506 break;
507 }
508 }
509 if (isset($_POST['cryptxoff'])) $b[] = $pID;
510 $b = array_unique($b);
511 sort($b);
512 $cryptX_var[excludedIDs] = implode(",", $b);
513 update_option( 'cryptX', $cryptX_var);
514 $cryptX_var = (array) get_option('cryptX'); // reread Options
515 }
516
517 /**
518 * Attach the menu page to the `Options` tab
519 */
520 function menu() {
521 add_options_page(
522 'CryptX',
523 (version_compare($GLOBALS['wp_version'], '2.6.999', '>') ? '<img src="' .@plugins_url('cryptx/icon.png'). '" width="10" height="10" alt="CryptX Icon" />' : ''). 'CryptX',
524 9,
525 __FILE__,
526 array(
527 $this,
528 '_submenu'
529 )
530 );
531 }
532
533
534 /**
535 * Handles and renders the menu page
536 */
537 function _submenu() {
538 global $cryptX_var;
539
540 if (isset($_POST) && !empty($_POST)) {
541 if (function_exists('current_user_can') === true && (current_user_can('manage_options') === false || current_user_can('edit_plugins') === false)) {
542 wp_die("You don't have permission to access!");
543 }
544 check_admin_referer('cryptX');
545 update_option( 'cryptX', $_POST['cryptX_var']);
546 $cryptX_var = (array) get_option('cryptX'); // reread Options
547 ?>
548 <div id="message" class="updated fade">
549 <p><strong><?php _e('Settings saved.') ?></strong></p>
550 </div>
551 <?php } ?>
552
553 <div class="wrap">
554 <?php if (version_compare($GLOBALS['wp_version'], '2.6.999', '>')) { ?>
555 <div class="icon32" style="background: url(<?php echo @plugins_url('cryptx/icon32.png') ?>) no-repeat"><br /></div>
556 <?php } ?>
557 <h2>CryptX</h2>
558
559 <form method="post" action="">
560
561 <?php wp_nonce_field('cryptX') ?>
562
563 <div id="poststuff" class="ui-sortable">
564 <div class="postbox">
565
566 <h3><?php _e("Presentation",'cryptx'); ?></h3>
567
568 <div class="inside">
569 <table class="form-table">
570 <tr valign="top">
571 <td><input name="cryptX_var[opt_linktext]" type="radio" id="opt_linktext" value="0" <?php echo ($cryptX_var[opt_linktext] == 0) ? 'checked="checked"' : ''; ?> /></td>
572 <th scope="row"><label for="cryptX_var[at]"><?php _e("Replacement for '@'",'cryptx'); ?></label></th>
573 <td><input name="cryptX_var[at]" value="<?php echo $cryptX_var[at]; ?>" type="text" class="regular-text" /></td>
574 </tr>
575 <tr valign="top">
576 <td>&nbsp;</td>
577 <th scope="row"><label for="cryptX_var[dot]"><?php _e("Replacement for '.'",'cryptx'); ?></label></th>
578 <td><input name="cryptX_var[dot]" value="<?php echo $cryptX_var[dot]; ?>" type="text" class="regular-text" /></td>
579 </tr>
580 <tr valign="top">
581 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext2" value="1" <?php echo ($cryptX_var[opt_linktext] == 1) ? 'checked="checked"' : ''; ?>/></td>
582 <th><label for="cryptX_var[alt_linktext]"><?php _e("Text for link",'cryptx'); ?></label></th>
583 <td><input name="cryptX_var[alt_linktext]" value="<?php echo $cryptX_var[alt_linktext]; ?>" type="text" class="regular-text" /></td>
584 </tr>
585 <tr valign="top">
586 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext3" value="2" <?php echo ($cryptX_var[opt_linktext] == 2) ? 'checked="checked"' : ''; ?>/></td>
587 <th><label for="cryptX_var[alt_linkimage]"><?php _e("Image-URL",'cryptx'); ?></label></th>
588 <td><input name="cryptX_var[alt_linkimage]" value="<?php echo $cryptX_var[alt_linkimage]; ?>" type="text" class="regular-text" /></td>
589 </tr>
590 <tr valign="top">
591 <td scope="row">&nbsp;</td>
592 <th><label for="cryptX_var[http_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th>
593 <td><input name="cryptX_var[http_linkimage_title]" value="<?php echo $cryptX_var[http_linkimage_title]; ?>" type="text" class="regular-text" /></td>
594 </tr>
595 <tr valign="top">
596 <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>
597 <th><label for="cryptX_var[alt_uploadedimage]"><?php _e("Select image from folder",'cryptx'); ?></label></th>
598 <td> <select name="cryptX_var[alt_uploadedimage]" onchange="cryptX_bild_wechsel(this)">
599 <?php foreach($this->_dirImages() as $image) {
600 ?>
601 <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>
602 <?php } ?>
603 </select>
604 <br/><?php _e("the selected image: ",'cryptx'); ?><img src="<?php echo $cryptX_var[alt_uploadedimage]; ?>" id="cryptXmailTo" align="top" style="padding: 3px;"><br/>
605 <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>
606 </tr>
607 <tr valign="top">
608 <td>&nbsp;</td>
609 <th><label for="cryptX_var[alt_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th>
610 <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptX_var[alt_linkimage_title]; ?>" type="text" class="regular-text" /></td>
611 </tr>
612 <tr valign="top">
613 <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>
614 <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>
615 </tr>
616 <tr valign="top">
617 <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>
618 <th><?php _e("Convert Email to PNG-image",'cryptx'); ?></th>
619 <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>
620 </tr>
621 <tr valign="top">
622 <td>&nbsp;</td>
623 <th><label for="cryptX_var[c2i_font]"><?php _e("Choose a Font",'cryptx'); ?></label></th>
624 <td><select name="cryptX_var[c2i_font]">
625 <?php foreach($this->_dirFonts() as $font) { ?>
626 <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>
627 <?php } ?>
628 </select><br/>
629 <span class="setting-description"><?php echo sprintf( __("Upload your favorite font to '%s'. Only .ttf is Supported!",'cryptx'), plugin_dir_path( __FILE__ ).'fonts/' ); ?></span>
630 </td>
631 </tr>
632 <tr valign="top">
633 <td>&nbsp;</td>
634 <th><label for="cryptX_var[c2i_fontSize]"><?php _e("Font size (pixel)",'cryptx'); ?></label></th>
635 <td><input name="cryptX_var[c2i_fontSize]" value="<?php echo $cryptX_var[c2i_fontSize]; ?>" type="text" class="regular-text" /></td>
636 </tr>
637 <tr valign="top">
638 <td>&nbsp;</td>
639 <th><label for="cryptX_var[c2i_fontRGB]"><?php _e("Font color (RGB)",'cryptx'); ?></label></th>
640 <td><input name="cryptX_var[c2i_fontRGB]" value="<?php echo $cryptX_var[c2i_fontRGB]; ?>" type="text" class="regular-text" /></td>
641 </tr>
642 </table>
643 </div>
644 </div>
645
646 <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
647
648 <div class="postbox">
649
650 <h3><?php _e("General",'cryptx'); ?></h3>
651
652 <div class="inside">
653 <table class="form-table">
654 <tr valign="top">
655 <th scope="row"><?php _e("Apply CryptX to...",'cryptx'); ?></th>
656 <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/>
657 <input name="cryptX_var[theExcerpt]" <?php echo ($cryptX_var[theExcerpt]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Excerpt",'cryptx'); ?><br/>
658 <input name="cryptX_var[commentText]" <?php echo ($cryptX_var[commentText]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Comments",'cryptx'); ?><br/>
659 <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>
660 </tr>
661 <tr valign="top">
662 <th scope="row"><?php _e("Excluded ID's...",'cryptx'); ?></th>
663 <td><input name="cryptX_var[excludedIDs]" value="<?php echo $cryptX_var[excludedIDs]; ?>" type="text" class="regular-text" />
664 <br/><span class="setting-description"><?php _e("Enter all Page/Post ID's to exclude from CryptX as comma seperated list.",'cryptx'); ?></span>
665 <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>
666 </tr>
667 <tr valign="top">
668 <th scope="row"><?php _e("Type of decryption",'cryptx'); ?></th>
669 <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/>
670 <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>
671 </tr>
672 <tr valign="top">
673 <th scope="row"><?php _e("Where to load the needed javascript...",'cryptx'); ?></th>
674 <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/>
675 <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>
676 </tr>
677 <tr valign="top">
678 <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>
679 </tr>
680 </table>
681
682 </div>
683 </div>
684 <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
685
686 <div class="postbox">
687
688 <h3><?php _e("How to use CryptX in your Template",'cryptx'); ?></h3>
689
690 <div class="inside">
691 <table class="form-table">
692 <tr>
693 <td>In your Template you can use the following function to encrypt a email address:
694 <p style="border:1px solid #000; background-color: #e9e9e9;padding: 10px;">
695 <i>
696 &lt;?php <br/>
697 &nbsp;&nbsp;&nbsp;&nbsp; $mail="name@example.com"; <br/>
698 &nbsp;&nbsp;&nbsp;&nbsp; $text="Contact"; <br/>
699 &nbsp;&nbsp;&nbsp;&nbsp; $css ="email"; <br/>
700 &nbsp;&nbsp;&nbsp;&nbsp; if (function_exists('cryptx')) { <br/>
701 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cryptx($mail, $text, $css, 1); <br/>
702 &nbsp;&nbsp;&nbsp;&nbsp; } else { <br/>
703 &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/>
704 &nbsp;&nbsp;&nbsp;&nbsp; } <br/>
705 ?&gt;
706 </i></p>
707 <ol><li>parameter is the email address.</li>
708 <li>parameter is the linktext. If none given the email address is used.</li>
709 <li>parameter is a css class added to the link.</li>
710 <li>parameter is 1 for echo the encrypted email address or 0 to return the redult to a variable.</li></ol></td>
711 </tr>
712 </table>
713
714 </div>
715 </div>
716
717 <div class="postbox">
718
719 <h3><?php _e("Information",'cryptx'); ?></h3>
720
721 <div class="inside">
722 <table class="form-table">
723 <tr>
724 <td valign="top"><b><i><u>NEWS:</u></i>&nbsp;</b></td>
725 <td width="99%"><b>CryptX 2.7 supports now the shortcode [cryptx]...[/cryptx]! The shortcode was implemented for posts and pages, where CryptX was switched off.</b></td>
726 </tr>
727 </table>
728 <table class="form-table">
729 <tr>
730 <td><?php
731 $data = get_plugin_data(__FILE__);
732 echo sprintf(
733 '%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 />',
734 __('Plugin'),
735 'CryptX',
736 __('Version'),
737 $data['Version'],
738 __('Author'),
739 __('Follow on Twitter', 'cryptx'),
740 __('Donate', 'cryptx')
741 );
742 ?>
743 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.
744 </td>
745 </tr>
746 </table>
747
748 </div>
749 </div>
750
751 </div>
752
753 </form>
754
755 <script type="text/javascript">
756 <!--
757 function cryptX_bild_wechsel(select){
758 document.getElementById("cryptXmailTo").src = select.options[select.options.selectedIndex].value;
759 return true;
760 } //-->
761 </script>
762
763 </div>
764 <?php
765 }
766
767 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
768
769
770 //--end-of-class
771 }
772
773 }
774
775 /////////////////////////////////////////////////////////////////////////////
776
777 /**
778 * Initiating the plugin...
779 * @see cryptX
780 */
781 new cryptX;
782
783 /**
784 * Create Template functions...
785 * $content = string to convert
786 * $text = string to replace linktext
787 * $css = assign a css class to the link
788 * $echo = 0: keep result in a variable, 1: show result
789 */
790 function cryptx( $content, $text="", $css="", $echo=1 )
791 {
792 global $cryptX_var;
793 $cryptX = new cryptX;
794 $content = $cryptX->autolink( $content );
795 $content = $cryptX->encryptx( $content );
796 $content = $cryptX->linktext( $content );
797 if("" != $text) {
798 $content = preg_replace( "/(<a[^>]*>)(.*)(<\/a>)/i", '$1'.$text.'$3', $content );
799 }
800 if("" != $css) {
801 $content = preg_replace( "/(<a[^>]*)(>)/i", '$1 class="'.$css.'"$2', $content );
802 }
803 if(1 == $echo) echo $content;
804 return $content;
805 }
806 ?>