Chat php/ajax simple et compact

Soyez le premier à donner votre avis sur cette source.

Snippet vu 15 012 fois - Téléchargée 20 fois

Contenu du snippet

Voici un petit script de chat php/ajax, j'ai 15 ans c'est la première source que je dépose ...

c'est un petit script de base pour les débutants, le script Ajax n'est pas très compliqué, je me suis aidé de ce site : http://www.xul.fr/xml-ajax.html pour l'Ajax car je n'y connaissait rien.
L'originalité est dans le faite que le script ne nécessite aucune base de donnée ni aucun fichier texte puisqu'il s'auto-modifie.

Le Script possédé désormais une gestion des utilisateurs, et un tout nouveau design.
Pour connecter un utilisateur, il suffit, soit de se rendre sur la page et la on vous demandera de choisir un pseudo, soit d'appeler la page et de faire passer le pseudo de l'utilisateur par l'url (PAGE.php?login=PSEUDO , les caractères majuscule sont à modifier.)

Ps: Je n'ai pas le temps de mettre les explications de mon script, je le ferais ce soir ou demain ...

merci de dire ce que vous en pensez et de mettre une note !

Source / Exemple :


<?php
session_start();
$page_name = basename( __FILE__ );

if(isset($_POST['login']))
{
	$_SESSION['authentification'] = 'oui';
	$_SESSION['login'] = $_POST['login'];
}
elseif (isset($_GET['login']) && !isset($_SESSION['authentification']))
{
	$_SESSION['authentification'] = 'oui';
	$_SESSION['login'] = $_POST['login'];
}

