Location: PHPKode > projects > Ptk-forensics > ptk/lib/table_timeline.php
<?
/*
PTK  - DFLabs
Copyright (C) 2008 - DFLabs srl - All rights reserved
hide@address.com
*/
include("check_session.php");
include("check_session_image.php");
include("lib_std.php");
include("sanitize.php");

if (isset($_SESSION['tml_token']) && strcmp($_SESSION['tml_token'],$_GET['tk']) == 0){
$timeline = $_SESSION['timeline'];
$limit = sanitize($_GET['limit'],INT);
$total_page= ceil(sizeof($timeline)/$limit);
$p = sanitize($_GET['page'],INT);
$sort = sanitize($_GET['sort'],INT);
$reverse = sanitize($_GET['reverse'],PARANOID);

$verse = $_SESSION['timeline_verse'];
if($verse=='') $verse= SORT_ASC;

if($reverse=='true'){
	if($verse==SORT_DESC) $verse = SORT_ASC;
	else $verse = SORT_DESC;
}

if($verse==SORT_DESC){
	$sort_img = "../img/sort_desc.png";
}else{	
	$sort_img = "../img/sort_asc.png";
}

$_SESSION['timeline_verse'] = $verse;
$_SESSION['timeline_sort'] = $sort;

foreach ($timeline as $key => $row) {
    $sort_date[$key]  = $row['date_time'];
    $sort_file[$key]  = $row['file_name'];
    $sort_action[$key]  = $row['action'];
    $sort_size[$key]  = $row['size'];
    $sort_permissions[$key]  = $row['permission'];
}

switch($sort){
	case '0': array_multisort($sort_date, $verse, $timeline); break;
	case '1': array_multisort($sort_file, $verse, $timeline); break;
	case '2': array_multisort($sort_action, $verse, $timeline); break;
	case '3': array_multisort($sort_size, $verse, $timeline); break;
	case '4': array_multisort($sort_permissions, $verse, $timeline); break;
}

for($i=0; $i<sizeof($_SESSION["len_partitions"]);$i++){
	$partition_id .= $_SESSION["partition".$i."_id"].",";
}
$partition_id = preg_replace("/,$/", "", $partition_id);

$token = sanitize(RemoveXSS($_GET['tk']),PARANOID);
?>
<script src="../ajax/global.js" type="text/javascript"></script>  

<div id="row_number">
	Show <input type="text" id="row_limit" style="width: 50px; height: 20px; margin-top: 5px" value="<?=$limit;?>" onchange="show_timeline_page(<?=$p;?>, '', <?=$sort;?>,null,'<?=$token?>')"> rows
</div>

<?if($total_page>1){?>
<div id="page_numbers">
	<a href="#" class="pagination" onclick="show_timeline_page(0, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')"><<</a>
	<?if($p-1>=0){?>
		<a href="#" class="pagination" onclick="show_timeline_page(<?=$p-1;?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')"><</a>
	<?}?>
	<a href="#" class="pagination" onclick="show_timeline_page(<?=$p;?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')"><?=$p+1;?> of <?=$total_page;?></a>
	<?if($p+1!=$total_page){?>
		<a href="#" class="pagination" onclick="show_timeline_page(<?=$p+1;?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')">></a>
	<?}?>
	<a href="#" class="pagination" onclick="show_timeline_page(<?=$total_page-1?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')">>></a>	
</div>
<?}else{?>
<div id="page_numbers">&nbsp;</div>
<?}?>

<p style="font-size:8pt; margin-bottom:0px; margin-left:55px">
<img src="../img/select_all.png" style="vertical-align: middle">&nbsp;If selected: <u style="cursor:pointer" onclick="goto_multiple_bookmarks(1, '<?=$partition_id?>')">bookmark all</u><!-- |  <u style="cursor:pointer">export all</u>-->
</p>
<table class="timeline" id="timeline_table">
	<th><input type='checkbox' id='bookmark_all' onclick="check_uncheck_all()"></th>
	<th><img onclick="goto_multiple_bookmarks(1, '<?=$partition_id?>')" src='../img/star.png' style='cursor:pointer'/></th>
	<th onclick="show_timeline_page(<?=$p;?>, <?=$limit;?>, 0, true,'<?=$token?>')">Date-time<?if($sort==0){?>&nbsp;&nbsp;<img src="<?=$sort_img;?>"><?}?></th>
	<th onclick="show_timeline_page(<?=$p;?>, <?=$limit;?>, 1, true,'<?=$token?>')">File name<?if($sort==1){?>&nbsp;&nbsp;<img src="<?=$sort_img;?>"><?}?></th>
	<th onclick="show_timeline_page(<?=$p;?>, <?=$limit;?>, 2, true,'<?=$token?>')">Action<?if($sort==2){?>&nbsp;&nbsp;<img src="<?=$sort_img;?>"><?}?></th>
	<th onclick="show_timeline_page(<?=$p;?>, <?=$limit;?>, 3, true,'<?=$token?>')">Size<?if($sort==3){?>&nbsp;&nbsp;<img src="<?=$sort_img;?>"><?}?></th>
	<th onclick="show_timeline_page(<?=$p;?>, <?=$limit;?>, 4, true,'<?=$token?>')">Permissions<?if($sort==4){?>&nbsp;&nbsp;<img src="<?=$sort_img;?>"><?}?></th>
	<th>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th>
	<?for($i=0;$i<sizeof($timeline);$i++){
		$page = floor($i/$limit);
		if($page==$p){
			$old_odd = $odd;
			if($timeline[$i]['date_time']==$timeline[$i-1]['date_time']){
				$date_time = "";
				$odd = $old_odd;
			}else{
				$date_time = $timeline[$i]['date_time'];
				if($old_odd==1) $odd=0; else $odd=1;
			}
			$offset = get_partition_offset_from_id($timeline[$i]['id_partition']);
			if($_SESSION['timeline_id']=='all'){				
				$fs = get_partition_fs_from_id($timeline[$i]['id_partition']);
				$filename = $fs.$timeline[$i]['file_name'];
			}else{
				$filename = $timeline[$i]['file_name'];
			}
			
			$name = htmlspecialchars($filename);

			//$name = preg_replace("/\//", "_", $filename);
			//$name = preg_replace("/^_/", "", $name);
			
			$n = preg_replace("/\//", "", $name);
			$n = preg_replace("/\(deleted\)/", "", $n); 
			$n = urlencode($n);
			$nm = preg_replace("/\(deleted\)/", "", $filename);
			$nm = urlencode($nm);

			$bn = basename($timeline[$i]['file_name']);
			if(preg_match("/\(deleted\)/", $name)||(preg_match("/-dead/", $name)) ){
				$color = "#FF0000";
			}else{
				$color = "000000";
			}			
			$is_bookmark = check_bookmark($_SESSION['user'], $_SESSION['case_id'], $partition_id, $timeline[$i]['id'], 1, '');
			if($odd){
			?>
			<tr style="color:<?=$color;?>" class="odd" onmouseover='showPanel(<?=$i;?>)' onmouseout='hidePanel(<?=$i;?>)'>		
			<?}else{?>
			<tr style="color:<?=$color;?>" onmouseover='showPanel(<?=$i;?>)' onmouseout='hidePanel(<?=$i;?>)'>
			<?}?>	
				<td style='text-align: center'><input type='checkbox' name='bookmark_it' value='<?=$timeline[$i]['id']?>|<?=$bn?>'></td>
				<?if($is_bookmark==0){?>
					<td style='text-align: center'><img id='star<?=$timeline[$i]['id']?>' src='../img/star_empty.png' style='cursor:pointer' onclick="displayMessage('modal_bookmark.php?arg1=1&arg2=<?=$timeline[$i]['id']?>&arg3=<?=$partition_id?>&arg4=<?=$bn?>', '340', '250');return false"></td>
				<?}else{?>
					<td style='text-align: center'><img id='star<?=$timeline[$i]['id']?>' src='../img/star.png' style='cursor:pointer' onclick="delete_bookmark('1', '<?=$timeline[$i]['id']?>', '<?=$partition_id?>', '<?=$bn?>');"></td>
				<?}?>				
				<td><?=$date_time;?></td>
				<td><?=htmlspecialchars($filename)?></td>
				<td><?=$timeline[$i]['action'];?></td>
				<td><?=$timeline[$i]['size'];?></td>
				<td><?=$timeline[$i]['permission'];?></td>
				<td style='text-align: center; width: 60px'>
					<div id='panel<?=$i;?>' style='display:none'>
					<img style='cursor:pointer' src='../img/file_info.png' title='Show file details' onclick="displayMessage('modal_timeline_info.php?arg1=<?=$timeline[$i]['id'];?>&arg2=<?=$timeline[$i]['id_file'];?>', '600', '250');return false">
					<img style='cursor:pointer' src='../img/view_file.png' title='Show file content' onclick="displayMessage('modal_file_content.php?arg1=<?=$offset;?>&arg2=<?=$timeline[$i]['inode'];?>&arg3=<?=urlencode($name);?>', '800', '500');return false">
					<img style='cursor:pointer' src='../img/export.png' title='Export' onclick="window.location = 'export_file.php?arg1=<?=$offset;?>&arg2=<?=$timeline[$i]['inode'];?>&arg3=<?=$nm;?>'">&nbsp;					
					</div>
				</td>
			</tr>
		<?}?>
	<?}?>
</table>

<?if($total_page>1){?>
<div id="page_numbers">
	<a href="#" class="pagination" onclick="show_timeline_page(0, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')"><<</a>
	<?if($p-1>=0){?>
		<a href="#" class="pagination" onclick="show_timeline_page(<?=$p-1;?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')"><</a>
	<?}?>
	<a href="#" class="pagination" onclick="show_timeline_page(<?=$p;?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')"><?=$p+1;?> of <?=$total_page;?></a>
	<?if($p+1!=$total_page){?>
		<a href="#" class="pagination" onclick="show_timeline_page(<?=$p+1;?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')">></a>
	<?}?>
	<a href="#" class="pagination" onclick="show_timeline_page(<?=$total_page-1?>, <?=$limit;?>, <?=$sort;?>,null,'<?=$token?>')">>></a>	
</div>
<?}else{?>
	<br>
<?}?>
<?}?>
Return current item: Ptk-forensics