晋太元中,武陵人捕鱼为业。缘溪行,忘路之远近。忽逢桃花林,夹岸数百步,中无杂树,芳草鲜美,落英缤纷。渔人甚异之,复前行,欲穷其林。 林尽水源,便得一山,山有小口,仿佛若有光。便舍船,从口入。初极狭,才通人。复行数十步,豁然开朗。土地平旷,屋舍俨然,有良田、美池、桑竹之属。阡陌交通,鸡犬相闻。其中往来种作,男女衣着,悉如外人。黄发垂髫,并怡然自乐。 见渔人,乃大惊,问所从来。具答之。便要还家,设酒杀鸡作食。村中闻有此人,咸来问讯。自云先世避秦时乱,率妻子邑人来此绝境,不复出焉,遂与外人间隔。问今是何世,乃不知有汉,无论魏晋。此人一一为具言所闻,皆叹惋。余人各复延至其家,皆出酒食。停数日,辞去。此中人语云:“不足为外人道也。”(间隔 一作:隔绝) 既出,得其船,便扶向路,处处志之。及郡下,诣太守,说如此。太守即遣人随其往,寻向所志,遂迷,不复得路。 南阳刘子骥,高尚士也,闻之,欣然规往。未果,寻病终。后遂无问津者。
|
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/akaindir/public_html/crm/libraries/InStyle/ |
Upload File : |
<?php
/**
* InStyle
* Embedded CSS to Inline CSS Converter Class
* @version 0.1
* @updated 09/18/2009
*
* @author David Lim
* @email miliak@orst.edu
* @link http://www.davidandjennilyn.com
* @acknowledgements Simple HTML Dom
*/
class InStyle {
function convert($document) {
// Extract the CSS
preg_match('/<style[^>]+>(?<css>[^<]+)<\/style>/s', $document, $matches);
// Strip out extra newlines and tabs from CSS
$css = preg_replace("/[\n\r\t]+/s", "", $matches['css']);
// Returns the css after removing media queries
$refactoredCss = $this->findAndRemoveMediaQueries($css);
// Extract each CSS declaration
preg_match_all('/([a-zA-Z0-9_ ,#\.]+){([^}]+)}/s', $refactoredCss, $rules, PREG_SET_ORDER);
// For each CSS declaration, explode the selector and declaration into an array
// Array index 1 is the CSS selector
// Array index 2 is the CSS rule(s)
foreach ($rules as $rule) {
$styles[trim($rule['1'])] = $styles[trim($rule['1'])].trim($rule['2']);
}
// DEBUG: Show selector and declaration
if ($debug) {
echo '<pre>';
foreach ($styles as $selector=>$styling) {
echo $selector . ':<br>';
echo $styling . '<br/><br/>';
}
echo '</pre><hr/>';
}
$html_dom = new simple_html_dom();
// Load in the HTML without the head and style definitions
$html_dom->load($document); // Retaining styles without removing from head tag
// For each style declaration, find the selector in the HTML and add the inline CSS
if (!empty($styles)) {
foreach ($styles as $selector=>$styling) {
foreach ($html_dom->find($selector) as $element) {
$elementStyle = $element->style;
if(substr($elementStyle, -1) == ';'){
$element->style .= $styling;
} else {
$element->style .= ";".$styling;
}
}
}
$inline_css_message = $html_dom->save();
return $inline_css_message;
}
return false;
}
/**
* Function to find and remove media queries and return css without media queries
* @param type $css
* @return type
*/
function findAndRemoveMediaQueries($css){
$mediaBlocks = array();
$start = 0;
while (($start = strpos($css, "@media", $start)) !== false) {
// stack to manage brackets
$s = array();
// get the first opening bracket
$i = strpos($css, "{", $start);
// if $i is false, then there is probably a css syntax error
if ($i !== false)
{
// push bracket onto stack
array_push($s, $css[$i]);
// move past first bracket
$i++;
while (!empty($s))
{
// if the character is an opening bracket, push it onto the stack, otherwise pop the stack
if ($css[$i] == "{")
{
array_push($s, "{");
}
elseif ($css[$i] == "}")
{
array_pop($s);
}
$i++;
}
// cut the media block out of the css and store
$mediaBlocks[] = substr($css, $start, ($i) - $start);
// set the new $start to the end of the block
$start = $i;
}
}
foreach($mediaBlocks as $value){
$css = str_replace($value,'',$css);
}
return $css;
}
}
/* End of file inline_css.php */