<!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=utf-8">
<title>Web management</title>
<link rel="stylesheet" href="styles.css" type="text/css">
<?php include 'codes.php';?>
</head>
<body>
<?php 
$insertid = mysql_real_escape_string(stripslashes($_REQUEST['id']));
$level = mysql_real_escape_string(stripslashes($_REQUEST['level']));
$parent = mysql_real_escape_string(stripslashes($_REQUEST['parent']));
?>

<table width="980" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td><div><img src="img/frame-edit.png" width="180" height="37" alt=""></div>
<div class="frame">
<?php
$result = mysql_query("SELECT * FROM infocategories WHERE insert_id='$insertid' AND lang_id=1",$dbh);
$myrow=mysql_fetch_array($result); 
$page=$myrow['page'];
$level=$myrow['level'];
$toplevel=$level-1;
$parent1=$myrow['parent'];
?>

<form name="forma" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
<input type="hidden" name="id" value="<?php echo $insertid ?>">
<input type="hidden" name="level" value="<?php echo $level ?>">
<input type="hidden" name="parent" value="<?php echo $parent ?>">

<table width="100%" border="0" cellspacing="0" cellpadding="3">
    <tr>
      <td width="20">&nbsp;</td>
      <td width="200">&gt;&gt;</td>
      <td>
      
      <?php if ($level>1) { ?>  
         
     <select name="parent" class="forms">
<?php
$sql1 = "SELECT * FROM infocategories WHERE level='$toplevel' AND lang_id=1 ORDER BY priority";
$result1 = mysql_query($sql1);
while ($myrow=mysql_fetch_array($result1)) {
$catid=$myrow['insert_id'];
$category=$myrow['title'];
?>
  <?php if ($catid == $parent ) { ?>
          <option value="<?php echo $parent ?>" selected> 
            <?php echo $category ?>
            <?php } else { ?>
 <?php if ($catid == $parent1 ) { ?>
          <option value="<?php echo $parent1 ?>" selected> 
            <?php echo $category ?>
            <?php } else { ?>           
            <option value="<?php echo $catid ?>"> 
            <?php echo $category ?>
            </option>
<?php }}}?>
      </select> 
      
        <?php } ?>   
        
      </td>
    </tr>
    
    </table>
    
<?php
$sql50 = "SELECT * FROM lang WHERE active=1 ORDER BY id";
$result50 = mysql_query($sql50);
while ($myrow=mysql_fetch_array($result50)) {
$langid=$myrow['id'];
$language=$myrow['language'];
$dir=$myrow['dir'];
?>

<?php
$sql51 = "SELECT * FROM infocategories WHERE insert_id='$insertid' AND lang_id='$langid'";
$result51 = mysql_query($sql51);
while ($myrow=mysql_fetch_array($result51)) {
$insert_id=$myrow['insert_id'];
$lang_id=$myrow['lang_id'];
$page=$myrow['page'];
$title=$myrow['title'];
$description=$myrow['description'];
$keywords=$myrow['keywords'];
$publish=$myrow['publish'];
$priority=$myrow['priority'];
$parent=$myrow['parent'];
?>

<?php 
if  (isset($_POST['submit'])) {

$page = mysql_real_escape_string(stripslashes($_REQUEST['page']));
$titlelang = mysql_real_escape_string(stripslashes($_REQUEST["title$langid"]));
$descriptionlang = mysql_real_escape_string(stripslashes($_REQUEST["description$langid"]));
$keywordslang = mysql_real_escape_string(stripslashes($_REQUEST["keywords$langid"]));
$title = mysql_real_escape_string(stripslashes($_REQUEST["title$langid"]));
$description = mysql_real_escape_string(stripslashes($_REQUEST["description$langid"]));
$keywords = mysql_real_escape_string(stripslashes($_REQUEST["keywords$langid"]));
$publish = mysql_real_escape_string(stripslashes($_REQUEST['publish']));	  
$priority = mysql_real_escape_string(stripslashes($_REQUEST['priority']));
$level = mysql_real_escape_string(stripslashes($_REQUEST['level']));
$parent = mysql_real_escape_string(stripslashes($_REQUEST['parent']));

$sql="UPDATE infocategories SET page='$page', title='$titlelang', description='$descriptionlang', keywords='$keywordslang', publish='$publish', priority='$priority', level='$level', parent='$parent'  WHERE insert_id='$insertid' AND lang_id='$langid'";
$result = mysql_query($sql);

} ?>

  <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td width="20"><img src="img/<?php echo $dir ?>.png" width="16" height="16" alt=""></td> 
      <td width="200">Τίτλος 
        </td>
      <td> 
        <input type="text" name="title<?php echo $langid ?>" value="<?php echo $title ?>" size="100" class="forms">
        </td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir ?>.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή</td>
      <td><textarea name="description<?php echo $langid ?>" cols="100" rows="5" class="forms"><?php echo $description ?></textarea></td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir ?>.png" width="16" height="16" alt=""></td>
      <td>Keywords </td>
      <td><textarea name="keywords<?php echo $langid ?>" cols="100" rows="5" class="forms"><?php echo $keywords ?></textarea></td>
    </tr>
    </table>

<?php } ?>
<?php } ?>

