<!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 text="#000000" style="margin:0">
      <?php
$id = mysql_real_escape_string(stripslashes($_REQUEST['id']));
$category_id = mysql_real_escape_string(stripslashes($_REQUEST['category_id']));	  
$name = mysql_real_escape_string(stripslashes($_REQUEST['name']));
$name_en = mysql_real_escape_string(stripslashes($_REQUEST['name_en']));
$name_de = mysql_real_escape_string(stripslashes($_REQUEST['name_de']));
$name_fr = mysql_real_escape_string(stripslashes($_REQUEST['name_fr']));
$name_it = mysql_real_escape_string(stripslashes($_REQUEST['name_it']));
$name_es = mysql_real_escape_string(stripslashes($_REQUEST['name_es']));
$name_ru = mysql_real_escape_string(stripslashes($_REQUEST['name_ru']));
$name_zh = mysql_real_escape_string(stripslashes($_REQUEST['name_zh']));
$description = mysql_real_escape_string(stripslashes($_REQUEST['description']));
$description_en = mysql_real_escape_string(stripslashes($_REQUEST['description_en']));
$description_de = mysql_real_escape_string(stripslashes($_REQUEST['description_de']));
$description_fr = mysql_real_escape_string(stripslashes($_REQUEST['description_fr']));
$description_it = mysql_real_escape_string(stripslashes($_REQUEST['description_it']));
$description_es = mysql_real_escape_string(stripslashes($_REQUEST['description_es']));
$description_ru = mysql_real_escape_string(stripslashes($_REQUEST['description_ru']));
$description_zh = mysql_real_escape_string(stripslashes($_REQUEST['description_zh']));
$script = mysql_real_escape_string(stripslashes($_REQUEST['script']));
$image = mysql_real_escape_string(stripslashes($_REQUEST['image']));
$file = mysql_real_escape_string(stripslashes($_REQUEST['file']));
$publish = mysql_real_escape_string(stripslashes($_REQUEST['publish']));	  
$priority = mysql_real_escape_string(stripslashes($_REQUEST['priority']));	  

