Advertisement
Guest User

Untitled

a guest
Feb 19th, 2013
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.97 KB | None | 0 0
  1. <?php
  2. /**
  3. *
  4. * @ This file is created by deZender.Net
  5. * @ deZender (PHP5 Decoder for ionCube Encoder)
  6. *
  7. * @ Version : 1.1.5.0
  8. * @ Author : DeZender
  9. * @ Release on : 09.06.2012
  10. * @ Official site : http://DeZender.Net
  11. *
  12. */
  13.  
  14.  
  15. class template {
  16. var $tplpath = './templates/';
  17. var $currenttpl = 'clipcms';
  18. var $cache = true;
  19. protected $variables = array( );
  20. protected $blockvars = array( );
  21.  
  22. /**
  23. *@param string - filename
  24. *@access public
  25. */
  26. function display($filename) {
  27. global $url;
  28. global $db;
  29. global $host;
  30.  
  31. $file = $this->tplpath . $this->currenttpl . '/' . $filename;
  32. $this->assign_vars( array( 'TPL_PATH' => $url . '/' . $this->tplpath . $this->currenttpl, 'TPL_PATH_COMMON' => $url . '/' . $this->tplpath . 'common' ) );
  33.  
  34. if (!file_exists( $file )) {
  35. $error = debug_backtrace( );
  36. echo '
  37. <html>
  38. <head>
  39. <title>Error in file ';
  40. print_r( $error[0]['file'] );
  41. echo '&nbsp;on line ';
  42. @print_r( $error[0]['line'] );
  43. echo '</title>
  44. </head>
  45. <body>
  46. <font face=\'Arial\'>
  47. <h4 title=\'File ';
  48. @print_r( $error[0]['file'] );
  49. echo ' line ';
  50. @print_r( $error[0]['line'] );
  51. echo '\'>Template Error in file \'';
  52. @print_r( $error[0][file] );
  53. echo '\' on line \'';
  54. @print_r( $error[0]['line'] );
  55. echo '\':</h4>
  56. <div title=\'File ' . $file . '\' style=\'border:1px solid grey;padding:0.2em;text-align:justify;font-size:9pt\'>
  57. File <b>' . $file . '</b> does not exists!
  58. </div>
  59. </font>
  60. </body>
  61. </html>';
  62. exit( );
  63. }
  64.  
  65. $lastmodify = filemtime( $file );
  66. $cacher = new tplcacher( $filename, $lastmodify, $this->currenttpl );
  67.  
  68. if (( $cacher->checkvalid( ) === true && $this->cache )) {
  69. $tpl = $cacher->getdata( );
  70. } else {
  71. $tpl = $this->parser( file_get_contents( $file ) );
  72.  
  73. if ($this->cache) {
  74. $cacher->write( $tpl );
  75. $cache_file = dirname( __FILE__ ) . '/../cache/' . $filename . '.php';
  76.  
  77. if (file_exists( $cache_file )) {
  78. touch( $cache_file, $lastmodify );
  79. }
  80. }
  81. }
  82.  
  83.  
  84. if ($this->cache) {
  85. include( $cacher->getfile( ) );
  86. return null;
  87. }
  88.  
  89. eval( '?>' . $tpl );
  90. }
  91.  
  92. /**
  93. *@param string - data to parse
  94. *@access private
  95. */
  96. function parser($data) {
  97. global $debug;
  98.  
  99. preg_match_all( '/<!-- BEGIN (.*) -->(.*)<!-- END \1 -->/Usi', $data, $blockvars );
  100. foreach ($blockvars[1] as $key => $value) {
  101. $tmpdata = $blockvars[2][$key];
  102. $tmpdata = preg_replace( '/{' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)}/Ui', '<?php echo $row[""]; ?>', $tmpdata );
  103. $tmpdata = preg_replace( '/<!--\s*IF\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*-->/Ui', '<?php if(isset($row[""]) && $row[""]) { ?>', $tmpdata );
  104. $tmpdata = preg_replace( '/<!--\s*IF\s*NOT\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*-->/Ui', '<?php if(!isset($row[""]) || !$row[""]) { ?>', $tmpdata );
  105. $tmpdata = preg_replace( '/<!--\s*IF\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*=\s*\'([^\']+)\'\s*-->/Ui', '<?php if(isset($row[""]) && $row[""] == \'\') { ?>', $tmpdata );
  106. $tmpdata = preg_replace( '/<!--\s*ELSEIF\s*' . preg_quote( $value, '/' ) . '\.([a-zA-Z0-9_\-]+)\s*-->/Ui', '<?php } else if(isset($row[""]) && $row[""]) { ?>', $tmpdata );
  107. $data = preg_replace( '/' . preg_quote( $blockvars[0][$key], '/' ) . '/', '<?php foreach($this->blockvars["' . preg_quote( $value, '/' ) . '"] as $row) { ?>' . $tmpdata . '<?php } ?> ', $data );
  108. }
  109.  
  110. $data = preg_replace( '/{([a-zA-Z0-9_\-]+)}/iU', '<?php echo isset($this->variables[""]) ? $this->variables[""] : "{}"; ?>', $data );
  111. $data = preg_replace( '/<!--\s*INCLUDE\s+([^"]*)\s*-->/Usi', '<?php echo $this->display(""); ?>', $data );
  112. $data = preg_replace( '/<!--\s*IF\s([a-zA-Z0-9_]*)\s+=\s+([^"]+)\s*-->/Usi', '<?php if($this->variables[\'\'] == "") { ?>', $data );
  113. $data = preg_replace( '/<!--\s*IF\s([a-zA-Z0-9_]*)\s*-->/Usi', '<?php if(isset($this->variables[\'\']) && $this->variables[\'\']) { ?>', $data );
  114. $data = preg_replace( '/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s+=\s+([^"]+)\s*-->/Usi', '<?php if(isset($this->variables[\'\']) && $this->variables[\'\'] != "") { ?>', $data );
  115. $data = preg_replace( '/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s*-->/Usi', '<?php if(!isset($this->variables[\'\']) || !$this->variables[\'\']) { ?>', $data );
  116. $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 );
  117. $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 );
  118. $data = preg_replace( '/<!--\s*ELSEIF\s([a-zA-Z0-9_]*)\s*-->/Usi', '<?php }elseif(isset($this->variables[\'\']) && $this->variables[\'\']) { ?>', $data );
  119. $data = preg_replace( '/<!--\s*ELSE\s*-->/Usi', '<?php }else{ ?>', $data );
  120. $data = preg_replace( '/<!--\s*ENDIF\s(.*)\s*-->/Usi', '<?php } ?>', $data );
  121.  
  122. if (!$debug) {
  123. if (!function_exists( 'sanitize_output' )) {
  124. }
  125.  
  126. $data = sanitize_output( $data );
  127. }
  128.  
  129. return $data;
  130. }
  131.  
  132. /**
  133. *@param string - name of variable
  134. *@param string - value of variable
  135. *@access public
  136. */
  137. function assign_var($name, $value) {
  138. $this->variables[$name] = $value;
  139. }
  140.  
  141. /**
  142. *@param array - array of variables
  143. *@access public
  144. */
  145. function assign_vars($array) {
  146. $args = func_get_args( );
  147.  
  148. if (1 < count( $args )) {
  149. $backtrace = debug_backtrace( );
  150. echo nl2br( print_r( $backtrace, true ) );
  151. exit( );
  152. }
  153.  
  154. foreach ($array as $key => $value) {
  155. $this->variables[$key] = $value;
  156. }
  157.  
  158. }
  159.  
  160. function assign_block_vars($name, $array) {
  161. $this->blockvars[$name][] = $array;
  162. }
  163. .........................................................
  164. ...................................
  165. ..................
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement