<?

include 'inclydings/gzips.php';
include 'mysql.php';
include_once("inclydings/zag.php");
include_once("inclydings/check2.php");
include 'inclydings/ini.php';
include_once("inclydings/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("L2dbnam/esql2db/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"Нет активных квестов."; include_once"inclydings/down.php"; exit;}

foreach($data_0 as $k=>$v)
{
$dat_screen[]="$data_0[$k]<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 '<a href="userquest.php?start='.($start - 10).'&'.$sd.'&go=active">Назад</a> ';}
if ($total > $start + 10) {echo ' <a href="userquest.php?start='.($start + 10).'&'.$sd.'&go=active">Далее</a>';}

break;

case 'complete':

$file = @file("L2dbnam/esql2db/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"inclydings/down.php"; exit;}

foreach($data_0 as $k=>$v)
{
$dat_screen[]="$data_0[$k]<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 '<a href="userquest.php?start='.($start - 10).'&'.$sd.'&go=active">Назад</a> ';}
if ($total > $start + 10) {echo ' <a href="userquest.php?start='.($start + 10).'&'.$sd.'&go=active">Далее</a>';}

break;
}
}else{echo"Пароль или ник неверен. Возможно сессия устарела. Попробуйте авторизироваться заново.";}

include_once"inclydings/down.php";
?>

