bonjour,
j'ai essayé de copier le script de Niveau de sécurité du mot de passe de gmail quand on modifie notre mot de passe.
le fichier mps.js
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133 <script type="text/javascript" src="mps.js"></script> <script type="text/javascript"> <!-- var myxmlhttp; var isBrowserCompatible; ratingMsgs = new Array(6); ratingMsgColors = new Array(6); barColors = new Array(6); ratingMsgs[0] = "Trop court"; ratingMsgs[1] = "Faible"; ratingMsgs[2] = "Correct"; ratingMsgs[3] = "Bon"; ratingMsgs[4] = "Élevé(e)"; ratingMsgs[5] = "Non évalué"; ratingMsgColors[0] = "#676767"; ratingMsgColors[1] = "#aa0033"; ratingMsgColors[2] = "#f5ac00"; ratingMsgColors[3] = "#6699cc"; ratingMsgColors[4] = "#008000"; ratingMsgColors[5] = "#676767"; barColors[0] = "#dddddd"; barColors[1] = "#aa0033"; barColors[2] = "#ffcc33"; barColors[3] = "#6699cc"; barColors[4] = "#008000"; barColors[5] = "#676767"; function CreateRatePasswdReq(formKey) { if (!isBrowserCompatible) { return; } //var passwd = document.forms[formKey].Passwd.value; var passwd = document.getElementById("Passwd").value; var min_passwd_len = 3; var passwdKey = "Passwd"; if (passwd.length < min_passwd_len) { if (passwd.length > 0) { DrawBar(0); } else { resetBar(); } } else { passwd = escape(passwd); var params = passwdKey + "=" + passwd; myxmlhttp = CreateXmlHttpReq(RatePasswdXmlHttpHandler); XmlHttpPOST(myxmlhttp, "verifniveau.php", params); } } function RatePasswdXmlHttpHandler() { if (myxmlhttp.readyState != 4) { return; } rating = parseInt(myxmlhttp.responseText); DrawBar(rating); } function DrawBar(rating) { var posbar = getElement('posBar'); var negbar = getElement('negBar'); var passwdRating = getElement('passwdRating'); var barLength = getElement('passwdBarDiv').width; if (rating >= 0 && rating <= 4) { posbar.style.width = barLength / 4 * rating; negbar.style.width = barLength / 4 * (4 - rating); } else { posbar.style.width = 0; negbar.style.width = barLength; rating = 5; } posbar.style.background = barColors[rating]; passwdRating.innerHTML = "<font color='" + ratingMsgColors[rating] + "'>" + ratingMsgs[rating] + "</font>"; } function resetBar() { var posbar = getElement('posBar'); var negbar = getElement('negBar'); var passwdRating = getElement('passwdRating'); var barLength = getElement('passwdBar').width; posbar.style.width = "0px"; negbar.style.width = barLength + "px"; passwdRating.innerHTML = ""; } var agt = navigator.userAgent.toLowerCase(); var is_op = (agt.indexOf("opera") != -1); var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_op; var is_mac = (agt.indexOf("mac") != -1); var is_gk = (agt.indexOf("gecko") != -1); var is_sf = (agt.indexOf("safari") != -1); function gff(str, pfx) { var i = str.indexOf(pfx); if (i != -1) { var v = parseFloat(str.substring(i + pfx.length)); if (!isNaN(v)) { return v; } } return null; } function Compatible() { if (is_ie && !is_op && !is_mac) { var v = gff(agt, "msie "); if (v != null) { return (v >= 6.0); } } if (is_gk && !is_sf) { var v = gff(agt, "rv:"); if (v != null) { return (v >= 1.4); } else { v = gff(agt, "galeon/"); if (v != null) { return (v >= 1.3); } } } if (is_sf) { var v = gff(agt, "applewebkit/"); if (v != null) { return (v >= 124); } } return false; } myxmlhttp = CreateXmlHttpReq(RatePasswdXmlHttpHandler); isBrowserCompatible = Compatible() && myxmlhttp; </script>
Tout est parfait sauf que je ne sais pas quoi mettre dans le fichier verifniveau.php, dans la ligne qui contient ce code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 //------------------------------------------------------------------------ // This file depends on: // http://gmail.google.com/gmail?view=page&name=browser //------------------------------------------------------------------------ //------------------------------------------------------------------------ // Some browser detection logic. // Once http://gmail.google.com/gmail?view=page&name=browser has these // variables as *global* these definitions can be deleted. //------------------------------------------------------------------------ var agt = navigator.userAgent.toLowerCase(); var is_op = (agt.indexOf("opera") != -1); var is_ie = (agt.indexOf("msie") != -1) && document.all && !is_op; var is_ie5 = (agt.indexOf("msie 5") != -1) && document.all && !is_op; //------------------------------------------------------------------------ // Communication with server //------------------------------------------------------------------------ function CreateXmlHttpReq(handler) { var xmlhttp = null; if (is_ie) { // Guaranteed to be ie5 or ie6 var control = (is_ie5) ? "Microsoft.XMLHTTP" : "Msxml2.XMLHTTP"; try { xmlhttp = new ActiveXObject(control); xmlhttp.onreadystatechange = handler; } catch (ex) { // TODO: better help message alert("You need to enable active scripting and activeX controls"); } } else { // Mozilla xmlhttp = new XMLHttpRequest(); xmlhttp.onload = handler; xmlhttp.onerror = handler; } return xmlhttp; } // XMLHttp send POST request function XmlHttpPOST(xmlhttp, url, data) { try { xmlhttp.open("POST", url, true); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8"); xmlhttp.send(data); } catch (ex) { // do nothing } } // XMLHttp send GEt request function XmlHttpGET(xmlhttp, url) { try { xmlhttp.open("GET", url, true); xmlhttp.send(null); } catch (ex) { // do nothing } }
Code : Sélectionner tout - Visualiser dans une fenêtre à part xmlhttp.open("POST", url, true);
Partager