<?
include "header.php";
echo $header;

$folders = mysql_query("SELECT * FROM ims_folders WHERE u_id='$user_info[u_id]' ORDER BY name");

if(mysql_num_rows($folders) > 0) {
$welcome = "
Your image folders are listed below. Select a folder to view<br>
its contents or upload new images.
";
} else {
$welcome = "
Your account currently contains no image folders. To begin
uploading images, please click the Create New Folder button.
";
}

if($admin_info[demo_feature] == "on" & $user_info[email] == "$admin_info[demo_email]") {
echo "
<table cellpadding='0' cellspacing='0' width='520'>
<tr>
<td width='270'>
<b>Welcome to the $admin_info[site_name] Demonstration.</b><br>
Your image folders are listed below. Select a folder to view
its contents or upload new images.
</td>
<form action='create_folder.php' method='POST'>
<td valign='bottom' align='center'>
<input type='submit' class='button' value='Create New Folder'><br>
Note: Some features disabled in demo.
</td>
</tr>
</form>
</table>
";
} else {
echo "
<table cellpadding='0' cellspacing='0' width='520'>
<tr>
<td width='314'>
<b>Welcome to your account, $user_info[fname].</b><br>
$welcome
</td>
<form action='create_folder.php' method='POST'>
<td>
<input type='submit' class='button' value='Create New Folder'>
</td>
</tr>
</form>
</table>
";
}


$count = 0;
while($folder_info = mysql_fetch_assoc($folders)) {
$count = $count + 1;

// COUNT IMAGES IN THIS FOLDER
$images_inside = mysql_num_rows(mysql_query("SELECT * FROM ims_image WHERE u_id='$user_info[u_id]' AND f_id='$folder_info[f_id]'"));
$folder_space_used = mysql_fetch_assoc(mysql_query("SELECT sum(size) AS size FROM ims_image WHERE u_id='$user_info[u_id]' AND f_id='$folder_info[f_id]'"));
if($folder_space_used[size] == NULL) { $folder_space_used[size] = 0; }
$folder_space_used = ((int) $folder_space_used[size]) / (1024 * 1024);
$folder_space_used = rounder($folder_space_used);

echo "
  <table cellpadding='0' cellspacing='0' style='background: #FFFFFF; border: 1px solid #AAAAAA;"; if($count == 1) { echo " margin-top: 10px;"; } else { echo " border-top: none;"; } echo "'>
  <tr>
  <td width='20' valign='top' style='padding: 5px; padding-right: 4px; padding-top: 8px;'><a href='view_folder.php?f_id=$folder_info[f_id]' title='Open Folder'><img src='./icons/folder.gif' border='0'></a>&nbsp;</td>
  <td NOWRAP width='472' valign='top' style='padding: 5px; padding-left: 0px;'>
    <table width='100%' cellpadding='0' cellspacing='0'><tr>
    <td NOWRAP><a href='view_folder.php?f_id=$folder_info[f_id]' title='Open Folder'><b>$folder_info[name]</b></a>&nbsp; <b>($images_inside image"; if($images_inside != 1) { echo "s"; } echo ", $folder_space_used MB)</b></td>
    <td align='right'><a href='modify_folder.php?f_id=$folder_info[f_id]'><img src='./icons/modify.gif' border='0' alt='Modify Folder'></a> <a href='delete_folder.php?f_id=$folder_info[f_id]'><img src='./icons/delete.gif' border='0' alt='Delete Folder'></a></td>
    </tr>
    </table>
$folder_info[description]
  </td>
  </tr>
  </table>
";
}



echo $footer;
?>








