<?php

##############################################################################
# chat_BlackList.php3                                                                #
#                                                                            #
# Copyright ViralGames SARL 2000                                             #
##############################################################################


include("../config.php3");
include($BIB."bib_generic.php3");
include($BIB."bib_tables.php3");


$maxLigne = 100;

?>
<html>
<head></head>
<link rel="stylesheet" href="admin.css">
<body rightmargin=0>
<div align=center class=trTitle>Gestion de la Black List du Chat</div>
<br>
<?php
# insertion dans la black liste
if($toblackList == 1)
{
	$squery = "SELECT Id FROM Players WHERE NickName='".$pseudo."'";
	$rowsPlayers = main_db_query($squery);
	$rowPlayer = db_fetch_assoc($rowsPlayers);
	
	if($rowPlayer['Id'] != "")
	{
		# je verifie s il existe pas deja dans la black liste
		$squeryVerif = "SELECT COUNT(*) AS NB FROM Chat_BlackList WHERE Pseudo='".$pseudo."'";
		$rowExist = db_fetch_assoc(main_db_query($squeryVerif));
		if($rowExist['NB'] == 0)
		{
			$squeryInsert = "INSERT INTO Chat_BlackList (Pseudo,Id) VALUES ('".$pseudo."',".$rowPlayer['Id'].")";
			main_db_query($squeryInsert);
		}
	}
	else
	{
		$errorPseudo = $pseudo." n'existe pas !";
	}
	$pseudo = "";
	$toblackList = 0;
}
?>

<form>
<img src="<?php echo $IMAGES_DIR?>triangleorange.gif" border=0> 
Black lister (bloquer) le pseudo&nbsp;:&nbsp;</a><input type=hidden name=toblackList value="1">
<input class=inputBg2 class=bgpostit type=text name=pseudo value="">
<input align=absmiddle type=image src="<?php echo $IMAGES_DIR?>boutons/bouton_valider.gif" value="<?php echo C_ENVOYER?> !">
&nbsp;&nbsp;<?php echo $errorPseudo;?> 
</form>

<?php

if($deblock==1)
{
	//echo "daim mother fucker !!!";
	$squery = "SELECT Id,Pseudo FROM Chat_BlackList";
	$rowsBlacks = main_db_query($squery);
	while( $rowBlack = db_fetch_assoc($rowsBlacks) )
	{
		
		if( $$rowBlack['Pseudo']==1)
		{
			$squeryDelete = "DELETE FROM Chat_BlackList WHERE Id=".$rowBlack['Id'];

			//debug($squeryDelete);			
			$rowsBlackDelete = main_db_query($squeryDelete);
			
		}
		
	}
	
}


$squery = "SELECT Pseudo FROM Chat_BlackList";
		
$rowsBlacksLists = main_db_query($squery);
# recup les NickName de chaque joueur de PlayerOptions
for ($r=1;$r<=db_num_rows($rowsBlacksLists);$r++)
{
	$var_name="Player".$r;
	$tmp_row=db_fetch_assoc($rowsBlacksLists);
	$$var_name=$tmp_row['Pseudo'];
}

?>
<br style=font-size:1px>
<center>

<form>
<table cellpadding=5 align=center width=800>
<?php 
$index_case = 0;
for ($ligne = 1 ; $ligne <= $maxLigne ; $ligne++)
{
	echo "<tr bgcolor=#F5F9F7>";
	for ($colonne = 1 ; $colonne <= 5 ; $colonne++)
	{
		$index_case++;
		$var = "Player".$index_case;
		if($$var != "")
		{
			?>
			<td width=10%  class=smallDark align=left>
			<input type=checkbox name="<?php echo $$var;?>" value="1">
			<?php echo $$var; ?>
			</td>
			<?php
		}
	}
	echo "</tr>";
}
?>
</table>
<div align=center>
<input type="image" name="Valider" src="<?php echo $IMAGES_DIR . "boutons/btn_debloquer.gif"?>" border="0" alt="Valider">
<input type="hidden" name="deblock" value="1">
</div>
</form> 

</body>
</html>

