<?php

/*++++++++++++++++++++++++++++++++++++++++

  Script: Maian Gallery v2.0
  Written by: David Ian Bennett
  E-Mail: support@maianscriptworld.co.uk
  Website: http://www.maianscriptworld.co.uk

  ++++++++++++++++++++++++++++++++++++++++
  
  This File: categories.php
  Description: Show Image Categories

  ++++++++++++++++++++++++++++++++++++++++*/

// Make sure that this file is being called from parent file
if (!defined('INCLUDE_FILES')) {
  accessDenied($msg_script18,$msg_script19);
  exit;
}

$q_cat = mysql_query("SELECT * FROM ".$database['prefix']."categories 
                      WHERE id = '".(int)$_GET['cat']."'
                      LIMIT 1
                      ") or die(mysql_error());
$CAT = mysql_fetch_object($q_cat);

?>
<div align="center">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<tr>
    <td align="left" class="msgBox">&raquo; <b><?php echo $msg_adminmenu7; ?></b><br><br><?php echo $msg_manage10; ?></td>
</tr>
</table>
<table cellpadding="0" cellspacing="0" width="100%" class="menutable">
<tr>
    <td align="left" class="leftPad" style="border-right:0">&raquo; <b><?php echo strtoupper(cleanData($CAT->catname)); ?></b> (<?php echo rowCount('images',' WHERE cat = \''.$_GET['cat'].'\''); ?>)</td>
    <td align="right" class="leftPad" style="border-left:0">[ <a href="index.php?cmd=manage" title="<?php echo $msg_manage8; ?>" style="color:#FFFFFF"><?php echo $msg_manage8; ?></a> ]</td>
</tr>
</table>
<form method="POST" action="index.php?cmd=cat_images" onsubmit="return delete_confirm('<?php echo $msg_javascript33; ?>')">
<input type="hidden" name="process_del" value="1">
<input type="hidden" name="cat" value="<?php echo $CAT->id; ?>">
<input type="hidden" name="folder" value="<?php echo $CAT->folder; ?>">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<?php

$q_images = mysql_query("SELECT * FROM ".$database['prefix']."images 
                         WHERE cat = '{$_GET['cat']}'
                         ORDER BY name
                         LIMIT $limitvalue,$limit
                         ") or die(mysql_error());

if (mysql_num_rows($q_images)>0)
{
  while ($IMAGES = mysql_fetch_object($q_images))
  {
  ?>
  <tr>
    <td align="center" class="msgBox" style="line-height:20px">
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" width="15%" class="tdHeight"><a href="index.php?cmd=cat_images&amp;img=<?php echo $IMAGES->id; ?>" rel="gb_page_center[680, 540]" title="<?php echo cleanData($IMAGES->name); ?>"><img src="<?php echo $SETTINGS->folder; ?>/galleries/<?php echo $SETTINGS->folder_name; ?>/<?php echo $CAT->folder; ?>/<?php echo $IMAGES->thumbpath; ?>" alt="<?php echo cleanData($IMAGES->name); ?>" height="<?php echo ADD_IMG_HGHT; ?>" width="<?php echo ADD_IMG_WDTH; ?>" class="image_pad" title="<?php echo cleanData($IMAGES->name); ?>"></a></td>
      <td align="left" width="65%" class="tdHeight"><a href="index.php?cmd=cat_images&amp;edit=<?php echo $IMAGES->id; ?>" rel="gb_page_center[600, 500]" title="<?php echo $msg_settings11; ?>: <?php echo cleanData($IMAGES->name); ?>"><b><?php echo cleanData($IMAGES->name); ?></b></a><br>
      <span style="font-size:11px;font-style:italic"><i><?php echo $IMAGES->imagepath; ?></i><br>
      <?php echo $IMAGES->thumbpath; ?><br>
      <?php echo showImgAttributes($IMAGES->id,$CAT->folder,$IMAGES->imagepath); ?></span></td>
      <td align="center" width="15%" class="tdHeight" style="border:2px solid #083253"><a href="index.php?cmd=cat_images&amp;comments=<?php echo $IMAGES->id; ?>" rel="gb_page_center[680, 540]" title="<?php echo $msg_manage11; ?> (<?php echo rowCount('comments',' WHERE imageID = \''.$IMAGES->id.'\' AND is_active = \'1\''); ?>)"><?php echo $msg_manage11; ?></a><br><b><?php echo rowCount('comments',' WHERE imageID = \''.$IMAGES->id.'\' AND is_active = \'1\''); ?></b></td>
      <td align="center" class="tdHeight"><input type="checkbox" name="img[]" value="<?php echo $IMAGES->id; ?>"></td>
    </tr>
    </table>
    </td>
  </tr>
  <?php
  }
}
else
{

?>
<tr>
    <td align="center" class="msgBox">[ <?php echo $msg_manage5; ?> ]</td>
</tr>
<?php
}
?>
</table>
<?php
// page numbers..
if (rowCount('images',' WHERE cat = \''.$_GET['cat'].'\'')>0) {
  echo '<p align="right" class="pbutton"><input class="formbutton" type="submit" value="'.$msg_manage7.'" title="'.$msg_manage7.'"></p>';
  echo admin_page_numbers(rowCount('images',' WHERE cat = \''.$_GET['cat'].'\''),$limit,$page);
}
?>
</form>
</div>
