Plugin Directory

Changeset 2995586


Ignore:
Timestamp:
11/14/2023 08:08:15 AM (2 years ago)
Author:
mailboxvalidator
Message:

Update to use v2 for MailboxValidator API through MailboxValiator PHP SDK, and tested with WordPress 6.4.1.

Location:
email-validator-for-contact-form-7/trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • email-validator-for-contact-form-7/trunk/email-validator-for-contact-form-7.php

    r2964370 r2995586  
    99Description:  Enables Contact Form 7 users to validate their client’s email address before accepting their messages for sending using MailboxValidator. <strong>Before get started, install and activate the Contact Form 7 plugin first.</strong>
    1010
    11 Version:      1.6.6
     11Version:      1.7.0
    1212
    1313Author:       MailboxValidator
     
    106106        $options = get_option( 'mbv_wpcf7_email_validator_for_contact_form_7' );
    107107
    108         if ( $options['api_key'] == '' || $options['api_key'] == ' ' ) {
     108        if ( !(isset($options['api_key'])) || $options['api_key'] == '' || $options['api_key'] == ' ' ) {
    109109
    110110             echo '<div class="notice notice-warning is-dismissible"><p>';
     
    485485        $invalid_on_off = $options['invalid_on_off'] ?? 'on';
    486486
    487         echo '<input id="invalid_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[invalid_error_message]" style="width:100%" type="text" value="' . $invalid_error_message . '" ' . ( $invalid_on_off == 'off' ? 'disabled="disabled" ' : '' ) . ' aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
     487        echo '<input id="invalid_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[invalid_error_message]" style="width:100%" type="text" value="' . $invalid_error_message . '" aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
    488488        echo '<p id="errormessage-hint" style="color:#666666;font-style: italic;" >Your error message should be not more than 255 characters.</p>';
    489489
     
    499499        $disposable_on_off = $options['disposable_on_off'] ?? 'on';
    500500
    501         echo '<input id="disposable_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[disposable_error_message]" style="width:100%" type="text" value="' . $disposable_error_message . '" ' . ( $disposable_on_off == 'off' ? 'disabled="disabled" ' : '' ) . ' aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
     501        echo '<input id="disposable_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[disposable_error_message]" style="width:100%" type="text" value="' . $disposable_error_message . '" aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
    502502        echo '<p id="errormessage-hint" style="color:#666666;font-style: italic;" >Your error message should be not more than 255 characters.</p>';
    503503
     
    513513        $free_on_off = $options['free_on_off'] ?? 'on';
    514514
    515         echo '<input id="free_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[free_error_message]" style="width:100%" type="text" value="' . $free_error_message . '"  ' . ( $free_on_off == 'off' ? 'disabled="disabled" ' : '' ) . ' aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
     515        echo '<input id="free_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[free_error_message]" style="width:100%" type="text" value="' . $free_error_message . '" aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
    516516        echo '<p id="errormessage-hint" style="color:#666666;font-style: italic;" >Your error message should be not more than 255 characters.</p>';
    517517
     
    527527        $role_on_off = $options['role_on_off'] ?? 'on';
    528528
    529         echo '<input id="role_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[role_error_message]" style="width:100%" type="text" value="' . $role_error_message . '"  ' . ( $role_on_off == 'off' ? 'disabled="disabled" ' : '' ) . ' aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
     529        echo '<input id="role_error_message" name="mbv_wpcf7_email_validator_for_contact_form_7[role_error_message]" style="width:100%" type="text" value="' . $role_error_message . '" aria-describedby="errormessage-hint" max="255" maxlength="255"/>';
    530530        echo '<p id="errormessage-hint" style="color:#666666;font-style: italic;" >Your error message should be not more than 255 characters.</p>';
    531531
     
    664664
    665665        if ( $api_result != '' ) {
    666             if ( $api_result['error_message'] === '' ) {
    667                 if ( $api_result['status'] === 'False' ) {
     666            if ( !isset( $api_result['error_code'] ) ) {
     667                if ( $api_result['status'] ) {
     668                    return true;
     669                } else {
    668670                    return false;
    669                 } else {
    670                     return true;
    671671                }
    672672            } else {
     
    683683
    684684        if ( $api_result != '' ) {
    685             if ( $api_result['error_message'] === '' ) {
    686                 if ( $api_result['is_role'] === 'False' ) {
     685            if ( !isset( $api_result['error_code'] ) ) {
     686                if ( $api_result['is_role'] ) {
     687                    return true;
     688                } else {
    687689                    return false;
    688                 } else {
    689                     return true;
    690690                }
    691691            } else {
     
    706706        // if ( $data['error_message'] == '' ) {
    707707        if ($results != null) {
    708         if ( trim( $results->error_code ) === '' ) {
    709 
    710             // if ( $data['is_free'] == 'False' ) {
    711             if ( $results->is_free === 'False' ) {
    712 
     708            if ( !isset( $results->error_code ) ) {
     709
     710                // if ( $data['is_free'] == 'False' ) {
     711                if ( $results->is_free ) {
     712
     713                    return true;
     714
     715                } else {
     716
     717                    return false;
     718
     719                }
     720
     721            } else {
    713722                return false;
    714 
    715             } else {
    716 
    717                 return true;
    718 
    719723            }
    720 
    721724        } else {
    722725            return false;
    723726        }
    724         } else {
    725             return false;
    726         }
    727727
    728728    }
     
    735735        // if ( $data['error_message'] == '' ) {
    736736        if ($results != null) {
    737             if ( trim( $results->error_code ) === '' ) {
    738 
    739             // if ( $data['is_disposable'] == 'False' ) {
    740             if ( $results->is_disposable === 'False' ) {
    741 
     737            if ( !isset( $results->error_code ) ) {
     738
     739                // if ( $data['is_disposable'] == 'False' ) {
     740                if ( $results->is_disposable ) {
     741
     742                    return true;
     743
     744                } else {
     745
     746                    return false;
     747
     748                }
     749
     750            } else {
    742751                return false;
    743 
    744             } else {
    745 
    746                 return true;
    747 
    748752            }
    749 
    750         } else {
    751             return false;
    752         }
    753753        } else {
    754754            return false;
     
    815815            // $is_free = $options['free_on_off'] == 'on' ? mbv_wpcf7_validate_email_check_free( $_POST[$name] , $options['api_key'] ) : false;
    816816            if ($options['disposable_on_off'] === 'on') {
    817                 if ($single_result != '' && $single_result['error_message'] == '') {
    818                     $is_disposable = ($single_result['is_disposable'] == 'False') ? false : true;
     817                if ($single_result != '' && !(array_key_exists('error_message', $single_result))) {
     818                    $is_disposable = ($single_result['is_disposable']) ? true : false;
    819819                } else {
    820820                    $is_disposable = $this->mbv_wpcf7_validate_email_check_disposable( $_POST[$name] , $options['api_key'] );
     
    824824            }
    825825            if ($options['free_on_off'] === 'on') {
    826                 if ($single_result != '' && $single_result['error_message'] == '') {
    827                     $is_free = ($single_result['is_free'] == 'False') ? false : true;
     826                if ($single_result != '' && !(array_key_exists('error_message', $single_result))) {
     827                    $is_free = ($single_result['is_free']) ? true : false;
    828828                } else {
    829829                    $is_free = $this->mbv_wpcf7_validate_email_check_free( $_POST[$name] , $options['api_key'] );
  • email-validator-for-contact-form-7/trunk/readme.txt

    r2964370 r2995586  
    33Donate link: https://mailboxvalidator.com
    44Tags: mailboxvalidator, contact form 7, email validation, form validation, email validator, disposable email, free email, role-based email
    5 Tested up to: 6.3
    6 Stable tag: 1.6.6
     5Tested up to: 6.4.1
     6Stable tag: 1.7.0
    77Requires PHP: 5.2.4
    88
     
    6565
    6666== Changelog ==
     67
     68= 1.7.0 =
     69* Update to use v2 for MailboxValidator API through MailboxValiator PHP SDK, and tested with WordPress 6.4.1.
    6770
    6871= 1.6.6 =
  • email-validator-for-contact-form-7/trunk/vendor/mailboxvalidator/mailboxvalidator-php/README.md

    r2453608 r2995586  
    2121```
    2222"require": {
    23     "mailboxvalidator/mailboxvalidator-php": "2.0.*"
     23    "mailboxvalidator/mailboxvalidator-php": "2.1.*"
    2424}
    2525```
     
    116116    echo "Error connecting to API.\n";
    117117}
    118 else if (trim($results->error_code) === '') {
     118else if (!isset($results->error)) {
    119119    echo 'email_address = ' . $results->email_address . "\n";
    120120    echo 'domain = ' . $results->domain . "\n";
    121     echo 'is_free = ' . $results->is_free . "\n";
    122     echo 'is_syntax = ' . $results->is_syntax . "\n";
    123     echo 'is_domain = ' . $results->is_domain . "\n";
    124     echo 'is_smtp = ' . $results->is_smtp . "\n";
    125     echo 'is_verified = ' . $results->is_verified . "\n";
    126     echo 'is_server_down = ' . $results->is_server_down . "\n";
    127     echo 'is_greylisted = ' . $results->is_greylisted . "\n";
    128     echo 'is_disposable = ' . $results->is_disposable . "\n";
    129     echo 'is_suppressed = ' . $results->is_suppressed . "\n";
    130     echo 'is_role = ' . $results->is_role . "\n";
    131     echo 'is_high_risk = ' . $results->is_high_risk . "\n";
    132     echo 'is_catchall = ' . $results->is_catchall . "\n";
     121    echo 'is_free = ' . var_export($results->is_free, true) . "\n";
     122    echo 'is_syntax = ' . var_export($results->is_syntax, true) . "\n";
     123    echo 'is_domain = ' . var_export($results->is_domain, true) . "\n";
     124    echo 'is_smtp = ' . var_export($results->is_smtp, true) . "\n";
     125    echo 'is_verified = ' . var_export($results->is_verified, true) . "\n";
     126    echo 'is_server_down = ' . var_export($results->is_server_down, true) . "\n";
     127    echo 'is_greylisted = ' . var_export($results->is_greylisted, true) . "\n";
     128    echo 'is_disposable = ' . var_export($results->is_disposable, true) . "\n";
     129    echo 'is_suppressed = ' . var_export($results->is_suppressed, true) . "\n";
     130    echo 'is_role = ' . var_export($results->is_role, true) . "\n";
     131    echo 'is_high_risk = ' . var_export($results->is_high_risk, true) . "\n";
     132    echo 'is_catchall = ' . var_export($results->is_catchall, true) . "\n";
    133133    echo 'mailboxvalidator_score = ' . $results->mailboxvalidator_score . "\n";
    134134    echo 'time_taken = ' . $results->time_taken . "\n";
    135     echo 'status = ' . $results->status . "\n";
     135    echo 'status = ' . var_export($results->status, true) . "\n";
    136136    echo 'credits_available = ' . $results->credits_available . "\n";
    137137}
    138138else {
    139     echo 'error_code = ' . $results->error_code . "\n";
    140     echo 'error_message = ' . $results->error_message . "\n";
     139    echo 'error_code = ' . $results->error->error_code . "\n";
     140    echo 'error_message = ' . $results->error->error_message . "\n";
    141141}
    142142?>
     
    159159    echo "Error connecting to API.\n";
    160160}
    161 else if (trim($results->error_code) === '') {
     161else if (!isset($results->error)) {
    162162    echo 'email_address = ' . $results->email_address . "\n";
    163     echo 'is_disposable = ' . $results->is_disposable . "\n";
     163    echo 'is_disposable = ' . var_export($results->is_disposable, true) . "\n";
    164164    echo 'credits_available = ' . $results->credits_available . "\n";
    165165}
    166166else {
    167     echo 'error_code = ' . $results->error_code . "\n";
    168     echo 'error_message = ' . $results->error_message . "\n";
     167    echo 'error_code = ' . $results->error->error_code . "\n";
     168    echo 'error_message = ' . $results->error->error_message . "\n";
    169169}
    170170?>
     
    186186    echo "Error connecting to API.\n";
    187187}
    188 else if (trim($results->error_code) === '') {
     188else if (!isset($results->error)) {
    189189    echo 'email_address = ' . $results->email_address . "\n";
    190     echo 'is_free = ' . $results->is_free . "\n";
     190    echo 'is_free = ' . var_export($results->is_free, true) . "\n";
    191191    echo 'credits_available = ' . $results->credits_available . "\n";
    192192}
    193193else {
    194     echo 'error_code = ' . $results->error_code . "\n";
    195     echo 'error_message = ' . $results->error_message . "\n";
     194    echo 'error_code = ' . $results->error->error_code . "\n";
     195    echo 'error_message = ' . $results->error->error_message . "\n";
    196196}
    197197?>
     
    213213=========
    214214
    215 Copyright(C) 2018-2020 by MailboxValidator.com.
     215Copyright(C) 2018-2023 by MailboxValidator.com.
  • email-validator-for-contact-form-7/trunk/vendor/mailboxvalidator/mailboxvalidator-php/src/EmailValidation.php

    r2455221 r2995586  
    55{
    66    private $apiKey = '';
    7     private $singleValidationApiUrl = 'https://api.mailboxvalidator.com/v1/validation/single';
    8     private $disposableEmailApiUrl = 'https://api.mailboxvalidator.com/v1/email/disposable';
    9     private $freeEmailApiUrl = 'https://api.mailboxvalidator.com/v1/email/free';
     7    private $singleValidationApiUrl = 'https://api.mailboxvalidator.com/v2/validation/single';
     8    private $disposableEmailApiUrl = 'https://api.mailboxvalidator.com/v2/email/disposable';
     9    private $freeEmailApiUrl = 'https://api.mailboxvalidator.com/v2/email/free';
    1010   
    1111    public function __construct($key)
     
    1818   
    1919    }
     20   
     21    /*
     22    * Custom wrapper function for CURL
     23    */
     24    public function curl($url) {
     25        // Initialize cURL session
     26        $ch = curl_init();
     27       
     28        // Set cURL options
     29        curl_setopt($ch, CURLOPT_URL, $url);
     30        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return the response as a string instead of outputting it
     31
     32        // Execute cURL session and store the response in a variable
     33        $response = curl_exec($ch);
     34
     35        // Check for cURL errors
     36        if (curl_errno($ch)) {
     37            // echo 'cURL Error: ' . curl_error($ch);
     38            return null;
     39        }
     40
     41        // Close cURL session
     42        curl_close($ch);
     43       
     44        return $response;
     45    }
    2046   
    2147    /*
     
    3258            $params = implode('&', $params2);
    3359           
    34             $results = file_get_contents($this->singleValidationApiUrl . '?' . $params);
     60            $results = $this->curl($this->singleValidationApiUrl . '?' . $params);
    3561           
    3662            if ($results !== false) {
     
    4369            return null;
    4470        }
     71        // restore_error_handler();
    4572    }
    4673   
     
    5885            $params = implode('&', $params2);
    5986           
    60             $results = file_get_contents($this->disposableEmailApiUrl . '?' . $params);
     87            $results = $this->curl($this->disposableEmailApiUrl . '?' . $params);
    6188           
    6289            if ($results !== false) {
     
    84111            $params = implode('&', $params2);
    85112           
    86             $results = file_get_contents($this->freeEmailApiUrl . '?' . $params);
     113            $results = $this->curl($this->freeEmailApiUrl . '?' . $params);
    87114           
    88115            if ($results !== false) {
     
    96123        }
    97124    }
     125   
     126    /*private function ()
     127    {
     128        set_error_handler(
     129            function ($severity, $message, $file, $line) {
     130                throw new ErrorException($message, $severity, $severity, $file, $line);
     131            }
     132        );
     133    }*/
    98134}
Note: See TracChangeset for help on using the changeset viewer.