Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php namespace MoWeb3\controller; require_once realpath(dirname(__FILE__) . DIRECTOR..
Decoded Output download
<?php
namespace MoWeb3\controller;
require_once realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "Keccak" . DIRECTORY_SEPARATOR . "Keccak.php");
require_once realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "Elliptic" . DIRECTORY_SEPARATOR . "EC.php");
require_once realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "Elliptic" . DIRECTORY_SEPARATOR . "Curves.php");
use Elliptic\EC;
use kornrunner\Keccak;
use MoWeb3\MoWeb3Utils;
use MoWeb3View\ButtonView\MoWeb3View;
class MoWeb3FlowHandler
{
private $data;
private $request;
private $utils;
private $is_new_user;
public $is_testing_wallet_address = false;
public function __construct()
{
$this->utils = new \MoWeb3\MoWeb3Utils();
add_action("wp_ajax_nopriv_type_of_request", array($this, "type_of_request"));
add_action("wp_ajax_type_of_request", array($this, "type_of_request"));
add_action("init", array($this, "hidden_form_data"));
add_action("admin_init", array($this, "toggle_display_button"));
add_action("admin_init", array($this, "toggle_crypto_wallet_button_display"));
add_action("admin_init", array($this, "login_wallet_restriction"));
add_action("admin_init", array($this, "change_display_button_text"));
add_action("admin_init", array($this, "nft_save_setting"));
add_action("admin_init", array($this, "custom_login_button_save_setting"));
add_action("admin_init", array($this, "toggle_role_mapping"));
add_action("admin_init", array($this, "save_role_mapping"));
add_action("admin_init", array($this, "save_custom_inline_form_settings"));
add_action("admin_init", array($this, "inline_form_toggle"));
add_action("wp", array($this, "initialize_token_gating_restriction"));
}
public function toggle_crypto_wallet_button_display()
{
if (!(isset($_POST["mo_web3_multiple_button_display_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_multiple_button_display_nonce"])), "mo_web3_multiple_button_display"))) {
goto Ja;
}
$Fx = array();
global $V8;
$ga = $V8->get_multiple_crypto_wallet();
foreach ($ga as $Ky => $V7) {
$WW = $V7["id"];
$qH = isset($_POST[$WW]) ? sanitize_text_field(wp_unslash($_POST[$WW])) : '';
$Fx[$WW] = $qH;
EM:
}
G4:
$this->utils->mo_web3_update_option("mo_web3_display_multiple_button", $Fx);
Ja:
}
public function inline_form_toggle()
{
global $V8;
if (!(isset($_POST["mo_web3_inline_form_display_toggle_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_inline_form_display_toggle_nonce"])), "mo_web3_inline_form_display_toggle"))) {
goto fd;
}
$ZX = isset($_POST["mo_web3_inline_form_display_toggle"]) ? sanitize_text_field(wp_unslash($_POST["mo_web3_inline_form_display_toggle"])) : '';
if ($ZX == "checked") {
goto sx;
}
$V8->mo_web3_update_option("mo_web3_inline_form_display_toggle", "unchecked");
goto AK;
sx:
$V8->mo_web3_update_option("mo_web3_inline_form_display_toggle", "checked");
AK:
fd:
}
public function save_custom_inline_form_settings()
{
if (!(isset($_POST["mo_web3_inline_form_config_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_inline_form_config_nonce"])), "mo_web3_inline_form_config"))) {
goto Lt;
}
global $V8;
$NI = isset($_POST["label"]) ? sizeof($_POST["label"]) : 0;
$Pd = array();
$dv = 0;
$AQ = 0;
dF:
if (!($AQ < $NI)) {
goto d5;
}
$Tr = false;
if (!("on" === sanitize_text_field($_POST["required"][$AQ + $dv + 1]))) {
goto NW;
}
$dv++;
$Tr = true;
NW:
$Pd[$AQ] = array("label" => sanitize_text_field($_POST["label"][$AQ]), "type" => sanitize_text_field($_POST["type"][$AQ]), "meta_key" => sanitize_text_field($_POST["meta_key"][$AQ]), "required" => $Tr);
pz:
$AQ++;
goto dF;
d5:
$V8->mo_web3_update_option("mo_web3_inline_form_settings", json_encode($Pd), true);
Lt:
}
public function is_curr_page_is_resricted_page($fL, $CC)
{
$Or = strlen($CC);
$jr = strpos($fL, $CC);
if (!($jr === false)) {
goto ia;
}
return 0;
ia:
return 1;
}
public function change_display_button_text()
{
if (!(isset($_POST["mo_web3_button_custom_text_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_button_custom_text_nonce"])), "mo_web3_button_custom_text"))) {
goto d6;
}
$Av = $_POST["mo_web3_button_custom_text"];
$this->utils->mo_web3_update_option("mo_web3_button_custom_text", $Av);
global $V8;
$V8->mo_web3_update_option(\MoWeb3Constants::PANEL_MESSAGE_OPTION, "Login Button Text Changed!");
$V8->mo_web3_show_success_message();
d6:
}
public function custom_login_button_save_setting()
{
global $V8;
if (!(isset($_POST["mo_web3_custom_login_button_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_custom_login_button_nonce"])), "mo_web3_custom_login_button"))) {
goto dP;
}
$vf = isset($_POST["moweb3CustomCss"]) ? $_POST["moweb3CustomCss"] : '';
$Av = $_POST["mo_web3_button_custom_text"];
$vf = trim($vf ?? '');
$V8->mo_web3_update_option("mo_web3_button_custom_text", $Av);
$V8->mo_web3_show_success_message();
if ('' == $vf || strlen($vf) < 5) {
goto l1;
}
$V8->mo_web3_update_option("mo_web3_login_button_custom_css", $vf);
goto Ln;
l1:
$V8->mo_web3_delete_option("mo_web3_login_button_custom_css");
Ln:
$V8->mo_web3_update_option(\MoWeb3Constants::PANEL_MESSAGE_OPTION, "Login Button Setting Saved!");
dP:
if (!(isset($_POST["mo_web3_custom_profile_completion_redirect_url_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_custom_profile_completion_redirect_url_nonce"])), "mo_web3_custom_profile_completion_redirect_url"))) {
goto tl;
}
$dq = sanitize_url($_POST["mo_web3_custom_profile_completion_redirect_url"], $Um = null);
$nT = false;
if (!isset($_POST["mo_web3_username_specification_check"])) {
goto Ep;
}
$nT = sanitize_text_field($_POST["mo_web3_username_specification_check"]);
Ep:
$V8->mo_web3_update_option("mo_web3_username_specification", $nT);
$V8->mo_web3_update_option("mo_web3_custom_profile_completion_redirect_url", $dq);
tl:
}
public function get_curr_page_ID()
{
$post = get_post();
return !empty($post) ? $post->ID : null;
}
public function get_curr_page_url()
{
$Ov = $this->get_curr_page_ID();
if ($Ov) {
goto tL;
}
return null;
tL:
$fL = get_permalink($Ov);
return $fL;
}
public function error_page_html()
{
$i2 .= '';
$i2 .= "<div style="text-align: center;">";
$i2 .= "<div>";
$i2 .= "<h1 style="font-size: 1000%; margin:0px;">403</h1>";
$i2 .= "<h1 style="font-size: 200%;margin-top:0px;">Forbidden</h1>";
$i2 .= "<p>Access to this page on server side is denied</p>";
$i2 .= "</div>";
$i2 .= "</div>";
return $i2;
}
public function display_crypto_button_for_token_gated_page($fL, $yh)
{
echo "<div style="display: flex;justify-content: center;align-items: center;height: 100%; ">";
$LZ = '';
$Av = '';
if (0 == $yh) {
goto dU;
}
global $V8;
$KG = $V8->mo_web3_get_option("mo_web3_button_custom_text");
$Av = $KG;
goto N0;
dU:
$Av = "Connect with Cryptowallet";
N0:
$LZ = "[mo_web3_login_button_shortcode redirection_url="" . $fL . "" text_color="black" button_text="" . $Av . ""]";
echo do_shortcode($LZ);
echo "</div>";
}
public function is_site_admin()
{
return in_array("administrator", wp_get_current_user()->roles);
}
public function initialize_token_gating_restriction()
{
global $V8;
$UQ = $V8->mo_web3_get_option("mo_web3_content_gating_config_details_store");
$fL = $V8->get_current_page_url();
if (!($UQ && $fL)) {
goto Ry;
}
foreach ($UQ as $Ky => $V7) {
$jm = $Ky;
$mC = $V7["errorURL"];
$mo = $this->is_curr_page_is_resricted_page($fL, $jm);
$I0 = get_current_user_id();
$z_ = get_user_meta($I0, "moweb3_wallet_address", true);
$Ky = $I0 . "_owned_nft";
$la = get_user_meta($I0, $Ky, true);
$la = json_decode($la, TRUE);
if (!$mo) {
goto BD;
}
if (is_user_logged_in()) {
goto sb;
}
$this->display_crypto_button_for_token_gated_page($fL, 1);
exit;
goto M7;
sb:
if (!$this->is_site_admin()) {
goto LF;
}
goto HK;
LF:
if (!empty($z_)) {
goto h0;
}
$this->display_crypto_button_for_token_gated_page($fL, 0);
exit;
h0:
$Iz = explode(",", $V7["contractAddressName"]);
$I0 = get_current_user_id();
$Ky = $I0 . "_owned_tokens";
$hD = get_user_meta($I0, $Ky, true);
if (!(is_null($hD) && wp_redirect($mC))) {
goto sX;
}
exit;
sX:
$F3 = false;
$AQ = 0;
Z0:
if (!($AQ < sizeof($Iz))) {
goto Ni;
}
$JC = $Iz[$AQ];
if (!isset($hD[$JC])) {
goto bJ;
}
$F3 = $F3 || $hD[$JC]["hasContentAccess"];
if (!$F3) {
goto uN;
}
goto Ni;
uN:
bJ:
wQ:
$AQ++;
goto Z0;
Ni:
if (!($F3 === false && wp_redirect($mC))) {
goto iu;
}
exit;
iu:
HK:
M7:
BD:
jy:
}
mX:
Ry:
}
public function login_wallet_restriction()
{
if (!(isset($_POST["mo_web3_login_wallet_restriction_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_login_wallet_restriction_nonce"])), "mo_web3_login_wallet_restriction"))) {
goto Wm;
}
$qH = isset($_POST["mo_web3_login_wallet_restriction"]) ? sanitize_text_field(wp_unslash($_POST["mo_web3_login_wallet_restriction"])) : '';
if ($qH == "checked") {
goto Bb;
}
$this->utils->mo_web3_update_option("mo_web3_login_wallet_restriction", "unchecked");
goto BF;
Bb:
$this->utils->mo_web3_update_option("mo_web3_login_wallet_restriction", "checked");
BF:
Wm:
}
public function toggle_display_button()
{
if (!(isset($_POST["mo_web3_button_display_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_button_display_nonce"])), "mo_web3_button_display"))) {
goto kx;
}
$qH = isset($_POST["mo_web3_button_check"]) ? sanitize_text_field(wp_unslash($_POST["mo_web3_button_check"])) : '';
if ($qH == "checked") {
goto ht;
}
$this->utils->mo_web3_update_option("mo_web3_display_login_button", "unchecked");
goto Gq;
ht:
$this->utils->mo_web3_update_option("mo_web3_display_login_button", "checked");
Gq:
kx:
}
public function toggle_role_mapping()
{
global $V8;
if (!(isset($_POST["mo_web3_enable_role_mapping_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_enable_role_mapping_nonce"])), "mo_web3_enable_role_mapping"))) {
goto VT;
}
$qH = isset($_POST["enable_role_mapping"]) ? sanitize_text_field(wp_unslash($_POST["enable_role_mapping"])) : false;
$Js = $V8->mo_web3_get_option("mo_web3_role_mapping");
$Js["enable_role_mapping"] = $qH;
$V8->mo_web3_update_option("mo_web3_role_mapping", $Js);
VT:
}
public function save_role_mapping()
{
global $V8;
if (!(isset($_POST["mo_web3_save_role_mapping_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_save_role_mapping_nonce"])), "mo_web3_save_role_mapping"))) {
goto zV;
}
$Js = $V8->mo_web3_get_option("mo_web3_role_mapping");
$Js["restrict_login_for_mapped_roles"] = isset($_POST["restrict_login_for_mapped_roles"]) ? sanitize_text_field(wp_unslash($_POST["restrict_login_for_mapped_roles"])) : false;
$Js["keep_existing_user_roles"] = isset($_POST["keep_existing_user_roles"]) ? sanitize_text_field(wp_unslash($_POST["keep_existing_user_roles"])) : false;
$Js["dont_disturb_existing_user_roles"] = isset($_POST["dont_disturb_existing_user_roles"]) ? sanitize_text_field(wp_unslash($_POST["dont_disturb_existing_user_roles"])) : false;
$Js["_mapping_value_default"] = isset($_POST["_mapping_value_default"]) ? sanitize_text_field(wp_unslash($_POST["_mapping_value_default"])) : "subscriber";
$gF = 100;
$qu = 0;
$sC = [];
if (!isset($_POST["mapping_key_"])) {
goto bZ;
}
$sC = array_map("sanitize_text_field", wp_unslash($_POST["mapping_key_"]));
bZ:
$fw = count($sC);
$h7 = 1;
$Bh = 1;
dt:
if (!($Bh <= $fw)) {
goto fE;
}
if (isset($_POST["mapping_key_"][$h7])) {
goto w4;
}
Su:
if (!($h7 < 100)) {
goto tt;
}
if (!isset($_POST["mapping_key_"][$h7])) {
goto V2;
}
if (!('' === $_POST["mapping_key_"][$h7]["value"])) {
goto bd;
}
$h7++;
goto Su;
bd:
$Js["_mapping_key_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["value"] : ''));
$Js["_mapping_value_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["role"] : ''));
$qu++;
$h7++;
goto tt;
V2:
$h7++;
goto Su;
tt:
goto Cf;
w4:
if (!('' === $_POST["mapping_key_"][$h7]["value"])) {
goto to;
}
$h7++;
goto m6;
to:
$Js["_mapping_key_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["value"] : ''));
$Js["_mapping_value_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["role"] : ''));
$h7++;
$qu++;
Cf:
m6:
$Bh++;
goto dt;
fE:
$Js["role_mapping_count"] = $qu;
$jZ = $V8->mo_web3_update_option("mo_web3_role_mapping", $Js);
zV:
}
public function nft_save_setting()
{
if (!(isset($_POST["mo_web3_content_restriction_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_content_restriction_nonce"])), "mo_web3_content_restriction"))) {
goto CW;
}
$Fw = isset($_POST["pageUrlRegex"]) ? $_POST["pageUrlRegex"] : [];
$HE = isset($_POST["contractAddress"]) ? $_POST["contractAddress"] : [];
$DA = isset($_POST["blockchain"]) ? $_POST["blockchain"] : [];
$mC = isset($_POST["errorUrl"]) ? $_POST["errorUrl"] : [];
$EA = array();
$Fw = array_values($Fw);
$HE = array_values($HE);
$DA = array_values($DA);
$mC = array_values($mC);
foreach ($Fw as $WZ => $Ky) {
$Ky = sanitize_text_field($Ky);
$EA[$Ky] = array("contractAddress" => explode(";", sanitize_text_field(wp_unslash($HE[$WZ]))), "blockchain" => sanitize_text_field(wp_unslash($DA[$WZ])), "errorUrl" => sanitize_text_field($mC[$WZ]));
MB:
}
hw:
$this->utils->mo_web3_update_option("mo_web3_nft_settings", $EA);
global $V8;
$V8->mo_web3_update_option(\MoWeb3Constants::PANEL_MESSAGE_OPTION, "NFT setting saved");
$V8->mo_web3_show_success_message();
CW:
}
public function hidden_form_data()
{
if (!(isset($_POST["mo_web3_hiddenform_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_hiddenform_nonce"])), "mo_web3_wp_nonce"))) {
goto gb;
}
$j1 = isset($_POST["nonce"]) ? sanitize_text_field(wp_unslash($_POST["nonce"])) : '';
$S_ = isset($_POST["address"]) ? sanitize_text_field(wp_unslash($_POST["address"])) : '';
$rL = isset($_POST["checkNft"]) ? sanitize_text_field(wp_unslash($_POST["checkNft"])) : '';
$NG = isset($_POST["contracts"]) ? json_decode(stripslashes($_POST["contracts"]), true) : '';
$XS = isset($_POST["tokenConfigResults"]) ? json_decode(stripslashes($_POST["tokenConfigResults"]), true) : '';
$sm = isset($_POST["redirectionUrl"]) ? sanitize_text_field(wp_unslash($_POST["redirectionUrl"])) : site_url();
$BC = isset($_POST["walletType"]) ? sanitize_text_field(stripslashes($_POST["walletType"])) : '';
$Kp = $this->utils->mo_web3_get_transient($S_);
if (!("SignedAuth" == $BC)) {
goto fa;
}
if (!($j1 != $Kp)) {
goto eL;
}
wp_send_json("Error in signature");
eL:
fa:
if (!$this->is_testing_wallet_address) {
goto iX;
}
$S_ = $this->is_testing_wallet_address;
iX:
$f4 = array("meta_key" => "moweb3_wallet_address", "meta_value" => $S_);
$user = false;
$Eh = is_user_logged_in();
$B6 = get_users($f4);
$sU = count($B6);
$yv = false;
if (0 == $sU && false === $Eh) {
goto db;
}
if ($sU > 1) {
goto Np;
}
$user = $B6[0];
goto Hi;
Np:
wp_send_json("Invalid Request");
Hi:
goto fs;
db:
$yv = true;
fs:
$Hv = '';
if (true === $Eh) {
goto XU;
}
if (!$yv) {
goto wG;
}
$user = $this->utils->mo_web3_get_user($S_);
wG:
if (!(false === $user)) {
goto sT;
}
apply_filters("mo_web3_no_wallet_redirect_url", false);
sT:
$Hv = $user->ID;
clean_user_cache($user->ID);
wp_clear_auth_cookie();
wp_set_current_user($user->ID);
wp_set_auth_cookie($user->ID, true);
update_user_caches($user);
do_action("wp_login", $user->data->user_login, $user);
goto Ug;
XU:
$sp = get_current_user_id();
$Hv = $sp;
if (!($user && $sp != $user->ID)) {
goto xi;
}
wp_send_json("Error: This wallet is already in use by another user.");
xi:
Ug:
update_user_meta($Hv, "moweb3_wallet_address", $S_);
$Ky = $Hv . "_owned_tokens";
update_user_meta($Hv, $Ky, $XS);
$this->apply_role_mapping($user, $NG);
do_action("mo_web3_ld_course_mapping", $XS);
do_action("mo_web3_wc_coupon_mapping", $XS);
do_action("mo_web3_bb_profile_mapping", $XS);
do_action("mo_web3_memberpress_membership_mapping", $XS);
if (!$yv) {
goto J8;
}
$yr = array("ID" => $user->ID);
$Pd = json_decode($this->utils->mo_web3_get_option("mo_web3_inline_form_settings"), true);
if (!is_array($Pd)) {
goto Ex;
}
foreach ($Pd as $Ky => $V7) {
if (!isset($_POST[$V7["meta_key"]])) {
goto Og;
}
if (in_array($V7["meta_key"], $this->utils->get_wp_user_profile_attributes())) {
goto TV;
}
update_user_meta($user->ID, $V7["meta_key"], sanitize_text_field($_POST[$V7["meta_key"]]));
goto sJ;
TV:
$yr[$V7["meta_key"]] = sanitize_text_field($_POST[$V7["meta_key"]]);
sJ:
Og:
R3:
}
mm:
$yr = wp_update_user($yr);
if (is_wp_error($yr)) {
goto D7;
}
goto Bi;
D7:
die;
Bi:
Ex:
$VE = $this->utils->mo_web3_get_option("mo_web3_custom_profile_completion_redirect_url");
if (!$VE) {
goto up;
}
wp_redirect($VE);
exit;
up:
J8:
do_action("mo_web3_check_banned_nicknames", $Hv);
if ($sm) {
goto w3;
}
wp_send_json("NOT ABLE TO REDIRECT");
goto rg;
w3:
wp_redirect($sm);
die;
rg:
exit;
gb:
}
public function apply_role_mapping($ws, $NG)
{
global $V8;
$Js = $V8->mo_web3_get_option("mo_web3_role_mapping");
if (!(!$this->is_new_user && isset($Js["keep_existing_user_roles"]) && true === boolval($Js["keep_existing_user_roles"]))) {
goto EO;
}
return;
EO:
$ws = new \WP_User($ws->ID);
if (!(isset($Js["enable_role_mapping"]) && !boolval($Js["enable_role_mapping"]))) {
goto Ao;
}
$ws->set_role('');
return;
Ao:
$UF = 0;
$RQ = isset($Js["role_mapping_count"]) ? intval($Js["role_mapping_count"]) : 0;
$Nt = [];
$AQ = 1;
eC:
if (!($AQ <= $RQ)) {
goto I2;
}
$k8 = isset($Js["_mapping_key_" . $AQ]) ? $Js["_mapping_key_" . $AQ] : '';
array_push($Nt, $k8);
foreach ($NG as $TE) {
$sb = explode(",", $k8);
$UJ = isset($Js["_mapping_value_" . $AQ]) ? $Js["_mapping_value_" . $AQ] : '';
if (!in_array($TE, $sb)) {
goto yF;
}
if (!$k8) {
goto c5;
}
if (!(0 === $UF)) {
goto wK;
}
if (!($this->is_new_user || isset($Js["dont_disturb_existing_user_roles"]) && !boolval($Js["dont_disturb_existing_user_roles"]))) {
goto CX;
}
$ws->set_role('');
CX:
wK:
$ws->add_role($UJ);
$UF++;
c5:
yF:
wN:
}
uH:
ss:
$AQ++;
goto eC;
I2:
if (!(0 === $UF && isset($Js["_mapping_value_default"]) && '' !== $Js["_mapping_value_default"])) {
goto hv;
}
$ws->set_role($Js["_mapping_value_default"]);
hv:
$dw = 0;
if (!(isset($Js["restrict_login_for_mapped_roles"]) && boolval($Js["restrict_login_for_mapped_roles"]))) {
goto iy;
}
foreach ($NG as $TE) {
if (!in_array($TE, $Nt, true)) {
goto E7;
}
$dw = 1;
E7:
mk:
}
Nf:
if (!($dw !== 1)) {
goto w1;
}
require_once ABSPATH . "wp-admin/includes/user.php";
\wp_delete_user($ws->ID);
$kR = "You do not have permissions to login with your current roles. Please contact the Administrator.";
wp_die($kR);
w1:
iy:
}
public function get_solana_api_data($z_, $Lr, $M8)
{
$Bb = null;
$hF = null;
$f4 = array("headers" => array("Content-Type" => "application/json", "Authorization" => \MoWeb3Constants::NFT_PORT_AUTHORIZATION_Key));
if ("solanaMintAddress" == $Lr) {
goto Ms;
}
if (!("solanaCollectionID" == $Lr || "solanaCollectionKey" == $Lr)) {
goto fm;
}
$Bb = \MoWeb3Constants::NFT_PORT_API . "solana/nfts/{$M8}";
fm:
goto jt;
Ms:
$Bb = \MoWeb3Constants::NFT_PORT_API . "solana/nft/{$M8}";
jt:
$hF = wp_remote_get($Bb, $f4);
return $hF;
}
public function get_token_data_through_api($vN, $z_, $YV, $Lr = null, $M8 = null)
{
$Bb = null;
$YV = strtolower($YV);
$hF = null;
switch ($YV) {
case "solana":
$hF = $this->get_solana_api_data($z_, $Lr, $M8);
goto Uf;
default:
$hF = array("error" => "invalid case!!");
wp_send_json_error($hF, 500);
}
o0:
Uf:
if (!is_wp_error($hF)) {
goto sH;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
sH:
$hF = wp_remote_retrieve_body($hF);
wp_send_json($hF);
}
public function get_cronos_balance($z_, $vN)
{
$Bb = null;
$hF = null;
$Bb = \MoWeb3Constants::CRONOS_SCAN_API . "&contractaddress={$vN}&address={$z_}&tag=latest&apikey=" . \MoWeb3Constants::CRONOS_SCAN_API_KEY;
$hF = wp_remote_get($Bb);
if (!is_wp_error($hF)) {
goto fv;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
fv:
$hF = wp_remote_retrieve_body($hF);
wp_send_json($hF);
}
public function type_of_request()
{
if (!(wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST["mo_web3_verify_nonce"])), "mo_web3_wp_nonce") && isset($_REQUEST["request"]))) {
goto q_;
}
$cr = sanitize_text_field(wp_unslash($_REQUEST["request"]));
if ($cr == "login") {
goto Kf;
}
if ($cr == "auth") {
goto hx;
}
if ($cr == "checkInputFields") {
goto oS;
}
if ($cr == "getAdminConfiguredNftData") {
goto tJ;
}
if ($cr == "getUserHoldNFTData") {
goto Oh;
}
if ($cr == "showNftData") {
goto ES;
}
if ("get_configuration" == $cr) {
goto kp;
}
if ("getAlgorandBalance" == $cr) {
goto VY;
}
if ("getSolanaTokenDetails" == $cr) {
goto He;
}
if ("getLoopringBalance" == $cr) {
goto i3;
}
if ("getCronosBalance" == $cr) {
goto mq;
}
goto dX;
Kf:
$this->handle_login_request();
goto dX;
hx:
$this->handle_auth_request();
goto dX;
oS:
$this->check_input_fields();
goto dX;
tJ:
$this->get_admin_configured_nft_data();
goto dX;
Oh:
$vN = isset($_REQUEST["contractAddresses"]) ? sanitize_text_field(wp_unslash($_REQUEST["contractAddresses"])) : null;
$YV = isset($_REQUEST["blockchain"]) ? sanitize_text_field(wp_unslash($_REQUEST["blockchain"])) : null;
$z_ = isset($_REQUEST["wallet_address"]) ? sanitize_text_field(wp_unslash($_REQUEST["wallet_address"])) : null;
$W0 = isset($_REQUEST["isMultipleToken"]) ? sanitize_text_field(wp_unslash($_REQUEST["isMultipleToken"])) : null;
$AE = isset($_REQUEST["pageKey"]) ? sanitize_text_field(wp_unslash($_REQUEST["pageKey"])) : null;
$this->get_user_nft_using_api($vN, $z_, $YV, $W0, $AE);
goto dX;
ES:
$ui = $_REQUEST["nftDataUri"];
$this->display_nft_data($ui);
goto dX;
kp:
$this->get_configuration();
goto dX;
VY:
$z_ = sanitize_text_field(wp_unslash($_REQUEST["walletAddress"]));
$Dj = sanitize_text_field(wp_unslash($_REQUEST["tokenID"]));
$this->get_algorand_balance($z_, $Dj);
goto dX;
He:
$z_ = isset($_POST["walletAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["walletAddress"])) : null;
$pM = isset($_POST["fieldValue"]) ? sanitize_text_field(wp_unslash($_REQUEST["fieldValue"])) : null;
$tm = isset($_POST["fieldKey"]) ? sanitize_text_field(wp_unslash($_REQUEST["fieldKey"])) : null;
$YV = "solana";
$this->get_token_data_through_api(null, $z_, $YV, $tm, $pM);
goto dX;
i3:
$z_ = isset($_POST["walletAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["walletAddress"])) : null;
$vN = isset($_POST["contractAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["contractAddress"])) : null;
$Dj = isset($_POST["tokenIDs"]) ? sanitize_text_field(wp_unslash($_REQUEST["tokenIDs"])) : null;
$zR = $this->getLoopringAccountID($z_);
$this->get_loopring_balance($z_, $vN, $Dj, $zR);
goto dX;
mq:
$z_ = isset($_POST["walletAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["walletAddress"])) : null;
$vN = isset($_POST["contractAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["contractAddress"])) : null;
$this->get_cronos_balance($z_, $vN);
dX:
q_:
}
public function get_algorand_balance($z_, $Dj)
{
$Bb = \MoWeb3Constants::ALGORAND_API . "{$z_}/assets/{$Dj}";
$this->display_nft_data($Bb);
}
public function getLoopringAccountID($z_)
{
global $V8;
$zR = $V8->mo_web3_get_option("mo_lp_" . $z_);
if ($zR) {
goto Gw;
}
$Bb = \MoWeb3Constants::LOOPRING_API . "account?owner={$z_}";
$hF = wp_remote_get($Bb);
if (!is_wp_error($hF)) {
goto lk;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
lk:
$hF = wp_remote_retrieve_body($hF);
$hF = json_decode($hF);
$zR = $hF->accountId;
$V8->mo_web3_update_option("mo_lp_" . $z_, $zR);
Gw:
return $zR;
}
public function get_loopring_balance($z_, $vN, $i8, $zR)
{
global $V8;
$vC = $V8->mo_web3_get_option("mo_web3_loopring_api_key");
$f4 = array("headers" => array("X-API-KEY" => $vC));
$yX = 0;
$Mv = 0;
HY:
$Bb = \MoWeb3Constants::LOOPRING_API . "user/nft/balances?accountId={$zR}&tokenAddrs={$vN}&offset={$yX}&limit=100";
$hF = wp_remote_get($Bb, $f4);
if (!is_wp_error($hF)) {
goto zC;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
zC:
$hF = wp_remote_retrieve_body($hF);
$hF = json_decode($hF);
$vA = $hF->totalNum;
$hF = $hF->data;
$vN = strtolower($vN);
if (false == $V8->mo_web3_check_empty_or_null($i8)) {
goto vB;
}
foreach ($hF as $ox) {
$ox->tokenAddress = strtolower($ox->tokenAddress);
if (!($ox->tokenAddress == $vN)) {
goto Gx;
}
$Mv = $Mv + $ox->total;
Gx:
V8:
}
h1:
goto Uo;
vB:
$i8 = explode(",", $i8);
foreach ($i8 as $Dj) {
foreach ($hF as $ox) {
if (!($Dj == $ox->nftId)) {
goto cT;
}
$Mv = $Mv + $ox->total;
cT:
C7:
}
YI:
mv:
}
qs:
Uo:
$yX = $yX + 100;
if ($yX <= $vA) {
goto HY;
}
Cm:
wp_send_json($Mv);
}
public function get_configuration()
{
$S_ = isset($_REQUEST["address"]) ? sanitize_text_field(wp_unslash($_REQUEST["address"])) : '';
$pA = $this->utils->mo_web3_get_option("mo_web3_nft_settings");
$J4 = $this->utils->mo_web3_get_option("mo_web3_token_config_details_store");
$GW = $this->utils->mo_web3_get_option("mo_web3_role_mapping");
$xl = $this->utils->mo_web3_get_option("mo_web3_inline_form_settings");
if (!($pA && !is_null($pA))) {
goto Pr;
}
$hF["adminNftSetting"] = $pA;
Pr:
if (!($J4 && !is_null($J4))) {
goto i4;
}
$hF["tokenConfigDetails"] = $J4;
i4:
$yy = md5($S_);
$yx = false;
if (is_user_logged_in()) {
goto ya;
}
$yx = username_exists($S_) ? false : (username_exists($yy) ? false : true);
ya:
$hk = $this->utils->mo_web3_get_option("mo_web3_custom_profile_completion_redirect_url");
if (filter_var($hk, FILTER_VALIDATE_URL)) {
goto fc;
}
$hF["custom_profile_completion_redirect_url"] = null;
goto qG;
fc:
$hF["custom_profile_completion_redirect_url"] = $hk;
qG:
$hF["newUserRegisteration"] = $yx;
$hF["roleMappingSetting"] = $GW;
$hF["inlineFormSetting"] = json_decode($xl);
$hF["inline_form_toggle"] = $this->utils->mo_web3_get_option("mo_web3_inline_form_display_toggle");
wp_send_json($hF);
}
public function display_nft_data($ui)
{
$aw = wp_remote_get($ui);
$aw = wp_remote_retrieve_body($aw);
wp_send_json($aw);
}
public function get_admin_configured_nft_data()
{
$pA = $this->utils->mo_web3_get_option("mo_web3_nft_settings");
wp_send_json($pA);
}
public function get_user_nft_using_api($vN, $z_, $YV, $W0, $AE)
{
$f4 = array("headers" => array("Content-Type" => "application/json", "Authorization" => \MoWeb3Constants::NFT_PORT_AUTHORIZATION_Key));
$YV = strtolower($YV);
$Bb = '';
if ("ethereum" == $YV || "polygon" == $YV) {
goto kJ;
}
if ("algorand" == $YV) {
goto Rr;
}
if (!("solana" == $YV)) {
goto Hn;
}
$Bb = \MoWeb3Constants::MORALIS_SOLANA_API . "/account/mainnet/{$z_}/nft";
$f4["headers"]["X-API-Key"] = \MoWeb3Constants::MORALIS_API_Key;
$f4["headers"]["accept"] = "application/json";
$hF = wp_remote_get($Bb, $f4);
Hn:
goto jR;
Rr:
$Bb = \MoWeb3Constants::ALGORAND_API . "{$z_}";
$hF = wp_remote_get($Bb);
jR:
goto MK;
kJ:
if ($W0) {
goto xA;
}
$Bb = \MoWeb3Constants::NFT_PORT_API . $z_ . "?chain=" . $YV . "&contract_address=" . $vN;
goto vS;
xA:
$Bb = \MoWeb3Constants::ALCHEMY_API_ETH . "getNFTs?owner={$z_}&contractAddresses={$vN}&withMetadata=false";
if (!("polygon" == $YV)) {
goto Mi;
}
$Bb = \MoWeb3Constants::ALCHEMY_API_POLYGON . "getNFTs?owner={$z_}&contractAddresses={$vN}&withMetadata=false";
Mi:
if (!$AE) {
goto g3;
}
$Bb = $Bb . "&pageKey={$AE}";
g3:
vS:
$hF = wp_remote_get($Bb, $f4);
MK:
if (!is_wp_error($hF)) {
goto Gm;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
Gm:
$hF = wp_remote_retrieve_body($hF);
wp_send_json($hF);
}
public function check_for_valid_nickname($lw)
{
$kI = $this->utils->mo_web3_get_option("mo_web3_allow_unique_nickname");
if (!("checked" === $kI)) {
goto cV;
}
$bR = get_users(array("fields" => array("display_name")));
foreach ($bR as $PD) {
$PD = $PD->display_name;
if (!($lw === $PD)) {
goto V1;
}
wp_send_json("duplicate display name");
V1:
MD:
}
ZE:
cV:
$Ha = $this->utils->mo_web3_get_option("mo_web3_banned_nicknames");
foreach ($Ha as $Pv) {
if (!str_contains($lw, $Pv)) {
goto sp;
}
wp_send_json("invalid display name");
sp:
yf:
}
pe:
}
public function check_input_fields()
{
$yB = isset($_REQUEST["email"]) ? sanitize_text_field(wp_unslash($_REQUEST["email"])) : '';
$EA = email_exists($yB);
$lw = isset($_REQUEST["display_name"]) ? sanitize_text_field(wp_unslash($_REQUEST["display_name"])) : '';
if (!$EA) {
goto WA;
}
wp_send_json("duplicate email");
WA:
$this->check_for_valid_nickname($lw);
if ($EA) {
goto te;
}
wp_send_json("success");
te:
}
public function handle_login_request()
{
$S_ = isset($_REQUEST["address"]) ? sanitize_text_field(wp_unslash($_REQUEST["address"])) : '';
$j1 = $this->utils->mo_web3_get_transient($S_);
if ($j1) {
goto Dr;
}
$j1 = uniqid();
$RP = 24 * 60 * 60;
$this->utils->mo_web3_set_transient($S_, $j1, $RP);
wp_send_json("Sign this message to validate that you are the owner of the account. Random string: " . $j1);
goto K1;
Dr:
wp_send_json("Sign this message to validate that you are the owner of the account. Random string: " . $j1);
K1:
}
public function pub_key_to_address($Y7)
{
return "0x" . substr(Keccak::hash(substr(hex2bin($Y7->encode("hex")), 1), 256), 24);
}
public function verify_signature($Oi, $ed, $S_)
{
$cB = strlen($Oi);
$Xl = Keccak::hash("Ethereum Signed Message:
{$cB}{$Oi}", 256);
$h5 = ["r" => substr($ed, 2, 64), "s" => substr($ed, 66, 64)];
$jW = ord(hex2bin(substr($ed, 130, 2))) - 27;
if (!($jW != ($jW & 1))) {
goto d9;
}
if (preg_match("/00$/", $ed)) {
goto wi;
}
if (preg_match("/01$/", $ed)) {
goto JH;
}
return 0;
goto uJ;
JH:
$jW = 1;
uJ:
goto c2;
wi:
$jW = 0;
c2:
d9:
$Sf = new EC("secp256k1");
$Y7 = $Sf->recoverPubKey($Xl, $h5, $jW);
return $S_ == $this->pub_key_to_address($Y7);
}
public function handle_auth_request()
{
$S_ = isset($_REQUEST["address"]) ? sanitize_text_field(wp_unslash($_REQUEST["address"])) : '';
$ed = isset($_REQUEST["signature"]) ? sanitize_text_field(wp_unslash($_REQUEST["signature"])) : '';
$tl = isset($_REQUEST["wallet_restriction"]) ? sanitize_text_field(wp_unslash($_REQUEST["wallet_restriction"])) : '';
$j1 = $this->utils->mo_web3_get_transient($S_);
$Oi = "Sign this message to validate that you are the owner of the account. Random string: " . $j1;
if ($this->verify_signature($Oi, $ed, $S_)) {
goto X0;
}
$hF = array("isSignatureVerified" => 0, "nonce" => null);
wp_send_json($hF);
goto Uc;
X0:
$j1 = uniqid();
$RP = 24 * 60 * 60;
$this->utils->mo_web3_set_transient($S_, $j1, $RP);
$hF = array("isSignatureVerified" => 1, "nonce" => $j1);
$bL = $this->utils->mo_web3_get_option("mo_web3_login_wallet_restriction");
if (!($bL === "checked" && $tl === "false")) {
goto Td;
}
$hF["error"] = "Only metamask wallet allowed";
Td:
wp_send_json($hF);
Uc:
}
}
?>
Did this file decode correctly?
Original Code
<?php
namespace MoWeb3\controller;
require_once realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "Keccak" . DIRECTORY_SEPARATOR . "Keccak.php");
require_once realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "Elliptic" . DIRECTORY_SEPARATOR . "EC.php");
require_once realpath(dirname(__FILE__) . DIRECTORY_SEPARATOR . ".." . DIRECTORY_SEPARATOR . "lib" . DIRECTORY_SEPARATOR . "Elliptic" . DIRECTORY_SEPARATOR . "Curves.php");
use Elliptic\EC;
use kornrunner\Keccak;
use MoWeb3\MoWeb3Utils;
use MoWeb3View\ButtonView\MoWeb3View;
class MoWeb3FlowHandler
{
private $data;
private $request;
private $utils;
private $is_new_user;
public $is_testing_wallet_address = false;
public function __construct()
{
$this->utils = new \MoWeb3\MoWeb3Utils();
add_action("wp_ajax_nopriv_type_of_request", array($this, "type_of_request"));
add_action("wp_ajax_type_of_request", array($this, "type_of_request"));
add_action("init", array($this, "hidden_form_data"));
add_action("admin_init", array($this, "toggle_display_button"));
add_action("admin_init", array($this, "toggle_crypto_wallet_button_display"));
add_action("admin_init", array($this, "login_wallet_restriction"));
add_action("admin_init", array($this, "change_display_button_text"));
add_action("admin_init", array($this, "nft_save_setting"));
add_action("admin_init", array($this, "custom_login_button_save_setting"));
add_action("admin_init", array($this, "toggle_role_mapping"));
add_action("admin_init", array($this, "save_role_mapping"));
add_action("admin_init", array($this, "save_custom_inline_form_settings"));
add_action("admin_init", array($this, "inline_form_toggle"));
add_action("wp", array($this, "initialize_token_gating_restriction"));
}
public function toggle_crypto_wallet_button_display()
{
if (!(isset($_POST["mo_web3_multiple_button_display_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_multiple_button_display_nonce"])), "mo_web3_multiple_button_display"))) {
goto Ja;
}
$Fx = array();
global $V8;
$ga = $V8->get_multiple_crypto_wallet();
foreach ($ga as $Ky => $V7) {
$WW = $V7["id"];
$qH = isset($_POST[$WW]) ? sanitize_text_field(wp_unslash($_POST[$WW])) : '';
$Fx[$WW] = $qH;
EM:
}
G4:
$this->utils->mo_web3_update_option("mo_web3_display_multiple_button", $Fx);
Ja:
}
public function inline_form_toggle()
{
global $V8;
if (!(isset($_POST["mo_web3_inline_form_display_toggle_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_inline_form_display_toggle_nonce"])), "mo_web3_inline_form_display_toggle"))) {
goto fd;
}
$ZX = isset($_POST["mo_web3_inline_form_display_toggle"]) ? sanitize_text_field(wp_unslash($_POST["mo_web3_inline_form_display_toggle"])) : '';
if ($ZX == "checked") {
goto sx;
}
$V8->mo_web3_update_option("mo_web3_inline_form_display_toggle", "unchecked");
goto AK;
sx:
$V8->mo_web3_update_option("mo_web3_inline_form_display_toggle", "checked");
AK:
fd:
}
public function save_custom_inline_form_settings()
{
if (!(isset($_POST["mo_web3_inline_form_config_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_inline_form_config_nonce"])), "mo_web3_inline_form_config"))) {
goto Lt;
}
global $V8;
$NI = isset($_POST["label"]) ? sizeof($_POST["label"]) : 0;
$Pd = array();
$dv = 0;
$AQ = 0;
dF:
if (!($AQ < $NI)) {
goto d5;
}
$Tr = false;
if (!("on" === sanitize_text_field($_POST["required"][$AQ + $dv + 1]))) {
goto NW;
}
$dv++;
$Tr = true;
NW:
$Pd[$AQ] = array("label" => sanitize_text_field($_POST["label"][$AQ]), "type" => sanitize_text_field($_POST["type"][$AQ]), "meta_key" => sanitize_text_field($_POST["meta_key"][$AQ]), "required" => $Tr);
pz:
$AQ++;
goto dF;
d5:
$V8->mo_web3_update_option("mo_web3_inline_form_settings", json_encode($Pd), true);
Lt:
}
public function is_curr_page_is_resricted_page($fL, $CC)
{
$Or = strlen($CC);
$jr = strpos($fL, $CC);
if (!($jr === false)) {
goto ia;
}
return 0;
ia:
return 1;
}
public function change_display_button_text()
{
if (!(isset($_POST["mo_web3_button_custom_text_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_button_custom_text_nonce"])), "mo_web3_button_custom_text"))) {
goto d6;
}
$Av = $_POST["mo_web3_button_custom_text"];
$this->utils->mo_web3_update_option("mo_web3_button_custom_text", $Av);
global $V8;
$V8->mo_web3_update_option(\MoWeb3Constants::PANEL_MESSAGE_OPTION, "Login Button Text Changed!");
$V8->mo_web3_show_success_message();
d6:
}
public function custom_login_button_save_setting()
{
global $V8;
if (!(isset($_POST["mo_web3_custom_login_button_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_custom_login_button_nonce"])), "mo_web3_custom_login_button"))) {
goto dP;
}
$vf = isset($_POST["moweb3CustomCss"]) ? $_POST["moweb3CustomCss"] : '';
$Av = $_POST["mo_web3_button_custom_text"];
$vf = trim($vf ?? '');
$V8->mo_web3_update_option("mo_web3_button_custom_text", $Av);
$V8->mo_web3_show_success_message();
if ('' == $vf || strlen($vf) < 5) {
goto l1;
}
$V8->mo_web3_update_option("mo_web3_login_button_custom_css", $vf);
goto Ln;
l1:
$V8->mo_web3_delete_option("mo_web3_login_button_custom_css");
Ln:
$V8->mo_web3_update_option(\MoWeb3Constants::PANEL_MESSAGE_OPTION, "Login Button Setting Saved!");
dP:
if (!(isset($_POST["mo_web3_custom_profile_completion_redirect_url_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_custom_profile_completion_redirect_url_nonce"])), "mo_web3_custom_profile_completion_redirect_url"))) {
goto tl;
}
$dq = sanitize_url($_POST["mo_web3_custom_profile_completion_redirect_url"], $Um = null);
$nT = false;
if (!isset($_POST["mo_web3_username_specification_check"])) {
goto Ep;
}
$nT = sanitize_text_field($_POST["mo_web3_username_specification_check"]);
Ep:
$V8->mo_web3_update_option("mo_web3_username_specification", $nT);
$V8->mo_web3_update_option("mo_web3_custom_profile_completion_redirect_url", $dq);
tl:
}
public function get_curr_page_ID()
{
$post = get_post();
return !empty($post) ? $post->ID : null;
}
public function get_curr_page_url()
{
$Ov = $this->get_curr_page_ID();
if ($Ov) {
goto tL;
}
return null;
tL:
$fL = get_permalink($Ov);
return $fL;
}
public function error_page_html()
{
$i2 .= '';
$i2 .= "<div style="text-align: center;">";
$i2 .= "<div>";
$i2 .= "<h1 style="font-size: 1000%; margin:0px;">403</h1>";
$i2 .= "<h1 style="font-size: 200%;margin-top:0px;">Forbidden</h1>";
$i2 .= "<p>Access to this page on server side is denied</p>";
$i2 .= "</div>";
$i2 .= "</div>";
return $i2;
}
public function display_crypto_button_for_token_gated_page($fL, $yh)
{
echo "<div style="display: flex;justify-content: center;align-items: center;height: 100%; ">";
$LZ = '';
$Av = '';
if (0 == $yh) {
goto dU;
}
global $V8;
$KG = $V8->mo_web3_get_option("mo_web3_button_custom_text");
$Av = $KG;
goto N0;
dU:
$Av = "Connect with Cryptowallet";
N0:
$LZ = "[mo_web3_login_button_shortcode redirection_url="" . $fL . "" text_color="black" button_text="" . $Av . ""]";
echo do_shortcode($LZ);
echo "</div>";
}
public function is_site_admin()
{
return in_array("administrator", wp_get_current_user()->roles);
}
public function initialize_token_gating_restriction()
{
global $V8;
$UQ = $V8->mo_web3_get_option("mo_web3_content_gating_config_details_store");
$fL = $V8->get_current_page_url();
if (!($UQ && $fL)) {
goto Ry;
}
foreach ($UQ as $Ky => $V7) {
$jm = $Ky;
$mC = $V7["errorURL"];
$mo = $this->is_curr_page_is_resricted_page($fL, $jm);
$I0 = get_current_user_id();
$z_ = get_user_meta($I0, "moweb3_wallet_address", true);
$Ky = $I0 . "_owned_nft";
$la = get_user_meta($I0, $Ky, true);
$la = json_decode($la, TRUE);
if (!$mo) {
goto BD;
}
if (is_user_logged_in()) {
goto sb;
}
$this->display_crypto_button_for_token_gated_page($fL, 1);
exit;
goto M7;
sb:
if (!$this->is_site_admin()) {
goto LF;
}
goto HK;
LF:
if (!empty($z_)) {
goto h0;
}
$this->display_crypto_button_for_token_gated_page($fL, 0);
exit;
h0:
$Iz = explode(",", $V7["contractAddressName"]);
$I0 = get_current_user_id();
$Ky = $I0 . "_owned_tokens";
$hD = get_user_meta($I0, $Ky, true);
if (!(is_null($hD) && wp_redirect($mC))) {
goto sX;
}
exit;
sX:
$F3 = false;
$AQ = 0;
Z0:
if (!($AQ < sizeof($Iz))) {
goto Ni;
}
$JC = $Iz[$AQ];
if (!isset($hD[$JC])) {
goto bJ;
}
$F3 = $F3 || $hD[$JC]["hasContentAccess"];
if (!$F3) {
goto uN;
}
goto Ni;
uN:
bJ:
wQ:
$AQ++;
goto Z0;
Ni:
if (!($F3 === false && wp_redirect($mC))) {
goto iu;
}
exit;
iu:
HK:
M7:
BD:
jy:
}
mX:
Ry:
}
public function login_wallet_restriction()
{
if (!(isset($_POST["mo_web3_login_wallet_restriction_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_login_wallet_restriction_nonce"])), "mo_web3_login_wallet_restriction"))) {
goto Wm;
}
$qH = isset($_POST["mo_web3_login_wallet_restriction"]) ? sanitize_text_field(wp_unslash($_POST["mo_web3_login_wallet_restriction"])) : '';
if ($qH == "checked") {
goto Bb;
}
$this->utils->mo_web3_update_option("mo_web3_login_wallet_restriction", "unchecked");
goto BF;
Bb:
$this->utils->mo_web3_update_option("mo_web3_login_wallet_restriction", "checked");
BF:
Wm:
}
public function toggle_display_button()
{
if (!(isset($_POST["mo_web3_button_display_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_button_display_nonce"])), "mo_web3_button_display"))) {
goto kx;
}
$qH = isset($_POST["mo_web3_button_check"]) ? sanitize_text_field(wp_unslash($_POST["mo_web3_button_check"])) : '';
if ($qH == "checked") {
goto ht;
}
$this->utils->mo_web3_update_option("mo_web3_display_login_button", "unchecked");
goto Gq;
ht:
$this->utils->mo_web3_update_option("mo_web3_display_login_button", "checked");
Gq:
kx:
}
public function toggle_role_mapping()
{
global $V8;
if (!(isset($_POST["mo_web3_enable_role_mapping_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_enable_role_mapping_nonce"])), "mo_web3_enable_role_mapping"))) {
goto VT;
}
$qH = isset($_POST["enable_role_mapping"]) ? sanitize_text_field(wp_unslash($_POST["enable_role_mapping"])) : false;
$Js = $V8->mo_web3_get_option("mo_web3_role_mapping");
$Js["enable_role_mapping"] = $qH;
$V8->mo_web3_update_option("mo_web3_role_mapping", $Js);
VT:
}
public function save_role_mapping()
{
global $V8;
if (!(isset($_POST["mo_web3_save_role_mapping_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_save_role_mapping_nonce"])), "mo_web3_save_role_mapping"))) {
goto zV;
}
$Js = $V8->mo_web3_get_option("mo_web3_role_mapping");
$Js["restrict_login_for_mapped_roles"] = isset($_POST["restrict_login_for_mapped_roles"]) ? sanitize_text_field(wp_unslash($_POST["restrict_login_for_mapped_roles"])) : false;
$Js["keep_existing_user_roles"] = isset($_POST["keep_existing_user_roles"]) ? sanitize_text_field(wp_unslash($_POST["keep_existing_user_roles"])) : false;
$Js["dont_disturb_existing_user_roles"] = isset($_POST["dont_disturb_existing_user_roles"]) ? sanitize_text_field(wp_unslash($_POST["dont_disturb_existing_user_roles"])) : false;
$Js["_mapping_value_default"] = isset($_POST["_mapping_value_default"]) ? sanitize_text_field(wp_unslash($_POST["_mapping_value_default"])) : "subscriber";
$gF = 100;
$qu = 0;
$sC = [];
if (!isset($_POST["mapping_key_"])) {
goto bZ;
}
$sC = array_map("sanitize_text_field", wp_unslash($_POST["mapping_key_"]));
bZ:
$fw = count($sC);
$h7 = 1;
$Bh = 1;
dt:
if (!($Bh <= $fw)) {
goto fE;
}
if (isset($_POST["mapping_key_"][$h7])) {
goto w4;
}
Su:
if (!($h7 < 100)) {
goto tt;
}
if (!isset($_POST["mapping_key_"][$h7])) {
goto V2;
}
if (!('' === $_POST["mapping_key_"][$h7]["value"])) {
goto bd;
}
$h7++;
goto Su;
bd:
$Js["_mapping_key_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["value"] : ''));
$Js["_mapping_value_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["role"] : ''));
$qu++;
$h7++;
goto tt;
V2:
$h7++;
goto Su;
tt:
goto Cf;
w4:
if (!('' === $_POST["mapping_key_"][$h7]["value"])) {
goto to;
}
$h7++;
goto m6;
to:
$Js["_mapping_key_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["value"] : ''));
$Js["_mapping_value_" . $Bh] = sanitize_text_field(wp_unslash(isset($_POST["mapping_key_"][$h7]) ? $_POST["mapping_key_"][$h7]["role"] : ''));
$h7++;
$qu++;
Cf:
m6:
$Bh++;
goto dt;
fE:
$Js["role_mapping_count"] = $qu;
$jZ = $V8->mo_web3_update_option("mo_web3_role_mapping", $Js);
zV:
}
public function nft_save_setting()
{
if (!(isset($_POST["mo_web3_content_restriction_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_content_restriction_nonce"])), "mo_web3_content_restriction"))) {
goto CW;
}
$Fw = isset($_POST["pageUrlRegex"]) ? $_POST["pageUrlRegex"] : [];
$HE = isset($_POST["contractAddress"]) ? $_POST["contractAddress"] : [];
$DA = isset($_POST["blockchain"]) ? $_POST["blockchain"] : [];
$mC = isset($_POST["errorUrl"]) ? $_POST["errorUrl"] : [];
$EA = array();
$Fw = array_values($Fw);
$HE = array_values($HE);
$DA = array_values($DA);
$mC = array_values($mC);
foreach ($Fw as $WZ => $Ky) {
$Ky = sanitize_text_field($Ky);
$EA[$Ky] = array("contractAddress" => explode(";", sanitize_text_field(wp_unslash($HE[$WZ]))), "blockchain" => sanitize_text_field(wp_unslash($DA[$WZ])), "errorUrl" => sanitize_text_field($mC[$WZ]));
MB:
}
hw:
$this->utils->mo_web3_update_option("mo_web3_nft_settings", $EA);
global $V8;
$V8->mo_web3_update_option(\MoWeb3Constants::PANEL_MESSAGE_OPTION, "NFT setting saved");
$V8->mo_web3_show_success_message();
CW:
}
public function hidden_form_data()
{
if (!(isset($_POST["mo_web3_hiddenform_nonce"]) && wp_verify_nonce(sanitize_text_field(wp_unslash($_POST["mo_web3_hiddenform_nonce"])), "mo_web3_wp_nonce"))) {
goto gb;
}
$j1 = isset($_POST["nonce"]) ? sanitize_text_field(wp_unslash($_POST["nonce"])) : '';
$S_ = isset($_POST["address"]) ? sanitize_text_field(wp_unslash($_POST["address"])) : '';
$rL = isset($_POST["checkNft"]) ? sanitize_text_field(wp_unslash($_POST["checkNft"])) : '';
$NG = isset($_POST["contracts"]) ? json_decode(stripslashes($_POST["contracts"]), true) : '';
$XS = isset($_POST["tokenConfigResults"]) ? json_decode(stripslashes($_POST["tokenConfigResults"]), true) : '';
$sm = isset($_POST["redirectionUrl"]) ? sanitize_text_field(wp_unslash($_POST["redirectionUrl"])) : site_url();
$BC = isset($_POST["walletType"]) ? sanitize_text_field(stripslashes($_POST["walletType"])) : '';
$Kp = $this->utils->mo_web3_get_transient($S_);
if (!("SignedAuth" == $BC)) {
goto fa;
}
if (!($j1 != $Kp)) {
goto eL;
}
wp_send_json("Error in signature");
eL:
fa:
if (!$this->is_testing_wallet_address) {
goto iX;
}
$S_ = $this->is_testing_wallet_address;
iX:
$f4 = array("meta_key" => "moweb3_wallet_address", "meta_value" => $S_);
$user = false;
$Eh = is_user_logged_in();
$B6 = get_users($f4);
$sU = count($B6);
$yv = false;
if (0 == $sU && false === $Eh) {
goto db;
}
if ($sU > 1) {
goto Np;
}
$user = $B6[0];
goto Hi;
Np:
wp_send_json("Invalid Request");
Hi:
goto fs;
db:
$yv = true;
fs:
$Hv = '';
if (true === $Eh) {
goto XU;
}
if (!$yv) {
goto wG;
}
$user = $this->utils->mo_web3_get_user($S_);
wG:
if (!(false === $user)) {
goto sT;
}
apply_filters("mo_web3_no_wallet_redirect_url", false);
sT:
$Hv = $user->ID;
clean_user_cache($user->ID);
wp_clear_auth_cookie();
wp_set_current_user($user->ID);
wp_set_auth_cookie($user->ID, true);
update_user_caches($user);
do_action("wp_login", $user->data->user_login, $user);
goto Ug;
XU:
$sp = get_current_user_id();
$Hv = $sp;
if (!($user && $sp != $user->ID)) {
goto xi;
}
wp_send_json("Error: This wallet is already in use by another user.");
xi:
Ug:
update_user_meta($Hv, "moweb3_wallet_address", $S_);
$Ky = $Hv . "_owned_tokens";
update_user_meta($Hv, $Ky, $XS);
$this->apply_role_mapping($user, $NG);
do_action("mo_web3_ld_course_mapping", $XS);
do_action("mo_web3_wc_coupon_mapping", $XS);
do_action("mo_web3_bb_profile_mapping", $XS);
do_action("mo_web3_memberpress_membership_mapping", $XS);
if (!$yv) {
goto J8;
}
$yr = array("ID" => $user->ID);
$Pd = json_decode($this->utils->mo_web3_get_option("mo_web3_inline_form_settings"), true);
if (!is_array($Pd)) {
goto Ex;
}
foreach ($Pd as $Ky => $V7) {
if (!isset($_POST[$V7["meta_key"]])) {
goto Og;
}
if (in_array($V7["meta_key"], $this->utils->get_wp_user_profile_attributes())) {
goto TV;
}
update_user_meta($user->ID, $V7["meta_key"], sanitize_text_field($_POST[$V7["meta_key"]]));
goto sJ;
TV:
$yr[$V7["meta_key"]] = sanitize_text_field($_POST[$V7["meta_key"]]);
sJ:
Og:
R3:
}
mm:
$yr = wp_update_user($yr);
if (is_wp_error($yr)) {
goto D7;
}
goto Bi;
D7:
die;
Bi:
Ex:
$VE = $this->utils->mo_web3_get_option("mo_web3_custom_profile_completion_redirect_url");
if (!$VE) {
goto up;
}
wp_redirect($VE);
exit;
up:
J8:
do_action("mo_web3_check_banned_nicknames", $Hv);
if ($sm) {
goto w3;
}
wp_send_json("NOT ABLE TO REDIRECT");
goto rg;
w3:
wp_redirect($sm);
die;
rg:
exit;
gb:
}
public function apply_role_mapping($ws, $NG)
{
global $V8;
$Js = $V8->mo_web3_get_option("mo_web3_role_mapping");
if (!(!$this->is_new_user && isset($Js["keep_existing_user_roles"]) && true === boolval($Js["keep_existing_user_roles"]))) {
goto EO;
}
return;
EO:
$ws = new \WP_User($ws->ID);
if (!(isset($Js["enable_role_mapping"]) && !boolval($Js["enable_role_mapping"]))) {
goto Ao;
}
$ws->set_role('');
return;
Ao:
$UF = 0;
$RQ = isset($Js["role_mapping_count"]) ? intval($Js["role_mapping_count"]) : 0;
$Nt = [];
$AQ = 1;
eC:
if (!($AQ <= $RQ)) {
goto I2;
}
$k8 = isset($Js["_mapping_key_" . $AQ]) ? $Js["_mapping_key_" . $AQ] : '';
array_push($Nt, $k8);
foreach ($NG as $TE) {
$sb = explode(",", $k8);
$UJ = isset($Js["_mapping_value_" . $AQ]) ? $Js["_mapping_value_" . $AQ] : '';
if (!in_array($TE, $sb)) {
goto yF;
}
if (!$k8) {
goto c5;
}
if (!(0 === $UF)) {
goto wK;
}
if (!($this->is_new_user || isset($Js["dont_disturb_existing_user_roles"]) && !boolval($Js["dont_disturb_existing_user_roles"]))) {
goto CX;
}
$ws->set_role('');
CX:
wK:
$ws->add_role($UJ);
$UF++;
c5:
yF:
wN:
}
uH:
ss:
$AQ++;
goto eC;
I2:
if (!(0 === $UF && isset($Js["_mapping_value_default"]) && '' !== $Js["_mapping_value_default"])) {
goto hv;
}
$ws->set_role($Js["_mapping_value_default"]);
hv:
$dw = 0;
if (!(isset($Js["restrict_login_for_mapped_roles"]) && boolval($Js["restrict_login_for_mapped_roles"]))) {
goto iy;
}
foreach ($NG as $TE) {
if (!in_array($TE, $Nt, true)) {
goto E7;
}
$dw = 1;
E7:
mk:
}
Nf:
if (!($dw !== 1)) {
goto w1;
}
require_once ABSPATH . "wp-admin/includes/user.php";
\wp_delete_user($ws->ID);
$kR = "You do not have permissions to login with your current roles. Please contact the Administrator.";
wp_die($kR);
w1:
iy:
}
public function get_solana_api_data($z_, $Lr, $M8)
{
$Bb = null;
$hF = null;
$f4 = array("headers" => array("Content-Type" => "application/json", "Authorization" => \MoWeb3Constants::NFT_PORT_AUTHORIZATION_Key));
if ("solanaMintAddress" == $Lr) {
goto Ms;
}
if (!("solanaCollectionID" == $Lr || "solanaCollectionKey" == $Lr)) {
goto fm;
}
$Bb = \MoWeb3Constants::NFT_PORT_API . "solana/nfts/{$M8}";
fm:
goto jt;
Ms:
$Bb = \MoWeb3Constants::NFT_PORT_API . "solana/nft/{$M8}";
jt:
$hF = wp_remote_get($Bb, $f4);
return $hF;
}
public function get_token_data_through_api($vN, $z_, $YV, $Lr = null, $M8 = null)
{
$Bb = null;
$YV = strtolower($YV);
$hF = null;
switch ($YV) {
case "solana":
$hF = $this->get_solana_api_data($z_, $Lr, $M8);
goto Uf;
default:
$hF = array("error" => "invalid case!!");
wp_send_json_error($hF, 500);
}
o0:
Uf:
if (!is_wp_error($hF)) {
goto sH;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
sH:
$hF = wp_remote_retrieve_body($hF);
wp_send_json($hF);
}
public function get_cronos_balance($z_, $vN)
{
$Bb = null;
$hF = null;
$Bb = \MoWeb3Constants::CRONOS_SCAN_API . "&contractaddress={$vN}&address={$z_}&tag=latest&apikey=" . \MoWeb3Constants::CRONOS_SCAN_API_KEY;
$hF = wp_remote_get($Bb);
if (!is_wp_error($hF)) {
goto fv;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
fv:
$hF = wp_remote_retrieve_body($hF);
wp_send_json($hF);
}
public function type_of_request()
{
if (!(wp_verify_nonce(sanitize_text_field(wp_unslash($_REQUEST["mo_web3_verify_nonce"])), "mo_web3_wp_nonce") && isset($_REQUEST["request"]))) {
goto q_;
}
$cr = sanitize_text_field(wp_unslash($_REQUEST["request"]));
if ($cr == "login") {
goto Kf;
}
if ($cr == "auth") {
goto hx;
}
if ($cr == "checkInputFields") {
goto oS;
}
if ($cr == "getAdminConfiguredNftData") {
goto tJ;
}
if ($cr == "getUserHoldNFTData") {
goto Oh;
}
if ($cr == "showNftData") {
goto ES;
}
if ("get_configuration" == $cr) {
goto kp;
}
if ("getAlgorandBalance" == $cr) {
goto VY;
}
if ("getSolanaTokenDetails" == $cr) {
goto He;
}
if ("getLoopringBalance" == $cr) {
goto i3;
}
if ("getCronosBalance" == $cr) {
goto mq;
}
goto dX;
Kf:
$this->handle_login_request();
goto dX;
hx:
$this->handle_auth_request();
goto dX;
oS:
$this->check_input_fields();
goto dX;
tJ:
$this->get_admin_configured_nft_data();
goto dX;
Oh:
$vN = isset($_REQUEST["contractAddresses"]) ? sanitize_text_field(wp_unslash($_REQUEST["contractAddresses"])) : null;
$YV = isset($_REQUEST["blockchain"]) ? sanitize_text_field(wp_unslash($_REQUEST["blockchain"])) : null;
$z_ = isset($_REQUEST["wallet_address"]) ? sanitize_text_field(wp_unslash($_REQUEST["wallet_address"])) : null;
$W0 = isset($_REQUEST["isMultipleToken"]) ? sanitize_text_field(wp_unslash($_REQUEST["isMultipleToken"])) : null;
$AE = isset($_REQUEST["pageKey"]) ? sanitize_text_field(wp_unslash($_REQUEST["pageKey"])) : null;
$this->get_user_nft_using_api($vN, $z_, $YV, $W0, $AE);
goto dX;
ES:
$ui = $_REQUEST["nftDataUri"];
$this->display_nft_data($ui);
goto dX;
kp:
$this->get_configuration();
goto dX;
VY:
$z_ = sanitize_text_field(wp_unslash($_REQUEST["walletAddress"]));
$Dj = sanitize_text_field(wp_unslash($_REQUEST["tokenID"]));
$this->get_algorand_balance($z_, $Dj);
goto dX;
He:
$z_ = isset($_POST["walletAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["walletAddress"])) : null;
$pM = isset($_POST["fieldValue"]) ? sanitize_text_field(wp_unslash($_REQUEST["fieldValue"])) : null;
$tm = isset($_POST["fieldKey"]) ? sanitize_text_field(wp_unslash($_REQUEST["fieldKey"])) : null;
$YV = "solana";
$this->get_token_data_through_api(null, $z_, $YV, $tm, $pM);
goto dX;
i3:
$z_ = isset($_POST["walletAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["walletAddress"])) : null;
$vN = isset($_POST["contractAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["contractAddress"])) : null;
$Dj = isset($_POST["tokenIDs"]) ? sanitize_text_field(wp_unslash($_REQUEST["tokenIDs"])) : null;
$zR = $this->getLoopringAccountID($z_);
$this->get_loopring_balance($z_, $vN, $Dj, $zR);
goto dX;
mq:
$z_ = isset($_POST["walletAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["walletAddress"])) : null;
$vN = isset($_POST["contractAddress"]) ? sanitize_text_field(wp_unslash($_REQUEST["contractAddress"])) : null;
$this->get_cronos_balance($z_, $vN);
dX:
q_:
}
public function get_algorand_balance($z_, $Dj)
{
$Bb = \MoWeb3Constants::ALGORAND_API . "{$z_}/assets/{$Dj}";
$this->display_nft_data($Bb);
}
public function getLoopringAccountID($z_)
{
global $V8;
$zR = $V8->mo_web3_get_option("mo_lp_" . $z_);
if ($zR) {
goto Gw;
}
$Bb = \MoWeb3Constants::LOOPRING_API . "account?owner={$z_}";
$hF = wp_remote_get($Bb);
if (!is_wp_error($hF)) {
goto lk;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
lk:
$hF = wp_remote_retrieve_body($hF);
$hF = json_decode($hF);
$zR = $hF->accountId;
$V8->mo_web3_update_option("mo_lp_" . $z_, $zR);
Gw:
return $zR;
}
public function get_loopring_balance($z_, $vN, $i8, $zR)
{
global $V8;
$vC = $V8->mo_web3_get_option("mo_web3_loopring_api_key");
$f4 = array("headers" => array("X-API-KEY" => $vC));
$yX = 0;
$Mv = 0;
HY:
$Bb = \MoWeb3Constants::LOOPRING_API . "user/nft/balances?accountId={$zR}&tokenAddrs={$vN}&offset={$yX}&limit=100";
$hF = wp_remote_get($Bb, $f4);
if (!is_wp_error($hF)) {
goto zC;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
zC:
$hF = wp_remote_retrieve_body($hF);
$hF = json_decode($hF);
$vA = $hF->totalNum;
$hF = $hF->data;
$vN = strtolower($vN);
if (false == $V8->mo_web3_check_empty_or_null($i8)) {
goto vB;
}
foreach ($hF as $ox) {
$ox->tokenAddress = strtolower($ox->tokenAddress);
if (!($ox->tokenAddress == $vN)) {
goto Gx;
}
$Mv = $Mv + $ox->total;
Gx:
V8:
}
h1:
goto Uo;
vB:
$i8 = explode(",", $i8);
foreach ($i8 as $Dj) {
foreach ($hF as $ox) {
if (!($Dj == $ox->nftId)) {
goto cT;
}
$Mv = $Mv + $ox->total;
cT:
C7:
}
YI:
mv:
}
qs:
Uo:
$yX = $yX + 100;
if ($yX <= $vA) {
goto HY;
}
Cm:
wp_send_json($Mv);
}
public function get_configuration()
{
$S_ = isset($_REQUEST["address"]) ? sanitize_text_field(wp_unslash($_REQUEST["address"])) : '';
$pA = $this->utils->mo_web3_get_option("mo_web3_nft_settings");
$J4 = $this->utils->mo_web3_get_option("mo_web3_token_config_details_store");
$GW = $this->utils->mo_web3_get_option("mo_web3_role_mapping");
$xl = $this->utils->mo_web3_get_option("mo_web3_inline_form_settings");
if (!($pA && !is_null($pA))) {
goto Pr;
}
$hF["adminNftSetting"] = $pA;
Pr:
if (!($J4 && !is_null($J4))) {
goto i4;
}
$hF["tokenConfigDetails"] = $J4;
i4:
$yy = md5($S_);
$yx = false;
if (is_user_logged_in()) {
goto ya;
}
$yx = username_exists($S_) ? false : (username_exists($yy) ? false : true);
ya:
$hk = $this->utils->mo_web3_get_option("mo_web3_custom_profile_completion_redirect_url");
if (filter_var($hk, FILTER_VALIDATE_URL)) {
goto fc;
}
$hF["custom_profile_completion_redirect_url"] = null;
goto qG;
fc:
$hF["custom_profile_completion_redirect_url"] = $hk;
qG:
$hF["newUserRegisteration"] = $yx;
$hF["roleMappingSetting"] = $GW;
$hF["inlineFormSetting"] = json_decode($xl);
$hF["inline_form_toggle"] = $this->utils->mo_web3_get_option("mo_web3_inline_form_display_toggle");
wp_send_json($hF);
}
public function display_nft_data($ui)
{
$aw = wp_remote_get($ui);
$aw = wp_remote_retrieve_body($aw);
wp_send_json($aw);
}
public function get_admin_configured_nft_data()
{
$pA = $this->utils->mo_web3_get_option("mo_web3_nft_settings");
wp_send_json($pA);
}
public function get_user_nft_using_api($vN, $z_, $YV, $W0, $AE)
{
$f4 = array("headers" => array("Content-Type" => "application/json", "Authorization" => \MoWeb3Constants::NFT_PORT_AUTHORIZATION_Key));
$YV = strtolower($YV);
$Bb = '';
if ("ethereum" == $YV || "polygon" == $YV) {
goto kJ;
}
if ("algorand" == $YV) {
goto Rr;
}
if (!("solana" == $YV)) {
goto Hn;
}
$Bb = \MoWeb3Constants::MORALIS_SOLANA_API . "/account/mainnet/{$z_}/nft";
$f4["headers"]["X-API-Key"] = \MoWeb3Constants::MORALIS_API_Key;
$f4["headers"]["accept"] = "application/json";
$hF = wp_remote_get($Bb, $f4);
Hn:
goto jR;
Rr:
$Bb = \MoWeb3Constants::ALGORAND_API . "{$z_}";
$hF = wp_remote_get($Bb);
jR:
goto MK;
kJ:
if ($W0) {
goto xA;
}
$Bb = \MoWeb3Constants::NFT_PORT_API . $z_ . "?chain=" . $YV . "&contract_address=" . $vN;
goto vS;
xA:
$Bb = \MoWeb3Constants::ALCHEMY_API_ETH . "getNFTs?owner={$z_}&contractAddresses={$vN}&withMetadata=false";
if (!("polygon" == $YV)) {
goto Mi;
}
$Bb = \MoWeb3Constants::ALCHEMY_API_POLYGON . "getNFTs?owner={$z_}&contractAddresses={$vN}&withMetadata=false";
Mi:
if (!$AE) {
goto g3;
}
$Bb = $Bb . "&pageKey={$AE}";
g3:
vS:
$hF = wp_remote_get($Bb, $f4);
MK:
if (!is_wp_error($hF)) {
goto Gm;
}
$Au = $hF->get_error_message();
$Au = "Something went wrong: " . esc_attr($Au);
$hF = array("error" => $Au);
wp_send_json_error($hF, 500);
Gm:
$hF = wp_remote_retrieve_body($hF);
wp_send_json($hF);
}
public function check_for_valid_nickname($lw)
{
$kI = $this->utils->mo_web3_get_option("mo_web3_allow_unique_nickname");
if (!("checked" === $kI)) {
goto cV;
}
$bR = get_users(array("fields" => array("display_name")));
foreach ($bR as $PD) {
$PD = $PD->display_name;
if (!($lw === $PD)) {
goto V1;
}
wp_send_json("duplicate display name");
V1:
MD:
}
ZE:
cV:
$Ha = $this->utils->mo_web3_get_option("mo_web3_banned_nicknames");
foreach ($Ha as $Pv) {
if (!str_contains($lw, $Pv)) {
goto sp;
}
wp_send_json("invalid display name");
sp:
yf:
}
pe:
}
public function check_input_fields()
{
$yB = isset($_REQUEST["email"]) ? sanitize_text_field(wp_unslash($_REQUEST["email"])) : '';
$EA = email_exists($yB);
$lw = isset($_REQUEST["display_name"]) ? sanitize_text_field(wp_unslash($_REQUEST["display_name"])) : '';
if (!$EA) {
goto WA;
}
wp_send_json("duplicate email");
WA:
$this->check_for_valid_nickname($lw);
if ($EA) {
goto te;
}
wp_send_json("success");
te:
}
public function handle_login_request()
{
$S_ = isset($_REQUEST["address"]) ? sanitize_text_field(wp_unslash($_REQUEST["address"])) : '';
$j1 = $this->utils->mo_web3_get_transient($S_);
if ($j1) {
goto Dr;
}
$j1 = uniqid();
$RP = 24 * 60 * 60;
$this->utils->mo_web3_set_transient($S_, $j1, $RP);
wp_send_json("Sign this message to validate that you are the owner of the account. Random string: " . $j1);
goto K1;
Dr:
wp_send_json("Sign this message to validate that you are the owner of the account. Random string: " . $j1);
K1:
}
public function pub_key_to_address($Y7)
{
return "0x" . substr(Keccak::hash(substr(hex2bin($Y7->encode("hex")), 1), 256), 24);
}
public function verify_signature($Oi, $ed, $S_)
{
$cB = strlen($Oi);
$Xl = Keccak::hash("Ethereum Signed Message:
{$cB}{$Oi}", 256);
$h5 = ["r" => substr($ed, 2, 64), "s" => substr($ed, 66, 64)];
$jW = ord(hex2bin(substr($ed, 130, 2))) - 27;
if (!($jW != ($jW & 1))) {
goto d9;
}
if (preg_match("/00$/", $ed)) {
goto wi;
}
if (preg_match("/01$/", $ed)) {
goto JH;
}
return 0;
goto uJ;
JH:
$jW = 1;
uJ:
goto c2;
wi:
$jW = 0;
c2:
d9:
$Sf = new EC("secp256k1");
$Y7 = $Sf->recoverPubKey($Xl, $h5, $jW);
return $S_ == $this->pub_key_to_address($Y7);
}
public function handle_auth_request()
{
$S_ = isset($_REQUEST["address"]) ? sanitize_text_field(wp_unslash($_REQUEST["address"])) : '';
$ed = isset($_REQUEST["signature"]) ? sanitize_text_field(wp_unslash($_REQUEST["signature"])) : '';
$tl = isset($_REQUEST["wallet_restriction"]) ? sanitize_text_field(wp_unslash($_REQUEST["wallet_restriction"])) : '';
$j1 = $this->utils->mo_web3_get_transient($S_);
$Oi = "Sign this message to validate that you are the owner of the account. Random string: " . $j1;
if ($this->verify_signature($Oi, $ed, $S_)) {
goto X0;
}
$hF = array("isSignatureVerified" => 0, "nonce" => null);
wp_send_json($hF);
goto Uc;
X0:
$j1 = uniqid();
$RP = 24 * 60 * 60;
$this->utils->mo_web3_set_transient($S_, $j1, $RP);
$hF = array("isSignatureVerified" => 1, "nonce" => $j1);
$bL = $this->utils->mo_web3_get_option("mo_web3_login_wallet_restriction");
if (!($bL === "checked" && $tl === "false")) {
goto Td;
}
$hF["error"] = "Only metamask wallet allowed";
Td:
wp_send_json($hF);
Uc:
}
}
?>
Function Calls
None |
Stats
MD5 | ca3f646f8a5505a335ce6b703fefe265 |
Eval Count | 0 |
Decode Time | 147 ms |