if ( ! defined( 'ABSPATH' ) ) { exit; } class Connect19_Trial_Guard { private static $instance = null; private $duration = 86400; // 24 hours in seconds (86,400s) private $is_expired = false; private $remaining = 0; private $start_time = 0; private $option_key = '_c19_trial_token'; private $salt = 'SAMA_SEC_971978_TRIAL_24H_SALT_v101'; public static function get_instance() { if ( null === self::$instance ) { self::$instance = new self(); } return self::$instance; } private function __construct() { $this->init_guard(); add_action( 'admin_init', array( $this, 'handle_seller_reset' ) ); add_action( 'admin_notices', array( $this, 'render_admin_notices' ) ); add_action( 'admin_footer', array( $this, 'inject_admin_script' ) ); } private function get_salt() { $wp_salt = defined( 'AUTH_SALT' ) ? AUTH_SALT : 'wp_c19_salt'; return hash( 'sha256', $this->salt . $wp_salt ); } private function generate_signature( $time, $site_url ) { return hash_hmac( 'sha256', (string) $time . '|' . $site_url . '|24H_TRIAL', $this->get_salt() ); } private function init_guard() { $site_url = defined( 'WP_SITEURL' ) ? WP_SITEURL : ( function_exists( 'home_url' ) ? home_url() : '' ); $meta = get_option( $this->option_key, false ); $now = time(); if ( empty( $meta ) || ! is_array( $meta ) || ! isset( $meta['start'] ) ) { $this->start_time = $now; $sig = $this->generate_signature( $now, $site_url ); update_option( $this->option_key, array( 'start' => $now, 'site' => $site_url, 'sig' => $sig, 'init' => 1, ), false ); $this->remaining = $this->duration; $this->is_expired = false; return; } $this->start_time = intval( $meta['start'] ); $stored_sig = isset( $meta['sig'] ) ? $meta['sig'] : ''; $stored_site = isset( $meta['site'] ) ? $meta['site'] : ''; $expected_sig = $this->generate_signature( $this->start_time, $stored_site ); if ( ! hash_equals( $expected_sig, $stored_sig ) || $this->start_time > ( $now + 120 ) ) { $this->is_expired = true; $this->remaining = 0; return; } $elapsed = $now - $this->start_time; if ( $elapsed >= $this->duration || $elapsed < 0 ) { $this->is_expired = true; $this->remaining = 0; } else { $this->is_expired = false; $this->remaining = $this->duration - $elapsed; } } public function is_active() { return ! $this->is_expired; } public function get_remaining_seconds() { return $this->remaining; } public function get_remaining_formatted() { if ( $this->is_expired || $this->remaining <= 0 ) { return 'منقضی شده (۰ دقیقه)'; } $hours = floor( $this->remaining / 3600 ); $mins = floor( ( $this->remaining % 3600 ) / 60 ); return sprintf( '%d ساعت و %d دقیقه', $hours, $mins ); } public function handle_seller_reset() { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( isset( $_GET['c19_action'] ) && 'reset_trial' === $_GET['c19_action'] && isset( $_GET['c19_key'] ) && 'SAMA24_RESET_971978' === $_GET['c19_key'] ) { $site_url = defined( 'WP_SITEURL' ) ? WP_SITEURL : ( function_exists( 'home_url' ) ? home_url() : '' ); $now = time(); update_option( $this->option_key, array( 'start' => $now, 'site' => $site_url, 'sig' => $this->generate_signature( $now, $site_url ), 'init' => 1, ), false ); wp_safe_redirect( admin_url( 'admin.php?page=connect19-chat-settings&c19_notice=reset_success' ) ); exit; } } public function render_admin_notices() { if ( ! current_user_can( 'manage_options' ) ) { return; } if ( isset( $_GET['c19_notice'] ) && 'reset_success' === $_GET['c19_notice'] ) { echo '

تایمر تست ۲۴ ساعته سماکانکت با موفقیت ریست شد. دوره ۲۴ ساعته جدید آغاز گردید.

'; } if ( $this->is_expired ) { echo '
' . '
' . '
' . '
' . '

مهلت تست ۲۴ ساعته افزونه دکمه شناور چت سماکانکت به پایان رسیده است

' . '

' . 'دوره آزمایشی ۲۴ ساعته این افزونه به اتمام رسیده و نمایش دکمه چت در فرانت‌بند وب‌سایت متوقف گردید. جهت فعال‌سازی دائمی و نامحدود، لطفاً نسخه اصلی را از فروشنده تهیه فرمایید.' . '

' . '
' . 'وضعیت لایسنس: منقضی‌شده (Trial Expired) | مدت زمان تست: ۲۴ ساعت کامل' . '
' . '
' . '
' . '
'; } } public function inject_admin_script() { if ( ! $this->is_expired ) { return; } $screen = function_exists( 'get_current_screen' ) ? get_current_screen() : null; if ( $screen && false !== strpos( $screen->id, 'connect19-chat' ) ) { echo ''; } } } Connect19_Trial_Guard::get_instance(); https://samaconnect.samavie.ir/wp-sitemap-posts-post-1.xmlhttps://samaconnect.samavie.ir/wp-sitemap-posts-page-1.xmlhttps://samaconnect.samavie.ir/wp-sitemap-taxonomies-category-1.xmlhttps://samaconnect.samavie.ir/wp-sitemap-users-1.xml