コードをコピー コードは次のとおりです:
/*template.class.php
@ Kangsheng Weibo テンプレート抽出クラス このテンプレートは時間をかけて独自に作成すると使いやすいと思います。 by Lei Rijin
@ が ctt テンプレートを調べました。これは phpcms テンプレートに似ていますか? ? ^_^ ふふふ! ! !
@ Weibo http://weibo.com/lrjxgl
@ 良いものはみんなで共有します。抽出について質問がある場合は、
@ に問い合わせてください。デフォルトのテンプレート ファイルは .htm
$tpl = new template ('skin',"default");
$tpl->gt;objdir='tpp';
$tpl->rewrite=true;//書き換えを有効にするにはサーバーのサポートが必要です
$tpl-> ;rewrite_rule=array(array("/index.php/"),array("index.html")); //ルールを書き換えます
$tpl->assign("indexurl"," index.php") ;
$tpl->assign("str","私は文字列ラララです");
$tpl->assign("ec","エコーアウトされました");
$tpl->assign("subhtml","{subtpl ttt} これはテンプレート ファイルを導入するために使用され、これは ttt.htm を導入するために使用されます");
$tpl->assign ("a ",array('dasdasd'.'bbbbbbb','cccccccccccc'));
$tpl->assign("i",1); ");
*/
if(!define("CHARSET"))define("CHARSET","gb2312");//文字エンコーディング
if(!define("DIR_TPL")) 定義("DIR_TPL ","tpl");//デフォルトのテンプレート ディレクトリ
if(!define("DIR_DATA"))define("DIR_DATA","data");//デフォルトのデータ ディレクトリ
if(! generated(" DEBUG"))define("DEBUG",0);//デフォルトの実行モード
class template {
//note var
public $rewrite=false;//擬似を有効にするかどうかstatic rewrite
public $rewrite_rule=array(); //疑似静的ルールを設定します
public $defaulttpldir;//デフォルトのテンプレート
public $tpldir;//テンプレート ディレクトリ
public $objdir;/ /コンパイル キャッシュ ディレクトリ
public $tplfile;//テンプレート ファイル
public $objfile;//コンパイル ファイル
public $tplid=1;//テンプレート番号
public $currdir='default'; //現在のスタイルディレクトリ
public $vars=array();//メモ変数テーブル
public $removeblanks=false;//スペースを削除
public $stdout='display';//出力タイプ
関数 __construct ($tplid, $currdir) {
$this->template($tplid, $currdir);
}
関数テンプレート($tplid, $currdir) {
ob_start ();
if(file_exists(DIR_TPL.'/'.$currdir)) {
$this->currdir = $currdir
$this->tplid = $tplid; } else {
$this->currdir = 'default';
$this->tplid = 1;
}
$this->defaulttpldir = DIR_TPL.'/default';
$ this->tpldir = DIR_TPL.'/'.$this->currdir;
$this->objdir = DIR_DATA.'/cache/tpl';
if(version_compare(PHP_VERSION) , '5' ) == -1) {
register_shutdown_function(array(&$this, '__destruct'))
}
}
//note public
function assign($ k, $v ) {
$this->vars[$k] = $v;
}
//note public
function display($file) {
extract($) this->vars, EXTR_SKIP);
include $this->getObj($file)
}
function getObj($file, $tpldir = '') {
$subdir = ($pos = strpos($file, '/')) === false ? '' : substr($file, 0, $pos);
$file = $subdir ? 1) : $ ファイル;
$this->tplfile = ($tpldir ? $tpldir : $this->tpldir).'/'.($subdir ? $subdir.'/' : '')。 $file.' .htm';
$this->objfile = $this->objdir.'/'.($tpldir ? '' : $this->tplid.'_')サブディレクトリ ? $subdir .'_' : '').$file.'.php';
//デフォルトのディレクトリに注意してください
if(@filemtime($this->tplfile) === FALSE) {
$ this->tplfile = $this->defaulttpldir.'/'.($subdir ? $subdir.'/' : '').$file.'.htm'; >//note 比較の有効期限が切れているかどうかを判断します
if(!file_exists($this->objfile) DEBUG && @filemtime($this->objfile) tplfile)) {
$this->compile();
}
return $this->objfile;
}
function getTpl($file) {
$subdir = ($pos = strpos($file, '/')) === false ? '' : substr($file, 0, $pos);
$file = $subdir ($file, $pos + 1) : $file;
$tplfile = $this->tpldir.'/'.($subdir ? $subdir.'/' : '').$file.'.htm';
if(@filemtime ($tplfile) == = FALSE) {
$tplfile = $this->defaulttpldir.'/'.($subdir ? $subdir.'/' : '').$file.'.htm';
}
return $tplfile;
}
functioncompile() {
$var_regexp = "@?\$[a-zA-Z_]w*(?:[[w. "'[]$] +])*";
$vtag_regexp = "=(@?\$[a-zA-Z_]w*(?:[[w."'[]$] +])*)? >";
$const_regexp = "{([w]+)}";
$template = file_get_contents($this->tplfile);
for($i = 1; $i < ;= 3; $i++) {
if(strpos($template, '{subtpl') !== FALSE) {
if(DEBUG == 2) {
$ template = str_replace('{ subtpl ', '{tpl ', $template);
} else {
$template = preg_replace("/[nrt]*{subtpls+([a-z0-9_:/]) +)}[nrt] */ies", "file_get_contents($this->getTpl('\1'))", $template);
}
}
}
$remove = array(
'/(^rn)/*.+?(rn)*/(rn)/is',
'///note.+?(rn)/i',
'///デバッグ。+?(rn)/i'、
'/(^rn)(st)+/'、
'/(rn)/'、
);$this->removeblanks && $template = preg_replace($remove, '', $template);
$template = preg_replace("//s", "{\1}", $template);
$template = preg_replace("/{($var_regexp)}/", "=\1?>", $template);
$template = preg_replace("/{($const_regexp)}/", "=\1?>", $template);
$template = preg_replace("/(?", $template);
$template = preg_replace("/=(@?\$[a-zA-Z_]w*)(([[\$[]w]+])+)?>/ies" , "$this->arrayindex('\1', '\2')", $template);
$template = preg_replace("/{{eval (.*?)}}/ies", "$this->stripvtag(' \1?>')", $template);
$template = preg_replace("/{eval (.*?)}/ies", "$this->stripvtag(' \1?>')", $template);
$template = preg_replace("/[nrt]*{echos+(.+?)}[nrt]*/ies", "$this->stripvtag(' echo \1; ?>' 、'')"、$template);
$template = preg_replace("/{for (.*?)}/ies", "$this->stripvtag(' for(\1) {?>')", $template) ;
$template = preg_replace("/{elseifs+(.+?)}/ies", "$this->stripvtag(' } elseif(\1) { ?>')", $template );
for($i=0; $i$template = preg_replace("/{loops+$vtag_regexps+$vtag_regexps+$vtag_regexp}(.+?){/loop}/ies" , "$this->loopsection('\1', '\2', '\3', '\4')", $template);
$template = preg_replace("/{loops+$vtag_regexps+$vtag_regexp}(.+?){/loop}/ies", "$this->loopsection('\1', '', '\2' 、'\3')"、$template);
}
$template = preg_replace("/{ifs+(.+?)}/ies", "$this->stripvtag(' if(\1) { ?>')" 、$template);
$template = preg_replace("/{tpls+(w+?)}/is", " include $this->getObj("\1");?>", $template);
$template = preg_replace("/{tpls+(.+?)}/ise", "$this->stripvtag(' include $this->getObj("\1"); ?> ;')", $template);
$template = preg_replace("/{tmptpls+(w+?)}/is", " include $this->getObj("\1", $this->objdir);?>" 、$template);
$template = preg_replace("/{tmptpls+(.+?)}/ise", "$this->stripvtag(' include $this->getObj("\1", $this- >objdir); ?>')", $template);
$template = preg_replace("/{else}/is", " } else { ?>", $template);
$template = preg_replace("/{/if}/is", " } ?>", $template);
$template = preg_replace("/{/for}/is", " } ?>", $template);
$template = preg_replace("/$const_regexp/", "=\1?>", $template);//note {else} 也符合常量格式,此处注意要先後顺序
$template = preg_replace("/(\$[a-zA-Z_]w+[)([a-zA-Z_]w+)]/i", "\1'\2']", $template);
$fp = fopen($this->objfile, 'w');
fwrite($fp, $template);
fclose($fp);
}
function arrayindex($name, $items) {
$items = preg_replace("/[([a-zA-Z_]w*)]/is", "['\1' ]", $items);
return "=$name$items?>";
}
functionstripvtag($s) {
$vtag_regexp = "=(@?\$[a-zA-Z_]w*(?:[[w."'[] $]+])*)?>";
return preg_replace("/$vtag_regexp/is", "\1", str_replace("\"", '"', $s));
}
関数ループセクション($arr, $k, $v, $statement) {
$arr = $this->stripvtag($arr);
$k = $this->stripvtag( $k);
$v = $this->stripvtag($v);
$statement("\"", '"', $statement);
return $k " foreach((array)$arr as $k => $v) {?>$statement}?>" : " foreach((array)$arr as $v) {?>$statement } ?>";
}
function __destruct() {
$content = ob_get_contents();
//处理 rewrite
if($this->rewrite) {
$arr=$this->rewrite_rule;
$s=$arr[0];
$content=preg_replace($s,$e,$)
}
ob_end_clean();
echo $content;
}
$tpl = 新しいテンプレート('スキン',"デフォルト"); $tpl->objdir='tpp';
$tpl->rewrite=true;//开启rewrite 必要服务器のサポート
$tpl->rewrite_rule=array("/index.php/ "),array("index.html")); //書き換え
$tpl->assign("indexurl","index.php");
$tpl->assign("str ","我是字符串啦啦啦");
$tpl->assign("ec","我是被echo出来的");
$tpl->assign("subhtml" ,"{subtpl ttt}これはモジュール ファイルを挿入するために使用されます、これは ttt.htm に挿入されます"); cccccccccccc'));
$tpl->assign("i",1);
新規建 tpl/default/index.html
复制代
代码如下:

