if (yr<1000) yr += 1900;
hr = dt.getHours();
mi = dt.getMinutes();
-
+
time = (mi < 10) ? hr +':0'+mi : hr+':'+mi;
days = ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'];
months = ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet',
try {
window.external.AddSearchProvider(searchURI);
} catch(e) {
- alert("Impossible d'installer la barre de recherche");
+ alert("Impossible d'installer la barre de recherche");
}
}
}
return true;
} else if (obj.attachEvent) {
return obj.attachEvent("on"+evt, f);
- }
+ }
return false;
}
// }}}
+
+/***************************************************************************
+ * Password check
+ */
+
+// {{{ function checkPassword
+
+function getType(char) {
+ if (char >= 'a' && char <= 'z') {
+ return 1;
+ } else if (char >= 'A' && char <= 'Z') {
+ return 2;
+ } else if (char >= '0' && char <= '9') {
+ return 3;
+ } else {
+ return 4;
+ }
+}
+
+function checkPassword(box) {
+ var prev = 0;
+ var prop = 0;
+ var pass = box.value;
+ var types = Array(0, 0, 0, 0, 0);
+ for (i = 0 ; i < pass.length ; ++i) {
+ type = getType(pass.charAt(i));
+ if (prev != 0 && prev != type) {
+ prop += 5;
+ }
+ if (i >= 5) {
+ prop += 5;
+ }
+ if (types[type] == 0) {
+ prop += 10;
+ }
+ types[type]++;
+ prev = type;
+ }
+ if (prop > 100) {
+ prop = 100;
+ } else if (prop < 0) {
+ prop = 0;
+ }
+ ok = (prop >= 60);
+ $("#passwords_measure").width(prop + "%").css("background-color", ok ? "green" : "red");
+ if (ok) {
+ $(":submit").removeAttr("disabled");
+ } else {
+ $(":submit").attr("disabled", "disabled");
+ }
+}
+
+// }}}
+
+
/***************************************************************************
* The real OnLoad
*/
--- /dev/null
+<?php
+/***************************************************************************
+ * Copyright (C) 2003-2008 Polytechnique.org *
+ * http://opensource.polytechnique.org/ *
+ * *
+ * This program is free software; you can redistribute it and/or modify *
+ * it under the terms of the GNU General Public License as published by *
+ * the Free Software Foundation; either version 2 of the License, or *
+ * (at your option) any later version. *
+ * *
+ * This program is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
+ * GNU General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU General Public License *
+ * along with this program; if not, write to the Free Software *
+ * Foundation, Inc., *
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA *
+ ***************************************************************************/
+require_once 'platal.inc.php';
+
+function smarty_compiler_checkpasswd($tag_attrs, &$compiler)
+{
+ extract($compiler->_parse_attrs($tag_attrs));
+ if (!isset($width)) {
+ $width = '250px';
+ }
+ if (!isset($id)) {
+ $id = "newpassword";
+ }
+
+ return '?><script type="text/javascript" src="javascript/jquery.js" ></script>
+ <script type="text/javascript">//<![CDATA[
+ $(":input[@name=' . $id . ']").keyup(function(event) { checkPassword(event.target); });
+ //]]></script>
+ <div style="border: 1px solid white; width: ' . $width . '; height: 7px; background-color: #444">
+ <div id="passwords_measure" style="height: 100%; background-color: red; width: 0px"></div>
+ </div><?php';
+}
+
+/* vim: set expandtab enc=utf-8: */
+
+?>
</p>
<br />
<form action="{$smarty.server.REQUEST_URI}" method="post" id="changepass">
- {javascript name="jquery"}
- <script type="text/javascript">//<![CDATA[
- {literal}
- function getType(char) {
- if (char >= 'a' && char <= 'z') {
- return 1;
- } else if (char >= 'A' && char <= 'Z') {
- return 2;
- } else if (char >= '0' && char <= '9') {
- return 3;
- } else {
- return 4;
- }
- }
- function checkPassword(box) {
- var prev = 0;
- var prop = 0;
- var pass = box.value;
- var types = Array(0, 0, 0, 0, 0);
- for (i = 0 ; i < pass.length ; ++i) {
- type = getType(pass.charAt(i));
- if (prev != 0 && prev != type) {
- prop += 5;
- }
- if (i >= 5) {
- prop += 5;
- }
- if (types[type] == 0) {
- prop += 10;
- }
- types[type]++;
- prev = type;
- }
- if (prop > 100) {
- prop = 100;
- } else if (prop < 0) {
- prop = 0;
- }
- ok = (prop >= 60);
- $("#passwords").width(prop + "%").css("background-color", ok ? "green" : "red");
- if (ok) {
- $(":submit").removeAttr("disabled");
- } else {
- $(":submit").attr("disabled", "disabled");
- }
- }
- {/literal}
- //]]></script>
<table class="tinybicol" cellpadding="3" cellspacing="0"
summary="Formulaire de mot de passe">
<tr>
Nouveau mot de passe :
</td>
<td>
- <input type="password" size="10" maxlength="10" name="nouveau" onkeyup="checkPassword(this)" />
+ <input type="password" size="10" maxlength="10" name="nouveau" />
</td>
</tr>
<tr>
Sécurité
</td>
<td>
- <div style="border: 1px solid white; width: 250px; height: 7px; background-color: #444">
- <div id="passwords" style="height: 100%; background-color: red; width: 0px"></div>
- </div>
+ {checkpasswd id="nouveau"}
</td>
</tr>
<tr>