|
Server : LiteSpeed System : Linux quebec.us.hostns.io 5.14.0-687.42.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 27 11:55:12 EDT 2026 x86_64 User : gazetufm ( 1431) PHP Version : 8.1.35 Disable Function : NONE Directory : /home2/gazetufm/tali-ks.com/wp-content/plugins/litespeed-cache/src/ | |
|
Path: //home2/gazetufm/tali-ks.com/wp-content/plugins/litespeed-cache/src/guest.cls.php
Size: 2.21 KB
Permissions: 0644
<?php
/**
* Guest mode management class.
*
* Handles syncing of Guest Mode IP and UA lists from QUIC.cloud.
*
* @package LiteSpeed
* @since 7.7
*/
namespace LiteSpeed;
defined( 'WPINC' ) || exit();
/**
* Class Guest
*
* Extends Cloud class to provide Guest Mode related functionality.
*/
class Guest extends Cloud {
const LOG_TAG = '👤';
const TYPE_SYNC = 'sync';
/**
* Cron handler for daily Guest Mode sync.
*
* @since 7.7
* @return void
*/
public static function cron() {
self::debug( 'Cron: starting daily sync' );
self::cls()->sync_lists();
}
/**
* Sync Guest Mode IP and UA lists.
*
* Fetches the latest IP and UA lists from QUIC.cloud API and saves them locally.
*
* @since 7.7
* @return array{success: bool, message: string}
*/
public function sync_lists() {
self::debug( 'Starting Guest Mode lists sync' );
$cloud_dir = LITESPEED_STATIC_DIR . '/cloud';
$results = [
'ips' => false,
'uas' => false,
];
foreach ( [ 'ips', 'uas' ] as $type ) {
$url = $this->_cloud_server_wp . '/gm_' . $type;
$file = $cloud_dir . '/gm_' . $type . '.txt';
self::debug( 'Fetching: ' . $url );
$temp = File::download( $url, $file, 15 );
if ( is_wp_error( $temp ) ) {
self::debug( 'Fetch failed: ' . $temp->get_error_code() );
} elseif ( File::publish_temp_file( $temp, $file ) ) {
self::debug( 'Guest Mode ' . $type . ' synced' );
$results[ $type ] = true;
}
}
$success = $results['ips'] && $results['uas'];
$message = $success
? __( 'Guest Mode lists synced successfully.', 'litespeed-cache' )
: __( 'Failed to sync Guest Mode lists.', 'litespeed-cache' );
return [
'success' => $success,
'message' => $message,
];
}
/**
* Handle all request actions from main class.
*
* @since 7.7
* @return void
*/
public function handler() {
$type = Router::verify_type();
switch ( $type ) {
case self::TYPE_SYNC:
$result = $this->sync_lists();
if ( Router::is_ajax() ) {
wp_send_json( $result );
}
if ( $result['success'] ) {
Admin_Display::success( $result['message'] );
} else {
Admin_Display::error( $result['message'] );
}
break;
default:
break;
}
Admin::redirect();
}
}