| @@ -1,359 +1,672 @@ | ||
| 1 | 1 | <?php |
| 2 | 2 | /* |
| 3 | 3 | Plugin Name: CryptX |
| 4 | -Plugin URI: http://weber-nrw/wordpress/cryptx/ | |
| 4 | +Plugin URI: http://weber-nrw.de/wordpress/cryptx/ | |
| 5 | 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: 1.2 | |
| 6 | +Version: 3.1 | |
| 7 | 7 | Author: Ralf Weber |
| 8 | 8 | Author URI: http://weber-nrw.de/ |
| 9 | +Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696 | |
| 9 | 10 | */ |
| 10 | - | |
| 11 | -///////////////////////////////////////////////////////////////////////////// | |
| 12 | - | |
| 13 | 11 | /** |
| 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__)) ); | |
| 28 | - | |
| 29 | -$cryptX_var = (array) get_option('cryptX'); | |
| 30 | - | |
| 31 | -/** | |
| 32 | 12 | * "CryptX" WordPress Plugin |
| 33 | 13 | * |
| 34 | 14 | * @author Ralf Weber <ralf@weber-nrw.de> |
| 35 | 15 | * @license http://opensource.org/licenses/gpl-license.php GNU Public License |
| 36 | 16 | */ |
| 37 | -Class cryptX { | |
| 38 | 17 | |
| 39 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 18 | +if (!defined('ABSPATH')) { | |
| 19 | + return ; | |
| 20 | + } | |
| 40 | 21 | |
| 41 | - /** | |
| 42 | - * Constructor | |
| 43 | - * | |
| 44 | - * This constructor attaches the needer plugin hook callbacks | |
| 45 | - */ | |
| 46 | - function cryptX() { | |
| 22 | +define( 'CRYPTX_BASENAME', plugin_basename( __FILE__ ) ); | |
| 23 | +define( 'CRYPTX_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) ); | |
| 24 | +define( 'CRYPTX_FILENAME', str_replace( CRYPTX_BASEFOLDER.'/', '', plugin_basename(__FILE__) ) ); | |
| 47 | 25 | |
| 48 | - global $cryptX_var; | |
| 26 | +load_plugin_textdomain('cryptx', false, 'cryptx/languages/'); | |
| 49 | 27 | |
| 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 | - } | |
| 28 | +$cryptX_var = (array) get_option('cryptX'); | |
| 58 | 29 | |
| 59 | - // attach to admin menu | |
| 60 | - // | |
| 61 | - if (is_admin()) { | |
| 62 | - add_action('admin_menu', | |
| 63 | - array(&$this, '_menu') | |
| 64 | - ); | |
| 65 | - } | |
| 66 | 30 | |
| 67 | - // attach to plugin installation | |
| 68 | - // | |
| 69 | - add_action( | |
| 70 | - 'activate_' . str_replace( | |
| 71 | - DIRECTORY_SEPARATOR, '/', | |
| 72 | - str_replace( | |
| 73 | - realpath(ABSPATH . PLUGINDIR) . DIRECTORY_SEPARATOR, | |
| 74 | - '', __FILE__ | |
| 75 | - ) | |
| 76 | - ), | |
| 77 | - array(&$this, '_install') | |
| 78 | - ); | |
| 31 | +global $cryptX_var, $wp_version; | |
| 79 | 32 | |
| 80 | - // attach javascript to Header | |
| 81 | - // | |
| 82 | - if (@$cryptX_var[java]) { | |
| 83 | - add_action( | |
| 84 | - 'wp_head', | |
| 85 | - array(&$this, '_header') | |
| 86 | - ); | |
| 87 | - } | |
| 33 | +if (@$cryptX_var['theContent']) { | |
| 34 | + rw_cryptx_filter('the_content'); | |
| 35 | +} | |
| 36 | +if (@$cryptX_var['the_meta_key']) { | |
| 37 | + rw_cryptx_filter('the_meta_key'); | |
| 38 | +} | |
| 39 | +if (@$cryptX_var['theExcerpt']) { | |
| 40 | + rw_cryptx_filter('the_excerpt'); | |
| 41 | +} | |
| 42 | +if (@$cryptX_var['commentText']) { | |
| 43 | + rw_cryptx_filter('comment_text'); | |
| 44 | +} | |
| 45 | +if (@$cryptX_var['widgetText']) { | |
| 46 | + rw_cryptx_filter('widget_text'); | |
| 47 | +} | |
| 88 | 48 | |
| 89 | - } // End function | |
| 49 | +if (is_admin()) { | |
| 50 | + add_action('admin_menu', 'rw_cryptx_menu'); | |
| 51 | +} | |
| 90 | 52 | |
| 91 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 53 | +add_action( 'activate_' . str_replace( DIRECTORY_SEPARATOR, '/', str_replace( realpath(ABSPATH . PLUGINDIR) . DIRECTORY_SEPARATOR, '', __FILE__ ) ), 'rw_cryptx_install' ); | |
| 92 | 54 | |
| 93 | - /** | |
| 94 | - * Wrap _filter | |
| 95 | - * @param string $content | |
| 96 | - * @return string | |
| 97 | - */ | |
| 98 | - function _filter($apply) | |
| 99 | - { | |
| 100 | - global $cryptX_var; | |
| 55 | +if (@$cryptX_var['java']) { | |
| 56 | + if (@$cryptX_var['load_java']) { | |
| 57 | + add_action( 'wp_footer', 'rw_cryptx_header', 9 ); | |
| 58 | + } else { | |
| 59 | + add_action( 'wp_head', 'rw_cryptx_header', 9 ); | |
| 60 | + } | |
| 61 | +} | |
| 101 | 62 | |
| 102 | - if (@$cryptX_var[autolink]) { | |
| 103 | - add_filter($apply, | |
| 104 | - array(&$this, '_autolink')); | |
| 105 | - } | |
| 106 | - if (@$cryptX_var[java]) { | |
| 107 | - add_filter($apply, | |
| 108 | - array(&$this, '_encrypt')); | |
| 109 | - } else { | |
| 110 | - add_filter($apply, | |
| 111 | - array(&$this, '_unicode')); | |
| 112 | - } | |
| 63 | +if (@$cryptX_var[metaBox]) { | |
| 64 | + add_action('admin_menu', 'rw_cryptx_meta_box'); | |
| 65 | + add_action('wp_insert_post', 'rw_cryptx_insert_post' ); | |
| 66 | + add_action('wp_update_post', 'rw_cryptx_insert_post' ); | |
| 67 | +} | |
| 113 | 68 | |
| 114 | - } | |
| 69 | +if ( version_compare( $wp_version, '2.8', '>' ) ) { | |
| 70 | + add_filter( 'plugin_row_meta', 'rw_cryptx_init_row_meta', 10, 2 ); // only 2.8 and higher | |
| 71 | +} else { | |
| 72 | + add_filter( 'plugin_action_links', 'rw_cryptx_init_row_meta', 10, 2 ); | |
| 73 | +} | |
| 115 | 74 | |
| 116 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 75 | +add_filter( 'init', 'rw_cryptx_init_tinyurl'); | |
| 76 | +add_action( 'parse_request', 'rw_cryptx_parse_request'); | |
| 117 | 77 | |
| 118 | - /** | |
| 119 | - * Wrap _encrypt | |
| 120 | - * @param string $content | |
| 121 | - * @return string | |
| 122 | - */ | |
| 123 | - function _encrypt($content) | |
| 124 | - { | |
| 125 | - global $cryptX_var; | |
| 78 | +add_shortcode( 'cryptx', 'rw_cryptx_shortcode'); | |
| 126 | 79 | |
| 127 | - preg_match_all('/<a[^>]*href=["|\'](.*)["|\']*>(.*)<\/a>/iUs', $content, $links, PREG_SET_ORDER); | |
| 80 | +function rw_cryptx_shortcode( $atts, $content=null) { | |
| 81 | + global $cryptX_var; | |
| 128 | 82 | |
| 129 | - foreach( $links as $link ) { | |
| 83 | + if (@$cryptX_var[autolink]) $content = rw_cryptx_autolink($content, true); | |
| 84 | + $content = rw_cryptx_encryptx($content, true); | |
| 85 | + $content = rw_cryptx_linktext($content, true); | |
| 130 | 86 | |
| 131 | - if(preg_match('/mailto:(.*)/', $link[1], $mail)) { | |
| 132 | - $crypt = ''; | |
| 133 | - $ascii = 0; | |
| 134 | - for ($i = 0; $i < strlen( $mail[1] ); $i++) { | |
| 135 | - $ascii = ord ( substr ( $mail[1], $i ) ); | |
| 136 | - if (8364 <= $char) { | |
| 137 | - $ascii = 128; | |
| 138 | - } | |
| 139 | - $crypt .= chr($ascii + 1); | |
| 140 | - } | |
| 141 | - $temp = str_replace( $link[1], "javascript:DeCryptX('" . $crypt . "')", $link[0]); | |
| 142 | - $new_mail = str_replace( "@", $cryptX_var[at], $link[2]); | |
| 143 | - $new_mail = str_replace( ".", $cryptX_var[dot], $new_mail); | |
| 144 | - $temp = str_replace( $link[2], $new_mail, $temp); | |
| 145 | - $content = str_replace( $link[0], $temp, $content); | |
| 146 | - } | |
| 87 | + return $content; | |
| 88 | +} | |
| 147 | 89 | |
| 148 | - } // foreach | |
| 90 | +function rw_cryptx_parse_request( $wp ) { | |
| 91 | + if ( isset($_GET['cryptx']) ) { | |
| 92 | + switch( $_GET['cryptx'] ) { | |
| 93 | + case 'news': | |
| 94 | + include( 'ajax/news.php' ); | |
| 95 | + break; | |
| 96 | + } | |
| 97 | + exit; | |
| 98 | + } | |
| 99 | +} | |
| 149 | 100 | |
| 101 | +function rw_cryptx_init_tinyurl() { | |
| 102 | + global $cryptX_var; | |
| 103 | + $url = $_SERVER['REQUEST_URI']; | |
| 104 | + $params = explode( '/', $url ); | |
| 105 | + if ( count( $params ) > 1 ) { | |
| 106 | + $tiny_url = $params[count( $params ) -2]; | |
| 107 | + if ( $tiny_url == md5( get_bloginfo('url') ) ) { | |
| 108 | + $font = $cryptX_var['c2i_font']; | |
| 109 | + $msg = $params[count( $params ) -1]; | |
| 110 | + $size = $cryptX_var['c2i_fontSize']; | |
| 111 | + $pad = 1; | |
| 112 | + $transparent = 1; | |
| 113 | + $red = hexdec(substr($cryptX_var['c2i_fontRGB'],0,2)); | |
| 114 | + $grn = hexdec(substr($cryptX_var['c2i_fontRGB'],2,2)); | |
| 115 | + $blu = hexdec(substr($cryptX_var['c2i_fontRGB'],4,2)); | |
| 116 | + $bg_red = 255 - $red; | |
| 117 | + $bg_grn = 255 - $grn; | |
| 118 | + $bg_blu = 255 - $blu; | |
| 119 | + $width = 0; | |
| 120 | + $height = 0; | |
| 121 | + $offset_x = 0; | |
| 122 | + $offset_y = 0; | |
| 123 | + $bounds = array(); | |
| 124 | + $image = ""; | |
| 125 | + $bounds = ImageTTFBBox($size, 0, $font, "W"); | |
| 126 | + $font_height = abs($bounds[7]-$bounds[1]); | |
| 127 | + $bounds = ImageTTFBBox($size, 0, $font, $msg); | |
| 128 | + $width = abs($bounds[4]-$bounds[6]); | |
| 129 | + $height = abs($bounds[7]-$bounds[1]); | |
| 130 | + $offset_y = $font_height+abs(($height - $font_height)/2)-1; | |
| 131 | + $offset_x = 0; | |
| 132 | + $image = imagecreatetruecolor($width+($pad*2),$height+($pad*2)); | |
| 133 | + imagesavealpha($image, true); | |
| 134 | + $foreground = ImageColorAllocate($image, $red, $grn, $blu); | |
| 135 | + $background = imagecolorallocatealpha($image, 0, 0, 0, 127); | |
| 136 | + imagefill($image, 0, 0, $background); | |
| 137 | + ImageTTFText($image, $size, 0, $offset_x+$pad, $offset_y+$pad, $foreground, $font, $msg); | |
| 138 | + Header("Content-type: image/png"); | |
| 139 | + imagePNG($image); | |
| 140 | + die; | |
| 141 | + } | |
| 142 | + } | |
| 143 | +} | |
| 150 | 144 | |
| 151 | - return $content; | |
| 145 | +function rw_cryptx_init_row_meta($links, $file) { | |
| 146 | + if (CRYPTX_BASENAME == $file) { | |
| 147 | + return array_merge( | |
| 148 | + $links, | |
| 149 | + array( | |
| 150 | + sprintf( | |
| 151 | + '<a href="options-general.php?page=%s">%s</a>', | |
| 152 | + CRYPTX_BASENAME, | |
| 153 | + __('Settings') | |
| 154 | + ) | |
| 155 | + ), | |
| 156 | + array( | |
| 157 | + sprintf( | |
| 158 | + '<a href="https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696">%s</a>', | |
| 159 | + __('Donate', 'cryptx') | |
| 160 | + ) | |
| 161 | + ) | |
| 162 | + ); | |
| 152 | 163 | } |
| 164 | + return $links; | |
| 165 | +} | |
| 153 | 166 | |
| 154 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 167 | +function rw_cryptx_filter($apply) { | |
| 168 | + global $cryptX_var, $post, $shortcode_tags; | |
| 169 | + if (@$cryptX_var['autolink']) { | |
| 170 | + add_filter($apply, 'rw_cryptx_autolink', 5); | |
| 171 | + if (!empty($shortcode_tags) || is_array($shortcode_tags)) { | |
| 172 | + add_filter($apply, 'rw_cryptx_autolink', 11); | |
| 173 | + } | |
| 174 | + } | |
| 175 | + add_filter($apply, 'rw_cryptx_encryptx', 12); | |
| 176 | + add_filter($apply, 'rw_cryptx_linktext', 13); | |
| 177 | +} | |
| 155 | 178 | |
| 156 | - /** | |
| 157 | - * Wrap _unicode | |
| 158 | - * @param string $content | |
| 159 | - * @return string | |
| 160 | - */ | |
| 161 | - function _unicode($content) | |
| 162 | - { | |
| 163 | - global $cryptX_var; | |
| 179 | +function rw_cryptx_excluded($ID) { | |
| 180 | + global $cryptX_var; | |
| 181 | + $return = false; | |
| 182 | + $exIDs = explode(",", $cryptX_var['excludedIDs']); | |
| 183 | + if(in_array($ID, $exIDs) > 0 ) $return = true; | |
| 184 | + return $return; | |
| 185 | +} | |
| 164 | 186 | |
| 165 | - preg_match_all('/<a[^>]*href=["|\'](.*)["|\']*>(.*)<\/a>/iUs', $content, $links, PREG_SET_ORDER); | |
| 187 | +function rw_cryptx_linktext($content, $shortcode=false) { | |
| 188 | + global $post; | |
| 189 | + if (!rw_cryptx_excluded($post->ID) OR $shortcode!=false) { | |
| 190 | + $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", 'rw_cryptx_do_Linktext', $content ); | |
| 191 | + } | |
| 192 | + return $content; | |
| 193 | +} | |
| 166 | 194 | |
| 167 | - foreach( $links as $link ) { | |
| 195 | +function rw_cryptx_do_linktext($Match) { | |
| 196 | + global $cryptX_var; | |
| 197 | + switch ($cryptX_var['opt_linktext']) { | |
| 168 | 198 | |
| 169 | - if(preg_match('/mailto:(.*)/', $link[1], $mail)) { | |
| 170 | - $mailto = "mailto:" . $mail[1]; | |
| 171 | - $crypt = ''; | |
| 172 | - for ($i = 0; $i < strlen( $mailto ); $i++) { | |
| 173 | - $crypt .= "&#" . ord ( substr ( $mailto, $i ) ) . ";"; | |
| 174 | - } | |
| 175 | - $content = str_replace( $mailto, $crypt, $content); | |
| 176 | - $new_mail = str_replace( "@", $cryptX_var[at], $link[2]); | |
| 177 | - $new_mail = str_replace( ".", $cryptX_var[dot], $new_mail); | |
| 178 | - $content = str_replace( $link[2], $new_mail, $content); | |
| 179 | - } | |
| 199 | + case 1: // alternative text for mail link | |
| 200 | + $linktext = $cryptX_var['alt_linktext']; | |
| 201 | + break; | |
| 180 | 202 | |
| 181 | - } // foreach | |
| 182 | - return $content; | |
| 183 | - } | |
| 203 | + case 2: // alternative image for mail link | |
| 204 | + $linktext = "<img src=\"" . $cryptX_var['alt_linkimage'] . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var['alt_linkimage_title'] . "\" title=\"" . antispambot($cryptX_var['alt_linkimage_title']) . "\" />"; | |
| 205 | + break; | |
| 184 | 206 | |
| 185 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 207 | + case 3: // uploaded image for mail link | |
| 208 | + $imgurl = $cryptX_var['alt_uploadedimage']; | |
| 209 | + $linktext = "<img src=\"" . $imgurl . "\" class=\"cryptxImage\" alt=\"" . $cryptX_var['http_linkimage_title'] . "\" title=\"" .antispambot( $cryptX_var['http_linkimage_title']) . "\" />"; | |
| 210 | + break; | |
| 186 | 211 | |
| 187 | - function _autolink($content) { | |
| 212 | + case 4: // text scrambled by antispambot | |
| 213 | + $linktext = antispambot($Match[1]); | |
| 214 | + break; | |
| 188 | 215 | |
| 189 | - $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si"; | |
| 190 | - $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si"; | |
| 191 | - $src[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si"; | |
| 192 | - $src[]="/(<a[^>]*>)<a[^>]*>/"; | |
| 193 | - $src[]="/(<\/A>)<\/A>/i"; | |
| 216 | + case 5: // convert to image | |
| 217 | + $linktext = "<img src=\"" . get_bloginfo('url') . "/" . md5( get_bloginfo('url') ) . "/" . antispambot($Match[1]) . "\" class=\"cryptxImage\" alt=\"" . antispambot($Match[1]) . "\" title=\"" . antispambot($Match[1]) . "\" />"; | |
| 218 | + break; | |
| 194 | 219 | |
| 195 | - $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>"; | |
| 196 | - $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6"; | |
| 197 | - $tar[]="<a href=\"mailto:\\0\">\\0</a>"; | |
| 198 | - $tar[]="\\1"; | |
| 199 | - $tar[]="\\1"; | |
| 220 | + default: | |
| 221 | + $linktext = str_replace( "@", $cryptX_var['at'], $Match[1]); | |
| 222 | + $linktext = str_replace( ".", $cryptX_var['dot'], $linktext); | |
| 200 | 223 | |
| 201 | - $content = preg_replace($src,$tar,$content); | |
| 224 | + } | |
| 225 | + return $linktext; | |
| 226 | +} | |
| 202 | 227 | |
| 203 | - return $content; | |
| 228 | +function rw_cryptx_dirImages() { | |
| 229 | + $dir = plugin_dir_path( __FILE__ ).'images'; | |
| 230 | + $fh = opendir($dir); | |
| 231 | + $verzeichnisinhalt = array(); | |
| 232 | + while (true == ($file = readdir($fh))) | |
| 233 | + { | |
| 234 | + if ((substr(strtolower($file), -3)=="jpg") or (substr(strtolower($file), -3)=="gif")) | |
| 235 | + { | |
| 236 | + $verzeichnisinhalt[] = $file; | |
| 237 | + } | |
| 204 | 238 | } |
| 239 | + return $verzeichnisinhalt; | |
| 240 | +} | |
| 205 | 241 | |
| 206 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 207 | - | |
| 208 | - /** | |
| 209 | - * Performs the routines required at plugin installation: | |
| 210 | - * in general introducing the settings array | |
| 211 | - */ | |
| 212 | - function _install() { | |
| 213 | - add_option( | |
| 214 | - 'cryptX', | |
| 215 | - array( | |
| 216 | - 'at' => ' [at] ', | |
| 217 | - 'dot' => ' [dot] ', | |
| 218 | - 'theContent' => 1, | |
| 219 | - 'theExcerpt' => 0, | |
| 220 | - 'java' => 1, | |
| 221 | - ) | |
| 222 | - ); | |
| 223 | - } | |
| 224 | - | |
| 225 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 226 | - | |
| 227 | - /** | |
| 228 | - * Attach the menu page to the `Options` tab | |
| 229 | - */ | |
| 230 | - function _header() | |
| 242 | +function rw_cryptx_dirFonts() { | |
| 243 | + $dir = plugin_dir_path( __FILE__ ).'fonts'; | |
| 244 | + $fh = opendir($dir); | |
| 245 | + $verzeichnisinhalt = array(); | |
| 246 | + while (true == ($file = readdir($fh))) | |
| 231 | 247 | { |
| 232 | - $cryptX_script.= "<script type=\"text/javascript\" src=\"" . get_option('siteurl') . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n"; | |
| 233 | - print($cryptX_script); | |
| 248 | + if ((substr(strtolower($file), -3)=="ttf") or (substr(strtolower($file), -3)=="ttf")) | |
| 249 | + { | |
| 250 | + $verzeichnisinhalt[] = $file; | |
| 251 | + } | |
| 234 | 252 | } |
| 253 | + return $verzeichnisinhalt; | |
| 254 | +} | |
| 235 | 255 | |
| 236 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 256 | +function rw_cryptx_encryptx($content, $shortcode=false) { | |
| 257 | + global $post; | |
| 258 | + | |
| 259 | + if (!rw_cryptx_excluded($post->ID) OR $shortcode!=false) { | |
| 260 | + $content = preg_replace_callback('/<a (.*?)(href=("|\')mailto:(.*?)("|\')(.*?)|)>(.*?)<\/a>/i', 'rw_cryptx_mailtocrypt', $content ); | |
| 261 | + } | |
| 262 | + return $content; | |
| 263 | +} | |
| 237 | 264 | |
| 238 | - /** | |
| 239 | - * Attach the menu page to the `Options` tab | |
| 240 | - */ | |
| 241 | - function _menu() { | |
| 242 | - add_submenu_page('options-general.php', | |
| 243 | - 'CryptX', | |
| 244 | - 'CryptX', 9, | |
| 245 | - __FILE__, | |
| 246 | - array($this, '_submenu') | |
| 247 | - ); | |
| 265 | +function rw_cryptx_mailtocrypt($Match) { | |
| 266 | + global $cryptX_var; | |
| 267 | + $return = $Match[0]; | |
| 268 | + $mailto = "mailto:" . $Match[4]; | |
| 269 | + if (substr($Match[4], 0, 9) =="?subject=") return $return; | |
| 270 | + if (@$cryptX_var['java']) { | |
| 271 | + $crypt = ''; | |
| 272 | + $ascii = 0; | |
| 273 | + for ($i = 0; $i < strlen( $Match[4] ); $i++) { | |
| 274 | + $ascii = ord ( substr ( $Match[4], $i ) ); | |
| 275 | + if (8364 <= $ascii) { | |
| 276 | + $ascii = 128; | |
| 277 | + } | |
| 278 | + $crypt .= chr($ascii + 1); | |
| 248 | 279 | } |
| 280 | + $javascript="javascript:DeCryptX('" . $crypt . "')"; | |
| 281 | + $return = str_replace( "mailto:".$Match[4], $javascript, $return); | |
| 282 | + } else { | |
| 283 | + $return = str_replace( $mailto, antispambot($mailto), $return); | |
| 284 | + } | |
| 285 | + return $return; | |
| 286 | +} | |
| 249 | 287 | |
| 250 | - /** | |
| 251 | - * Handles and renders the menu page | |
| 252 | - */ | |
| 253 | - function _submenu() { | |
| 254 | - global $cryptX_var; | |
| 288 | +function rw_cryptx_autolink($content, $shortcode=false) { | |
| 289 | + global $post; | |
| 290 | + if (rw_cryptx_excluded($post->ID) AND $shortcode==false) return $content; | |
| 291 | + $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si"; | |
| 292 | + $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si"; | |
| 293 | + $src[]="/(\()([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(\))/si"; | |
| 294 | + $src[]="/(>)([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))([\s])/si"; | |
| 295 | + $src[]="/([\s])([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))(<)/si"; | |
| 296 | + $src[]="/^([_a-zA-Z0-9-]+(\.[_a-zA-Z0-9-]+)*@[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)*(\.[a-zA-Z]{2,}))/si"; | |
| 297 | + $src[]="/(<a[^>]*>)<a[^>]*>/"; | |
| 298 | + $src[]="/(<\/A>)<\/A>/i"; | |
| 299 | + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>"; | |
| 300 | + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6"; | |
| 301 | + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6"; | |
| 302 | + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6"; | |
| 303 | + $tar[]="\\1<a href=\"mailto:\\2\">\\2</a>\\6"; | |
| 304 | + $tar[]="<a href=\"mailto:\\0\">\\0</a>"; | |
| 305 | + $tar[]="\\1"; | |
| 306 | + $tar[]="\\1"; | |
| 307 | + $content = preg_replace($src,$tar,$content); | |
| 308 | + return $content; | |
| 309 | +} | |
| 255 | 310 | |
| 256 | - // sanitize referrer | |
| 257 | - // | |
| 258 | - $_SERVER['HTTP_REFERER'] = preg_replace( | |
| 259 | - '~&saved=.*$~Uis','', $_SERVER['HTTP_REFERER'] | |
| 311 | +function rw_cryptx_install() { | |
| 312 | + global $cryptX_var, $wpdb; | |
| 313 | + $firstImage = rw_cryptx_dirImages(); | |
| 314 | + $firstFont = rw_cryptx_dirFonts(); | |
| 315 | + $cryptX_var = (array) get_option('cryptX'); // reread Options | |
| 316 | + $defaults = array( | |
| 317 | + 'at' => ' [at] ', | |
| 318 | + 'dot' => ' [dot] ', | |
| 319 | + 'theContent' => 1, | |
| 320 | + 'the_meta_key' => 1, | |
| 321 | + 'theExcerpt' => 0, | |
| 322 | + 'commentText' => 1, | |
| 323 | + 'widgetText' => 0, | |
| 324 | + 'java' => 1, | |
| 325 | + 'load_java' => 0, | |
| 326 | + 'opt_linktext' => 0, | |
| 327 | + 'autolink' => 1, | |
| 328 | + 'alt_linktext' => '', | |
| 329 | + 'alt_linkimage' => '', | |
| 330 | + 'http_linkimage_title' => '', | |
| 331 | + 'alt_linkimage_title' => '', | |
| 332 | + 'excludedIDs' => '', | |
| 333 | + 'metaBox' => 1, | |
| 334 | + 'alt_uploadedimage' => plugins_url('cryptx/images/').$firstImage[0], | |
| 335 | + 'c2i_font' => plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0], | |
| 336 | + 'c2i_fontSize' => 10, | |
| 337 | + 'c2i_fontRGB' => '000000' | |
| 260 | 338 | ); |
| 261 | - | |
| 262 | - // information updated ? | |
| 263 | - // | |
| 264 | - if ($_POST['submit']) { | |
| 265 | - | |
| 266 | - // save | |
| 267 | - // | |
| 268 | - update_option( | |
| 269 | - 'cryptX', | |
| 270 | - $_POST['cryptX_var'] | |
| 271 | - ); | |
| 272 | - | |
| 273 | - die("<script>document.location.href = '{$_SERVER['HTTP_REFERER']}&saved=settings:" . time() . "';</script>"); | |
| 339 | + $cryptX_var = $cryptX_var + $defaults; | |
| 340 | + if ($cryptX_var['excludedIDs'] == "") { | |
| 341 | + $tmp = array(); | |
| 342 | + $excludes = $wpdb->get_results("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff' AND meta_value = 'true'"); | |
| 343 | + if(count($excludes) > 0) { | |
| 344 | + foreach ($excludes as $exclude) { | |
| 345 | + $tmp[] = $exclude->post_id; | |
| 274 | 346 | } |
| 347 | + sort($tmp); | |
| 348 | + $cryptX_var['excludedIDs'] = implode(",", $tmp); | |
| 349 | + update_option( 'cryptX', $cryptX_var); | |
| 350 | + $cryptX_var = (array) get_option('cryptX'); // reread Options | |
| 351 | + $wpdb->query("DELETE FROM $wpdb->postmeta WHERE meta_key = 'cryptxoff'"); | |
| 352 | + } | |
| 353 | + } | |
| 354 | + if (empty($cryptX_var['c2i_font'])) { | |
| 355 | + $cryptX_var['c2i_font'] = plugin_dir_path( __FILE__ ).'fonts/'.$firstFont[0]; | |
| 356 | + } | |
| 357 | + if (empty($cryptX_var['c2i_fontSize'])) { | |
| 358 | + $cryptX_var['c2i_fontSize'] = 10; | |
| 359 | + } | |
| 360 | + if (empty($cryptX_var['c2i_fontRGB'])) { | |
| 361 | + $cryptX_var['c2i_fontRGB'] = '000000'; | |
| 362 | + } | |
| 363 | + update_option( 'cryptX', $cryptX_var); | |
| 364 | + $cryptX_var = (array) get_option('cryptX'); // reread Options | |
| 365 | +} | |
| 275 | 366 | |
| 276 | - // operation report detected | |
| 277 | - // | |
| 278 | - if (@$_GET['saved']) { | |
| 367 | +function rw_cryptx_header() { | |
| 368 | + $cryptX_script = "<script type=\"text/javascript\" src=\"" . site_url() . '/' . PLUGINDIR . '/' . dirname(plugin_basename (__FILE__)) . "/js/cryptx.js\"></script>\n"; | |
| 369 | + print($cryptX_script); | |
| 370 | +} | |
| 279 | 371 | |
| 280 | - list($saved, $ts) = explode(':', $_GET['saved']); | |
| 281 | - if (time() - $ts < 10) { | |
| 282 | - echo '<div id="message" class="updated fade"><p><strong>'; | |
| 372 | +function rw_cryptx_meta() { | |
| 373 | + global $post; | |
| 374 | + ?> | |
| 375 | + <input type="checkbox" name="cryptxoff" <?php if (rw_cryptx_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page | |
| 376 | + <?php | |
| 377 | +} | |
| 283 | 378 | |
| 284 | - switch ($saved) { | |
| 285 | - case 'settings' : | |
| 286 | - echo 'Settings saved.'; | |
| 287 | - break; | |
| 288 | - } | |
| 379 | +function rw_cryptx_option() { | |
| 380 | + global $post; | |
| 381 | + if ( current_user_can('edit_posts') ) { ?> | |
| 382 | + <fieldset id="cryptxoption" class="dbx-box"> | |
| 383 | + <h3 class="dbx-handle">CryptX</h3> | |
| 384 | + <div class="dbx-content"> | |
| 385 | + <input type="checkbox" name="cryptxoff" <?php if (rw_cryptx_excluded($post->ID)) { echo 'checked="checked"'; } ?>/> Disable CryptX for this post/page | |
| 386 | + </div> | |
| 387 | + </fieldset> | |
| 388 | +<?php | |
| 389 | + } | |
| 390 | +} | |
| 289 | 391 | |
| 290 | - echo '</strong></p></div>'; | |
| 291 | - } | |
| 292 | - } | |
| 392 | +function rw_cryptx_meta_box() { | |
| 393 | + if ( function_exists('add_meta_box') ) { | |
| 394 | + add_meta_box('cryptx','CryptX', 'rw_cryptx_meta','post'); | |
| 395 | + add_meta_box('cryptx','CryptX', 'rw_cryptx_meta','page'); | |
| 396 | + } else { | |
| 397 | + add_action('dbx_post_sidebar', 'rw_cryptx_option'); | |
| 398 | + add_action('dbx_page_sidebar', 'rw_cryptx_option'); | |
| 399 | + } | |
| 400 | +} | |
| 293 | 401 | |
| 294 | - // read the settings | |
| 295 | - // | |
| 296 | - //$cryptX = (array) get_option('cryptX'); | |
| 297 | - | |
| 298 | -?> | |
| 299 | -<!-- Start Optionen im Adminbereich (xhtml, au�erhalb PHP) --> | |
| 300 | -<div class="wrap"> | |
| 301 | - <h2><?php _e("CryptX Options...",'cryptx'); ?></h2> | |
| 302 | - <form method="post"> | |
| 303 | - <blockquote> | |
| 304 | - <table> | |
| 305 | - <tr> | |
| 306 | - <td valign="top"><?php _e("Replacement for '@'",'cryptx'); ?> | |
| 307 | - <input name="cryptX_var[at]" value="<?php echo $cryptX_var[at]; ?>" type="text" /></td> | |
| 308 | - </tr> | |
| 309 | - <tr> | |
| 310 | - <td valign="top"><?php _e("Replacement for '.'",'cryptx'); ?> | |
| 311 | - <input name="cryptX_var[dot]" value="<?php echo $cryptX_var[dot]; ?>" type="text" /></td> | |
| 312 | - </tr> | |
| 313 | - <tr> | |
| 314 | - <td valign="top"><input name="cryptX_var[theContent]" <?php echo ($cryptX_var[theContent]) ? 'checked="checked"' : ''; ?> type="checkbox" /> | |
| 315 | - <?php _e("Apply CryptX to the Content",'cryptx'); ?></td> | |
| 316 | - </tr> | |
| 317 | - <tr> | |
| 318 | - <td valign="top"><input name="cryptX_var[theExcerpt]" <?php echo ($cryptX_var[theExcerpt]) ? 'checked="checked"' : ''; ?> type="checkbox" /> | |
| 319 | - <?php _e("Apply CryptX to the Excerpt",'cryptx'); ?></td> | |
| 320 | - </tr> | |
| 321 | - <tr> | |
| 322 | - <td valign="top"> | |
| 323 | - <input name="cryptX_var[java]" <?php echo ($cryptX_var[java]) ? 'checked="checked"' : ''; ?> type="radio" value="1" /> | |
| 324 | - <?php _e("Use javascript to hide the Email-Link.",'cryptx'); ?><br /> | |
| 325 | - <input name="cryptX_var[java]" <?php echo (!$cryptX_var[java]) ? 'checked="checked"' : ''; ?> type="radio" value="0" /> | |
| 326 | - <?php _e("Use Unicode to hide the Email-Link.",'cryptx'); ?> | |
| 327 | - </td> | |
| 328 | - </tr> | |
| 329 | - <tr> | |
| 330 | - <td valign="top"><input name="cryptX_var[autolink]" <?php echo ($cryptX_var[autolink]) ? 'checked="checked"' : ''; ?> type="checkbox" /> | |
| 331 | - <?php _e("Add mailto to all unlinked email addresses",'cryptx'); ?></td> | |
| 332 | - </tr> | |
| 333 | - <tr> | |
| 334 | - <td><input type="submit" name="submit" value="Update »" /></td> | |
| 335 | - </tr> | |
| 336 | - </table> | |
| 337 | - </blockquote> | |
| 338 | - </form> | |
| 339 | -</div> | |
| 340 | -<?php | |
| 402 | +function rw_cryptx_insert_post($pID) { | |
| 403 | + global $cryptX_var, $post; | |
| 404 | + $rev = wp_is_post_revision($pID); | |
| 405 | + if($rev) $pID = $rev; | |
| 406 | + $b = explode(",", $cryptX_var['excludedIDs']); | |
| 407 | + if($b[0] == '') unset($b[0]); | |
| 408 | + foreach($b as $x=>$y) { | |
| 409 | + if($y == $pID) { | |
| 410 | + unset($b[$x]); | |
| 411 | + break; | |
| 341 | 412 | } |
| 342 | - | |
| 343 | - // -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- | |
| 344 | - | |
| 345 | - | |
| 346 | - //--end-of-class | |
| 347 | 413 | } |
| 414 | + if (isset($_POST['cryptxoff'])) $b[] = $pID; | |
| 415 | + $b = array_unique($b); | |
| 416 | + sort($b); | |
| 417 | + $cryptX_var['excludedIDs'] = implode(",", $b); | |
| 418 | + update_option( 'cryptX', $cryptX_var); | |
| 419 | + $cryptX_var = (array) get_option('cryptX'); // reread Options | |
| 420 | +} | |
| 348 | 421 | |
| 422 | +function rw_cryptx_menu() { | |
| 423 | + add_options_page( | |
| 424 | + 'CryptX', | |
| 425 | + (version_compare($GLOBALS['wp_version'], '2.6.999', '>') ? '<img src="' .@plugins_url('cryptx/icon.png'). '" width="10" height="10" alt="CryptX Icon" />' : ''). 'CryptX', | |
| 426 | + 'manage_options', | |
| 427 | + __FILE__, | |
| 428 | + 'rw_cryptx_submenu' | |
| 429 | + ); | |
| 349 | 430 | } |
| 350 | 431 | |
| 351 | -///////////////////////////////////////////////////////////////////////////// | |
| 432 | +function rw_cryptx_submenu() { | |
| 433 | + global $cryptX_var; | |
| 434 | + if (isset($_POST) && !empty($_POST)) { | |
| 435 | + if (function_exists('current_user_can') === true && (current_user_can('manage_options') === false || current_user_can('edit_plugins') === false)) { | |
| 436 | + wp_die("You don't have permission to access!"); | |
| 437 | + } | |
| 438 | + check_admin_referer('cryptX'); | |
| 439 | + update_option( 'cryptX', $_POST['cryptX_var']); | |
| 440 | + $cryptX_var = (array) get_option('cryptX'); // reread Options | |
| 441 | + ?> | |
| 442 | + <div id="message" class="updated fade"> | |
| 443 | + <p><strong><?php _e('Settings saved.') ?></strong></p> | |
| 444 | + </div> | |
| 445 | + <?php } ?> | |
| 446 | + | |
| 447 | + <div class="wrap"> | |
| 448 | + <?php if (version_compare($GLOBALS['wp_version'], '2.6.999', '>')) { ?> | |
| 449 | + <div class="icon32" style="background: url(<?php echo @plugins_url('cryptx/icon32.png') ?>) no-repeat"><br /></div> | |
| 450 | + <?php } ?> | |
| 451 | + <h2>CryptX</h2> | |
| 452 | + <br class="clear" /> | |
| 453 | + <form method="post" action=""> | |
| 454 | + <?php wp_nonce_field('cryptX') ?> | |
| 455 | + <div id="poststuff" class="ui-sortable"> | |
| 456 | + <div id="rw_cryptx_information_box" class="postbox"> | |
| 457 | + <h3><?php _e("Information",'cryptx'); ?></h3> | |
| 458 | + <div class="inside"> | |
| 459 | + <table class="form-table"> | |
| 460 | + <tr> | |
| 461 | + <td valign="top" width="1%" nowrap><b><i><u>NEWS:</u></i> </b></td> | |
| 462 | + <td valign="top"><div id="cryptx-news-content" style="display:none;"></div></td> | |
| 463 | + <td valign="top" width="50%" style="border-left: 1px solid #999;"><?php | |
| 464 | + $data = get_plugin_data(__FILE__); | |
| 465 | + echo sprintf( | |
| 466 | + '%1$s: %2$s <br /> %3$s: %4$s <br /> %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 />', | |
| 467 | + __('Plugin'), | |
| 468 | + 'CryptX', | |
| 469 | + __('Version'), | |
| 470 | + $data['Version'], | |
| 471 | + __('Author'), | |
| 472 | + __('Follow on Twitter', 'cryptx'), | |
| 473 | + __('Donate', 'cryptx') | |
| 474 | + ); | |
| 475 | + ?> | |
| 476 | + </td> | |
| 477 | + </tr> | |
| 478 | + <tr> | |
| 479 | + <td colspan="3" align="center"> | |
| 480 | + 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. | |
| 481 | + </td> | |
| 482 | + </tr> | |
| 483 | + </table> | |
| 484 | + </div> | |
| 485 | + </div> | |
| 486 | + <div id="rw_cryptx_presentation_box" class="postbox"> | |
| 487 | + <h3><?php _e("Presentation",'cryptx'); ?></h3> | |
| 488 | + <div class="inside"> | |
| 489 | + <table class="form-table"> | |
| 490 | + <tr valign="top"> | |
| 491 | + <td><input name="cryptX_var[opt_linktext]" type="radio" id="opt_linktext" value="0" <?php echo ($cryptX_var['opt_linktext'] == 0) ? 'checked="checked"' : ''; ?> /></td> | |
| 492 | + <th scope="row"><label for="cryptX_var[at]"><?php _e("Replacement for '@'",'cryptx'); ?></label></th> | |
| 493 | + <td><input name="cryptX_var[at]" value="<?php echo $cryptX_var['at']; ?>" type="text" class="regular-text" /></td> | |
| 494 | + </tr> | |
| 495 | + <tr valign="top"> | |
| 496 | + <td> </td> | |
| 497 | + <th scope="row"><label for="cryptX_var[dot]"><?php _e("Replacement for '.'",'cryptx'); ?></label></th> | |
| 498 | + <td><input name="cryptX_var[dot]" value="<?php echo $cryptX_var['dot']; ?>" type="text" class="regular-text" /></td> | |
| 499 | + </tr> | |
| 500 | + <tr valign="top"> | |
| 501 | + <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> | |
| 502 | + <th><label for="cryptX_var[alt_linktext]"><?php _e("Text for link",'cryptx'); ?></label></th> | |
| 503 | + <td><input name="cryptX_var[alt_linktext]" value="<?php echo $cryptX_var['alt_linktext']; ?>" type="text" class="regular-text" /></td> | |
| 504 | + </tr> | |
| 505 | + <tr valign="top"> | |
| 506 | + <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> | |
| 507 | + <th><label for="cryptX_var[alt_linkimage]"><?php _e("Image-URL",'cryptx'); ?></label></th> | |
| 508 | + <td><input name="cryptX_var[alt_linkimage]" value="<?php echo $cryptX_var['alt_linkimage']; ?>" type="text" class="regular-text" /></td> | |
| 509 | + </tr> | |
| 510 | + <tr valign="top"> | |
| 511 | + <td scope="row"> </td> | |
| 512 | + <th><label for="cryptX_var[http_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th> | |
| 513 | + <td><input name="cryptX_var[http_linkimage_title]" value="<?php echo $cryptX_var['http_linkimage_title']; ?>" type="text" class="regular-text" /></td> | |
| 514 | + </tr> | |
| 515 | + <tr valign="top"> | |
| 516 | + <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> | |
| 517 | + <th><label for="cryptX_var[alt_uploadedimage]"><?php _e("Select image from folder",'cryptx'); ?></label></th> | |
| 518 | + <td> <select name="cryptX_var[alt_uploadedimage]" onchange="cryptX_bild_wechsel(this)"> | |
| 519 | + <?php foreach(rw_cryptx_dirImages() as $image) { | |
| 520 | + ?> | |
| 521 | + <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> | |
| 522 | + <?php } ?> | |
| 523 | + </select> | |
| 524 | + <br/><?php _e("the selected image: ",'cryptx'); ?><img src="<?php echo $cryptX_var['alt_uploadedimage']; ?>" id="cryptXmailTo" align="top" style="padding: 3px;"><br/> | |
| 525 | + <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> | |
| 526 | + </tr> | |
| 527 | + <tr valign="top"> | |
| 528 | + <td> </td> | |
| 529 | + <th><label for="cryptX_var[alt_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th> | |
| 530 | + <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptX_var['alt_linkimage_title']; ?>" type="text" class="regular-text" /></td> | |
| 531 | + </tr> | |
| 532 | + <tr valign="top"> | |
| 533 | + <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> | |
| 534 | + <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> | |
| 535 | + </tr> | |
| 536 | + <tr valign="top"> | |
| 537 | + <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> | |
| 538 | + <th><?php _e("Convert Email to PNG-image",'cryptx'); ?></th> | |
| 539 | + <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> | |
| 540 | + </tr> | |
| 541 | + <tr valign="top"> | |
| 542 | + <td> </td> | |
| 543 | + <th><label for="cryptX_var[c2i_font]"><?php _e("Choose a Font",'cryptx'); ?></label></th> | |
| 544 | + <td><select name="cryptX_var[c2i_font]"> | |
| 545 | + <?php foreach(rw_cryptx_dirFonts() as $font) { ?> | |
| 546 | + <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> | |
| 547 | + <?php } ?> | |
| 548 | + </select><br/> | |
| 549 | + <span class="setting-description"><?php echo sprintf( __("Upload your favorite font to '%s'. Only .ttf is Supported!",'cryptx'), plugin_dir_path( __FILE__ ).'fonts/' ); ?></span> | |
| 550 | + </td> | |
| 551 | + </tr> | |
| 552 | + <tr valign="top"> | |
| 553 | + <td> </td> | |
| 554 | + <th><label for="cryptX_var[c2i_fontSize]"><?php _e("Font size (pixel)",'cryptx'); ?></label></th> | |
| 555 | + <td><input name="cryptX_var[c2i_fontSize]" value="<?php echo $cryptX_var['c2i_fontSize']; ?>" type="text" class="regular-text" /></td> | |
| 556 | + </tr> | |
| 557 | + <tr valign="top"> | |
| 558 | + <td> </td> | |
| 559 | + <th><label for="cryptX_var[c2i_fontRGB]"><?php _e("Font color (RGB)",'cryptx'); ?></label></th> | |
| 560 | + <td><input name="cryptX_var[c2i_fontRGB]" value="<?php echo $cryptX_var['c2i_fontRGB']; ?>" type="text" class="regular-text" /></td> | |
| 561 | + </tr> | |
| 562 | + </table> | |
| 563 | + <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p> | |
| 564 | + </div> | |
| 565 | + </div> | |
| 566 | + <div id="rw_cryptx_general_box" class="postbox"> | |
| 567 | + <h3><?php _e("General",'cryptx'); ?></h3> | |
| 568 | + <div class="inside"> | |
| 569 | + <table class="form-table"> | |
| 570 | + <tr valign="top"> | |
| 571 | + <th scope="row"><?php _e("Apply CryptX to...",'cryptx'); ?></th> | |
| 572 | + <td><input name="cryptX_var[theContent]" type="checkbox" <?php echo (isset($cryptX_var['theContent']) == true) ? 'checked="checked"' : ''; ?> /> <?php _e("Content",'cryptx'); ?> <?php _e("(<i>this can be disabled per Post by an Option</i>)",'cryptx'); ?><br/> | |
| 573 | + <input name="cryptX_var[the_meta_key]" type="checkbox" <?php echo (isset($cryptX_var['the_meta_key']) == true) ? 'checked="checked"' : ''; ?> /> <?php _e("Custom fields",'cryptx'); ?><br/> | |
| 574 | + <input name="cryptX_var[theExcerpt]" type="checkbox" <?php echo (isset($cryptX_var['theExcerpt']) == true) ? 'checked="checked"' : ''; ?> /> <?php _e("Excerpt",'cryptx'); ?><br/> | |
| 575 | + <input name="cryptX_var[commentText]" type="checkbox" <?php echo (isset($cryptX_var['commentText']) == true) ? 'checked="checked"' : ''; ?> /> <?php _e("Comments",'cryptx'); ?><br/> | |
| 576 | + <input name="cryptX_var[widgetText]" type="checkbox" <?php echo (isset($cryptX_var['widgetText']) == true) ? 'checked="checked"' : ''; ?> /> <?php _e("Widgets",'cryptx'); ?> <?php _e("(<i>works only on all widgets, not on a single widget</i>!)",'cryptx'); ?></td> | |
| 577 | + </tr> | |
| 578 | + <tr valign="top"> | |
| 579 | + <th scope="row"><?php _e("Excluded ID's...",'cryptx'); ?></th> | |
| 580 | + <td><input name="cryptX_var[excludedIDs]" value="<?php echo $cryptX_var['excludedIDs']; ?>" type="text" class="regular-text" /> | |
| 581 | + <br/><span class="setting-description"><?php _e("Enter all Page/Post ID's to exclude from CryptX as comma seperated list.",'cryptx'); ?></span> | |
| 582 | + <br/><input name="cryptX_var[metaBox]" <?php echo (isset($cryptX_var['metaBox']) == true) ? 'checked="checked"' : ''; ?> type="checkbox" /> <?php _e("Enable the CryptX Widget on editing a post or page.",'cryptx'); ?></td> | |
| 583 | + </tr> | |
| 584 | + <tr valign="top"> | |
| 585 | + <th scope="row"><?php _e("Type of decryption",'cryptx'); ?></th> | |
| 586 | + <td><input name="cryptX_var[java]" <?php echo (isset($cryptX_var['java']) == true) ? 'checked="checked"' : ''; ?> type="radio" value="1" /> <?php _e("Use javascript to hide the Email-Link.",'cryptx'); ?><br/> | |
| 587 | + <input name="cryptX_var[java]" <?php echo (isset($cryptX_var['java']) != true) ? 'checked="checked"' : ''; ?> type="radio" value="0" /> <?php _e("Use Unicode to hide the Email-Link.",'cryptx'); ?></td> | |
| 588 | + </tr> | |
| 589 | + <tr valign="top"> | |
| 590 | + <th scope="row"><?php _e("Where to load the needed javascript...",'cryptx'); ?></th> | |
| 591 | + <td><input name="cryptX_var[load_java]" <?php echo (isset($cryptX_var['load_java']) != true) ? 'checked="checked"' : ''; ?> type="radio" value="0" /> <?php _e("Load the javascript in the <b>header</b> of the page.",'cryptx'); ?><br/> | |
| 592 | + <input name="cryptX_var[load_java]" <?php echo (isset($cryptX_var['load_java']) == true) ? 'checked="checked"' : ''; ?> type="radio" value="1" /> <?php _e("Load the javascript in the <b>footer</b> of the page.",'cryptx'); ?></td> | |
| 593 | + </tr> | |
| 594 | + <tr valign="top"> | |
| 595 | + <th scope="row" colspan="2"><input name="cryptX_var[autolink]" <?php echo (isset($cryptX_var['autolink']) == true) ? 'checked="checked"' : ''; ?> type="checkbox" /> <?php _e("Add mailto to all unlinked email addresses",'cryptx'); ?></th> | |
| 596 | + </tr> | |
| 597 | + </table> | |
| 598 | + <p><input type="submit" name="cryptX" class="button-primary" value="<?php _e('Save Changes') ?>" /></p> | |
| 599 | + </div> | |
| 600 | + </div> | |
| 601 | + <div id="rw_cryptx_howto_box" class="postbox"> | |
| 602 | + <h3><?php _e("How to use CryptX in your Template",'cryptx'); ?></h3> | |
| 603 | + <div class="inside"> | |
| 604 | + <table class="form-table"> | |
| 605 | + <tr> | |
| 606 | + <td>In your Template you can use the following function to encrypt a email address: | |
| 607 | + <p style="border:1px solid #000; background-color: #e9e9e9;padding: 10px;"> | |
| 608 | + <i> | |
| 609 | + <?php <br/> | |
| 610 | + $mail="name@example.com"; <br/> | |
| 611 | + $text="Contact"; <br/> | |
| 612 | + $css ="email"; <br/> | |
| 613 | + if (function_exists('cryptx')) { <br/> | |
| 614 | + cryptx($mail, $text, $css, 1); <br/> | |
| 615 | + } else { <br/> | |
| 616 | + echo sprintf('<a href="mailto:%s" class="%s">%s</a>', $mail, $css, ($text != "" ? $text : $mail)); <br/> | |
| 617 | + } <br/> | |
| 618 | + ?> | |
| 619 | + </i></p> | |
| 620 | + <ol><li>parameter is the email address.</li> | |
| 621 | + <li>parameter is the linktext. If none given the email address is used.</li> | |
| 622 | + <li>parameter is a css class added to the link.</li> | |
| 623 | + <li>parameter is 1 for echo the encrypted email address or 0 to return the redult to a variable.</li></ol></td> | |
| 624 | + </tr> | |
| 625 | + </table> | |
| 626 | + </div> | |
| 627 | + </div> | |
| 628 | + </form> | |
| 629 | + <script type="text/javascript"> | |
| 630 | + function cryptX_bild_wechsel(select){ | |
| 631 | + document.getElementById("cryptXmailTo").src = select.options[select.options.selectedIndex].value; | |
| 632 | + return true; | |
| 633 | + } | |
| 634 | + </script> | |
| 635 | + <script type="text/javascript"> | |
| 636 | + jQuery.ajax({ | |
| 637 | + url: "<?php bloginfo('wpurl'); ?>?cryptx=news", | |
| 638 | + success: function(data) { | |
| 639 | + jQuery("#cryptx-news-content").html(data).fadeIn(); | |
| 640 | + }, | |
| 641 | + error: function() { | |
| 642 | + jQuery("#cryptx-news-content").html('An error ocured while loading News.').fadeIn(); | |
| 643 | + } | |
| 644 | + }); | |
| 645 | + </script> | |
| 646 | + </div> | |
| 647 | + </div> | |
| 648 | +<?php | |
| 649 | + } | |
| 352 | 650 | |
| 353 | 651 | /** |
| 354 | -* Initiating the plugin... | |
| 355 | -* @see cryptX | |
| 652 | +* Create Template functions... | |
| 653 | +* $content = string to convert | |
| 654 | +* $text = string to replace linktext | |
| 655 | +* $css = assign a css class to the link | |
| 656 | +* $echo = 0: keep result in a variable, 1: show result | |
| 356 | 657 | */ |
| 357 | -new cryptX; | |
| 358 | - | |
| 359 | -?> | |
| 658 | +function cryptx( $content, $text="", $css="", $echo=1 ) { | |
| 659 | + global $cryptX_var; | |
| 660 | + $content = rw_cryptx_autolink( $content, true ); | |
| 661 | + $content = rw_cryptx_encryptx( $content, true ); | |
| 662 | + $content = rw_cryptx_linktext( $content, true ); | |
| 663 | + if("" != $text) { | |
| 664 | + $content = preg_replace( "/(<a[^>]*>)(.*)(<\/a>)/i", '$1'.$text.'$3', $content ); | |
| 665 | + } | |
| 666 | + if("" != $css) { | |
| 667 | + $content = preg_replace( "/(<a[^>]*)(>)/i", '$1 class="'.$css.'"$2', $content ); | |
| 668 | + } | |
| 669 | + if(1 == $echo) echo $content; | |
| 670 | + return $content; | |
| 671 | +} | |
| 672 | +?> | |