Plugin Directory

Changeset 879752


Ignore:
Timestamp:
03/21/2014 09:11:17 PM (12 years ago)
Author:
BrianLayman
Message:

Updated to current version of WordPress
Resolved issues with quotes and apostrophes in the original field
Removed the excessive use of prepare()

Location:
word-filter-plus
Files:
22 added
4 edited

Legend:

Unmodified
Added
Removed
  • word-filter-plus/trunk/csv-manip.php

    r512224 r879752  
    55 * @package word-filter-plus
    66 *
    7  * Copyright 2012 - eHermits, Inc. LTD - GNU 2
     7 * Copyright 2014 - eHermits, Inc. LTD
    88 *
    99 */
     
    2222            // If there is a separator ( ; ) or a quote ( " ) or a linebreak in the string, we need to quote it.
    2323            $needQuote = FALSE;
     24           
     25            // This do while executes only once even though it is while false
     26            // This is a TODO that needs to be looked at
    2427            do {
    2528                if ( strpos( $val, '"' ) !== FALSE ) {
  • word-filter-plus/trunk/readme.txt

    r512483 r879752  
    44Tags: replace, filter, risky, language, post, comment, page, censor, bbcode, moderate, clean
    55Requires at least: 2.9
    6 Tested up to: 3.3
    7 Stable tag: 1.0.1
     6Tested up to: 3.8.1
     7Stable tag: 2.0
    88
    99Update or clean the contents of your site, by filtering or replacing words and phrases in your posts, pages, excerpts, titles and comments.
     
    7575== Changelog ==
    7676
     77= 1.0 =
     78* First release
     79
    7780= 1.0.1 =
    7881* Redefined a static method that was causing problems on activation
    7982
    80 = 1.0 =
    81 * First release
     83= 2.0 =
     84* Fixed the repeated addition of slashes during save.  This may make this version incompatible with earlier releases. Contact the me if you have issues upgrading and I will resolve this.
     85* Fixed excessive use if prepare statements
    8286
    8387== Upgrade Notice ==
  • word-filter-plus/trunk/wfp-settings.php

    r512224 r879752  
    55 * @package word-filter-plus
    66 *
    7  * Copyright 2012 - eHermits, Inc. LTD - GNU 2
     7 * Copyright 2014 - eHermits, Inc. LTD
    88 *
    99 */
     
    182182            }
    183183            $id             = $_POST['id'];
    184             $original       = $_POST['original']; //do not stripslashes_deep, base_64 encode then. ( ver 0.2 )
    185             $replacer   = stripslashes_deep( $_POST['replacer'] );
     184            $original       = stripslashes_deep( $_POST['original'] );
     185            $replacer       = stripslashes_deep( $_POST['replacer'] );
    186186            $in_posts       = $_POST['in_posts'];
    187187            $in_comments    = $_POST['in_comments'];
     
    210210                            VALUES ( %s, %s, %s, %s, %s, %s, %s, %s, %s )",
    211211                            array(
    212                                 $wpdb->escape( base64_encode( trim( $original[ $i ] ) ) ),
    213                                 $wpdb->escape( trim( $replacer[ $i ] ) ),
     212                                $wpdb->escape( $original[ $i ] ),
     213                                $wpdb->escape( $replacer[ $i ] ),
    214214                                $wpdb->escape( $in_posts[ $i ] ),
    215215                                $wpdb->escape( $in_comments[ $i ] ),
     
    225225                    } elseif ( !empty( $original[ $i ] ) && !empty( $id[ $i ] ) ) {
    226226                        $wpdb->update( $this->parent->plugin_table_name,
    227                             array( 'original'   => $wpdb->escape( base64_encode( trim( $original[ $i ] ) ) ),
    228                                 'replacement'       => $wpdb->escape( trim( $replacer[ $i ] ) ),
     227                            array( 'original'       => $wpdb->escape( $original[ $i ] ),
     228                                'replacement'       => $wpdb->escape( $replacer[ $i ] ),
    229229                                'in_posts'          => $wpdb->escape( $in_posts[ $i ] ),
    230230                                'in_comments'       => $wpdb->escape( $in_comments[ $i ] ),
     
    486486</style>
    487487<div id="tcc-donate-donate">
    488 <p><img src="http://www.gravatar.com/avatar/1f7624ae2dd3d0ed7a9e423017313c9e?s=64" height="64" width="64" /><?php esc_html_e( 'Hi there! If you enjoy this plugin, consider showing your appreciation by making a small donation to its author!', 'tcc-donate' ); ?></p>
     488<p><img src="http://www.gravatar.com/avatar/1f7624ae2dd3d0ed7a9e423017313c9e?s=64" height="64px" width="64px" /><?php esc_html_e( 'Hi there! If you enjoy this plugin, consider showing your appreciation by making a small donation to its author!', 'tcc-donate' ); ?></p>
    489489<p style="text-align: center"><a href="http://thecodecave.com/donate" target="_new"><?php esc_html_e( 'Click here to donate using PayPal' ); ?></a></p>
    490490</div>
     
    519519            <form method="post" action="<?php echo $this->curLink;?>">
    520520            <?php wp_nonce_field( 'wfp_settings_plus_nonce_action', 'wfp_settings_plus_nonce' ); ?>
    521             <table class="widefat fixed" width="650" align="center" width="100%" id="word-replacer-list">
     521            <table class="widefat fixed" width="650px" align="center" width="100%" id="word-replacer-list">
    522522                <thead>
    523523                    <tr>
    524                         <th width="40">Delete</th>
    525                         <th>Original</th><th width="5">&nbsp;</th><th>Replacement</th>
    526                         <th class="replacer_expandable" width="40">Posts</th>
    527                         <th class="replacer_expandable" width="70">Comments</th>
    528                         <th class="replacer_expandable" width="40">Pages</th>
    529                         <th class="replacer_expandable" width="40">Titles</th>
    530                         <th class="replacer_expandable" width="80">Case Insensitive</th>
    531                         <th class="replacer_expandable" width="80">Partial Match</th>
    532                         <th class="replacer_expandable" width="40">Regex</th>
    533                         <th class="replacer_expandall" width="20"><a style="color:black" href="#" title="Expand/Collapse">&laquo;&raquo;</a></th>
     524                        <th width="45px">Delete</th>
     525                        <th>Original</th>
     526                        <th width="5">&nbsp;</th>
     527                        <th>Replacement</th>
     528                        <th class="replacer_expandable" width="40px">Posts</th>
     529                        <th class="replacer_expandable" width="75px">Comments</th>
     530                        <th class="replacer_expandable" width="40px">Pages</th>
     531                        <th class="replacer_expandable" width="40px">Titles</th>
     532                        <th class="replacer_expandable" width="80px">Case Insensitive</th>
     533                        <th class="replacer_expandable" width="80px">Partial Match</th>
     534                        <th class="replacer_expandable" width="40px">Regex</th>
     535                        <th class="replacer_expandable" width="20px"><a style="color:black" href="#" title="Expand/Collapse">&laquo;&raquo;</a></th>
    534536                    </tr>
    535537                </thead>
     
    549551                            <input type="hidden" name="id[<?php echo intval( $i );?>]" value="<?php echo $aReplacement['id']; ?>" />
    550552                            <input type="hidden" name="count" value="" />
    551                             <input style="width:100%" type="text" name="original[<?php echo intval( $i );?>]" id="original_<?php echo intval( $i );?>" value="<?php echo htmlspecialchars( base64_decode( $aReplacement['original'], true )?base64_decode( $aReplacement['original'] ):$aReplacement['original'] ) ?>" /></td><td> &raquo; </td>
     553                            <input style="width:100%" type="text" name="original[<?php echo intval( $i );?>]" id="original_<?php echo intval( $i );?>" value="<?php echo $this->parent->_specialchar( $aReplacement['original'] ) ?>" /></td><td> &raquo; </td>
    552554                        <td>
    553555                            <textarea style="resize:vertical;width:100%" name="replacer[<?php echo intval( $i );?>]"><?php echo $this->parent->_specialchar( $aReplacement['replacement'] ); ?></textarea>
  • word-filter-plus/trunk/word-filter-plus.php

    r512407 r879752  
    44Plugin URI: http://wordpress.org/extend/plugins/word-filter-plus/
    55Description: Filter or replace words or phrases in posts, pages, excerpts, titles and/or comments.
    6 Author: Brian C. Layman
    7 Version: 1.0.1
    8 Author URI: http://TheCodeCave.com
     6Author: Brian Layman
     7Version: 2.0
     8Author URI: http://eHermitsInc.com
    99
    1010*/
    1111
    12 /*  Copyright 2012 eHermits, Inc.
    13 
    14     This plugin includes code & inspiration from many GNU projects including: 
     12/*  Copyright 2014 eHermits, Inc.
     13
     14    This plugin includes code & inspiration from many GPL projects including: 
    1515        The core replacement code was based upon the "Word Replacer" plugin by Takien.
    1616        The CVS Export includes some code from Otto's member export plugin.
     
    6767         * @var array The list of the current fields in the database
    6868         */
    69         var $field_names = array('original', 'replacement', 'in_posts', 'in_comments', 'in_pages', 'in_titles', 'case_insensitive', 'partial_match', 'use_regex' );
     69        var $field_names = array( 'original', 'replacement', 'in_posts', 'in_comments', 'in_pages', 'in_titles', 'case_insensitive', 'partial_match', 'use_regex' );
    7070
    7171        function word_filter_plus(){
     
    139139            if ( !$word_filter_plus_replacements = get_transient( 'word_filter_plus_replacements' ) ) {
    140140                /* It wasn't there, so regenerate the data and save the transient*/
    141                 $word_filter_plus_replacements = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM " . $this->plugin_table_name . " ORDER BY id" ), ARRAY_A ) ;
     141                $word_filter_plus_replacements = $wpdb->get_results( "SELECT * FROM " . $this->plugin_table_name . " ORDER BY id" , ARRAY_A ) ;
    142142                set_transient( 'word_filter_plus_replacements', $word_filter_plus_replacements );
    143143            }
     
    177177            require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
    178178             
    179             if( $wpdb->get_var( $wpdb->prepare( 'show tables like "' . $this->plugin_table_name . '"' ) ) !== $this->plugin_table_name ) {
     179            if( $wpdb->get_var( 'show tables like "' . $this->plugin_table_name . '"' ) !== $this->plugin_table_name ) {
    180180                dbDelta( $sql );
    181181                add_option( WFP_OPTION_VER, $this->plugin_version );
     
    198198            foreach( $this->replacement_list() as $aReplacement ) {
    199199                $i++;
    200                 $original       = base64_decode( $aReplacement['original'], true )?base64_decode( $aReplacement['original'] ):$aReplacement['original'];
     200                $original       = htmlspecialchars_decode( $this->_specialchar( $aReplacement['original'] ) );
    201201                $replacement    = htmlspecialchars_decode( $this->_specialchar( $aReplacement['replacement'] ) );
    202202                $in_posts       = $aReplacement['in_posts'];
     
    218218                $i++;
    219219                if ( $aReplacement['in_comments'] == 'yes' ) {         
    220                     $original = base64_decode( $aReplacement['original'], true )?base64_decode( $aReplacement['original'] ):$aReplacement['original'];
    221                     $replacement    = stripslashes( $aReplacement['replacement'] );
    222                     $case_insensitive   = $aReplacement['case_insensitive'];
    223                     $partial_match  = $aReplacement['partial_match'];
    224                     $use_regex      = $aReplacement['use_regex'];
     220                    $original       = stripslashes( $aReplacement[ 'original' ] );
     221                    $replacement    = stripslashes( $aReplacement[ 'replacement' ] );
     222                    $case_insensitive   = $aReplacement[ 'case_insensitive' ];
     223                    $partial_match  = $aReplacement[ 'partial_match' ];
     224                    $use_regex      = $aReplacement[ 'use_regex' ];
    225225
    226226                    $content = $this->do_replacement( $original, $replacement, $case_insensitive, $partial_match, $use_regex, $content );
     
    235235                $i++;
    236236                if( $aReplacement['in_titles']  == 'yes' ) {
    237                     $original       = base64_decode( $aReplacement['original'], true )?base64_decode( $aReplacement['original'] ):$aReplacement['original'];
    238                     $replacement    = stripslashes( $aReplacement['replacement'] );
    239                     $case_insensitive = $aReplacement['case_insensitive'];
    240                     $partial_match  = $aReplacement['partial_match'];
    241                     $use_regex      = $aReplacement['use_regex'];
     237                    $original       = stripslashes( $aReplacement[ 'original' ] );
     238                    $replacement    = stripslashes( $aReplacement[ 'replacement' ] );
     239                    $case_insensitive = $aReplacement[ 'case_insensitive' ];
     240                    $partial_match  = $aReplacement[ 'partial_match' ];
     241                    $use_regex      = $aReplacement[ 'use_regex' ];
    242242
    243243                    $content = $this->do_replacement( $original, $replacement, $case_insensitive, $partial_match, $use_regex, $content );
     
    275275                if ( get_transient( 'batch_running' ) ) {
    276276                    if ( WFP_DEBUG ) error_log("Adding cancel Record");
    277                     $wpdb->query( $wpdb->prepare( "insert into $wpdb->options (option_name, option_value, autoload) values ('wfp_cancel','1','no');" ) );
     277                    $wpdb->query( "insert into $wpdb->options (option_name, option_value, autoload) values ('wfp_cancel','1','no');" );
    278278                }
    279279                delete_transient( 'batch_running' );
     
    331331            while ( $row = mysql_fetch_assoc( $result ) ) {
    332332                set_time_limit( 30 ); // No one query can take more than 30 seconds, but the script can run for longer.
    333                 $sql = $wpdb->prepare( "SELECT COUNT(*) FROM $wpdb->options where option_name = 'wfp_cancel';" );
     333                $sql = "SELECT COUNT(*) FROM $wpdb->options where option_name = 'wfp_cancel';";
    334334                $cancelled = $wpdb->get_var( $sql );
    335335                if ( $cancelled > 0 ) {
     
    439439                if ( $cancelled > 0 ) {
    440440                    if ( WFP_DEBUG ) error_log( "Batch cancelled. Exiting: $cancelled || $sql" );
    441                     $wpdb->query( $wpdb->prepare( "delete FROM $wpdb->options where option_name = 'wfp_cancel';" ) );
     441                    $wpdb->query( "delete FROM $wpdb->options where option_name = 'wfp_cancel';" );
    442442                    wp_clear_scheduled_hook( WFP_COMMENT_EVENT );
    443443                    delete_option( WFP_OPTION_ITERATION );
Note: See TracChangeset for help on using the changeset viewer.