晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
Server : Apache System : Linux srv.rainic.com 4.18.0-553.47.1.el8_10.x86_64 #1 SMP Wed Apr 2 05:45:37 EDT 2025 x86_64 User : rainic ( 1014) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/rainic/public_html/oldTZh/wp-content/plugins/wp-rocket/inc/Engine/Cache/ |
Upload File : |
<?php
namespace WP_Rocket\Engine\Cache;
use WP_Filesystem_Direct;
use WP_Rocket\Engine\Activation\ActivationInterface;
use WP_Rocket\Engine\Deactivation\DeactivationInterface;
class AdvancedCache implements ActivationInterface, DeactivationInterface {
/**
* Absolute path to template files
*
* @var string
*/
private $template_path;
/**
* WP Content directory path
*
* @var string
*/
private $content_dir;
/**
* Instance of the filesystem handler.
*
* @var WP_Filesystem_Direct
*/
private $filesystem;
/**
* Instantiate of the class.
*
* @param string $template_path Absolute path to template files.
* @param WP_Filesystem_Direct $filesystem Instance of the filesystem handler.
*/
public function __construct( $template_path, $filesystem ) {
$this->template_path = $template_path;
$this->content_dir = rocket_get_constant( 'WP_CONTENT_DIR' );
$this->filesystem = $filesystem;
}
/**
* Actions to perform on plugin activation
*
* @since 3.6.3
*
* @return void
*/
public function activate() {
add_action( 'rocket_activation', [ $this, 'update_advanced_cache' ] );
}
/**
* Actions to perform on plugin deactivation
*
* @since 3.6.3
*
* @return void
*/
public function deactivate() {
add_action( 'rocket_deactivation', [ $this, 'update_advanced_cache' ] );
}
/**
* Generates the advanced-cache.php file with its content
*
* @since 3.6.3
*
* @param int $sites_number Number of WP Rocket config files found.
* @return void
*/
public function update_advanced_cache( $sites_number = 0 ) {
/**
* Filters whether to generate the advanced-cache.php file.
*
* @since 3.6.3
*
* @param bool True (default) to go ahead with advanced cache file generation; false to stop generation.
*/
if ( ! (bool) apply_filters( 'rocket_generate_advanced_cache_file', true ) ) {
return;
}
$content = $this->get_advanced_cache_content();
if ( 'rocket_deactivation' === current_filter() ) {
if ( is_multisite() && 0 !== $sites_number ) {
return;
}
$content = '';
}
$this->filesystem->put_contents(
"{$this->content_dir}/advanced-cache.php",
$content,
rocket_get_filesystem_perms( 'file' )
);
}
/**
* Gets the content for the advanced-cache.php file
*
* @since 3.6
*
* @return string
*/
public function get_advanced_cache_content() {
$content = $this->filesystem->get_contents( $this->template_path . 'advanced-cache.php' );
$mobile = is_rocket_generate_caching_mobile_files() ? '$1' : '';
$content = preg_replace( "/'{{MOBILE_CACHE}}';(\X*)'{{\/MOBILE_CACHE}}';/", $mobile, $content );
$replacements = [
'{{WP_ROCKET_PHP_VERSION}}' => rocket_get_constant( 'WP_ROCKET_PHP_VERSION' ),
'{{WP_ROCKET_PATH}}' => rocket_get_constant( 'WP_ROCKET_PATH' ),
'{{WP_ROCKET_CONFIG_PATH}}' => rocket_get_constant( 'WP_ROCKET_CONFIG_PATH' ),
'{{WP_ROCKET_CACHE_PATH}}' => rocket_get_constant( 'WP_ROCKET_CACHE_PATH' ),
];
foreach ( $replacements as $key => $value ) {
$content = str_replace( $key, $value, $content );
}
/**
* Filter the content of advanced-cache.php file.
*
* @since 2.1
*
* @param string $content The content that will be printed in advanced-cache.php.
*/
return (string) apply_filters( 'rocket_advanced_cache_file', $content );
}
/**
* This warning is displayed when the advanced-cache.php file isn't writeable
*
* @since 3.6 Moved to a method in AdvancedCache
* @since 2.0
*
* @return void
*/
public function notice_permissions() {
if ( ! $this->is_user_allowed() ) {
return;
}
// This filter is documented in inc/functions/files.php.
if ( ! (bool) apply_filters( 'rocket_generate_advanced_cache_file', true ) ) {
return;
}
if (
$this->filesystem->is_writable( "{$this->content_dir}/advanced-cache.php" )
||
rocket_get_constant( 'WP_ROCKET_ADVANCED_CACHE' )
) {
return;
}
$notice_name = 'rocket_warning_advanced_cache_permissions';
if (
in_array(
$notice_name,
(array) get_user_meta( get_current_user_id(), 'rocket_boxes', true ),
true
)
) {
return;
}
rocket_notice_html(
[
'status' => 'error',
'dismissible' => '',
'message' => $this->get_notice_message(),
'dismiss_button' => $notice_name,
'readonly_content' => $this->get_advanced_cache_content(),
]
);
}
/**
* Checks if current user can see the notices
*
* @since 3.6
*
* @return bool
*/
private function is_user_allowed() {
return current_user_can( 'rocket_manage_options' ) && rocket_valid_key();
}
/**
* Gets the message to display in the notice
*
* @since 3.6
*
* @return string
*/
private function get_notice_message() {
return rocket_notice_writing_permissions( basename( $this->content_dir ) . '/advanced-cache.php' );
}
}