<?php
///////////////////////////////////////////////////////////////////////////////
//                                                                           //
//   Program Name         : ProPhotoHost                                     //
//   Release Version      : 1.0                                              //
//   Home Page            : http://www.prophotohost.com                      //
//   Program Author       : Jake P                                           //
//   Supplied by          : drew010                                          //
//   Nullified by         : CyKuH [WTN]                                      //
//   Distribution         : via WebForum, ForumRU and associated file dumps  //
//                                                                           //
///////////////////////////////////////////////////////////////////////////////
session_start();
if($session_access == false) {
	header("location: ./error.php?error=session");
}

include('i.setup.php');
include('i.connection.php');
include('i.function.php');

if($mode == "delete") {
	$query = mysql_query("SELECT image_id FROM image WHERE image_member_id = '$session_member_id' and image_status = 'A' ORDER BY image_id");
	while($data = mysql_fetch_object($query, $db)) {
		if(${"checkbox" . $data->image_id} == 1) {
			$sql = "UPDATE image SET image_status='D' WHERE image_id = '$data->image_id'";
			$result = mysql_query($sql);
		}
	}
}
?>

<html>

<head>
<title><?php print($page_title); ?></title>

<meta name="description" content="<?php print($page_desc); ?>">
<meta name="keywords" content="<?php print($page_key); ?>">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">


<?php include('i.style.php'); ?>

<script language="javascript">
	
	function copyit(theField) {
		var tempval=eval("document.home."+theField)
		tempval.focus()
		tempval.select()
		therange=tempval.createTextRange()
		therange.execCommand("Copy")
	}
	
	function new_window(mypage, myname, w, h, scroll) {
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
		winprops = 'height='+h+',width='+w+',top='+wint+',left='+winl+',scrollbars='+scroll+',resizable'
		win = window.open(mypage, myname, winprops)
		if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }
	}
	
	function jp_delete(field) {
		var agree = confirm("Are you sure you want to delete the selected images?");
		
		if(agree) {
			document.home.action = "<? echo $PHP_SELF; ?>?mode=delete";
			document.home.submit();		
		}
	}
	
</script>

</head>

