PluginProbe
CryptX / 2.6.0
CryptX v2.6.0
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.6.0, at cryptx.php

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