403Webshell
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 :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /home/httpd/html/baberankings.com.bak/members/kernel/parser_php5.php
<?
/* K-Rate
(C) Rinalds Uzkalns, 2003-2004. All Rights Reserved
http://turn-k.net

Version: 1.00 (22.09.04)
*/
?>
<?

//class_template('templates/aim/header.tpl');

function load_template($templ) {
//        $st = getmicrotime();
        $tpl = new show_template;
        $tpl->template = $templ;
        $tpl->print_out();
//        $fin = getmicrotime() - $st;
//        echo "<!-- $templ || $fin -->";
        }

class show_template {
        var $templ = array();     //template data
        var $tpi = 0;             //template current line index
        var $template = '';       //template path
        var $s = '';              //current line
        var $loop = array();      //loop structures
        var $if = array();        //if structures
        var $act = array();       //actions for each line
        var $cancel_loop = false; //cancel loop

    # Has the template already been analyzed?
        function start() {
                if (isset($GLOBALS['tplcache'][$this->template])) {
                    //have it compiled before
                        $this->act = $GLOBALS['tplcache'][$this->template]->act;
                        $this->loop = $GLOBALS['tplcache'][$this->template]->loop;
                        $this->ifs = $GLOBALS['tplcache'][$this->template]->ifs;
                        $this->templ = $GLOBALS['tplcache'][$this->template]->templ;
                        } else {
                    //analyze
                        $this->get();
                        }
                }

    # Get template content and analyze
        function get() {
            $startp = getmicrotime();
            
            //get template content
                $f = fopen($this->template,'r');
                if (!$f) return false;
                while (!feof($f)) {
                    $s = chop(fgets($f,4096));
                        if ($s == '') continue;
                        if (substr($s,0,5) == '<!--[') {
                                if ($nx != '') $this->templ[] = $nx;
                                $this->templ[] = $s;
                                $nx = '';
                                }
                        elseif (substr($s,0,2) == '<?') {
                                if ($nx != '') $this->templ[] = $nx;
                                $nx = $s;
                                }
                        else
                                $nx .= ($nx != '' ? "\n" : '').$s;

                        if (substr($nx,-2) == '?>') {
                                $this->templ[] = $nx;
                                $nx = '';
                                }
                        }

                if ($nx != '') $this->templ[] = $nx;
                fclose($f);

            //analyze content
                foreach ($this->templ as $key => $value) {

                    //ordinary output
                        if (substr($value,0,5) != '<!--[' && substr($value,0,2) != '<?') {
                                $this->act[$key] = 'do_print';
                                }

                    //if conditions
                        elseif (substr($value,0,7) == '<!--[If') {
                                if (substr($value,0,13) == '<!--[If Start') {
                                        $this->ifs[$key]['start'] = $key;
                                        $startedif[] = $key;
                                        $this->act[$key] = 'if_start';
                                        }

                                if (substr($value,0,11) == '<!--[If End') {
                                        $last = $startedif[count($startedif)-1];
                                        $this->ifs[$last]['end'] = $key;
                                        array_pop($startedif);
                                        }

                                if (substr($value,0,12) == '<!--[If Else') {
                                        $last = $startedif[count($startedif)-1];
                                        $this->ifs[$last]['else'] = $key;
                                        }
                                }
                    //loops
                        elseif (substr($value,0,9) == '<!--[Loop') {
                                if (substr($value,0,15) == '<!--[Loop Start') {
                                        $this->loop[$key]['start'] = $key;
                                        $startedloop[] = $key;
                                        $this->act[$key] = 'loop_start';
                                        }

                                if (substr($value,0,13) == '<!--[Loop End') {
                                        $last = $startedloop[count($startedloop)-1];
                                        $this->loop[$last]['end'] = $key;
                                        array_pop($startedloop);
                                        }
                                }

                    //eval
                        elseif (substr($value,0,2) == '<?') {
                                $this->act[$key] = 'do_eval';
                                }
                    //array
                        elseif (substr($value,0,10) == '<!--[Array') {
                                $this->act[$key] = 'do_array';
                                }

                    //include file
                        elseif (substr($value,0,17) == '<!--[Include File') {
                                $this->act[$key] = 'include_file';
                                }

                    //include template
                        elseif (substr($value,0,21) == '<!--[Include Template') {
                                $this->act[$key] = 'include_template';
                                }

                    //loop - continue
                        elseif ($value == '<!--[Continue]-->') {
                                $this->act[$key] = 'continue_loop';
                                }

                    //loop - break
                        elseif ($value == '<!--[Break]-->') {
                                $this->act[$key] = 'break_loop';
                                }

                    //error or html comment apparently - just print it out
                        else
                                $this->act[$key] = 'do_print';

                        }

                $GLOBALS['tplcache'][$this->template] = $this;
//                $GLOBALS['compile'] += getmicrotime() - $startp;
                }


    # The main function
        function print_out() {
            //get template
                $this->start();

            //output content
                $this->exec_block(0, count($this->templ)-1, 0);
                }

    # Read next line
        function templ_read() {
                $this->tpi++;
                return $this->templ[$this->tpi];
                }

