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

Software: Apache. PHP/7.3.33 

uname -a: Linux acloudg.aryanict.com 4.18.0-513.9.1.lve.el8.x86_64 #1 SMP Mon Dec 4 15:01:22 UTC
2023 x86_64
 

uid=1095(katebhospital) gid=1098(katebhospital) groups=1098(katebhospital) 

Safe-mode: OFF (not secure)

/opt/cloudlinux/venv/lib/python3.11/site-packages/clwpos/   drwxr-xr-x
Free 294.2 GB of 429.69 GB (68.47%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     wpos_hooks.py (4.85 KB)      -rwxr-xr-x
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/opt/cloudlinux/venv/bin/python3 -bb
# -*- 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/LICENCE.TXT

import subprocess
import sys
from distutils.sysconfig import get_python_lib
from pathlib import Path

from clwpos.constants import (
    ALT_PHP_REDIS_ENABLE_UTILITY,
    INSTALL_CACHING_HOOKS_UTILITY,
)
from clwpos.optimization_features import OBJECT_CACHE_FEATURE
from clwpos.feature_suites import (
    any_suite_allowed_on_server,
    is_module_allowed_for_user
)
from clwpos.utils import is_wpos_supported

UNIVERSAL_HOOK_PATH_DNF = '/etc/dnf/universal-hooks/multi_pkgs/transaction'
UNIVERSAL_HOOK_PATH_YUM = '/etc/yum/universal-hooks/multi_pkgs/posttrans'
UNIVERSAL_HOOK_PATH_APT = '/etc/apt/universal-hooks/multi_pkgs/Post-Invoke'
HOOKS_LISTENERS_DIR = '/usr/share/cloudlinux/hooks/listeners'
MODIFY_USER_HOOK = 'wpos_modify_user_hook.py'
USER_DIRS_HOOK = 'wpos_user_dirs_hook.py'
# Hooks that depend on AccelerateWP activation state
DYNAMIC_WPOS_HOOKS = (MODIFY_USER_HOOK,)
# Default hooks that should be always installed
DEFAULT_WPOS_HOOKS = (USER_DIRS_HOOK,)

def get_universal_hook_alt_php_path() -> Path:
    """
    Get path to yum universal hooks directory
    with alt-php*-pecl-ext hooks.
    """
    dir_name = 'alt-php__WILDCARD__-pecl-ext'
    if Path('/etc/apt/').exists():
        return Path(UNIVERSAL_HOOK_PATH_APT, dir_name)
    elif Path('/etc/dnf/').exists():
        return Path(UNIVERSAL_HOOK_PATH_DNF, dir_name)
    return Path(UNIVERSAL_HOOK_PATH_YUM, dir_name)


def install_yum_universal_hook_alt_php() -> None:
    """
    Install yum universal hook for configuring PHP redis
    after alt-php*-pecl-ext package is installed/updated.
    """
    hook_dir_path = get_universal_hook_alt_php_path()
    hook_dir_path.mkdir(parents=True, exist_ok=True)
    hook_name = Path(ALT_PHP_REDIS_ENABLE_UTILITY).name
    hook_full_path = Path(hook_dir_path, hook_name)
    if not hook_full_path.exists():
        hook_full_path.symlink_to(ALT_PHP_REDIS_ENABLE_UTILITY)


def uninstall_yum_universal_hook_alt_php() -> None:
    """
    Remove yum universal hook for configuring PHP redis ext.
    """
    hook_dir_path = get_universal_hook_alt_php_path()
    hook_name = Path(ALT_PHP_REDIS_ENABLE_UTILITY).name
    hook_full_path = Path(hook_dir_path, hook_name)
    # check is_symlink because we want to delete link even if it's broken
    if hook_full_path.is_symlink():
        hook_full_path.unlink()


def install_single_hook(hook) -> None:
    """
    Install single hook
    """
    lve_utils_hooks_dir = Path(get_python_lib(), 'clwpos', 'hooks')
    listeners_hook_path = Path(HOOKS_LISTENERS_DIR, hook)
    lve_utils_hook_path = Path(lve_utils_hooks_dir, hook)
    # remove old hook pointing to symlink to lve_utils
    if 'lve_utils' in str(listeners_hook_path.resolve()) or \
            'python3.7' in str(listeners_hook_path.resolve()):
        listeners_hook_path.unlink()
    if not listeners_hook_path.exists() and lve_utils_hook_path.exists():
        listeners_hook_path.symlink_to(lve_utils_hook_path)


def uninstall_single_hook(hook):
    """
    Uninstall single hook
    """
    listeners_hook_path = Path(HOOKS_LISTENERS_DIR, hook)
    if listeners_hook_path.is_symlink():
        listeners_hook_path.unlink()


def install_default_panel_hooks() -> None:
    """
    Install wpos_user_dirs_hook.py hook
    """
    for hook in DEFAULT_WPOS_HOOKS:
        install_single_hook(hook)


def uninstall_default_panel_hooks() -> None:
    """
    Uninstall wpos_user_dirs_hook.py hook
    """
    for hook in DEFAULT_WPOS_HOOKS:
        uninstall_single_hook(hook)


def install_dynamic_panel_hooks() -> None:
    """
    Install panel WPOS hooks.
    """
    subprocess.run([INSTALL_CACHING_HOOKS_UTILITY, '-i'], capture_output=True)
    for hook in DYNAMIC_WPOS_HOOKS:
        install_single_hook(hook)


def uninstall_dynamic_panel_hooks() -> None:
    """
    Remove panel WPOS hooks.
    """
    subprocess.run([INSTALL_CACHING_HOOKS_UTILITY, '-d'], capture_output=True)

    for hook in DYNAMIC_WPOS_HOOKS:
        uninstall_single_hook(hook)


def _install_hooks():
    """
    Install all hooks
    """
    install_default_panel_hooks()

    if is_wpos_supported() and any_suite_allowed_on_server():
        if is_module_allowed_for_user(OBJECT_CACHE_FEATURE):
            install_yum_universal_hook_alt_php()
        install_dynamic_panel_hooks()


def _uninstall_hooks():
    """
    Uninstall all hooks
    """
    uninstall_yum_universal_hook_alt_php()
    uninstall_dynamic_panel_hooks()
    uninstall_default_panel_hooks()


def main():
    """
    Install or uninstall panel and yum/dnf universal hooks.
    """
    if '--install' in sys.argv:
        _install_hooks()
    elif '--uninstall' in sys.argv:
        _uninstall_hooks()


if __name__ == "__main__":
    main()

:: 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.0048 ]--