<!--NEW LANG -->

<?php
$sql52 = "SELECT * FROM lang WHERE id NOT IN (SELECT lang_id FROM infocategories WHERE insert_id='$insertid') AND active=1 ORDER BY id";
$result52 = mysql_query($sql52);
$nu_row52 = mysql_num_rows($result52);
while ($myrow=mysql_fetch_array($result52)) {
$langid2=$myrow['id'];
$language2=$myrow['language'];
$dir2=$myrow['dir'];
?>
<?php if  ($nu_row52>0) { ?>

  <table width="100%" border="0" cellspacing="0" cellpadding="4">
    <tr>
      <td width="20"><img src="img/<?php echo $dir2 ?>.png" width="16" height="16" alt=""></td> 
      <td width="200">Τίτλος 
        </td>
      <td> 
        <input type="text" name="title<?php echo $langid2 ?>" size="100" class="forms">
        </td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir2 ?>.png" width="16" height="16" alt=""></td>
      <td>Περιγραφή </td>
      <td><textarea name="description<?php echo $langid2 ?>" cols="100" rows="5" class="forms"></textarea></td>
    </tr>
    <tr>
      <td><img src="img/<?php echo $dir2 ?>.png" width="16" height="16" alt=""></td>
      <td>Keywords </td>
      <td><textarea name="keywords<?php echo $langid2 ?>" cols="100" rows="5" class="forms"></textarea></td>
    </tr>
    </table>
    
<?php 
if  (isset($_POST['submit'])) {
$titlelang2 = mysql_real_escape_string(stripslashes($_REQUEST["title$langid2"]));
$descriptionlang2 = mysql_real_escape_string(stripslashes($_REQUEST["description$langid2"]));
$keywordslang2 = mysql_real_escape_string(stripslashes($_REQUEST["keywords$langid2"]));

$sql = "INSERT INTO infocategories (insert_id, lang_id, page, title, description, keywords, publish, priority, level, parent) VALUES ('$insert_id', '$langid2', '$page', '$titlelang2', '$descriptionlang2', '$keywordslang2',  '$publish', '$priority', '$level', '$parent')";
$result = mysql_query($sql);
?>


<meta http-equiv="refresh" content="0;URL=edit-infocategory.php?id=<?php echo $insertid ?>">    
    
<?php } ?>
<?php } ?>
<?php } ?>

<!--END NEW LANG -->

<table width="100%" border="0" cellspacing="0" cellpadding="4">
<tr>
      <td>&nbsp;</td>
      <td>Page</td>
      <td><input name="page" type="text" class="forms" value="<?php echo $page ?>" size="100"></td>
    </tr>
    <tr>
      <td width="20">&nbsp;</td> 
      <td width="200">Εικόνα</td>
      <td><input type="hidden" name="max_file_size" value="600000">
        <input name="upload" type="file" size="50" class="forms">   
        </td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td>Δημοσίευση στο site?</td>
      <td><select name="publish" class="forms">
        <?php if ($publish=="yes") { ?>
        <option value="yes" selected>yes</option>
        <option value="no">no</option>
        <?php }else{?> 
        <option value="no" selected>no</option>
        <option value="yes">yes</option>
        <?php } ?>
        </select></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Αριθμός προτεραιότητας</td>
      <td><input type="text" name="priority" size="20" maxlength="11" value="<?php echo $priority ?>" class="forms"></td>
    </tr>
    </table>
 
 <?php
	    $uploadid=$insertid;
        $uploaddir = '../flash/info/'; 
		$filetype = '.jpg'; 
		$uploadname = $uploadid . $filetype; 

        if (isset($_POST['submit'])){ 
        if( $_FILES['upload']['tmp_name'] != "" ){
		
        $dest = $uploaddir . $uploadname; 
       if (copy ( $_FILES['upload']['tmp_name'], $dest )){ 
                } }
 
		}?>
   
  <div align="center" style="padding:5px">
   <input type="submit" name="submit" value="Καταχώρηση" class="button">
   <input type="reset" name="reset" value="Επαναφορά" class="button">  
   </div>
   
</form>  

</div>
<div align="right"><a href="all-infocategories.php" class="links">μεταφορά στην Λίστα</a></div></td>
  </tr>
</table>
<div align="center"><img src="../flash/info/<?php echo $insertid ?>.jpg" width="150"> </div>
<?php include 'menudown.php';?>

</body>
</html>
