X7ROOT File Manager
Current Path:
/opt/cloudlinux/venv/lib/python3.11/site-packages/clselect
opt
/
cloudlinux
/
venv
/
lib
/
python3.11
/
site-packages
/
clselect
/
??
..
??
__init__.py
(536 B)
??
__pycache__
??
baseclselect
??
clextselect.py
(19.61 KB)
??
clpassenger.py
(26.52 KB)
??
clselect.py
(21.96 KB)
??
clselectctl.py
(9.15 KB)
??
clselectctlnodejsuser.py
(20.66 KB)
??
clselectctlphp.py
(45.92 KB)
??
clselectctlpython.py
(44.75 KB)
??
clselectctlruby.py
(18.59 KB)
??
clselectdomains.py
(4.6 KB)
??
clselectexcept.py
(10.22 KB)
??
clselectnodejs
??
clselectnodejsuser
??
clselectphp
??
clselectphpuser
??
clselectprint.py
(5.39 KB)
??
clselectpython
??
clselectpythonuser
??
clselectruby
??
clselectstatistics.py
(3.81 KB)
??
cluserextselect.py
(16.54 KB)
??
cluseroptselect.py
(24.39 KB)
??
cluserselect.py
(30.7 KB)
??
locked_extensions.ini
(1.2 KB)
??
models.py
(815 B)
??
utils.py
(16.22 KB)
Editing: clselectdomains.py
#!/opt/cloudlinux/venv/bin/python3 -bb # 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 """ Panel-specific rules for determining which domains are compatible with PHP Selector. Each panel has its own set of allowed handler types (and version filters for Plesk). The public helpers aggregate these into a simple mapping ``{username: {domain, …}}`` or a flat ``set`` of domain names. """ from __future__ import print_function from __future__ import division from __future__ import absolute_import from collections import defaultdict from future.utils import iteritems from cldetectlib import get_suEXEC_status from clcommon.cpapi import get_domains_php_info, get_system_php_info, getCPName def _is_acceptable_php_handler_cpanel(handler): """ Handler is supported in the following cases: - handler is suphp or lsapi with suexec or suphp (check for last two is in the _get_php_selector_usage method) - handler is cgi or fcgi (only with suexec, otherwise scripts do not run in cagefs) - handler is None (possible when php package was removed and we can`t detect handler, it is set to None) """ return handler in {'suphp', 'lsapi'} or \ handler in {'cgi', 'fcgi'} and get_suEXEC_status() or handler is None def _get_php_selector_domains_for_cpanel(): """ Return domains that are using php selector. 1. Skip domains whose version is not system default (php selector replaces only system default version binary with symlink to alt-php) 2. Take only domains that use supported handlers. """ vhosts_php_info = get_domains_php_info() default_php_id = get_system_php_info()['default_version_id'] phpselector_domains = defaultdict(set) for domain, domain_info in iteritems(vhosts_php_info): if domain_info['php_version_id'] != default_php_id: continue if _is_acceptable_php_handler_cpanel(domain_info['handler_type']): phpselector_domains[domain_info['username']].add(domain) return dict(phpselector_domains) def _get_php_selector_domains_for_plesk(): """ Return domains that meet panel specific requirements which will allow php selector to work when the common requirements are met. """ allowed_handlers = ('cgi', 'fastcgi') def is_allowed_version(handler_id): lsphp_vendor_version = 'x-httpd-lsphp-custom' if 'lsphp' in handler_id: return handler_id == lsphp_vendor_version return True domains_php_info = get_domains_php_info() result = defaultdict(set) for domain, info in iteritems(domains_php_info): if (info['handler_type'] in allowed_handlers and is_allowed_version(info['php_version_id'])): result[info['username']].add(domain) return dict(result) def _get_php_selector_domains_for_da(): """ Return domains that meet panel specific requirements which will allow php selector to work when the common requirements are met. """ allowed_handlers = ('fastcgi', 'suphp', 'cgi', 'lsphp') domains_php_info = get_domains_php_info() result = defaultdict(set) for domain, php_info in iteritems(domains_php_info): if php_info['handler_type'] in allowed_handlers: result[php_info['username']].add(domain) return dict(result) def _get_php_vhosts_for_current_panel(): """ Detect current control panel and get list of php selector domains for it Return None if control panel is not supported """ panel = getCPName() if panel == 'cPanel': return _get_php_selector_domains_for_cpanel() elif panel == 'DirectAdmin': return _get_php_selector_domains_for_da() elif panel == 'Plesk': return _get_php_selector_domains_for_plesk() else: # php selector is not officially # supported on another control panels return None def get_php_selector_compatible_domains(): """ Return domains compatible with PHP Selector for the current panel. Result: {username: {domain, ...}, ...} or None if panel is unsupported. """ return _get_php_vhosts_for_current_panel() def get_all_selector_compatible_domains_flat(): """ Return a flat set of all domains compatible with PHP Selector across all users, or an empty set if panel is unsupported. """ by_user = _get_php_vhosts_for_current_panel() if by_user is None: return set() result = set() for domains_set in by_user.values(): result.update(domains_set) return result
Upload File
Create Folder