Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Encoder)
- *
- * @ Version : 1.1.5.0
- * @ Author : DeZender
- * @ Release on : 09.06.2012
- * @ Official site : http://DeZender.Net
- *
- */
- class template {
- var $tplpath = './templates/';
- var $currenttpl = 'clipcms';
- var $cache = true;
- protected $variables = array( );
- protected $blockvars = array( );
- /**
- *@param string - filename
- *@access public
- */
- function display($filename) {
- global $url;
- global $db;
- global $host;
- $file = $this->tplpath . $this->currenttpl . '/' . $filename;
- $this->assign_vars( array( 'TPL_PATH' => $url . '/' . $this->tplpath . $this->currenttpl, 'TPL_PATH_COMMON' => $url . '/' . $this->tplpath . 'common' ) );
- if (!file_exists( $file )) {
- $error = debug_backtrace( );
- echo '
- <html>
- <head>
- <title>Error in file ';
- print_r( $error[0]['file'] );
- echo ' on line ';
- @print_r( $error[0]['line'] );
- echo '</title>
- </head>
- <body>
- <font face=\'Arial\'>
- <h4 title=\'File ';
- @print_r( $error[0]['file'] );
- echo ' line ';
- @print_r( $error[0]['line'] );
- echo '\'>Template Error in file \'';
- @print_r( $error[0][file] );
- echo '\' on line \'';
- @print_r( $error[0]['line'] );
- echo '\':</h4>
- <div title=\'File ' . $file . '\' style=\'border:1px solid grey;padding:0.2em;text-align:justify;font-size:9pt\'>
- File <b>' . $file . '</b> does not exists!
- </div>
- </font>
- </body>
- </html>';
- exit( );
- }
- $lastmodify = filemtime( $file );
- $cacher = new tplcacher( $filename, $lastmodify, $this->currenttpl );
- if (( $cacher->checkvalid( ) === true && $this->cache )) {
- $tpl = $cacher->getdata( );
- } else {
- $tpl = $this->parser( file_get_contents( $file ) );
- if ($this->cache) {
- $cacher->write( $tpl );
- $cache_file = dirname( __FILE__ ) . '/../cache/' . $filename . '.php';
- if (file_exists( $cache_file )) {
- touch( $cache_file, $lastmodify );
- }
- }
- }
- if ($this->cache) {
- include( $cacher->getfile( ) );
- return null;
- }
- eval( '?>' . $tpl );
- }
- /**
- *@param string - data to parse
- *@access private
- */
- function parser($data) {
- global $debug;
- preg_match_all( '/<!-- BEGIN (.*) -->(.*)<!-- END \1 -->/Usi', $data, $blockvars );
- foreach ($blockvars[1] as $key => $value) {
- $tmpdata = $blockvars[2][$key];
- $tmpdata = preg_replace( '/{' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)}/Ui', '<?php echo $row[""]; ?>', $tmpdata );
- $tmpdata = preg_replace( '/<!--\s*IF\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*-->/Ui', '<?php if(isset($row[""]) && $row[""]) { ?>', $tmpdata );
- $tmpdata = preg_replace( '/<!--\s*IF\s*NOT\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*-->/Ui', '<?php if(!isset($row[""]) || !$row[""]) { ?>', $tmpdata );
- $tmpdata = preg_replace( '/<!--\s*IF\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*=\s*\'([^\']+)\'\s*-->/Ui', '<?php if(isset($row[""]) && $row[""] == \'\') { ?>', $tmpdata );
- $tmpdata = preg_replace( '/<!--\s*ELSEIF\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*-->/Ui', '<?php } else if(isset($row[""]) && $row[""]) { ?>', $tmpdata );
- $data = preg_replace( '/' . preg_quote( $blockvars[0][$key], '/' ) . '/', '<?php foreach($this->blockvars["' . preg_quote( $value, '/' ) . '"] as $row) { ?>' . $tmpdata . '<?php } ?> ', $data );
- }
- $data = preg_replace( '/{([a-zA-Z0-9_\-]+)}/iU', '<?php echo isset($this->variables[""]) ? $this->variables[""] : "{}"; ?>', $data );
- $data = preg_replace( '/<!--\s*INCLUDE\s+([^"]*)\s*-->/Usi', '<?php echo $this->display(""); ?>', $data );
- $data = preg_replace( '/<!--\s*IF\s([a-zA-Z0-9_]*)\s+=\s+([^"]+)\s*-->/Usi', '<?php if($this->variables[\'\'] == "") { ?>', $data );
- $data = preg_replace( '/<!--\s*IF\s([a-zA-Z0-9_]*)\s*-->/Usi', '<?php if(isset($this->variables[\'\']) && $this->variables[\'\']) { ?>', $data );
- $data = preg_replace( '/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s+=\s+([^"]+)\s*-->/Usi', '<?php if(isset($this->variables[\'\']) && $this->variables[\'\'] != "") { ?>', $data );
- $data = preg_replace( '/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s*-->/Usi', '<?php if(!isset($this->variables[\'\']) || !$this->variables[\'\']) { ?>', $data );
- $data = preg_replace( '/<!--\s*IF\s([a-zA-Z0-9_]*)\s*AND\s*([a-zA-Z0-9_]*)\s*-->/Usi', '<?php if((isset($this->variables[\'\']) && $this->variables[\'\']) && isset($this->variables[\'\']) && $this->variables[\'\']) { ?>', $data );
- $data = preg_replace( '/<!--\s*IF\s([a-zA-Z0-9_]*)\s*OR\s*([a-zA-Z0-9_]*)\s*-->/Usi', '<?php if((isset($this->variables[\'\']) OR isset($this->variables[\'\']) )) { ?>', $data );
- $data = preg_replace( '/<!--\s*ELSEIF\s([a-zA-Z0-9_]*)\s*-->/Usi', '<?php }elseif(isset($this->variables[\'\']) && $this->variables[\'\']) { ?>', $data );
- $data = preg_replace( '/<!--\s*ELSE\s*-->/Usi', '<?php }else{ ?>', $data );
- $data = preg_replace( '/<!--\s*ENDIF\s(.*)\s*-->/Usi', '<?php } ?>', $data );
- if (!$debug) {
- if (!function_exists( 'sanitize_output' )) {
- }
- $data = sanitize_output( $data );
- }
- return $data;
- }
- /**
- *@param string - name of variable
- *@param string - value of variable
- *@access public
- */
- function assign_var($name, $value) {
- $this->variables[$name] = $value;
- }
- /**
- *@param array - array of variables
- *@access public
- */
- function assign_vars($array) {
- $args = func_get_args( );
- if (1 < count( $args )) {
- $backtrace = debug_backtrace( );
- echo nl2br( print_r( $backtrace, true ) );
- exit( );
- }
- foreach ($array as $key => $value) {
- $this->variables[$key] = $value;
- }
- }
- function assign_block_vars($name, $array) {
- $this->blockvars[$name][] = $array;
- }
- .........................................................
- ...................................
- ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement