add requirement for mbstring-extension as we need to be multibyte-character-safe in generatePassword(); adjust special-character-default setting to be the same as on a fresh install; outsource version-definition to separate file; set version to 0.9.34-dev3

Signed-off-by: Michael Kaufmann (d00p) <d00p@froxlor.org>
This commit is contained in:
Michael Kaufmann (d00p)
2015-02-23 12:23:44 +01:00
parent e132723475
commit fe718ef67f
11 changed files with 116 additions and 30 deletions

View File

@@ -18,29 +18,48 @@
/**
* Generates a random password
*/
function generatePassword() {
$alpha_lower = 'abcdefghijklmnopqrstuvwxyz';
$alpha_upper = strtoupper($alpha_lower);
$numeric = '0123456789';
$special = Settings::Get('panel.password_special_char');
$length = Settings::Get('panel.password_min_length') > 3 ? Settings::Get('panel.password_min_length') : 10;
function generatePassword()
{
$alpha_lower = 'abcdefghijklmnopqrstuvwxyz';
$alpha_upper = strtoupper($alpha_lower);
$numeric = '0123456789';
$special = Settings::Get('panel.password_special_char');
$length = Settings::Get('panel.password_min_length') > 3 ? Settings::Get('panel.password_min_length') : 10;
$pw = str_shuffle($alpha_lower);
$n = floor(($length)/4);
$pw = special_shuffle($alpha_lower);
$n = floor(($length) / 4);
if (Settings::Get('panel.password_alpha_upper')) {
$pw .= substr(str_shuffle($alpha_upper), 0, $n);
}
if (Settings::Get('panel.password_alpha_upper')) {
$pw .= mb_substr(special_shuffle($alpha_upper), 0, $n);
}
if (Settings::Get('panel.password_numeric')) {
$pw .= substr(str_shuffle($numeric), 0, $n);
}
if (Settings::Get('panel.password_numeric')) {
$pw .= mb_substr(special_shuffle($numeric), 0, $n);
}
if (Settings::Get('panel.password_special_char_required')) {
$pw .= substr(str_shuffle($special), 0, $n);
}
if (Settings::Get('panel.password_special_char_required')) {
$pw .= mb_substr(special_shuffle($special), 0, $n);
}
$pw = substr($pw, -$length);
$pw = mb_substr($pw, - $length);
return str_shuffle($pw);
return special_shuffle($pw);
}
/**
* multibyte-character safe shuffle function
*
* @param string $str
*
* @return string
*/
function special_shuffle($str = null)
{
$len = mb_strlen($str);
$sploded = array();
while ($len -- > 0) {
$sploded[] = mb_substr($str, $len, 1);
}
shuffle($sploded);
return join('', $sploded);
}

View File

@@ -50,7 +50,4 @@ define('TABLE_PANEL_DOMAINREDIRECTS', 'domain_redirect_codes');
define('TABLE_PANEL_DOMAIN_SSL_SETTINGS', 'domain_ssl_settings');
define('TABLE_DOMAINTOIP', 'panel_domaintoip');
// VERSION INFO
$version = '0.9.34-dev2';
$dbversion = '2';
$branding = '';
require dirname(__FILE__).'/version.inc.php';

25
lib/version.inc.php Normal file
View File

@@ -0,0 +1,25 @@
<?php
/**
* This file is part of the Froxlor project.
* Copyright (c) 2010 the Froxlor Team (see authors).
*
* For the full copyright and license information, please view the COPYING
* file that was distributed with this source code. You can also view the
* COPYING file online at http://files.froxlor.org/misc/COPYING.txt
*
* @copyright (c) the authors
* @author Froxlor team <team@froxlor.org> (2010-)
* @license GPLv2 http://files.froxlor.org/misc/COPYING.txt
* @package System
*
*/
// Main version variable
$version = '0.9.34-dev3';
// Database version (unused, old stuff from SysCP)
$dbversion = '2';
// Distribution branding-tag (used for Debian etc.)
$branding = '';