Plugin Directory

Changeset 2330673


Ignore:
Timestamp:
06/25/2020 01:16:58 PM (6 years ago)
Author:
mrbrazzi
Message:

1.0.1

  • Added required filters for AlinkTap plugin
  • Added some improvements
Location:
rest-client-tap/trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • rest-client-tap/trunk/README.txt

    r1810593 r2330673  
    44Tags: api rest, tipster, pick
    55Requires at least: 3.5
    6 Tested up to: 4.9.2
    7 Stable tag: 1.0.1
     6Tested up to: 5.4.2
     7Stable tag: 1.1
    88License: GPLv2 or later
    99License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    5454
    5555= 1.0.1 =
     56* Added required filters for AlinkTap plugin
     57* Added some improvements
     58
     59= 1.0.1 =
    5660* Added unique function names in main plugin file.
    5761
  • rest-client-tap/trunk/admin/class-rest-client-tap-admin.php

    r1810593 r2330673  
    113113       
    114114        $wp_customize->add_setting( 'tap_base_url', array(
    115             'default'           => 'http://todoapuestas.com',
     115            'default'           => 'https://todoapuestas.com',
    116116            'capability'        => 'edit_theme_options',
    117117            'sanitize_callback' => 'sanitize_text_field',
  • rest-client-tap/trunk/includes/class-rest-client-tap.php

    r1810593 r2330673  
    178178        $this->loader->add_filter( 'rest_client_tap_oauth_access_token', $plugin_public, 'get_oauth_access_token' );
    179179        $this->loader->add_filter( 'rest_client_tap_get_result_from_api', $plugin_public, 'get_result_from_api', 10, 3 );
    180        
     180
     181        $this->loader->add_filter('rest_client_tap_check_ip', $plugin_public, 'check_ip', 10, 2);
    181182        $this->loader->add_filter( 'rest_client_tap_request_block_bookies', $plugin_public, 'request_block_bookies' );
    182183    }
  • rest-client-tap/trunk/public/class-rest-client-tap-public.php

    r1810593 r2330673  
    172172    public function get_result_from_api($url, $assoc = true, $intention = 'Request result')
    173173    {
    174         $apiResponse = wp_remote_get($url);
     174        $apiResponse = wp_remote_get($url, array('timeout' => 30));
    175175        $apiResponseCode = wp_remote_retrieve_response_code($apiResponse);
    176176        $apiResponseBody = wp_remote_retrieve_body($apiResponse);
     
    186186            $error = sprintf( __( '[%s] Invalid response. %s', $this->plugin_name ), $intention, $error );
    187187            $_SESSION['REST_CLIENT_TAP_ERRORS'][] = $error;
    188             log_error($error);
     188//          log_error($error);
    189189            return null;
    190190        }
     
    251251    }
    252252   
    253     public function check_ip($ip)
    254     {
     253    public function check_ip($session_name, $ip = null)
     254    {
     255        $session_id = session_id();
     256        if(empty($session_id) && !headers_sent()) @session_start();
     257        if(is_null($ip)) {
     258            $ip = $_SERVER['REMOTE_ADDR'];
     259            if (array_key_exists('HTTP_X_REAL_IP', $_SERVER)) {
     260                $ip = $_SERVER['HTTP_X_REAL_IP'];
     261            }
     262        }
     263        if(isset($_SESSION[$session_name])){
     264            if(strcmp($ip, $_SESSION[$session_name]['client_ip']) === 0){
     265                $country = $_SESSION[$session_name]['client_country'];
     266                return $country;
     267            }
     268            unset($_SESSION[$session_name]);
     269        }
     270
    255271        $url_check_ip = '%s/api/geoip/country-by-ip.json/%s/?access_token=%s&_=%s';
    256272        $baseUrl = get_theme_mod( 'tap_base_url' );
     
    260276        $apiUrl = esc_url(sprintf($url_check_ip, $baseUrl, $ip, $oauthAccessToken, $now->getTimestamp()));
    261277        $result = $this->get_result_from_api($apiUrl, true, 'Request Country by IP');
    262         // TODO: revisar funcionamiento.
    263         return $result;
     278
     279        if ( ! isset( $_SESSION[$session_name] ) ) {
     280            $_SESSION[$session_name] = array(
     281                'client_ip'      => $ip,
     282                'client_country' => $result
     283            );
     284        }
     285
     286        return $result;
    264287    }
    265288}
  • rest-client-tap/trunk/rest-client-tap.php

    r1810593 r2330673  
    33/**
    44 * @link              http://www.linkedin.com/in/mrbrazzi/
    5  * @since             1.0.1
     5 * @since             1.1
    66 * @package           RestClientTap
    77 *
     
    1010 * Plugin URI:        https://www.wordpress.org/plugins/rest-client-tap
    1111 * Description:       Rest client plugin to TodoApuestas API services
    12  * Version:           1.0.0
     12 * Version:           1.1
    1313 * Author:            Alain Sanchez <luka.ghost@gmail.com>
    1414 * Author URI:        http://www.linkedin.com/in/mrbrazzi/
Note: See TracChangeset for help on using the changeset viewer.