|
|
|
|
|
|
IT Security and Insecurity Portal |
|
|
SOlved |
|
Posted: Fri Jan 04, 2013 8:13 pm |
|
|
david |
Advanced user |
|
|
Joined: Jan 04, 2013 |
Posts: 58 |
|
|
|
|
|
|
|
|
Last edited by david on Thu Mar 07, 2013 10:53 pm; edited 1 time in total |
|
|
|
|
Can somebody help please |
|
Posted: Sat Jan 05, 2013 8:48 pm |
|
|
david |
Advanced user |
|
|
Joined: Jan 04, 2013 |
Posts: 58 |
|
|
|
|
|
|
|
|
Last edited by david on Thu Mar 07, 2013 10:53 pm; edited 1 time in total |
|
|
|
|
|
|
|
Posted: Mon Jan 07, 2013 10:30 am |
|
|
vv456 |
Advanced user |
|
|
Joined: Aug 24, 2012 |
Posts: 190 |
|
|
|
|
|
|
|
Decoded
Code: | <?php class template { public $tplpath = './templates/'; public $currenttpl = 'clipcms'; public $cache = true; private $variables = array(); private $blockvars = array(); public function reparse($str) { $return = $this->parser($str); return $return; } public function display($filename) { global $url; $file = $this->tplpath . $this->currenttpl . '/' . $filename; $this->assignarray(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()); }else{ eval('?>'.$tpl); } } private function parser($data) { 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["\\1"]; ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*IF\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*-->/Ui','<?php if(isset($row["\\1"]) && $row["\\1"]) { ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*IF\s*NOT\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*-->/Ui','<?php if(!isset($row["\\1"]) || !$row["\\1"]) { ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*IF\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*=\s*\'([^\']+)\'\s*-->/Ui','<?php if(isset($row["\\1"]) && $row["\\1"] == \'\\2\') { ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*IF\sNOT\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*=\s*\'([^\']+)\'\s*-->/Ui','<?php if(isset($row["\\1"]) && $row["\\1"] != \'\\2\') { ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*ELSEIF\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*-->/Ui','<?php } else if(isset($row["\\1"]) && $row["\\1"]) { ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*ELSEIF\s*NOT\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*-->/Ui','<?php } else if(!isset($row["\\1"]) || !$row["\\1"]) { ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*ELSEIF\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*=\s*\'([^\']+)\'\s*-->/Ui','<?php } else if(isset($row["\\1"]) && $row["\\1"] == \'\\2\') { ?>',$tmpdata); $tmpdata = preg_replace('/<!--\s*ELSEIF\sNOT\s*'.preg_quote($value,'/').'\.([a-zA-Z0-9_\-]+)\s*=\s*\'([^\']+)\'\s*-->/Ui','<?php } else if(isset($row["\\1"]) && $row["\\1"] != \'\\2\') { ?>',$tmpdata); $data = preg_replace('/'.preg_quote($blockvars[0][$key],'/').'/','<?php foreach($this->blockvars["'.preg_quote($value, '/').'"] as $row) { ?>' . $tmpdata . '<?php } ?> ',$data); } $data = preg_replace('#<!--\s*PHP\s*-->(.*)<!--\s*ENDPHP\s*-->#Usi','<?php \\1 ?>',$data); $data = preg_replace('/{([a-zA-Z0-9_\-]+)}/iU','<?php echo isset($this->variables["\\1"]) ? $this->variables["\\1"] : "{\\1}"; ?>',$data); $data = preg_replace('/<!--\s*INCLUDE\s+([^"]*)\s*-->/Usi','<?php echo $this->display("\\1"); ?>',$data); $data = preg_replace('/<!--\s*DEFINE\s+([^"]*)\s*=\s*\'([^\']*)\'\s*-->/Usi','<?php $this->variables["\\1"] = \'\\2\' ?>',$data); $data = preg_replace('/<!--\s*IF\s([a-zA-Z0-9_]*)\s+=\s+([^"]+)\s*-->/Usi','<?php if($this->variables[\'\\1\'] == "\\2") { ?>',$data); $data = preg_replace('/<!--\s*IF\s([a-zA-Z0-9_]*)\s*-->/Usi','<?php if(isset($this->variables[\'\\1\']) && $this->variables[\'\\1\']) { ?>',$data); $data = preg_replace('/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s+=\s+([^"]+)\s*-->/Usi','<?php if(isset($this->variables[\'\\1\']) && $this->variables[\'\\1\'] != "\\2") { ?>',$data); $data = preg_replace('/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s*-->/Usi','<?php if(!isset($this->variables[\'\\1\']) || !$this->variables[\'\\1\']) { ?>',$data); $data = preg_replace('/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s*AND\s*NOT\s*([a-zA-Z0-9_]*)\s*-->/Usi','<?php if((!isset($this->variables[\'\\1\']) || !$this->variables[\'\\1\']) && (!isset($this->variables[\'\\2\']) || !$this->variables[\'\\2\'])) { ?>',$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[\'\\1\']) && $this->variables[\'\\1\']) && isset($this->variables[\'\\2\']) && $this->variables[\'\\2\']) { ?>',$data); $data = preg_replace('/<!--\s*IF\s([a-zA-Z0-9_]*)\s+is\s+([^"]+)\s*-->/Usi','<?php if (strcasecmp($this->variables[\'\\1\'],"\\2")==0) { ?>',$data); $data = preg_replace('/<!--\s*IF\sNOT\s([a-zA-Z0-9_]*)\s*OR\s*NOT\s*([a-zA-Z0-9_]*)\s*-->/Usi','<?php if((!isset($this->variables[\'\\1\']) OR !$this->variables[\'\\1\']) OR (!isset($this->variables[\'\\2\']) || !$this->variables[\'\\2\'])) { ?>',$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[\'\\1\']) OR isset($this->variables[\'\\2\']) )) { ?>',$data); $data = preg_replace('/<!--\s*IF\s([a-zA-Z0-9_]*)\s*OR\s*([a-zA-Z0-9_]*)\sOR\s*([a-zA-Z0-9_]*)\s*-->/Usi','<?php if((isset($this->variables[\'\\1\']) OR isset($this->variables[\'\\2\']) OR isset($this->variables[\'\\3\']) )) { ?>',$data); $data = preg_replace('/<!--\s*ELSEIF\s([a-zA-Z0-9_]*)\s*-->/Usi','<?php }elseif(isset($this->variables[\'\\1\']) && $this->variables[\'\\1\']) { ?>',$data); $data = preg_replace('/<!--\s*ELSE\s*-->/Usi','<?php }else{ ?>',$data); $data = preg_replace('/<!--\s*ENDIF\s(.*)\s*-->/Usi','<?php } ?>',$data); if(isset($GLOBALS['tplrules'])) { foreach($GLOBALS['tplrules'] as $pattern => $repl) { $data = preg_replace($pattern, $repl, $data); } } return $data; } public function assign($name, $value) { $this->variables[$name] = $value; } public function assignarray($array) { foreach($array as $key => $value) { $this->variables[$key] = $value; } } public function assign_vars($name, $array) { $this->blockvars[$name][] = $array; } public function __construct () { $this->license_check(); } public function license_check() { global $database, $db, $admin, $querycount, $host; if(empty($db)) { include(__DIR__."/../config.php"); define('DB_PREFIX', $database['prefix']); $querycount = 0; $db = new errorhandler_mysqli($database['location'], $database['username'], $database['password'], $database['database']); if (mysqli_connect_errno()) { error_handler("Couldn't establish connection to the database."); } } if(ini_get('allow_url_fopen') != 1){ error_handler("You need 'allow_url_fopen' to be set to '1' (i.e. it needs to be enabled).\n<br />Without that, this script won't work - sorry."); } $last_check_db = $db->query("SELECT content FROM ".DB_PREFIX."settings WHERE `name` = 'last_check'")->fetch_assoc(); $last_check_db = $last_check_db['content']; $timestamp_last = @simple_crypt($database['password'], $last_check_db, "decrypt"); if(!isValidTimestamp($timestamp_last)){ $timestamp_last = 0; } $now = new DateTime(); $now->setTimestamp(time()); $last_check = new DateTime(); $last_check->setTimestamp($timestamp_last); $interval = $now->diff($last_check); $diff = (int)$interval->format('%a'); if($diff >= 1){ $reachable = urlOK("http://licensing.clipcms.de/check.php?ping=1"); if($host == ""){ $host = preg_replace("/^(.*\.)?([^.]*\..*)$/", "$2", $_SERVER['HTTP_HOST']); } if($reachable){ $result = file_get_contents_curl("http://licensing.clipcms.de/check.php", array("host" => $host)); if($result != "1"){ error_handler("Your license file is invalid.<br />\nPlease contact me.<br /><br /><span style='font-size: 11px;'>Response:<br />".$result."</span>"); }else{ $db->query("UPDATE ".DB_PREFIX."settings SET `content` = '".@simple_crypt($database['password'], time(), "encrypt")."' WHERE `name` = 'last_check'"); } }else{ error_handler("The license server is not reachable.<br />Please check your firewall settings or contact me."); } }else{ return; } } } class tplcacher { private $filename; private $lastmodify; private $clastmodify; private $data; private $valid; public function __construct($name, $lastmodify, $currenttpl) { $name = str_replace("../", "", $name); $name = str_replace("./", "", $name); $name = str_replace('/','_', $name); $this->filename = dirname(__FILE__) . "/../cache/".$currenttpl."_".$name.".php"; $this->lastmodify = $lastmodify; if(file_exists($this->filename)) { $this->clastmodify = filemtime($this->filename); if($this->clastmodify > $this->lastmodify) { $this->valid = true; $this->data = file_get_contents($this->filename); } else { $this->valid = false; } } else { $this->valid = false; } } public function checkvalid() { return $this->valid; } public function getdata() { return $this->data; } public function write($data) { if($dh = @fopen($this->filename, 'w')) { fwrite($dh, $data); fclose($dh); } } public function getfile() { return $this->filename; } }
?> |
|
|
|
|
|
|
www.waraxe.us Forum Index -> PHP script decode requests
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
All times are GMT
Page 1 of 1
|
|
|
Powered by phpBB © 2001-2008 phpBB Group
|
|
|
|
|