<?php


namespace OTP\Handler\Forms;

use OTP\Helper\FormSessionVars;
use OTP\Helper\MoOTPDocs;
use OTP\Helper\MoPHPSessions;
use OTP\Helper\MoUtility;
use OTP\Helper\SessionUtils;
use OTP\Objects\FormHandler;
use OTP\Objects\IFormHandler;
use OTP\Traits\Instance;
use ReflectionException;
class ClassifyRegistrationForm extends FormHandler implements IFormHandler
{
    use Instance;
    protected function __construct()
    {
        $this->_isLoginOrSocialForm = FALSE;
        $this->_isAjaxForm = FALSE;
        $this->_formSessionVar = FormSessionVars::CLASSIFY_REGISTER;
        $this->_typePhoneTag = "\143\x6c\141\x73\163\x69\x66\x79\137\x70\x68\157\x6e\145\137\x65\x6e\x61\142\154\145";
        $this->_typeEmailTag = "\143\154\141\x73\x73\x69\x66\171\x5f\x65\x6d\x61\151\x6c\137\x65\x6e\141\x62\154\145";
        $this->_formKey = "\103\x4c\x41\123\123\111\x46\131\x5f\122\x45\107\111\123\x54\105\x52";
        $this->_formName = mo_("\x43\x6c\141\163\163\151\146\x79\x20\124\150\145\x6d\145\40\x52\x65\147\151\163\164\162\141\164\x69\157\156\x20\x46\157\162\155");
        $this->_isFormEnabled = get_mo_option("\143\154\x61\x73\x73\151\146\171\x5f\x65\x6e\x61\x62\154\x65");
        $this->_phoneFormId = "\151\156\160\165\164\x5b\156\141\155\145\x3d\x70\x68\x6f\x6e\145\x5d";
        $this->_formDocuments = MoOTPDocs::CLASSIFY_LINK;
        parent::__construct();
    }
    function handleForm()
    {
        $this->_otpType = get_mo_option("\x63\x6c\x61\163\163\x69\146\171\137\164\x79\x70\145");
        add_action("\x77\x70\137\145\156\x71\x75\145\x75\x65\x5f\163\x63\x72\x69\x70\x74\163", array($this, "\x5f\163\x68\x6f\167\x5f\x70\150\157\x6e\x65\137\146\151\x65\154\x64\x5f\x6f\x6e\x5f\160\141\x67\x65"));
        add_action("\x75\163\x65\x72\137\162\x65\x67\151\x73\x74\x65\x72", array($this, "\163\x61\166\x65\137\x70\x68\157\156\x65\137\x6e\x75\x6d\x62\x65\x72"), 10, 1);
        $this->routeData();
    }
    function routeData()
    {
        if (SessionUtils::isStatusMatch($this->_formSessionVar, self::VALIDATED, $this->getVerificationType())) {
            goto W4;
        }
        if (!(MoUtility::sanitizeCheck("\x6f\160\x74\x69\157\156", $_POST) === "\x76\x65\162\x69\146\171\x5f\x75\163\x65\x72\137\143\x6c\141\163\x73\151\146\x79")) {
            goto wh;
        }
        $this->_handle_classify_theme_form_post($_POST);
        wh:
        goto YQ;
        W4:
        $this->unsetOTPSessionVariables();
        YQ:
    }
    function _show_phone_field_on_page()
    {
        wp_enqueue_script("\x63\154\x61\x73\x73\151\146\171\163\x63\x72\x69\160\x74", MOV_URL . "\x69\156\143\154\x75\144\x65\x73\x2f\x6a\x73\x2f\143\154\x61\163\163\151\146\x79\56\155\x69\156\56\152\163\x3f\x76\x65\162\x73\151\157\156\75" . MOV_VERSION, array("\152\x71\165\145\162\x79"));
    }
    function _handle_classify_theme_form_post($BT)
    {
        $lQ = $BT["\165\163\145\x72\156\141\155\x65"];
        $en = $BT["\x65\155\141\x69\154"];
        $s9 = $BT["\x70\x68\x6f\x6e\x65"];
        if (!(username_exists($lQ) != FALSE)) {
            goto W3;
        }
        return;
        W3:
        if (!(email_exists($en) != FALSE)) {
            goto i6;
        }
        return;
        i6:
        MoUtility::initialize_transaction($this->_formSessionVar);
        if (strcasecmp($this->_otpType, $this->_typePhoneTag) === 0) {
            goto ds;
        }
        if (strcasecmp($this->_otpType, $this->_typeEmailTag) === 0) {
            goto ME;
        }
        $this->sendChallenge($_POST["\165\163\x65\x72\x6e\x61\x6d\145"], $en, null, $s9, "\x62\157\x74\x68", null, null);
        goto nx;
        ME:
        $this->sendChallenge($_POST["\165\163\x65\x72\156\x61\x6d\145"], $en, null, null, "\x65\x6d\141\x69\x6c", null, null);
        nx:
        goto u9;
        ds:
        $this->sendChallenge($_POST["\x75\163\145\x72\x6e\x61\155\145"], $en, null, $s9, "\160\x68\157\156\x65", null, null);
        u9:
    }
    function save_phone_number($LG)
    {
        $YN = MoPHPSessions::getSessionVar("\160\150\157\156\x65\137\156\165\155\142\x65\x72\x5f\x6d\157");
        if (!$YN) {
            goto Uh;
        }
        update_user_meta($LG, "\160\x68\157\x6e\145", $YN);
        Uh:
    }
    function handle_failed_verification($te, $j4, $sP, $Cw)
    {
        if (SessionUtils::isOTPInitialized($this->_formSessionVar)) {
            goto S7;
        }
        return;
        S7:
        $HK = strcasecmp($this->_otpType, $this->_typePhoneTag) === 0 ? "\x70\150\x6f\156\145" : (strcasecmp($this->_otpType, $this->_typeEmailTag) === 0 ? "\145\155\141\151\x6c" : "\x62\157\164\x68");
        $Qg = strcasecmp($HK, "\x62\157\x74\150") === 0 ? 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->_formSessionVar, $this->_txSessionId));
    }
    public function getPhoneNumberSelector($fv)
    {
        if (!($this->isFormEnabled() && $this->_otpType === $this->_typePhoneTag)) {
            goto uh;
        }
        array_push($fv, $this->_phoneFormId);
        uh:
        return $fv;
    }
    function handleFormOptions()
    {
        if (MoUtility::areFormOptionsBeingSaved($this->getFormOption())) {
            goto BZ;
        }
        return;
        BZ:
        $this->_otpType = $this->sanitizeFormPOST("\x63\154\141\x73\x73\151\x66\171\137\164\x79\x70\x65");
        $this->_isFormEnabled = $this->sanitizeFormPOST("\143\154\141\x73\x73\151\x66\171\x5f\x65\156\141\142\x6c\145");
        update_mo_option("\143\154\141\x73\163\x69\146\171\137\x65\x6e\x61\142\154\145", $this->_isFormEnabled);
        update_mo_option("\143\154\x61\x73\163\x69\146\171\x5f\164\x79\x70\145", $this->_otpType);
    }
}
