晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/www/wp-contentTZh/plugins/elementor/core/logger/items/ |
Upload File : |
<?php
namespace Elementor\Core\Logger\Items;
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly.
}
class Base implements Log_Item_Interface {
const FORMAT = 'date [type] message [meta]';
const TRACE_FORMAT = '#key: file(line): class type function()';
const TRACE_LIMIT = 5;
protected $date;
protected $type;
protected $message;
protected $meta = [];
protected $times = 0;
protected $times_dates = [];
protected $args = [];
public function __construct( $args ) {
$this->date = current_time( 'mysql' );
$this->message = ! empty( $args['message'] ) ? esc_html( $args['message'] ) : '';
$this->type = ! empty( $args['type'] ) ? $args['type'] : 'info';
$this->meta = ! empty( $args['meta'] ) ? $args['meta'] : [];
$this->args = $args;
$this->set_trace();
}
public function __get( $name ) {
if ( property_exists( $this, $name ) ) {
return $this->{$name};
}
return '';
}
public function __toString() {
$vars = get_object_vars( $this );
return strtr( static::FORMAT, $vars );
}
#[\ReturnTypeWillChange]
public function jsonSerialize() {
return [
'class' => get_class( $this ),
'item' => [
'date' => $this->date,
'message' => $this->message,
'type' => $this->type,
'meta' => $this->meta,
'times' => $this->times,
'times_dates' => $this->times_dates,
'args' => $this->args,
],
];
}
public function deserialize( $properties ) {
$this->date = ! empty( $properties['date'] ) && is_string( $properties['date'] ) ? $properties['date'] : '';
$this->message = ! empty( $properties['message'] ) && is_string( $properties['message'] ) ? $properties['message'] : '';
$this->type = ! empty( $properties['type'] ) && is_string( $properties['type'] ) ? $properties['type'] : '';
$this->meta = ! empty( $properties['meta'] ) && is_array( $properties['meta'] ) ? $properties['meta'] : [];
$this->times = ! empty( $properties['times'] ) && is_string( $properties['times'] ) ? $properties['times'] : '';
$this->times_dates = ! empty( $properties['times_dates'] ) && is_array( $properties['times_dates'] ) ? $properties['times_dates'] : [];
$this->args = ! empty( $properties['args'] ) && is_array( $properties['args'] ) ? $properties['args'] : [];
}
/**
* @return Log_Item_Interface | null
*/
public static function from_json( $str ) {
$obj = json_decode( $str, true );
if ( ! array_key_exists( 'class', $obj ) ) {
return null;
}
$class = $obj['class'];
if ( class_exists( $class ) ) {
/** @var Base $item */
$item = new $class( $obj['item']['message'] );
$item->deserialize( $obj['item'] );
return $item;
}
return null;
}
public function to_formatted_string( $output_format = 'html' ) {
$vars = get_object_vars( $this );
$format = static::FORMAT;
if ( 'html' === $output_format ) {
$format = str_replace( 'message', '<strong>message</strong>', static::FORMAT );
}
if ( empty( $vars['meta'] ) ) {
$format = str_replace( '[meta]', '', $format );
} else {
$vars['meta'] = stripslashes( var_export( $vars['meta'], true ) ); // @codingStandardsIgnoreLine
}
return strtr( $format, $vars );
}
public function get_fingerprint() {
$unique_key = $this->type . $this->message . var_export( $this->meta, true ); // @codingStandardsIgnoreLine
// Info messages are not be aggregated:
if ( 'info' === $this->type ) {
$unique_key .= $this->date;
}
return md5( $unique_key );
}
public function increase_times( $item, $truncate = true ) {
++$this->times;
$this->times_dates[] = $item->date;
if ( $truncate && ( self::MAX_LOG_ENTRIES < count( $this->times_dates ) ) ) {
$this->times_dates = array_slice( $this->times_dates, -self::MAX_LOG_ENTRIES );
}
}
public function format( $format = 'html' ) {
$trace = $this->format_trace();
if ( empty( $trace ) ) {
return $this->to_formatted_string( $format );
}
$copy = clone $this;
$copy->meta['trace'] = $trace;
return $copy->to_formatted_string( $format );
}
public function get_name() {
return 'Log';
}
private function format_trace() {
$trace = empty( $this->meta['trace'] ) ? '' : $this->meta['trace'];
if ( is_string( $trace ) ) {
return $trace;
}
$trace_str = '';
foreach ( $trace as $key => $trace_line ) {
$format = static::TRACE_FORMAT;
$trace_line['key'] = $key;
if ( empty( $trace_line['file'] ) ) {
$format = str_replace( 'file(line): ', '', $format );
}
$trace_str .= PHP_EOL . strtr( $format, $trace_line );
$trace_str .= empty( $trace_line['args'] ) ? '' : var_export( $trace_line['args'], true ); // @codingStandardsIgnoreLine
}
return $trace_str . PHP_EOL;
}
private function set_trace() {
if ( ! empty( $this->args['trace'] ) && true === $this->args['trace'] ) {
$limit = empty( $this->args['trace_limit'] ) ? static::TRACE_LIMIT : $this->args['trace_limit'];
$stack = debug_backtrace( DEBUG_BACKTRACE_IGNORE_ARGS ); // @codingStandardsIgnoreLine
while ( ! empty( $stack ) && ! empty( $stack[0]['file'] ) && ( false !== strpos( $stack[0]['file'], 'core' . DIRECTORY_SEPARATOR . 'logger' ) ) ) {
array_shift( $stack );
}
$this->meta['trace'] = array_slice( $stack, 0, $limit );
return;
}
if ( is_array( $this->args ) ) {
unset( $this->args['trace'] );
}
}
}