<!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
$id = mysql_real_escape_string(stripslashes($_REQUEST['id']));
$room_id = mysql_real_escape_string(stripslashes($_REQUEST['room_id']));
$name = mysql_real_escape_string(stripslashes($_REQUEST['name']));
$priority = mysql_real_escape_string(stripslashes($_REQUEST['priority']));	  

if  (isset($_POST['submit'])) {
	$sql="UPDATE panoramas SET name='$name', priority='$priority' WHERE id='$id'";
	$result = mysql_query($sql);	
?>


                    <?php 
		 $newid = $id;
        $uploaddir = '../panoramas/'; 
		$uploaddir2 = '../panoramas/scene/';
		$uploadid = $newid; 
		$filetype = '.jpg'; 
		$uploadname = $newid . $filetype; 
		$filetype2 = '.jpe'; 
		$uploadname2 = $newid . $filetype2; 
		
		$dest = $uploaddir . $uploadname; 
		$dest2 = $uploaddir2 . $uploadname2;

        if (isset($_POST['submit'])){ 
		
		if( $_FILES['upload']['tmp_name'] != "" ){
		if (copy ( $_FILES['upload']['tmp_name'], $dest )){ 
                } }

        if( $_FILES['upload2']['tmp_name'] != "" ){
		if (copy ( $_FILES['upload2']['tmp_name'], $dest2 )){ 
                } }
				
?>

<?php } ?> 



<?php
 	$stringData= "<";
	$stringData=$stringData."?xml version=\"1.0\" encoding=\"UTF-8\"";
		$stringData=$stringData."?";
			$stringData=$stringData.">";
	$stringData=$stringData."
	<Root>
  <MainWindow>
    <className>TWMainWindow</className>
     <name>MainWindow</name>
    <bgColor>255,255,255</bgColor>
    <Image>
      <className>TWStillImage</className>
      <name>Image1</name>
      <zOrder>0</zOrder>
      <bounds>0,402,700,18</bounds>
      <sizeMode>fill Size</sizeMode>
      <image />
    </Image>
    <Button>
      <className>TWButton</className>
      <name>Button1</name>
      <zOrder>2</zOrder>
      <bounds>0,402,18,18</bounds>
      <normalImg>images/autoleft1.gif</normalImg>
      <overImg>images/autoleft2.gif</overImg>
      <pressImg>images/autoleft3.gif</pressImg>
      <hint>images/hint_left.jpg</hint>
      <type>normal</type>
      <action>left(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button2</name>
      <zOrder>3</zOrder>
      <bounds>18,402,18,18</bounds>
      <normalImg>images/autoright1.gif</normalImg>
      <overImg>images/autoright2.gif</overImg>
      <pressImg>images/autoright3.gif</pressImg>
      <hint>images/hint_right.jpg</hint>
      <type>normal</type>
      <action>right(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button3</name>
      <zOrder>4</zOrder>
      <bounds>36,402,18,18</bounds>
      <normalImg>images/autoup1.gif</normalImg>
      <overImg>images/autoup2.gif</overImg>
      <pressImg>images/autoup3.gif</pressImg>
      <hint>images/hint_up.jpg</hint>
      <type>normal</type>
      <action>up(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button4</name>
      <zOrder>5</zOrder>
      <bounds>54,402,18,18</bounds>
      <normalImg>images/autodown1.gif</normalImg>
      <overImg>images/autodown2.gif</overImg>
      <pressImg>images/autodown3.gif</pressImg>
      <hint>images/hint_down.jpg</hint>
      <type>normal</type>
      <action>down(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button5</name>
      <zOrder>6</zOrder>
      <bounds>72,402,18,18</bounds>
      <normalImg>images/zoomin1.gif</normalImg>
      <overImg>images/zoomin2.gif</overImg>
      <pressImg>images/zoomin3.gif</pressImg>
      <hint>images/hint_zoomin.jpg</hint>
      <type>normal</type>
      <action>zoomin(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button6</name>
      <zOrder>7</zOrder>
      <bounds>90,402,18,18</bounds>
      <normalImg>images/zoomout1.gif</normalImg>
      <overImg>images/zoomout2.gif</overImg>
      <pressImg>images/zoomout3.gif</pressImg>
      <hint>images/hint_zoomout.jpg</hint>
      <type>normal</type>
      <action>zoomout(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button7</name>
      <zOrder>8</zOrder>
      <bounds>108,402,18,18</bounds>
      <normalImg>images/stop1.gif</normalImg>
      <overImg>images/stop2.gif</overImg>
      <pressImg>images/stop3.gif</pressImg>
      <hint>images/hint_st.jpg</hint>
      <type>normal</type>
      <action>stop()</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button8</name>
      <zOrder>9</zOrder>
      <bounds>126,402,18,18</bounds>
      <normalImg>images/reset1.gif</normalImg>
      <overImg>images/reset2.gif</overImg>
      <pressImg>images/reset3.gif</pressImg>
      <hint>images/hint_reset.jpg</hint>
      <type>normal</type>
      <action>reset()</action>
    </Button>
    <SceneViewer>
      <className>TWSceneViewer</className>
      <name>SceneViewer</name>
      <zOrder>1</zOrder>
      <bgColor>255,255,255</bgColor>
      <bounds>0,0,700,420</bounds>
    </SceneViewer>
  </MainWindow>
  <FullScreenbar>
    <className>TWFullScreenbar</className>
    <name>FSbar</name>
    <bgImg1>images/toolbar.gif</bgImg1>
    <Button>
      <className>TWButton</className>
      <name>Button1</name>
      <zOrder>2</zOrder>
      <bounds>0,0,18,18</bounds>
      <normalImg>images/autoleft1.gif</normalImg>
      <overImg>images/autoleft2.gif</overImg>
      <pressImg>images/autoleft3.gif</pressImg>
      <hint>images/hint_left.jpg</hint>
      <type>normal</type>
      <action>left(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button2</name>
      <zOrder>3</zOrder>
      <bounds>18,0,18,18</bounds>
      <normalImg>images/autoright1.gif</normalImg>
      <overImg>images/autoright2.gif</overImg>
      <pressImg>images/autoright3.gif</pressImg>
      <hint>images/hint_right.jpg</hint>
      <type>normal</type>
      <action>right(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button3</name>
      <zOrder>4</zOrder>
      <bounds>36,0,18,18</bounds>
      <normalImg>images/autoup1.gif</normalImg>
      <overImg>images/autoup2.gif</overImg>
      <pressImg>images/autoup3.gif</pressImg>
      <hint>images/hint_up.jpg</hint>
      <type>normal</type>
      <action>up(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button4</name>
      <zOrder>5</zOrder>
      <bounds>54,0,18,18</bounds>
      <normalImg>images/autodown1.gif</normalImg>
      <overImg>images/autodown2.gif</overImg>
      <pressImg>images/autodown3.gif</pressImg>
      <hint>images/hint_down.jpg</hint>
      <type>normal</type>
      <action>down(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button5</name>
      <zOrder>6</zOrder>
      <bounds>72,0,18,18</bounds>
      <normalImg>images/zoomin1.gif</normalImg>
      <overImg>images/zoomin2.gif</overImg>
      <pressImg>images/zoomin3.gif</pressImg>
      <hint>images/hint_zoomin.jpg</hint>
      <type>normal</type>
      <action>zoomin(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button6</name>
      <zOrder>7</zOrder>
      <bounds>90,0,18,18</bounds>
      <normalImg>images/zoomout1.gif</normalImg>
      <overImg>images/zoomout2.gif</overImg>
      <pressImg>images/zoomout3.gif</pressImg>
      <hint>images/hint_zoomout.jpg</hint>
      <type>normal</type>
      <action>zoomout(String SceneViewer, int 20)</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button7</name>
      <zOrder>8</zOrder>
      <bounds>108,0,18,18</bounds>
      <normalImg>images/stop1.gif</normalImg>
      <overImg>images/stop2.gif</overImg>
      <pressImg>images/stop3.gif</pressImg>
      <hint>images/hint_st.jpg</hint>
      <type>normal</type>
      <action>stop()</action>
    </Button>
    <Button>
      <className>TWButton</className>
      <name>Button8</name>
      <zOrder>9</zOrder>
      <bounds>126,0,18,18</bounds>
      <normalImg>images/reset1.gif</normalImg>
      <overImg>images/reset2.gif</overImg>
      <pressImg>images/reset3.gif</pressImg>
      <hint>images/hint_reset.jpg</hint>
      <type>normal</type>
      <action>reset()</action>
    </Button>
  </FullScreenbar>
  <Scene>
    <className>SceneNode</className>
    <name>".$uploadid."</name>
    <type>Spherical</type>
    <effectType>FadeInFadeOut</effectType>
    <effectTime>2</effectTime>
    <pan>0</pan>
    <tilt>0</tilt>
    <fov>75</fov>
    <panMax>180</panMax>
    <panMin>-180</panMin>
    <tiltMax>90</tiltMax>
    <tiltMin>-90</tiltMin>
    <fovMax>150</fovMax>
    <fovMin>30</fovMin>
    <speed>20</speed>
    <hfov>360</hfov>
    <aboveFov>90</aboveFov>
    <path>/panoramas/scene/".$uploadid.".jpe</path>
  </Scene>
</Root>  ";
  ?>
      <?php
  $ourFileName = "../panoramas/".$uploadid.".txt";
$ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
fwrite($ourFileHandle, $stringData);
fclose($ourFileHandle);


?>
	
<meta http-equiv="refresh" content="0;URL=edit-panorama.php?id=<?php echo $id ?>">
<?php
} else {	
			$result = mysql_query("SELECT * FROM panoramas WHERE id='$id'",$dbh);
			$myrow=mysql_fetch_array($result); 
			$room_id=$myrow['room_id'];
			$id=$myrow['id'];
			$name=$myrow['name'];
			$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">
    <tr>
      <td width="20">&nbsp;</td> 
      <td width="200">Τίτλος 
        </td>
      <td> 
        <input type="text" name="name" size="100" value="<?php echo $name ?>" class="forms">
        </td>
    </tr>
    <tr>
      <td>&nbsp;</td> 
      <td>Εικόνα</td>
      <td>
        <input type="hidden" name="max_file_size" value="5000000">
        <input name="upload" type="file" size="50" class="forms">   
        </td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td>Αρχείο .jpe</td>
      <td><input name="upload2" type="file" size="50" class="forms"></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-panoramas.php" class="links">μεταφορά στην Λίστα</a></div></td>
  </tr>
</table><?php include 'menudown.php';?>
<?php } ?>
</body>
</html>
