| Server IP : 208.122.213.31 / Your IP : 216.73.216.45 Web Server : Apache System : Linux msd6191.mjhst.com 4.18.0-553.137.1.el8_10.x86_64 #1 SMP Wed Jun 24 11:40:24 UTC 2026 x86_64 User : WHMCS_MIA_382 ( 1001) PHP Version : 7.4.33 Disable Function : NONE MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/httpd/html/baberankings.com.bak/members/kernel/ |
Upload File : |
<?
# Replace variables
function template_replace_vars($s) {
return '"'.preg_replace('/<%(.*)%>/sU', '".'.'do_format(\'\\1\')'.'."', $s).'"';
}
function echo_replace_vars($s) {
$s = preg_replace('/<%_(.*)%>/sU', '<? echo _\\1; ?>', $s);
$s = str_replace('<%dir%>', '<? echo constant(\'dir\'); ?>', $s);
return preg_replace('/<%(.*)%>/sU', '<? echo '.'do_format(\'\\1\')'.'; ?>', $s);
}
# Format replaced vars
function do_format($value,$s = '') {
global $en;
$value = (isset($en[$value]) ? $en[$value] : @constant($value));
/*$i = strtolower($s);
if (strpos($i,'echo') || strpos($i,'define')) {
$value = str_replace('"','`',$value);
$value = str_replace(chr(39),'`',$value);
}*/
return $value;
}
function format_loop($from,$to,$s) {
if (preg_match('/<%(.*)%>/',$from)) {
$from = 'do_format(\''.substr($from,2,-2).'\')';
} else {
$from = '\''.$from.'\'';
}
if (preg_match('/<%(.*)%>/',$to)) {
$to = 'do_format(\''.substr($to,2,-2).'\')';
} else {
$to = '\''.$to.'\'';
}
$s = stripslashes($s);
$loop_id = uniqid('sql_');
return '<? $to[\''.$loop_id.'\'] = '.$to.'; $from[\''.$loop_id.'\'] = '.$from.'; $query = '.template_replace_vars($s).'; $'.$loop_id.' = sql_query($query); if (sql_num_rows($'.$loop_id.') > 0) { if (!is_numeric($to[\''.$loop_id.'\'])) $to[\''.$loop_id.'\'] = sql_num_rows($'.$loop_id.'); $from[\''.$loop_id.'\'] = min($from[\''.$loop_id.'\'],sql_num_rows($'.$loop_id.')); sql_data_seek($'.$loop_id.',$from[\''.$loop_id.'\']-1); $en[\'loops_left\'] = $en[\'total_count\'] = $en[\'total_cnt\'][\''.$loop_id.'\'] = sql_num_rows($'.$loop_id.'); } $en[\'loops_cnt\'][\''.$loop_id.'\'] = 0; $en[\'loops_count\'] = min(sql_num_rows($'.$loop_id.')-($from[\''.$loop_id.'\']-1),$to[\''.$loop_id.'\']); $tos[\''.$loop_id.'\'] = $to; while (($line = sql_fetch_assoc($'.$loop_id.')) && $en[\'loops_cnt\'][\''.$loop_id.'\'] < $tos[\''.$loop_id.'\']) {$en = array_merge($en,$line);
if (!is_array($en[\'loops_cnt\'])) { $en[\'loops_cnt\'] = array(); }
$en[\'loops_index\'] = ++$en[\'loops_cnt\'][\''.$loop_id.'\'];
$en[\'loops_left\'] = $en[\'total_cnt\'][\''.$loop_id.'\']-$en[\'loops_cnt\'][\''.$loop_id.'\']; ?>';
}
function array_loop($s) {
list($offs,$arr) = explode(' ',$s);
if ($arr == '') {
$from = 1;
$to = 'max';
$arr = $s;
}
else {
list($from,$to) = explode(',',substr($offs,1,-1));
}
$arr = $s = stripslashes($arr);
$loop_id = uniqid('arr_');
return '<? $to[\''.$loop_id.'\'] = \''.$to.'\'; $from[\''.$loop_id.'\'] = \''.$from.'\'; global '.(strpos($arr,'[') > 0 ? substr($arr,0,strpos($arr,'[')) : $arr).'; $en[\'loops_left\'] = $en[\'total_count\'] = $en[\'total_cnt\'][\''.$loop_id.'\'] = count('.$s.'); if (!is_numeric($to[\''.$loop_id.'\'])) $to[\''.$loop_id.'\'] = count('.$s.'); $from[\''.$loop_id.'\'] = min($from[\''.$loop_id.'\'],count('.$s.')); for ($k = 1; $k < $from[\''.$loop_id.'\']; $k++) array_shift($k); $en[\'loops_count\'] = count('.$s.'); foreach ('.$s.' as $key => $line) {if (++$en[\'loops\'][\''.$loop_id.'\'] > $to[\''.$loop_id.'\']) break; $en[\'loop_key\'] = $key; $en[\'loops_left\'] = $en[\'total_cnt\'][\''.$loop_id.'\'] - $en[\'loops\'][\''.$loop_id.'\']; $en[\'loops_index\'] = $en[\'loops\'][\''.$loop_id.'\']; $en = array_merge($en,$line); ?>';
}
function format_array($s) {
list($arr,$query) = explode(' ',$s,2);
return '<? global '.(strpos($arr,'[') > 0 ? substr($arr,0,strpos($arr,'[')) : $arr).'; '.$arr.' = array_merge('.$arr.',(array)sql_fetch_assoc(sql_query('.template_replace_vars(stripslashes($query)).'))); ?>';
}
function format_if($s) {
$s = '<? if ('.stripslashes(preg_replace('/<%(.*)%>/sU', 'do_format(\'\\1\')', $s)).') { ?>';
$s = preg_replace('/\'do_format\((.*)\)\'/','do_format(\\1)',$s);
return $s;
}
function make_php($file) {
global $names;
$globtables = implode(',$',array_flip($names));
//get template content
$f = fopen($file,'r');
if (!$f) return false;
$s = fread($f,filesize($file));
fclose($f);
$s = '<? global $en,$'.$globtables.'; ?>'.$s;
//variables inside PHP
/*
$dbls = chr(92);
$s = preg_replace('/<\?(.*)<%(.*)%>(.*)\?>/sm','<?'.$dbls.'1".do_format(\''.$dbls.'2\')."'.$dbls.'3?>',$s);
*/
//if structures
$s = str_replace('<!--[If End]-->','<? } ?>',$s);
$s = str_replace('<!--[If Else]-->','<? } else { ?>',$s);
$s = preg_replace('/<!--\[If Start (.*)\]-->/e',"format_if('\\1')",$s);
//loop structures
$s = str_replace('<!--[Loop End]-->','<? } ?>',$s);
$s = str_replace('<!--[Loop Start QUERY:','<!--[Loop Start [1,max] QUERY:',$s);
$s = preg_replace('/<!--\[Loop Start \[(.*)\,(.*)\] QUERY\:(.*)\]-->/e','format_loop(\'\\1\',\'\\2\',addslashes(\'\\3\'))',$s);
$s = preg_replace('/<!--\[Loop Start (.*)\]-->/e','array_loop(addslashes(\'\\1\'))',$s);
//arrays
$s = preg_replace('/<!--\[Array (.*)\]-->/e','format_array(addslashes(\'\\1\'))',$s);
//includes
$s = preg_replace('/<!--\[Include File (.*)\]-->/',"<? include '\\1'; ?>",$s);
//template includes
$s = preg_replace('/<!--\[Include Template (.*)\]-->/',"<? load_template('\\1'); ?>",$s);
//variables
$s = echo_replace_vars($s);
//break/continue
$s = str_replace('<!--[Break]-->','<? break; ?>',$s);
$s = str_replace('<!--[Continue]-->','<? continue; ?>',$s);
//replace table names
// foreach ($names as $key => $value)
// $s = str_replace('$'.$key,$value,$s);
//merge PHP blocks
$s = str_replace("\r",'',$s);
$s = str_replace("?>\n<?",'',$s);
$s = str_replace("\n\n",'',$s);
$s = str_replace("?><?",'',$s);
// dirty fixes
$s = str_replace('if () { }','', $s);
return $s;
}
function load_template($file) {
$tplfile = 'templates/compiled/'.md5($file).'.php';
if (!file_exists($tplfile) || filemtime($tplfile) != filemtime($file)) {
$s = make_php($file);
$f = fopen('templates/compiled/'.md5($file).'.php','w');
fwrite($f,$s);
fclose($f);
touch($tplfile,filemtime($file));
}
// echo '<br><font color=red>'.md5($file).'</font><br><b>'.$file.'</b><br>';
include $tplfile;
}
//parses email templates
function emailtemplatetxt($subj,$text) {
global $en;
$cns = get_defined_constants();
$out[body] = preg_replace('/%%(.*)%%/sUe', "\$en['\\1']", $text);
$out[body] = preg_replace('/##(.*)##/sUe', "\$cns['\\1']", $out[body]);
$out[subj] = preg_replace('/%%(.*)%%/sUe', "\$en['\\1']", $subj);
$out[subj] = preg_replace('/##(.*)##/sUe', "\$cns['\\1']", $out[subj]);
return $out;
}
//parses email templates
function emailtemplate($template_file) {
global $en;
$f = fopen($template_file,'r');
if (!$f) die('Couldn`t open '.$template_file.'!');
$lines = 0;
while (!feof($f)) {
$lines++;
$s = chop(fgets($f,4096));
if ($lines == 1){ $out[subj] = $s;} else
{$out[body] .= $s."\n";}
}
fclose($f);
return emailtemplatetxt($out['subj'],$out['body']);
}
?>