PluginProbe
CryptX / 3.2.7
CryptX v3.2.7
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 3.2.7, at cryptx.php

147 lines 4.6 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: 3.2.7
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 * "CryptX" WordPress Plugin
13 *
14 * @author Ralf Weber <ralf@weber-nrw.de>
15 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
16 */
17
18 //avoid direct calls to this file, because now WP core and framework has been used
19 if ( ! function_exists('add_action') ) {
20 header('Status: 403 Forbidden');
21 header('HTTP/1.1 403 Forbidden');
22 exit();
23 }
24
25 /**
26 * some basics
27 */
28 global $wp_version;
29 define( 'CRYPTX_BASENAME', plugin_basename( __FILE__ ) );
30 define( 'CRYPTX_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) );
31 define( 'CRYPTX_FILENAME', str_replace( CRYPTX_BASEFOLDER.'/', '', plugin_basename(__FILE__) ) );
32 load_plugin_textdomain('cryptx', false, 'cryptx/languages/');
33 require_once(plugin_dir_path( __FILE__ ) . 'functions.php');
34 require_once(plugin_dir_path( __FILE__ ) . 'classes.php');
35 require_once(plugin_dir_path( __FILE__ ) . 'admin.php');
36 $cryptX_var = rw_loadDefaults();
37 $is_js_needed = false;
38
39 foreach($cryptX_var['filter'] as $filter) {
40 if (@$cryptX_var[$filter]) {
41 rw_cryptx_filter($filter);
42 }
43 }
44
45 add_action( 'activate_' . plugin_basename( __FILE__ ), 'rw_cryptx_install' );
46 wp_register_script( 'decryptx', plugins_url( '/js/cryptx.min.js' , __FILE__ ), array(), false, $cryptX_var['load_java'] );
47
48 if (@$cryptX_var['metaBox']) {
49 add_action('admin_menu', 'rw_cryptx_meta_box');
50 add_action('wp_insert_post', 'rw_cryptx_insert_post' );
51 add_action('wp_update_post', 'rw_cryptx_insert_post' );
52 }
53
54 if ( version_compare( $wp_version, '2.8', '>' ) ) {
55 add_filter( 'plugin_row_meta', 'rw_cryptx_init_row_meta', 10, 2 ); // only 2.8 and higher
56 } else {
57 add_filter( 'plugin_action_links', 'rw_cryptx_init_row_meta', 10, 2 );
58 }
59
60 add_filter( 'init', 'rw_cryptx_init_tinyurl');
61 add_action( 'parse_request', 'rw_cryptx_parse_request');
62
63 add_shortcode( 'cryptx', 'rw_cryptx_shortcode');
64
65 /**
66 * get CryptX Version
67 */
68 function rw_cryptx_version() {
69 if ( ! function_exists( 'get_plugins' ) )
70 require_once( ABSPATH . 'wp-admin/includes/plugin.php' );
71 $plugin_folder = get_plugins( '/' . plugin_basename( dirname( __FILE__ ) ) );
72 $plugin_file = basename( ( __FILE__ ) );
73 return $plugin_folder[$plugin_file]['Version'];
74 }
75
76
77 /**
78 * New Template functions...
79 * $content = string to convert
80 * $args = string/array with the following parameters
81 * array('text' => "", 'css_class' => "", 'css_id' => "", 'echo' => 1)
82 * or
83 * "text=&css_class=&css_id=&echo=1"
84 */
85 function encryptx( $content, $args="" ) {
86 global $cryptX_var;
87
88 $is_shortcode = true;
89
90 // Parse incomming $args into an array and merge it with $defaults
91 $encryptx_vars = rw_loadDefaults( $args );
92
93 // OPTIONAL: Declare each item in $args as its own variable i.e. $type, $before.
94 // extract( $args, EXTR_SKIP );
95
96 $tmp = explode("?", $content);
97 $content = $tmp[0];
98 $params = (!empty($tmp[1]))? $tmp[1] : '';
99 if($encryptx_vars['autolink']) {
100 $content = rw_cryptx_autolink( $content, true );
101 if (!empty($params)) {
102 $content = preg_replace( '/(.*\")(.*)(\".*>)(.*)(<\/a>)/i', '$1$2?'.$params.'$3$4$5', $content );
103 }
104 }
105 $content = rw_cryptx_encryptx( $content, true );
106 $content = rw_cryptx_linktext( $content, true );
107 if(!empty($encryptx_vars['text'])) {
108 $content = preg_replace( '/(.*">)(.*)(<.*)/i', '$1'.$encryptx_vars['text'].'$3', $content );
109 }
110 if(!empty($encryptx_vars['css_id'])) {
111 $content = preg_replace( '/(.*)(">)/i', '$1" id="'.$encryptx_vars['css_id'].'">', $content );
112 }
113 if(!empty($encryptx_vars['css_class'])) {
114 $content = preg_replace( '/(.*)(">)/i', '$1" class="'.$encryptx_vars['css_class'].'">', $content );
115 }
116
117 $is_shortcode = false;
118
119 if(!$encryptx_vars['echo'])
120 return $content;
121
122 echo $content;
123
124 }
125
126 /**
127 * Template function that encrypt the get_post_meta result
128 * call it with the default get_post_meta parameters
129 **/
130 function get_encryptx_meta( $post_id, $key, $single=false ) {
131
132 $values = get_post_meta( $post_id, $key, $single );
133
134 if(is_array($values)) {
135 $return = array();
136 foreach( $values as $value) {
137 $return[] = encryptx($value, array('echo' => 0));
138 }
139 } else {
140 $return = encryptx($values, array('echo' => 0));
141 }
142
143 return $return;
144
145 }
146
147 ?>