📄 html.class.php
字号:
<?php
///////////////////////////////////////////////////////////////////
// Author:daong | E-mail: dahongy@gmail.com
// Copyright © Http://www.phpstcms.cn
// This is not a free software, please to pay for more functions
// $Id: 2009-05-01 version V2.5 $
///////////////////////////////////////////////////////////////////
class html
{
var $type;
var $id;
var $page;
var $arg;
var $content;
function html($type,$arg=array())
{
if($arg) ksort($arg);
$this->type = $type;
$this->arg = $arg;
$this->content = $this->getContent($this->type, $this->arg);
$this->content = $this->convert($this->content);
//$this->write($this->content, $this->type, $arg);
}
function compile($arg)
{
$query = "";
if($arg)
{
foreach($arg as $k => $v)
{
$rs[] = $k ."=". $v;
}
$query = "?".implode("&",$rs);
}
return $query;
}
function getArg($arg)
{
$str = "";
if($arg)
{
foreach($arg as $k => $v)
{
if($k=="id")
{
$rs[] = $v;
}
elseif($k=="action")
{
$rs[] = $v;
}
else
{
$rs[] = substr($k,0,1).$v;
}
}
$str = implode("_",$rs);
}
return $str;
}
function getContent($type, $arg)
{
global $STCMS;
$url = WEB_URL."{$type}.php".$this->compile($arg);
$host = "http://".$STCMS['DOMAIN'];
if(strrchr(WEB_URL,$host) === false)
{
$url = $host.$url;
}
$url = str_replace("http:/","http://",str_replace("//","/",$url));
$content = file_get_contents($url);
return $content;
}
function convert($content)
{
$content = preg_replace("|href=\"".WEB_URL."category.php\?id=(\d+)\"|i", "href=\"".WEB_URL."html/category/\$1.html\"", $content);
$content = preg_replace("|href=\"".WEB_URL."special.php\?id=(\d+)\"|i", "href=\"".WEB_URL."html/special/\$1.html\"", $content);
$content = preg_replace("#href=\"".WEB_URL."special.php\?action=(new|rank|recommend)\"#i", "href=\"".WEB_URL."html/special/\$1.html\"", $content);
$content = preg_replace("#href=\"".WEB_URL."special.php\?action=(new|rank|recommend)&category=(\d+)&page=(\d+)\"#i", "href=\"".WEB_URL."html/special/\$1_c\$2_p\$3.html\"", $content);
$content = preg_replace("#href=\"".WEB_URL."special.php\?action=(new|rank|recommend)&category=(\d+)\"#i", "href=\"".WEB_URL."html/special/\$1_c\$2.html\"", $content);
$content = preg_replace("#href=\"".WEB_URL."special.php\?action=(new|rank|recommend)&page=(\d+)\"#i", "href=\"".WEB_URL."html/special/\$1_p\$2.html\"", $content);
$content = preg_replace("|href=\"".WEB_URL."music.php\?id=(\d+)\"|i", "href=\"".WEB_URL."html/music/\$1.html\"", $content);
$content = preg_replace("#href=\"".WEB_URL."music.php\?action=(new|rank|recommend|hot)&category=(\d+)&page=(\d+)\"#i", "href=\"".WEB_URL."html/music/\$1_c\$2_p\$3.html\"", $content);
$content = preg_replace("#more\('".WEB_URL."music.php\?action=(new|rank|recommend|hot)&category=(\d+)'#i", "more('".WEB_URL."html/music/\$1_c\$2.html'", $content);
$content = preg_replace("#href=\"".WEB_URL."music.php\?action=(new|rank|recommend|hot)&category=(\d+)\"#i", "href=\"".WEB_URL."html/music/\$1_c\$2.html\"", $content);
$content = preg_replace("#href=\"".WEB_URL."music.php\?action=(new|rank|recommend|hot)\"#i", "href=\"".WEB_URL."html/music/\$1.html\"", $content);
$content = preg_replace("|href=\"".WEB_URL."page.php\?id=(\d+)\"|i", "href=\"".WEB_URL."html/page/\$1.html\"", $content);
$content = preg_replace("|href=\"".WEB_URL."\"|i", "href=\"".WEB_URL."html/index.html\"", $content);
return $content;
}
function write()
{
if($this->type == "index")
{
$path = STCMS_ROOT."index.html";
}
else
{
$path = STCMS_ROOT."/html/{$this->type}/".$this->getArg($this->arg).".html";
}
return writeFile($path, $this->content, "w+");
}
}
?>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -