All pastes #1572114 Raw Edit

snatchlist.php

public php v1 · immutable
#1572114 ·published 2009-09-19 19:21 UTC
rendered paste body
<?enforce_login();$UserID = $_GET['id'];$MaxPerPage = 20;//If userid isent a number throw an errorif (!is_number($UserID)) { error('','ID: '.$_GET[id].' was non-numberic','','',true); }// Get page # for pagination linksif(!isset($_GET['page']) || !is_number($_GET['page'])) $_GET['page'] = 1;$StartRecord = ($_GET['page']-1)*$MaxPerPage;// Check permissions and run query or throw errorif($LoggedUser['ID'] != $UserID && !check_perms('users_mod')) { error(403); }	$DB->Query('SELECT SQL_CALC_FOUND_ROWS SQL_SMALL_RESULT		m.ID,		m.Username,		s.fid,		s.uploaded,		s.downloaded,		s.last_action,		s.seeding,		s.seedtime,		s.hnr,		tg.name,		tg.id,		tg.year		FROM users_main AS m		JOIN transfer_history AS s ON s.uid = m.ID		LEFT JOIN torrents AS t on t.ID=s.fid		LEFT JOIN torrents_group AS tg on tg.ID=t.GroupID		WHERE m.ID ='.$UserID.' 		LIMIT '.$StartRecord.', '.$MaxPerPage);		// If user doesn't exist throw error	if ($DB->record_count() == 0) { 		error('','User has no data!','','',true);	}	// Loop through query and create table data	while(list($ID, $Username, $Fid, $Uploaded, $Downloaded, $LastAction, $Seeding, $SeedTime, $HnR, $TorrentName, $GroupID, $Year) = $DB->next_record()){ 			if (!$TorrentName) { $Link = "Torrent Deleted [ID: ".$Fid."]"; } else { $Link = "<a href='torrents.php?id=".$GroupID."'>".$TorrentName." [".$Year."]</a>"; }			if ($Seeding=="1") { $Seeding = "<span class='r99'>Yes</span>"; } else { $Seeding = "<span class='r00'>No</span>"; }			if ($HnR=="0") { $HnR = "<span class='r99'>No</span>"; } 			if ($HnR=="1") { 				if (check_perms('users_mod')) { 					$HnR = "<span class='r00'>Yes - <a href=''>Remove</a></span>"; 				} 				else { 					$HnR = "<span class='r00'>Yes</span>"; 				} 			}			if ($HnR=="2") { $HnR = "<span class='r00'>Removed</span>"; } 			if ($SeedTime=="0") { $SeedTime = "Never"; } else { $SeedTime = time_diff('0',$SeedTime,'2',false, true, $Time = 0); }			$SData .= "<tr><td>".$Link."</td><td style='text-align: center;'>".get_size($Uploaded)."</td>			<td style='text-align: center;'>".get_size($Downloaded)."</td><td style='text-align: center;'>".ratio($Uploaded, $Downloaded)."</td>			<td style='text-align: center;'>".format_time($LastAction,true,2,true)."</td><td style='text-align: center;'>".$Seeding."</td><td style='text-align: center;'>".$SeedTime."</td><td style='text-align: center;'>".$HnR."</td></tr>"; 	}	// Count found rows to make correct # of pagination links 		$DB->query("SELECT FOUND_ROWS()");	list($TorrentCount)=$DB->next_record();	$Pages=get_pages('snatchlist.php',$_GET['page'],$TorrentCount,$MaxPerPage,'id='.$UserID,true);// Query to select Username from Id	to use in page title and header	$DB->query('SELECT Username FROM users_main WHERE ID ='.$UserID);	list($Username)=$DB->next_record();	// Duh!! Create page		show_header('Upload/Download History for '.$Username);?><div class="thin" align='center'>    <h2>Upload/Download History for <a href="user.php?id=<?=$UserID?>"><?=$Username?></a></h2>    <br />		<table><tr><td>		1) At the moment the list is not sortable but will be in the furture.<br />		2) # of results per page can't be changed but when finished there will be an option in your User panel. 		</td></tr></table>	<br />	<div class="linkbox"><?=$Pages?></div>	<table>		<tr class="colhead_dark">			<td><strong>File Name</strong></td>			<td style='text-align: center;'><strong>Uploaded</strong></td>			<td style='text-align: center;'><strong>Downloaded</strong></td>			<td style='text-align: center;'><strong>Ratio</strong></td>			<td style='text-align: center;'><strong>Last Action</strong></td>			<td style='text-align: center;'><strong>Seeding</strong></td>			<td style='text-align: center;'><strong>Seed Time</strong></td>			<td style='text-align: center;'><strong>H&R</strong></td>		</tr>		<?=$SData?>	</table>	<div class="linkbox"><?=$Pages?></div></div><?show_footer();?>