PluginProbe
CryptX / 2.5.0
CryptX v2.5.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.5.0, at cryptx.php

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