<?
session_start();
include 'cnn.php';
@$login = $_SESSION['login'];
@$senha = $_SESSION['senha'];
if(!isset($_SESSION['login'])) { echo "<strong>Para acessar essa pagina é preciso esta logado</strong>"; }
else{
$vip=mssql_fetch_row(mssql_query("select vip from memb_info where memb___id='".$login."'"));
if($vip[0] == 0) { echo "<strong>Para acessar essa pagina &eacute; preciso ser Silver Vip</strong>"; }
else{
?>
<?
$id = $_GET['id'];
$msg = $_POST['msg'];
$char = $_POST['char'];
	
$PegaTicket = mssql_query("SELECT titulo,id,name,assunto,msg,status,login,data FROM site_ticket WHERE Id='".$id."'");
$Exibe = mssql_fetch_row($PegaTicket);

$pegafoto = mssql_query("SELECT foto FROM Character WHERE Name='".$Exibe[2]."'");
$foto = mssql_fetch_row($pegafoto);

$Chars = mssql_query("select name from character where accountid='".$login."'");
$Char=mssql_fetch_row($Chars); {

if ($Exibe[5] == 0) { $status = "<form name='form1' method='post' action=''>
<div class=\"quadros\">
  <label>Responder ticket</label>
  <label>Escolha o char para responder o ticket:</label>
<select name=\"char\" id=\"char\">
		echo '<option value=$Char[0]>$Char[0]</option>';
        }
		</select>
		<br />    
  <textarea name=\"msg\" id=\"msg\"></textarea>
<br />
<br /> 
  <input name=\"prossegue\" type=\"submit\" class=\"submit\" id=\"prossegue\" value=\"Responder\">
  </div>
  </form>
<br>
N&atilde;o use a tecla Enter nen simbolos especiais, pois ser&aacute; acuso de inject. "; }
if ($Exibe[5] == 1) { $status = "<script>alert('O administrador fechou este ticket, se o suporte nao tenha lhe ajudado, abra outro ticket.'); 
location='javascript:history.back()'</script>"; }
?>





  <h1>Visualizando ticket - Assunto:
  <?=$Exibe[3]?></h1>
<div class="quadros">
<table width=100%>
<tr>
<td align="center" bgcolor="#CCCCCC"><strong><?=$Exibe[2]?></strong></td>
<td align="right" bgcolor="#CCCCCC">Postado em: <?=$Exibe[7]?></td>
</tr>
<tr>
<td width=105 height=135 align="center" bgcolor="#EDEBDC"><img src="images/logo.png" width=100 height=130></td>
<td height="112" valign="top" bgcolor="#E5E5E5" align="center"><strong><?=$Exibe[4]?></strong></tr>
</table>
<br />
<br />
<?
$coment = mssql_query("SELECT name,data,msg,id FROM site_ticket_res WHERE titulo='".$Exibe[0]."'");
for($i=0;$i<mssql_num_rows($coment);$i++) {
$rank = $i+1;
$res = mssql_fetch_row($coment);

$pegafoto2 = mssql_query("SELECT foto FROM Character WHERE Name='".$res[0]."'");
$foto2 = mssql_fetch_row($pegafoto2);
?>
<table width=100%>
<tr>
<td align="center" bgcolor="#CCCCCC"><strong><?=$res[0]?></strong></td>
<td align="right" bgcolor="#CCCCCC">Postado em: <?=$res[1]?></td>
</tr>
<tr>
<td width=105 height=135 align="center" bgcolor="#EDEBDC"><img src="images/logo.png" width=100 height=130></td>
<td height="112" valign="top" align="center" bgcolor="#E5E5E5"><strong><?=$res[2]?></strong></td>
</tr>
<tr>
<td valign="top" align="center" bgcolor="#CCCCCC"><strong><a href="?go=painel/ticket_del_com&amp;id=<?=$res[3]?>">Excluir</a></strong></td>
</tr>
</table>
<? } ?>
<?=$status?>
<? 
if($_POST['prossegue']) {
$char = $_POST['char'];
$msg = $_POST['msg'];
$data=date("d/m/y - h:i a");

$VerificaStatus = mssql_fetch_row(mssql_query("select connectstat from memb_stat where memb___id='".$login."'"));
$VerificaChar = mssql_num_rows(mssql_query("select name from character where name='".$char."' and accountid='".$login."'"));
if($VerificaStatus[0] >= 1) {
echo "<script>alert('Saia da conta.'); 
location='javascript:history.back()'</script>";
}
if($VerificaChar <= 0) { 
echo "<script>alert('Char inválido.'); 
location='javascript:history.back()'</script>"; 
}
elseif($msg == NULL) { 
echo "<script>alert('Mensagem inválida'); 
location='javascript:history.back()'</script>"; 
}
else {
mssql_query("INSERT INTO site_ticket_res (name,msg,data,titulo) values ('$char','$msg','$data','$Exibe[0]')");
echo "<script>alert('Resposta adicionada.'); 
	location='javascript:history.back()'</script>";	
} } }
} }
?></div>