0GrV J d dl Z d dlZd dlZd dlZd dlZd dlmZ d dlmZm Z m
Z
mZmZ d dl
mZ d dlmZ d dlmZmZ dZ G d d e Z G d
de Zded
edeeef fdZdedefdZdeeef defdZdedefdZdeeef defdZdeeef defdZd1dede
ee de e fdZd Z defdZ!d Z"d Z#ded efd!Z$d"ed#ede
e fd$Z%d"ede
e fd%Z&d2d'Z'd( Z(d3d*ed+efd,Z)d1d+efd-Z*d1d+efd.Z+d/ Z,d0 Z-dS )4 N)Path)UnionIterableOptionalTupleList)Enum)ClPwd)get_rhn_systemid_value is_ubuntuz0/opt/cpvendor/config/cl-manager-ui-settings.jsonc e Zd ZdZdZdZdS )
PluginTypez2
Plugin types that are currently detected
zobject-cachezadvanced-cacheN)__name__
__module____qualname____doc__OBJECT_CACHEADVANCED_CACHE /builddir/build/BUILDROOT/alt-python27-cllib-3.4.36-1.el9.cloudlinux.x86_64/opt/cloudlinux/venv/lib/python3.11/site-packages/clcommon/clwpos_lib.pyr r s$ "L%NNNr r c e Zd ZdZdZdZdZdS ) WpPluginszj
Static WP plugin names, that are not detected
dynamically from drop-in files, dir names, etc
Unknownz WP RocketAccelerateWPN)r r r r UNKNOWN WP_ROCKET
ACCELERATE_WPr r r r r ! s) GI"MMMr r lineis_multiline_commentreturnc
|r[d| vrdS | d }t | d| d \ }}t | |dz d d \ }}||z |fS d| v r!| d }| d| dfS d| v r!| d }| d| dfS d | v rU| d }t | d| d \ }}t | |dz d d \ }}||z |fS | dfS )
z
Yep, this bicycle is needed to handle different comment types in .php file
https://www.php.net/manual/en/language.basic-syntax.comments.php
and ensure that needed line is not under comment
z*/) TNT Fz//#z/*)find
clean_comment)r r pospart1_part2s r r' r' + s; 7t8))D//C$T$3$Z66HE1*7S1WXX*N*N'E'5="666t||iiooDSDz5
d{{iinnDSDz5 t||iioo dsdU33q&3DqND&I&I##u}222;r filec ~ t j | }t j | S N)ospathrealpathisfile)r,
realpath_files r
_is_real_filer4 K s+ G$$T**M
7>>-(((r abs_pathc X t j | d }t j | rt | rdS n# t
$ r Y nw xY wt j | t j }t j |d }t j |d }t j | ot | }t j | o| ot | S )a&
WordPress looks for wp-config.php file in the
(1) WordPress root and (2) one directory above the root.
Check that there is no wp-settings.php file in the second case.
This check helps when there is a nested installation, e.g
/ is WordPress and /wp_path/ is WordPress.
wp-config.phpTzwp-settings.php)r/ r0 joinexistsr4 OSErrorpardir)r5
wp_config_phpabs_path_level_upwp_config_php_level_upwp_settings_phpwp_settings_php_existss r _check_wp_config_phprA P s
X??
7>>-(( ]=-I-I 4
Xry99W\\*;_MMgll#46GHHOW^^O<<_A_A_
7>>011 1%%1/001s AA
A A dirc ~ t j | }t j | S r. )r/ r0 r1 isdir)rB realpath_dirs r _is_real_dirrF j s+ 7##C((L
7==&&&r c t j | d }dt j | v ot | S )z.
Check wp-includes exists and is dir.
zwp-includes)r/ r0 r8 listdirrF )r5 wp_includess r _check_wp_includesrJ o s; ',,x77KBJx000N\+5N5NNr c t j | sdS n# t $ r Y dS w xY wt | j d rdS t | ot | S # t $ r Y nw xY wdS )z
Checks whether passed directory is a wordpress directory
by checking presence of wp-includes folder and wp-config.php file.
Fz.wp-toolkit) r/ r0 r9 r: r name
startswithrA rJ )r5 s r
is_wp_pathrN w s
w~~h'' 5 uu H~~%%m44 u
#H--N2DX2N2NN
5s $
22A= =
B
B
doc_rootexcludesc # < K t j | sdS t | rdV t | D ]C}| s|rt | |v r+t | r |j V DdS )z
Returns folder with wordpress
Empty string is wp is in docroot dir
:param doc_root:
root path to start search from
:param excludes:
list of paths that must be excluded from search, e.g. subdomains
Nr# ) r/ r0 r9 rN r iterdiris_dirstrrL )rO rP r0 s r
find_wp_pathsrU s 7>>(## ( X&&(( {{}} D X--d )OOO r c 4 t j d| d| d }t |dd 5 }d} | }|sn7t || \ }}| | r d d d dS N d d d n# 1 swxY w Y dS )
z8
Looks for defined php variable with true value
z^\s*define\s*\(\s*((\'z\')|(\"z\"))\s*,\s*true\s*\)\s*;utf-8ignoreencodingerrorsFTN)recompileopenreadliner' match)varr0 rfr r cleaned_lines r _is_php_define_var_foundre s
VSVVVVVWWA
dWX 6 6 6 !$ ::<