<?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: edit_image.php
  Description: Edit Image

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

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

$q_image = mysql_query("SELECT * FROM ".$database['prefix']."images 
                        WHERE id = '".(isset($_POST['edit']) ? (int)$_POST['edit'] : (int)$_GET['edit'])."'
                        LIMIT 1") or die(mysql_error());
$IMG = mysql_fetch_object($q_image);

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $msg_charset; ?>">
<title></title>
<link href="css/css.css" rel="stylesheet" type="text/css">
<script type="text/javascript" src="js/overlib.js"><!-- overLIB (c) Erik Bosrup --></script>
<style type="text/css">
body {
  margin:0;
  padding:0;
}
</style>
</head>

<body>
<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>
<form method="post" action="index.php?cmd=cat_images">
<input type="hidden" name="process" value="1">
<input type="hidden" name="edit" value="<?php echo $IMG->id; ?>">
<table width="100%" cellspacing="0" cellpadding="0" border="0">
<tr>
    <td align="left" style="padding:5px;background-color:#1EB5DD;color:#FFFFFF">
<table width="100%" cellspacing="0" cellpadding="2" border="0">
<tr>
    <td align="left" style="color:#FFFFFF;padding:5px;border:1px solid #063052;background-color:#0F5B96">
    <?php
    if (isset($UPDATED))
    {
    ?>
    <table width="100%" cellspacing="0" cellpadding="0">
    <tr>
      <td align="left" style="padding:5px;height:300px" valign="top">
      <?php echo $msg_addimg30; ?><br><br>
      &#8226; <a href="index.php?cmd=cat_images&amp;edit=<?php echo $IMG->id; ?>" title="<?php echo $msg_addimg31; ?>"><?php echo $msg_addimg31; ?></a>
      </td>
    </tr>
    </table>
    <?php
    }
    else
    {
    ?>
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
        <td align="left" valign="top" style="padding:5px">
        <table width="100%" border="0" cellpadding="0" cellspacing="2">
        <tr>
            <td align="left" class="tdHeight" width="25%"><b><?php echo $msg_addimg7; ?></b>:</td>
            <td width="75%" align="left" class="tdHeight"><input type="text" name="name" maxlength="200" class="formbox" value="<?php echo cleanData($IMG->name); ?>"></td>
        </tr>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_addimg9; ?></b>:</td>
            <td align="left" class="tdHeight">
            <select name="cat">
            <?php
            
            $q_cats = mysql_query("SELECT * FROM ".$database['prefix']."categories 
                                   WHERE parent = '1'
                                   ORDER BY catname
                                   ") or die(mysql_error());
  
            while ($CATS = mysql_fetch_object($q_cats)) {
              echo '<option value="'.$CATS->id.'" style="padding-left:3px"'.($IMG->cat==$CATS->id ? ' selected="selected"' : '').'>'.cleanData($CATS->catname).'</option>'."\n";
  
              // Does this category have children...
              $q_children = mysql_query("SELECT * FROM ".$database['prefix']."categories
                                         WHERE child = '{$CATS->id}'
                                         ORDER BY catname
                                         ") or die(mysql_error());
  
              if (mysql_num_rows($q_children)>0) {
                while ($CHILDREN = mysql_fetch_object($q_children)) {
                  echo '<option value="'.$CHILDREN->id.'" style="padding-left:3px"'.($IMG->cat==$CHILDREN->id ? ' selected="selected"' : '').'>- '.cleanData($CHILDREN->catname).'</option>'."\n";
                }
              }
            }

            ?>
            </select> <?php echo toolTip($msg_javascript2,$msg_addimg34); ?>
            </td>
        </tr>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_addimg11; ?></b>:<br><br><i>(<?php echo $msg_addimg14; ?>)</i></td>
            <td align="left" class="tdHeight"><textarea name="comments" style="width:90%" rows="5" cols="20"><?php echo cleanData($IMG->comments); ?></textarea></td>
        </tr>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_cats20; ?></b>:</td>
            <td align="left" class="tdHeight"><input type="text" name="keywords" class="formbox" value="<?php echo cleanData($IMG->keywords); ?>"></td>
        </tr>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_cats21; ?></b>:</td>
            <td align="left" class="tdHeight"><input type="text" name="description" class="formbox" value="<?php echo cleanData($IMG->description); ?>"></td>
        </tr>
        <?php

        // Is cart enabled..show buy options..
        if ($SETTINGS->cart)
        {
        ?>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_addimg6; ?></b>:</td>
            <td align="left" class="tdHeight"><?php echo $msg_script5; ?> <input type="radio" name="sale_item" value="1"<?php echo ($IMG->sale_item ? ' checked="checked"' : ''); ?>> <?php echo $msg_script6; ?> <input type="radio" name="sale_item" value="0"<?php echo (!$IMG->sale_item ? ' checked="checked"' : ''); ?>></td>
        </tr>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_addimg15; ?></b>:</td>
            <td align="left" class="tdHeight"><textarea name="details" style="width:90%" rows="5" cols="20"><?php echo cleanData($IMG->details); ?></textarea></td>
        </tr>
        <?php
        }
        
        ?>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_addimg28; ?></b>:</td>
            <td align="left" class="tdHeight"><input type="text" name="visits" class="formbox" style="width:10%" value="<?php echo $IMG->visits; ?>"></td>
        </tr>
        <tr>
            <td align="left" class="tdHeight"><b><?php echo $msg_addimg33; ?></b>:</td>
            <td align="left" class="tdHeight"><?php echo $msg_script5; ?> <input type="radio" name="enabled" value="1"<?php echo ($IMG->enabled ? ' checked="checked"' : ''); ?>> <?php echo $msg_script6; ?> <input type="radio" name="enabled" value="0"<?php echo (!$IMG->enabled ? ' checked="checked"' : ''); ?>></td>
        </tr>
        <tr>
            <td align="left" class="tdHeight">&nbsp;</td>
            <td align="left" class="tdHeight"><br><input type="submit" class="formbutton" value="<?php echo $msg_addimg29; ?>" title="<?php echo $msg_addimg29; ?>"></td>
        </tr>
        </table>
        </td>
    </tr>
    </table>
    <?php
    }
    ?>
    </td>
</tr>
</table>
</td></tr></table>
</form>
</body>
</html>
