PluginProbe
CryptX / 3.3.2
CryptX v3.3.2
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 +52 -298 1.03.3.2 View file →
@@ -1,318 +1,72 @@
1 1 <?php
2 2 /*
3 -Plugin Name: CryptX
4 -Plugin URI: http://weber-nrw.de/
5 -Description: En-/Decrypt mailto-Links to prevent Spam Bots scanning Sorcecode for Emails.
6 -Version: 1.0
7 -Author: Ralf Weber
8 -Author URI: http://weber-nrw.de/
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: 3.3.2
7 + * Requires at least: 4.6
8 + * Author: Ralf Weber
9 + * Author URI: http://weber-nrw.de/
10 + * License: GPL v2 or later
11 + * License URI: https://www.gnu.org/licenses/gpl-2.0.html
12 + * Text Domain: cryptx
9 13 */
10 14
11 -/////////////////////////////////////////////////////////////////////////////
15 +//avoid direct calls to this file, because now WP core and framework has been used
16 +if ( ! function_exists('add_action') ) {
17 + header('Status: 403 Forbidden');
18 + header('HTTP/1.1 403 Forbidden');
19 + exit();
20 +}
12 21
13 22 /**
14 -* @internal prevent from direct calls
15 -*/
16 -if (!defined('ABSPATH')) {
17 - return ;
18 - }
23 + * some basics
24 + */
25 +global $wp_version;
26 +/** @const CryptX version */
27 +define( 'CRYPTX_VERSION', "3.3.2");
28 +define( 'CRYPTX_BASENAME', plugin_basename( __FILE__ ) );
29 +define( 'CRYPTX_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) );
30 +define( 'CRYPTX_DIR_URL', plugin_dir_url( __FILE__ ) );
31 +define( 'CRYPTX_DIR_PATH', plugin_dir_path( __FILE__ ) );
32 +define( 'CRYPTX_FILENAME', str_replace( CRYPTX_BASEFOLDER.'/', '', plugin_basename(__FILE__) ) );
19 33
20 -/**
21 -* @internal prevent from second inclusion
22 -*/
23 -if (!class_exists('cryptX')) {
34 +require_once(CRYPTX_DIR_PATH . 'include/functions.php');
24 35
25 -/////////////////////////////////////////////////////////////////////////////
36 +require_once(CRYPTX_DIR_PATH . 'include/admin_option_page.php');
26 37
27 -load_plugin_textdomain('cryptx', PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) );
28 -
29 -$cryptX_var = (array) get_option('cryptX');
30 -
38 +$cryptX_var = get_option('cryptX');
31 39 /**
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 {
40 + * check for needed updates
41 + */
42 +if( version_compare(CRYPTX_VERSION, $cryptX_var['version']) > 0 ) {
43 + cryptx_do_updates();
44 +}
45 +$cryptX_var = rw_loadDefaults();
38 46
39 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
47 +$is_js_needed = false;
40 48
41 - /**
42 - * Constructor
43 - *
44 - * This constructor attaches the needer plugin hook callbacks
45 - */
46 - function cryptX() {
49 +foreach($cryptX_var['filter'] as $filter) {
50 + if (@$cryptX_var[$filter]) {
51 + rw_cryptx_filter($filter);
52 + }
53 +}
47 54
48 - global $cryptX_var;
55 +add_action( 'activate_' . CRYPTX_BASENAME, 'rw_cryptx_install' );
49 56
50 - // attach the converstion handlers
51 - //
52 - if (@$cryptX_var[theContent]) {
53 - if (@$cryptX_var[java]) {
54 - add_filter('the_content',
55 - array(&$this, '_encrypt'));
56 - } else {
57 - add_filter('the_content',
58 - array(&$this, '_unicode'));
59 - }
60 - }
61 - if (@$cryptX_var[theExcerpt]) {
62 - if (@$cryptX_var[java]) {
63 - add_filter('the_content',
64 - array(&$this, '_encrypt'));
65 - } else {
66 - add_filter('the_content',
67 - array(&$this, '_unicode'));
68 - }
69 - }
57 +// Hook into the 'wp_enqueue_scripts' action
58 +add_action( 'wp_enqueue_scripts', 'cryptx_javascripts_load' );
70 59
71 - // attach to admin menu
72 - //
73 - if (is_admin()) {
74 - add_action('admin_menu',
75 - array(&$this, '_menu')
76 - );
77 - }
78 60
79 - // attach to plugin installation
80 - //
81 - add_action(
82 - 'activate_' . str_replace(
83 - DIRECTORY_SEPARATOR, '/',
84 - str_replace(
85 - realpath(ABSPATH . PLUGINDIR) . DIRECTORY_SEPARATOR,
86 - '', __FILE__
87 - )
88 - ),
89 - array(&$this, '_install')
90 - );
91 -
92 - // attach javascript to Header
93 - //
94 - if (@$cryptX_var[java]) {
95 - add_action(
96 - 'wp_head',
97 - array(&$this, '_header')
98 - );
99 - }
100 -
101 - } // End function
102 -
103 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
104 -
105 - /**
106 - * Wrap _encrypt
107 - * @param string $content
108 - * @return string
109 - */
110 - function _encrypt($content)
111 - {
112 - global $cryptX_var;
113 -
114 - preg_match_all('/<a[^>]*href=["|\'](.*)["|\']*>(.*)<\/a>/iUs', $content, $links, PREG_SET_ORDER);
115 -
116 - foreach( $links as $link ) {
117 -
118 - if(preg_match('/mailto:(.*)/', $link[1], $mail)) {
119 - $crypt = '';
120 - $ascii = 0;
121 - for ($i = 0; $i < strlen( $mail[1] ); $i++) {
122 - $ascii = ord ( substr ( $mail[1], $i ) );
123 - if (8364 <= $char) {
124 - $ascii = 128;
125 - }
126 - $crypt .= chr($ascii + 1);
127 - }
128 - $content = str_replace( $link[1], "javascript:DeCryptX('" . $crypt . "')", $content);
129 - $new_mail = str_replace( "@", $cryptX_var[at], $link[2]);
130 - $new_mail = str_replace( ".", $cryptX_var[dot], $new_mail);
131 - $content = str_replace( $link[2], $new_mail, $content);
132 - }
133 -
134 - } // foreach
135 - return $content;
136 - }
137 -
138 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
139 -
140 - /**
141 - * Wrap _unicode
142 - * @param string $content
143 - * @return string
144 - */
145 - function _unicode($content)
146 - {
147 - global $cryptX_var;
148 -
149 - preg_match_all('/<a[^>]*href=["|\'](.*)["|\']*>(.*)<\/a>/iUs', $content, $links, PREG_SET_ORDER);
150 -
151 - foreach( $links as $link ) {
152 -
153 - if(preg_match('/mailto:(.*)/', $link[1], $mail)) {
154 - $mailto = "mailto:" . $mail[1];
155 - $crypt = '';
156 - for ($i = 0; $i < strlen( $mailto ); $i++) {
157 - $crypt .= "&#".ord ( substr ( $mailto, $i ) );
158 - }
159 - $content = str_replace( $mailto, $crypt, $content);
160 - $new_mail = str_replace( "@", $cryptX_var[at], $link[2]);
161 - $new_mail = str_replace( ".", $cryptX_var[dot], $new_mail);
162 - $content = str_replace( $link[2], $new_mail, $content);
163 - }
164 -
165 - } // foreach
166 - return $content;
167 - }
168 -
169 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
170 -
171 - /**
172 - * Performs the routines required at plugin installation:
173 - * in general introducing the settings array
174 - */
175 - function _install() {
176 - add_option(
177 - 'cryptX',
178 - array(
179 - 'at' => ' [at] ',
180 - 'dot' => ' [dot] ',
181 - 'theContent' => 1,
182 - 'theExcerpt' => 0,
183 - 'java' => 1,
184 - )
185 - );
186 - }
187 -
188 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
189 -
190 - /**
191 - * Attach the menu page to the `Options` tab
192 - */
193 - function _header()
194 - {
195 - $cryptX_script.= "<script type=\"text/javascript\" src=\"" . get_option('siteurl') . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n";
196 - print($cryptX_script);
197 - }
198 -
199 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
200 -
201 - /**
202 - * Attach the menu page to the `Options` tab
203 - */
204 - function _menu() {
205 - add_submenu_page('options-general.php',
206 - 'CryptX',
207 - 'CryptX', 9,
208 - __FILE__,
209 - array($this, '_submenu')
210 - );
211 - }
212 -
213 - /**
214 - * Handles and renders the menu page
215 - */
216 - function _submenu() {
217 - global $cryptX_var;
218 -
219 - // sanitize referrer
220 - //
221 - $_SERVER['HTTP_REFERER'] = preg_replace(
222 - '~&saved=.*$~Uis','', $_SERVER['HTTP_REFERER']
223 - );
224 -
225 - // information updated ?
226 - //
227 - if ($_POST['submit']) {
228 -
229 - // save
230 - //
231 - update_option(
232 - 'cryptX',
233 - $_POST['cryptX_var']
234 - );
235 -
236 - die("<script>document.location.href = '{$_SERVER['HTTP_REFERER']}&saved=settings:" . time() . "';</script>");
237 - }
238 -
239 - // operation report detected
240 - //
241 - if (@$_GET['saved']) {
242 -
243 - list($saved, $ts) = explode(':', $_GET['saved']);
244 - if (time() - $ts < 10) {
245 - echo '<div id="message" class="updated fade"><p><strong>';
246 -
247 - switch ($saved) {
248 - case 'settings' :
249 - echo 'Settings saved.';
250 - break;
251 - }
252 -
253 - echo '</strong></p></div>';
254 - }
255 - }
256 -
257 - // read the settings
258 - //
259 - //$cryptX = (array) get_option('cryptX');
260 -
261 -?>
262 -<!-- Start Optionen im Adminbereich (xhtml, au�erhalb PHP) -->
263 -<div class="wrap">
264 - <h2><?php _e("CryptX Options...",'cryptx'); ?></h2>
265 - <form method="post">
266 - <blockquote>
267 - <table>
268 - <tr>
269 - <td valign="top"><?php _e("Replacement for '@'",'cryptx'); ?>
270 - <input name="cryptX_var[at]" value="<?php echo $cryptX_var[at]; ?>" type="text" /></td>
271 - </tr>
272 - <tr>
273 - <td valign="top"><?php _e("Replacement for '.'",'cryptx'); ?>
274 - <input name="cryptX_var[dot]" value="<?php echo $cryptX_var[dot]; ?>" type="text" /></td>
275 - </tr>
276 - <tr>
277 - <td valign="top"><input name="cryptX_var[theContent]" <?php echo ($cryptX_var[theContent]) ? 'checked="checked"' : ''; ?> type="checkbox" />
278 - <?php _e("Apply CryptX to the Content",'cryptx'); ?></td>
279 - </tr>
280 - <tr>
281 - <td valign="top"><input name="cryptX_var[theExcerpt]" <?php echo ($cryptX_var[theExcerpt]) ? 'checked="checked"' : ''; ?> type="checkbox" />
282 - <?php _e("Apply CryptX to the Excerpt",'cryptx'); ?></td>
283 - </tr>
284 - <tr>
285 - <td valign="top">
286 - <input name="cryptX_var[java]" <?php echo ($cryptX_var[java]) ? 'checked="checked"' : ''; ?> type="radio" value="1" />
287 - <?php _e("Use javascript to hide the Email-Link.",'cryptx'); ?><br />
288 - <input name="cryptX_var[java]" <?php echo (!$cryptX_var[java]) ? 'checked="checked"' : ''; ?> type="radio" value="0" />
289 - <?php _e("Use Unicode to hide the Email-Link.",'cryptx'); ?>
290 - </td>
291 - </tr>
292 - <tr>
293 - <td><input type="submit" name="submit" value="Update &raquo;" /></td>
294 - </tr>
295 - </table>
296 - </blockquote>
297 - </form>
298 -</div>
299 -<?php
300 - }
301 -
302 - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
303 -
304 -
305 - //--end-of-class
306 - }
307 -
61 +if (@$cryptX_var['metaBox']) {
62 + add_action('admin_menu', 'rw_cryptx_meta_box');
63 + add_action('wp_insert_post', 'rw_cryptx_insert_post' );
64 + add_action('wp_update_post', 'rw_cryptx_insert_post' );
308 65 }
309 66
310 -/////////////////////////////////////////////////////////////////////////////
67 +add_filter( 'plugin_row_meta', 'rw_cryptx_init_row_meta', 10, 2 );
311 68
312 -/**
313 -* Initiating the plugin...
314 -* @see cryptX
315 -*/
316 -new cryptX;
69 +add_filter( 'init', 'rw_cryptx_init_tinyurl');
70 +// add_action( 'parse_request', 'rw_cryptx_parse_request');
317 71
318 -?>
72 +add_shortcode( 'cryptx', 'rw_cryptx_shortcode');