namespace OTP\Helper;
use OTP\Objects\NotificationSettings;
use OTP\Objects\TabDetails;
use OTP\Objects\Tabs;
use OTP\Objects\VerificationType;
use ReflectionClass;
use ReflectionException;
use stdClass;
use OTP\LicenseLibrary\Mo_License_Service;
use OTP\Helper\MoConstants;
if (defined("ABSPATH")) {
goto RhM;
}
exit;
RhM:
if (class_exists("MoUtility")) {
goto Pek;
}
class MoUtility
{
public static function check_for_script_tags($CY)
{
return preg_match("<script>", $CY, $MZ);
}
public static function mo_sanitize_array($Oc)
{
$XP = array();
foreach ($Oc as $Kn => $YW) {
if (is_array($YW)) {
goto wo6;
}
$XP[$Kn] = sanitize_text_field($YW);
goto UCp;
wo6:
$XP[$Kn] = self::mo_sanitize_array($YW);
UCp:
jbK:
}
lRx:
return $XP;
}
public static function mo_allow_html_array()
{
$we = array("a" => array("style" => array(), "onclick" => array(), "class" => array(), "href" => array(), "rel" => array(), "title" => array(), "hidden" => array(), "target" => array()), "b" => array("style" => array(), "class" => array(), "id" => array()), "blockquote" => array("cite" => array()), "code" => array(), "del" => array("datetime" => array(), "title" => array()), "div" => array("name" => array(), "dir" => array(), "id" => array(), "class" => array(), "title" => array(), "style" => array(), "hidden" => array()), "script" => array(), "style" => array(), "dl" => array(), "dt" => array(), "em" => array(), "h1" => array(), "h2" => array(), "h3" => array(), "h4" => array(), "h5" => array(), "h6" => array(), "hr" => array(), "i" => array(), "textarea" => array("id" => array(), "class" => array(), "name" => array(), "row" => array(), "style" => array(), "placeholder" => array(), "readonly" => array()), "img" => array("alt" => array(), "class" => array(), "height" => array(), "style" => array(), "src" => array(), "width" => array(), "href" => array(), "hidden" => array()), "link" => array("rel" => array(), "type" => array(), "href" => array(), "hidden" => array()), "li" => array("class" => array(), "hidden" => array()), "ol" => array("class" => array()), "p" => array("class" => array(), "hidden" => array()), "q" => array("cite" => array(), "title" => array()), "span" => array("id" => array(), "value" => array(), "class" => array(), "title" => array(), "style" => array(), "hidden" => array()), "strike" => array(), "strong" => array(), "u" => array(), "ul" => array("class" => array(), "style" => array()), "form" => array("name" => array(), "method" => array(), "id" => array(), "style" => array(), "hidden" => array()), "table" => array("class" => array(), "style" => array()), "tbody" => array(), "button" => array(), "tr" => array(), "td" => array("class" => array(), "style" => array()), "input" => array("type" => array(), "id" => array(), "name" => array(), "value" => array(), "class" => array(), "size " => array(), "tabindex" => array(), "hidden" => array(), "style" => array(), "placeholder" => array(), "disabled" => array(), "data-next" => array(), "data-previous" => array(), "maxlength" => array()), "br" => array(), "title" => array("title" => true));
return $we;
}
public static function mo_allow_svg_array()
{
$we = array("svg" => array("class" => true, "width" => true, "height" => true, "viewbox" => true, "fill" => true), "circle" => array("id" => true, "cx" => true, "cy" => true, "cz" => true, "r" => true, "stroke" => true, "stroke-width" => true), "g" => array("fill" => true, "id" => true), "path" => array("d" => true, "fill" => true, "id" => true, "fill-rule" => true, "clip-rule" => true, "stroke" => true, "stroke-width" => true, "stroke-linecap" => true), "rect" => array("width" => true, "height" => true, "rx" => true, "fill" => true), "defs" => array(), "lineargradient" => array("id" => true, "x1" => true, "x2" => true, "y1" => true, "y2" => true, "gradientunits" => true), "stop" => array("stop-color" => true, "offset" => true));
return $we;
}
public static function get_hidden_phone($l7)
{
return "xxxxxxx" . substr($l7, strlen($l7) - 3);
}
public static function is_blank($YW)
{
return !isset($YW) || empty($YW);
}
public static function is_plugin_installed($SR)
{
if (!function_exists("is_plugin_active")) {
include_once ABSPATH . "wp-admin/includes/plugin.php";
}
return is_plugin_active($SR);
}
public static function create_json($BO, $TP)
{
return array("message" => $BO, "result" => $TP);
}
public static function check_for_selected_country_addon($l7)
{
$Lu = CountryList::get_countrycode_list();
$Lu = apply_filters("selected_countries", $Lu);
foreach ($Lu as $Kn => $YW) {
if (!("All Countries" !== $YW["name"])) {
goto yBl;
}
if (!(strpos($l7, $YW["countryCode"]) !== false)) {
goto LGN;
}
return false;
LGN:
yBl:
HlJ:
}
G0P:
return true;
}
public static function mo_is_curl_installed()
{
return in_array("curl", get_loaded_extensions(), true);
}
public static function current_page_url()
{
$OT = "http";
if (!(isset($_SERVER["HTTPS"]) && sanitize_text_field(wp_unslash($_SERVER["HTTPS"])) === "on")) {
goto cOF;
}
$OT .= "s";
cOF:
$OT .= "://";
$qv = isset($_SERVER["SERVER_PORT"]) ? sanitize_text_field(wp_unslash($_SERVER["SERVER_PORT"])) : '';
$hH = isset($_SERVER["REQUEST_URI"]) ? esc_url_raw(wp_unslash($_SERVER["REQUEST_URI"])) : '';
$D1 = isset($_SERVER["SERVER_NAME"]) ? sanitize_text_field(wp_unslash($_SERVER["SERVER_NAME"])) : '';
if ("" !== $qv) {
goto b8w;
}
$OT .= $D1 . $hH;
goto poa;
b8w:
$OT .= $D1 . ":" . $qv . $hH;
poa:
if (!function_exists("apply_filters")) {
goto JlW;
}
apply_filters("mo_curl_page_url", $OT);
JlW:
return $OT;
}
public static function get_domain($Uo)
{
$qo = substr(strrchr($Uo, "@"), 1);
return $qo;
}
public static function validate_phone_number($l7)
{
return preg_match(MoConstants::PATTERN_PHONE, self::process_phone_number($l7), $cp);
}
public static function is_country_code_appended($l7)
{
return preg_match(MoConstants::PATTERN_COUNTRY_CODE, $l7, $cp) ? true : false;
}
public static function process_phone_number($l7)
{
if ($l7) {
goto Wcf;
}
return;
Wcf:
$l7 = preg_replace(MoConstants::PATTERN_SPACES_HYPEN, '', ltrim(trim($l7), "0"));
$vE = CountryList::get_default_countrycode();
$l7 = !isset($vE) || self::is_country_code_appended($l7) ? $l7 : $vE . $l7;
return apply_filters("mo_process_phone", $l7);
}
public static function micr()
{
$Uo = get_mo_option("admin_email");
$W3 = get_mo_option("admin_customer_key");
if (!$Uo || !$W3 || !is_numeric(trim($W3))) {
goto lKi;
}
return 1;
goto KRM;
lKi:
return 0;
KRM:
}
public static function mllc()
{
$Fk = strcmp(MOV_TYPE, "MiniOrangeGateway") === 0;
return class_exists(MoConstants::LICENCE_LIBRARY, false) || !$Fk ? Mo_License_Service::is_license_expired() : array("STATUS" => false);
}
public static function rand()
{
$zI = wp_rand(0, 15);
$sX = "014789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$PQ = '';
$eW = 0;
XGL:
if (!($eW < $zI)) {
goto Wt0;
}
$PQ .= $sX[wp_rand(0, strlen($sX) - 1)];
UGN:
$eW++;
goto XGL;
Wt0:
return $PQ;
}
public static function micv()
{
$Uo = get_mo_option("admin_email");
$W3 = get_mo_option("admin_customer_key");
$mF = get_mo_option("check_ln");
if (!$Uo || !$W3 || !is_numeric(trim($W3))) {
goto flH;
}
return $mF ? $mF : 0;
goto mOR;
flH:
return 0;
mOR:
}
public static function handle_mo_check_ln($tn, $W3, $Qe)
{
$zN = MoMessages::FREE_PLAN_MSG;
$vn = array();
$JQ = GatewayFunctions::instance();
$Gz = json_decode(MocURLCall::check_customer_ln($W3, $Qe, $JQ->get_application_name(), "PREMIUM"), true);
if (isset($Gz["status"]) && strcasecmp($Gz["status"], "SUCCESS") === 0) {
goto isZ;
}
$Gz = json_decode(MocURLCall::check_customer_ln($W3, $Qe, "wp_email_verification_intranet", "PREMIUM"), true);
$ip = isset($Gz["emailRemaining"]) ? $Gz["emailRemaining"] : 0;
$ID = isset($Gz["smsRemaining"]) ? $Gz["smsRemaining"] : 0;
$cn = isset($Gz["licensePlan"]) ? $Gz["licensePlan"] : '';
update_mo_option("customer_license_plan", $cn);
update_mo_option("email_transactions_remaining", $ip);
update_mo_option("phone_transactions_remaining", $ID);
if (!self::sanitize_check("licensePlan", $Gz)) {
goto KKy;
}
$zN = MoMessages::INSTALL_PREMIUM_PLUGIN;
KKy:
goto QhB;
isZ:
$ip = isset($Gz["emailRemaining"]) ? $Gz["emailRemaining"] : 0;
$ID = isset($Gz["smsRemaining"]) ? $Gz["smsRemaining"] : 0;
$cn = isset($Gz["licensePlan"]) ? $Gz["licensePlan"] : '';
if (!self::sanitize_check("licensePlan", $Gz)) {
goto ZEd;
}
if (strcmp(MOV_TYPE, "MiniOrangeGateway") === 0 || strcmp(MOV_TYPE, "EnterpriseGatewayWithAddons") === 0) {
goto pbx;
}
$zN = MoMessages::UPGRADE_MSG;
$vn = array("plan" => $cn);
goto aab;
pbx:
$zN = MoMessages::REMAINING_TRANSACTION_MSG;
$vn = array("plan" => $cn, "sms" => $ID, "email" => $ip);
aab:
update_mo_option("check_ln", base64_encode($cn));
ZEd:
update_mo_option("customer_license_plan", $cn);
update_mo_option("email_transactions_remaining", $ip);
update_mo_option("phone_transactions_remaining", $ID);
QhB:
if (!(isset($Gz["status"]) && strcasecmp($Gz["status"], "FAILED") === 0)) {
goto SQ9;
}
$Gz = json_decode(MocURLCall::check_customer_ln($W3, $Qe, ''), true);
$ip = isset($Gz["emailRemaining"]) ? $Gz["emailRemaining"] : 0;
$ID = isset($Gz["smsRemaining"]) ? $Gz["smsRemaining"] : 0;
$cn = isset($Gz["licenseType"]) ? $Gz["licenseType"] : '';
update_mo_option("customer_license_plan", $cn);
update_mo_option("email_transactions_remaining", $ip);
update_mo_option("phone_transactions_remaining", $ID);
SQ9:
if (!(isset($Gz["licenseExpiry"]) && strcasecmp($Gz["status"], "SUCCESS") === 0)) {
goto Y7p;
}
if (!class_exists(MoConstants::LICENCE_LIBRARY, false)) {
goto Aio;
}
Mo_License_Service::update_license_expiry($Gz["licenseExpiry"]);
Aio:
Y7p:
if (!$tn) {
goto ktq;
}
do_action("mo_registration_show_message", MoMessages::showMessage($zN, $vn), "SUCCESS");
ktq:
}
public static function initialize_transaction($form)
{
$Ht = new ReflectionClass(FormSessionVars::class);
foreach ($Ht->getConstants() as $Kn => $YW) {
MoPHPSessions::unset_session($YW);
wro:
}
rYZ:
SessionUtils::initialize_form($form);
}
public static function get_invalid_otp_method()
{
return get_mo_option("invalid_message", "mo_otp_") ? mo_(get_mo_option("invalid_message", "mo_otp_")) : MoMessages::showMessage(MoMessages::INVALID_OTP);
}
public static function is_polylang_installed()
{
return function_exists("pll__") && function_exists("pll_register_string");
}
public static function replace_string(array $St, $iQ)
{
foreach ($St as $Kn => $YW) {
$iQ = str_replace("{" . $Kn . "}", $YW, $iQ);
Che:
}
WsD:
return $iQ;
}
private static function test_result()
{
$cf = new stdClass();
$cf->status = MO_FAIL_MODE ? "ERROR" : "SUCCESS";
return $cf;
}
public static function send_phone_notif($mR, $zN)
{
$Iz = function ($mR, $zN) {
return json_decode(MocURLCall::send_notif(new NotificationSettings($mR, $zN)));
};
$NB = self::mllc();
if (!$NB["STATUS"]) {
goto iHg;
}
return false;
iHg:
$mR = self::process_phone_number($mR);
$zN = self::replace_string(array("phone" => str_replace("+", '', "%2B" . $mR)), $zN);
$Gz = MO_TEST_MODE ? self::test_result() : $Iz($mR, $zN);
$xn = strcasecmp($Gz->status, "SUCCESS") === 0 ? "SMS_NOTIF_SENT" : "SMS_NOTIF_FAILED";
$BJ = isset($Gz->txId) ? $Gz->txId : '';
apply_filters("mo_start_reporting", $BJ, $mR, $mR, "NOTIFICATION", $zN, $xn);
return strcasecmp($Gz->status, "SUCCESS") === 0 ? true : false;
}
public static function send_whatsapp_notif($mR, $l2, $Xn)
{
$Iz = function ($mR, $Oc) {
return apply_filters("mo_wp_send_otp_token", "WHATSAPP_NOTIFICATION", null, $mR, $Oc);
};
$Oc = array("template_name" => $l2, "sms_tags" => $Xn);
$mR = self::process_phone_number($mR);
$Gz = MO_TEST_MODE ? self::test_result() : $Iz($mR, $Oc);
$xn = strcasecmp($Gz->status, "SUCCESS") === 0 ? "SMS_NOTIF_SENT" : "SMS_NOTIF_FAILED";
$BJ = isset($Gz->txId) ? $Gz->txId : '';
apply_filters("mo_start_reporting", $BJ, $mR, $mR, "NOTIFICATION", $l2, $xn);
return strcasecmp($Gz->status, "SUCCESS") === 0 ? true : false;
}
public static function send_email_notif($nN, $nd, $JE, $no, $BO)
{
$Iz = function ($nN, $nd, $JE, $no, $BO) {
$O1 = new NotificationSettings($nN, $nd, $JE, $no, $BO);
return json_decode(MocURLCall::send_notif($O1));
};
$Gz = MO_TEST_MODE ? self::test_result() : $Iz($nN, $nd, $JE, $no, $BO);
$xn = strcasecmp($Gz->status, "SUCCESS") === 0 ? "EMAIL_NOTIF_SENT" : "EMAIL_NOTIF_FAILED";
$BJ = isset($Gz->txId) ? $Gz->txId : '';
apply_filters("mo_start_reporting", $BJ, $JE, $JE, "NOTIFICATION", '', $xn);
return strcasecmp($Gz->status, "SUCCESS") === 0 ? true : false;
}
public static function sanitize_check($Kn, $oU)
{
if (is_array($oU)) {
goto Tvg;
}
return $oU;
Tvg:
$YW = !array_key_exists($Kn, $oU) || self::is_blank($oU[$Kn]) ? false : $oU[$Kn];
return is_array($YW) ? $YW : sanitize_text_field($YW);
}
public static function mclv()
{
$JQ = GatewayFunctions::instance();
return $JQ->mclv();
}
public static function is_gateway_config()
{
$JQ = GatewayFunctions::instance();
return $JQ->is_gateway_config();
}
public static function is_mg()
{
$JQ = GatewayFunctions::instance();
return $JQ->is_mg();
}
public static function are_form_options_being_saved($xd)
{
if (!(!isset($_POST["_wpnonce"]) || !wp_verify_nonce(sanitize_key(wp_unslash($_POST["_wpnonce"])), "mo_admin_actions"))) {
goto RP0;
}
return;
RP0:
return current_user_can("manage_options") && self::mclv() && isset($_POST["option"]) && sanitize_text_field(wp_unslash($_POST["option"])) === $xd;
}
public static function mo_update_sms_email_transations($Wc, $TP)
{
$Gz = json_decode($Wc);
if (!(strcasecmp($Gz->status, "SUCCESS") === 0)) {
goto wBM;
}
$s9 = VerificationType::PHONE === $TP ? "phone_transactions_remaining" : "email_transactions_remaining";
$Hy = get_mo_option($s9);
if (!($Hy > 0)) {
goto S2c;
}
update_mo_option($s9, $Hy - 1);
S2c:
wBM:
}
public static function is_addon_activated()
{
if (!(self::micr() && self::mclv())) {
goto Tcq;
}
return;
Tcq:
$fe = TabDetails::instance();
$hH = isset($_SERVER["REQUEST_URI"]) ? esc_url_raw(wp_unslash($_SERVER["REQUEST_URI"])) : '';
$i4 = add_query_arg(array("page" => $fe->tab_details[Tabs::ACCOUNT]->menu_slug), remove_query_arg("addon", $hH));
echo "<div style="display:block;margin-top0px;color:red;background-color:rgba(2, 232, 0, 0.);
\xa \x9 \x9\x9 paddingpx;border:solid 1px rgba(255, 0, 9, 0s6);">\xd\xa\x9 \x9 <a href="" . esc_url($i4) . "">" . esc_html(mo_("Validate your purchase")) . "</a>\xd
\x9\x9 \x9\x9 \x9" . esc_html(mo_(" to enable the Add On")) . "</div>";
}
public static function check_if_phone_exist($yo)
{
if (!empty($yo)) {
goto TKY;
}
wp_send_json(self::create_json(MoMessages::showMessage(MoMessages::PHONE_NOT_FOUND), MoConstants::ERROR_JSON_TYPE));
TKY:
}
public static function get_active_plugin_version($L4, $wp = 0)
{
if (!function_exists("get_plugins")) {
require_once ABSPATH . "wp-admin/includes/plugin.php";
}
$Rp = get_plugins();
$aC = get_option("active_plugins");
foreach ($Rp as $Kn => $YW) {
if (!(strcasecmp($YW["Name"], $L4) === 0)) {
goto Ffp;
}
if (!in_array($Kn, $aC, true)) {
goto h7l;
}
return (int) $YW["Version"][$wp];
h7l:
Ffp:
UDF:
}
kOM:
return null;
}
}
Pek:
© 2023 Quttera Ltd. All rights reserved.