Location: PHPKode > projects > Libretto: Web download manager > libretto/content/download.php
<?
/*
 * Libretto - Web download manager.
 * Copyright (C) 2007 Jordi Pujol (jordi_pujolATtelefonicaDOTnet).
 * 
 * This program is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License as published by the Free Software
 * Foundation; either version 2 of the License, or (at your option) any later
 * version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
 * Place, Suite 330, Boston, MA 02111-1307 USA
 */

include "includes/globals.php";
include_once "includes/downloady.php";

global $openfile_details;

function sort_header( $item ) {
?>
	<th align="center" title="<? echo t($item); ?>">
		<table border="0" cellspacing="0" cellpadding="1" title="<? echo t($item); ?>">
		<th>
			<? echo t($item); ?>
		</th>
		<th title="<? echo t('clicktosort'); ?>">
			<input type="image" name="sort_<? echo $item; ?>" src="<?
			if ( $_SESSION['sort'] == $item ) {
				if ( $_SESSION['sortorder'] == CSORT_ASC )
				echo "images/go-up.png";
				else
				echo "images/go-down.png";
			} else
				echo "images/go-up-down.png";
			?>" alt="<? echo t($item); ?>">
		</th>
		</table>
	</th>
<?
}

$openfile_details = '';

if ( isset($_SESSION['openfile']) ) {
	$sid = $_SESSION['openfile'];
	$d= new downloady();
	$details = $d->GetDetails($sid);
	$openfile_details = '<p>'."\n".
		'<form method="POST" enctype="multipart/form-data">'."\n".
		'<div style="width: 100%; overflow-x: auto; overflow-y: hidden;">'."\n".
		'<table width="100%" border="1" cellpadding="0" cellspacing="0">'."\n".
		'<tr>'."\n".
		'<th align="center" title="'.t('save').'">'.t('save').'</th>'."\n";
	if ( $details['status'] == 0 )
		$openfile_details .= '<th align="center" title="'.t('delete').'">'.t('delete').'</th>'."\n";
	$openfile_details .= '<th align="center" title="'.t('filename').'">'.t('filename').'</th>'."\n";
	$openfile_details .= '<th align="center" title="'.t('size').'">'.t('size').'</th>'."\n";
	$openfile_details .= '</tr>'."\n";
	$dw = ( (isset($details['user']) && isset($users[$details['user']]['destdir'])) ?
		$users[$details['user']]['destdir'] :
		$destdir );
	$openfile_details .= get_files_dir($dw, $details['destdir'], $details['destdir'], 0, $details['status']);
	$openfile_details .= '</table></br>'."\n".
		'</div>'."\n".
		'<input type="hidden" name="_submit_download1" value="1"/>'."\n".
		'</form>'."\n".
		'</p>'."\n";
}
?>
<h1><? echo t('downloadstatus'); ?></h1>
<?  displayUserName();
displayDriveSpaceBar(); ?>
<br>
<form method="POST" enctype="multipart/form-data">
	<div style="width: 100%; overflow-x: auto; overflow-y: hidden;">
		<table id="files" border="1em">
		<tr>
			<th align="center" title="<? echo t('info'); ?>"><? echo t('info'); ?></th>
			<th align="center" title="<? echo t('play'); ?>"><? echo t('play'); ?></th>
			<th align="center" title="<? echo t('pauseresume'); ?>"><? echo t('pauseresume'); ?></th>
			<th align="center" title="<? echo t('markdone'); ?>"><? echo t('markdone'); ?></th>
			<th align="center" title="<? echo t('viewlog'); ?>"><? echo t('viewlog'); ?></th>
			<? if ( $authrequire && isset($users[$user]['administrator']) && $users[$user]['administrator'] )
			sort_header('user');
			?>
			<? sort_header("status"); ?>
			<? sort_header("done"); ?>
			<? sort_header("url"); ?>
			<? sort_header("destdir"); ?>
			<? sort_header("mask"); ?>
			<? sort_header("savefile"); ?>
			<? sort_header("size"); ?>
			<? sort_header("percent"); ?>
			<th align="center" title="<? echo t('progress'); ?>"
			>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?
			echo t('progress');
			?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
			</th>
			<? sort_header("fetched"); ?>
			<? sort_header("speed"); ?>
			<? sort_header("downloader"); ?>
			<? sort_header("downloadtype"); ?>
			<th align="center" title="<? echo t('pid'); ?>"><? echo t('pid'); ?></th>
			<th align="center" title="<? echo t('httpuser'); ?>"><? echo t('httpuser'); ?></th>
			<th align="center" title="<? echo t('httppasswd'); ?>"><? echo t('httppasswd'); ?></th>
			<th align="center" title="<? echo t('up'); ?>"><? echo t('up'); ?></th>
			<th align="center" title="<? echo t('down'); ?>"><? echo t('down'); ?></th>
			<th align="center" title="<? echo t('peers'); ?>"><? echo t('peers'); ?></th>
			<th align="center" title="<? echo t('sharing'); ?>"><? echo t('sharing'); ?></th>
			<th align="center" title="<? echo t('estimatedtime'); ?>"><? echo t('estimatedtime'); ?></th>
		</tr>
		<?  $d= new downloady();
			$list = $d->GetJobListDetailed($_SESSION['sort'], $_SESSION['sortorder']);
			foreach ( $list AS $details ) {
		?>
		<tr>
			<td align="center" title="<? echo t('info'); ?>">
			<input type="image" name="info_<? echo $details['sid']; ?>" src="images/document-properties.png"
			alt="<? echo t('info'); ?>">
			</td>
			<? if ( isset($sid) && $sid == $details['sid'] ) { ?>
			<td align="center" title="<? echo t('close'); ?>">
			<input type="image" name="close_<? echo $details['sid']; ?>" src="images/document-open.png"
				title="<? echo t('close'); ?>" alt="<? echo t('close'); ?>">
			</td>
			<? } else { ?>
			<td align="center" title="<? echo t('play'); ?>">
			<input type="image" name="play_<? echo $details['sid']; ?>" src="images/folder.png"
				title="<? echo t('play'); ?>" alt="<? echo t('play'); ?>">
			</td>
			<? } ?>
			<td align="center">
			<? if ( $details['status'] > 0 ) { ?>
			<input type="image" name="pause_<? echo $details['sid']; ?>" src="images/process-stop.png"
				title="<? echo t('pause'); ?>" alt="<? echo t('pause'); ?>">
			<? } else { ?>
			<input type="image" name="resume_<? echo $details['sid']; ?>" src="images/view-refresh.png"
			title="<? echo t('resume'); ?>" alt="<? echo t('resume'); ?>">
			<? } ?>
			</td>
			<td align="center" title="<? echo t('markdone'); ?>">
			<input type="image" name="done_<? echo $details['sid']; ?>" src="images/process-delete.png"
			alt="<? echo t('markdone'); ?>">
			</td>
			<td align="center" title="<? echo t('viewlog'); ?>">
			<A HREF="index.php?inline=true&getid=<? echo base64_encode(str_replace($tmpdir, "", $tmpdir.$details['sid'].'.stat')); ?>" TARGET="_blank">
			<IMG SRC="images/edit-paste.png" BORDER="0" alt="<? echo t('viewlog'); ?>"></A>
			</td>
			<? if ($authrequire && isset($users[$user]['administrator']) && $users[$user]['administrator'] ) { ?>
			<td align="center" title="<? echo t('user'); ?>"><? echo $details['user']; ?></td>
			<? } ?>
			<td align="center" title="<? echo t('status'); ?>">
			<? echo ($details['status'] > 0 ? t('active') : t('inactive') ); ?></td>
			<td align="center" title="<? echo t('done'); ?>"><? echo t($details['done']); ?></td>
			<td align="left" title="<? echo t('url'); ?>">
			<? echo htmlspecialchars($details['url']); ?></td>
			<td align="left" title="<? echo t('destdir'); ?>">
			<? echo htmlspecialchars(str_replace($storagedir, "", $details['destdir'])); ?></td>
			<td align="left" title="<? echo t('mask'); ?>">
			<? echo htmlspecialchars($details['mask']); ?></td>
			<td align="left" title="<? echo t('savefile'); ?>">
			<? echo htmlspecialchars($details['savefile']); ?></td>
			<td align="right" title="<? echo t('size'); ?>"><? if ($details['size'] >= 0)
			echo number_format($details['size'], 0,
				$decimal_point, $thousands_sep);
			else
			echo t('unknown');
			?></td>
			<td align="right" title="<? echo t('percent'); ?>"><? if ($details['percent'] >= 0)
			echo number_format($details['percent'], 2,
				$decimal_point, $thousands_sep);
			else
			echo t('unknown');
			?></td>
			<td align="center" title="<? echo t('progress'); ?>"><? if ($details['percent'] >= 0)
			echo displayPercentBar($details['percent']); ?>
			</td>
			<td align="right" title="<? echo t('fetched'); ?>">
			<? echo number_format($details['fetched'], 0,
				$decimal_point, $thousands_sep); ?>
			</td>
			<td align="right" title="<? echo t('speed'); ?>">
			<? echo number_format($details['speed'], 2,
			$decimal_point, $thousands_sep); ?>
			</td>
			<td align="center" title="<? echo t('downloader'); ?>"><? echo t($details['downloader']); ?></td>
			<td align="center" title="<? echo t('downloadtype'); ?>"><? echo t($details['downloadtype']); ?></td>
			<td align="right" title="<? echo t('pid'); ?>">
			<? echo number_format($details['pid'], 0,
			$decimal_point, $thousands_sep); ?>
			</td>
			<td align="left" title="<? echo t('httpuser'); ?>"><? echo $details['httpuser']; ?></td>
			<td align="left" title="<? echo t('httppasswd'); ?>"><? echo $details['httppasswd']; ?></td>
			<td align="right" title="<? echo t('up'); ?>">
			<? echo number_format($details['up'], 2,
			$decimal_point, $thousands_sep); ?>
			</td>
			<td align="right" title="<? echo t('down'); ?>">
			<? echo number_format($details['down'], 2,
			$decimal_point, $thousands_sep); ?>
			</td>
			<td align="right" title="<? echo t('peers'); ?>">
			<? echo number_format($details['peers'], 0,
			$decimal_point, $thousands_sep); ?>
			</td>
			<td align="right" title="<? echo t('sharing'); ?>">
			<? echo number_format($details['sharing'], 0,
			$decimal_point, $thousands_sep); ?>
			</td>
			<td align="right" title="<? echo t('estimatedtime'); ?>">
			<? echo htmlspecialchars($details['estimatedtime']); ?>
			</td>
		</tr>
		<? } ?>
	</table>
	</br>
	</div>
	<? if ( ! isset($refreshinterval) || $refreshinterval == 0 ) { ?>
	<div align="center">
		<p><input type="submit" name="refresh" value="<? echo t('refresh'); ?>"/>
		</p>
	</div>
	<? }
	?>
	<input type="hidden" name="_submit_download" value="1"/>
</form>
<? if ($info_details) { ?>
	<p>
		<div style="width: 100%; overflow-x: auto; overflow-y: auto;">
			<table width="100%" border="1" cellpadding="0" cellspacing="0">
			<? echo $info_details; ?>
			</table>
			</br>
		</div>
	</p>
<? } ?>
<? if ($openfile_details) {
	echo $openfile_details;
}
?>
Return current item: Libretto: Web download manager