調試bug 請通知本人,謝謝! 新版功能: 1. 新增{-script lang='php'-} 範本也可以寫php程式碼 2.修改1.0 細節錯誤: 如無用功程式碼,最佳化核心程式碼,提高運行編譯速度。 3.新增範本格式化函數{-$string|subistr(12):'...'-} ,時間格式化 {-$time|time('ymd')-}
- /**
- * [Wecis] (C)2012-2099haowei Inc.
- * 這不是免費軟體,使用須遵守許可條款
- * 版本:2.0 RC
- **/
-
- class wecis{
-
- private $assign=array ( );
- public $tpl_cache_dir = 'cache/';
- public $tpl_cache_open = TRUE;
- public $tpl_cache_time = 5 ;
- public $tpl_tpl_dir = 'template/dir; = '{-';
- public $tpl_rw_right = '-}';
-
- public function wecis(){
- return '[{name:'wecis 2.0 rc'}]';
- }
-
- public function allocate($tplvar,$value){
- if(empty($tplvar) ||empty($value)){
- $this->error(' wecis- > allocate() 缺少參數');
- }
- return $this->assign[$tplvar]=$value;
- }
-
- public function display($ tplfile){
-
- public function display($ tplfile){
- if(empty($tplfile)){ $this->error('wecis-> display() 參數遺失'); }
- if($this->tpl_cache_open){
- if(file_exists($this->tpl_cache_dir.$this->cahce_format($tplfile))){
- if($this-> ;cahce_timeout(> ; $tplfile)) {
- $this->cache_delete($tplfile);
- 包含$this->cache($tplfile) ? $this->tpl_cache_dir.$this->cahce_format($tplfile) : '' ;
- }else{
- 包含$this->tpl_cache_dir.$this->cahce_format($tplfile);
-
- }
- }else{
- 包含$this-this>cache( $tplfile) ? >tpl_cache_dir.$this->cahce_format($tplfile) : '';
- }
- }
-
- 公用函數儲存($tplfile){
- $data = file_get_contents ($this-> tpl_tpl_dir.$tplfile);
- $data = preg_replace('/'.$this->tpl_rw_left.'script lang='php''.$this->tpl_rw_right.'/' ,' $data = preg_replace('/'.$this->tpl_rw_left.'/script'.$this->tpl_rw_right.'/','?> ;',$data);
- $ data = preg_replace('/'.$this->tpl_rw_left.'loop ($(.*)?) as ($(.*)?)'.$this->tpl_rw_right.'/','',$data);
- $data = preg_replace('/'.$this->tpl_rw_left. '/loop'.$this->tpl_rw_right.'/','',$data);
- $data = preg_replace('/'.$this->tpl_rw_left.'($( .*)?)[((.*)?)]'.$this->tpl_rw_right.'/',' $data = preg_replace('/'.$this->tpl_rw_left.'if((.*)?)'.$this->tpl_rw_right.'/',' php if(\1){ ?>',$data );
- $data = preg_replace('/'.$this->tpl_rw_left.'else'.$this->tpl_rw_right.'/', '',$data);
- $data = preg_replace('/'.$this->tpl_rw_left.'/if'.$this->tpl_rw_right.'/ ','',$data);
- $data = preg_replace('/'.$this->tpl_rw_left.'($(.*)?)|subistr(((.*)?)):((.*)?)'.$this->tpl_rw_right.' /','',$data);
- $data = preg_replace('/'.$this->tpl_rw_left.'($( . *)?)|時間:(((.*)?))' .$this->tpl_rw_right.'/',"",$data) ;
- $data = preg_replace('/'.$this ->tpl_rw_left.'($(.*)?)'.$this->tpl_rw_right.'/',' ' ,$data);
- $arr ='';
- foreach($this->分配為$k=>$v) {
- if(!is_array($v)) {
- $ data = !is_numeric($v) ? 🎜> }else{
- $ arr.='';
- }
- }
- 回傳 file_put_contents($this->tpl_cache_dir.$this->cahce_format($tplfile),$arr.$data) ? 🎜>
- public function cahce_timeout($tplfile){
- $time = time();
- $filetime = fileatime($this->tpl_cache_dir.$this->cahce_format($4)); > return $time-$filetime > ($this->tpl_cache_time*60) ? 1 : 0;
- }
-
- public function cahce_format($tplfile){
- return md5($this->md5($this-md version()).str_replace('/','.',$tplfile ).'.php';
- }
-
- public function cache_delete($tplfile){
- return unlink($this ->tpl_cache_dir.$this->cahce_format($tplfile)) ? 1 : 0;
- }
-
- 私有函數錯誤($str){
- 返回退出($str);
- }
-
- 公用函數版本(){
- }
-
- 公用函數版本(){
- return 'wecis 2.0 RC';
- }
-
- }
-
-
-
- 複製程式碼
複製程式碼
|