Plugin Directory

Changeset 3309799


Ignore:
Timestamp:
06/11/2025 12:32:13 PM (10 months ago)
Author:
mlsimport
Message:

Update to version 6.0.7 from GitHub

Location:
mlsimport
Files:
10 edited
1 copied

Legend:

Unmodified
Added
Removed
  • mlsimport/tags/6.0.7/README.MD

    r3308382 r3309799  
    55Tested up to: 6.7.1
    66Requires PHP: 7.4
    7 Stable Tag: 6.0.5
     7Stable Tag: 6.0.7
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • mlsimport/tags/6.0.7/admin/partials/mlsimport-admin-options.php

    r3308300 r3309799  
    150150}
    151151
     152
     153// Add before username fieldset
     154/*
     155global $mlsimport;
     156$current_token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient();
     157$token_expiry = get_option('mlsimport_token_expiry', 0);
     158
     159
     160$expiry_date = date('Y-m-d H:i:s', $token_expiry);
     161$is_expired = time() >= $token_expiry;
     162$status_color = $is_expired ? '#dc3545' : '#28a745';
     163$status_text = $is_expired ? 'EXPIRED' : 'VALID';
     164
     165echo '<div style="background: #f9f9f9; padding: 15px; margin-bottom: 20px; border-radius: 5px;">';
     166echo '<h4>Current Token Status</h4>';
     167echo '<p><strong>Token:</strong> ' . esc_html(substr($current_token, 0, 20)) . '...</p>';
     168echo '<p><strong>Status:</strong> <span style="color: ' . $status_color . '; font-weight: bold;">' . $status_text . '</span></p>';
     169echo '<p><strong>Expires:</strong> ' . esc_html($expiry_date) . '</p>';
     170echo '</div>';
     171*/
    152172
    153173
  • mlsimport/tags/6.0.7/includes/ThemeImport.php

    r3308300 r3309799  
    2828
    2929    public function globalApiRequestCurlSaas($method, $valuesArray, $type = 'GET') {
     30
     31       
    3032        global $mlsimport;
    31         $url = MLSIMPORT_API_URL . $method;
     33       
     34        // Skip validation for token requests
     35        if ($method !== 'token') {
     36            if (!self::validateAndRefreshToken()) {
     37                return 'Token validation failed';
     38            }
     39        }
     40       
     41        $url = MLSIMPORT_API_URL . $method;
    3242        $headers = ['Content-Type' => 'text/plain'];
    3343
     
    92102    public static function globalApiRequestSaas($method, $valuesArray, $type = 'GET') {
    93103            global $mlsimport;
     104             // Skip validation for token and mls requests
     105            if ($method !== 'token' && $method !== 'mls') {
     106                if (!self::validateAndRefreshToken()) {
     107                    return [
     108                        'success' => false,
     109                        'error_message' => 'Token validation failed'
     110                    ];
     111                }
     112            }
     113
     114           
    94115            $url = MLSIMPORT_API_URL . $method;
    95116
     
    138159
    139160
    140 
     161   
     162    /**
     163     * Check if token is expired and refresh if needed
     164     * Call this before any external API request
     165     *
     166     * @return bool True if token is valid, false if refresh failed
     167     */
     168    private static function validateAndRefreshToken() {
     169        global $mlsimport;
     170       
     171        // Get stored expiry timestamp
     172        $token_expiry = get_option('mlsimport_token_expiry', 0);
     173        $current_time = time();
     174       
     175        // Check if token is expired
     176        if ($current_time >= $token_expiry) {
     177            // Token expired, refresh it
     178            $refresh_result = self::refreshToken();
     179           
     180            if (!$refresh_result) {
     181                error_log('MLSImport: Failed to refresh expired token');
     182                return false;
     183            }
     184        }
     185       
     186        return true;
     187    }
     188
     189    private static function refreshToken() {
     190        global $mlsimport;
     191       
     192        // Get credentials for token request
     193        $options = get_option('mlsimport_admin_options');
     194        $username = isset($options['mlsimport_username']) ? $options['mlsimport_username'] : '';
     195        $password = isset($options['mlsimport_password']) ? $options['mlsimport_password'] : '';
     196       
     197        if (empty($username) || empty($password)) {
     198            error_log('MLSImport: Missing credentials for token refresh');
     199            return false;
     200        }
     201       
     202        // Prepare token request
     203        $url = MLSIMPORT_API_URL . 'token';
     204        $body = wp_json_encode(array(
     205            'username' => $username,
     206            'password' => $password
     207        ));
     208       
     209        $args = array(
     210            'method' => 'POST',
     211            'headers' => array(
     212                'Content-Type' => 'application/json'
     213            ),
     214            'body' => $body,
     215            'timeout' => 45
     216        );
     217       
     218        // Make token request
     219        $response = wp_remote_post($url, $args);
     220       
     221        if (is_wp_error($response)) {
     222            error_log('MLSImport: Token refresh request failed: ' . $response->get_error_message());
     223            return false;
     224        }
     225       
     226        $body = wp_remote_retrieve_body($response);
     227        $data = json_decode($body, true);
     228       
     229        if (!isset($data['success']) || !$data['success'] || !isset($data['token']) || !isset($data['expires'])) {
     230            error_log('MLSImport: Invalid token refresh response');
     231            return false;
     232        }
     233       
     234        // Store new token and expiry
     235        //$mlsimport->admin->mlsimport_saas_store_mls_api_token_transient($data['token']);
     236       
     237        $expires_in = $data['expires'] - time();
     238        set_transient('mlsimport_saas_token', $data['token'], $expires_in);
     239
     240        update_option('mlsimport_token_expiry', intval($data['expires']));
     241       
     242        error_log('MLSImport: Token successfully refreshed. Expires: ' . date('Y-m-d H:i:s', $data['expires']));
     243       
     244        return true;
     245    }
    141246
    142247
  • mlsimport/tags/6.0.7/mlsimport.php

    r3308382 r3309799  
    44 * Plugin URI:        https://mlsimport.com/
    55 * Description:       "MLS Import - The MLSImport plugin facilitates the connection to your real estate MLS database, allowing you to download and synchronize real estate property data from the MLS.
    6  * Version:           6.0.5
    7  * Stable tag:        6.0.5
     6 * Version:           6.0.7
     7 * Stable tag:        6.0.7
    88 * Requires at least: 5.2
    99 * Requires PHP:      7.2
     
    2222
    2323
    24 define( 'MLSIMPORT_VERSION', '6.0.5' );
     24define( 'MLSIMPORT_VERSION', '6.0.7' );
    2525define( 'MLSIMPORT_CLUBLINK', 'mlsimport.com' );
    2626define( 'MLSIMPORT_CLUBLINKSSL', 'https' );
  • mlsimport/tags/6.0.7/readme.txt

    r3308382 r3309799  
    55Tested up to: 6.7.1
    66Requires PHP: 7.4
    7 Stable Tag: 6.0.5
     7Stable Tag: 6.0.7
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • mlsimport/trunk/README.MD

    r3308382 r3309799  
    55Tested up to: 6.7.1
    66Requires PHP: 7.4
    7 Stable Tag: 6.0.5
     7Stable Tag: 6.0.7
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
  • mlsimport/trunk/admin/partials/mlsimport-admin-options.php

    r3308300 r3309799  
    150150}
    151151
     152
     153// Add before username fieldset
     154/*
     155global $mlsimport;
     156$current_token = $mlsimport->admin->mlsimport_saas_get_mls_api_token_from_transient();
     157$token_expiry = get_option('mlsimport_token_expiry', 0);
     158
     159
     160$expiry_date = date('Y-m-d H:i:s', $token_expiry);
     161$is_expired = time() >= $token_expiry;
     162$status_color = $is_expired ? '#dc3545' : '#28a745';
     163$status_text = $is_expired ? 'EXPIRED' : 'VALID';
     164
     165echo '<div style="background: #f9f9f9; padding: 15px; margin-bottom: 20px; border-radius: 5px;">';
     166echo '<h4>Current Token Status</h4>';
     167echo '<p><strong>Token:</strong> ' . esc_html(substr($current_token, 0, 20)) . '...</p>';
     168echo '<p><strong>Status:</strong> <span style="color: ' . $status_color . '; font-weight: bold;">' . $status_text . '</span></p>';
     169echo '<p><strong>Expires:</strong> ' . esc_html($expiry_date) . '</p>';
     170echo '</div>';
     171*/
    152172
    153173
  • mlsimport/trunk/includes/ThemeImport.php

    r3308300 r3309799  
    2828
    2929    public function globalApiRequestCurlSaas($method, $valuesArray, $type = 'GET') {
     30
     31       
    3032        global $mlsimport;
    31         $url = MLSIMPORT_API_URL . $method;
     33       
     34        // Skip validation for token requests
     35        if ($method !== 'token') {
     36            if (!self::validateAndRefreshToken()) {
     37                return 'Token validation failed';
     38            }
     39        }
     40       
     41        $url = MLSIMPORT_API_URL . $method;
    3242        $headers = ['Content-Type' => 'text/plain'];
    3343
     
    92102    public static function globalApiRequestSaas($method, $valuesArray, $type = 'GET') {
    93103            global $mlsimport;
     104             // Skip validation for token and mls requests
     105            if ($method !== 'token' && $method !== 'mls') {
     106                if (!self::validateAndRefreshToken()) {
     107                    return [
     108                        'success' => false,
     109                        'error_message' => 'Token validation failed'
     110                    ];
     111                }
     112            }
     113
     114           
    94115            $url = MLSIMPORT_API_URL . $method;
    95116
     
    138159
    139160
    140 
     161   
     162    /**
     163     * Check if token is expired and refresh if needed
     164     * Call this before any external API request
     165     *
     166     * @return bool True if token is valid, false if refresh failed
     167     */
     168    private static function validateAndRefreshToken() {
     169        global $mlsimport;
     170       
     171        // Get stored expiry timestamp
     172        $token_expiry = get_option('mlsimport_token_expiry', 0);
     173        $current_time = time();
     174       
     175        // Check if token is expired
     176        if ($current_time >= $token_expiry) {
     177            // Token expired, refresh it
     178            $refresh_result = self::refreshToken();
     179           
     180            if (!$refresh_result) {
     181                error_log('MLSImport: Failed to refresh expired token');
     182                return false;
     183            }
     184        }
     185       
     186        return true;
     187    }
     188
     189    private static function refreshToken() {
     190        global $mlsimport;
     191       
     192        // Get credentials for token request
     193        $options = get_option('mlsimport_admin_options');
     194        $username = isset($options['mlsimport_username']) ? $options['mlsimport_username'] : '';
     195        $password = isset($options['mlsimport_password']) ? $options['mlsimport_password'] : '';
     196       
     197        if (empty($username) || empty($password)) {
     198            error_log('MLSImport: Missing credentials for token refresh');
     199            return false;
     200        }
     201       
     202        // Prepare token request
     203        $url = MLSIMPORT_API_URL . 'token';
     204        $body = wp_json_encode(array(
     205            'username' => $username,
     206            'password' => $password
     207        ));
     208       
     209        $args = array(
     210            'method' => 'POST',
     211            'headers' => array(
     212                'Content-Type' => 'application/json'
     213            ),
     214            'body' => $body,
     215            'timeout' => 45
     216        );
     217       
     218        // Make token request
     219        $response = wp_remote_post($url, $args);
     220       
     221        if (is_wp_error($response)) {
     222            error_log('MLSImport: Token refresh request failed: ' . $response->get_error_message());
     223            return false;
     224        }
     225       
     226        $body = wp_remote_retrieve_body($response);
     227        $data = json_decode($body, true);
     228       
     229        if (!isset($data['success']) || !$data['success'] || !isset($data['token']) || !isset($data['expires'])) {
     230            error_log('MLSImport: Invalid token refresh response');
     231            return false;
     232        }
     233       
     234        // Store new token and expiry
     235        //$mlsimport->admin->mlsimport_saas_store_mls_api_token_transient($data['token']);
     236       
     237        $expires_in = $data['expires'] - time();
     238        set_transient('mlsimport_saas_token', $data['token'], $expires_in);
     239
     240        update_option('mlsimport_token_expiry', intval($data['expires']));
     241       
     242        error_log('MLSImport: Token successfully refreshed. Expires: ' . date('Y-m-d H:i:s', $data['expires']));
     243       
     244        return true;
     245    }
    141246
    142247
  • mlsimport/trunk/mlsimport.php

    r3308382 r3309799  
    44 * Plugin URI:        https://mlsimport.com/
    55 * Description:       "MLS Import - The MLSImport plugin facilitates the connection to your real estate MLS database, allowing you to download and synchronize real estate property data from the MLS.
    6  * Version:           6.0.5
    7  * Stable tag:        6.0.5
     6 * Version:           6.0.7
     7 * Stable tag:        6.0.7
    88 * Requires at least: 5.2
    99 * Requires PHP:      7.2
     
    2222
    2323
    24 define( 'MLSIMPORT_VERSION', '6.0.5' );
     24define( 'MLSIMPORT_VERSION', '6.0.7' );
    2525define( 'MLSIMPORT_CLUBLINK', 'mlsimport.com' );
    2626define( 'MLSIMPORT_CLUBLINKSSL', 'https' );
  • mlsimport/trunk/readme.txt

    r3308382 r3309799  
    55Tested up to: 6.7.1
    66Requires PHP: 7.4
    7 Stable Tag: 6.0.5
     7Stable Tag: 6.0.7
    88License: GPLv3
    99License URI: https://www.gnu.org/licenses/gpl-3.0.html
Note: See TracChangeset for help on using the changeset viewer.