Retire du vieux code inusité : classe trash (et les appels a un datepicker js

qui était pour cette classe) et passwordstrengthmeter, jamais implémenté
This commit is contained in:
Alan Garcia 2013-04-23 21:15:17 +00:00
parent 3ac7b334f3
commit db5162248c
6 changed files with 2 additions and 360 deletions

4
.gitattributes vendored
View File

@ -281,7 +281,6 @@ bureau/admin/js/jquery_ui/css/smoothness/jquery-ui-1.8.23.custom.css -text
bureau/admin/js/jquery_ui/index.html -text
bureau/admin/js/jquery_ui/js/jquery-1.7.2.min.js -text
bureau/admin/js/jquery_ui/js/jquery-ui-1.8.23.custom.min.js -text
bureau/admin/js/passwordStrengthMeter.js -text
bureau/admin/js/prototype.js -text
bureau/admin/login.php -text
bureau/admin/logo2.png -text
@ -336,13 +335,11 @@ bureau/admin/sql_users_list.php -text
bureau/admin/sql_users_password.php -text
bureau/admin/sql_users_rights.php -text
bureau/admin/stats_members.php -text
bureau/admin/styles/passwordStrengthMeter.css -text
bureau/admin/styles/style-bluedesktop10.css -text
bureau/admin/styles/style-empty.css -text
bureau/admin/styles/style-hw.css -text
bureau/admin/styles/style.css -text
bureau/admin/tempovars.php -text
bureau/admin/trash_dateselect.php -text
bureau/admin/vm.php -text
bureau/admin/webmail-redirect.php -text
bureau/class/config.php -text
@ -371,7 +368,6 @@ bureau/class/m_menu.php -text
bureau/class/m_mysql.php -text
bureau/class/m_piwik.php -text
bureau/class/m_quota.php -text
bureau/class/m_trash.php -text
bureau/class/mime.php -text
bureau/class/reset_stats_conf.php -text
bureau/class/variables.php -text

View File

@ -31,9 +31,8 @@ if (!$charset) $charset="UTF-8";
<meta http-equiv="Content-Type" content="text/html; charset=<?php echo $charset; ?>" />
<title><?php __("AlternC Control Panel"); ?></title>
<link rel="stylesheet" href="js/jquery_ui/css/smoothness/jquery-ui-1.8.23.custom.css" type="text/css" />
<link rel="stylesheet" href="styles/style.css" type="text/css" />
<link rel="stylesheet" href="styles/passwordStrengthMeter.css" type="text/css" />
<link rel="stylesheet" href="js/jquery_ui/css/smoothness/jquery-ui-1.8.23.custom.css" type="text/css" />
<link rel="stylesheet" href="styles/style-empty.css" type="text/css" title="Default - Desktop TNG"/>
<link rel="alternate stylesheet" href="styles/style-bluedesktop10.css" type="text/css" title="Blue Desktop 1.0" />
@ -45,11 +44,7 @@ if (!$charset) $charset="UTF-8";
<script src="js/alternc.js" type="text/javascript" ></script>
<script src="js/jquery.min.js" type="text/javascript"></script>
<script src="js/jquery_ui/js/jquery-ui-1.8.23.custom.min.js" type="text/javascript"></script>
<?php
$lang_date_picker="js/jquery_ui/js/jquery.ui.datepicker-".substr($lang,0,2).".js";
if (file_exists($lang_date_picker))
echo "<script src=\"$lang_date_picker\" type=\"text/javascript\"></script>";
?>
</head>
<body>
<?

View File

