Viewing File: /opt/imunify360/venv/lib/python3.11/site-packages/clcommon/__pycache__/clwpos_lib.cpython-311.pyc



]jBJddlZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZmZddl
mZddlmZddlmZmZdZGdd	eZGd
deZded
edeeeffdZdedefdZdeeefdefdZdedefdZdeeefdefdZdeeefdefdZd1dede
eede	efdZdZ defdZ!dZ"dZ#ded efd!Z$d"ed#ede
efd$Z%d"ede
efd%Z&d2d'Z'd(Z(d3d*ed+efd,Z)d1d+efd-Z*d1d+efd.Z+d/Z,d0Z-dS)4N)Path)UnionIterableOptionalTupleList)Enum)ClPwd)get_rhn_systemid_value	is_ubuntuz0/opt/cpvendor/config/cl-manager-ui-settings.jsonceZdZdZdZdZdS)
PluginTypez2
    Plugin types that are currently detected
    zobject-cachezadvanced-cacheN)__name__
__module____qualname____doc__OBJECT_CACHEADVANCED_CACHEs/builddir/build/BUILD/imunify360-venv-2.6.3/opt/imunify360/venv/lib/python3.11/site-packages/clcommon/clwpos_lib.pyrrs$"L%NNNrrceZdZdZdZdZdZdS)	WpPluginszj
    Static WP plugin names, that are not detected
    dynamically from drop-in files, dir names, etc
    Unknownz	WP RocketAccelerateWPN)rrrrUNKNOWN	WP_ROCKET
ACCELERATE_WPrrrrr!s)GI"MMMrrlineis_multiline_commentreturnc
|r[d|vrdS|d}t|d|d\}}t||dzdd\}}||z|fSd|vr!|d}|d|dfSd|vr!|d}|d|dfSd	|vrU|d	}t|d|d\}}t||dzdd\}}||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*/)TNTFz//#z/*)find
clean_comment)rr pospart1_part2s      rr'r'+s;7t8))D//C$T$3$Z66HE1*7S1WXX*N*N'E'5="666t||iiooDSDz5  
d{{iinnDSDz5  t||iioo dsdU33q&3DqND&I&I##u}222;rfilec~tj|}tj|SN)ospathrealpathisfile)r,
realpath_files  r
_is_real_filer4Ks+G$$T**M
7>>-(((rabs_pathcX	tj|d}tj|rt	|rdSn#t
$rYnwxYwtj|tj}tj|d}tj|d}tj|ot	|}tj|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/r0joinexistsr4OSErrorpardir)r5
wp_config_phpabs_path_level_upwp_config_php_level_upwp_settings_phpwp_settings_php_existss      r_check_wp_config_phprAPs
X??

7>>-((	]=-I-I	4



Xry99W\\*;_MMgll#46GHHOW^^O<<_A_A_
7>>0111%%1/001sAA
A A dirc~tj|}tj|Sr.)r/r0r1isdir)rBrealpath_dirs  r_is_real_dirrFjs+7##C((L
7==&&&rctj|d}dtj|vot	|S)z.
    Check wp-includes exists and is dir.
    zwp-includes)r/r0r8listdirrF)r5wp_includess  r_check_wp_includesrJos;',,x77KBJx000N\+5N5NNrc	tj|sdSn#t$rYdSwxYwt	|jdrdS	t|ot|S#t$rYnwxYwdS)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/r0r9r:rname
startswithrArJ)r5s r
is_wp_pathrNws
w~~h''	5	uuH~~%%m44u
#H--N2DX2N2NN



5s$
22A==
B
	B
doc_rootexcludesc#<Ktj|sdSt|rdVt	|D]C}|s|rt||vr+t|r	|jVDdS)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/r0r9rNriterdiris_dirstrrL)rOrPr0s   r
find_wp_pathsrUs7>>(##(X&&(({{}}		D		X--d	)OOOrc4tjd|d|d}t|dd5}d}	|}|sn7t	||\}}||r	d	d	d	dSN	d	d	d	n#1swxYwYdS)
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)varr0rfr rcleaned_lines       r_is_php_define_var_foundres	
VSVVVVVWWA	
dWX	6	6	6!$	::<<D
1>tEY1Z1Z.L.ww|$$
	5sAB
?B

BBwordpress_pathc|d}tj|sdSt	d|S)z
    Detects whether plugin is really enabled,
    cause not all plugins are enabled 'on load'
    # https://kevdees.com/what-are-wordpress-drop-in-plugins/
    r7FWP_CACHE)joinpathr/r0r9re)rf	wp_configs  ris_advanced_cache_enabledrksB''88I
