CrazyCat Programming Factory
rendre internet plus accessible
 

Créer un chat sur son site

Logo diversLa plupart des réseaux IRC francophones fournissent une applet installable sur son site.
Le réseau zeolia.net offre deux possibilités:
- utiliser son applet (vous n'avez qu'un javascript et un formulaire à mettre sur votre site)
- utiliser votre propre applet.

Utiliser l'applet


C'est la simplicité même. Il vous suffit d'intégrer le code suivant dans votre page:
<script language="javascript" type="text/javascript">
function pop_it(the_form) {
   my_form = eval(the_form)
   window.open("http://www.zeolia.net/applet/wait.php", "popup", "height=440, width=640, menubar='no', toolbar='no', location='no', status='no', scrollbars='no'");
   my_form.target = "popup";
   my_form.submit();
   popup.focus();
}
</script>
<form name="chatform" action="http://www.zeolia.net/applet/guests.php" method="post">
Nickname : <input type=text name="nick" maxlength=32 size=12 value="" />
Password : <input type=password name="pass" size=12 /> (Si nick enregistré)
<input type=hidden name="chan" value="CANAL" />
<input type=button onclick="pop_it(chatform);" value="Tchatter" />
(Attention, c'est en popup)</form>

Utiliser votre applet


Ceci demande à ce que vous installiez une applet (pjirc est la plus simple à mettre en place) et que vous fassiez une page en php de manière à intégrer un formulaire de connexion:
<?
$channel = "canal";

if ($_POST["tchat"] == "yes") {
    $nick = $_POST["nick"];
    $pass = $_POST["pass"];
    if ($nick) {
        $l_nick = "<param name=\"nick\" value=\"".$nick."\" />\n";
    } else {
        $l_nick = "<param name=\"nick\" value=\"Visiteur-????\" />\n";
    }
    if ($pass) {
        $l_pass = "<param name=\"command1\" value=\"/nickserv identify ".$pass."\" />\n";
        $l_pass .= "<param name=\"command2\" value=\"/join #".$channel."\" />\n";
    } else {
        $l_pass = "<param name=\"command1\" value=\"/join #".$channel."\" />\n";
    }
    $applet = "<div class=\"content\">\n";
    $applet .= "<applet name=\"pjirc\" code=\"IRCApplet.class\" archive=\"irc.jar,pixx.jar\" width=\"720\" height=\"600\" />\n";
    $applet .= "<param name=\"CABINETS\" value=\"securedirc.cab,irc.cab,pixx.cab\" />\n";
    $applet .= $l_nick;
    $applet .= "<param name=\"alternatenick\" value=\"Guest-??\" />\n";
    $applet .= "<param name=\"fullname\" value=\"Guest from http://www.zeolia.net\" />\n";
    $applet .= "<param name=\"host\" value=\"irc.zeolia.net\" />\n";
    $applet .= "<param name=\"userid\" value=\"guest\" />\n";
    $applet .= $l_pass;
    $applet .= "<param name=\"quitmessage\" value=\"Chat: http://www.zeolia.net\" />\n";
    $applet .= "<param name=\"soundword1\" value=\"me snd/ding.au\" />\n";
    $applet .= "<param name=\"language\" value=\"french\" />\n";
    $applet .= "<param name=\"lngextension\" value=\"lng\" />\n";
    $applet .= "<param name=\"soundbeep\" value=\"snd/bell2.au\" />\n";
    $applet .= "<param name=\"soundquery\" value=\"snd/ding.au\" />\n";
    $applet .= "<param name=\"gui\" value=\"pixx\" />\n";
   
    $applet .= "<param name=\"style:sourcefontrule1\" value=\"Status+Channel+Query all Arial 12\" />\n";
    $applet .= "<param name=\"style:bitmapsmileys\" value=\"true\" />\n";
    $applet .= "<param name=\"style:smiley1\" value=\":) img/sourire.gif\" />\n";
    $applet .= "<param name=\"style:smiley2\" value=\":-) img/sourire.gif\" />\n";
    $applet .= "<param name=\"style:smiley3\" value=\":D img/content.gif\" />\n";
    $applet .= "<param name=\"style:smiley4\" value=\":-D img/content.gif\" />\n";
    $applet .= "<param name=\"style:smiley5\" value=\":-O img/OH-2.gif\" />\n";
    $applet .= "<param name=\"style:smiley6\" value=\":o img/OH-1.gif\" />\n";
    $applet .= "<param name=\"style:smiley7\" value=\":P img/langue.gif\" />\n";
    $applet .= "<param name=\"style:smiley8\" value=\":-P img/langue.gif\" />\n";
    $applet .= "<param name=\"style:smiley9\" value=\";) img/clin-oeuil.gif\" />\n";
    $applet .= "<param name=\"style:smiley10\" value=\";-) img/clin-oeuil.gif\" />\n";
    $applet .= "<param name=\"style:smiley11\" value=\":( img/triste.gif\" />\n";
    $applet .= "<param name=\"style:smiley12\" value=\":| img/OH-3.gif\" />\n";
    $applet .= "<param name=\"style:smiley13\" value=\":-| img/OH-3.gif\" />\n";
    $applet .= "<param name=\"style:smiley14\" value=\":'( img/pleure.gif\" />\n";
    $applet .= "<param name=\"style:smiley15\" value=\":$ img/rouge.gif\" />\n";
    $applet .= "<param name=\"style:smiley16\" value=\":-$ img/rouge.gif\" />\n";
    $applet .= "<param name=\"style:smiley17\" value=\"(H) img/cool.gif\" />\n";
    $applet .= "<param name=\"style:smiley18\" value=\"(h) img/cool.gif\" />\n";
    $applet .= "<param name=\"style:smiley19\" value=\":-@ img/enerve1.gif\" />\n";
    $applet .= "<param name=\"style:smiley20\" value=\":@ img/enerve2.gif\" />\n";
    $applet .= "<param name=\"style:smiley21\" value=\":s img/roll-eyes.gif\" />\n";
    $applet .= "<param name=\"style:smiley22\" value=\":-S img/roll-eyes.gif\" />\n";
    $applet .= "<param name=\"style:smiley23\" value=\"(l) img/coeur.gif\" />\n";
    $applet .= "<param name=\"style:smiley24\" value=\"(k) img/bouche.gif\" />\n";
   
    $applet .= "<param name=\"pixx:language\" value=\"pixx-french\" />\n";
    $applet .= "<param name=\"pixx:highlightnick\" value=\"true\" />\n";
    $applet .= "<param name=\"pixx:highlight\" value=\"true\">\n";
    $applet .= "<param name=\"pixx:nickfield\" value=\"false\">\n";
    $applet .= "<param name=\"pixx:styleselector\" value=\"true\" />\n";
    $applet .= "<param name=\"pixx:setfontonstyle\" value=\"true\" />\n";
    $applet .= "<param name=\"pixx:timestamp\" value=\"true\" />\n";
    $applet .= "<param name=\"pixx:mouseurlopen\" value=\"1 2\" />\n";
    $applet .= "<param name=\"pixx:mousechanneljoin\" value=\"1 2\" />\n";
   
    // Blocage des part/join
    /*
    $applet .= "<param name=\"pixx:showstatus\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showhelp\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showabout\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showconnect\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchanlist\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchannelnickchanged\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchannelnickmodeapply\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchannelmodeapply\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchanneltopicchanged\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchannelnickquit\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchannelnickkick\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchannelnickpart\" value=\"false\" />\n";
    $applet .= "<param name=\"pixx:showchannelnickjoin\" value=\"false\" />\n";
    */

    $applet .= "<param name=\"pixx:configurepopup\" value=\"true\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring1\" value=\"Whois\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring2\" value=\"Query\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring3\" value=\"Ban\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring4\" value=\"Kick + Ban\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring5\" value=\"--\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring6\" value=\"Op\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring7\" value=\"DeOp\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring8\" value=\"HalfOp\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring9\" value=\"DeHalfOp\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring10\" value=\"Voice\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring11\" value=\"DeVoice\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring12\" value=\"--\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring13\" value=\"Ping\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring14\" value=\"Version\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring15\" value=\"Time\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring16\" value=\"Finger\" />\n";
    $applet .= "<param name=\"pixx:popupmenustring17\" value=\"--\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand1_1\" value=\"/Whois %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand2_1\" value=\"/Query %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand3_1\" value=\"/mode %2 -o %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand3_2\" value=\"/mode %2 +b %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand4_1\" value=\"/mode %2 -o %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand4_2\" value=\"/mode %2 +b %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand4_3\" value=\"/kick %2 %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand6_1\" value=\"/mode %2 +o %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand7_1\" value=\"/mode %2 -o %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand8_1\" value=\"/mode %2 +h %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand9_1\" value=\"/mode %2 -h %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand10_1\" value=\"/mode %2 +v %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand11_1\" value=\"/mode %2 -v %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand13_1\" value=\"/CTCP PING %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand14_1\" value=\"/CTCP VERSION %1\" />\n";
    $applet .= "<param name=\"pixx:popupmenucommand15_1\" value=\"/CTCP TIME %1\" />\n";
   
    $applet .= "<param name=\"pixx:color0\" value=\"DEE3E7\" />\n";
    $applet .= "<param name=\"pixx:color1\" value=\"000000\" />\n";
    $applet .= "<param name=\"pixx:color2\" value=\"DEE3E7\" />\n";
    $applet .= "<param name=\"pixx:color3\" value=\"DEE3E7\" />\n";
   
    $applet .= "<param name=\"pixx:color4\" value=\"D1D7DC\" />\n";
    $applet .= "<param name=\"pixx:color5\" value=\"DEE3E7\" />\n";
    $applet .= "<param name=\"pixx:color6\" value=\"E5E5E5\" />\n";
    $applet .= "<param name=\"pixx:color7\" value=\"D1D7DC\" />\n";
    $applet .= "<param name=\"pixx:color8\" value=\"FFA34F\" />\n";
    $applet .= "<param name=\"pixx:color9\" value=\"000000\" />\n";
   
    $applet .= "<param name=\"pixx:color10\" value=\"EFEFEF\" />\n";
    $applet .= "<param name=\"pixx:color11\" value=\"FFA34F\" />\n";
    $applet .= "<param name=\"pixx:color12\" value=\"599FCB\" />\n";
    $applet .= "<param name=\"pixx:color13\" value=\"DEE3E7\" />\n";
    $applet .= "<param name=\"pixx:color14\" value=\"DEE3E7\" />\n";
    $applet .= "<param name=\"pixx:color15\" value=\"DEE3E7\" />\n";
    $applet .= "<param name=\"pixx:showhelp\" value=\"true\" />\n";
    $applet .= "<param name=\"pixx:showabout\" value=\"true\" />\n";
    $applet .= "</applet>\n";
    $applet .= "<div>\n";
    $applet .= "<a href=\"javascript:smiley(':)')\" /><img src=\"img/sourire.gif\" width=\"15\" height=\"15\" border=0 alt=\":)\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':D')\" /><img src=\"img/content.gif\" width=\"15\" height=\"15\" border=0 alt=\":D\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':-O')\" /><img src=\"img/OH-2.gif\" width=\"15\" height=\"15\" border=0 alt=\":-O\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':o')\" /><img src=\"img/OH-1.gif\" width=\"15\" height=\"15\" border=0 alt=\":o\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':P')\" /><img src=\"img/langue.gif\" width=\"15\" height=\"15\" border=0 alt=\":P\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(';)')\" /><img src=\"img/clin-oeuil.gif\" width=\"15\" height=\"15\" border=0 alt=\";)\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':(')\" /><img src=\"img/triste.gif\" width=\"15\" height=\"15\" border=0 alt=\":(\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':|')\" /><img src=\"img/OH-3.gif\" width=\"15\" height=\"15\" border=0 alt=\":|\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':\'(')\" /><img src=\"img/pleure.gif\" width=\"15\" height=\"15\" border=0 alt=\":\'(\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':$')\" /><img src=\"img/rouge.gif\" width=\"15\" height=\"15\" border=0 alt=\":$\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley('(H)')\" /><img src=\"img/cool.gif\" width=\"15\" height=\"15\" border=0 alt=\"(H)\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':-@')\" /><img src=\"img/enerve1.gif\" width=\"15\" height=\"15\" border=0 alt=\":-@\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':@')\" /><img src=\"img/enerve2.gif\" width=\"15\" height=\"15\" border=0 alt=\":@\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley(':s')\" /><img src=\"img/roll-eyes.gif\" width=\"15\" height=\"15\" border=0 alt=\":s\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley('(l)')\" /><img src=\"img/coeur.gif\" width=\"15\" height=\"15\" border=0 alt=\"(l)\" /></a> \n";
    $applet .= "<a href=\"javascript:smiley('(k)')\" /><img src=\"img/bouche.gif\" width=\"15\" height=\"15\" border=0 alt=\"(k)\" /></a> \n";
    $applet .= "</div>\n</div>\n";
} else {
    $applet = "<div class=\"content\">\n";
    $applet .= "<p class=\"titre\"><img src=\"./faf_ban.jpg\" /></p>\n";
    $applet .= "<div class=\"subform\">\n";
    $applet .= "<form name=\"chatform\" action=\"./faf.php\" method=\"post\">\n";
    $applet .= "<input type=\"hidden\" name=\"tchat\" value=\"yes\" />\n";
    $applet .= "<p><b>Pseudonyme:</b> <input type=\"text\" name=\"nick\" maxlength=32 size=12 value=\"\" /></p>\n";
    $applet .= "<p><b>Mot de passe:</b> <input type=\"password\" name=\"pass\" size=12 /> (Si pseudonyme enregistré)</p>\n";
    $applet .= "<p><input type=\"submit\" value=\"Entrer sur le tchat\" /></p>\n";
    $applet .= "</form>\n";
    $applet .= "</div>\n";
}
   
echo '<html>
<head>
    <title>Chat</title>
    <script language="javascript" src="./chat.js" type="text/javascript"></script>
</head>
<body>'
.$applet.'</body>
</html>'
;

Le fichier chat.js est celui fourni avec l'applet, en voici la source:
var english = 0;
var german  = 1;
var french = 2;

var lang = english;

var ltxt = new Array();

ltxt[ 0] = ["is away!","ist weg!","est away"];
ltxt[ 1] = ["Reason:","Grund:","Raison:"];
ltxt[ 2] = ["is back","ist zurück","est de retour"];
ltxt[ 3] = ["from:","von:","de:"];
ltxt[ 4] = ["Guest","Gast","Guest"];
ltxt[ 5] = ["away time","Abwesenheit","away time"];
ltxt[ 6] = ["you are already away!","Du bist bereits abwesend!","vous êtes déjà away"];
ltxt[ 7] = ["you are not away!","Du bist nicht abwesend!","vous n'êtes pas away"];

var mtime;
var jtime;
var lev = 0;
var isaway = false;

function chkForm() {
    if(document.login.chan.value == "") {
        alert("Please enter a channel!");
        document.login.chan.focus();
        return false;
    }
    if(document.login.host.value == "") {
        alert("Please enter an IRC server!");
        document.login.host.focus();
        return false;
    }
    RandomNick();
}

function RandomNick() {
    if(document.login.nick.value == "")  {
        document.login.nick.value = ltxt[4][lang] + Math.round(Math.random()*1000);
        return true;
    }
}

function smiley(symbol) {
    document.pjirc.setFieldText(document.pjirc.getFieldText()+' '+symbol);
    document.pjirc.requestSourceFocus();
}

function maway(away_reason,nick) {
    if (!isaway) {
        txt = "/me " + ltxt[0][lang];
        if (away_reason != "") txt += " " + ltxt[1][lang] + " " + away_reason;
        document.pjirc.sendString(txt);
        document.pjirc.sendString("/away " + away_reason);
        document.pjirc.sendString("/nick " + nick +"|away");
        document.pjirc.requestSourceFocus();
        mtime = new Date();
    } else alert(ltxt[6][lang]);
    isaway = true;
}

function mback(away_reason,nick) {
    if (isaway) {
        jtime = new Date(); lev = 0; mins = 0; hours = 0;
        secs = Math.round((Date.parse(jtime)-Date.parse(mtime))/1000);
        if (secs>59) {mins = parseInt(secs/60); secs %= 60; lev=1;}
        if (lev==1 && mins>59) {hours = parseInt(mins/60); mins %= 60; lev=2;}

        awaytxt = ". "+ltxt[5][lang] + ": ";
        if (lev==2) awaytxt += hours+"h, ";
        if (lev==1) awaytxt += mins+"min, ";
        awaytxt += secs+"sec";

        txt = "/me " + ltxt[2][lang];
        if (away_reason != "") txt += " " + ltxt[3][lang] + " " + away_reason;
        document.pjirc.sendString(txt + awaytxt + ".");
        document.pjirc.sendString("/away ");
        document.pjirc.sendString("/nick " + nick);
        document.pjirc.requestSourceFocus();
    } else alert(ltxt[7][lang]);
    isaway = false;
}


Bon chat :)

©2006-2019 Geek Zone | eggdrop.fr | zeolia.net