<?php
header('Content-Type: text/html; charset=UTF-8');
include("includes/site_info.php");
include('session_handler.inc');

$WUserID = $_SESSION['Sess_UserId'];
$WUsername = $_SESSION['Sess_UserName'];

$gallery_query=mysql_query("SELECT DATE_FORMAT(modified_date, '%M %d, %Y') as mod_date, DATE_FORMAT(gallery_date, '%M %d, %Y') as create_date, Gallery_ID, Name, Description, Level, cover FROM gallery WHERE mem_id = '$WUserID' ORDER BY modified_date desc limit 6") or die(mysql_error());
$gallery_TOTAL = mysql_num_rows($gallery_query);

$photo_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$WUserID' order by pic_default asc, mod_date desc, pic_date desc limit 6") or die(mysql_error());
$photo_TOTAL = mysql_num_rows($photo_query);
?>

<div id="top_panel" class="grey_row_back">
  <?php include ("panel_top.php"); ?>
</div>
<?php 
	foreach($_GET as $field=>$data) {
	if ($field=="done") {
		echo'<div id="msg_content_done">Wow, Your request was done!</div>';
	}
	elseif ($field=="error") {
		echo'<div id="msg_content_error">Ops! Database Error, please try again!</div>';
	}
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td valign="top"><table width="100%" border="0" cellspacing="0" cellpadding="5" class="white_back_t_xb">
        <tr>
          <td><div class="light_orang_h">
              <div style="background-color:#FF0000; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
              Galleries </div>
             <div class="right white_back padding_tb_5">  <a class="button" title="Add Album" href="#caddalbum?tab=media" onclick="javascript: callpage(this.href);" rel="subpage_link">Add Album</a> <a class="button" title="More Album" href="#cgalleries?tab=media" onclick="javascript: callpage(this.href);" rel="subpage_link">More</a></div> 
            <div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
            <div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
        </tr>
        <tr>
          <td><?php if ($gallery_TOTAL > 0){ ?>
            <?php while ($gallery = mysql_fetch_object($gallery_query) ) {
$galleryitem_query=mysql_query("SELECT * FROM galleryitem WHERE Gallery_ID = '$gallery->Gallery_ID'") or die(mysql_error());
$galleryitem_TOTAL = mysql_num_rows($galleryitem_query);
if ($gallery->cover!=0){
$cover_query=mysql_query("SELECT * FROM galleryitem WHERE Gallery_ID = '$gallery->Gallery_ID' and GalleryItem_ID='$gallery->cover' limit 1") or die(mysql_error());
$cover= mysql_fetch_object($cover_query);
$url = $SITE_MAIN_WWW_ROOT."/members/".$WUsername."/gallery/".md5($gallery->cover)."_medium.".$cover->ext;
} else {
$url = $SITE_WWW_ROOT."/images/spacer.gif";
}
?>
            <div class="left padding_10" style="width:110px">
              <span class="left img_b_p3"><div class="clippedImage" style="background-image: 
url(&quot;<?=$url?>&quot;);"><a href="#cgallery?tab=media&gid=<?=$gallery->Gallery_ID?>" onclick="javascript: callpage(this.href);" rel="subpage_link">&nbsp;</a></div></span>
              <div class="left padding_lr_5"> <b> <a href="#cgallery?tab=media&gid=<?=$gallery->Gallery_ID?>" onclick="javascript: callpage(this.href);" rel="subpage_link">
				<?=$gallery->Name?>
                </a> </b> <br />
                <span class="lightgrey_10">
                <?=$gallery->Level?>
                <br />
                <span class="line_height20">
                <?=$galleryitem_TOTAL?>
                <?php if ($galleryitem_TOTAL > 1) echo "photos"; else echo "photo"; ?>
                <br />
                </span> </span>
                <span class="lightgrey_10"> Updated
                <?= $gallery->mod_date?>
                <br />
                Created
                <?= $gallery->create_date?>
                <br />
                <span class="line_height20"> <a href="#ceditgallery?tab=media&gid=<?=$gallery->Gallery_ID?>" onclick="javascript: callpage(this.href);" rel="subpage_link">Edit</a> | <a href="#cgallery?tab=media&gid=<?=$gallery->Gallery_ID?>" onclick="javascript: callpage(this.href);" rel="subpage_link">View</a> | <a href="#ceditdelete?tab=media&gid=<?=$gallery->Gallery_ID?>" rel="subpage_link" onclick="javascript: callpage(this.href);">Delete</a> </span> </span> </div>
            </div>
            <?php } ?>
            <?php } ?>
          </td>
        </tr>
        <tr>
          <td><div class="light_orang_h">
              <div style="background-color:#0000FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
              Profile Photos </div>
            <div class="right white_back padding_tb_5"> <a class="button" title="Add Photo" href="#caddpphoto?tab=media" onclick="javascript: callpage(this.href);" rel="subpage_link">Add Photo</a> <a class="button" title="More Photos" href="#cphoto?tab=media" onclick="javascript: callpage(this.href);" rel="subpage_link">More</a></div>
            <div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
            <div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
        </tr>
        <tr>
          <td><table width="100%" border="0" cellpadding="5" cellspacing="0">
              <tr>
                <td><?php if ($photo_TOTAL > 0){ ?>
                  <?php while ($photo = mysql_fetch_object($photo_query) ) {
$photoitem_query=mysql_query("SELECT * FROM pictures WHERE pic_userid = '$WUserID'") or die(mysql_error());
$photoitem_TOTAL = mysql_num_rows($photoitem_query);
$url = $SITE_MAIN_WWW_ROOT."/members/".$WUsername."/picture/".$photo->pic_picture."_medium.".$photo->ext;
?>
                  <div class="left padding_10">
                    <span class="left img_b_p3"><div class="clippedImage" style="background-image: 
url(&quot;<?=$url?>&quot;);"><a href="#cpropic?tab=media&pid=<?=$photo->pic_id?>" onclick="javascript: callpage(this.href);" rel="subpage_link">&nbsp;</a></div></span>
                  </div>
                  <?php } ?>
                  <?php } ?>
                </td>
              </tr>
            </table></td>
        </tr>
        <!-- 
		    <tr>
              <td><div class="light_orang_h">
                  <div style="background-color:#FF00FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
                Audio </div>
                  <div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
                <div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellpadding="5" cellspacing="0">
                <tr>
                  <td>&nbsp;</td>
                </tr>
              </table></td>
            </tr>
            <tr>
              <td><div class="light_orang_h">
                  <div style="background-color:#FF00FF; width:10px; height:10px; float:left; margin-top:3px; margin-right:5px;"><img src="images/spacer.gif" width="10" height="10" /></div>
                Video</div>
                  <div class="dot_line"><img src="images/spacer.gif" width="1" height="1" /></div>
                <div class="solid_line"><img src="images/spacer.gif" width="1" height="1" /></div></td>
            </tr>
            <tr>
              <td><table width="100%" border="0" cellpadding="5" cellspacing="0">
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
              </table></td>
            </tr>
           -->
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
        <tr>
          <td>&nbsp;</td>
        </tr>
      </table></td>
  </tr>
</table>
