File "update_chat.php"

Full Path: /home/analogde/www/download/CHESS_2022/update_chat.php
File size: 1.33 KB
MIME-type: text/x-php
Charset: utf-8

<?php

	session_start();

	//header("Cache-Control: no-cache, must-revalidate");
	header("Cache-Control: no-cache");
	header("Pragma: no-cache"); 

	include('database.php');
	DB_connexion(); 
   
	if($_SESSION['login'] != 'no')
	{
   
    $msgs=mysql_query('SELECT * FROM tchat ORDER BY id DESC LIMIT 0,50');
	$cpt = 0;
																		
	while($infos = mysql_fetch_array($msgs)) 
		 {
			$champ = date('d-m-Y ', strtotime($infos["date_mess"])) ."  à  " .date(' H:i:s', strtotime($infos["date_mess"])); 
			$utilisateur = $infos["login"];
			$txt = $infos["mess"];
			$id = $infos["id"];
			$destinataires = $infos["destinataires"];
								
			$pieces = explode(",", $destinataires);
			$nb_elements = count($pieces);
										
			$flag_login = false;
										
			for($i = 0; $i < $nb_elements; $i++)
				{	$element = $pieces[$i];
					if($element == $_SESSION['login'])	
		 			  {  $flag_login = true;
						 echo '<div class="pseudo"><img src="images/puce_tchat_login.jpg" />&nbsp;'.$utilisateur.'</div> ';
						 if($cpt%2 == 1) /* impair */
						    echo '<div class="affiche_message_pair">'.$txt.'</div>';
						 else /* pair */
							echo '<div class="affiche_message_impair">'.$txt.'</div>';
						echo '<div class="date">'.$champ.'<img src="images/puce_tchat_date.jpg" /></div>';
						$cpt = $cpt + 1;
					 }
				}
		}             
 }   

?>