Changeset 3102339
- Timestamp:
- 06/13/2024 01:47:03 PM (20 months ago)
- Location:
- cryptx/tags/3.4
- Files:
-
- 3 added
- 8 edited
- 1 copied
-
. (copied) (copied from cryptx/trunk)
-
classes (added)
-
classes/CryptX.php (added)
-
cryptx.php (modified) (2 diffs)
-
include/admin_changelog.php (modified) (1 diff)
-
include/admin_general.php (modified) (7 diffs)
-
include/admin_howto.php (modified) (1 diff)
-
include/admin_option_page.php (modified) (3 diffs)
-
include/admin_presentation.php (modified) (12 diffs)
-
js/cryptx-min.js (added)
-
js/cryptx.js (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
cryptx/tags/3.4/cryptx.php
r2530154 r3102339 4 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: 3. 3.3.27 * Requires at least: 4.66 * Version: 3.4 7 * Requires at least: 6.0 8 8 * Author: Ralf Weber 9 9 * Author URI: http://weber-nrw.de/ … … 14 14 15 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();16 if ( ! function_exists( 'add_action' ) ) { 17 header( 'Status: 403 Forbidden' ); 18 header( 'HTTP/1.1 403 Forbidden' ); 19 exit(); 20 20 } 21 21 22 /**23 * some basics24 */25 global $wp_version;26 22 /** @const CryptX version */ 27 define( 'CRYPTX_VERSION', "3. 3.2");23 define( 'CRYPTX_VERSION', "3.4" ); 28 24 define( 'CRYPTX_BASENAME', plugin_basename( __FILE__ ) ); 29 25 define( 'CRYPTX_BASEFOLDER', plugin_basename( dirname( __FILE__ ) ) ); 30 define( 'CRYPTX_DIR_URL', rtrim( plugin_dir_url( __FILE__ ), "/" ) ."/" );26 define( 'CRYPTX_DIR_URL', rtrim( plugin_dir_url( __FILE__ ), "/" ) . "/" ); 31 27 define( 'CRYPTX_DIR_PATH', plugin_dir_path( __FILE__ ) ); 32 define( 'CRYPTX_FILENAME', str_replace( CRYPTX_BASEFOLDER .'/', '', plugin_basename(__FILE__) ) );28 define( 'CRYPTX_FILENAME', str_replace( CRYPTX_BASEFOLDER . '/', '', plugin_basename( __FILE__ ) ) ); 33 29 34 require_once(CRYPTX_DIR_PATH . 'include/functions.php'); 30 require_once( CRYPTX_DIR_PATH . 'classes/CryptX.php' ); 31 require_once( CRYPTX_DIR_PATH . 'include/admin_option_page.php' ); 35 32 36 require_once(CRYPTX_DIR_PATH . 'include/admin_option_page.php'); 33 $CryptX_instance = Cryptx\CryptX::getInstance(); 34 $CryptX_instance->startCryptX(); 37 35 38 $cryptX_var = get_option('cryptX');39 36 /** 40 * check for needed updates 37 * Encrypts the given content using the Cryptx shortcode. 38 * 39 * @param string $content The content to be encrypted. 40 * @param string $args (optional) Additional arguments is deprecated and are not used anymore. 41 * 42 * @return string The encrypted content wrapped in the Cryptx shortcode. 41 43 */ 42 if( isset( $cryptX_var['version'] ) && version_compare(CRYPTX_VERSION, $cryptX_var['version']) > 0 ){43 cryptx_do_updates();44 function encryptx( string $content, string $args = "" ): string { 45 return do_shortcode( '[cryptx]' . $content . '[/cryptx]' ); 44 46 } 45 $cryptX_var = rw_loadDefaults();46 47 $is_js_needed = false;48 49 foreach($cryptX_var['filter'] as $filter) {50 if (@$cryptX_var[$filter]) {51 rw_cryptx_filter($filter);52 }53 }54 55 add_action( 'activate_' . CRYPTX_BASENAME, 'rw_cryptx_install' );56 57 // Hook into the 'wp_enqueue_scripts' action58 add_action( 'wp_enqueue_scripts', 'cryptx_javascripts_load' );59 60 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' );65 }66 67 add_filter( 'plugin_row_meta', 'rw_cryptx_init_row_meta', 10, 2 );68 69 add_filter( 'init', 'rw_cryptx_init_tinyurl');70 // add_action( 'parse_request', 'rw_cryptx_parse_request');71 72 add_shortcode( 'cryptx', 'rw_cryptx_shortcode'); -
cryptx/tags/3.4/include/admin_changelog.php
r2159075 r3102339 4 4 */ 5 5 function rw_cryptx_settings_tab_content_changelog() { 6 global $cryptX_var, $rw_cryptx_active_tab; 7 if ( 'changelog' != $rw_cryptx_active_tab ) 6 if ( 'changelog' != rw_cryptx_getActiveTab() ) { 8 7 return; 8 } 9 9 10 /** 11 * the following code is quick and dirty to parse the changelog content of the readme.txt file 12 */ 13 $file_contents = @implode('', @file(CRYPTX_DIR_PATH . '/readme.txt')); 14 $file_contents = str_replace(array("\r\n", "\r"), "\n", $file_contents); 15 $file_contents = trim($file_contents); 16 // split $file_content into sections 17 $_sections = preg_split('/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); 18 $sections = array(); 19 for ( $i=1; $i <= count($_sections); $i +=2 ) { 20 $_sections[$i] = $_sections[$i]; 21 $title = $_sections[$i-1]; 22 $sections[str_replace(' ', '_', strtolower($title))] = array('title' => $title, 'content' => $_sections[$i]); 23 } 24 // split changelog section into single version entries 25 $_changelogs = preg_split('/^[\s]*=[\s]*(.+?)[\s]*=/m', $sections['changelog']['content'], -1, PREG_SPLIT_DELIM_CAPTURE|PREG_SPLIT_NO_EMPTY); 26 $entries = array(); 27 for ( $i=1; $i <= count($_changelogs); $i +=2 ) { 28 $_changelogs[$i] = $_changelogs[$i]; 29 $version = $_changelogs[$i-1]; 30 $entries[str_replace(' ', '_', strtolower($version))] = array('version' => $version, 'content' => $_changelogs[$i]); 10 /** 11 * the following code is quick and dirty to parse the changelog content of the readme.txt file 12 */ 13 $file_contents = @implode( '', @file( CRYPTX_DIR_PATH . '/readme.txt' ) ); 14 $file_contents = str_replace( array( "\r\n", "\r" ), "\n", $file_contents ); 15 $file_contents = trim( $file_contents ); 16 // split $file_content into sections 17 $_sections = preg_split( '/^[\s]*==[\s]*(.+?)[\s]*==/m', $file_contents, - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); 18 $sections = array(); 19 for ( $i = 1; $i <= count( $_sections ); $i += 2 ) { 20 $_sections[ $i ] = $_sections[ $i ]; 21 $title = $_sections[ $i - 1 ]; 22 $sections[ str_replace( ' ', '_', strtolower( $title ) ) ] = array( 23 'title' => $title, 24 'content' => $_sections[ $i ] 25 ); 26 } 27 // split changelog section into single version entries 28 $_changelogs = preg_split( '/^[\s]*=[\s]*(.+?)[\s]*=/m', $sections['changelog']['content'], - 1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY ); 29 $entries = array(); 30 for ( $i = 1; $i <= count( $_changelogs ); $i += 2 ) { 31 $_changelogs[ $i ] = $_changelogs[ $i ]; 32 $version = $_changelogs[ $i - 1 ]; 33 $entries[ str_replace( ' ', '_', strtolower( $version ) ) ] = array( 34 'version' => $version, 35 'content' => $_changelogs[ $i ] 36 ); 37 } 38 // rearrange version entries as html 39 $changelogs = array(); 40 foreach ( $entries as $entry ) { 41 $content = $entry['content']; 42 $content = ltrim( $content, "\n" ); 43 $content = str_replace( "* ", "<li>", $content ); 44 $content = str_replace( "\n", " </li>\n", $content ); 45 $changelogs[] = array( 46 'version' => "<dt>" . $entry['version'] . "</dt>", 47 'content' => "<dd><ul>" . $content . "</ul></dd>" 48 ); 49 } 50 unset( $file_contents, $_sections, $sections, $_changelogs, $entries ); 51 ?> 52 <h4><?php _e( "Changelog", 'cryptx' ); ?></h4> 53 <?php 54 foreach ( $changelogs as $log ) { 55 echo "<dl>" . implode( "", $log ) . "</dl>"; 56 } 57 unset( $changelogs ); 31 58 } 32 // rearrange version entries as html 33 $changelogs = array(); 34 foreach($entries as $entry) { 35 $content = $entry['content']; 36 $content = ltrim( $content, "\n"); 37 $content = str_replace("* ", "<li>", $content); 38 $content = str_replace("\n", " </li>\n", $content); 39 $changelogs[]= array('version' => "<dt>".$entry['version']."</dt>", 'content' => "<dd><ul>".$content."</ul></dd>"); 40 } 41 unset( $file_contents, $_sections, $sections, $_changelogs, $entries); 42 ?> 43 <h4><?php _e( "Changelog",'cryptx' ); ?></h4> 44 <?php 45 foreach($changelogs as $log) { 46 echo "<dl>".implode("",$log)."</dl>"; 47 } 48 unset( $changelogs ); 49 } 59 50 60 add_action( 'rw_cryptx_settings_content', 'rw_cryptx_settings_tab_content_changelog' ); -
cryptx/tags/3.4/include/admin_general.php
r2159075 r3102339 4 4 */ 5 5 function rw_cryptx_settings_tab_content_general() { 6 global $cryptX_var, $rw_cryptx_active_tab; 7 if ( 'general' != $rw_cryptx_active_tab ) 6 $CryptX_instance = Cryptx\CryptX::getInstance(); 7 $cryptXOptions = $CryptX_instance->loadCryptXOptionsWithDefaults(); 8 if ( 'general' != rw_cryptx_getActiveTab() ) 8 9 return; 9 10 ?> … … 14 15 <th scope="row"><?php _e("Apply CryptX to...",'cryptx'); ?></th> 15 16 <td> 16 <input name="cryptX_var[the_content]" type="checkbox" value="1" <?php checked( $cryptX _var['the_content'], 1 ); ?> /> <?php _e("Content",'cryptx'); ?> <?php _e("(<i>this can be disabled per Post by an Option</i>)",'cryptx'); ?><br/>17 <input name="cryptX_var[the_meta_key]" type="checkbox" value="1" <?php checked( $cryptX _var['the_meta_key'], 1 ); ?> /> <?php _e("Custom fields (<strong>works only with the_meta()!</strong>)",'cryptx'); ?><br/>18 <input name="cryptX_var[the_excerpt]" type="checkbox" value="1" <?php checked( $cryptX _var['the_excerpt'], 1 ); ?> /> <?php _e("Excerpt",'cryptx'); ?><br/>19 <input name="cryptX_var[comment_text]" type="checkbox" value="1" <?php checked( $cryptX _var['comment_text'], 1 ); ?> /> <?php _e("Comments",'cryptx'); ?><br/>20 <input name="cryptX_var[widget_text]" type="checkbox" value="1" <?php checked( $cryptX _var['widget_text'], 1 ); ?> /> <?php _e("Widgets",'cryptx'); ?> <?php _e("(<i>works only on all widgets, not on a single widget</i>!)",'cryptx'); ?>17 <input name="cryptX_var[the_content]" type="checkbox" value="1" <?php checked( $cryptXOptions['the_content'], 1 ); ?> /> <?php _e("Content",'cryptx'); ?> <?php _e("(<i>this can be disabled per Post by an Option</i>)",'cryptx'); ?><br/> 18 <input name="cryptX_var[the_meta_key]" type="checkbox" value="1" <?php checked( $cryptXOptions['the_meta_key'], 1 ); ?> /> <?php _e("Custom fields (<strong>works only with the_meta()!</strong>)",'cryptx'); ?><br/> 19 <input name="cryptX_var[the_excerpt]" type="checkbox" value="1" <?php checked( $cryptXOptions['the_excerpt'], 1 ); ?> /> <?php _e("Excerpt",'cryptx'); ?><br/> 20 <input name="cryptX_var[comment_text]" type="checkbox" value="1" <?php checked( $cryptXOptions['comment_text'], 1 ); ?> /> <?php _e("Comments",'cryptx'); ?><br/> 21 <input name="cryptX_var[widget_text]" type="checkbox" value="1" <?php checked( $cryptXOptions['widget_text'], 1 ); ?> /> <?php _e("Widgets",'cryptx'); ?> <?php _e("(<i>works only on all widgets, not on a single widget</i>!)",'cryptx'); ?> 21 22 </td> 22 23 </tr> … … 28 29 <tr> 29 30 <th scope="row"><?php _e("Excluded ID's...",'cryptx'); ?></th> 30 <td><input name="cryptX_var[excludedIDs]" value="<?php echo $cryptX _var['excludedIDs']; ?>" type="text" class="regular-text" />31 <td><input name="cryptX_var[excludedIDs]" value="<?php echo $cryptXOptions['excludedIDs']; ?>" type="text" class="regular-text" /> 31 32 <br/><span class="setting-description"><?php _e("Enter all Page/Post ID's to exclude from CryptX as comma seperated list.",'cryptx'); ?></span> 32 <br/><input name="cryptX_var[metaBox]" type="checkbox" value="1" <?php checked( $cryptX _var['metaBox'], 1 ); ?> /> <?php _e("Enable the CryptX Widget on editing a post or page.",'cryptx'); ?></td>33 <br/><input name="cryptX_var[metaBox]" type="checkbox" value="1" <?php checked( $cryptXOptions['metaBox'], 1 ); ?> /> <?php _e("Enable the CryptX Widget on editing a post or page.",'cryptx'); ?></td> 33 34 </tr> 34 35 … … 39 40 <tr> 40 41 <th scope="row"><?php _e("Type of decryption",'cryptx'); ?></th> 41 <td><input name="cryptX_var[java]" type="radio" value="1" <?php checked( $cryptX _var['java'], 1 ); ?>/> <?php _e("Use javascript to hide the Email-Link.",'cryptx'); ?><br/>42 <input name="cryptX_var[java]" type="radio" value="0" <?php checked( $cryptX _var['java'], 0 ); ?>/> <?php _e("Use Unicode to hide the Email-Link.",'cryptx'); ?></td>42 <td><input name="cryptX_var[java]" type="radio" value="1" <?php checked( $cryptXOptions['java'], 1 ); ?>/> <?php _e("Use javascript to hide the Email-Link.",'cryptx'); ?><br/> 43 <input name="cryptX_var[java]" type="radio" value="0" <?php checked( $cryptXOptions['java'], 0 ); ?>/> <?php _e("Use Unicode to hide the Email-Link.",'cryptx'); ?></td> 43 44 </tr> 44 45 … … 49 50 <tr> 50 51 <th scope="row"><?php _e("Where to load the needed javascript...",'cryptx'); ?></th> 51 <td><input name="cryptX_var[load_java]" type="radio" value="0" <?php checked( $cryptX _var['load_java'], 0 ); ?>/> <?php _e("Load the javascript in the <b>header</b> of the page.",'cryptx'); ?><br/>52 <input name="cryptX_var[load_java]" type="radio" value="1" <?php checked( $cryptX _var['load_java'], 1 ); ?>/> <?php _e("Load the javascript in the <b>footer</b> of the page.",'cryptx'); ?></td>52 <td><input name="cryptX_var[load_java]" type="radio" value="0" <?php checked( $cryptXOptions['load_java'], 0 ); ?>/> <?php _e("Load the javascript in the <b>header</b> of the page.",'cryptx'); ?><br/> 53 <input name="cryptX_var[load_java]" type="radio" value="1" <?php checked( $cryptXOptions['load_java'], 1 ); ?>/> <?php _e("Load the javascript in the <b>footer</b> of the page.",'cryptx'); ?></td> 53 54 </tr> 54 55 … … 58 59 59 60 <tr> 60 <th scope="row" colspan="2"><input name="cryptX_var[autolink]" type="checkbox" value="1" <?php checked( $cryptX _var['autolink'], 1 ); ?>/> <?php _e("Add mailto to all unlinked email addresses",'cryptx'); ?></th>61 <th scope="row" colspan="2"><input name="cryptX_var[autolink]" type="checkbox" value="1" <?php checked( $cryptXOptions['autolink'], 1 ); ?>/> <?php _e("Add mailto to all unlinked email addresses",'cryptx'); ?></th> 61 62 </tr> 62 63 … … 67 68 <tr> 68 69 <th scope="row"><?php _e("Whitelist of extensions",'cryptx'); ?></th> 69 <td><input name="cryptX_var[whiteList]" value="<?php echo $cryptX _var['whiteList']; ?>" type="text" class="regular-text" />70 <td><input name="cryptX_var[whiteList]" value="<?php echo $cryptXOptions['whiteList']; ?>" type="text" class="regular-text" /> 70 71 <br/><span class="setting-description"><?php _e("<strong>This is a workaround for the 'retina issue'.</strong><br/>You can provide a comma seperated list of extensions like 'jpeg,jpg,png,gif' which will be ignored by CryptX.",'cryptx'); ?></span> 71 72 </tr> -
cryptx/tags/3.4/include/admin_howto.php
r2186829 r3102339 4 4 */ 5 5 function rw_cryptx_settings_tab_content_howto() { 6 global $cryptX_var, $rw_cryptx_active_tab; 7 if ( 'howto' != $rw_cryptx_active_tab ) 6 if ( 'howto' != rw_cryptx_getActiveTab() ) 8 7 return; 9 8 ?> -
cryptx/tags/3.4/include/admin_option_page.php
r2530154 r3102339 74 74 * save options 75 75 */ 76 function rw_cryptx_saveOptions() { 77 global $cryptX_var, $data, $rw_cryptx_active_tab; 78 79 if (isset($_POST) && !empty($_POST)) { 80 if (function_exists('current_user_can') === true && current_user_can('manage_options') === false) { 81 wp_die("You don't have permission to access!"); 82 } 83 $saveOptions = cryptx_sanitize_data($_POST['cryptX_var']); 84 check_admin_referer('cryptX'); 85 if(isset($_POST['cryptX_var_reset'])) { 86 delete_option('cryptX'); 87 $saveOptions = rw_loadDefaults(); 88 } 89 if(isset($_POST['cryptX_save_general_settings'])) { 90 $checkboxes = array( 91 'the_content' => 0, 92 'the_meta_key' => 0, 93 'the_excerpt' => 0, 94 'comment_text' => 0, 95 'widget_text' => 0, 96 'autolink' => 0, 97 'metaBox' => 0, 98 ); 99 $saveOptions = wp_parse_args( $saveOptions, $checkboxes ); 100 } 101 $saveOptions = wp_parse_args( $saveOptions, rw_loadDefaults() ); 102 update_option( 'cryptX', $saveOptions); 103 $cryptX_var = rw_loadDefaults(); 104 ?> 105 <div id="message" class="updated fade"> 106 <p><strong><?php _e('Settings saved.') ?></strong></p> 107 </div> 108 <?php 109 } 76 function rw_cryptx_saveOptions(): void { 77 if ( isValidPostRequest() ) { 78 $CryptX_instance = Cryptx\CryptX::getInstance(); 79 $saveOptions = sanitizePostData(); 80 81 check_admin_referer( 'cryptX' ); 82 83 if ( isResetPost() ) { 84 // $saveOptions = rw_Defaults(); 85 $saveOptions = $CryptX_instance->getCryptXOptionsDefaults(); 86 } 87 88 if ( isSaveGeneralSettingsPost() ) { 89 $saveOptions = parseGeneralSettings( $saveOptions ); 90 } 91 92 // $saveOptions = wp_parse_args( $saveOptions, rw_loadCryptXOptionsWithDefaults() ); 93 $CryptX_instance->saveCryptXOptions($saveOptions); 94 // $saveOptions = wp_parse_args( $saveOptions, $CryptX_instance->loadCryptXOptionsWithDefaults() ); 95 // update_option( 'cryptX', $saveOptions ); 96 // $cryptXOptions = rw_loadCryptXOptionsWithDefaults(); 97 98 displaySuccessMessage(); 99 } 100 } 101 102 function isValidPostRequest(): bool { 103 if ( function_exists( 'current_user_can' ) === true && current_user_can( 'manage_options' ) === false ) { 104 wp_die( "You don't have permission to access!" ); 105 } 106 107 return ! empty( $_POST['cryptX_var'] ); 108 } 109 110 function sanitizePostData() { 111 return cryptx_sanitize_data( $_POST['cryptX_var'] ); 112 } 113 114 function isResetPost(): bool { 115 return isset( $_POST['cryptX_var_reset'] ); 116 } 117 118 function isSaveGeneralSettingsPost(): bool { 119 return isset( $_POST['cryptX_save_general_settings'] ); 120 } 121 122 function parseGeneralSettings( $saveOptions ): array { 123 $checkboxes = [ 124 'the_content' => 0, 125 'the_meta_key' => 0, 126 'the_excerpt' => 0, 127 'comment_text' => 0, 128 'widget_text' => 0, 129 'autolink' => 0, 130 'metaBox' => 0, 131 ]; 132 133 return wp_parse_args( $saveOptions, $checkboxes ); 134 } 135 136 function displaySuccessMessage(): void { 137 echo "<div id='message' class='updated fade'><p><strong>"; 138 _e( 'Settings saved.' ); 139 echo "</strong></p></div>"; 110 140 } 111 141 … … 113 143 * sanitize given options 114 144 */ 115 function cryptx_sanitize_data($data) { 116 if( isset( $data['version']) ) $data['version'] = sanitize_text_field($data['version']); 117 if( isset( $data['at']) ) $data['at'] = sanitize_text_field($data['at']); 118 if( isset( $data['dot']) ) $data['dot'] = sanitize_text_field($data['dot']); 119 if( isset( $data['css_id']) ) $data['css_id'] = sanitize_text_field($data['css_id']); 120 if( isset( $data['css_class']) ) $data['css_class'] = sanitize_text_field($data['css_class']); 121 if( isset( $data['the_content']) ) $data['the_content'] = (int) $data['the_content']; 122 if( isset( $data['the_meta_key']) ) $data['the_meta_key'] = (int) $data['the_meta_key']; 123 if( isset( $data['the_excerpt']) ) $data['the_excerpt'] = (int) $data['the_excerpt']; 124 if( isset( $data['comment_text']) ) $data['comment_text'] = (int) $data['comment_text']; 125 if( isset( $data['java']) ) $data['java'] = (int) $data['java']; 126 if( isset( $data['load_java']) ) $data['load_java'] = (int) $data['load_java']; 127 if( isset( $data['opt_linktext']) ) $data['opt_linktext'] = (int) $data['opt_linktext']; 128 if( isset( $data['autolink']) ) $data['autolink'] = (int) $data['autolink']; 129 if( isset( $data['alt_linktext']) ) $data['alt_linktext'] = sanitize_text_field($data['alt_linktext']); 130 if( isset( $data['http_linkimage_title']) ) $data['http_linkimage_title'] = sanitize_text_field($data['http_linkimage_title']); 131 if( isset( $data['alt_linkimage_title']) ) $data['alt_linkimage_title'] = sanitize_text_field($data['alt_linkimage_title']); 132 if( isset( $data['excludedIDs']) ) $data['excludedIDs'] = sanitize_text_field($data['excludedIDs']); 133 if( isset( $data['metaBox']) ) $data['metaBox'] = (bool) $data['metaBox']; 134 if( isset( $data['excludedIDs']) ) $data['excludedIDs'] = sanitize_text_field($data['excludedIDs']); 135 if( isset( $data['alt_uploadedimage']) ) $data['alt_uploadedimage'] = sanitize_text_field($data['alt_uploadedimage']); 136 if( isset( $data['c2i_font']) ) $data['c2i_font'] = sanitize_text_field($data['c2i_font']); 137 if( isset( $data['c2i_fontSize']) ) $data['c2i_fontSize'] = (int) $data['c2i_fontSize']; 138 if( isset( $data['c2i_fontRGB']) ) $data['c2i_fontRGB'] = sanitize_text_field($data['c2i_fontRGB']); 139 if( isset( $data['echo']) ) $data['echo'] = (int) $data['echo']; 140 if( isset( $data['whiteList']) ) $data['whiteList'] = sanitize_text_field($data['whiteList']); 141 return $data; 145 function cryptx_sanitize_data( $data ) { 146 $textFields = [ 147 'version', 148 'at', 149 'dot', 150 'css_id', 151 'css_class', 152 'alt_linktext', 153 'http_linkimage_title', 154 'alt_linkimage_title', 155 'excludedIDs', 156 'alt_uploadedimage', 157 'c2i_font', 158 'c2i_fontRGB', 159 'whiteList' 160 ]; 161 162 $intFields = [ 163 'the_content', 164 'the_meta_key', 165 'the_excerpt', 166 'comment_text', 167 'java', 168 'load_java', 169 'opt_linktext', 170 'autolink', 171 'c2i_fontSize', 172 'echo' 173 ]; 174 175 $boolFields = [ 'metaBox' ]; 176 177 foreach ( $textFields as $field ) { 178 if ( isset( $data[ $field ] ) ) { 179 $data[ $field ] = sanitize_text_field( $data[ $field ] ); 180 } 181 } 182 183 foreach ( $intFields as $field ) { 184 if ( isset( $data[ $field ] ) ) { 185 $data[ $field ] = (int) $data[ $field ]; 186 } 187 } 188 189 foreach ( $boolFields as $field ) { 190 if ( isset( $data[ $field ] ) ) { 191 $data[ $field ] = (bool) $data[ $field ]; 192 } 193 } 194 195 return $data; 142 196 } 143 197 … … 146 200 */ 147 201 function rw_cryptx_submenu() { 148 global $cryptX_var, $data, $rw_cryptx_active_tab; 149 rw_cryptx_saveOptions(); 150 $rw_cryptx_active_tab = isset( $_GET['tab'] ) ? $_GET['tab'] : 'general'; 151 ?> 202 // global $cryptXOptions, $data, $rw_cryptx_active_tab; 203 rw_cryptx_saveOptions(); 204 205 // Give meaningful name to tab variable 206 rw_cryptx_generateHtml(); 207 } 208 209 function rw_cryptx_generateHtml(): void { 210 ?> 152 211 <div class="cryptx-option-page"> 153 <h1><?php _e("CryptX settings", 'cryptx'); ?></h1>212 <h1><?php _e("CryptX settings", 'cryptx'); ?></h1> 154 213 <form method="post" action=""> 155 <?php wp_nonce_field('cryptX') ?> 156 157 <h2 class="nav-tab-wrapper"> 158 <?php 159 do_action( 'rw_cryptx_settings_tab' ); 160 ?> 161 </h2> 162 <div class="cryptx-tab-content-wrapper"> 163 <?php 164 do_action( 'rw_cryptx_settings_content' ); 165 ?> 166 </div><!-- /.cryptx-tab-content-wrapper --> 214 <?php wp_nonce_field('cryptX') ?> 215 <h2 class="nav-tab-wrapper"> 216 <?php 217 do_action('rw_cryptx_settings_tab'); 218 ?> 219 </h2> 220 <div class="cryptx-tab-content-wrapper"> 221 <?php 222 do_action('rw_cryptx_settings_content'); 223 ?> 224 </div><!-- /.cryptx-tab-content-wrapper --> 167 225 </form> 168 226 </div><!-- /.cryptx-option-page --> 169 <?php 170 } 171 227 <?php 228 } 229 230 function rw_cryptx_getActiveTab() { 231 $allowedTabs = ['general', 'presentation', 'howto', 'changelog']; 232 $tab = $_GET['tab'] ?? 'general'; 233 return in_array($tab, $allowedTabs) ? $tab : 'general'; 234 } 172 235 /** 173 236 * Option page navigation 174 237 */ 175 function rw_cryptx_settings_tab_presentation(){ 176 global $rw_cryptx_active_tab; ?> 177 <a class="nav-tab <?php echo $rw_cryptx_active_tab == 'general' || '' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=general' ); ?>"> 238 function rw_cryptx_settings_tab_presentation(): void { 239 //global $rw_cryptx_active_tab; 240 ?> 241 <a class="nav-tab <?php echo rw_cryptx_getActiveTab() == 'general' || '' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=general' ); ?>"> 178 242 <?php _e("General",'cryptx'); ?> 179 243 </a> 180 <a class="nav-tab <?php echo $rw_cryptx_active_tab== 'presentation' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=presentation' ); ?>">244 <a class="nav-tab <?php echo rw_cryptx_getActiveTab() == 'presentation' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=presentation' ); ?>"> 181 245 <?php _e("Presentation",'cryptx'); ?> 182 246 </a> 183 <a class="nav-tab <?php echo $rw_cryptx_active_tab== 'howto' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=howto' ); ?>">247 <a class="nav-tab <?php echo rw_cryptx_getActiveTab() == 'howto' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=howto' ); ?>"> 184 248 <?php _e("How to…",'cryptx'); ?> 185 249 </a> 186 <a class="nav-tab <?php echo $rw_cryptx_active_tab== 'changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=changelog' ); ?>">250 <a class="nav-tab <?php echo rw_cryptx_getActiveTab() == 'changelog' ? 'nav-tab-active' : ''; ?>" href="<?php echo admin_url( 'options-general.php?page=' . CRYPTX_BASEFOLDER . '&tab=changelog' ); ?>"> 187 251 <?php _e("Changelog",'cryptx'); ?> 188 252 </a> 189 253 <?php 190 254 } 191 add_action( 'rw_cryptx_settings_tab', 'rw_cryptx_settings_tab_presentation' );255 add_action( 'rw_cryptx_settings_tab', 'rw_cryptx_settings_tab_presentation'); -
cryptx/tags/3.4/include/admin_presentation.php
r2159075 r3102339 4 4 */ 5 5 function rw_cryptx_settings_tab_content_presentation() { 6 global $cryptX_var, $rw_cryptx_active_tab; 7 if ( 'presentation' != $rw_cryptx_active_tab ) 6 $CryptX_instance = Cryptx\CryptX::getInstance(); 7 $cryptXOptions = $CryptX_instance->loadCryptXOptionsWithDefaults(); 8 if ( 'presentation' != rw_cryptx_getActiveTab() ) 8 9 return; 9 10 ?> … … 14 15 <tr> 15 16 <th><label for="cryptX_var[css_id]"><?php _e("CSS ID",'cryptx'); ?></label></th> 16 <td><input name="cryptX_var[css_id]" value="<?php echo $cryptX _var['css_id']; ?>" type="text" class="regular-text" /><br /><?php _e("Please be careful using this feature! IDs should be unique. You should prefer of using a css class instead.",'cryptx'); ?></td>17 <td><input name="cryptX_var[css_id]" value="<?php echo $cryptXOptions['css_id']; ?>" type="text" class="regular-text" /><br /><?php _e("Please be careful using this feature! IDs should be unique. You should prefer of using a css class instead.",'cryptx'); ?></td> 17 18 </tr> 18 19 <tr> 19 20 <th><label for="cryptX_var[css_class]"><?php _e("CSS Class",'cryptx'); ?></label></th> 20 <td><input name="cryptX_var[css_class]" value="<?php echo $cryptX _var['css_class']; ?>" type="text" class="regular-text" /></td>21 <td><input name="cryptX_var[css_class]" value="<?php echo $cryptXOptions['css_class']; ?>" type="text" class="regular-text" /></td> 21 22 </tr> 22 23 </table> … … 27 28 <tbody> 28 29 <tr> 29 <td><input name="cryptX_var[opt_linktext]" type="radio" id="opt_linktext" value="0" <?php checked( $cryptX _var['opt_linktext'], 0 ); ?> /></td>30 <td><input name="cryptX_var[opt_linktext]" type="radio" id="opt_linktext" value="0" <?php checked( $cryptXOptions['opt_linktext'], 0 ); ?> /></td> 30 31 <th scope="row"><label for="cryptX_var[at]"><?php _e("Replacement for '@'",'cryptx'); ?></label></th> 31 <td><input name="cryptX_var[at]" value="<?php echo $cryptX _var['at']; ?>" type="text" class="regular-text" /></td>32 <td><input name="cryptX_var[at]" value="<?php echo $cryptXOptions['at']; ?>" type="text" class="regular-text" /></td> 32 33 </tr> 33 34 <tr> 34 35 <td> </td> 35 36 <th scope="row"><label for="cryptX_var[dot]"><?php _e("Replacement for '.'",'cryptx'); ?></label></th> 36 <td><input name="cryptX_var[dot]" value="<?php echo $cryptX _var['dot']; ?>" type="text" class="regular-text" /></td>37 <td><input name="cryptX_var[dot]" value="<?php echo $cryptXOptions['dot']; ?>" type="text" class="regular-text" /></td> 37 38 </tr> 38 39 … … 42 43 43 44 <tr> 44 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext2" value="1" <?php checked( $cryptX _var['opt_linktext'], 1 ); ?> /></td>45 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext2" value="1" <?php checked( $cryptXOptions['opt_linktext'], 1 ); ?> /></td> 45 46 <th><label for="cryptX_var[alt_linktext]"><?php _e("Text for link",'cryptx'); ?></label></th> 46 <td><input name="cryptX_var[alt_linktext]" value="<?php echo $cryptX _var['alt_linktext']; ?>" type="text" class="regular-text" /></td>47 <td><input name="cryptX_var[alt_linktext]" value="<?php echo $cryptXOptions['alt_linktext']; ?>" type="text" class="regular-text" /></td> 47 48 </tr> 48 49 … … 52 53 53 54 <tr> 54 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext3" value="2" <?php checked( $cryptX _var['opt_linktext'], 2 ); ?> /></td>55 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext3" value="2" <?php checked( $cryptXOptions['opt_linktext'], 2 ); ?> /></td> 55 56 <th><label for="cryptX_var[alt_linkimage]"><?php _e("Image-URL",'cryptx'); ?></label></th> 56 <td><input name="cryptX_var[alt_linkimage]" value="<?php echo $cryptX _var['alt_linkimage']; ?>" type="text" class="regular-text" /></td>57 <td><input name="cryptX_var[alt_linkimage]" value="<?php echo $cryptXOptions['alt_linkimage']; ?>" type="text" class="regular-text" /></td> 57 58 </tr> 58 59 <tr> 59 60 <td scope="row"> </td> 60 61 <th><label for="cryptX_var[http_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th> 61 <td><input name="cryptX_var[http_linkimage_title]" value="<?php echo $cryptX _var['http_linkimage_title']; ?>" type="text" class="regular-text" /></td>62 <td><input name="cryptX_var[http_linkimage_title]" value="<?php echo $cryptXOptions['http_linkimage_title']; ?>" type="text" class="regular-text" /></td> 62 63 </tr> 63 64 … … 67 68 68 69 <tr> 69 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext4" value="3" <?php checked( $cryptX _var['opt_linktext'], 3 ); ?>/></td>70 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext4" value="3" <?php checked( $cryptXOptions['opt_linktext'], 3 ); ?>/></td> 70 71 <th><label for="upload_image_button"><?php _e("Select an uploaded image",'cryptx'); ?></label></th> 71 72 <td> … … 73 74 <input id="remove_image_button" type="button" class="button button-link-delete hidden" value="<?php _e( 'Delete image' ); ?>" /> 74 75 <span id="opt_linktext4_notice"><?php _e("You have to upload an image first before this option can be activated.",'cryptx'); ?></span> 75 <input type='hidden' name='cryptX_var[alt_uploadedimage]' id='image_attachment_id' value='<?php echo $cryptX _var['alt_uploadedimage']; ?>'>76 <input type='hidden' name='cryptX_var[alt_uploadedimage]' id='image_attachment_id' value='<?php echo $cryptXOptions['alt_uploadedimage']; ?>'> 76 77 <div> 77 <img id='image-preview' src='<?php echo wp_get_attachment_url( $cryptX _var['alt_uploadedimage'] ); ?>'>78 <img id='image-preview' src='<?php echo wp_get_attachment_url( $cryptXOptions['alt_uploadedimage'] ); ?>'> 78 79 </div> 79 80 </td> … … 82 83 <td> </td> 83 84 <th><label for="cryptX_var[alt_linkimage_title]"><?php _e("Title-Tag for the Image",'cryptx'); ?></label></th> 84 <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptX _var['alt_linkimage_title']; ?>" type="text" class="regular-text" /></td>85 <td><input name="cryptX_var[alt_linkimage_title]" value="<?php echo $cryptXOptions['alt_linkimage_title']; ?>" type="text" class="regular-text" /></td> 85 86 </tr> 86 87 … … 90 91 91 92 <tr> 92 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext4" value="4" <?php checked( $cryptX _var['opt_linktext'], 4 ); ?> /></td>93 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext4" value="4" <?php checked( $cryptXOptions['opt_linktext'], 4 ); ?> /></td> 93 94 <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> 94 95 </tr> … … 99 100 100 101 <tr> 101 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext5" value="5" <?php checked( $cryptX _var['opt_linktext'], 5 ); ?> /></td>102 <td scope="row"><input type="radio" name="cryptX_var[opt_linktext]" id="opt_linktext5" value="5" <?php checked( $cryptXOptions['opt_linktext'], 5 ); ?> /></td> 102 103 <th><?php _e("Convert Email to PNG-image",'cryptx'); ?></th> 103 <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("CryptX@". rw_cryptx_getDomain()); ?>" align="absmiddle" alt="<?php echo antispambot("CryptX@".rw_cryptx_getDomain()); ?>" title="<?php echo antispambot("CryptX@".rw_cryptx_getDomain()); ?>"></td>104 <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("CryptX@".$CryptX_instance->getDomain()); ?>" align="absmiddle" alt="<?php echo antispambot("CryptX@".$CryptX_instance->getDomain()); ?>" title="<?php echo antispambot("CryptX@".$CryptX_instance->getDomain()); ?>"></td> 104 105 </tr> 105 106 <tr> … … 108 109 <td><select name="cryptX_var[c2i_font]"> 109 110 <?php 110 foreach( rw_cryptx_listDir(CRYPTX_DIR_PATH.'fonts', "ttf") as $font) {111 foreach($CryptX_instance->getFilesInDirectory( CRYPTX_DIR_PATH . 'fonts', "ttf") as $font) { 111 112 printf('<option value="%1$s" %3$s>%2$s</option>', 112 113 $font, 113 114 str_replace(".ttf", "", $font), 114 ($cryptX _var['c2i_font'] == $font)? "selected" : ""115 ($cryptXOptions['c2i_font'] == $font)? "selected" : "" 115 116 ); 116 117 } … … 121 122 <td> </td> 122 123 <th><label for="cryptX_var[c2i_fontSize]"><?php _e("Font size (pixel)",'cryptx'); ?></label></th> 123 <td><input name="cryptX_var[c2i_fontSize]" value="<?php echo $cryptX _var['c2i_fontSize']; ?>" type="number" class="regular-text" /></td>124 <td><input name="cryptX_var[c2i_fontSize]" value="<?php echo $cryptXOptions['c2i_fontSize']; ?>" type="number" class="regular-text" /></td> 124 125 </tr> 125 126 <tr> 126 127 <td> </td> 127 128 <th><label for="cryptX_var[c2i_fontRGB]"><?php _e("Font color (RGB)",'cryptx'); ?></label></th> 128 <td><input name="cryptX_var[c2i_fontRGB]" value="<?php echo $cryptX _var['c2i_fontRGB']; ?>" type="text" class="color-field regular-text" /></td>129 <td><input name="cryptX_var[c2i_fontRGB]" value="<?php echo $cryptXOptions['c2i_fontRGB']; ?>" type="text" class="color-field regular-text" /></td> 129 130 </tr> 130 131 </tbody> -
cryptx/tags/3.4/js/cryptx.js
r1111020 r3102339 1 function DeCryptString( s ) 2 { 3 var n = 0; 4 var r = "mailto:"; 5 var z = 0; 6 for( var i = 0; i < s.length/2; i++) 7 { 8 z = s.substr(i*2, 1); 9 n = s.charCodeAt( i*2+1 ); 10 if( n >= 8364 ) 11 { 12 n = 128; 13 } 14 r += String.fromCharCode( n - z ); 1 const UPPER_LIMIT = 8364; 2 const DEFAULT_VALUE = 128; 3 4 /** 5 * Decrypts an encrypted string using a specific encryption algorithm. 6 * 7 * @param {string} encryptedString - The encrypted string to be decrypted. 8 * @returns {string} The decrypted string. 9 */ 10 function DeCryptString(encryptedString) { 11 let charCode = 0; 12 let decryptedString = "mailto:"; 13 let encryptionKey = 0; 14 15 for (let i = 0; i < encryptedString.length; i += 2) { 16 encryptionKey = encryptedString.substr(i, 1); 17 charCode = encryptedString.charCodeAt(i + 1); 18 19 if (charCode >= UPPER_LIMIT) { 20 charCode = DEFAULT_VALUE; 21 } 22 23 decryptedString += String.fromCharCode(charCode - encryptionKey); 15 24 } 16 return r; 25 26 return decryptedString; 17 27 } 18 28 19 function DeCryptX( s ) 29 /** 30 * Redirects the current page to the decrypted URL. 31 * 32 * @param {string} encryptedUrl - The encrypted URL to be decrypted and redirected to. 33 * @return {void} 34 */ 35 function DeCryptX( encryptedUrl ) 20 36 { 21 location.href=DeCryptString( s);37 location.href=DeCryptString( encryptedUrl ); 22 38 } -
cryptx/tags/3.4/readme.txt
r2949844 r3102339 3 3 Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=4026696 4 4 Tags: encode, antispam, email, spam, spider, unicode, mailto, filter, spam bot, decrypt, encrypt, mail, javascript, post, page, widget, image, comment, excerpt, custom fields 5 Requires at least: 4.66 Tested up to: 6. 37 Stable tag: 3. 3.3.28 Requires PHP: 5.65 Requires at least: 6.0 6 Tested up to: 6.5.4 7 Stable tag: 3.4 8 Requires PHP: 8.2 9 9 License: GPLv2 or later 10 10 License URI: https://www.gnu.org/licenses/gpl-2.0.html … … 22 22 23 23 == Changelog == 24 = 3.4 = 25 * main code rewritten as class to prevent problems with WordPress or other plugin functions. 26 * added documentation blocks to class methods for better readability. 27 * renamed methods for better readability. 28 * fixed some bugs 24 29 = 3.3.3.2 = 25 30 * fixed the "Double Slashes in cryptx-asset-URL" issue
Note: See TracChangeset
for help on using the changeset viewer.