!C99Shell v. 2.0 [PHP 7 Update] [25.02.2019]!

Software: Apache. PHP/5.6.40 

uname -a: Linux cpanel06wh.bkk1.cloud.z.com 2.6.32-954.3.5.lve1.4.80.el6.x86_64 #1 SMP Thu Sep 24
01:42:00 EDT 2020 x86_64
 

uid=851(cp949260) gid=853(cp949260) groups=853(cp949260) 

Safe-mode: OFF (not secure)

/opt/alt/python37/lib/python3.7/site-packages/clwpos/   drwxr-xr-x
Free 201.87 GB of 981.82 GB (20.56%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     stats.py (3.57 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
# -*- coding: utf-8 -*-

# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2021 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT

import os
import pwd
from typing import List

from clcommon import cpapi
from clcommon.clpwd import drop_privileges
from clwpos.logsetup import setup_logging
from clwpos.optimization_features import ALL_OPTIMIZATION_FEATURES
from clwpos.feature_suites import get_allowed_modules
from clwpos.utils import get_admin_options
from clwpos.user.config import UserConfig

_logger = setup_logging('clwpos_statistics')


def get_sites_count_with_enabled_wpos_statistics(user: str, checked_modules: List[str]) -> int:
    """
    Calculates total count of sites with at least one enabled
    module per user
    """
    count = 0
    try:
        with drop_privileges(user):
            uc = UserConfig(user)
            count = uc.get_enabled_sites_count_by_modules(checked_modules)
    except Exception as e:
        _logger.warning('Error while getting info from clwpos user config %s', str(e))
        return count
    return count


def get_users_count_with_allowed_wpos_statistics(user: str, checked_modules: List[str]) -> int:
    """
    Checks if there are any allowed modules for user
    """
    try:
        uid = pwd.getpwnam(user).pw_uid
    except KeyError:
        _logger.debug('Unable to get uid for %s', user)
        return False
    allowed_modules = get_allowed_modules(uid)
    return any(checked_module in allowed_modules for checked_module in checked_modules)


def _get_wpos_statistics_total_count(modules: List[str], kind: str = 'allowed'):
    """
    Returns total count of users with allowed wpos module
    or total count of sites with enabled wpos module
    for all panel users on server
    """
    total_count = 0
    panel_users = cpapi.cpusers()
    for user in panel_users:
        if kind == 'allowed':
            if get_users_count_with_allowed_wpos_statistics(user, modules):
                total_count += 1
        else:
            total_count += get_sites_count_with_enabled_wpos_statistics(user, modules)
    return total_count


def is_accelerate_wp_icon_enabled():
    """
    Obtains admin`s options, e.g show_icon
    """
    try:
        options = get_admin_options()
    except Exception as e:
        _logger.error('Error when getting admin options: %s', str(e))
        return -42
    return options.get('show_icon')


def fill_current_wpos_statistics():
    """
    Returns current statistics with enabled sites/allowed users counters
    per module and in total
    """
    is_feature_flag = os.path.isfile('/var/lve/enable-wpos.flag')
    is_feature_icon_enabled = is_accelerate_wp_icon_enabled()
    result = {
        'allowed_users': dict(),
            # total:
            # object_cache:
            # site_optimization:
        'enabled_sites': dict(),
            # total:
            # object_cache:
            # site_optimization:
        'is_accelerate_wp_flag_enabled': is_feature_flag,
        'is_accelerate_wp_icon_enabled': is_feature_icon_enabled
    }

    result['allowed_users']['total'] = _get_wpos_statistics_total_count(
        ALL_OPTIMIZATION_FEATURES,
        'allowed')
    result['enabled_sites']['total'] = _get_wpos_statistics_total_count(
        ALL_OPTIMIZATION_FEATURES, 'enabled')

    for module in ALL_OPTIMIZATION_FEATURES:
        result['allowed_users'][module] = _get_wpos_statistics_total_count(
            [module], 'allowed')
        result['enabled_sites'][module] = _get_wpos_statistics_total_count(
            [module], 'enabled')

    return result

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ Read-Only ]

:: Make Dir ::
 
[ Read-Only ]
:: Make File ::
 
[ Read-Only ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.0 [PHP 7 Update] [25.02.2019] maintained by KaizenLouie | C99Shell Github | Generation time: 0.1053 ]--