7>>)$$u#J	:::rcft|!td|rtjjSdS)z
    They are advising to check whether WP_ROCKET_ADVANCED_CACHE is defined
    to ensure plugin is working
    https://docs.wp-rocket.me/article/134-advanced-cache-error-message
    NWP_ROCKET_ADVANCED_CACHE)accelerate_wp_pluginrerrvalue)drop_in_paths rwp_rocket_pluginrqs6L))1$%?NN2"((4rct|dd5}d|vrtjjcdddS	dddn#1swxYwYdS)zB
    Checking if the plugin folder name exists in the drop-in
    rWrXrYz/clsopN)r^readrrro)rprcs  rrnrns
lWX	>	>	>1!qvvxx*0111111111111111111111114s'AAAplugin_typec|d}||d}tj|sdS|tjjkrt|sdS|d}t||p=t|p.t|pt|ptj
j}|S)a
    Looking for object-cache.php or advanced-cache.php in wordpress folder
    If found - tries to find 'plugin-owner' of <-cache>.php by
    content comparison
    If cannot be found -> tries to read <-cache>.php headers looking for Plugin name: <Plugin>
    z
wp-contentz.phpNplugins)rir/r0r9rrrork$get_wp_cache_plugin_by_scanning_dirsget_wp_cache_plugin_by_headerrnrqrr)rfrtwp_content_diractivated_cacheplugins_dirplugin_names      rget_wp_cache_pluginr}s$,,\::N$--.B.B.BCCO
7>>/**tj/555>WXf>g>g5t )))44K6TT-2?CC-)/::-&o66-&,	ractivated_pluginr{cp|sdS|sdS|}|D]`}t	j|D]I\}}}|j|vr:t||jz}||kr|jccSJadS)zT
    Scanning plugins/* dir and looking for similar <object/advanced_cache>.php
    N)is_filerS
read_bytesrRr/walkrLr)r~r{activated_plugin_bytespluginrootdirsfilesplugin_object_cache_paths        rrwrws##%%tt-88::%%''''!#	'	'D$$--+/::8H8M+M(+6688<RRR!;&&&&&		'
4rctj|sdSd}tjdtj}t
|dd5}t|D]P}|}|	|}|#|
dccdddSQ	dddn#1swxYwYdS)zS
    Looking for Plugin name: <Some name> in <object/advanced.php>
    headers
    Nz-^.*plugin name:\s*(?P<plugin_name>[\w ]+)\s*$rWrXrYr|)r/r0r9r\r]
IGNORECASEr^ranger_searchgroup)r~max_top_lines_countrbrcr*rr`s       rrxrx	s,
7>>*++t

CR]SSA	
	B	B	B2a*++	2	2A::<<DHHTNNE {{=111122222222!	22222222222222224sAC5CC
Cobject_cachecrg}	t|}n#tj$rgcYSwxYwtj|dd}tj|sgS	t|dd5}|}dddn#1swxYwYtj
|}n#t$rgcYSwxYw|didi}	|D]%}
|
|	vr||	|
vr|
|
&|S)	z?
    Filter user`s wp paths with paths with enabled module
    z.clwposzclwpos_config.jsonrWrXrYNdocrootspublic_html)r
get_homedirNoSuchUserExceptionr/r0r8r9r^rsjsonloads	Exceptiongetappend)user
user_wp_pathsrpaths_with_enabled_modulehomeconfigrcconfdatamodules_datawp_paths           r get_wp_paths_with_enabled_modulers!#ww""4(($			W\\$	+?
@
@F
7>>&!!	
&78
<
<
<	6688D															z$			88J++//
rBBL 66l""vg1F'F'F%,,W555$$sB!&::CB3'C3B77C:B7;CC"!C"c	Hg}tjds|dtjds|dtjds|d|rtj}t
rgd|z}|dd	ingd
|z}tj	|ddd|
}tjd|j|j
tjds:tj	ddgddd}tjd|j|j
tj	gdddd}tjd|j|j
td}|rRtj	ddd|ddgddd}tjd|j|j
dSdS)N/usr/bin/cloudlinux-awp-adminz
accelerate-wpz /usr/sbin/cloudlinux-ssa-managerzalt-php-ssaz/usr/sbin/cloudlinux-xray-agentzalt-php-xray)zapt-get-yinstallDEBIAN_FRONTENDnoninteractive)yumrrTF)capture_outputtextcheckenvz:Installing AccelerateWP packages captured out: %s, err: %sz/usr/share/clos_ssa/ssa_enabledz
enable-ssa)rrrz(Activation SSA captured out: %s, err: %s)z /usr/sbin/cloudlinux-autotracingenablez--allz0Activation autotracing captured out: %s, err: %s	system_idz!/usr/sbin/cloudlinux-xray-managerzenable-user-agentz--system_idzID-r#z1Activation xray manager captured out: %s, err: %s)r/r0r9renvironcopyrupdate
subprocessrunloggingdebugstdoutstderrrreplace)packagesrinstall_commandprocrs     rinstall_accelerate_wpr:s@H
7>>9::)(((
7>><=='
&&&
7>>;<<('''njoo;;	B:::XEOJJ)+;<====666AO~odUZ`cddd
RTXT_aealmmm
7>>;<<\~A<P-1EKKK
@$+t{[[[>???
	DMDdkSWS^___&{33Ie~
02E}V_VgVghmoqVrVrs	


	
I4;X\XcdddddeerFasync_set_suitesourcecttjdrdStjtrttdd5}t
j|}dddn#1swxYwY|diddurtj
d	dSgd
}|dkr|ddg|r-tj
|tjtj
dStj|ddd}tj
d|j|jdS)zh
    1. Installs needed packages
    2. Enables autotracing
    3. Allows AccelerateWP Free for all
    z8/var/clwpos/admin/allowed_for_all_site_optimization.flagNrbrW)rZfeatures_override
accelerate_wpFzWActivation AccelerateWP Free skipped: Vendor UI skip the enabling of Accelerate WP Free)r	set-suite--allowed-for-all--suitesrBILLING_OVERRIDE--source)rrTrrrz6Activation AccelerateWP Free captured out: %s, err: %s)rr/r0r9VENDOR_UI_CONFIG_PATHr^rloadrrrextendrPopenPIPErrr)rrrcvendor_config_contentcommandrs      rconfigure_accelerate_wpres	w~~PQQ	w~~+,,
'w
?
?
?	11$(IaLL!	1	1	1	1	1	1	1	1	1	1	1	1	1	1	1!$$%8"==AA/RRV[[[MstttF   G###
$67888j??	
	
	
	
	
	
~gT$TRRR
NPTP[]a]hiiiiis+BBBcttjdrdSgd}|dkr|gdtj|ddd}tjd|j	|j
dS)Nz3/var/clwpos/admin/allowed_for_all_object_cache.flag)rr--visible-for-allraccelerate_wp_premiumrrrz--preserve-user-settingsTrz9Activation AccelerateWP Premium captured out: %s, err: %srr/r0r9rrrrrrr)rrrs   rconfigure_accelerate_wp_premiumrs	w~~KLL(((G###SSSTTT>'dNNNDMMt{\`\ghhhhhrcttjdrdSgd}|dkr|ddgtj|ddd}tjd|j	|j
gd}|dkr|gd	tj|ddd}tjd
|j	|j
dS)Nz*/var/clwpos/admin/allowed_for_all_cdn.flag)rrrraccelerate_wp_cdnrrTrz5Activation AccelerateWP CDN captured out: %s, err: %s)rrrraccelerate_wp_cdn_prorz9Activation AccelerateWP CDN PRO captured out: %s, err: %sr)rcommand_cdnrcommand_cdn_pros    rconfigure_accelerate_wp_cdnrs
	w~~BCC(((K###J(:;<<<>+T$TRRRDMI4;X\Xcddd000O###[[[\\\>/dQUVVVDMMt{\`\ghhhhhrc&|sdStjddgdddj}tj|}||dkrdStjddd|dd	gddd}t
jd
|j|jdS)Nrzget-optionsTrupgrade_urlzset-optionsz
--upgrade-urlz--suiterzBSetting AccelerateWP Premium upgrade url captured out: %s, err: %s)	rrrrrrrrr)roptions_jsonoptionsrs    rconfigure_upgrade_urlrs>#BM"R#',0"&((()/j&&Ggkk-0000>:(*&$24!%)-#%%%DMV+t{,,,,,rctjdp^tjdp?tjdp tjdpdS)z
    Locale could be set via those envvars, let`s get them in same priority gettext does
    for envar in ('LANGUAGE', 'LC_ALL', 'LC_MESSAGES', 'LANG'):
    LANGUAGE = (unset),
    LC_ALL = (unset),
    LC_MESSAGES = "UTF-8",
    LANG = "uk_UA.UTF-8"
    LANGUAGELC_ALLLC_MESSAGESLANGen_US)r/rrrrrget_locale_from_envarsrsh
JNN:&&
z~~h''
z~~m,,
z~~f%%
	rr.)r)FN).rr\r/rrpathlibrtypingrrrrrenumr	clcommon.clpwdr
clcommon.utilsrrrrrrTboolr'r4rArFrJrNrUrerkrqrnr}rwrxrrrrrrrrrr<module>rs								99999999999999      <<<<<<<<K&&&&&&&&########4E#t)<L@))))))
15d#3111114'c'd''''
OsDy!1OdOOOOsDy)d.C8DI+>(SV-6$;d;;;;			3.4dW_`cWd(DXc](%%%%:(e(e(eV%j%jT%j3%j%j%j%jPiiCiiii,!i!i!i!i!i!iH,,,6




r
Back to Directory File Manager