<?
/*
PTK - DFLabs
Copyright (C) 2008 - DFLabs srl - All rights reserved
hide@address.com
*/
include("check_session.php");
include("check_session_image.php");
include("lib_commands.php");
include("loggerClass.php");
include("lib_std.php");
if (isset($_SESSION['data_token']) && strcmp($_SESSION['data_token'],$_GET['tk'])==0){
$offset = sanitize($_GET['arg1'],INT);
$start = sanitize($_GET['arg2'],INT);
$end = sanitize($start+499,INT);
$range = "$start-$end";
$token = sanitize(RemoveXSS($_GET['tk']),PARANOID);
$list = get_allocation_list($_SESSION['image_path'], $offset, $range);
$arr = preg_split("/\n/", $list);
if($list!=''){
?>
<table class="keyword">
<tr>
<td style="border:0px">
<?if($start!=0){?>
<img style="cursor:pointer;" src="../img/left.png" onclick="ajax_request('get_allocation_list.php?tk=<?=$token?>&arg1=<?=$offset;?>&arg2=<?=$start-500;?>', 'allocation_list')">
<?}?>
</td>
<td colspan=2 style="border:0px; text-align:right">
<b><?=$range;?></b>
</td>
<td style="border:0px; text-align:right">
<img style="cursor:pointer" src="../img/arrow.png" onclick="ajax_request('get_allocation_list.php?tk=<?=$token?>&arg1=<?=$offset;?>&arg2=<?=$end+1;?>', 'allocation_list')">
</td>
</tr>
<th colspan=2>Sector</th><th colspan=2">Status</th>
<?
foreach($arr as $arr){
if(preg_match("/^(\d+)\|(\D)/", $arr, $out)){
$sector = sanitize($out[1],INT);
if($out[2]=='a'){
$status = 'allocated';
}else{
$status = 'free';
}
echo "<tr style='cursor:pointer' onclick=\"createNewTab('tab_view_right','$sector','','get_data_unit.php?tk=".$token."&arg1=$offset&arg2=$sector&arg3=1',true)\"><td colspan=2>$sector</td><td colspan=2>$status<tr>";
}
}
?>
</table>
<br>
<?
}else{
echo "<br>Can't generate allocation list for raw images.";
}
}else{
new AuditLog('Unauthorized access to get_allocation_list');
header("location: goto_home.php");
}
?>