Plugin Directory

Changeset 2961271


Ignore:
Timestamp:
08/31/2023 03:41:03 PM (2 years ago)
Author:
coderevolution
Message:

Fixed reported XSS issues

Location:
wp-pocket-urls
Files:
27 added
5 edited

Legend:

Unmodified
Added
Removed
  • wp-pocket-urls/trunk/README.txt

    r2807068 r2961271  
    44Tags: : affiliate link, link shortener, short link, short url, hide affiliate link, link cloak, cloak links, affiliate links, pretty link, redirect link, forward link, shorturl, hoplink, shortlink, tinyurl, url shrinking, 301 redirect, 307 redirect, 302 redirect, affiliate link management, affiliate link manager, affiliate link redirect, affiliate links, link cloak, link cloaking, link redirect, manage affiliate links, click counting, visitor information, link masking, link cloacking, link cloacker, url cloacker
    55Requires at least: 4.0.0
    6 Tested up to: 6.1
     6Tested up to: 6.2
    77Stable tag: trunk
    88Requires PHP: 5.2.4
     
    9696= 1.0.0 =
    9797Initial release.
    98 = 1.0.1 =
    99 Fixed reported bugs.
  • wp-pocket-urls/trunk/assets/views/reports.php

    r2359978 r2961271  
    114114    <!--end gchart-->
    115115    <div class="total-clicks">
    116       <h4><?php echo esc_html__('Total:', 'wp_pocketurl');?> <?php echo $total_clicks; ?> <?php echo esc_html__('clicks', 'wp_pocketurl');?></h4>
     116      <h4><?php echo esc_html__('Total:', 'wp_pocketurl');?> <?php echo esc_html($total_clicks); ?> <?php echo esc_html__('clicks', 'wp_pocketurl');?></h4>
    117117    </div>
    118118    <div id="chart_container" style="width:800px;"></div>
  • wp-pocket-urls/trunk/classes/class-wp-pocketurl-admin.php

    r2361962 r2961271  
    213213    // change wp pocketurl link post slug if the option changed
    214214    public function wp_pocketurl_link_slug_change($new_value,$old_value ){
    215         if($new_value !== $old_value ){
     215        if($new_value !== $old_value )
     216        {
     217            $registered = FALSE;
    216218            //check if the old value is empty
    217219            if(empty($old_value)) $old_value = 'go';
     
    222224                // that replaces 'go' with 'option value' and give it a higher
    223225                // priority than the existing rule.
    224                 foreach($current_rules as $key => $val) {
    225                     if(strpos($key, $old_value ) !== false) {
    226                         add_rewrite_rule(str_ireplace($old_value, $new_value, $key), $val, 'top');
     226                if(is_array($current_rules))
     227                {
     228                    foreach($current_rules as $key => $val) {
     229                        if(strpos($key, $old_value ) !== false) {
     230                            $registered = TRUE;
     231                            add_rewrite_rule(str_ireplace($old_value, $new_value, $key), $val, 'top');
     232                        }
    227233                    }
    228234                }
    229235            }
    230             flush_rewrite_rules();
     236            if($registered)
     237            {
     238                flush_rewrite_rules();
     239            }
    231240        }
    232241        return $new_value;
  • wp-pocket-urls/trunk/classes/class-wp-pocketurl-reports.php

    r2359978 r2961271  
    2020    foreach ($links as $key => $link) {
    2121      $lselected = ($clink == $link->ID) ? 'selected' :'';
    22       $output[] ="<option value='{$link->ID}' {$lselected}>{$link->post_title}</option>";
     22      $output[] ="<option value='" . esc_attr($link->ID) . "' " . esc_attr($lselected) . ">" . esc_attr($link->post_title) . "</option>";
    2323    }
    2424    $output[]='</select></label>';
     
    3030    foreach ($months as $key => $month) {
    3131      $mselected = ($cmonth == $month) ? 'selected' :'';
    32       $output[] = '<option value="'.$month.'" '.$mselected.'>'.$month.'</option>';
     32      $output[] = '<option value="'.esc_attr($month).'" '.esc_attr($mselected).'>'.esc_attr($month).'</option>';
    3333    }
    3434    $output[]='</select></label>';
     
    4141    foreach ($terms as $key => $term) {
    4242      $cselected = ($cat == $term->term_id) ? 'selected' :'';
    43       $output[] = '<option value="'.$term->term_id.'" '.$cselected.'>'.$term->name.'</option>';
     43      $output[] = '<option value="'.esc_attr($term->term_id).'" '.esc_attr($cselected).'>'.esc_attr($term->name).'</option>';
    4444    }
    4545    $output[]='</select></label>';
     
    5252    foreach ($countries as $key => $country) {
    5353      $coselected = ($ccountry == $country->code) ? 'selected' :'';
    54       $output[] = '<option value="'.$country->code.'" '.$coselected.'>'.$country->name.'</option>';
     54      $output[] = '<option value="'.esc_attr($country->code).'" '.esc_attr($coselected).'>'.esc_attr($country->name).'</option>';
    5555    }
    5656    $output[]='</select></label>';
    5757    $output[]='<input type="submit" class="button button-primary" value="'.__('Update').'" />';
    5858   
    59     echo implode($output);
     59    echo implode('',$output);
    6060  }
    6161  /*
     
    151151  * get clicks count grouped by date
    152152  */
    153   public function wp_pocketurl_get_clicks_report($cmonth=null, $cat=null, $country=null,$link ){
     153  public function wp_pocketurl_get_clicks_report($cmonth=null, $cat=null, $country=null,$link=null ){
    154154    global $wpdb;$and=0;
    155155    $sql = "SELECT count(1) as clicks, DATE(click_date) as date  FROM {$wpdb->wp_pocketurl_clicks_table}";
  • wp-pocket-urls/trunk/wp-pocketurl.php

    r2393200 r2961271  
    44Plugin URI: https://www.coderevolution.ro/wp-pocketurl
    55Description: WP Pocket URLs gives you the ability to shorten your affiliate links and keep track of clicks for each link.
    6 Version: 1.0.1
     6Version: 1.0.2
    77Author: CodeRevolution
    88Author URI: https://www.coderevolution.ro
     
    7878function wp_poketurl_isExternal($href, $base)
    7979{
     80    if(empty($href) || empty($base))
     81    {
     82        return 1;
     83    }
    8084    $components = parse_url($href);
    8185    $comp_base = parse_url($base);
    8286    if(!isset($components['host']) || !isset($comp_base['host']))
    8387    {
     88        if(stristr($href, $base) !== false)
     89        {
     90            return 0;
     91        }
    8492        return 1;
    8593    }
     
    151159        ini_set('max_execution_time', $timeout);
    152160        ini_set('ignore_user_abort', 1);
    153         ignore_user_abort(true);
    154         set_time_limit($timeout);
     161        if(function_exists('ignore_user_abort'))
     162{
     163    ignore_user_abort(true);
     164}
     165        if(function_exists('set_time_limit'))
     166{
     167    set_time_limit($timeout);
     168}
    155169       
    156170        $content = $post->post_content;
     
    200214                $url_str = str_replace(array('/', '-', '_', ':'), ' ', $url_str);
    201215                $keyword_class = new WP_poketurl_keywords();
    202                 if ( ! function_exists( 'get_page_by_title' ) )
    203                 {
    204                     include_once( ABSPATH . 'wp-includes/post.php' );
    205                 }
    206216                $query_words = $keyword_class->keywords($url_str, 1);
    207217                $feed_id = sanitize_title($query_words);
    208                 if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     218                if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    209219                {
    210220                    $query_words = $keyword_class->keywords($url_str, 2);
    211221                    $feed_id = sanitize_title($query_words);
    212                     if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     222                    if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    213223                    {
    214224                        $query_words = $keyword_class->keywords($url_str, 3);
    215225                        $feed_id = sanitize_title($query_words);
    216                         if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     226                        if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    217227                        {
    218228                            $query_words = $keyword_class->keywords($url_str, 4);
    219229                            $feed_id = sanitize_title($query_words);
    220                             if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     230                            if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    221231                            {
    222232                                $query_words = $keyword_class->keywords($url_str, 5);
    223233                                $feed_id = sanitize_title($query_words);
    224                                 if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     234                                if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    225235                                {
    226236                                    $query_words = $keyword_class->keywords($url_str, 6);
    227237                                    $feed_id = sanitize_title($query_words);
    228                                     if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     238                                    if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    229239                                    {
    230240                                        $query_words = $keyword_class->keywords($url_str, 7);
    231241                                        $feed_id = sanitize_title($query_words);
    232                                         if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     242                                        if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    233243                                        {
    234244                                            $query_words = $keyword_class->keywords($url_str, 8);
    235245                                            $feed_id = sanitize_title($query_words);
    236                                             if (get_page_by_title($feed_id, OBJECT, 'wp_pocketurl_link') !== NULL)
     246                                            if (wp_pocketurl_get_page_by_title(html_entity_decode($feed_id), OBJECT, 'wp_pocketurl_link') !== NULL)
    237247                                            {
    238248                                                $feed_id .= '-' . uniqid();
     
    250260                $post_id = wp_insert_post($my_post, true);
    251261                if (!is_wp_error($post_id)) {
    252                     $cusOption = '0';
    253                     $linkRedirection = get_option('wp_pocketurl_link_redirection', '301');
    254                     update_post_meta($post_id,'wp_pocketurl_link', $href);
    255                     update_post_meta($post_id,'wp_pocketurl_link_custom_options', $cusOption);
    256                     update_post_meta($post_id,'wp_pocketurl_link_redirection', $linkRedirection);
    257                     $new_link = get_permalink($post_id);
    258                     $content = str_replace($href, $new_link, $content);
    259                     $need_update = true;
     262                    if($post_id === 0)
     263                    {
     264                        wp_pocketurl_log_to_file('Error occurred while inserting new redirect rule!');
     265                    }
     266                    else
     267                    {
     268                        $cusOption = '0';
     269                        $linkRedirection = get_option('wp_pocketurl_link_redirection', '301');
     270                        update_post_meta($post_id,'wp_pocketurl_link', $href);
     271                        update_post_meta($post_id,'wp_pocketurl_link_custom_options', $cusOption);
     272                        update_post_meta($post_id,'wp_pocketurl_link_redirection', $linkRedirection);
     273                        $new_link = get_permalink($post_id);
     274                        $content = str_replace($href, $new_link, $content);
     275                        $need_update = true;
     276                    }
    260277                }
    261278                else
     
    274291            $args['ID'] = $post->ID;
    275292            $args['post_content'] = $content;
     293            remove_filter('content_save_pre', 'wp_filter_post_kses');
     294            remove_filter('content_filtered_save_pre', 'wp_filter_post_kses');
     295            remove_filter('title_save_pre', 'wp_filter_kses');
    276296            $post_updated = wp_update_post($args);
     297            add_filter('content_save_pre', 'wp_filter_post_kses');
     298            add_filter('content_filtered_save_pre', 'wp_filter_post_kses');
     299            add_filter('title_save_pre', 'wp_filter_kses');
    277300            if (is_wp_error($post_updated)) {
    278301                $errors = $post_updated->get_error_messages();
     
    284307    }
    285308}
     309function wp_pocketurl_get_page_by_title($title, $ret_type, $post_type)
     310{
     311    $xposts = get_posts(
     312        array(
     313            'post_type'              => $post_type,
     314            'title'                  => $title,
     315            'post_status'            => 'all',
     316            'numberposts'            => 1,
     317            'update_post_term_cache' => false,
     318            'update_post_meta_cache' => false,           
     319            'orderby'                => 'post_date ID',
     320            'order'                  => 'ASC',
     321        )
     322    );
     323    if ( ! empty( $xposts ) ) {
     324        $zap = $xposts[0];
     325    } else {
     326        $zap = null;
     327    }
     328    return $zap;
     329}
    286330function wp_pocketurl_log_to_file($str)
    287331{
Note: See TracChangeset for help on using the changeset viewer.