if (isset($_SESSION['authentification']))
{
$login = $_SESSION['login'];
}
elseif (!isset($_SESSION['authentification']) && !isset($_GET['action']))
{
echo '<html><head>
<title>Petit Chat - By Chouquette</title>
<style type="text/css">* {margin:0px; padding:0px;}
body {background:url('.$page_name.'?action=fond) repeat-x #2fb4ff;}
#identification {position: absolute; width: 300px; margin-left: -150px; left: 50%; height: 80px; margin-top: -60px; top: 50%; border: 1px solid #000000; background-color: #eee; padding:5px;}
body,td,th {font-family: Verdana; font-size: 11px;}
p {margin-top: 0px; margin-bottom: 0px; line-height: 150%}
</style>
</head><body>
<img style="margin-left:5px;" src="'.$page_name.'?action=logo" width="387" height="200" />
<div id="identification">
<form method="post" action="'.$page_name.'">
  <p>Login :</p><input type="text" name="login" id="login" />
  <p><input type="submit" style=" margin-top:8px;" name="button" id="button" value="Envoyer" /></p>
</form>
</body></html>';

exit();

}

$message_garde = 50;
$tempsdeconnect = 15;

$chat='a:0:{}';

$enligne='a:0:{}';

$chat = stripslashes($chat);
$chat = unserialize($chat);
$enligne = stripslashes($enligne);
$enligne = unserialize($enligne);

$images = array( 
"fond" => 
"R0lGODlhA1wwiwLEXDBcMC+0/y+z/7Hb9TCz/zK1/zW2/jq3/j+4/kW6/Uy9/VO//FvB/GLD+2fF+2rG+27H+nLI+nbK+nvL+YDM+YbO+IzQ+JHS+JbT95zV96HX9qbY9qva9q7b9f///1wwXDBcMFwwXDBcMCH5BAFcMFwwHVwwLFwwXDBcMFwwA1wwiwJcMAX/oCCOZGmeXCI3qqrQcrALz3Rt33i9cXu//cCgcEgsGo8/jXLJbDqf0Kj0mVFmrtisdsvter9XjFicGZvP6LR6nb6Y3Zc4Jk6v2+/4vF5vscT7gIGCg4SFhBUVfYiLjI2Oj5CRiBQVlBSXmJmam5ydnp+YE5eiE6Wmp6ipqquqEqUSsLGys7S1trIRubq7vL2+vhC5EMPExcbHyMnEDw8Qzc/M0dLT1NMO1w4P19rY3d7f3g0NDuLl5ufo6egMDA3s7uzx8vP09fb38wv6+/z9/v9cMAMKBKhAn4KDCBMqXFzIsKHDhxAXJkCYoKLFixgzatzIsaPHBAgqXCIYSbKkyZMoU9WqXFzJ0uSBkS8RHJhJs6bNmzhz6tx508ABA0CDCh1KtKjRo0iLFjBQYCnTpk+bSp1KtarVq1ivEiDQdKvXr2DDih37dVwwgQFozxJcMDBcMFwwW7dv4cp123au21wwAeTmtbsXL19cMH3v+oW7d65fvHkHIwbMWHHixoXtNmZM+K5eyZYrHx4MuLDiy4kjY/58OPPizo8zUz5NmbBnwaVFe+Z8ubZo1KYtBw59+nbrz39fG6ZdubjexX1DT+48Wblr2KZp895teDh11cU530aM3Lht4b9rG++dO0AIXDA7",
"logo" =>
"R0lGODlhgwHIXDDEXDBcMP///1wwXDBcMK/b9QEBAZ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6cbl3kRnJkR97hg3ikIMJdM4ZkSZrkSXak50EjSrJkS/LjP7qkHeYeTMZkTdqkORbjTdZh8+WkTvrkT77jspTjdfwEBFww5VFcIuU1ukZPiqMMhGNSQmVUSuUcVl43TiHlVWKlTuoITWZlV3rlV4JlWB6jUYplWZplQTLlWXplCFwwXDA7");

function secureArray($item)
{
$item=addslashes($item);
$item= str_replace("<script",' ',$item);
$item= str_replace("rn",'<br />',$item);
return $item;
} 

function ChangerVar($modifier,$remplacement,$variable)
{
	$fichier = '';
	$tableau = file($modifier);
	while(list($cle,$val) = each($tableau))
	{
		$fichier .= $val;
	}
	$fichier = str_replace("<","<",$fichier);
	$fichier = str_replace(">",">",$fichier);
	preg_match_all("/".$variable."=(.*);/",$fichier,$matches, PREG_SET_ORDER);
	foreach ($matches as $message)
	{
	   $fichier = str_replace($message[0],"".$variable."='".$remplacement."';",$fichier);
	}
	$fichier = str_replace("<","<",$fichier);
	$fichier = str_replace(">",">",$fichier);
	
	$fichieredit = fopen($modifier,"w+");
	fwrite($fichieredit,$fichier);  
	fclose($fichieredit);
	
}

if (isset($_GET['action'])) {
  
  switch ($_GET['action']) {

  case "nouveau_message":
	
	$key = 'pasconnecte';
	for ($numero = 0; $numero < count($enligne); $numero++)
	{
		if($login == $enligne[$numero][0])
		{
		$key = 'connecte';
		$enligne[$numero][0] = $login;
		$enligne[$numero][1] = time();
		$enligne = serialize($enligne);
		ChangerVar($page_name,SecureArray($enligne),'enligne');
		$enligne = unserialize($enligne);
		}
	}

	
	if($key == 'pasconnecte')
	{ 
	$nbrenligne = count($enligne);
	$enligne[$nbrenligne][0] = $login;
	$enligne[$nbrenligne][1] =  time();
	$enligne = serialize($enligne);
	ChangerVar($page_name,SecureArray($enligne),'enligne');
	}

	for ($numero = 0; $numero < count($chat); $numero++)
	{
		echo $chat[$numero][1].'  -  '.stripslashes(urldecode($chat[$numero][2])).'     -     <strong>'.stripslashes(urldecode($chat[$numero][0])).'</strong><br />
';
	}
		exit();
	break;

	case "vider":
		ChangerVar($page_name,secureArray('a:0:{}'),'chat');
	break;

	case "poster":
		$nbr = count($chat);
		
		$chat[$nbr][0] = SecureArray(urlencode($login));
		$chat[$nbr][1] = date('d/m/y h:i:s');
		$chat[$nbr][2] = SecureArray(urlencode($_POST['message']));
		if($nbr >= $message_garde) { array_shift($chat); }
		$chat = serialize($chat);
		ChangerVar($page_name,SecureArray($chat),'chat');
		$chat = unserialize($chat);
		exit();
	break;

	case "enligne" :
		$cache = array();
		echo "<select class='UserOnline' size=\"20\">";
		for ($numero = 0; $numero < count($enligne); $numero++)
		{
	
			if($enligne[$numero][1] > time() - $tempsdeconnect )
			{
			$cachenbr = count($cache);
			$cache[$cachenbr][0] = $enligne[$numero][0];
			$cache[$cachenbr][1] = $enligne[$numero][1];
			echo "<option>".$enligne[$numero][0]."</option>
";
			}
		}
		echo "</select>";
		$cache = serialize($cache);
		ChangerVar($page_name,SecureArray($cache),'enligne');
		exit();
	break;
	
	case "fond" :
	header("Content-type: gif");
	echo stripslashes(base64_decode($images['fond']));
	break;

    case "logo" :
	header("Content-type: gif");
	echo stripslashes(base64_decode($images['logo']));
	break;

    }
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
<title>Chouquette - Chat Ajax/PHP</title>
<style type="text/css">

body {
font:Verdana;
font-size:12px;
background:url(<?php echo $page_name.'?action=fond'; ?>) repeat-x #2fb4ff;
font-family: Verdana;
}

#chat {
width:810px;
margin-top:160px;
position:absolute;
margin-left: -405px;
left: 50%;

}

.UserOnline {
width:150px;
height:300px;
float:right;
background-color: #000000;
color : #FFFFFF;
border:none;
}

#utilisateurs {
width:150px;
height:300px;
float:right;
overflow:hidden;
border: 1px solid #FFFFFF;
background-color: #000000;
}