if  (isset($_POST['submit'])) {
	$sql="UPDATE info SET category_id='$category_id', name='$name', name_en='$name_en', name_de='$name_de', name_fr='$name_fr', name_it='$name_it', name_es='$name_es', name_ru='$name_ru', name_zh='$name_zh', description='$description', description_en='$description_en', description_de='$description_de',  description_fr='$description_fr',  description_it='$description_it',  description_es='$description_es',  description_ru='$description_ru', description_zh='$description_zh', script='$script', image='$image', file='$file', publish='$publish', priority='$priority' WHERE id='$id'";
	$result = mysql_query($sql);	
?>

                    <?php 
        $newid = $id;
		$uploaddir = '../images/info/'; 
		$uploadid = $newid; 
		$filetype = '.jpg'; 
		$uploadname = $newid . $filetype; 
		

        if (isset($_POST['submit'])){ 
        if( $_FILES['upload']['tmp_name'] != "" ){
		
        $dest = $uploaddir . $uploadname; 
        if (copy ( $_FILES['upload']['tmp_name'], $dest )){ 
		
	function createthumb($name,$filename,$new_w,$new_h){
	$system=explode('.',$name);
	if (preg_match('/jpg|jpeg/',$system[3])){
		$src_img=imagecreatefromjpeg($name);
	}
	if (preg_match('/png/',$system[3])){
		$src_img=imagecreatefrompng($name);
	}
	
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
if ($old_x > $old_y) {
	$thumb_w=$new_w;
	$thumb_h=$old_y*($new_h/$old_x);
}
if ($old_x < $old_y) {
	//$thumb_w=$old_x*($new_w/$old_y);
	//$thumb_h=$new_h;
	
	$thumb_w=$new_w;
	$thumb_h=$old_y*($new_h/$old_x);
	
}
if ($old_x == $old_y) {
	$thumb_w=$new_w;
	$thumb_h=$new_h;
}
$dst_img=ImageCreateTrueColor($thumb_w,$thumb_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$thumb_w,$thumb_h,$old_x,$old_y); 

	
if (preg_match("/png/",$system[3]))
{
	imagepng($dst_img,$filename); 
} else {
	imagejpeg($dst_img,$filename); 
}
imagedestroy($dst_img); 
imagedestroy($src_img); 
}

			createthumb('../images/info/'.$uploadid.'.jpg','../images/info/thumbs/'.$uploadid.'.jpg',150,150);
                } 
 }
?>
<?php } ?>
 <?php 
		$newid = $id;
        $uploaddir1 = '../images/info/files/'; 
		$uploadid1 = $newid; 
		$filetype1 = $_REQUEST['file']; 
		$uploadname1 = $newid . $filetype1; 
		
if (isset($_POST['submit'])){ 
        if( $_FILES['upload1']['tmp_name'] != "" ){ 
        
		
        $dest = $uploaddir1 . $uploadname1; 
       if (copy ( $_FILES['upload1']['tmp_name'], $dest )){ 
                } }
?>

<?php } ?>

<meta http-equiv="refresh" content="0;URL=edit-info.php?id=<?php echo $id ?>">
<?php
} else {	
			$result = mysql_query("SELECT * FROM info WHERE id='$id'",$dbh);
			$myrow=mysql_fetch_array($result); 
			$id=$myrow['id'];
			$category_id=$myrow['category_id'];
			$name=$myrow['name'];
			$name_en=$myrow['name_en'];
			$name_de=$myrow['name_de'];
			$name_fr=$myrow['name_fr'];
            $name_it=$myrow['name_it'];
            $name_es=$myrow['name_es'];
            $name_ru=$myrow['name_ru'];
			$name_zh=$myrow['name_zh'];
			$description=$myrow['description'];
			$description_en=$myrow['description_en'];
			$description_de=$myrow['description_de'];
            $description_fr=$myrow['description_fr'];
            $description_it=$myrow['description_it'];
            $description_es=$myrow['description_es'];
            $description_ru=$myrow['description_ru'];
			$description_zh=$myrow['description_zh'];
			$script=$myrow['script'];
			$image=$myrow['image'];
			$file=$myrow['file'];
			$publish=$myrow['publish'];
			$priority=$myrow['priority'];

?>

<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">

<form name="forma" method="post" action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" enctype="multipart/form-data">
  <input type="hidden" name="id" value="<?php echo $id ?>">
  <table width="100%" border="0" cellspacing="0" cellpadding="4" class="text">
    <tr>
      <td width="20">&nbsp;</td> 
      <td width="200">Ενότητα 
        </td>
      <td> 
        <select name="category_id" class="forms">
          <?php
			$sql = "SELECT * FROM infocategories ORDER BY priority";
			$result = mysql_query($sql);
			while ($myrow=mysql_fetch_array($result)) {
				$catid1=$myrow['id'];
				$category1=$myrow['category'];
?>
          <?php
	if ($catid1 == $category_id ) {
?>
          <option value="<?php echo $catid1 ?>" selected> 
            <?php echo $category1 ?>
            <?php } else { ?>
            <option value="<?php echo $catid1 ?>"> 
            <?php echo $category1 ?>
            </option>
          <?php 
				}
				}
?>
          </select>
        </td>
      </tr>
     <?php if ($lang1==1) { ?>
    <tr>
      <td width="20"><img src="img/lang1.png" width="16" height="16" alt=""></td> 
      <td width="200">Τίτλος 
        </td>
      <td> 
        <input type="text" name="name" size="100" value="<?php echo $name ?>" class="forms">
        </td>
    </tr>
    <?php } ?>
    <?php if ($lang2==1) { ?>
    <tr>
      <td><img src="img/lang2.png" width="16" height="16" alt=""></td> 
      <td>Τίτλος </td>
      <td> 
        <input type="text" name="name_en" size="100" value="<?php echo $name_en ?>" class="forms">
        </td>
      </tr>
      <?php } ?>
    <?php if ($lang3==1) { ?>
    <tr>
      <td><img src="img/lang3.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="name_de" size="100" value="<?php echo $name_de ?>" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang4==1) { ?>
    <tr>
      <td><img src="img/lang4.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="name_fr" size="100" value="<?php echo $name_fr ?>" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang5==1) { ?>
    <tr>
      <td><img src="img/lang5.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="name_it" size="100" value="<?php echo $name_it ?>" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang6==1) { ?>
    <tr>
      <td><img src="img/lang6.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="name_es" size="100" value="<?php echo $name_es ?>" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang7==1) { ?>
    <tr>
      <td><img src="img/lang7.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="name_ru" size="100" value="<?php echo $name_ru ?>" class="forms"></td>
    </tr>
      <?php } ?>
     <?php if ($lang8==1) { ?>
    <tr>
      <td><img src="img/lang8.png" width="16" height="16" alt=""></td>
      <td>Τίτλος </td>
      <td><input type="text" name="name_zh" size="100" value="<?php echo $name_zh ?>" class="forms"></td>
    </tr>
      <?php } ?>
    <?php if ($lang1==1) { ?>
    <tr>
      <td><img src="img/lang1.png" width="16" height="16" alt=""></td> 
      <td>Κείμενο </td>
      <td> 
        <textarea name="description" rows="10" class="mceEditor"><?php echo $description ?></textarea>
        </td>
    </tr>
      <?php } ?>
    <?php if ($lang2==1) { ?>
    <tr>
      <td><img src="img/lang2.png" width="16" height="16" alt=""></td> 
      <td>Κείμενο </td>
      <td> 
        <textarea name="description_en" rows="10" class="mceEditor"><?php echo $description_en ?></textarea>
        </td>
      </tr>
      <?php } ?>
    <?php if ($lang3==1) { ?>
    <tr>
      <td><img src="img/lang3.png" width="16" height="16" alt=""></td>
      <td>Κείμενο </td>
      <td><textarea name="description_de" rows="10" class="mceEditor"><?php echo $description_de ?></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang4==1) { ?>
    <tr>
      <td><img src="img/lang4.png" width="16" height="16" alt=""></td>
      <td>Κείμενο </td>
      <td><textarea name="description_fr" rows="10" class="mceEditor"><?php echo $description_fr ?></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang5==1) { ?>
    <tr>
      <td><img src="img/lang5.png" width="16" height="16" alt=""></td>
      <td>Κείμενο </td>
      <td><textarea name="description_it" rows="10" class="mceEditor"><?php echo $description_it ?></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang6==1) { ?>
    <tr>
      <td><img src="img/lang6.png" width="16" height="16" alt=""></td>
      <td>Κείμενο </td>
      <td><textarea name="description_es" rows="10" class="mceEditor"><?php echo $description_es ?></textarea></td>
    </tr>
      <?php } ?>
    <?php if ($lang7==1) { ?>
    <tr>
      <td><img src="img/lang7.png" width="16" height="16" alt=""></td>
      <td>Κείμενο </td>
      <td><textarea name="description_ru" rows="10" class="mceEditor"><?php echo $description_ru ?></textarea></td>
    </tr>
     <?php } ?>
     <?php if ($lang8==1) { ?>
    <tr>
      <td><img src="img/lang8.png" width="16" height="16" alt=""></td>
      <td>Κείμενο </td>
      <td><textarea name="description_zh" rows="10" class="mceEditor"><?php echo $description_zh ?></textarea></td>
    </tr>
     <?php } ?> 
    <tr>
      <td>&nbsp;</td>
      <td>Κώδικας</td>
      <td><textarea name="script" cols="100" rows="6" class="forms"><?php echo $script ?></textarea></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Εικόνα</td>
      <td><select name="image" class="forms">
        <?php if ($image==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>
        <input type="hidden" name="max_file_size" value="4000000">
        <input name="upload" type="file" size="50" class="forms"></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Αρχείο</td>
      <td>Τύπος
        <select name="file" class="forms">
          <option value="<?php echo $file ?>" selected><?php echo $file ?></option>
          <option value="">KANENA</option>
          <option value=".doc">doc</option>
          <option value=".docx">docx</option>
          <option value=".pdf">pdf</option>
          <option value=".ppt">powerpoint</option>
          <option value=".pptx">powerpoint-x</option>
          <option value=".wmv">video wmv</option>
        </select>
        <input name="upload1" 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>

  <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-info.php?catid=<?php echo $category_id ?>" class="links">μεταφορά στην Λίστα</a></div>
<?php if ($image==yes) { ?>
<div align="center"><img src="../images/info/thumbs/<?php echo $id ?>.jpg" width="150"> </div>
<?php } ?>
    </td>
  </tr>
</table>

<?php include 'menudown.php';?>
<?php } ?>
</body>
</html>
