!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/lvestats/lib/commons/   drwxr-xr-x
Free 233.26 GB of 981.82 GB (23.76%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Feedback    Self remove    Logout    


Viewing file:     users_manager.py (3.01 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
#!/usr/bin/python
# coding=utf-8

# Copyright © Cloud Linux GmbH & Cloud Linux Software, Inc 2010-2019 All Rights Reserved
#
# Licensed under CLOUD LINUX LICENSE AGREEMENT
# http://cloudlinux.com/docs/LICENSE.TXT
from __future__ import absolute_import
import logging
from collections import namedtuple

from clcommon import cpapi, FormattedException

from lvestats.lib.commons import func
from typing import Optional, Dict, Generator, Tuple, List  # pylint: disable=unused-import


class UserNotFoundError(FormattedException):
    pass


class User(namedtuple('User', ['username', 'domain', 'reseller'])):
    pass


class UsersInfoManager(object):
    """
    Implements some different functions for user management;
    """
    def __init__(self):
        self.users_cache = dict()  # type: Dict[str, User]

    def build_users_cache(self, reseller):
        # type: (Optional[str]) -> None
        """Cache data from cpapi for given reseller"""
        try:
            self.users_cache = dict(self._iter_panel_users(reseller))
        except cpapi.NotSupported:
            logging.info("Control panel API is not implemented, "
                         "some features may not work properly")

    def _iter_panel_users(self, reseller):
        # type: (Optional[str]) -> Generator[Tuple[str, User]]
        for login, reseller_, domain in self._iter_panel_users_tuples(reseller):
            yield login, User(username=login, reseller=reseller_, domain=domain)

    @staticmethod
    def _iter_panel_users_tuples(reseller):
        # type: (Optional[str]) -> Tuple[str, str, str]
        if reseller is None:
            for login, reseller_, domain in cpapi.cpinfo(keyls=('cplogin', 'reseller', 'dns')):
                yield login, reseller_, domain
        else:
            # TODO: do we really need get_reseller_domains?
            for login, domain in list(func.get_reseller_domains(reseller).items()):
                yield login, reseller, domain

    def get_domain(self, username, raise_exc=True):
        # type: (str, bool) -> Optional[str]
        """Get domain for user"""
        try:
            return self.users_cache[username].domain
        except KeyError:
            if raise_exc:
                raise UserNotFoundError({
                    'message': "An error occurred while getting domain for user %(username)s",
                    'context': {'username': username}})
            return None

    def get_reseller(self, username, raise_exc=True):
        # type: (str, bool) -> Optional[str]
        """Get reseller for user"""
        try:
            return self.users_cache[username].reseller
        except KeyError:
            if raise_exc:
                raise UserNotFoundError({
                    'message': "An error occurred while getting reseller for user %(username)s",
                    'context': {'username': username}})
            return None

    def get_login_list(self):
        # type: () -> List[str]
        """Get list of cached users"""
        return list(self.users_cache.keys())


g_usersManager = UsersInfoManager()

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