#texte {
width:650px;
height:300px;
overflow-y: auto;
border: 1px solid #FFFFFF;
background-color: #000000;
color : #FFFFFF;
}

#message {
height:40px;
width:810px;
margin-top:10px;
background-color: #000000;
color : #FFFFFF;
}
<!--

  • {
margin:0px; padding:0px; } li { margin-left:15px; } .menuitems{ padding-left:15px; padding-right:10px; } p { margin-top: 0px; margin-bottom: 0px; line-height: 150%} input,textarea,select { border: 1px solid #FFFFFF; font-weight: bold; font-size: 10px; font-family: verdana; } input { border:1px solid #000000; } hr { color: #0093e6; background-color: #0093e6; height: 5px; } </style> <script language="javascript" type="text/javascript"> var actualise = 1000; // temps entre chaque rechargement des messages function httprequest() // fonction nécessaires pour les requêtes Ajax { var xmlhttp=false; try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");} catch (e){ try { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) {xmlhttp = false;} } if (!xmlhttp && typeof XMLHttpRequest!='undefined') { xmlhttp = new XMLHttpRequest(); } return xmlhttp; } function envoyer() { var texte = document.getElementById('message').value; while(texte.indexOf("&") > 0 || texte.indexOf("+") > 0) { texte = texte.replace("&","%26"); texte = texte.replace("+","%2B"); } // Envoi de la requete var envoyer = httprequest(); envoyer.open("POST", '<?php echo $page_name; ?>?action=poster', true); envoyer.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); envoyer.send('message='+texte); } function vider() { var vider = httprequest(); vider.open("GET","<?php echo $page_name; ?>?action=vider",true); vider.send(null); } function Message() { var message = httprequest(); message.open("GET","<?php echo $page_name; ?>?action=nouveau_message",true); message.onreadystatechange = function() { if (message.readyState == 4) { if(message.status == 200) { document.getElementById('texte').innerHTML = message.responseText;} } } message.send(null); setTimeout("Message()",actualise); } function Utilisateurs() { var utilisateur = httprequest(); utilisateur.open("GET","<?php echo $page_name; ?>?action=enligne",true); utilisateur.onreadystatechange = function() { if (utilisateur.readyState == 4) { if(utilisateur.status == 200) { document.getElementById("utilisateurs").innerHTML = utilisateur.responseText;} } } utilisateur.send(null); setTimeout("Utilisateurs()",5000); } </script> </head> <body onLoad="Message();Utilisateurs();"> <div id="chat"> <div id='utilisateurs'></div> <div id='texte'></div> <p> <textarea id="message" cols="80" rows="3"></textarea> </p> <p>&nbsp;</p> <p> <input type="button" onClick="envoyer()" value="Envoyer"> <input type="button" onClick="vider()" value="Vider les messages"> </p> </div> <img src="<?php echo $page_name.'?action=logo'; ?>" width="387" height="200"> </body> </html>

A voir également

Ajouter un commentaire

Commentaires

philippe62770
Messages postés
1
Date d'inscription
lundi 5 janvier 2015
Statut
Membre
Dernière intervention
5 janvier 2015

salut commen je pourrait changer limage de la chat an haud a gauche merci
cs_bonhommecrea
Messages postés
44
Date d'inscription
dimanche 14 mars 2010
Statut
Membre
Dernière intervention
13 mars 2011

euh 243 pardon
cs_bonhommecrea
Messages postés
44
Date d'inscription
dimanche 14 mars 2010
Statut
Membre
Dernière intervention
13 mars 2011

ligne 143, il y a un commentaire que tu as ouvert et que tu n'a pas refermé :)
rojbisami
Messages postés
6
Date d'inscription
dimanche 26 avril 2009
Statut
Membre
Dernière intervention
18 avril 2010

Un bon script.
Vérifiez l'affichage de l'heure.
cs_SuperChouquette
Messages postés
37
Date d'inscription
dimanche 24 février 2008
Statut
Membre
Dernière intervention
18 mai 2010

Tu dois avoir du texte ou un esoace avant
<?php
session_start();

il ne faut pas qu'il y en ait.

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.