Файловый менеджер - Редактировать - /var/www/xthruster/html/wp-content/uploads/flags/connect-manager.tar
Назад
classes/connect-runner.php 0000644 00000004375 14721611161 0011663 0 ustar 00 <?php namespace ImageOptimization\Modules\ConnectManager\Classes; use ImageOptimization\Modules\ConnectManager\Components\Connect_Interface; if ( ! defined( 'ABSPATH' ) ) { exit; // exit if accessed directly } class Connect_Runner { public $connect; public function __construct( Connect_Interface $connect ) { $this->connect = $connect; } public function is_connected() { return $this->connect->is_connected(); } public function is_activated() : bool { return $this->connect->is_activated(); } public function is_valid_home_url() : bool { return $this->connect->is_valid_home_url(); } public function get_connect_status() { return $this->connect->get_connect_status(); } public function get_connect_data( bool $force = false ): array { return $this->connect->get_connect_data( $force ); } public function update_usage_data( $new_usage_data ): void { $this->connect->update_usage_data( $new_usage_data ); } public function get_activation_state() : string { return $this->connect->get_activation_state(); } public function get_access_token() { return $this->connect->get_access_token(); } public function get_client_id(): string { return $this->connect->get_client_id(); } public function get_client_secret(): string { return $this->connect->get_client_secret(); } public function images_left(): int { return $this->connect->images_left(); } public function user_is_subscription_owner(): bool { return $this->connect->user_is_subscription_owner(); } // Legacy Nonces. public function connect_init_nonce(): string { return $this->connect->connect_init_nonce(); } public function disconnect_nonce(): string { return $this->connect->disconnect_nonce(); } public function deactivate_nonce(): string { return $this->connect->deactivate_nonce(); } public function get_subscriptions_nonce(): string { return $this->connect->get_subscriptions_nonce(); } public function activate_nonce(): string { return $this->connect->activate_nonce(); } public function version_nonce(): string { return $this->connect->version_nonce(); } public function get_is_connect_on_fly(): bool { return $this->connect->get_is_connect_on_fly(); } public function refresh_token(): void { $this->connect->refresh_token(); } } module.php 0000644 00000003040 14721611161 0006537 0 ustar 00 <?php namespace ImageOptimization\Modules\ConnectManager; use ImageOptimization; use ImageOptimization\Classes\{ Module_Base, }; use ImageOptimization\Modules\ConnectManager\Classes\Connect_Runner; use ImageOptimization\Modules\ConnectManager\Components\Legacy_Connect; use ImageOptimization\Modules\ConnectManager\Components\Connect; use ImageOptimization\Plugin; if ( ! defined( 'ABSPATH' ) ) { exit; // Exit if accessed directly } /** * Class Module */ class Module extends Module_Base { /** * Connect instance * * @var connect_instance */ public $connect_instance; /** * Get module name. * Retrieve the module name. * @access public * @return string Module name. */ public function get_name() { return 'connect-manager'; } /** * component_list * @return string[] */ public static function component_list() : array { return [ 'Legacy_Connect', 'Connect', ]; } public function __construct() { // Register components. $this->register_components(); // Load Connect Manager. add_action( 'plugins_loaded', [ $this, 'load_connect_manager' ] ); } /** * Load Connect Manager * * Load the correct version of Connect Manager based on whether * the user is already connected using legacy version or not. * * @return void */ public function load_connect_manager() { if ( ImageOptimization\Modules\Connect\Module::is_active() ) { $this->connect_instance = new Connect_Runner( new Connect() ); } else { $this->connect_instance = new Connect_Runner( new Legacy_Connect() ); } } } components/connect.php 0000644 00000010110 14721611161 0011064 0 ustar 00 <?php namespace ImageOptimization\Modules\ConnectManager\Components; use ImageOptimization\Modules\Connect\{ Module as ConnectModule, Classes\Data, Classes\Service, Classes\Utils as ConnectUtils, Rest\Authorize, Rest\Version }; use ImageOptimization\Classes\Logger; use ImageOptimization\Classes\Utils; use Throwable; if ( ! defined( 'ABSPATH' ) ) { exit; // exit if accessed directly } class Connect implements Connect_Interface { const STATUS_CHECK_TRANSIENT = 'image_optimizer_status_check'; public function is_connected() : bool { return ConnectModule::is_connected(); } public function is_activated() : bool { return ConnectModule::is_connected(); } public function is_valid_home_url() : bool { return ConnectUtils::is_valid_home_url(); } public function get_connect_status() { if ( ! $this->is_connected() ) { Logger::log( Logger::LEVEL_INFO, 'Status check error. Reason: User is not connected' ); return null; } $cached_status = get_transient( self::STATUS_CHECK_TRANSIENT ); if ( $cached_status ) { return $cached_status; } try { $response = Utils::get_api_client()->make_request( 'POST', 'status/check' ); } catch ( Throwable $t ) { Logger::log( Logger::LEVEL_ERROR, 'Status check error. Reason: ' . $t->getMessage() ); return null; } if ( ! isset( $response->status ) ) { Logger::log( Logger::LEVEL_ERROR, 'Invalid response from server' ); return null; } if ( ! empty( $response->site_url ) && Data::get_home_url() !== $response->site_url ) { Data::set_home_url( $response->site_url ); } set_transient( self::STATUS_CHECK_TRANSIENT, $response, MINUTE_IN_SECONDS * 5 ); return $response; } public function get_connect_data( bool $force = false ): array { $data = get_transient( self::STATUS_CHECK_TRANSIENT ); $user = []; // Return empty array if transient does not exist or is expired. if ( ! $data ) { return $user; } // Return if user property does not exist in the data object. if ( ! property_exists( $data, 'user' ) ) { return $user; } if ( $data->user->email ) { $user = [ 'user' => [ 'email' => $data->user->email, ], ]; } return $user; } public function update_usage_data( $new_usage_data ): void { $connect_status = $this->get_connect_status(); if ( ! isset( $new_usage_data->allowed ) || ! isset( $new_usage_data->used ) ) { return; } if ( 0 === $new_usage_data->allowed - $new_usage_data->used ) { $connect_status->status = 'expired'; } $connect_status->quota = $new_usage_data->allowed; $connect_status->used_quota = $new_usage_data->used; set_transient( self::STATUS_CHECK_TRANSIENT, $connect_status, MINUTE_IN_SECONDS * 5 ); } public function get_activation_state() : string { /** * Returning true because the license key is * not used for deactivation in connect. */ return true; } public function get_access_token() { return Data::get_access_token(); } public function get_client_id(): string { return Data::get_client_id(); } public function get_client_secret(): string { return Data::get_client_secret(); } public function images_left(): int { $plan_data = $this->get_connect_status(); if ( empty( $plan_data ) ) { return 0; } $quota = $plan_data->quota; $used_quota = $plan_data->used_quota; return max( $quota - $used_quota, 0 ); } public function user_is_subscription_owner(): bool { return Data::user_is_subscription_owner(); } // Nonces. public function connect_init_nonce(): string { return Authorize::NONCE_NAME; } public function disconnect_nonce(): string { return Authorize::NONCE_NAME; } public function deactivate_nonce(): string { return Authorize::NONCE_NAME; } public function get_subscriptions_nonce(): string { return Authorize::NONCE_NAME; } public function activate_nonce(): string { return Authorize::NONCE_NAME; } public function version_nonce(): string { return Version::NONCE_NAME; } public function get_is_connect_on_fly(): bool { return true; } public function refresh_token(): void { Service::refresh_token(); } } components/legacy-connect.php 0000644 00000004105 14721611161 0012335 0 ustar 00 <?php namespace ImageOptimization\Modules\ConnectManager\Components; use ImageOptimization\Modules\Oauth\{ Components\Connect, Classes\Data, Rest\Activate, Rest\Connect_Init, Rest\Deactivate, Rest\Disconnect, Rest\Get_Subscriptions, Rest\Version, }; if ( ! defined( 'ABSPATH' ) ) { exit; // exit if accessed directly } class Legacy_Connect implements Connect_Interface { public function is_connected() : bool { return Connect::is_connected(); } public function is_activated() : bool { return Connect::is_activated(); } public function is_valid_home_url() : bool { return true; } public function get_connect_status() { return Connect::get_connect_status(); } public function get_connect_data( bool $force = false ): array { return Data::get_connect_data( $force ); } public function update_usage_data( $new_usage_data ): void { Connect::update_usage_data( $new_usage_data ); } public function get_activation_state() : string { return Data::get_activation_state(); } public function get_access_token() { return Data::get_access_token(); } public function get_client_id(): string { return Data::get_client_id(); } public function get_client_secret(): string { return Data::get_client_secret(); } public function images_left(): int { return Data::images_left(); } public function user_is_subscription_owner(): bool { return Data::user_is_subscription_owner(); } // Legacy Nonces. public function connect_init_nonce(): string { return Connect_Init::NONCE_NAME; } public function disconnect_nonce(): string { return Disconnect::NONCE_NAME; } public function deactivate_nonce(): string { return Deactivate::NONCE_NAME; } public function get_subscriptions_nonce(): string { return Get_Subscriptions::NONCE_NAME; } public function activate_nonce(): string { return Activate::NONCE_NAME; } public function version_nonce(): string { return Version::NONCE_NAME; } public function get_is_connect_on_fly(): bool { return false; } // Placeholder function for legacy connect. public function refresh_token(): void { } } components/connect-interface.php 0000644 00000002156 14721611161 0013035 0 ustar 00 <?php namespace ImageOptimization\Modules\ConnectManager\Components; if ( ! defined( 'ABSPATH' ) ) { exit; // exit if accessed directly } interface Connect_Interface { // Connect. public function is_connected(): bool; public function is_activated() : bool; public function is_valid_home_url() : bool; public function get_connect_status(); public function get_connect_data( bool $force = false ): array; public function update_usage_data( $new_usage_data ): void; public function get_activation_state() : string; public function get_access_token(); public function get_client_id(): string; public function get_client_secret(): string; public function images_left(): int; public function user_is_subscription_owner(): bool; // Nonces. public function connect_init_nonce(): string; public function disconnect_nonce(): string; public function deactivate_nonce(): string; public function get_subscriptions_nonce(): string; public function activate_nonce(): string; public function version_nonce(): string; public function get_is_connect_on_fly(): bool; public function refresh_token(): void; }
| ver. 1.4 |
Github
|
.
| PHP 7.4.3-4ubuntu2.24 | Генерация страницы: 0 |
proxy
|
phpinfo
|
Настройка