<?
session_start();
include_once "functions.inc.php";

if ($_POST['send'] == 'OK') {
$data[1] = $_POST['kategori'];
	if ($_POST['key'] == '') {add_db('files/kategori.txt',$data);}
	else if ($_POST['key'] != ''){ $data[0] = $_POST['key']; edit_db('files/kategori.txt',$data);}

$_SESSION['note'] = "Data berhasil disimpan"; 
redirect('gallery_kategori.php'); die();
}

if ($_GET['q'] == 'del' && $_GET['id'] != '') {
del_db('files/kategori.txt',$_GET['id']);

$_SESSION['note'] = "Data berhasil dihapus";
redirect('gallery_kategori.php'); die();
}

if ($_GET['id'] != '') {
$column_kategori_detail = key_db('files/kategori.txt',$_GET['id']);
}

?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Kategori Gallery</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<link href="style_gallery.css" rel="stylesheet" type="text/css">

<script>

<!--

active1 = new Image(26,26);
 active1.src = "but1b.jpg";
 inactive1 = new Image(26,26);
 inactive1.src = "but1a.jpg";

active2 = new Image(26,26);
 active2.src = "but2b.jpg";
 inactive2 = new Image(26,26);
 inactive2.src = "but2a.jpg";

active3 = new Image(26,26);
 active3.src = "but3b.jpg";
 inactive3 = new Image(26,26);
 inactive3.src = "but3a.jpg";
 
active4 = new Image(26,26);
 active4.src = "but4b.jpg";
 inactive4 = new Image(26,26);
 inactive4.src = "but4a.jpg";

active5 = new Image(26,26);
 active5.src = "but5b.jpg";
 inactive5 = new Image(26,26);
 inactive5.src = "but5a.jpg";
 
active6 = new Image(26,26);
 active6.src = "but6b.jpg";
 inactive6 = new Image(26,26);
 inactive6.src = "but6a.jpg";


//-->

</script>
</head>
<style><!--a:hover{color:#000080; text-decoration:underline; }--></style>
<style><!--a{text-decoration:none}; //--></style>
<body topmargin="0" leftmargin="0" bgcolor="#000000">
<div align="center">
  <center>
  <table border="0" cellpadding="0" cellspacing="0"  bordercolor="#111111" width="780" id="AutoNumber1" height="100%">
    <tr>
        <td width="100%" height="243" valign="top"><img src="top.JPG" width="900" height="210"> 
          <table width="100%" border="0">
            <tr>
              <td width="58%" height="21"> 
                <div align="left"><font face="Arial" size="1" color="#FFFFFF"><span lang="sk"><a href="index.htm"><font color="#FFFFFF" size="2"><b><font size="3">Home</font></b></font></a></span></font><font color="#FF0000" size="4"><b> 
                  | </b></font><font face="Arial" size="1" color="#FFFFFF"><span lang="sk"><a href="clinic.htm"><font color="#FFFFFF" size="2"><b><font size="3">Photography 
                  Clinic</font></b></font></a></span></font><font color="#FF0000" size="4"><b> 
                  | </b></font><font face="Arial" size="1" color="#FFFFFF"><span lang="sk"><a href="Gallery.php"><font color="#FFFFFF" size="2"><b><font size="3">Gallery 
                  Photo</font></b></font></a></span></font><font color="#FF0000" size="4"><b><font face="Arial" size="2" color="#FFFFFF"> 
                  </font>| </b></font><font face="Arial" size="1" color="#FFFFFF"><span lang="sk"><font color="#FFFFFF" size="2"><b><font face="Arial" size="1" color="#FFFFFF"><span lang="sk"><a href="Biography.htm"><font color="#FFFFFF" size="2"><b><font size="3">Biography</font></b></font></a></span></font></b></font> 
                  </span></font><font color="#FF0000" size="4"><b><font face="Arial" size="2" color="#FFFFFF"> 
                  </font>| </b></font><font face="Arial" size="1" color="#FFFFFF"><span lang="sk"><a href="ContactMe.htm"><font color="#FFFFFF" size="2"><b><font size="3">Contact 
                  Me</font></b></font></a></span></font></div>
              </td>
              <td width="41%" background="pinsil.gif" height="21">&nbsp;</td>
              <td width="1%">&nbsp;</td>
            </tr>
          </table>
        </td>
    </tr>
    <tr>
        <td width="100%" bgcolor="#000000" valign="top">
<table border="0" cellpadding="0" cellspacing="0"  bordercolor="#111111" width="100%" height="100%">
        <tr>
              <td align="center" valign="top" bgcolor="#000000"> 
                <table width="98%" border="0">
                  <tr>
                    <td>&nbsp;</td>
                  </tr>
                </table>
                <table width="98%" border="0">
                  <tr>
                    <td bgcolor="#CC3300"><font color="#FF0000"><b><font size="4" color="#FFFFFF">Gallery Photo</font></b></font></td>
                  </tr>
                  <tr>
                    <td align="left" valign="top">

 <p>Kategori :</p>
 <table width="400" border="0" cellspacing="0" cellpadding="2">
   <tr align="left" valign="top">
     <td width="236">&nbsp;</td>
     <td width="156" align="center"><a href="#add">Add</a></td>
   </tr>
<?
$row_kategori = read_db('files/kategori.txt',1,999);
foreach ($row_kategori as $column_kategori) {
?>
   <tr align="left" valign="top">
     <td><?=$column_kategori[1]?>&nbsp;</td>
     <td align="center"><a href="gallery_kategori.php?q=edit&id=<?=$column_kategori[0]?>">Edit</a> | <a href="gallery_kategori.php?q=del&id=<?=$column_kategori[0]?>" onClick="return confirm('Apakah anda yakin akan menghapus?');">Del</a> </td>
   </tr>
<? }?>
 </table>
 <p>&nbsp;</p>
 <form name="form1" method="post" action="">
   <a name="add"></a>Nama kategori: 
   <input name="kategori" type="text" id="kategori" value="<?=trim($column_kategori_detail[1])?>" size="33">
   <input type="submit" name="Submit" value="Simpan">
   <input name="send" type="hidden" id="send" value="OK"> 
   <input name="key" type="hidden" id="key" value="<?=$_GET['id']?>">
 </form>
 <p>&nbsp;</p>
 <p>&nbsp; </p>
					</td>
                  </tr>
                </table>
                <p>&nbsp;</p></td>
            </tr>
      </table>
        </td>
    </tr>
    <tr>
        <td width="100%" bgcolor="#CC3300" height="20" style="border-left-width: 1; border-right-width: 1; border-top: 1px solid #606060; border-bottom-width: 1"> 
          <p align="center"><font size="1" face="Arial" color="#FFFFFF">Copyright 
            © 2012 </font> 
        </td>
    </tr>
  </table>
  </center>
</div>

</body>
</html>
<?
$note = $_SESSION['note'] ; 
if ($note != '') {
?>
<script type="text/javascript"> 
<!-----hide from old browsers 
alert('<?php echo $note ;?>'); 
//---------> 
</script> 
<? 
} 
$_SESSION['note'] = ''; $note = '';
?>