@ -1,132 +0,0 @@
/* Intelligent Web NameSpace */
var IW = IW || {};
/**
* Password validator logic
*/
(function(IW) {
var secondsInADay = 86400;
function PasswordValidator() {
}
/**
* How long a password can be expected to last
*/
PasswordValidator.prototype.passwordLifeTimeInDays = 365;
/**
* An estimate of how many attempts could be made per second to guess a password
*/
PasswordValidator.prototype.passwordAttemptsPerSecond = 500;
/**
* An array of regular expressions to match against the password. Each is associated
* with the number of unique characters that each expression can match.
* @param password
*/
PasswordValidator.prototype.expressions = [
{
regex : /[A-Z]+/,
uniqueChars : 26
},
{
regex : /[a-z]+/,
uniqueChars : 26
},
{
regex : /[0-9]+/,
uniqueChars : 10
},
{
regex : /[!\?.;,\\@$£#*()%~<>{}\[\]]+/,
uniqueChars : 17
}
];
/**
* Checks the supplied password
* @param {String} password
* @return The predicted lifetime of the password, as a percentage of the defined password lifetime.
*/
PasswordValidator.prototype.checkPassword = function(password) {
if (password == null) password="0"
var
expressions = this.expressions,
i,
l = expressions.length,
expression,
possibilitiesPerLetterInPassword = 0;
for (i = 0; i < l; i++) {
expression = expressions[i];
if (expression.regex.exec(password)) {
possibilitiesPerLetterInPassword += expression.uniqueChars;
}
}
var
totalCombinations = Math.pow(possibilitiesPerLetterInPassword, password.length),
// how long, on average, it would take to crack this (@ 200 attempts per second)
crackTime = ((totalCombinations / this.passwordAttemptsPerSecond) / 2) / secondsInADay,
// how close is the time to the projected time?
percentage = crackTime / this.passwordLifeTimeInDays;
return Math.min(Math.max(password.length * 5, percentage * 100), 100);
};
IW.PasswordValidator = new PasswordValidator();
})(IW);
/**
* jQuery plugin which allows you to add password validation to any
* form element.
*/
(function(IW, jQuery) {
function updatePassword() {
var
percentage = IW.PasswordValidator.checkPassword(this.val()),
progressBar = this.parent().find(".passwordStrengthBar div");
progressBar
.removeClass("strong medium weak useless")
.stop()
.animate({"width": percentage + "%"});
if (percentage > 90) {
progressBar.addClass("strong");
} else if (percentage > 50) {
progressBar.addClass("medium")
} else if (percentage > 10) {
progressBar.addClass("weak");
} else {
progressBar.addClass("useless");
}
}
jQuery.fn.passwordValidate = function() {
this
.bind('keyup', jQuery.proxy(updatePassword, this))
.after("<div class='passwordStrengthBar'>" +
"<div></div>" +
"</div>");
updatePassword.apply(this);
return this; // for chaining
}
})(IW, jQuery);
/* Have all the password elements on the page validate */
jQuery("input[type='password']").passwordValidate();

View File

@ -1,9 +0,0 @@
.style1 {
font-family: Geneva, Arial, Helvetica, sans-serif;
font-size: 12px;
}
.inbox { width:200px;border:solid 1px gray; }
.graybar { width:200px; background:#dddddd; height:3px; float:left; }
.colorbar {margin-top:-3px;width:1px;background-image:url(images/passwordstrength.jpg);height:3px; float:left;}
.percent {margin-top:0px;float:left;}
.result {color:green; font-family:Tahoma;font-size:11px;}

View File

@ -1,107 +0,0 @@
<?php
/*
$Id: dateselect.php,v 0.0 2010/11/16 23:52:00 root Exp $
----------------------------------------------------------------------
AlternC - Web Hosting System
Copyright (C) 2002 by the AlternC Development Team.
http://alternc.org/
----------------------------------------------------------------------
Based on:
Valentin Lacambre's web hosting softwares: http://altern.org/
----------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
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.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
Original Author of file: Alan Garcia
Purpose of file: Show the date selection form for temporary emails
----------------------------------------------------------------------
*/
require_once("../class/config.php");
$istrash=false;
if (! is_null($res['trash_info']) && $res['trash_info']->is_trash ) {
$istrash=true;
}
?>
<p>
<input type="radio" name="istrash" id="istrash0" class="inc" value="0"<?php cbox(!$istrash); ?> onclick="hide('trash_expire_picker');"><label for="istrash0"><?php __("No"); ?></label>
<input type="radio" name="istrash" id="istrash1" class="inc" value="1"<?php cbox($istrash); ?> onclick="show('trash_expire_picker');"><label for="istrash1"><?php __("Yes"); ?></label>
</p>
<div id="trash_expire_picker">
<table>
<tbody>
<tr>
<td valign="top">
<input type="radio" name="trash_type_expiration" value="trash_in_x" id="trash_in_x" onclick="trash_exp_in_activate();">
</td><td>
<label for="trash_in_x"><?php __('You want it to be deleted in');?></label><br/>
<select id="trash_exp_in_value" name="trash_exp_in_value" >
<?php for($i=1;$i<=30;$i++) { ?>
<option value="<?php echo $i;?>" <?php echo $i==7?'selected="selected"':"" ;?>><?php echo $i;?></option>
<?php } // for ?>
</select>
<select id="trash_exp_in_unit" name="trash_exp_in_unit">
<option value="hours"><?php __("Hours"); ?></option>
<option value="days" selected="selected"><?php __("Days"); ?></option>
<option value="weeks"><?php __("Weeks"); ?></option>
</select>
</td>
</tr><tr>
<td valign="top">
<input type="radio" name="trash_type_expiration" value="trash_at_x" id="trash_at_x" checked="checked" onclick="trash_exp_at_activate();">
</td><td>
<label for="trash_at_x"><?php __('Delete this email the following day,<br/>enter the date using DD/MM/YYYY format');?></label><br/>
<input id="trash_datepicker" name="trash_datepicker" type="text" size="10" value="<?php
if ($istrash) {
echo $res['trash_info']->human_display();
} else {
echo strftime("%d/%m/%Y",mktime() + (3600*24*7));
}
?>" />
</td>
</tr>
</tbody>
</table>
<br />
<span style="color: red;"><?php __("All this account information will be deleted at expiration");?></span>
</div>
<script>
$(document).ready(function() {
$("#trash_datepicker").datepicker({ minDate: '+1d'}); // We can't give an anterior date
$("#trash_datepicker").datepicker( "option", "dateFormat", "dd/mm/yy" ); // format of the date
// FIXME : I let Benjamin make de translation wrapper for jquery and jquery_ui, he have a better view than me
trash_exp_at_activate();
});
function trash_exp_at_activate() {
$('#trash_datepicker').removeAttr('disabled');
$('#trash_exp_in_value').attr('disabled', true);
$('#trash_exp_in_unit').attr('disabled', true);
}
function trash_exp_in_activate() {
$('#trash_datepicker').attr('disabled', 'disabled');
$('#trash_exp_in_value').removeAttr('disabled');
$('#trash_exp_in_unit').removeAttr('disabled');
}
<?php if (!$istrash) { ?>
hide('trash_expire_picker');
<?php } ?>
</script>

View File

@ -1,101 +0,0 @@
<?php
/*
----------------------------------------------------------------------
AlternC - Web Hosting System
Copyright (C) 2000-2012 by the AlternC Development Team.
https://alternc.org/
----------------------------------------------------------------------
LICENSE
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
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.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
Purpose of file: Manage trash class
----------------------------------------------------------------------
*/
class m_trash {
var $is_trash=false;
var $expiration_date=null;
var $expiration_date_db=null;
/* ----------------------------------------------------------------- */
/**
* Constructeur
*/
function m_trash() {
}
function set_from_db($expiration_date_db) {
$this->expiration_date_db=$expiration_date_db;
$this->expiration_date=strtotime($this->expiration_date_db);
if ($this->expiration_date_db) $this->is_trash=true;
}
function human_display() {
return strftime("%d/%m/%Y",$this->expiration_date);
}
function getfromform() {
$fields = array (
"istrash" => array ("request", "boolean", false),
"trash_type_expiration" => array ("request", "string", ""),
"trash_exp_in_value" => array ("request", "string", ""),
"trash_exp_in_unit" => array ("request", "string", ""),
"trash_datepicker" => array ("request", "string", ""),
);
$champs=getFields($fields);
foreach($champs as $k=>$v) $$k = $v;
if (!$istrash) $trash_type_expiration="no_exp";
switch($trash_type_expiration) {
case "trash_at_x":
// We can use date_parse_from_format if we have php 5.3
//$this->expiration_date=date_parse_from_format("%d/%m/%Y",$trash_datepicker);
$mydate=strptime($trash_datepicker, "%d/%m/%Y");
if ($mydate){
$this->expiration_date=new DateTime("@".mktime( 0, 0, 0, $mydate['tm_mon']+1, $mydate['tm_mday']+1, 1900+$mydate['tm_year']));
} else {
$this->expiration_date=new DateTime("@".(time() + (7*24*3600)));
}
$this->is_trash=true;
break;
case "trash_in_x":
$this->is_trash=true;
switch ($trash_exp_in_unit) {
case "weeks":
$trash_unit = 7*24*3600;
break;
case "days":
$trash_unit = 24*3600;
break;
case "hours":
$trash_unit = 3600;
break;
}
$this->expiration_date= new DateTime("@".(time() + ($trash_exp_in_value*$trash_unit)) );
break;
case "no_exp":
$this->is_trash=false;
break;
default:
$this->is_trash=false;
} // switch
if (!is_null($this->expiration_date)) $this->expiration_date_db=$this->expiration_date->format('Y-m-d H:i:s');
}
}
?>