晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/wp-includesTZh/SimplePie/src/XML/Declaration/ |
Upload File : |
<?php
// SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
// SPDX-License-Identifier: BSD-3-Clause
declare(strict_types=1);
namespace SimplePie\XML\Declaration;
/**
* Parses the XML Declaration
*/
class Parser
{
/**
* XML Version
*
* @access public
* @var string
*/
public $version = '1.0';
/**
* Encoding
*
* @access public
* @var string
*/
public $encoding = 'UTF-8';
/**
* Standalone
*
* @access public
* @var bool
*/
public $standalone = false;
private const STATE_BEFORE_VERSION_NAME = 'before_version_name';
private const STATE_VERSION_NAME = 'version_name';
private const STATE_VERSION_EQUALS = 'version_equals';
private const STATE_VERSION_VALUE = 'version_value';
private const STATE_ENCODING_NAME = 'encoding_name';
private const STATE_EMIT = 'emit';
private const STATE_ENCODING_EQUALS = 'encoding_equals';
private const STATE_STANDALONE_NAME = 'standalone_name';
private const STATE_ENCODING_VALUE = 'encoding_value';
private const STATE_STANDALONE_EQUALS = 'standalone_equals';
private const STATE_STANDALONE_VALUE = 'standalone_value';
private const STATE_ERROR = false;
/**
* Current state of the state machine
*
* @access private
* @var self::STATE_*
*/
public $state = self::STATE_BEFORE_VERSION_NAME;
/**
* Input data
*
* @access private
* @var string
*/
public $data = '';
/**
* Input data length (to avoid calling strlen() everytime this is needed)
*
* @access private
* @var int
*/
public $data_length = 0;
/**
* Current position of the pointer
*
* @var int
* @access private
*/
public $position = 0;
/**
* Create an instance of the class with the input data
*
* @access public
* @param string $data Input data
*/
public function __construct(string $data)
{
$this->data = $data;
$this->data_length = strlen($this->data);
}
/**
* Parse the input data
*
* @access public
* @return bool true on success, false on failure
*/
public function parse(): bool
{
while ($this->state && $this->state !== self::STATE_EMIT && $this->has_data()) {
$state = $this->state;
$this->$state();
}
$this->data = '';
if ($this->state === self::STATE_EMIT) {
return true;
}
// Reset the parser state.
$this->version = '1.0';
$this->encoding = 'UTF-8';
$this->standalone = false;
return false;
}
/**
* Check whether there is data beyond the pointer
*
* @access private
* @return bool true if there is further data, false if not
*/
public function has_data(): bool
{
return (bool) ($this->position < $this->data_length);
}
/**
* Advance past any whitespace
*
* @return int Number of whitespace characters passed
*/
public function skip_whitespace()
{
$whitespace = strspn($this->data, "\x09\x0A\x0D\x20", $this->position);
$this->position += $whitespace;
return $whitespace;
}
/**
* Read value
*
* @return string|false
*/
public function get_value()
{
$quote = substr($this->data, $this->position, 1);
if ($quote === '"' || $quote === "'") {
$this->position++;
$len = strcspn($this->data, $quote, $this->position);
if ($this->has_data()) {
$value = substr($this->data, $this->position, $len);
$this->position += $len + 1;
return $value;
}
}
return false;
}
public function before_version_name(): void
{
if ($this->skip_whitespace()) {
$this->state = self::STATE_VERSION_NAME;
} else {
$this->state = self::STATE_ERROR;
}
}
public function version_name(): void
{
if (substr($this->data, $this->position, 7) === 'version') {
$this->position += 7;
$this->skip_whitespace();
$this->state = self::STATE_VERSION_EQUALS;
} else {
$this->state = self::STATE_ERROR;
}
}
public function version_equals(): void
{
if (substr($this->data, $this->position, 1) === '=') {
$this->position++;
$this->skip_whitespace();
$this->state = self::STATE_VERSION_VALUE;
} else {
$this->state = self::STATE_ERROR;
}
}
public function version_value(): void
{
if ($version = $this->get_value()) {
$this->version = $version;
$this->skip_whitespace();
if ($this->has_data()) {
$this->state = self::STATE_ENCODING_NAME;
} else {
$this->state = self::STATE_EMIT;
}
} else {
$this->state = self::STATE_ERROR;
}
}
public function encoding_name(): void
{
if (substr($this->data, $this->position, 8) === 'encoding') {
$this->position += 8;
$this->skip_whitespace();
$this->state = self::STATE_ENCODING_EQUALS;
} else {
$this->state = self::STATE_STANDALONE_NAME;
}
}
public function encoding_equals(): void
{
if (substr($this->data, $this->position, 1) === '=') {
$this->position++;
$this->skip_whitespace();
$this->state = self::STATE_ENCODING_VALUE;
} else {
$this->state = self::STATE_ERROR;
}
}
public function encoding_value(): void
{
if ($encoding = $this->get_value()) {
$this->encoding = $encoding;
$this->skip_whitespace();
if ($this->has_data()) {
$this->state = self::STATE_STANDALONE_NAME;
} else {
$this->state = self::STATE_EMIT;
}
} else {
$this->state = self::STATE_ERROR;
}
}
public function standalone_name(): void
{
if (substr($this->data, $this->position, 10) === 'standalone') {
$this->position += 10;
$this->skip_whitespace();
$this->state = self::STATE_STANDALONE_EQUALS;
} else {
$this->state = self::STATE_ERROR;
}
}
public function standalone_equals(): void
{
if (substr($this->data, $this->position, 1) === '=') {
$this->position++;
$this->skip_whitespace();
$this->state = self::STATE_STANDALONE_VALUE;
} else {
$this->state = self::STATE_ERROR;
}
}
public function standalone_value(): void
{
if ($standalone = $this->get_value()) {
switch ($standalone) {
case 'yes':
$this->standalone = true;
break;
case 'no':
$this->standalone = false;
break;
default:
$this->state = self::STATE_ERROR;
return;
}
$this->skip_whitespace();
if ($this->has_data()) {
$this->state = self::STATE_ERROR;
} else {
$this->state = self::STATE_EMIT;
}
} else {
$this->state = self::STATE_ERROR;
}
}
}
class_alias('SimplePie\XML\Declaration\Parser', 'SimplePie_XML_Declaration_Parser');