<?
$bq = mysql_query("SELECT * FROM `chyby` WHERE `id_name` = '".mysql_real_escape_string(addslashes($_GET["pl"]))."'");
$b  = mysql_fetch_array($bq);
if(isset($_GET["status"]) &&
   prihlaseny() == true   &&
   is_numeric($_GET["status"])
  ) {
  mysql_query("Update `chyby` Set `status`='".$_GET["status"]."' WHERE `id`='".$b["id"]."'");
  echo '<script>
window.location.href="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/chyba/'.$_GET["pl"].'/";
</script>';
  }
if(isset($_GET["smazat"]) && prihlaseny() == true)
  {
  mysql_query("delete from `diskuze` where `entry`='".$b["id"]."'");
  mysql_query("delete from `chyby` where `id_name`='".$b["id_name"]."'");
  echo '<script>
window.location.href="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/chyby/";
</script>';
 
  }  
 
if(mysql_num_rows($bq)==1) {
?>
<div id="perex" class="box">
<h1><? echo getTyp($b["typ"])." ".htmlspecialchars($b["jmeno"]); ?></h1>
<? 
if(prihlaseny()==true) {
echo "<b>Administrace:</b> <a href='http://".$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10)."/index.php?strana=chyba&pl=".$b["id_name"]."&status=3'>Vyřešené</a> | <a href='http://".$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10)."/index.php?strana=chyba&pl=".$b["id_name"]."&status=2'>Řeší se</a> | <a href='http://".$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10)."/index.php?strana=chyba&pl=".$b["id_name"]."&status=1'>Čekající na schválení</a> | <a href='http://".$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10)."/index.php?strana=chyba&pl=".$b["id_name"]."&status=4'>Nevyřešené</a> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href='http://".$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10)."/index.php?strana=chyba&pl=".$b["id_name"]."&smazat'>Smazat</a> 
";
}
?>
<table style="border : 1px solid #94dbea;" width='100%' cellspacing='0' cellpadding='0'><tr><td height='8'>
<tr>
<td style="" align='center' width='150' rowspan='5' class='tbl2'>
<?
if($b["screenshot"] == 0) {
echo '<img src="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/images/none.png">';
} else 
{

if(file_exists("screenshots/".$b["screenshot"].".jpg")) {
echo '<a href="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/screenshots/'.$b["screenshot"].'.jpg" rel="lightbox" title="Velikost: '.velikost('screenshots/'.$b["screenshot"].'.jpg').'"><img src="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/images/jpg.png"></a>';
}

if(file_exists("screenshots/".$b["screenshot"].".png")) {
echo '<a href="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/screenshots/'.$b["screenshot"].'.png" rel="lightbox" title="Velikost: '.velikost('screenshots/'.$b["screenshot"].'.png').'"><img src="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/images/png.png"></a>';
}
if(file_exists("screenshots/".$b["screenshot"].".gif")) {
echo '<a href="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/screenshots/'.$b["screenshot"].'.gif" rel="lightbox" title="Velikost: '.velikost('screenshots/'.$b["screenshot"].'.gif').'"><img src="http://'.$_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10).'/images/gif.png"></a>';
}

}
?>
</td>
<td width='1%' style="border-bottom : 1px dotted #94dbea;" class='tbl1' style='white-space:nowrap'><b>Poslal:</b></td>
<td class='tbl1' style="border-bottom : 1px dotted #94dbea;"><? echo htmlspecialchars($b["postava"]); if(prihlaseny() == true) { echo " - ".$b["mail"]; } ?></td>
</tr>
<tr>
<td width='1%' style="border-bottom : 1px dotted #94dbea;" class='tbl2' style='white-space:nowrap'><b>Typ</b></td>
<td class='tbl2' style="border-bottom : 1px dotted #94dbea;"><? echo getTyp($b["typ"]); ?></td>
</tr>
<tr>
<td width='1%' style="border-bottom : 1px dotted #94dbea;" class='tbl1' style='white-space:nowrap'><b>Frakce:</b></td>
<td class='tbl1' style="border-bottom : 1px dotted #94dbea;"><? echo getFrakce($b["frakce"]); ?></td>

</tr>
<tr>
<td width='1%' style="border-bottom : 1px dotted #94dbea;" class='tbl2' style='white-space:nowrap'><b>Posláno:</b></td>
<td class='tbl2' style="border-bottom : 1px dotted #94dbea;"><? echo date("d.m.Y H:i:s",$b["datum"]); ?></td>
</tr>
<tr>
<td width='1%' style="border-bottom : 1px dotted #94dbea;" class='tbl1' style='white-space:nowrap'><b>Status:</b></td>
<td class='tbl1' style="border-bottom : 1px dotted #94dbea;"><? echo getStatus($b["status"]); ?></td>
</tr>
</table>
<? echo nl2br(htmlspecialchars($b["prispevek"])); ?>
</div>

