<?
include 'mysql.php';
include_once("include/zag.php");
include 'include/ini.php';
include 'include/sesi.php';
if (isset($user)) {

switch(@$go) {
default:

echo"<small>
<a href=\"userquest.php?$sd&go=active\">Активные</a><br/>
<a href=\"userquest.php?$sd&go=complete\">Завершенные</a>
</small>";

break;

case 'active':

$file = @file("MySql/base123/userquest/$log.dat");
$total = count($file);

for ($i = 0; $i < $total; $i++){
$data = explode("||",$file[$i]);

if($data[2]=="active"){

$data_0[]=$data[0];
}}

if(empty($data_0)){echo"<small>Нет активных квестов.</small>"; include_once"include/down.php"; exit;}

foreach($data_0 as $k=>$v)
{
$dat_screen[]="<small>$data_0[$k]</small><br/>";
}


$total = count($dat_screen);


if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + 10){ $end = $total; }
else {$end = $start + 10; }
for ($i = $start; $i < $end; $i++){

echo"$dat_screen[$i]";

}
if ($start !== 0) {echo '<small><a href="userquest.php?start='.($start - 10).'&'.$sd.'&go=active">Назад</a> </small>';}
if ($total > $start + 10) {echo '<small> <a href="userquest.php?start='.($start + 10).'&'.$sd.'&go=active">Далее</a></small>';}

break;

case 'complete':

$file = @file("MySql/base123/userquest/$log.dat");
$total = count($file);

for ($i = 0; $i < $total; $i++){
$data = explode("||",$file[$i]);

if($data[2]=="completeok"){

$data_0[]=$data[0];
}}

if(empty($data_0)){echo"<small>Нет завершенных квестов.</small>"; include_once"include/down.php"; exit;}

foreach($data_0 as $k=>$v)
{
$dat_screen[]="<small>$data_0[$k]</small><br/>";
}


$total = count($dat_screen);


if (empty($_GET['start'])) $start = 0;
else $start = $_GET['start'];
if ($total < $start + 10){ $end = $total; }
else {$end = $start + 10; }
for ($i = $start; $i < $end; $i++){

echo"$dat_screen[$i]";

}


if ($start !== 0) {echo '<small><a href="userquest.php?start='.($start - 10).'&'.$sd.'&go=active">Назад</a> </small>';}
if ($total > $start + 10) {echo '<small> <a href="userquest.php?start='.($start + 10).'&'.$sd.'&go=active">Далее</a></small>';}

break;
}
}else{echo"<small>Пароль или логин неверен!</small>";}

include_once"include/down.php";
?>

