<?php


namespace OTP\Handler\Forms;

use OTP\Helper\FormSessionVars;
use OTP\Helper\MoOTPDocs;
use OTP\Helper\MoUtility;
use OTP\Helper\SessionUtils;
use OTP\Objects\FormHandler;
use OTP\Objects\IFormHandler;
use OTP\Objects\VerificationLogic;
use OTP\Objects\VerificationType;
use OTP\Traits\Instance;
use ReflectionException;
class PaidMembershipForm extends FormHandler implements IFormHandler
{
    use Instance;
    protected function __construct()
    {
        $this->_isLoginOrSocialForm = FALSE;
        $this->_isAjaxForm = FALSE;
        $this->_formSessionVar = FormSessionVars::PMPRO_REGISTRATION;
        $this->_formKey = "\120\x4d\137\x50\122\x4f\137\x46\117\122\x4d";
        $this->_formName = mo_("\x50\141\151\144\x20\115\x65\x6d\142\145\x72\123\x68\151\x70\x20\x50\x72\x6f\40\122\x65\x67\x69\x73\x74\x72\x61\164\151\x6f\x6e\x20\x46\157\x72\x6d");
        $this->_phoneFormId = "\151\156\160\x75\x74\x5b\156\141\x6d\145\x3d\160\x68\157\156\145\x5f\160\141\151\144\x6d\x65\x6d\142\x65\162\163\x68\151\160\x5d";
        $this->_typePhoneTag = "\160\155\x70\x72\157\x5f\160\150\157\156\x65\137\145\156\141\142\x6c\x65";
        $this->_typeEmailTag = "\x70\155\160\x72\x6f\137\x65\x6d\x61\151\x6c\137\145\x6e\x61\142\x6c\x65";
        $this->_isFormEnabled = get_mo_option("\160\x6d\x70\162\157\137\145\x6e\141\142\154\x65");
        $this->_formDocuments = MoOTPDocs::PAID_MEMBERSHIP_PRO;
        parent::__construct();
    }
    function handleForm()
    {
        $this->_otpType = get_mo_option("\x70\x6d\160\162\x6f\137\x6f\x74\x70\x5f\164\171\x70\145");
        add_action("\x77\x70\137\145\x6e\161\x75\145\165\x65\137\x73\143\162\x69\160\164\163", array($this, "\137\x73\x68\157\167\x5f\x70\x68\157\x6e\145\137\146\x69\x65\154\144\137\157\x6e\x5f\x70\141\147\145"));
        add_filter("\160\x6d\160\162\157\x5f\x63\150\x65\x63\x6b\x6f\165\x74\137\x62\x65\146\x6f\162\145\137\x70\162\x6f\143\x65\x73\x73\151\156\x67", array($this, "\x5f\160\x61\x69\x64\115\145\x6d\x62\145\x72\x73\x68\x69\160\x50\162\x6f\122\145\x67\151\x73\164\x72\141\164\151\157\156\x43\150\145\x63\153"), 1, 1);
        add_filter("\x70\155\160\x72\x6f\x5f\143\150\145\143\153\x6f\165\164\x5f\x63\157\156\146\151\x72\155\x65\x64", array($this, "\151\163\x56\141\x6c\x69\x64\141\164\x65\144"), 99, 2);
    }
    public function isValidated($sL, $LR)
    {
        global $Vr;
        return $Vr == "\160\155\x70\x72\157\x5f\145\x72\x72\x6f\162" ? false : $sL;
    }
    public function _paidMembershipProRegistrationCheck()
    {
        global $Vr;
        if (!SessionUtils::isStatusMatch($this->_formSessionVar, self::VALIDATED, $this->getVerificationType())) {
            goto j6;
        }
        $this->unsetOTPSessionVariables();
        return;
        j6:
        $this->validatePhone($_POST);
        if (!($Vr != "\x70\x6d\x70\x72\x6f\x5f\145\162\162\x6f\162")) {
            goto vB;
        }
        MoUtility::initialize_transaction($this->_formSessionVar);
        $this->startOTPVerificationProcess($_POST);
        vB:
    }
    private function startOTPVerificationProcess($BT)
    {
        if (strcasecmp($this->_otpType, $this->_typePhoneTag) == 0) {
            goto Wp;
        }
        if (strcasecmp($this->_otpType, $this->_typeEmailTag) == 0) {
            goto EF;
        }
        goto Bq;
        Wp:
        $this->sendChallenge('', '', null, trim($BT["\160\x68\157\156\x65\137\160\x61\151\144\155\x65\155\x62\145\x72\x73\150\x69\160"]), "\160\x68\157\x6e\145");
        goto Bq;
        EF:
        $this->sendChallenge('', $BT["\142\145\155\141\x69\x6c"], null, $BT["\142\145\155\x61\x69\154"], "\145\x6d\141\x69\x6c");
        Bq:
    }
    public function validatePhone($BT)
    {
        if (!($this->getVerificationType() != VerificationType::PHONE)) {
            goto Q2;
        }
        return;
        Q2:
        global $zm, $Vr, $phoneLogic, $EY;
        if (!($Vr == "\160\155\160\162\157\x5f\x65\162\x72\x6f\162")) {
            goto AK;
        }
        return;
        AK:
        $h1 = $BT["\x70\x68\x6f\x6e\145\x5f\x70\x61\x69\144\x6d\145\155\x62\145\162\x73\150\x69\x70"];
        if (MoUtility::validatePhoneNumber($h1)) {
            goto PA;
        }
        $Kl = str_replace("\x23\x23\x70\x68\157\156\145\x23\43", $h1, $phoneLogic->_get_otp_invalid_format_message());
        $Vr = "\160\155\x70\162\x6f\x5f\x65\162\162\x6f\162";
        $EY = false;
        $zm = apply_filters("\x70\x6d\x70\x72\157\137\x73\145\164\x5f\x6d\145\x73\x73\x61\x67\145", $Kl, $Vr);
        PA:
    }
    function _show_phone_field_on_page()
    {
        if (!(strcasecmp($this->_otpType, $this->_typePhoneTag) == 0)) {
            goto mA;
        }
        wp_enqueue_script("\160\141\151\144\155\145\155\x62\x65\162\163\x68\151\x70\x73\143\x72\151\160\164", MOV_URL . "\151\156\143\x6c\165\x64\x65\163\x2f\152\163\x2f\160\141\151\144\155\x65\155\x62\x65\162\163\150\151\x70\160\x72\157\x2e\x6d\x69\x6e\56\x6a\163\77\x76\145\162\x73\x69\157\x6e\x3d" . MOV_VERSION, array("\x6a\161\165\x65\x72\x79"));
        mA:
    }
    function handle_failed_verification($te, $j4, $sP, $Cw)
    {
        $HK = $this->getVerificationType();
        $Qg = $HK === VerificationType::BOTH ? TRUE : FALSE;
        miniorange_site_otp_validation_form($te, $j4, $sP, MoUtility::_get_invalid_otp_method(), $HK, $Qg);
    }
    function handle_post_verification($TG, $te, $j4, $xy, $sP, $yJ, $Cw)
    {
        SessionUtils::addStatus($this->_formSessionVar, self::VALIDATED, $Cw);
    }
    public function unsetOTPSessionVariables()
    {
        SessionUtils::unsetSession(array($this->_txSessionId, $this->_formSessionVar));
    }
    public function getPhoneNumberSelector($fv)
    {
        if (!(self::isFormEnabled() && $this->_otpType == $this->_typePhoneTag)) {
            goto Az;
        }
        array_push($fv, $this->_phoneFormId);
        Az:
        return $fv;
    }
    function handleFormOptions()
    {
        if (MoUtility::areFormOptionsBeingSaved($this->getFormOption())) {
            goto Yp;
        }
        return;
        Yp:
        $this->_isFormEnabled = $this->sanitizeFormPOST("\x70\155\x70\x72\157\x5f\145\x6e\141\142\x6c\145");
        $this->_otpType = $this->sanitizeFormPOST("\x70\x6d\x70\x72\x6f\x5f\143\157\156\164\x61\x63\164\x5f\x74\171\160\x65");
        update_mo_option("\x70\x6d\x70\162\x6f\x5f\145\x6e\141\x62\x6c\145", $this->_isFormEnabled);
        update_mo_option("\x70\155\160\162\157\137\x6f\x74\x70\x5f\164\x79\160\145", $this->_otpType);
    }
}
