1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77
| function getXhr(){
var xhr = null;
if(window.XMLHttpRequest) // Firefox et autres
xhr = new XMLHttpRequest();
else if(window.ActiveXObject){ // Internet Explorer
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch (e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
}
else { // XMLHttpRequest non supporté par le navigateur
alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
xhr = false;
}
return xhr
}
//************************************fonction de connexion*********************************
function connexion(){
var xhr = getXhr()
var p = document.getElementById("pwd").value;
var l = document.getElementById("login").value;
xhr.open("GET", "querypass.php?p="+p+"&l="+l + "&nocache=" + Math.random(), false);
xhr.onreadystatechange = function(){
if(xhr.readyState==4 && xhr.status==200 ){
var xml = xhr.responseXML
var ress = xml.getElementsByTagName('ress')[0];
var id = ress.getElementsByTagName('id')[0].firstChild.nodeValue
var nom = ress.getElementsByTagName('nom')[0].firstChild.nodeValue
var prenom = ress.getElementsByTagName('prenom')[0].firstChild.nodeValue
var stat = ress.getElementsByTagName('stat')[0].firstChild.nodeValue
if(stat == 0)
{redirection(0)
window.href="index_error.html"}
else
{cre_cook0("cookies",id)
window.location.replace("menu.html")}
}}
xhr.send(null);
}
//*********************************fonction creation cookies*****************************
function cre_cook0(nom,contenu) {
var expireDate = new Date();
expireDate.setTime(expireDate.getTime() + 24*3600*1000);
document.cookie = nom + "=" + escape(contenu)
+ ";expires=" + expireDate.toGMTString();
}
//*************************fonction affichage valeur cookies****************************
function litCook() {
var nom="cookies";
c=lit_cook(nom)
if(c=="") alert("Le cookie est vide !")
else alert("Le cookie vaut : "+c)
//window.location.replace("index_error.html")
}
//**********************fonction lecture cookies****************************************
function lit_cook(nom) {
var deb,fin
deb = document.cookie.indexOf(nom + "=")
if (deb >= 0) {
deb += nom.length + 1
fin = document.cookie.indexOf(";",deb)
if (fin < 0) fin = document.cookie.length
return unescape(document.cookie.substring(deb,fin))
}
return ""
} |
Partager