HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: xnsbb3110 (1041)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/public/imunifyav/plib/controllers/IndexController.php
<?php

class IndexController extends \Imunify360\BaseController
{
    // License types as they are listed in agent
    const LICENSE_TYPE_IMUNIFY_AV_PLUS = 'imunifyAVPlus';
    const LICENSE_TYPE_IMUNIFY_360 = 'imunify360';

    /**
     * Initialize the controller.
     */
    public function init()
    {
        parent::init();

        $session = new \pm_Session();
        $client = $session->getClient();
        if (!$client->isAdmin()) {
            $this->_redirect('/client/index');
        }
        \Imunify360\ImunifyHelper::defineAppMode();
    }

    /**
     * Default action for the controller.
     */
    public function indexAction()
    {
        $panel = new \Imunify360\panels\Plesk();
        $this->view->headScript()->appendScript('var i360role = "admin"');

        $settings = json_encode($this->getSettings());
        $this->view->headScript()->appendScript("var i360PleskSettings = $settings;");

        $this->commonAppends();
    }

    /**
     * Handle request action.
     */
    public function requestAction()
    {
        $panel = new \Imunify360\panels\Plesk();
        (new \Imunify360\Request($panel))->handle();
    }

    /**
     * Get the license type based on the license key.
     *
     * @return string|null The license type if available, null otherwise.
     */
    private function getLicenseType()
    {
        $licenseKey = \Imunify360\ImunifyHelper::getImunifyLicenseKey();
        if ($licenseKey) {
            return strpos($licenseKey, 'IMAV') === 0 ? self::LICENSE_TYPE_IMUNIFY_AV_PLUS : self::LICENSE_TYPE_IMUNIFY_360;
        }
        return null;
    }

    /**
     * Get the settings for the controller.
     *
     * @return array The settings array.
     */
    private function getSettings(): array
    {
        $serverFileManager = new \pm_ServerFileManager();
        return array(
            'buyUrl' => \pm_Context::getBuyUrl(),
            'upgradeUrl' => \pm_Context::getUpgradeLicenseUrl(),
            'marketplace' => $serverFileManager->fileExists('/var/imunify360/plesk-ext-marketplace'),
            'licenseType' => self::getLicenseType(),
            'userScanAllowed' => null,
            'userCleanupAllowed' => null,
        );
    }
}