<?
if(isset($_POST["bgok"])) {
if(strlen($_POST["jmeno"])     >= 5)                 { $jmeno     = true; } else { $jmeno     = false; }
if(strlen($_POST["prispevek"]) >= 20)                { $prispevek = true; } else { $prispevek = false; }
if($_SESSION["captcha"]        == $_POST["captcha"]) { $captcha   = true; } else { $captcha   = false; }
if($jmeno == true && $prispevek == true && captcha == true) {
if(prihlaseny() == true) {
$prispeveek = "<font color=\'red\'>".mysql_real_escape_string($_POST["prispevek"])."</font>";
mysql_query("INSERT INTO `diskuze` (`entry`,`jmeno`,`prispevek`,`datum`,`ip`) VALUES ('".$b["id"]."','".mysql_real_escape_string(addslashes($_POST["jmeno"]))."','".$prispeveek."','".time()."','".$_SERVER["REMOTE_ADDR"]."')");
} else {
mysql_query("INSERT INTO `diskuze` (`entry`,`jmeno`,`prispevek`,`datum`,`ip`) VALUES ('".$b["id"]."','".mysql_real_escape_string(addslashes($_POST["jmeno"]))."','".htmlspecialchars(mysql_real_escape_string($_POST["prispevek"]))."','".time()."','".$_SERVER["REMOTE_ADDR"]."')");
}

echo mysql_error();

} else 
{
if($jmeno     == false)     { echo "&nbsp;&nbsp;<b>Jméno musí mít aspoň 5 znaků</b><br />";      }
if($prispevek == false)     { echo "&nbsp;&nbsp;<b>Příspevek musí mít aspoň 20 znaků</b><br />"; }
if($captcha   == false)     { echo "&nbsp;&nbsp;<b>Špatně opsaný ověřovací kód</b><br />";       }

}
}
$pq = mysql_query("SELECT * FROM `diskuze` WHERE `entry` = '".$b["id"]."'");
echo '<table style="width : 100%;">';
while($j = mysql_fetch_array($pq)) {
echo '

<tr><td style="border-bottom : 1px solid #94dbea;">
<a name="'.$j["id"].'"></a>
Poslal '.htmlspecialchars($j["jmeno"]).' | '.date("d.m.Y H:i:s",$j["datum"]).'
</td></tr>
<tr><td>'.nl2br($j["prispevek"]).'</td></tr>
<tr><td></td></tr>

';
}
?>
</table>
<h2>Přidat komentář</h2>
<form method="post" action="http://<? echo $_SERVER["SERVER_NAME"].substr($_SERVER["PHP_SELF"], 0, -10);?>/chyba/<? echo $b["id_name"]; ?>/">
<table>
<tr><td>Jméno postavy ve hře</td><td><input type="text" name="jmeno"></td><td><font color="#666666">Jméno postavy ve hře</font></td></tr>
<tr><td>Ověřovací kód</td><td><input type="text" name="captcha"></td><td><font color="#666666">Opište pouze <b>černé</b> znaky</font></td></tr>
<tr><td></td><td><img style="padding-top : 5px;"src="../../captcha.php"></td><td></td></tr>
</table>
<table>
&nbsp;&nbsp;<textarea name="prispevek" onkeydown=textCounter(this.form.prispevek,this.form.descriptionleft,1000); onkeyup=textCounter(this.form.prispevek,this.form.descriptionleft,1000); cols="80" style="" maxlength="1000" rows="4"></textarea>
&nbsp;&nbsp;Ještě zbýva <INPUT style='BORDER-RIGHT: 0px; BORDER-TOP:0px;BORDER-LEFT:0px; BORDER-BOTTOM:0px; WIDTH: 35px;	FONT-SIZE: 15px; COLOR: #000; FONT-FAMILY:Arial' maxLength=3 name=descriptionleft readOnly size=1 tabIndex=1000 value=1000> 
</table>
&nbsp;&nbsp;<input type="submit" name="bgok" value="Odeslat"> &nbsp;&nbsp; <input type="reset" name="bgok" value="Resetovat">

<? } else { ?>
<h2>Chyba se nenacházi v databázi</h2>
<? } ?>