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

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