namespace MO_CAW\LicenseLibrary;
define("MO_CAW_LICENSE_LIBRARY_PATH", plugin_dir_url(__FILE__));
use MO_CAW\LicenseLibrary\Classes\Mo_License_Constants;
use MO_CAW\LicenseLibrary\Classes\Mo_License_Dao;
use MO_CAW\LicenseLibrary\Exceptions\Mo_License_Grace_Expired_Exception;
use MO_CAW\LicenseLibrary\Exceptions\Mo_License_Invalid_Expiry_Date_Exception;
use MO_CAW\LicenseLibrary\Exceptions\Mo_License_Missing_Customer_Email_Exception;
use MO_CAW\LicenseLibrary\Exceptions\Mo_License_Missing_License_Key_Exception;
use MO_CAW\LicenseLibrary\Exceptions\Mo_License_Missing_Or_Invalid_Customer_Key_Exception;
use MO_CAW\LicenseLibrary\Exceptions\Mo_License_Unknown_Error_Exception;
use MO_CAW\LicenseLibrary\Utils\Mo_License_Actions_Utility;
use MO_CAW\LicenseLibrary\Utils\Mo_License_Service_Utility;
if (defined("ABSPATH")) {
goto b5;
}
exit;
b5:
class Mo_License_Service
{
public static function is_license_expired()
{
try {
Mo_License_Service_Utility::check_customer_login_and_license();
$cv = Mo_License_Service_Utility::is_license_grace_expired();
} catch (Mo_License_Grace_Expired_Exception $Of) {
return Mo_License_Service_Utility::return_true_with_code($Of::MESSAGE);
} catch (Mo_License_Invalid_Expiry_Date_Exception $Of) {
return Mo_License_Service_Utility::return_true_with_code($Of::MESSAGE);
} catch (Mo_License_Missing_License_Key_Exception $Of) {
return Mo_License_Service_Utility::return_true_with_code($Of::MESSAGE);
} catch (Mo_License_Missing_Customer_Email_Exception $Of) {
return Mo_License_Service_Utility::return_true_with_code($Of::MESSAGE);
} catch (Mo_License_Missing_Or_Invalid_Customer_Key_Exception $Of) {
return Mo_License_Service_Utility::return_true_with_code($Of::MESSAGE);
} catch (Mo_License_Unknown_Error_Exception $Of) {
return Mo_License_Service_Utility::return_true_with_code($Of::MESSAGE);
}
return Mo_License_Service_Utility::return_false_with_code($cv["CODE"]);
}
public static function is_customer_license_verified()
{
try {
Mo_License_Service_Utility::check_customer_login_and_license();
} catch (Mo_License_Missing_Customer_Email_Exception $Of) {
return false;
} catch (Mo_License_Missing_Or_Invalid_Customer_Key_Exception $Of) {
return false;
} catch (Mo_License_Missing_License_Key_Exception $Of) {
return false;
}
return true;
}
public static function is_customer_logged_into_plugin()
{
try {
Mo_License_Service_Utility::check_customer_login();
} catch (Mo_License_Missing_Customer_Email_Exception $Of) {
return false;
} catch (Mo_License_Missing_Or_Invalid_Customer_Key_Exception $Of) {
return false;
}
return true;
}
public static function get_html_disabled_status($FW = true)
{
if ($FW) {
goto qs;
}
$qu = self::is_customer_license_verified();
goto fR;
qs:
$Xa = self::is_license_expired();
$qu = !$Xa["STATUS"];
fR:
if (!(false === $qu)) {
goto cs;
}
return "disabled";
cs:
return '';
}
public static function refresh_license_expiry()
{
$uO = Mo_License_Actions_Utility::fetch_license_expiry_date();
if (!$uO) {
goto ek;
}
self::update_license_expiry($uO);
return $uO;
ek:
return false;
}
public static function mo_check_admin_referer($ql = -1, $Gp = "_wpnonce", $FW = true)
{
$cd = check_admin_referer($ql, $Gp);
$Xa = false;
if ($FW) {
goto d_;
}
$qu = self::is_customer_license_verified();
goto Jm;
d_:
$Xa = self::is_license_expired();
$qu = !$Xa["STATUS"];
Jm:
if (!(!$qu || !$cd)) {
goto SJ;
}
wp_die(esc_html(Mo_License_Constants::ADMIN_ERROR_MESSAGE));
SJ:
return true;
}
public static function mo_check_ajax_referer($gt = -1, $Gp = false, $Ud = true, $FW = true)
{
if ($FW) {
goto hE;
}
$qu = self::is_customer_license_verified();
goto oA;
hE:
$Xa = self::is_license_expired();
$qu = !$Xa["STATUS"];
oA:
$Ij = check_ajax_referer($gt, $Gp, $Ud);
if (!(!$qu || !$Ij)) {
goto Ch;
}
wp_send_json_error(array("message" => "Invalid License Key."), 403);
exit;
Ch:
wp_send_json_success(array("message" => "Referer verified successfully."), 200);
}
public static function get_expiry_remaining_days($uO)
{
$R9 = strtotime($uO);
$KU = strtotime(gmdate("Y-m-d"));
$lU = $R9 - $KU;
$dq = floor($lU / (60 * 60 * 24));
return $dq;
}
public static function get_grace_days_left($uO)
{
$dq = self::get_expiry_remaining_days($uO);
if (!($dq > 0)) {
goto gJ;
}
return false;
gJ:
return Mo_License_Config::GRACE_PERIOD_DAYS + $dq;
}
public static function get_disable_date($uO)
{
return gmdate("M d, Y", strtotime($uO . "+" . Mo_License_Config::GRACE_PERIOD_DAYS . " days"));
}
public static function get_expiry_date()
{
$Ma = Mo_License_Service_Utility::mo_decrypt_data(Mo_License_Dao::mo_get_option(Mo_License_Constants::LICENSE_EXPIRY_DATE_OPTION));
if ($Ma) {
goto a3;
}
$Ma = Mo_License_Actions_Utility::fetch_license_expiry_date();
if ($Ma) {
goto v4;
}
$Ma = Mo_License_Constants::EPOCH_DATE;
v4:
self::update_license_expiry($Ma);
a3:
return $Ma;
}
public static function get_formatted_license_expiry_date($t1)
{
try {
$M2 = new \DateTime($t1);
$Hw = $M2->getTimestamp();
$t1 = gmdate("F j, Y", $Hw);
return $t1;
} catch (\Exception $Of) {
return $t1;
}
}
public static function is_customer_license_valid($Mr = false, $FW = true)
{
if ($FW) {
goto jQ;
}
$qu = self::is_customer_license_verified();
goto IP;
jQ:
$Xa = self::is_license_expired();
$qu = !$Xa["STATUS"];
IP:
if (!(true === $qu)) {
goto vL;
}
return $Mr ? '' : true;
vL:
return $Mr ? "disabled" : false;
}
public static function update_license_expiry($uO)
{
Mo_License_Dao::mo_update_option(Mo_License_Constants::LICENSE_EXPIRY_DATE_OPTION, Mo_License_Service_Utility::mo_encrypt_data(self::get_formatted_license_expiry_date($uO)));
$ou = self::is_license_expired();
if (true === $ou["STATUS"]) {
goto kb;
}
if (!Mo_License_Dao::mo_get_option(Mo_License_Constants::LICENSE_EXPIRED_OPTION)) {
goto Kq;
}
self::reset_license_values();
Kq:
goto PJ;
kb:
Mo_License_Dao::mo_update_option(Mo_License_Constants::LICENSE_EXPIRED_OPTION, true);
PJ:
}
public static function reset_license_values()
{
$lW = Mo_License_Constants::get_constants();
foreach ($lW as $O0 => $I4) {
if (!(strpos($O0, "OPTION") !== false)) {
goto iS;
}
Mo_License_Dao::mo_delete_option($I4);
iS:
S_:
}
hJ:
}
}
© 2023 Quttera Ltd. All rights reserved.