ホットAIツール

Undresser.AI Undress
リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover
写真から衣服を削除するオンライン AI ツール。

Undress AI Tool
脱衣画像を無料で

Clothoff.io
AI衣類リムーバー

AI Hentai Generator
AIヘンタイを無料で生成します。

人気の記事

ホットツール

Safe Exam Browser
Safe Exam Browser は、オンライン試験を安全に受験するための安全なブラウザ環境です。このソフトウェアは、あらゆるコンピュータを安全なワークステーションに変えます。あらゆるユーティリティへのアクセスを制御し、学生が無許可のリソースを使用するのを防ぎます。

EditPlus 中国語クラック版
サイズが小さく、構文の強調表示、コード プロンプト機能はサポートされていません

DVWA
Damn Vulnerable Web App (DVWA) は、非常に脆弱な PHP/MySQL Web アプリケーションです。その主な目的は、セキュリティ専門家が法的環境でスキルとツールをテストするのに役立ち、Web 開発者が Web アプリケーションを保護するプロセスをより深く理解できるようにし、教師/生徒が教室環境で Web アプリケーションを教え/学習できるようにすることです。安全。 DVWA の目標は、シンプルでわかりやすいインターフェイスを通じて、さまざまな難易度で最も一般的な Web 脆弱性のいくつかを実践することです。このソフトウェアは、

ドリームウィーバー CS6
ビジュアル Web 開発ツール

SAP NetWeaver Server Adapter for Eclipse
Eclipse を SAP NetWeaver アプリケーション サーバーと統合します。
