| Server IP : 151.101.66.159 / Your IP : 216.73.216.66 Web Server : Flywheel/5.1.0 System : Linux wordpress 6.12.113+ #1 SMP Thu Oct 22 02:38:20 UTC 2026 x86_64 User : root ( ) PHP Version : 7.4.33.18 Disable Function : disk_free_space,diskfreespace,dl,exec,fpassthru,getmypid,getmyuid,highlight_file,link,opcache_compile_file,opcache_get_configuration,opcache_is_script_cached,passthru,pcntl_alarm,pcntl_exec,pcntl_fork,pcntl_get_last_error,pcntl_getpriority,pcntl_setpriority,pcntl_signal,pcntl_signal_dispatch,pcntl_sigprocmask,pcntl_sigtimedwait,pcntl_sigwaitinfo,pcntl_strerror,pcntl_wait,pcntl_waitpid,pcntl_wexitstatus,pcntl_wifcontinued,pcntl_wifexited,pcntl_wifsignaled,pcntl_wifstopped,pcntl_wstopsig,pcntl_wtermsig,phpinfo,popen,posix_ctermid,posix_getcwd,posix_getegid,posix_geteuid,posix_getgid,posix_getgrgid,posix_getgrnam,posix_getgroups,posix_getlogin,posix_getpgid,posix_getpgrp,posix_getpid,posix_getppid,posix_getpwnam,posix_getpwuid,posix_getrlimit,posix_getsid,posix_getuid,posix_isatty,posix_kill,posix_mkfifo,posix_setegid,posix_seteuid,posix_setgid,posix_setpgid,posix_setsid,posix_setuid,posix_times,posix_ttyname,posix_uname,proc_close,proc_get_status,proc_nice,proc_open,proc_terminate,shell_exec,show_source,socket_listen,source,system,virtual MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /www/wp-content/plugins/filester/vendor-prefixed/src/License/ |
Upload File : |
<?php
namespace FilesterScoped\YayCommerce\AdminShell\License;
use FilesterScoped\YayCommerce\AdminShell\License\Contracts\LicenseConfigAdapter;
\defined('ABSPATH') || exit;
/**
* License state model.
*
* Option keys are derived from the adapter slug — NEVER hardcoded.
* Ported from YayMail Pro License.php — YAYMAIL_* constants replaced with adapter.
* @internal
*/
class License
{
protected LicenseConfigAdapter $adapter;
/** Cached license key (may be false if not set). */
protected $license_key = null;
/** Cached license info array. */
protected $license_info = null;
public function __construct(LicenseConfigAdapter $adapter)
{
$this->adapter = $adapter;
$this->license_key = $this->get_license_key();
$this->license_info = $this->get_license_info();
}
public function update_license_info(array $license_info) : void
{
unset($license_info['success']);
update_option($this->adapter->get_plugin_slug() . '_license_info', $license_info, \false);
$this->license_info = $license_info;
}
public function update_license_key(string $license_key) : void
{
update_option($this->adapter->get_plugin_slug() . '_license_key', $license_key);
$this->license_key = $license_key;
}
public function get_license_key()
{
return get_option($this->adapter->get_plugin_slug() . '_license_key');
}
public function get_license_info() : array
{
$default = ['expires' => 'Not updated'];
$info = get_option($this->adapter->get_plugin_slug() . '_license_info');
$info = \is_string($info) ? \json_decode($info, \true) : $info;
return $info ?: $default;
}
public function remove_license_key() : void
{
delete_option($this->adapter->get_plugin_slug() . '_license_key');
$this->license_key = null;
}
public function remove_license_info() : void
{
delete_option($this->adapter->get_plugin_slug() . '_license_info');
$this->license_info = ['expires' => 'Not updated'];
}
public function activate(string $license_key) : array
{
$activate_response = LicenseAPI::activate_license($this->adapter->get_store_url(), $this->adapter->get_item_id(), $license_key);
if ($activate_response['success']) {
$this->update_license_key($license_key);
$this->update_license_info($activate_response);
}
LicenseHandler::remove_site_plugin_check($this->adapter);
return $activate_response;
}
public function update() : array
{
$license_key = $this->get_license_key();
$response = LicenseAPI::check_license($this->adapter->get_store_url(), $this->adapter->get_item_id(), $license_key);
if ($response['success']) {
$this->update_license_info($response);
} elseif (empty($response['is_server_error'])) {
$this->remove();
}
LicenseHandler::remove_site_plugin_check($this->adapter);
return $response;
}
public function remove() : void
{
// Deactivate on EDD side to free the activation slot
$license_key = $this->get_license_key();
if (!empty($license_key)) {
LicenseAPI::deactivate_license($this->adapter->get_store_url(), $this->adapter->get_item_id(), $license_key);
}
LicenseHandler::remove_site_plugin_check($this->adapter);
$this->remove_license_key();
$this->remove_license_info();
}
public function is_active() : bool
{
return (bool) $this->license_key;
}
public function is_expired() : bool
{
if ($this->is_active()) {
$license_info = $this->get_license_info();
$expires = $license_info['expires'] ?? null;
if ($expires && 'lifetime' !== $expires && 'Not updated' !== $expires) {
return \strtotime($expires) < \time();
}
}
return \false;
}
public function format_license_key(int $group = 8, string $separator = '-', int $hidden = 20) : string
{
$key = (string) $this->license_key;
$len = \strlen($key);
if ($len <= $hidden) {
return $key;
}
for ($i = $len - $hidden; $i < $len; $i++) {
$key[$i] = '*';
}
$formatted = '';
for ($i = 0; $i < $len; $i++) {
$formatted .= $key[$i];
if (0 === ($i + 1) % $group && $i + 1 >= $group && $i !== $len - 1) {
$formatted .= $separator;
}
}
return $formatted;
}
public function get_renewal_url() : string
{
return $this->adapter->get_store_url() . 'checkout/?edd_license_key=' . $this->license_key . '&download_id=' . $this->adapter->get_item_id();
}
public function get_upgrade_url() : string
{
$payment_id = $this->license_info['payment_id'] ?? '';
return $this->adapter->get_store_url() . 'checkout/purchase-history/?view=upgrades&action=manage_licenses&payment_id=' . $payment_id;
}
}