Plugin Directory

Changeset 2991088


Ignore:
Timestamp:
11/07/2023 05:57:05 PM (2 years ago)
Author:
datafeedr.com
Message:

Update to version 1.2.0 from GitHub

Location:
ads-by-datafeedrcom
Files:
2 added
2 deleted
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • ads-by-datafeedrcom/assets/screenshot-1.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/assets/screenshot-2.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/assets/screenshot-3.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/assets/screenshot-4.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/assets/screenshot-5.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/assets/screenshot-6.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/assets/screenshot-7.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/assets/screenshot-8.jpg

    • Property svn:mime-type changed from application/octet-stream to image/jpeg
  • ads-by-datafeedrcom/tags/1.2.0/dfads.php

    r2489876 r2991088  
    44Plugin URI: https://www.datafeedr.com/
    55Description: Randomly display any type of advertisement anywhere on your site.  Add rotating banner ads, Google Adsense, videos, text links and more to your sidebar, widget areas, posts and pages.
    6 Version: 1.1.3
    7 Tested up to: 5.7
     6Version: 1.2.0
     7Tested up to: 6.3.3-alpha
    88Author: datafeedr.com
    99Author URI: https://www.datafeedr.com/
    1010
    11 Copyright 2021 Ads by datafeedr.com
     11Copyright 2023 Ads by datafeedr.com
    1212
    1313This program is free software; you can redistribute it and/or modify
     
    3030define( 'DFADS_CONTEXT', 'dfads' );
    3131define( 'DFADS_DOCS_URL', 'http://www.datafeedr.com/dfads/' );
    32 define( 'DFADS_VERSION', '1.1.3' );
     32define( 'DFADS_VERSION', '1.2.0' );
    3333
    3434/**
    3535 * Require necessary files.
    3636 */
     37require_once( DFADS_PLUGIN_PATH . 'inc/functions.php' );
    3738require_once( DFADS_PLUGIN_PATH . 'inc/cpt.class.php' );
    3839require_once( DFADS_PLUGIN_PATH . 'inc/dfads.class.php' );
     
    6667 */
    6768function dfads_ajax_load_ads(){
    68     echo dfads( $_REQUEST );
     69
     70    $request = $_REQUEST;
     71
     72    $user_signature = trim( $request['signature'] ?? '' );
     73
     74    if ( empty( $user_signature ) ) {
     75        die( 'Missing signature' );
     76    }
     77
     78    unset( $request['signature'] );
     79
     80    $allowed_params = array_keys( DFADS::get_default_params() );
     81
     82    foreach ( $request as $k => $v ) {
     83
     84        // These are added here: DFADS::get_javascript();
     85        if ( in_array( $k, [ '_block_id', 'action' ] ) ) {
     86            continue;
     87        }
     88
     89        // Remove any other keys provided that aren't allowed.
     90        if ( ! in_array( $k, $allowed_params, true ) ) {
     91            unset( $request[ $k ] );
     92        }
     93    }
     94
     95    $known_signature = dfads_hash_hmac( serialize( $request ) );
     96
     97    if ( ! hash_equals( $known_signature, $user_signature ) ) {
     98        die( 'Invalid signature' );
     99    }
     100
     101    echo dfads( $request );
    69102    die;
    70103}
     104
    71105add_action('wp_ajax_nopriv_dfads_ajax_load_ads', 'dfads_ajax_load_ads');
    72106add_action('wp_ajax_dfads_ajax_load_ads', 'dfads_ajax_load_ads');
  • ads-by-datafeedrcom/tags/1.2.0/inc/dfads.class.php

    r2003040 r2991088  
    3030        $this->update_impression_count( $ads );
    3131       
    32         // Return user's own callback function.
    33         if ( function_exists( $this->args['callback_function'] ) ) {
     32        // Return user's own callback function if exists and is allowed.
     33        if ( function_exists( $this->args['callback_function'] ) && in_array( $this->args['callback_function'], dfads_allowed_callback_functions(), true ) ) {
    3434            return call_user_func_array($this->args['callback_function'], array( $ads, $this->args ));
    3535        }
     
    6565        }
    6666
    67         $defaults = array (
    68             'groups'            => '-1',
    69             'limit'             => '-1',
    70             'orderby'           => 'random',
    71             'order'             => 'ASC',
    72             'container_id'      => '',
    73             'container_html'    => 'div',
    74             'container_class'   => '',
    75             'ad_html'           => 'div',
    76             'ad_class'          => '',
    77             'callback_function' => '',
    78             'return_javascript' => '',
    79         );
     67        $defaults = $this->get_default_params();
    8068               
    8169        $this->args = wp_parse_args( $new_args, $defaults );
     
    277265        $args['_block_id'] = $id;
    278266        $args['container_html'] = 'none'; // Set to 'none' so we don't display the container HTML twice.
     267        $args['action']            = 'dfads_ajax_load_ads';
     268
     269        // Sign the request.
     270        $signature         = dfads_hash_hmac( serialize( $args ) );
     271        $args['signature'] = $signature;
    279272       
    280273        return '
     
    282275        <script>
    283276        (function($) {
    284             $("#'.$id .'").load("'.admin_url( 'admin-ajax.php?action=dfads_ajax_load_ads&'.http_build_query( $args ) ).'" );           
     277            $("#' . $id . '").load("' . admin_url( 'admin-ajax.php?' . http_build_query( $args ) ) . '" );         
    285278        })( jQuery );
    286279        </script>
    287280        <noscript>'.dfads( http_build_query( $args )  ).'</noscript>
    288281        ';
    289        
    290282    }
    291283   
     
    361353        return $randomString;
    362354    }
     355
     356    public static function get_default_params() {
     357        return array(
     358            'groups'            => '-1',
     359            'limit'             => '-1',
     360            'orderby'           => 'random',
     361            'order'             => 'ASC',
     362            'container_id'      => '',
     363            'container_html'    => 'div',
     364            'container_class'   => '',
     365            'ad_html'           => 'div',
     366            'ad_class'          => '',
     367            'callback_function' => '',
     368            'return_javascript' => '',
     369        );
     370    }
    363371}
  • ads-by-datafeedrcom/tags/1.2.0/readme.txt

    r2489876 r2991088  
    44Tags: ads, random ads, rotating ads, datafeedr, advertisements, advertising, banner ads, banners, adsense, google adsense
    55Requires at least: 3.5
    6 Tested up to: 5.7
    7 Stable tag: 1.1.3
     6Tested up to: 6.3.3-alpha
     7Stable tag: 1.2.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1616
    1717You have full control over how many ads get displayed as well as their sort order.
     18
     19**Important**
     20
     21As of version 1.2.0, all custom callback functions (ie. `callback_function`) need to be returned by the `dfads_allowed_callback_functions()` function. To do this, add your allowed custom callback functions like this:
     22
     23```
     24add_filter( 'dfads_allowed_callback_functions', function ( array $functions ) {
     25    $functions[] = 'my_first_custom_callback_function';
     26    $functions[] = 'my_second_custom_callback_function';
     27
     28    return $functions;
     29} );
     30```
    1831
    1932[youtube http://www.youtube.com/watch?v=tPL8ND0nh4o]
     
    100113== Changelog ==
    101114
     115= 1.2.0 - 2023/11/07 =
     116* Added signed requests for ad blocks rendered via Javascript.
     117
    102118= 1.1.3 - 2020/03/08 =
    103119* Updated jQuery for upgrade.
  • ads-by-datafeedrcom/trunk/dfads.php

    r2489876 r2991088  
    44Plugin URI: https://www.datafeedr.com/
    55Description: Randomly display any type of advertisement anywhere on your site.  Add rotating banner ads, Google Adsense, videos, text links and more to your sidebar, widget areas, posts and pages.
    6 Version: 1.1.3
    7 Tested up to: 5.7
     6Version: 1.2.0
     7Tested up to: 6.3.3-alpha
    88Author: datafeedr.com
    99Author URI: https://www.datafeedr.com/
    1010
    11 Copyright 2021 Ads by datafeedr.com
     11Copyright 2023 Ads by datafeedr.com
    1212
    1313This program is free software; you can redistribute it and/or modify
     
    3030define( 'DFADS_CONTEXT', 'dfads' );
    3131define( 'DFADS_DOCS_URL', 'http://www.datafeedr.com/dfads/' );
    32 define( 'DFADS_VERSION', '1.1.3' );
     32define( 'DFADS_VERSION', '1.2.0' );
    3333
    3434/**
    3535 * Require necessary files.
    3636 */
     37require_once( DFADS_PLUGIN_PATH . 'inc/functions.php' );
    3738require_once( DFADS_PLUGIN_PATH . 'inc/cpt.class.php' );
    3839require_once( DFADS_PLUGIN_PATH . 'inc/dfads.class.php' );
     
    6667 */
    6768function dfads_ajax_load_ads(){
    68     echo dfads( $_REQUEST );
     69
     70    $request = $_REQUEST;
     71
     72    $user_signature = trim( $request['signature'] ?? '' );
     73
     74    if ( empty( $user_signature ) ) {
     75        die( 'Missing signature' );
     76    }
     77
     78    unset( $request['signature'] );
     79
     80    $allowed_params = array_keys( DFADS::get_default_params() );
     81
     82    foreach ( $request as $k => $v ) {
     83
     84        // These are added here: DFADS::get_javascript();
     85        if ( in_array( $k, [ '_block_id', 'action' ] ) ) {
     86            continue;
     87        }
     88
     89        // Remove any other keys provided that aren't allowed.
     90        if ( ! in_array( $k, $allowed_params, true ) ) {
     91            unset( $request[ $k ] );
     92        }
     93    }
     94
     95    $known_signature = dfads_hash_hmac( serialize( $request ) );
     96
     97    if ( ! hash_equals( $known_signature, $user_signature ) ) {
     98        die( 'Invalid signature' );
     99    }
     100
     101    echo dfads( $request );
    69102    die;
    70103}
     104
    71105add_action('wp_ajax_nopriv_dfads_ajax_load_ads', 'dfads_ajax_load_ads');
    72106add_action('wp_ajax_dfads_ajax_load_ads', 'dfads_ajax_load_ads');
  • ads-by-datafeedrcom/trunk/inc/dfads.class.php

    r2003040 r2991088  
    3030        $this->update_impression_count( $ads );
    3131       
    32         // Return user's own callback function.
    33         if ( function_exists( $this->args['callback_function'] ) ) {
     32        // Return user's own callback function if exists and is allowed.
     33        if ( function_exists( $this->args['callback_function'] ) && in_array( $this->args['callback_function'], dfads_allowed_callback_functions(), true ) ) {
    3434            return call_user_func_array($this->args['callback_function'], array( $ads, $this->args ));
    3535        }
     
    6565        }
    6666
    67         $defaults = array (
    68             'groups'            => '-1',
    69             'limit'             => '-1',
    70             'orderby'           => 'random',
    71             'order'             => 'ASC',
    72             'container_id'      => '',
    73             'container_html'    => 'div',
    74             'container_class'   => '',
    75             'ad_html'           => 'div',
    76             'ad_class'          => '',
    77             'callback_function' => '',
    78             'return_javascript' => '',
    79         );
     67        $defaults = $this->get_default_params();
    8068               
    8169        $this->args = wp_parse_args( $new_args, $defaults );
     
    277265        $args['_block_id'] = $id;
    278266        $args['container_html'] = 'none'; // Set to 'none' so we don't display the container HTML twice.
     267        $args['action']            = 'dfads_ajax_load_ads';
     268
     269        // Sign the request.
     270        $signature         = dfads_hash_hmac( serialize( $args ) );
     271        $args['signature'] = $signature;
    279272       
    280273        return '
     
    282275        <script>
    283276        (function($) {
    284             $("#'.$id .'").load("'.admin_url( 'admin-ajax.php?action=dfads_ajax_load_ads&'.http_build_query( $args ) ).'" );           
     277            $("#' . $id . '").load("' . admin_url( 'admin-ajax.php?' . http_build_query( $args ) ) . '" );         
    285278        })( jQuery );
    286279        </script>
    287280        <noscript>'.dfads( http_build_query( $args )  ).'</noscript>
    288281        ';
    289        
    290282    }
    291283   
     
    361353        return $randomString;
    362354    }
     355
     356    public static function get_default_params() {
     357        return array(
     358            'groups'            => '-1',
     359            'limit'             => '-1',
     360            'orderby'           => 'random',
     361            'order'             => 'ASC',
     362            'container_id'      => '',
     363            'container_html'    => 'div',
     364            'container_class'   => '',
     365            'ad_html'           => 'div',
     366            'ad_class'          => '',
     367            'callback_function' => '',
     368            'return_javascript' => '',
     369        );
     370    }
    363371}
  • ads-by-datafeedrcom/trunk/readme.txt

    r2489876 r2991088  
    44Tags: ads, random ads, rotating ads, datafeedr, advertisements, advertising, banner ads, banners, adsense, google adsense
    55Requires at least: 3.5
    6 Tested up to: 5.7
    7 Stable tag: 1.1.3
     6Tested up to: 6.3.3-alpha
     7Stable tag: 1.2.0
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    1616
    1717You have full control over how many ads get displayed as well as their sort order.
     18
     19**Important**
     20
     21As of version 1.2.0, all custom callback functions (ie. `callback_function`) need to be returned by the `dfads_allowed_callback_functions()` function. To do this, add your allowed custom callback functions like this:
     22
     23```
     24add_filter( 'dfads_allowed_callback_functions', function ( array $functions ) {
     25    $functions[] = 'my_first_custom_callback_function';
     26    $functions[] = 'my_second_custom_callback_function';
     27
     28    return $functions;
     29} );
     30```
    1831
    1932[youtube http://www.youtube.com/watch?v=tPL8ND0nh4o]
     
    100113== Changelog ==
    101114
     115= 1.2.0 - 2023/11/07 =
     116* Added signed requests for ad blocks rendered via Javascript.
     117
    102118= 1.1.3 - 2020/03/08 =
    103119* Updated jQuery for upgrade.
Note: See TracChangeset for help on using the changeset viewer.