Location: PHPKode > projects > Maian Gallery > maian_gallery/admin/data_files/cats.php
<?php

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

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

  ++++++++++++++++++++++++++++++++++++++++
  
  This File: cats.php
  Description: Categories

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

// Make sure that this file is being called from parent file
if (!defined('INCLUDE_FILES')) {
  accessDenied($msg_script18,$msg_script19);
  exit;
}
 
 // Load edit variable..
 if (isset($_GET['edit'])) {
 
   $q_edit = mysql_query("SELECT * FROM ".$database['prefix']."categories 
                          WHERE id = '".(isset($_POST['edit']) ? (int)$_POST['edit'] : (int)$_GET['edit'])."'
                          LIMIT 1") or die(mysql_error());
   $EDIT = mysql_fetch_object($q_edit);
 }

?>
<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_adminmenu4; ?></b><br><br><?php echo $msg_cats; ?></td>
</tr>
</table>
<table cellpadding="0" cellspacing="1" width="100%" class="menutable">
<tr>
    <td align="left" class="leftPad">&raquo; <b><?php echo strtoupper((isset($EDIT) ? $msg_cats10 : $msg_cats3)); ?></b></td>
</tr>
</table>
<form method="POST" action="index.php?cmd=cats">
<input type="hidden" name="process" value="1">
<?php
if (isset($EDIT)) {
?>
<input type="hidden" name="edit" value="<?php echo $EDIT->id; ?>">
<?php
}
?>
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<tr>
    <td align="left" valign="top" class="msgBox">
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td width="30%" align="left" class="tdHeight"><b><?php echo $msg_cats2; ?></b>:</td>
        <td width="70%" align="left" class="tdHeight"><input class="formbox" type="text" name="cat" maxlength="100" size="25" value="<?php echo (isset($EDIT) ? cleanData($EDIT->catname) : ''); ?>"> <i>(<?php echo $msg_script14.' 100 '.$msg_script15; ?>)</i></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight"><b><?php echo $msg_cats12; ?></b>:</td>
        <td align="left" class="tdHeight"><select name="type">
        <option value="parent" style="padding-left:3px"<?php echo (isset($EDIT) && $EDIT->parent ? ' selected="selected"' : ''); ?>><?php echo $msg_cats13; ?></option>
        <option value="0" disabled="disabled">&nbsp;</option>
        <optgroup label="<?php echo $msg_cats14; ?>">
        <?php
        
        $q_parents = mysql_query("SELECT * FROM ".$database['prefix']."categories 
                               WHERE parent = '1'
                               ORDER BY catname
                               ") or die(mysql_error());
        
        while ($PARENTS = mysql_fetch_object($q_parents))
        {
        ?>
        <option style="padding-left:3px" value="<?php echo $PARENTS->id; ?>"<?php echo (isset($EDIT) && $EDIT->child==$PARENTS->id ? ' selected="selected"' : ''); ?>><?php echo cleanData($PARENTS->catname); ?></option>
        <?php
        }
        
        if (mysql_num_rows($q_parents)==0)
        {
        ?>
        <option style="padding-left:3px" value="0" disabled="disabled"><?php echo $msg_cats18; ?></option>
        <?php
        }
        
        ?>
        </optgroup>
        </select></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight" valign="top"><br><b><?php echo $msg_addimg11; ?></b>: <br><br><i>(<?php echo $msg_addimg14; ?>)</i></td>
        <td align="left" class="tdHeight"><textarea name="comments" rows="4" cols="25" style="width:70%"><?php echo (isset($EDIT) ? cleanData($EDIT->comments) : ''); ?></textarea></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight"><b><?php echo $msg_cats19; ?></b>:</td>
        <td align="left" class="tdHeight"><input class="formbox" type="text" name="folder" maxlength="50" size="25" value="<?php echo (isset($EDIT) ? cleanData($EDIT->folder) : ''); ?>" style="width:50%"> <i>(<?php echo $msg_script14.' 50 '.$msg_script15; ?>)</i> <?php echo toolTip($msg_javascript2,$msg_javascript32); ?></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight"><b><?php echo $msg_cats20; ?></b>:</td>
        <td align="left" class="tdHeight"><input class="formbox" type="text" name="keywords" size="25" value="<?php echo (isset($EDIT) ? cleanData($EDIT->keywords) : ''); ?>"> <i>(<?php echo $msg_addimg14; ?>)</i> <?php echo toolTip($msg_javascript2,$msg_javascript47); ?></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight"><b><?php echo $msg_cats21; ?></b>:</td>
        <td align="left" class="tdHeight"><input class="formbox" type="text" name="description" size="25" value="<?php echo (isset($EDIT) ? cleanData($EDIT->description) : ''); ?>"> <i>(<?php echo $msg_addimg14; ?>)</i> <?php echo toolTip($msg_javascript2,$msg_javascript48); ?></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight"><b><?php echo $msg_cats22; ?></b>:</td>
        <td align="left" class="tdHeight"><select name="mp3">
        <option value="none"<?php echo ($SETTINGS->mp3=='none' ? ' selected="selected"' : ''); ?>><?php echo $msg_settings84; ?></option>
        <?php

        // Load mp3 files..
        $showmp3 = opendir(RELATIVE_PATH.'mp3/');

        while ($read = readdir($showmp3))
        {
  	      if ($read != "." && $read != ".." && $read != "index.html" && $read!='email')
          {
        	  echo '<option'.((isset($EDIT) && $read == $EDIT->mp3) ? ' selected="selected"' : '').' style="padding-left:3px">'.$read.'</option>'."\n";
          }
        }

        closedir($showmp3);
        
        ?>
        </select> <i>(<?php echo $msg_addimg14; ?>)</i> <?php echo toolTip($msg_javascript2,$msg_javascript54); ?></td>
    </tr>
    <tr>
        <td align="left" class="tdHeight"><b><?php echo $msg_cats6; ?></b>:</td>
        <td align="left" class="tdHeight">
        <input type="checkbox" name="en_cat" value="1"<?php echo (isset($EDIT) && $EDIT->en_cat ? ' checked="checked"' : ''); ?>> <?php echo $msg_cats23; ?>
        <?php
        if ($SETTINGS->comments) {
        ?>
        <input type="checkbox" name="en_comments" value="1"<?php echo ($SETTINGS->comments && !isset($EDIT) ? ' checked="checked"' : (isset($EDIT) && $EDIT->en_comments ? ' checked="checked"' : '')); ?>> <?php echo $msg_cats7; ?>
        <?php
        }
        if ($SETTINGS->slideshow) {
        ?>
        <input type="checkbox" name="en_slideshow" value="1"<?php echo ($SETTINGS->slideshow && !isset($EDIT) ? ' checked="checked"' : (isset($EDIT) && $EDIT->en_slideshow ? ' checked="checked"' : '')); ?>> <?php echo $msg_cats8; ?>
        <?php
        }
        if ($SETTINGS->watermarks) {
        ?>
        <input type="checkbox" name="en_watermarks" value="1"<?php echo ($SETTINGS->watermarks && !isset($EDIT) ? ' checked="checked"' : (isset($EDIT) && $EDIT->en_watermarks ? ' checked="checked"' : '')); ?>> <?php echo $msg_cats9; ?>
        <?php
        }
        ?>
        </td>
    </tr>
    <tr>
        <td valign="top" class="tdHeight">&nbsp;</td>
        <td valign="top" align="left" class="tdHeight"><br><input type="submit" class="<?php echo (isset($EDIT) ? 'editbutton' : 'formbutton'); ?>" value="<?php echo (isset($EDIT) ? $msg_cats10 : $msg_cats3); ?>" title="<?php echo (isset($EDIT) ? $msg_cats10 : $msg_cats3); ?>"><?php echo (isset($EDIT) ? '&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="button" class="formbutton" value="'.$msg_script28.'" title="'.$msg_script28.'" onclick="window.location=\'index.php?cmd=cats\'">' : ''); ?></td>
    </tr>
    </table>
    </td>
</tr>
</table>
</form>
<?php
$q_cats = mysql_query("SELECT * FROM ".$database['prefix']."categories 
                       WHERE parent = '1'
                       ORDER BY catname
                       LIMIT $limitvalue,$limit
                       ") or die(mysql_error());
?>
<table cellpadding="0" cellspacing="0" width="100%" class="menutable">
<tr>
    <td align="left" class="leftPad">&raquo; <b><?php echo strtoupper($msg_cats5); ?></b> (<?php echo rowCount('categories'); ?>) <?php echo (rowCount('categories')>0 ? '('.$msg_cats15.')' : ''); ?></td>
</tr>
</table>
<form method="POST" action="index.php?cmd=cats" onsubmit="return delete_confirm('<?php echo $msg_javascript31; ?>')">
<input type="hidden" name="process_del" value="1">
<table width="100%" border="0" cellpadding="0" cellspacing="1" style="border: 2px solid #083253">
<?php

if (mysql_num_rows($q_cats)>0)
{
  while ($CATS = mysql_fetch_object($q_cats))
  {
  ?>
  <tr>
    <td align="center" class="msgBox">
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" width="95%" class="tdHeight"><a href="index.php?cmd=cats&amp;edit=<?php echo $CATS->id; ?>"><b><?php echo cleanData($CATS->catname); ?></b></a></td>
      <td align="center" class="tdHeight"><input type="checkbox" name="cat[]" value="<?php echo $CATS->id; ?>"></td>
    </tr>
    <tr>
      <td align="left" colspan="2" style="line-height:20px">
      <?php
      
      $q_child = mysql_query("SELECT * FROM ".$database['prefix']."categories 
                              WHERE child = '{$CATS->id}'
                              ORDER BY catname
                              ") or die(mysql_error());
                             
      while ($CHILDREN = mysql_fetch_object($q_child))
      {
      ?>
      &#8226; <a href="index.php?cmd=cats&amp;edit=<?php echo $CHILDREN->id; ?>"><?php echo cleanData($CHILDREN->catname); ?></a> [<a href="index.php?cmd=cats&amp;del=<?php echo $CHILDREN->id; ?>" onclick="return delete_confirm('<?php echo $msg_javascript30; ?>')" title="<?php echo $msg_cats16; ?>"><b>X</b></a>]<br>
      <?php
      }                       
      
      ?>
      </td>
    </tr>  
    </table>
    </td>
  </tr>
  <?php
  }
}
else
{

?>
<tr>
    <td align="center" class="msgBox">[ <?php echo $msg_cats4; ?> ]</td>
</tr>
<?php
}
?>
</table>
<?php
// page numbers..
if (rowCount('categories')>0) {
  echo '<p align="right" class="pbutton"><input class="formbutton" type="submit" value="'.$msg_cats17.'" title="'.$msg_cats17.'"></p>';
  echo admin_page_numbers(rowCount('categories',' WHERE parent=\'1\''),$limit,$page);
}
?>
</form>
</div>
Return current item: Maian Gallery