PluginProbe
CryptX / 2.6.6
CryptX v2.6.6
4.2.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 All 93 releases
← All changes | cryptx.php +736 -350 trunk2.6.6 View file →
@@ -1,401 +1,787 @@
1 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.6
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 +
2 14 /**
3 - * Plugin Name: CryptX
4 - * Plugin URI: https://wordpress.org/plugins/cryptx/
5 - * Description: CryptX encrypts email addresses in your posts, pages, comments, and text widgets to protect them from spam bots while keeping them readable for your visitors.
6 - * Version: 4.2.1
7 - * Requires at least: 6.7
8 - * Tested up to: 7.1
9 - * Requires PHP: 8.1
10 - * Author: Ralf Weber
11 - * Author URI: https://weber-nrw.de/
12 - * License: GPL v2 or later
13 - * License URI: https://www.gnu.org/licenses/gpl-2.0.html
14 - * Text Domain: cryptx
15 - *
16 - * CryptX is free software: you can redistribute it and/or modify
17 - * it under the terms of the GNU General Public License as published by
18 - * the Free Software Foundation, either version 2 of the License, or
19 - * any later version.
20 - *
21 - * CryptX is distributed in the hope that it will be useful,
22 - * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 - * GNU General Public License for more details.
25 - *
26 - * You should have received a copy of the GNU General Public License
27 - * along with CryptX. If not, see https://www.gnu.org/licenses/gpl-2.0.html.
28 - *
29 - * @package CryptX
30 - * @since 1.0.0
31 - */
15 +* @internal prevent from direct calls
16 +*/
17 +if (!defined('ABSPATH')) {
18 + return ;
19 + }
32 20
33 -// Prevent direct access
34 -if (!defined('ABSPATH')) {
35 - exit;
36 -}
21 +/**
22 +* @internal prevent from second inclusion
23 +*/
24 +if (!class_exists('cryptX')) {
37 25
38 -// Plugin constants
39 -define('CRYPTX_VERSION', '4.2.1');
40 -define('CRYPTX_PLUGIN_FILE', __FILE__);
41 -define('CRYPTX_PLUGIN_BASENAME', plugin_basename(__FILE__));
42 -define('CRYPTX_BASENAME', plugin_basename(__FILE__)); // Add this missing constant
43 -define('CRYPTX_DIR_PATH', plugin_dir_path(__FILE__));
44 -define('CRYPTX_DIR_URL', plugin_dir_url(__FILE__));
45 -define('CRYPTX_BASEFOLDER', dirname(CRYPTX_PLUGIN_BASENAME));
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__) ) );
46 31
47 -// Minimum requirements. Keep these in sync with the plugin header above and
48 -// with "Requires at least" / "Requires PHP" in readme.txt. They are defined
49 -// once and used both for the check and for the notice, so the number shown to
50 -// the user cannot drift away from the number actually enforced.
51 -define('CRYPTX_MIN_PHP', '8.1');
52 -define('CRYPTX_MIN_WP', '6.7');
32 +load_plugin_textdomain('cryptx', sprintf('%s/cryptx/languages', PLUGINDIR ));
53 33
34 +$cryptX_var = (array) get_option('cryptX');
35 +
54 36 /**
55 - * Shows an admin notice to whoever is in a position to act on it.
56 - *
57 - * Registered on both admin_notices and network_admin_notices. Without the
58 - * second, a network administrator working in the network backend -- the only
59 - * person who can deactivate a network-activated plugin -- never saw that the
60 - * server runs too old a PHP, or that a class file is missing. The capability
61 - * differs per screen: on a site it is activate_plugins, in the network backend
62 - * manage_network_plugins, which a mere site administrator does not hold.
63 - *
64 - * @param string $message The message, already translated and unescaped.
65 - *
66 - * @return void
67 - */
68 -function cryptx_admin_notice(string $message): void
69 -{
70 - $render = static function () use ($message): void {
71 - $capability = is_network_admin() ? 'manage_network_plugins' : 'activate_plugins';
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 {
72 43
73 - if (!current_user_can($capability)) {
74 - return;
75 - }
44 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
76 45
77 - printf('<div class="notice notice-error"><p>%s</p></div>', esc_html($message));
78 - };
46 + /**
47 + * Constructor
48 + *
49 + * This constructor attaches the needer plugin hook callbacks
50 + */
51 + function cryptX() {
79 52
80 - add_action('admin_notices', $render);
81 - add_action('network_admin_notices', $render);
82 -}
53 + global $cryptX_var, $wp_version;
83 54
84 -if (version_compare(PHP_VERSION, CRYPTX_MIN_PHP, '<')) {
85 - cryptx_admin_notice(sprintf(
86 - /* translators: %1$s: Required PHP version, %2$s: Current PHP version */
87 - __('CryptX requires PHP version %1$s or higher. You are running version %2$s. Please update PHP.', 'cryptx'),
88 - CRYPTX_MIN_PHP,
89 - PHP_VERSION
90 - ));
91 - return;
92 -}
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 + }
93 69
94 -// WordPress version check
95 -global $wp_version;
96 -if (version_compare($wp_version, CRYPTX_MIN_WP, '<')) {
97 - cryptx_admin_notice(sprintf(
98 - /* translators: %1$s: Required WordPress version, %2$s: Current WordPress version */
99 - __('CryptX requires WordPress version %1$s or higher. You are running version %2$s. Please update WordPress.', 'cryptx'),
100 - CRYPTX_MIN_WP,
101 - $GLOBALS['wp_version']
102 - ));
103 - return;
104 -}
70 + // attach to admin menu
71 + //
72 + if (is_admin()) {
73 + add_action('admin_menu',
74 + array(&$this, 'menu')
75 + );
76 + }
105 77
106 -// Autoloader for plugin classes
107 -spl_autoload_register(function ($class) {
108 - // Check if the class belongs to our namespace
109 - if (strpos($class, 'CryptX\\') !== 0) {
110 - return;
111 - }
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 + );
112 90
113 - // Remove namespace prefix
114 - $class = substr($class, 7);
91 + // attach javascript to Header
92 + //
93 + if (@$cryptX_var[java]) {
94 + if (@$cryptX_var[load_java]) {
95 + add_action(
96 + 'wp_footer',
97 + array(&$this, 'header'),
98 + 9
99 + );
100 + } else {
101 + add_action(
102 + 'wp_head',
103 + array(&$this, 'header'),
104 + 9
105 + );
106 + }
107 + }
115 108
116 - // Convert namespace separators to directory separators
117 - $class = str_replace('\\', DIRECTORY_SEPARATOR, $class);
109 + if (@$cryptX_var[metaBox]) {
110 + add_action('admin_menu',
111 + array(&$this, 'cryptx_meta_box')
112 + );
113 +
114 + add_action('wp_insert_post',
115 + array(&$this, 'cryptx_insert_post')
116 + );
117 + add_action('wp_update_post',
118 + array(&$this, 'cryptx_insert_post')
119 + );
120 + }
121 +
122 + // Add FAQ and support information
123 + if ( version_compare( $wp_version, '2.8', '>' ) ) {
124 + add_filter( 'plugin_row_meta', array($this, 'init_row_meta'), 10, 2 ); // only 2.8 and higher
125 + } else {
126 + add_filter( 'plugin_action_links', array($this, 'init_row_meta'), 10, 2 );
127 + }
128 +
129 + // Add tinyurl for image action
130 + add_filter( 'init', array($this, 'init_tinyurl'));
131 + } // End function
118 132
119 - // Build the full path
120 - $file = CRYPTX_DIR_PATH . 'classes' . DIRECTORY_SEPARATOR . $class . '.php';
133 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
121 134
122 - // Include the file if it exists
123 - if (file_exists($file)) {
124 - require_once $file;
125 - }
126 -});
135 + function init_tinyurl() {
136 + global $cryptX_var;
137 + // check TinyURl
138 + $url = $_SERVER["REQUEST_URI"];
139 + $params = explode( '/', $url );
140 + if ( count( $params ) > 1 ) {
141 + $tiny_url = $params[count( $params ) -2];
142 + if ( $tiny_url == md5( get_bloginfo('url') ) ) {
143 + // define vars
144 + $font = $cryptX_var[c2i_font];
145 + $msg = $params[count( $params ) -1];
146 + $size = $cryptX_var[c2i_fontSize];
147 + $pad = 1;
148 + $transparent = 1;
149 + $red = hexdec(substr($cryptX_var[c2i_fontRGB],0,2));
150 + $grn = hexdec(substr($cryptX_var[c2i_fontRGB],2,2));
151 + $blu = hexdec(substr($cryptX_var[c2i_fontRGB],4,2));
152 + $bg_red = 255 - $red;
153 + $bg_grn = 255 - $grn;
154 + $bg_blu = 255 - $blu;
155 + $width = 0;
156 + $height = 0;
157 + $offset_x = 0;
158 + $offset_y = 0;
159 + $bounds = array();
160 + $image = "";
161 + // get the font height.
162 + $bounds = ImageTTFBBox($size, 0, $font, "W");
163 + if ($rot < 0)
164 + {
165 + $font_height = abs($bounds[7]-$bounds[1]);
166 + }
167 + else if ($rot > 0)
168 + {
169 + $font_height = abs($bounds[1]-$bounds[7]);
170 + }
171 + else
172 + {
173 + $font_height = abs($bounds[7]-$bounds[1]);
174 + }
175 + // determine bounding box.
176 + $bounds = ImageTTFBBox($size, 0, $font, $msg);
177 + $width = abs($bounds[4]-$bounds[6]);
178 + $height = abs($bounds[7]-$bounds[1]);
179 + $offset_y = $font_height+abs(($height - $font_height)/2)-1;
180 + $offset_x = 0;
181 + $image = imagecreatetruecolor($width+($pad*2),$height+($pad*2));
182 + imagesavealpha($image, true);
183 + //$background = ImageColorAllocate($image, $bg_red, $bg_grn, $bg_blu);
184 + $foreground = ImageColorAllocate($image, $red, $grn, $blu);
185 + $background = imagecolorallocatealpha($image, 0, 0, 0, 127);
186 + imagefill($image, 0, 0, $background);
187 + // render the image
188 + ImageTTFText($image, $size, 0, $offset_x+$pad, $offset_y+$pad, $foreground, $font, $msg);
189 + // output PNG object.
190 + Header("Content-type: image/png");
191 + imagePNG($image);
192 + die;
193 + }
194 + }
195 + }
127 196
128 -// The settings screen posts nothing: it talks to the REST routes in
129 -// CryptX\Admin\RestController, which carry their own capability check and are
130 -// covered by WordPress' REST nonce. The global cryptx_nonce_check() that used
131 -// to sit here guarded $_POST['cryptX_var'], a key nothing has sent since the
132 -// old settings form was removed in 4.1.0 -- a dead guard next to a live one is
133 -// a trap for whoever wires up the next form.
197 + function init_row_meta($links, $file) {
198 + if (CRYPTX_BASENAME == $file) {
199 + return array_merge(
200 + $links,
201 + array(
202 + sprintf(
203 + '<a href="options-general.php?page=%s">%s</a>',
204 + CRYPTX_BASENAME,
205 + __('Settings')
206 + )
207 + ),
208 + array(
209 + sprintf(
210 + '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696">%s</a>',
211 + __('Donate', 'cryptx')
212 + )
213 + )
214 + );
215 + }
216 + return $links;
217 + }
134 218
135 -// Initialize the plugin
136 -add_action('plugins_loaded', function() {
137 - // Check if all required classes can be loaded
138 - $requiredClasses = [
139 - 'CryptX\\CryptX',
140 - 'CryptX\\Config',
141 - 'CryptX\\SecureEncryption',
142 - 'CryptX\\Exposure',
143 - 'CryptX\\Block',
144 - 'CryptX\\ImageToken',
145 - 'CryptX\\Admin\\NetworkDefaults',
146 - 'CryptX\\Admin\\SettingsPage',
147 - 'CryptX\\Admin\\SettingsSchema',
148 - 'CryptX\\Admin\\RestController',
149 - 'CryptX\\Admin\\SiteHealth',
150 - ];
219 + function filter($apply)
220 + {
221 + global $cryptX_var, $post, $shortcode_tags;
151 222
152 - $missingClasses = [];
153 - foreach ($requiredClasses as $class) {
154 - if (!class_exists($class)) {
155 - $missingClasses[] = $class;
156 - }
157 - }
223 + if (@$cryptX_var[autolink]) {
224 + add_filter($apply, array(&$this, 'autolink'), 5);
225 + if (!empty($shortcode_tags) || is_array($shortcode_tags)) {
226 + add_filter($apply, array(&$this, 'autolink'), 11);
227 + }
228 + }
229 + add_filter($apply, array($this, 'encryptx'), 12);
230 + add_filter($apply, array($this, 'linktext'), 13);
231 + }
158 232
159 - if (!empty($missingClasses)) {
160 - cryptx_admin_notice(
161 - __('CryptX: Missing required classes: ', 'cryptx') . implode(', ', $missingClasses)
162 - );
163 - return;
164 - }
233 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
165 234
166 - // Initialize the main plugin class
167 - try {
168 - $cryptx_instance = CryptX\CryptX::get_instance();
169 - $cryptx_instance->startCryptX();
170 - cryptx_register_action_links();
235 + function _excluded($ID) {
236 + global $cryptX_var;
237 + $return = false;
238 + $exIDs = explode(",", $cryptX_var[excludedIDs]);
239 + if(in_array($ID, $exIDs) > 0 ) $return = true;
240 + return $return;
241 + }
242 +
243 + function linktext($content)
244 + {
245 + global $post;
246 + if (!$this->_excluded($post->ID)) {
247 + $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 );
248 + }
249 + return $content;
250 + }
171 251
172 - // Guarded here as well as inside register(), and deliberately not
173 - // listed in $requiredClasses above. Both of those would load the file
174 - // on every single front-end and admin request -- class_exists() runs
175 - // the autoloader, and so does a static call -- to register commands
176 - // that only exist under WP-CLI.
177 - //
178 - // class_exists() is still asked so that a package missing the file
179 - // cannot raise a fatal Error, which catch (Exception) below would not
180 - // have caught. It buys no notice: the commands are then simply absent.
181 - // That is the right silence -- nothing a visitor or an administrator
182 - // sees depends on them.
183 - if (defined('WP_CLI') && WP_CLI && class_exists('CryptX\Cli')) {
184 - CryptX\Cli::register();
185 - }
186 - } catch (Exception $e) {
187 - cryptx_admin_notice(
188 - __('CryptX initialization failed: ', 'cryptx') . $e->getMessage()
189 - );
190 - }
191 -});
252 + function _linktext($Match)
253 + {
254 + global $cryptX_var;
255 + switch ($cryptX_var[opt_linktext]) {
192 256
193 -/**
194 - * Runs a callback once for every site of the network, in batches.
195 - *
196 - * get_sites() without a limit pulls the whole network into memory, and a
197 - * network can have thousands of sites. Same construction as uninstall.php,
198 - * deliberately: the two do the same job at opposite ends of the plugin's life,
199 - * and one of them being cleverer than the other only makes both harder to
200 - * trust.
201 - *
202 - * On a single site the callback simply runs once.
203 - *
204 - * @param callable $callback Receives nothing; runs with the site switched in.
205 - *
206 - * @return void
207 - */
208 -function cryptx_for_each_site(callable $callback): void
209 -{
210 - if (!is_multisite()) {
211 - $callback();
257 + case 1: // alternative text for mail link
258 + $linktext = $cryptX_var[alt_linktext];
259 + break;
212 260
213 - return;
214 - }
261 + case 2: // alternative image for mail link
262 + $linktext = "<img src=\"" . $cryptX_var[alt_linkimage] . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[alt_linkimage_title] . "\" title=\"" . $cryptX_var[alt_linkimage_title] . "\" />";
263 + break;
215 264
216 - $batch_size = 100;
217 - $offset = 0;
265 + case 3: // uploaded image for mail link
266 + $imgurl = $cryptX_var[alt_uploadedimage];
267 + $linktext = "<img src=\"" . $imgurl . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var[http_linkimage_title] . "\" title=\"" . $cryptX_var[http_linkimage_title] . "\" />";
268 + break;
218 269
219 - do {
220 - $site_ids = get_sites([
221 - 'fields' => 'ids',
222 - 'number' => $batch_size,
223 - 'offset' => $offset,
224 - 'orderby' => 'id',
225 - 'update_site_meta_cache' => false,
226 - ]);
270 + case 4: // text scrambled by antispambot
271 + $linktext = antispambot($Match[1]);
272 + break;
227 273
228 - foreach ($site_ids as $site_id) {
229 - switch_to_blog($site_id);
274 + case 5: // convert to image
275 + $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]) . "\" />";
276 + break;
230 277
231 - // finally, so a failing callback does not leave the blog stack
232 - // switched for whatever runs next. It does not keep the loop
233 - // going: an exception still travels upwards and the remaining
234 - // sites are skipped. Catching it here would hide a broken site
235 - // instead, and that is a trade to make deliberately, not in
236 - // passing.
237 - try {
238 - $callback();
239 - } finally {
240 - restore_current_blog();
241 - }
242 - }
278 + default:
279 + $linktext = str_replace( "@", $cryptX_var[at], $Match[1]);
280 + $linktext = str_replace( ".", $cryptX_var[dot], $linktext);
243 281
244 - $offset += $batch_size;
245 - } while (count($site_ids) === $batch_size);
246 -}
282 + }
283 + return $linktext;
284 + }
247 285
248 -/**
249 - * Removes the plugin's transients from the site that is currently switched in.
250 - *
251 - * @return void
252 - */
253 -function cryptx_delete_transients(): void
254 -{
255 - global $wpdb;
286 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
256 287
257 - // The LIKE patterns run through $wpdb->esc_like() and $wpdb->prepare().
258 - // No user input is involved here, so this is not a hole, but "_" is a
259 - // single-character wildcard in LIKE: unescaped, '_transient_cryptx_%' also
260 - // matches names like 'Xtransient1cryptxZ...' belonging to other plugins.
261 - // esc_like() turns those underscores into literal ones. The table name is
262 - // an identifier, not a value, and therefore must stay outside prepare().
263 - $transientLike = $wpdb->esc_like('_transient_cryptx_') . '%';
264 - $transientTimeoutLike = $wpdb->esc_like('_transient_timeout_cryptx_') . '%';
288 + function _dirImages()
289 + {
290 + $dir = plugin_dir_path( __FILE__ ).'images';
291 + $fh = opendir($dir);
292 + $verzeichnisinhalt = array();
293 + while (true == ($file = readdir($fh)))
294 + {
295 + if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif"))
296 + {
297 + $verzeichnisinhalt[] = $file;
298 + }
299 + }
300 + return $verzeichnisinhalt;
301 + }
265 302
266 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
267 - $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $transientLike));
268 - // phpcs:ignore WordPress.DB.DirectDatabaseQuery.DirectQuery, WordPress.DB.DirectDatabaseQuery.NoCaching
269 - $wpdb->query($wpdb->prepare("DELETE FROM {$wpdb->options} WHERE option_name LIKE %s", $transientTimeoutLike));
270 -}
303 + function _dirFonts()
304 + {
305 + $dir = plugin_dir_path( __FILE__ ).'fonts';
306 + $fh = opendir($dir);
307 + $verzeichnisinhalt = array();
308 + while (true == ($file = readdir($fh)))
309 + {
310 + if ((substr(strtolower($file), -3)=="ttf") or (substr(strtolower($file), -3)=="ttf"))
311 + {
312 + $verzeichnisinhalt[] = $file;
313 + }
314 + }
315 + return $verzeichnisinhalt;
316 + }
271 317
272 -/**
273 - * Sets up the plugin's options for the site that is currently switched in.
274 - *
275 - * @return void
276 - */
277 -function cryptx_install_site(): void
278 -{
279 - if (!class_exists('CryptX\\CryptX')) {
280 - return;
281 - }
318 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
282 319
283 - CryptX\CryptX::get_instance()->installCryptX();
284 -}
320 + function encryptx($content)
321 + {
322 + global $post;
323 +
324 + if (!$this->_excluded($post->ID)) {
325 + $content = preg_replace_callback('/<a (.*?)(href=("|\')mailto:(.*?)("|\')(.*?)|)>(.*?)<\/a>/i', array(get_class($this), 'mailtocrypt'), $content );
326 + }
327 + return $content;
328 + }
285 329
286 -// Activation.
287 -//
288 -// $network_wide is true when someone ticks "Network Activate". WordPress then
289 -// fires this hook exactly once, not once per site -- so without the loop, every
290 -// site but the current one is left without its stored options and, more to the
291 -// point, without the one-time migration of the pre-4.0 "cryptxoff" post meta.
292 -// The plugin still works there, because the defaults fill in, but a site that
293 -// carried excluded posts from an old version would silently lose them.
294 -register_activation_hook(__FILE__, function ($network_wide = false) {
295 - if ($network_wide) {
296 - cryptx_for_each_site('cryptx_install_site');
297 - } else {
298 - cryptx_install_site();
299 - }
330 + function mailtocrypt($Match)
331 + {
332 + global $cryptX_var;
333 + $return = $Match[0];
334 + $mailto = "mailto:" . $Match[4];
335 + //* If mailto contains no email adress, like a link from "Sociable" do nothing *//
336 + if (substr($Match[4], 0, 9) =="?subject=") return $return;
337 + if (@$cryptX_var[java]) {
338 + $crypt = '';
339 + $ascii = 0;
340 + for ($i = 0; $i < strlen( $Match[4] ); $i++) {
341 + $ascii = ord ( substr ( $Match[4], $i ) );
342 + if (8364 <= $char) {
343 + $ascii = 128;
344 + }
345 + $crypt .= chr($ascii + 1);
346 + }
347 + $javascript="javascript:DeCryptX('" . $crypt . "')";
348 + $return = str_replace( "mailto:".$Match[4], $javascript, $return);
349 + } else {
350 + $return = str_replace( $mailto, antispambot($mailto), $return);
351 + }
352 + return $return;
353 + }
300 354
301 - flush_rewrite_rules();
302 -});
303 355
304 -// Deactivation. Same reason, other direction: the transients of every site but
305 -// the current one used to survive a network deactivation.
306 -register_deactivation_hook(__FILE__, function ($network_wide = false) {
307 - if ($network_wide) {
308 - cryptx_for_each_site('cryptx_delete_transients');
309 - } else {
310 - cryptx_delete_transients();
311 - }
312 -});
356 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
313 357
314 -// A site created while the plugin is network-active gets the same treatment as
315 -// one that existed at activation time. Without this the new site works -- the
316 -// defaults see to that -- but nothing is ever written until someone saves, and
317 -// the behaviour differs from every other site in the network for no reason
318 -// anybody could see.
319 -add_action('wp_initialize_site', function ($site) {
320 - // The network option directly, not is_plugin_active_for_network(): that
321 - // lives in wp-admin/includes/plugin.php, which is not loaded when a site is
322 - // created over the REST API or WP-CLI -- exactly the paths that create sites
323 - // in bulk.
324 - $network_active = get_site_option('active_sitewide_plugins', []);
358 + function autolink($content) {
359 + global $post;
360 + if ($this->_excluded($post->ID)) return $content;
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-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(\))/si";
364 + $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))([\s])/si";
365 + $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si";
366 + $src[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si";
367 + $src[]="/(<a[^>]*>)<a[^>]*>/";
368 + $src[]="/(<\/A>)<\/A>/i";
369 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>";
370 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
371 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
372 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
373 + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6";
374 + $tar[]="<a href=\"mailto:\\0\">\\0</a>";
375 + $tar[]="\\1";
376 + $tar[]="\\1";
377 + $content = preg_replace($src,$tar,$content);
378 + return $content;
379 + }
325 380
326 - if (!isset($network_active[CRYPTX_PLUGIN_BASENAME])) {
327 - return;
328 - }
381 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
329 382
330 - $site_id = is_object($site) ? (int) $site->blog_id : (int) $site;
331 383
332 - switch_to_blog($site_id);
333 - cryptx_install_site();
334 - restore_current_blog();
335 -}, 20);
384 + function install() {
385 + global $cryptX_var, $wpdb;
386 + $firstImage = $this->_dirImages();
387 + $firstFont = $this->_dirFonts();
388 + add_option(
389 + 'cryptX',
390 + array(
391 + 'at' => ' [at] ',
392 + 'dot' => ' [dot] ',
393 + 'theContent' => 1,
394 + 'theExcerpt' => 0,
395 + 'commentText' => 1,
396 + 'widgetText' => 0,
397 + 'java' => 1,
398 + 'opt_linktext' => 0,
399 + 'autolink' => 1,
400 + 'excludedIDs' => '',
401 + 'metaBox' => 1,
402 + 'alt_uploadedimage' => plugins_url('cryptx/images/').$firstImage[0],
403 + 'c2i_font' => plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0],
404 + 'c2i_fontSize' => 10,
405 + 'c2i_fontRGB' => '000000',
406 + )
407 + );
408 + $cryptX_var = (array) get_option('cryptX'); // reread Options
409 + if ($cryptX_var[excludedIDs] == "") {
410 + $tmp = array();
411 + $excludes = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff' AND meta_value = 'true'");
412 + if(count($excludes) > 0) {
413 + foreach ($excludes as $exclude) {
414 + $tmp[] = $exclude->post_id;
415 + }
416 + sort($tmp);
417 + $cryptX_var[excludedIDs] = implode(",", $tmp);
418 + update_option( 'cryptX', $cryptX_var);
419 + $cryptX_var = (array) get_option('cryptX'); // reread Options
420 + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff'");
421 + }
422 + }
423 + if (empty($cryptX_var[c2i_font])) {
424 + $cryptX_var[c2i_font] = plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0];
425 + }
426 + if (empty($cryptX_var[c2i_fontSize])) {
427 + $cryptX_var[c2i_fontSize] = 10;
428 + }
429 + if (empty($cryptX_var[c2i_fontRGB])) {
430 + $cryptX_var[c2i_fontRGB] = '000000';
431 + }
432 + update_option( 'cryptX', $cryptX_var);
433 + $cryptX_var = (array) get_option('cryptX'); // reread Options
434 + }
336 435
337 -// Add plugin action links.
338 -//
339 -// Registered inside the successful-initialisation path on purpose, not at the
340 -// top level of this file. It refers to a class constant, and the plugins screen
341 -// is exactly where someone goes to switch off a plugin whose class files are
342 -// missing -- a fatal error there would take away the only lever they have.
343 -// A plugin that did not initialise has no settings page to link to anyway.
344 -function cryptx_register_action_links(): void
345 -{
346 - add_filter('plugin_action_links_' . CRYPTX_PLUGIN_BASENAME, function ($links) {
347 - $settings_link = '<a href="' .
348 - esc_url(admin_url('options-general.php?page=' . CryptX\Admin\SettingsPage::MENU_SLUG)) .
349 - '">' . esc_html__('Settings', 'cryptx') . '</a>';
350 - array_unshift($links, $settings_link);
436 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
351 437
352 - return $links;
353 - });
354 -}
438 + /**
439 + * Attach the menu page to the `Options` tab
440 + */
441 + function header()
442 + {
443 + $cryptX_script.= "<script type=\"text/javascript\" src=\"" . site_url() . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n";
444 + print($cryptX_script);
445 + }
355 446
356 -/**
357 - * Encrypts the given content using the CryptX library and wraps it with a shortcode.
358 - *
359 - * @param string $content The content to be encrypted.
360 - * @param array|null $args Optional arguments to customize the encryption process.
361 - *
362 - * @return string The encrypted content wrapped in the appropriate shortcode.
363 - */
364 -if (!function_exists('cryptx_encrypt')) {
365 - function cryptx_encrypt(string $content, ?array $args = []): string
366 - {
367 - $cryptXInstance = Cryptx\CryptX::get_instance();
368 - // $attributesString contains the escaped (esc_attr()) shortcode attributes from $args
369 - // The signature allows null, convertArrayToArgumentString() does not.
370 - $attributesString = $cryptXInstance->convertArrayToArgumentString($args ?? []);
447 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
371 448
372 - // wp_kses_post() and not esc_html(): the caller passes content, and
373 - // content in WordPress may carry markup. esc_html() turned a "<br>" in
374 - // a theme field into a visible "&lt;br&gt;" -- reported in the support
375 - // forum, and worked around there with html_entity_decode(), which
376 - // undoes the plugin's own protection in the Unicode and entity modes.
377 - // wp_kses_post keeps what a post may contain and drops the rest.
378 - $shortcode = '[cryptx' . $attributesString . ']' . wp_kses_post($content) . '[/cryptx]';
379 449
380 - return do_shortcode($shortcode);
381 - }
450 + function cryptx_meta() {
451 + global $post;
452 + ?>
453 + <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
454 + <?php
455 + }
456 +
457 + function cryptx_option() {
458 + global $post;
459 + if ( current_user_can('edit_posts') ) { ?>
460 + <fieldset id="cryptxoption" class="dbx-box">
461 + <h3 class="dbx-handle">CryptX</h3>
462 + <div class="dbx-content">
463 + <input type="checkbox" name="cryptxoff" <?php if ($this->_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page
464 + </div>
465 + </fieldset>
466 + <?php
467 + }
468 + }
469 +
470 + function cryptx_meta_box() {
471 + // Check whether the 2.5 function add_meta_box exists, and if it doesn't use 2.3 functions.
472 + if ( function_exists('add_meta_box') ) {
473 + add_meta_box('cryptx','CryptX', array(&$this, 'cryptx_meta'),'post');
474 + add_meta_box('cryptx','CryptX', array(&$this, 'cryptx_meta'),'page');
475 + } else {
476 + add_action('dbx_post_sidebar', array(&$this, 'cryptx_option'));
477 + add_action('dbx_page_sidebar', array(&$this, 'cryptx_option'));
478 + }
479 + }
480 +
481 + //add_action('admin_menu', 'cryptx_meta_box');
482 +
483 + function cryptx_insert_post($pID) {
484 + global $cryptX_var, $post;
485 +
486 + $rev = wp_is_post_revision($pID);
487 + if($rev) $pID = $rev;
488 + $b = explode(",", $cryptX_var[excludedIDs]);
489 + if($b[0] == '') unset($b[0]);
490 + foreach($b as $x=>$y) {
491 + if($y == $pID) {
492 + unset($b[$x]);
493 + break;
494 + }
495 + }
496 + if (isset($_POST['cryptxoff'])) $b[] = $pID;
497 + $b = array_unique($b);
498 + sort($b);
499 + $cryptX_var[excludedIDs] = implode(",", $b);
500 + update_option( 'cryptX', $cryptX_var);
501 + $cryptX_var = (array) get_option('cryptX'); // reread Options
502 + }
503 +
504 + /**
505 + * Attach the menu page to the `Options` tab
506 + */
507 + function menu() {
508 + add_options_page(
509 + 'CryptX',
510 + (version_compare($GLOBALS['wp_version'], '2.6.999', '>') ? '<img src="' .@plugins_url('cryptx/icon.png'). '" width="10" height="10" alt="CryptX Icon" />' : ''). 'CryptX',
511 + 9,
512 + __FILE__,
513 + array(
514 + $this,
515 + '_submenu'
516 + )
517 + );
518 + }
519 +
520 +
521 + /**
522 + * Handles and renders the menu page
523 + */
524 + function _submenu() {
525 + global $cryptX_var;
526 +
527 + if (isset($_POST) && !empty($_POST)) {
528 + if (function_exists('current_user_can') === true && (current_user_can('manage_options') === false || current_user_can('edit_plugins') === false)) {
529 + wp_die("You don't have permission to access!");
530 + }
531 + check_admin_referer('cryptX');
532 + update_option( 'cryptX', $_POST['cryptX_var']);
533 + $cryptX_var = (array) get_option('cryptX'); // reread Options
534 + ?>
535 + <div id="message" class="updated fade">
536 + <p><strong><?php _e('Settings saved.') ?></strong></p>
537 + </div>
538 + <?php } ?>
539 +
540 + <div class="wrap">
541 + <?php if (version_compare($GLOBALS['wp_version'], '2.6.999', '>')) { ?>
542 + <div class="icon32" style="background: url(<?php echo @plugins_url('cryptx/icon32.png') ?>) no-repeat"><br /></div>
543 + <?php } ?>
544 + <h2>CryptX</h2>
545 +
546 + <form method="post" action="">
547 +
548 + <?php wp_nonce_field('cryptX') ?>
549 +
550 + <div id="poststuff" class="ui-sortable">
551 + <div class="postbox">
552 +
553 + <h3><?php _e("Presentation",'cryptx'); ?></h3>
554 +
555 + <div class="inside">
556 + <table class="form-table">
557 + <tr valign="top">
558 + <td><input name="cryptX_var[opt_linktext]" type="radio" id="opt_linktext" value="0" <?php echo ($cryptX_var[opt_linktext] == 0) ? 'checked="checked"' : ''; ?> /></td>
559 + <th scope="row"><label for="cryptX_var[at]"><?php _e("Replacement for '@'",'cryptx'); ?></label></th>
560 + <td><input name="cryptX_var[at]" value="<?php echo $cryptX_var[at]; ?>" type="text" class="regular-text" /></td>
561 + </tr>
562 + <tr valign="top">
563 + <td>&nbsp;</td>
564 + <th scope="row"><label for="cryptX_var[dot]"><?php _e("Replacement for '.'",'cryptx'); ?></label></th>
565 + <td><input name="cryptX_var[dot]" value="<?php echo $cryptX_var[dot]; ?>" type="text" class="regular-text" /></td>
566 + </tr>
567 + <tr valign="top">
568 + <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>
569 + <th><label for="cryptX_var[alt_linktext]"><?php _e("Text for link",'cryptx'); ?></label></th>
570 + <td><input name="cryptX_var[alt_linktext]" value="<?php echo $cryptX_var[alt_linktext]; ?>" type="text" class="regular-text" /></td>
571 + </tr>
572 + <tr valign="top">
573 + <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>
574 + <th><label for="cryptX_var[alt_linkimage]"><?php _e("Image-URL",'cryptx'); ?></label></th>
575 + <td><input name="cryptX_var[alt_linkimage]" value="<?php echo $cryptX_var[alt_linkimage]; ?>" type="text" class="regular-text" /></td>
576 + </tr>
577 + <tr valign="top">
578 + <td scope="row">&nbsp;</td>
579 + <th><label for="cryptX_var[http_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th>
580 + <td><input name="cryptX_var[http_linkimage_title]" value="<?php echo $cryptX_var[http_linkimage_title]; ?>" type="text" class="regular-text" /></td>
581 + </tr>
582 + <tr valign="top">
583 + <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>
584 + <th><label for="cryptX_var[alt_uploadedimage]"><?php _e("Select image from folder",'cryptx'); ?></label></th>
585 + <td> <select name="cryptX_var[alt_uploadedimage]" onchange="cryptX_bild_wechsel(this)">
586 + <?php foreach($this->_dirImages() as $image) {
587 + ?>
588 + <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>
589 + <?php } ?>
590 + </select>
591 + <br/><?php _e("the selected image: ",'cryptx'); ?><img src="<?php echo $cryptX_var[alt_uploadedimage]; ?>" id="cryptXmailTo" align="top" style="padding: 3px;"><br/>
592 + <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>
593 + </tr>
594 + <tr valign="top">
595 + <td>&nbsp;</td>
596 + <th><label for="cryptX_var[alt_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th>
597 + <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptX_var[alt_linkimage_title]; ?>" type="text" class="regular-text" /></td>
598 + </tr>
599 + <tr valign="top">
600 + <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>
601 + <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>
602 + </tr>
603 + <tr valign="top">
604 + <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>
605 + <th><?php _e("Convert Email to PNG-image",'cryptx'); ?></th>
606 + <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>
607 + </tr>
608 + <tr valign="top">
609 + <td>&nbsp;</td>
610 + <th><label for="cryptX_var[c2i_font]"><?php _e("Choose a Font",'cryptx'); ?></label></th>
611 + <td><select name="cryptX_var[c2i_font]">
612 + <?php foreach($this->_dirFonts() as $font) { ?>
613 + <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>
614 + <?php } ?>
615 + </select><br/>
616 + <span class="setting-description"><?php echo sprintf( __("Upload your favorite font to '%s'. Only .ttf is Supported!",'cryptx'), plugin_dir_path( __FILE__ ).'fonts/' ); ?></span>
617 + </td>
618 + </tr>
619 + <tr valign="top">
620 + <td>&nbsp;</td>
621 + <th><label for="cryptX_var[c2i_fontSize]"><?php _e("Font size (pixel)",'cryptx'); ?></label></th>
622 + <td><input name="cryptX_var[c2i_fontSize]" value="<?php echo $cryptX_var[c2i_fontSize]; ?>" type="text" class="regular-text" /></td>
623 + </tr>
624 + <tr valign="top">
625 + <td>&nbsp;</td>
626 + <th><label for="cryptX_var[c2i_fontRGB]"><?php _e("Font color (RGB)",'cryptx'); ?></label></th>
627 + <td><input name="cryptX_var[c2i_fontRGB]" value="<?php echo $cryptX_var[c2i_fontRGB]; ?>" type="text" class="regular-text" /></td>
628 + </tr>
629 + </table>
630 + </div>
631 + </div>
632 +
633 + <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
634 +
635 + <div class="postbox">
636 +
637 + <h3><?php _e("General",'cryptx'); ?></h3>
638 +
639 + <div class="inside">
640 + <table class="form-table">
641 + <tr valign="top">
642 + <th scope="row"><?php _e("Apply CryptX to...",'cryptx'); ?></th>
643 + <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/>
644 + <input name="cryptX_var[theExcerpt]" <?php echo ($cryptX_var[theExcerpt]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Excerpt",'cryptx'); ?><br/>
645 + <input name="cryptX_var[commentText]" <?php echo ($cryptX_var[commentText]) ? 'checked="checked"' : ''; ?> type="checkbox" />&nbsp;&nbsp;<?php _e("Comments",'cryptx'); ?><br/>
646 + <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>
647 + </tr>
648 + <tr valign="top">
649 + <th scope="row"><?php _e("Excluded ID's...",'cryptx'); ?></th>
650 + <td><input name="cryptX_var[excludedIDs]" value="<?php echo $cryptX_var[excludedIDs]; ?>" type="text" class="regular-text" />
651 + <br/><span class="setting-description"><?php _e("Enter all Page/Post ID's to exclude from CryptX as comma seperated list.",'cryptx'); ?></span>
652 + <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>
653 + </tr>
654 + <tr valign="top">
655 + <th scope="row"><?php _e("Type of decryption",'cryptx'); ?></th>
656 + <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/>
657 + <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>
658 + </tr>
659 + <tr valign="top">
660 + <th scope="row"><?php _e("Where to load the needed javascript...",'cryptx'); ?></th>
661 + <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/>
662 + <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>
663 + </tr>
664 + <tr valign="top">
665 + <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>
666 + </tr>
667 + </table>
668 +
669 + </div>
670 + </div>
671 + <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p>
672 +
673 + <div class="postbox">
674 +
675 + <h3><?php _e("How to use CryptX in your Template",'cryptx'); ?></h3>
676 +
677 + <div class="inside">
678 + <table class="form-table">
679 + <tr>
680 + <td>In your Template you can use the following function to encrypt a email address:
681 + <p style="border:1px solid #000; background-color: #e9e9e9;padding: 10px;">
682 + <i>
683 + &lt;?php <br/>
684 + &nbsp;&nbsp;&nbsp;&nbsp; $mail="name@example.com"; <br/>
685 + &nbsp;&nbsp;&nbsp;&nbsp; $text="Contact"; <br/>
686 + &nbsp;&nbsp;&nbsp;&nbsp; $css ="email"; <br/>
687 + &nbsp;&nbsp;&nbsp;&nbsp; if (function_exists('cryptx')) { <br/>
688 + &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cryptx($mail, $text, $css, 1); <br/>
689 + &nbsp;&nbsp;&nbsp;&nbsp; } else { <br/>
690 + &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/>
691 + &nbsp;&nbsp;&nbsp;&nbsp; } <br/>
692 + ?&gt;
693 + </i></p>
694 + <ol><li>parameter is the email address.</li>
695 + <li>parameter is the linktext. If none given the email address is used.</li>
696 + <li>parameter is a css class added to the link.</li>
697 + <li>parameter is 1 for echo the encrypted email address or 0 to return the redult to a variable.</li></ol></td>
698 + </tr>
699 + </table>
700 +
701 + </div>
702 + </div>
703 +
704 + <div class="postbox">
705 +
706 + <h3><?php _e("Information",'cryptx'); ?></h3>
707 +
708 + <div class="inside">
709 + <table class="form-table">
710 + <tr>
711 + <td><?php
712 + $data = get_plugin_data(__FILE__);
713 + echo sprintf(
714 + '%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 />',
715 + __('Plugin'),
716 + 'CryptX',
717 + __('Version'),
718 + $data['Version'],
719 + __('Author'),
720 + __('Follow on Twitter', 'cryptx'),
721 + __('Donate', 'cryptx')
722 + );
723 + ?>
724 + 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.
725 + </td>
726 + </tr>
727 + </table>
728 +
729 + </div>
730 + </div>
731 +
732 + </div>
733 +
734 + </form>
735 +
736 + <script type="text/javascript">
737 + <!--
738 + function cryptX_bild_wechsel(select){
739 + document.getElementById("cryptXmailTo").src = select.options[select.options.selectedIndex].value;
740 + return true;
741 + } //-->
742 + </script>
743 +
744 + </div>
745 +<?php
746 + }
747 +
748 + // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
749 +
750 +
751 + //--end-of-class
752 + }
753 +
382 754 }
383 755
756 +/////////////////////////////////////////////////////////////////////////////
757 +
384 758 /**
385 - * Encrypts the given content using the CryptX library and wraps it with a shortcode.
386 - *
387 - * @deprecated 4.0.5 Use cryptx_encrypt() instead.
388 - * @see cryptx_encrypt()
389 - */
390 -if (!function_exists('encryptx')) {
391 - function encryptx(string $content, ?array $args = []): string
392 - {
393 - _doing_it_wrong(
394 - 'encryptx',
395 - esc_html__('This function is deprecated. Use cryptx_encrypt() instead.', 'cryptx'),
396 - '4.0.5'
397 - );
759 +* Initiating the plugin...
760 +* @see cryptX
761 +*/
762 +new cryptX;
398 763
399 - return cryptx_encrypt($content, $args);
400 - }
401 -}
764 +/**
765 +* Create Template functions...
766 +* $content = string to convert
767 +* $text = string to replace linktext
768 +* $css = assign a css class to the link
769 +* $echo = 0: keep result in a variable, 1: show result
770 +*/
771 +function cryptx( $content, $text="", $css="", $echo=1 )
772 +{
773 + global $cryptX_var;
774 + $cryptX = new cryptX;
775 + $content = $cryptX->autolink( $content );
776 + $content = $cryptX->encryptx( $content );
777 + $content = $cryptX->linktext( $content );
778 + if("" != $text) {
779 + $content = preg_replace( "/(<a[^>]*>)(.*)(<\/a>)/i", '$1'.$text.'$3', $content );
780 + }
781 + if("" != $css) {
782 + $content = preg_replace( "/(<a[^>]*)(>)/i", '$1 class="'.$css.'"$2', $content );
783 + }
784 + if(1 == $echo) echo $content;
785 + return $content;
786 +}
787 +?>