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

cryptx.php in CryptX 2.5.1, at cryptx.php

644 lines 22.3 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.5.1
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 } // End function
121
122 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
123
124 function init_row_meta($links, $file) {
125 if (CRYPTX_BASENAME == $file) {
126 return array_merge(
127 $links,
128 array(
129 sprintf(
130 '<a href="options-general.php?page=%s">%s</a>',
131 CRYPTX_BASENAME,
132 __('Settings')
133 )
134 ),
135 array(
136 sprintf(
137 '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696">%s</a>',
138 __('Donate', 'cryptx')
139 )
140 )
141 );
142 }
143 return $links;
144 }
145
146 function filter($apply)
147 {
148 global $cryptX_var, $shortcode_tags;
149
150 if (@$cryptX_var[autolink]) {
151 add_filter($apply, array(&$this, 'autolink'), 5);
152 }
153
154 if (!empty($shortcode_tags) || is_array($shortcode_tags)) {
155 add_filter($apply, array(&$this, 'autolink'), 11);
156 }
157
158 add_filter($apply, array($this, 'encryptx'), 12);
159 add_filter($apply, array($this, 'linktext'), 13);
160 }
161
162 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
163
164 function _excluded($ID) {
165 global $cryptX_var;
166 $return = false;
167 $exIDs = explode(",", $cryptX_var[excludedIDs]);
168 if(array_search($ID, $exIDs) >0 ) $return = true;
169 return $return;
170 }
171
172 function linktext($content)
173 {
174 global $post;
175 $cryptxoff = false;
176 $cryptxoffmeta = get_post_meta($post->ID,'cryptxoff',true);
177 if ($cryptxoffmeta == "true") {
178 $cryptxoff = true;
179 }
180 if (!$this->_excluded($post->ID)) {
181 $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 );
182 }
183 return $content;
184 }
185
186 function _linktext($Match)
187 {
188 global $cryptX_var;
189 switch ($cryptX_var[opt_linktext]) {
190
191 case 1: // alternative text for mail link
192 $linktext = $cryptX_var[alt_linktext];
193 break;
194
195 case 2: // alternative image for mail link
196 $linktext = "<img src=\"" . $cryptX_var[alt_linkimage] . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[alt_linkimage_title] . "\" title=\"" . $cryptX_var[alt_linkimage_title] . "\">";
197 break;
198
199 case 3: // uploaded image for mail link
200 $imgurl = $cryptX_var[alt_uploadedimage];
201 $linktext = "<img src=\"" . $imgurl . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[http_linkimage_title] . "\" title=\"" . $cryptX_var[http_linkimage_title] . "\">";
202 break;
203
204 case 4: // text scrambled by antispambot
205 $linktext = antispambot($Match[1]);
206 break;
207
208 default:
209 $linktext = str_replace( "@", $cryptX_var[at], $Match[1]);
210 $linktext = str_replace( ".", $cryptX_var[dot], $linktext);
211
212 }
213 return $linktext;
214 }
215
216 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
217
218 function _dirImages()
219 {
220 $dir = plugin_dir_path( __FILE__ ).'images';
221 $fh = opendir($dir);
222 $verzeichnisinhalt = array();
223 while (true == ($file = readdir($fh)))
224 {
225 if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif"))
226 {
227 $verzeichnisinhalt[] = $file;
228 }
229 }
230 return $verzeichnisinhalt;
231 }
232
233 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
234
235 function encryptx($content)
236 {
237 global $post;
238
239 if (!$this->_excluded($post->ID)) {
240 $content = preg_replace_callback('/<a (.*?)(href=("|\')mailto:(.*?)("|\')(.*?)|)>(.*?)<\/a>/i', array(get_class($this), 'mailtocrypt'), $content );
241 }
242 return $content;
243 }
244
245 function mailtocrypt($Match)
246 {
247 global $cryptX_var;
248 $return = $Match[0];
249 $mailto = "mailto:" . $Match[4];
250 //* If mailto contains no email adress, like a link from "Sociable" do nothing *//
251 if (substr($Match[4], 0, 9) =="?subject=") return $return;
252 if (@$cryptX_var[java]) {
253 $crypt = '';
254 $ascii = 0;
255 for ($i = 0; $i < strlen( $Match[4] ); $i++) {
256 $ascii = ord ( substr ( $Match[4], $i ) );
257 if (8364 <= $char) {
258 $ascii = 128;
259 }
260 $crypt .= chr($ascii + 1);
261 }
262 $javascript="javascript:DeCryptX('" . $crypt . "')";
263 $return = str_replace( "mailto:".$Match[4], $javascript, $return);
264 } else {
265 $return = str_replace( $mailto, antispambot($mailto), $return);
266 }
267 return $return;
268 }
269
270
271 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
272
273 function autolink($content) {
274
275 $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
276 $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si";
277 $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))([\s])/si";
278 $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si";
279 $src[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
280 $src[]="/(<a[^>]*>)<a[^>]*>/";
281 $src[]="/(<\/A>)<\/A>/i";
282
283 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>";
284 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
285 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
286 $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
287 $tar[]="<a href=\"mailto:\\0\">\\0</a>";
288 $tar[]="\\1";
289 $tar[]="\\1";
290
291 $content = preg_replace($src,$tar,$content);
292
293 return $content;
294 }
295
296 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
297
298
299 function install() {
300 global $cryptX_var, $wpdb;
301 add_option(
302 'cryptX',
303 array(
304 'at' => ' [at] ',
305 'dot' => ' [dot] ',
306 'theContent' => 1,
307 'theExcerpt' => 0,
308 'commentText' => 1,
309 'widgetText' => 0,
310 'java' => 1,
311 'opt_linktext' => 0,
312 'autolink' => 1,
313 'excludedIDs' => '',
314 'metaBox' => 1,
315 )
316 );
317 $cryptX_var = (array) get_option('cryptX'); // reread Options
318 if ($cryptX_var[excludedIDs] == "") {
319 $excludes = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff' AND meta_value = 'true'");
320 foreach ($excludes as $exclude) {
321 $tmp[] = $exclude->post_id;
322 }
323 sort($tmp);
324 $cryptX_var[excludedIDs] = implode(",", $tmp);
325 update_option( 'cryptX', $cryptX_var);
326 $cryptX_var = (array) get_option('cryptX'); // reread Options
327 $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff'");
328 }
329 }
330
331 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
332
333 /**
334 * Attach the menu page to the `Options` tab
335 */
336 function header()
337 {
338 $cryptX_script.= "<script type=\"text/javascript\" src=\"" . site_url() . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n";
339 print($cryptX_script);
340 }
341
342 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
343
344
345 function cryptx_meta() {
346 global $post;
347 ?>
348 <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
349 <?php
350 }
351
352 function cryptx_option() {
353 global $post;
354 if ( current_user_can('edit_posts') ) { ?>
355 <fieldset id="cryptxoption" class="dbx-box">
356 <h3 class="dbx-handle">CryptX</h3>
357 <div class="dbx-content">
358 <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
359 </div>
360 </fieldset>
361 <?php
362 }
363 }
364
365 function cryptx_meta_box() {
366 // Check whether the 2.5 function add_meta_box exists, and if it doesn't use 2.3 functions.
367 if ( function_exists('add_meta_box') ) {
368 add_meta_box('cryptx','CryptX', array(&$this, 'cryptx_meta'),'post');
369 add_meta_box('cryptx','CryptX', array(&$this, 'cryptx_meta'),'page');
370 } else {
371 add_action('dbx_post_sidebar', array(&$this, 'cryptx_option'));
372 add_action('dbx_page_sidebar', array(&$this, 'cryptx_option'));
373 }
374 }
375
376 //add_action('admin_menu', 'cryptx_meta_box');
377
378 function cryptx_insert_post($pID) {
379 global $cryptX_var, $post;
380 $b = explode(",", $cryptX_var[excludedIDs]);
381 foreach($b as $x=>$y) {
382 if($y == $pID) {
383 unset($b[$x]);
384 break;
385 }
386 }
387 if (isset($_POST['cryptxoff'])) $b[] = $pID;
388 sort($b);
389 $cryptX_var[excludedIDs] = implode(",", $b);
390 update_option( 'cryptX', $cryptX_var);
391 $cryptX_var = (array) get_option('cryptX'); // reread Options
392 }
393
394 /**
395 * Attach the menu page to the `Options` tab
396 */
397 function menu() {
398 add_options_page(
399 'CryptX',
400 (version_compare($GLOBALS['wp_version'], '2.6.999', '>') ? '<img src="' .@plugins_url('cryptx/icon.png'). '" width="10" height="10" alt="CryptX Icon" />' : ''). 'CryptX',
401 9,
402 __FILE__,
403 array(
404 $this,
405 '_submenu'
406 )
407 );
408 }
409
410
411 /**
412 * Handles and renders the menu page
413 */
414 function _submenu() {
415 global $cryptX_var;
416
417 if (isset($_POST) && !empty($_POST)) {
418 if (function_exists('current_user_can') === true && (current_user_can('manage_options') === false || current_user_can('edit_plugins') === false)) {
419 wp_die("You don't have permission to access!");
420 }
421 check_admin_referer('cryptX');
422 update_option( 'cryptX', $_POST['cryptX_var']);
423 $cryptX_var = (array) get_option('cryptX'); // reread Options
424 ?>
425 <div id="message" class="updated fade">
426 <p><strong><?php _e('Settings saved.') ?></strong></p>
427 </div>
428 <?php } ?>
429
430 <div class="wrap">
431 <?php if (version_compare($GLOBALS['wp_version'], '2.6.999', '>')) { ?>
432 <div class="icon32" style="background: url(<?php echo @plugins_url('cryptx/icon32.png') ?>) no-repeat"><br /></div>
433 <?php } ?>
434 <h2>CryptX</h2>
435
436 <form method="post" action="">
437
438 <?php wp_nonce_field('cryptX') ?>
439
440 <div id="poststuff" class="ui-sortable">
441 <div class="postbox">
442
443 <h3><?php _e("Presentation",'cryptx'); ?></h3>
444
445 <div class="inside">
446 <table class="form-table">
447 <tr valign="top">
448 <td><input name="cryptX_var[opt_linktext]" type="radio" id="opt_linktext" value="0" <?php echo ($cryptX_var[opt_linktext] == 0) ? 'checked="checked"' : ''; ?> /></td>
449 <th scope="row"><label for="cryptX_var[at]"><?php _e("Replacement for '@'",'cryptx'); ?></label></th>
450 <td><input name="cryptX_var[at]" value="<?php echo $cryptX_var[at]; ?>" type="text" class="regular-text" /></td>
451 </tr>
452 <tr valign="top">
453 <td>&nbsp;</td>
454 <th scope="row"><label for="cryptX_var[dot]"><?php _e("Replacement for '.'",'cryptx'); ?></label></th>
455 <td><input name="cryptX_var[dot]" value="<?php echo $cryptX_var[dot]; ?>" type="text" class="regular-text" /></td>
456 </tr>
457 <tr valign="top">
458 <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>
459 <th><label for="cryptX_var[alt_linktext]"><?php _e("Text for link",'cryptx'); ?></label></th>
460 <td><input name="cryptX_var[alt_linktext]" value="<?php echo $cryptX_var[alt_linktext]; ?>" type="text" class="regular-text" /></td>
461 </tr>
462 <tr valign="top">
463 <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>
464 <th><label for="cryptX_var[alt_linkimage]"><?php _e("Image-URL",'cryptx'); ?></label></th>
465 <td><input name="cryptX_var[alt_linkimage]" value="<?php echo $cryptX_var[alt_linkimage]; ?>" type="text" class="regular-text" /></td>
466 </tr>
467 <tr valign="top">
468 <td scope="row">&nbsp;</td>
469 <th><label for="cryptX_var[http_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th>
470 <td><input name="cryptX_var[http_linkimage_title]" value="<?php echo $cryptX_var[http_linkimage_title]; ?>" type="text" class="regular-text" /></td>
471 </tr>
472 <tr valign="top">
473 <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>
474 <th><label for="cryptX_var[alt_uploadedimage]"><?php _e("Select image from folder",'cryptx'); ?></label></th>
475 <td><select name="cryptX_var[alt_uploadedimage]" onchange="cryptX_bild_wechsel(this)">
476 <?php foreach($this->_dirImages() as $image) {
477 $FirstIMG = (!isset($FirstIMG))? plugins_url('cryptx/images/').$image : ($cryptX_var[alt_uploadedimage] == plugins_url('cryptx/images/').$image) ? plugins_url('cryptx/images/').$image : $FirstIMG;
478 ?>
479 <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>
480 <?php } ?>
481 </select>&nbsp;&nbsp;<img src="<?php echo $FirstIMG; ?>" id="cryptXmailTo"><br/>
482 <span class="setting-description"><?php echo sprintf( __("Upload your favorite email-image to '%s'. Only .jpg and .gif Supported!",'cryptx'), plugin_dir_path( __FILE__ ) ); ?></span></td>
483 </tr>
484 <tr valign="top">
485 <td>&nbsp;</td>
486 <th><label for="cryptX_var[alt_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th>
487 <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptX_var[alt_linkimage_title]; ?>" type="text" class="regular-text" /></td>
488 </tr>
489 <tr valign="top">
490 <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>
491 <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>
492 </tr>
493 </table>
494 </div>
495 </div>
496 <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
497
498 <div class="postbox">
499
500 <h3><?php _e("General",'cryptx'); ?></h3>
501
502 <div class="inside">
503 <table class="form-table">
504 <tr valign="top">
505 <th scope="row"><?php _e("Apply CryptX to...",'cryptx'); ?></th>
506 <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/>
507 <input name="cryptX_var[theExcerpt]" <?php echo ($cryptX_var[theExcerpt]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Excerpt",'cryptx'); ?><br/>
508 <input name="cryptX_var[commentText]" <?php echo ($cryptX_var[commentText]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Comments",'cryptx'); ?><br/>
509 <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>
510 </tr>
511 <tr valign="top">
512 <th scope="row"><?php _e("Excluded ID's...",'cryptx'); ?></th>
513 <td><input name="cryptX_var[excludedIDs]" value="<?php echo $cryptX_var[excludedIDs]; ?>" type="text" class="regular-text" />
514 <br/><span class="setting-description"><?php _e("Enter all Page/Post ID's to exclude from CryptX as comma seperated list.",'cryptx'); ?></span>
515 <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>
516 </tr>
517 <tr valign="top">
518 <th scope="row"><?php _e("Type of decryption",'cryptx'); ?></th>
519 <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/>
520 <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>
521 </tr>
522 <tr valign="top">
523 <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>
524 </tr>
525 </table>
526
527 </div>
528 </div>
529 <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
530
531 <div class="postbox">
532
533 <h3><?php _e("How to use CryptX in your Template",'cryptx'); ?></h3>
534
535 <div class="inside">
536 <table class="form-table">
537 <tr>
538 <td>In your Template you can use the following function to encrypt a email address:
539 <p style="border:1px solid #000; background-color: #e9e9e9;padding: 10px;">
540 <i>
541 &lt;?php <br/>
542 &nbsp;&nbsp;&nbsp;&nbsp; $mail="name@example.com"; <br/>
543 &nbsp;&nbsp;&nbsp;&nbsp; $text="Contact"; <br/>
544 &nbsp;&nbsp;&nbsp;&nbsp; $css ="email"; <br/>
545 &nbsp;&nbsp;&nbsp;&nbsp; if (function_exists('cryptx')) { <br/>
546 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cryptx($mail, $text, $css, 1); <br/>
547 &nbsp;&nbsp;&nbsp;&nbsp; } else { <br/>
548 &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/>
549 &nbsp;&nbsp;&nbsp;&nbsp; } <br/>
550 ?&gt;
551 </i></p>
552 <ol><li>parameter is the email address.</li>
553 <li>parameter is the linktext. If none given the email address is used.</li>
554 <li>parameter is a css class added to the link.</li>
555 <li>parameter is 1 for echo the encrypted email address or 0 to return the redult to a variable.</li></ol></td>
556 </tr>
557 </table>
558
559 </div>
560 </div>
561
562 <div class="postbox">
563
564 <h3><?php _e("Information",'cryptx'); ?></h3>
565
566 <div class="inside">
567 <table class="form-table">
568 <tr>
569 <td><?php
570 $data = get_plugin_data(__FILE__);
571 echo sprintf(
572 '%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 />',
573 __('Plugin'),
574 'CryptX',
575 __('Version'),
576 $data['Version'],
577 __('Author'),
578 __('Follow on Twitter', 'cryptx'),
579 __('Donate', 'cryptx')
580 );
581 ?>
582 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.
583 </td>
584 </tr>
585 </table>
586
587 </div>
588 </div>
589
590 </div>
591
592 </form>
593
594 <script type="text/javascript">
595 <!--
596 function cryptX_bild_wechsel(select){
597 document.getElementById("cryptXmailTo").src = select.options[select.options.selectedIndex].value;
598 return true;
599 } //-->
600 </script>
601
602 </div>
603 <?php
604 }
605
606 // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
607
608
609 //--end-of-class
610 }
611
612 }
613
614 /////////////////////////////////////////////////////////////////////////////
615
616 /**
617 * Initiating the plugin...
618 * @see cryptX
619 */
620 new cryptX;
621
622 /**
623 * Create Template functions...
624 * $content = string to convert
625 * $text = string to replace linktext
626 * $css = assign a css class to the link
627 * $echo = 0: keep result in a variable, 1: show result
628 */
629 function cryptx( $content, $text="", $css="", $echo=1 )
630 {
631 global $cryptX_var;
632 $cryptX = new cryptX;
633 $content = $cryptX->autolink( $content );
634 $content = $cryptX->encryptx( $content );
635 if("" != $text) {
636 $content = preg_replace( "/(<a[^>]*>)(.*)(<\/a>)/i", '$1'.$text.'$3', $content );
637 }
638 if("" != $css) {
639 $content = preg_replace( "/(<a[^>]*)(>)/i", '$1 class="'.$css.'"$2', $content );
640 }
641 if(1 == $echo) echo $content;
642 return $content;
643 }
644 ?>