    # Replace variables
        function template_replace_vars($s) {
                return preg_replace('/<%(.*)%>/sUe', '$this->do_format("\\1",$s)', $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;
                }

    # Execute template block
        function exec_block($start, $end, $jump = -2) {
                $this->tpi = $start - 1;
                while ($this->tpi < $end) {
                        $s = $this->templ_read();
                        $this->s = $this->template_replace_vars($s);
                        if ($this->act[$this->tpi] == 'continue_loop') return false;
                        if ($this->act[$this->tpi] == 'break_loop') {
                                $this->cancel_loop = true;
                                return false;
                                }
                        eval('$this->'.$this->act[$this->tpi].'();');
                        }
                if ($jump != -2)
                        $this->tpi = $jump;
                }

    # Echo a line
        function do_print() {
                echo $this->s;
                }

    # If structure
        function if_start() {
                global $names, $en;
                extract($names);
                $cond = substr($this->s,14);
                $cond = substr($cond,0,strpos($cond,']-->'));
                $evstr = '$out = ('.$cond.');';
                @eval($evstr);

                if ($out) {
                    //returns true, let's do something
                        $end = isset($this->ifs[$this->tpi]['else']) ? $this->ifs[$this->tpi]['else'] : $this->ifs[$this->tpi]['end'];
                        $this->exec_block($this->tpi+1, $end-1, $this->ifs[$this->tpi]['end']);
                        }
                else    {
                    //returns false, go to else or end
                        if (isset($this->ifs[$this->tpi]['else'])) {
                            //else block present
                                $this->exec_block($this->ifs[$this->tpi]['else']+1, $this->ifs[$this->tpi]['end']-1, $this->ifs[$this->tpi]['end']);
                                }
                        else {
                            //go to end of if structure
                                $this->tpi = $this->ifs[$this->tpi]['end'];
                                }
                        }
                }

    # Loops
        function loop_start() {
                global $names, $en;
                extract($names);
                $cond = substr($this->s,16);
                $cond = substr($cond,0,strpos($cond,']-->'));

            //from-to?
                if (substr($cond,0,1) == '[') {
                        $bounds = substr($cond,1,strpos($cond,'] ')-1);
                        if (strpos($bounds,':'))
                                list($type,$bounds) = explode(':',$bounds);
                        $cond = substr($cond,strpos($cond,'] ')+2);
                        list($from,$to) = explode(',',$bounds);

                        $from = (int)$from;
                        if ($to == '') $to = 'max';
                        }

            //mysql query as array?
                if (substr($cond,0,6) == 'QUERY:') {
                    //process query
                        $cond = substr($cond,6);
                        eval('$query = "'.$cond.'";');
                        $result = sql_query($query);

                    //create loop array
                        $looparray = array();
                        while ($line = sql_fetch_assoc($result))
                                $looparray[] = $line;

                        $en['lastq'] = $result;
                        }

            //PHP array as loop array?
                elseif (substr($cond,0,1) == '$') {
                        $glob = strpos($cond,'[') ? substr($cond,0,strpos($cond,'[')) : $cond;
                        eval('global '.$glob.';');
                        eval('$looparray = '.$cond.';');
                        }

            //For loop
                elseif ($type == 'for') {
                        $looparray = array();
                        for ($k = $from; $k <= $to; $k++)
                                $looparray[]['index'] = $k;
                                }

            //check bounds
                if ($to == 'max') $to = count($looparray);
                if (!$from) {
                        $from = 1;
                        $to = count($looparray);
                        }
                if ($from == 0) $from = 1;

            //slice offsets off the array
                $en['total_count'] = count($looparray);
                for ($k = 2; $k <= $from; $k++) array_shift($looparray);
                for ($k = count($looparray); $k > $to; $k--) array_pop($looparray);
                
            //and now just do the stuff...
                $st = $this->tpi;
                $end = $this->loop[$this->tpi]['end'];
                $en['loops_count'] = count($looparray);

                while (count($looparray) > 0) {
                        $this->cancel_loop = false;
                        $en['loop_key'] = key($looparray);
                        $loopentry = array_shift($looparray);

                        $en['loops_index'] = $from++;
                        $en['loops_left'] = count($looparray);
                        $en = array_merge($en, $loopentry);

                        $this->exec_block($this->loop[$st]['start']+1,$this->loop[$st]['end']-1,$this->loop[$st]['end']);
                        if ($this->cancel_loop == true) {echo 'break'; break; }
                        }
                $this->tpi = $end;
                }
                
    # Eval
        function do_eval() {
                global $names, $en;
                global $en;
                //print_r($en);
                extract($names);
                $ev = substr($this->s,2,-2);
				eval($ev);
                }

    # Array
        function do_array() {
                global $names, $en;
                extract($names);

                $incl = substr($this->s,11);
                $arr = substr($incl,0,strpos($incl,' '));
                $incl = substr($incl,strlen($arr)+1);
                $incl = substr($incl,0,strpos($incl,']-->'));

                eval('$query = "'.$incl.'";');
                $res = sql_query($query) or die(mysql_error());
				$line = sql_fetch_assoc($res);
				if (is_Array($line))
					eval('global $en; $en = array_merge($en,$line);');
                }

    # Include file
        function include_file() {
                global $names, $en;
                extract($names);
                $incl = substr($this->s,18);
                $incl = substr($incl,0,strpos($incl,']'));
                include $incl;
                }

    # Include template
        function include_template() {
                global $names, $en;
                $incl = substr($this->s,22);
                $incl = substr($incl,0,strpos($incl,']'));
                load_template($incl);
                }


        }

//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']);
        }

?>

Youez - 2016 - github.com/yon3zu
LinuXploit