############################################################## 
## MOD Title: 			Username live checking (in french : Pseudo live verification)
## MOD Version: 		1.0.0
## MOD Author: 			Lefkeo
## Website of author: 	http://www.lefkeo-fr.com
## Email for contact:	lefkeo @ gmail.com
## MOD Traduction: 		Zuker - http://www.eddb.com.ar
## Description :		Al registrarte, un campo avisa al usuario si el nombre que quiere utilizar esta en uso o no.
## 
## Demonstration board : http://www.lefkeo.info/profile.php?mode=register&agreed=true
## Thanks to Krucial 	http://www.editeurjavascript.com/trucs/35,ajax_interrogez_votre_serveur_avec_javascript.php
## MOD ok for all version of phpbb
## 
## Level installation: Easy
## Time for installation: 1 minute
##
## Files To Edit:      1
##      templates/subSilver/profile_add_body.tpl    
##
## Included Files:     1
##		/verifpseudo.php
##
############################################################## 
## 
## 	AJAX + PHP are the best :)
##
############################################################## 
## MOD History: 
## 
##   20 april 2006 Version 1.0.0
##	 31 may 2006, small changement
##
############################################################## 
# 
#-----[ COPY ]------------------------------------------
#

root/verifpseudo.php >> TO >> /verifpseudo.php

#
#-----[ OPEN ]------------------------------------------
#

templates/subSilver/profile_add_body.tpl

#
#-----[ SEARCH ( at the first line ) ]------------------------------------------
#

<form action="{S_PROFILE_ACTION}" {S_FORM_ENCTYPE} method="post">

#
#-----[ ADD, BEFORE ]------------------------------------------
#

<script type="text/javascript">
function writediv(texte)
{
document.getElementById('pseudobox').innerHTML = texte;
}

function verifPseudo(username)
{
if(username != '')
{
if(username.length<2)
writediv('<span class="gensmall" style="color:#cc0000"><strong>'+username+' :</strong> El nombre de usuario es demasiado corto </span>');
else if(username.length>30)
writediv('<span class="gensmall" style="color:#cc0000"><strong>'+username+' :</strong> El nombre de usuario es demasiado largo</span>');
else if(texte = file('verifpseudo.php?username='+escape(username)))
{
if(texte == 1)
writediv('<span class="gensmall" style="color:#cc0000"><strong>'+username+' :</strong> El nombre de usuario no est disponible, por favor utilice otro</span>');
else if(texte == 2)
writediv('<span class="gensmall" style="color:#1A7917"><strong>'+username+' :</strong> El nombre de usuario est disponible para registrar</span>');
else
writediv(texte);
}
}

}

function file(fichier)
{
if(window.XMLHttpRequest) // FIREFOX
xhr_object = new XMLHttpRequest();
else if(window.ActiveXObject) // IE
xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
else
return(false);
xhr_object.open("GET", fichier, false);
xhr_object.send(null);
if(xhr_object.readyState == 4) return(xhr_object.responseText);
else return(false);
}
</script>

#
#-----[ SEARCH ]------------------------------------------
#

		<input type="text" class="post" style="width:200px" name="username" size="25" maxlength="25" value="{USERNAME}" /></td>

#
#-----[ REPLACE BY  ]------------------------------------------
#

		<input type="text" class="post" style="width:200px" name="username" size="25" maxlength="25" value="{USERNAME}" onKeyUp="verifPseudo(this.value)" /><div id="pseudobox"></div></td>


#
#-----[ SAVE AND CLOSE ]----------------------------
#
# EoM