<body marginwidth="0" marginheight="0" leftmargin="0" topmargin="0" rightmargin="0">
	
	<table width="100%" cellpadding="0" cellspacing="0">
		
		<?php include('i.header.php'); ?>
		
		<tr>
			
			<td valign="top">
				
				<table cellpadding="0" cellspacing="0">
					
					<tr>
						
						<td><font face="verdana" size="1">&nbsp;&nbsp;&nbsp;</font></td>
						
					</tr>
					
				<tr>
					
					<td><font face="verdana" size="1">&nbsp;&nbsp;&nbsp;</font></td>
					
					<td valign="top">
						
						<table cellpadding="0" cellspacing="0">
							
							<?php include('i.tab.php'); ?>
							
						</table>
						
					</td>
					
					<td><font face="verdana" size="1">&nbsp;&nbsp;</font></td>
					
					<td valign="top" width="100%" height="100%">
						
						<table width="100%" height="100%" cellpadding="0" cellspacing="0">
							
							<tr>
								
								<td><font face="verdana" size="1">&nbsp;</font></td>
								
								<td width="100%" height="100%">
									
									<table width="100%" height="100%" cellpadding="0" cellspacing="0">
										
										<tr>
											
											<td><img src="./images/heading.control.gif"></td>
											
										</tr>
										
										<tr>
											
											<td height="8" background="images/hr.gif"></td>
											
										</tr>
										
										<tr>
											
											<td><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<tr>
											
											<td>
												
												<table>
													
													<?php
													$query = mysql_query("SELECT member_name FROM member WHERE member_id = '$session_member_id'");
													$data = mysql_fetch_object($query, $db);
													
													$query = mysql_query("SELECT image_id, image_size FROM image WHERE image_member_id = '$session_member_id' and image_status = 'A'");
													while($data2 = mysql_fetch_object($query, $db)) {
														$size = $size + $data2->image_size;
													}
													$rows = mysql_num_rows($query);
													?>
													
													<tr>
														
														<td>
															
															<font face="verdana" size="1">
																
																Welcome <b><?php print($data->member_name); ?></b>!<br><br>
																You have <b><?php print($rows); ?></b> images hosted.<br>
																<?php
																$file_size = round(($size/1024), 2);
																if($file_size > 1024) {
																?>
																	Space used <b><?php print(round(($file_size/1024), 2)); ?> mb</b>.
																<?php } else { ?>
																	Space used <b><?php print($file_size); ?> kb</b>.
																<?php } ?>
																
															</font>
															
														</td>
														
													</tr>
													
												</table>
												
											</td>
											
										</tr>
										
										<tr>
											
											<td><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<tr>
											
											<td><img src="./images/heading.manager.gif"></td>
											
										</tr>
										
										<tr>
											
											<td height="8" background="images/hr.gif"></td>
											
										</tr>
										
										<tr>
											
											<td><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<?php
										$query = mysql_query("SELECT image_id, image_name, image_ext, image_caption, image_width, image_height, image_size FROM image WHERE image_member_id = '$session_member_id' and image_status = 'A' ORDER BY image_id");
										$rows = mysql_num_rows($query);
										
										if($rows == 0) {
										?>
											
											<tr>
												
												<td>
													
													<font face="verdana" size="1">There are no images at this time.</font>
													
												</td>
												
											</tr>
											
										<?php
										}
										else {
										?>
										
										<form name="home" method="post">
										<input type="hidden" name="list_num" value="<?php print($rows); ?>">
										
										<tr>
											
											<td>
												
												<table width="100%" cellpadding="4" cellspacing="0">
													
													<tr>
														
														<td align="center"><font face="verdana" size="1"><b>Delete</b></font></td>
														
														<td align="center"><font face="verdana" size="1"><b>Image</b></font></td>
														
														<td><font face="verdana" size="1"><b>Caption</b></font></td>
														
														<td align="center"><font face="verdana" size="1"><b>Width/Height</b></font></td>
														
														<td align="center" nowrap><font face="verdana" size="1"><b>Size[kb]</b></font></td>
														
													</tr>
													
													<?php
													if($startat == "") {
														$startat = 0;
													}
													if($perpage == "") {
														$perpage = 5;
													}
													
													$line = $startat;
													$templine = 0;
													$recordnum = 0;
													$total_views = 0;
													$count_total = 0;
													
													$max = mysql_num_rows($query);
													while($data = mysql_fetch_object($query, $db)) {
														if($templine < $perpage and $line < $max) {
															if($line == $recordnum) {
																$line++;
																$templine++;
																
																if(($thisrow%2) == 0) {
																	$color = "#EEEEEE";
																	$thisrow++;
																}
																else {
																	$color = "#FFFFFF";
																	$thisrow++;
																}
																?>
																
																<tr bgcolor="<?php print($color); ?>">
																	
																	<td align="center"><input type="checkbox" name="checkbox<?php print($data->image_id); ?>" value="1"></td>
																	
																	<?php if($data->image_ext == "gif") { ?>
																		
																		<td align="center"><a href="javascript:new_window('./detail.php?id=<?php print($data->image_id); ?>', 'popup', '<?php print($data->image_width); ?>', '<?php print($data->image_height); ?>', 'no');"><img src="./hosted/<?php print($data->image_name); ?>.<?php print($data->image_ext); ?>" height="50" border="1"></a></td>
																		
																	<?php } else { ?>
																		
																		<td align="center"><a href="javascript:new_window('./detail.php?id=<?php print($data->image_id); ?>', 'popup', '<?php print($data->image_width); ?>', '<?php print($data->image_height); ?>', 'no');"><img src="./hosted/thumb_<?php print($data->image_name); ?>.<?php print($data->image_ext); ?>" height="50" border="1"></a></td>
																		
																	<?php } ?>
																	<td width="100%">
																		
																		<table cellpadding="0" cellspacing="0">
																			
																			<?php if($data->image_caption == "") { ?>
																			
																			<tr>
																				
																				<td align="right"><font face="verdana" size="1">caption:&nbsp;</font></td>
																				<td colspan="2"><font face="verdana" size="1">n\a</font></td>
																				
																			</tr>
																			
																			<?php } else { ?>
																			
																			<tr>
																				
																				<td align="right"><font face="verdana" size="1">caption:&nbsp;</font></td>
																				<td colspan="2"><font face="verdana" size="1"><?php print($data->image_caption); ?></font></td>
																				
																			</tr>
																			
																			<?php } ?>
																			
																			<tr>
																				
																				<td align="right"><font face="verdana" size="1">link:&nbsp;</font></td>
																				<td nowrap><font face="verdana" size="1"><input type="text" name="link<?php print($data->image_id); ?>" class="form" value="<?php print($page_url); ?>/hosted/<?php print($data->image_name); ?>.<?php print($data->image_ext); ?>" style="width: 425px;">&nbsp;</font></td>
																				<td nowrap><a href="javascript:copyit('link<?php print($data->image_id); ?>');"><img src="./images/bu.copy.gif" border="0"></a></td>
																				
																			</tr>
																			
																		</table>
																		
																	</td>
																	
																	<td align="center"><font face="verdana" size="1"><?php print($data->image_width); ?>/<?php print($data->image_height); ?></font></td>
																	
																	<?php
																	$file_size = round(($data->image_size/1024), 2);
																	if($file_size > 1024) {
																	?>
																		<td align="center" nowrap><font face="verdana" size="1"><?php print(round(($file_size/1024), 2)); ?> mb</font></td>
																	<?php } else { ?>
																		<td align="center" nowrap><font face="verdana" size="1"><?php print($file_size); ?> kb</font></td>
																	<?php } ?>
																	
																</tr>
																
															<?php
															}
															$recordnum++;
														}
													}
													?>
													
													<tr>
														
														<td colspan="6" height="8" background="images/hr.gif"></td>
														
													</tr>
													
													<tr>
														
														<td align="center">
															
															<a href="javascript:jp_delete();"><img src="./images/bu.delete.gif" border="0"></a>
															
														</td>
														
														<td colspan="6">
															
															<table width="100%">
																
																<tr>
																
																	<td align="center" nowrap>
																		
																		<font face="verdana" size="1">
																			
																			<?php
																			if(($startat + $perpage) < $max) {
																				print(($startat + 1) . " - " .  ($startat + $perpage) . " of " . $max);
																			} else {
																				print(($startat + 1) . " - " .  $max . " of " . $max);
																			}
																			?>
																			
																		</font>
																		
																	</td>
																	
																	<td align="center" nowrap>
																		
																		<a href="<?php print($PHP_SELF . "?startat=" . $startat . "&perpage=5" . "&sort_by=" . $sort_by); ?>"><img src="./images/bu.5.gif" border="0"></a>
																		<a href="<?php print($PHP_SELF . "?startat=" . $startat . "&perpage=10" . "&sort_by=" . $sort_by ); ?>"><img src="./images/bu.10.gif" border="0"></a>
																		<a href="<?php print($PHP_SELF . "?startat=" . $startat . "&perpage=15" . "&sort_by=" . $sort_by ); ?>"><img src="./images/bu.15.gif" border="0"></a>
																		<a href="<?php print($PHP_SELF . "?startat=" . $startat . "&perpage=20" . "&sort_by=" . $sort_by ); ?>"><img src="./images/bu.20.gif" border="0"></a>
																		<a href="<?php print($PHP_SELF . "?startat=" . $startat . "&perpage=25" . "&sort_by=" . $sort_by ); ?>"><img src="./images/bu.25.gif" border="0"></a>
																		
																	</td>
																	
																	<td align="right" nowrap>
																		
																		<font face="verdana" size="1">
																			
																			<?
																			if(($startat - $perpage) < 1) { ?>
																				<a href="<?php print($PHP_SELF . "?startat=0&perpage=" . $perpage . "&sort_by=" . $sort_by); ?>">Previous</a>
																			<?php } else { ?>
																				<a href="<?php print($PHP_SELF . "?startat=" . ($startat - $perpage)); ?>&perpage=<?php print($perpage) . "&sort_by=" . $sort_by; ?>">Previous</a>
																			<?php } ?>
																			 : 
																			<?php if($line < $max) { ?>
																				<a href="<?php print($PHP_SELF . "?startat=" . ($startat + $perpage)); ?>&perpage=<?php print($perpage) . "&sort_by=" . $sort_by; ?>">Next</a>
																			<?php } else { ?>
																				<a href="<?php print($PHP_SELF . "?startat=" . $startat); ?>&perpage=<?php print($perpage) . "&sort_by=" . $sort_by; ?>">Next</a>
																			<?php } ?>
																			
																		</font>
																		
																	</td>
																	
																</tr>
																
															</table>
															
														</td>
														
													</tr>
													
												</table>
												
											</td>
											
										</tr>
										
										</form>
										
										<?php } ?>
										
										<tr>
											
											<td height="100%"><font face="verdana" size="1">&nbsp;</font></td>
											
										</tr>
										
										<tr>
											
											<td height="8" background="images/hr.gif"></td>
											
										</tr>
										
									</table>
									
								</td>
								
								<td><font face="verdana" size="1">&nbsp;</font></td>
								
							</tr>
							
						</table>
						
					</td>
					
				</tr>
				
			</table>
			
		</td>
		
	</tr>
	
	<?php include('i.footer.php'); ?>
	
	</table>
	
</body>

</html>