<?php
  ///////////////////////////////////////////////////
  //2010 (C)
  //Карпухин Павел
  ///////////////////////////////////////////////////
  require_once "utils/chlang_osn.php";

  $title = $TEXT['book-otziv-edit2'];
  $button = $TEXT['btn_save'];
  $action = "film-edit_otz.php";

  require_once "config.php";
  require_once "utils/functions.php";
  require_once "utils/top_film.php";

  if($result2['administrator'] == 0 && $result2['user'] == 0) {puterror2($result2['skin'],$TEXT['error-loginform2']); require_once "utils/bottom_film.php"; exit();}

  if(empty($_GET['film_id'])) {puterror2($result2['skin'],$TEXT['error-film5']); require_once "utils/bottom_film.php"; exit();}
  if(strlen($_GET['film_id'])>255) {puterror2($result2['skin'],$TEXT['error-film6']); require_once "utils/bottom_film.php"; exit();}
  $_GET['film_id'] = rep($_GET['film_id']);
?>
<form name='film' enctype='multipart/form-data' action=<?php echo $action; ?> method=post>
<?php
$query_iskh = "SELECT film_name, photo_film, autors FROM tbl_film WHERE film_id = '".$_GET['film_id']."' ";
 $result_iskh = mysqli_query($dbcnx,$query_iskh);
  if(!$result_iskh) {puterror2($result2['skin'],$TEXT['error-tbl3']); require_once "utils/bottom_film.php"; exit();}
     $result_iskh2 = mysqli_fetch_array($result_iskh);
     $autors = $result_iskh2['autors'];

      $sm = preg_replace("/\.\.+./","",$result_iskh2['photo_film']);
      if(!empty($result_iskh2['photo_film']) && file_exists($sm)) {$result_image = "<img alt='".$TEXT['global-alt']."' src='".$sm."' />";}
        else {$result_image =  "<img alt='".$TEXT['global-alt']."' align='top' src='skins/".$result2['skin']."/nophoto.png' />";}

      $query_otziv = "SELECT * FROM tbl_otziv WHERE book_id = '".$_GET['film_id']."' AND login_id = '".$result2['login_id']."'";
        $result_otz = mysqli_query($dbcnx,$query_otziv);
          if(!$result_otz) {puterror2($result2['skin'],$TEXT['error-tbl22']); require_once "utils/bottom_film.php"; exit();}
          $result_otziv = mysqli_fetch_array($result_otz);
          $film_ocenka = $result_otziv['usr_rating'];

?>
<table align="center" width="98%" border="0">
    <tr><td class="zagolovok">&nbsp;<?php echo rep_back($result_iskh2['film_name']); ?>&nbsp;<span class="opis">&#040;<?php echo $autors; ?>&#041;</span></td></tr>
</table>
<hr width="98%" />
<table align="center" width="98%" border="0">
<tr>
<td width="5%" valign="top">
 <table align="left" border="0" width="100%">
  <tr><td><?php echo $result_image; ?></td></tr>
 </table>
</td>
<td width="65%" valign="top" align="right">
<fieldset>
 <legend align="left" title="<?php echo $TEXT['book-otziv-add2']; ?>"><?php echo $TEXT['film-otziv']; ?></legend>
<table align="left" width="100%" border="0">
<tr><td  class="inform"><?php echo $TEXT['book-otziv']; ?>:</td><td><textarea class="input" cols="85" rows="3" name=otziv ><?php echo $result_otziv['otziv']; ?></textarea></td></tr>
<tr><td  class="inform"><?php echo $TEXT['book-ocenka']; ?>:</td><td>
 <select name=film_ocenka>
  <option value=1 <?php if ($film_ocenka == 1) {echo "selected";} ?>><?php echo $TEXT['book-ocenka1']; ?>
  <option value=2 <?php if ($film_ocenka == 2) {echo "selected";} ?>><?php echo $TEXT['book-ocenka2']; ?>
  <option value=3 <?php if ($film_ocenka == 3) {echo "selected";} ?>><?php echo $TEXT['book-ocenka3']; ?>
  <option value=4 <?php if ($film_ocenka == 4) {echo "selected";} ?>><?php echo $TEXT['book-ocenka4']; ?>
  <option value=5 <?php if ($film_ocenka == 5) {echo "selected";} ?>><?php echo $TEXT['book-ocenka5']; ?>
 </select>
</td></tr>
<tr><td  class="inform"><?php echo $TEXT['delete-new']; ?>:</td><td><input type=checkbox name=delotz /></td></tr>
</table>
</fieldset>
<table align="left" width="100%" border="0">
<tr><td>
<input class="button2" type=submit value='<?php echo $button; ?>' />
<input type=hidden name=film_id value='<?php echo $_GET['film_id']; ?>' />
<input type=hidden name=otz_id value='<?php echo $result_otziv['otz_id']; ?>' />
</td></tr>
</table>
</td></tr>
</table>
</form>
<?php
  require_once "utils/bottom_film.php";
?>