fonctions + local + db

This commit is contained in:
quenenni 2017-08-15 03:39:37 +02:00
parent 2f830d7e4f
commit ff154144e5
3 changed files with 36 additions and 14 deletions

View File

@ -90,7 +90,8 @@ require_once(dirname(__FILE__) . "/local.php");
// Define constants from vars of /etc/alternc/local.sh
// The you can't choose where is the AlternC Panel
define("DEFAULT_PASS_SIZE", 8);
define("DEFAULT_PASS_SIZE", 10);
define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
define('ALTERNC_HTML', "$L_ALTERNC_HTML");
if (isset($L_ALTERNC_LOGS_ARCHIVE)) {
@ -163,9 +164,9 @@ foreach (glob($root . "class/class_system_*.php") as $fcs) {
include_once("lang_env.php");
$mem = new m_mem();
$err = new m_err();
$authip = new m_authip();
$hooks = new m_hooks();
$msg = new m_messages();
if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROTO"]=="https") {
$_SERVER["HTTPS"]="on";
@ -186,7 +187,6 @@ if ((variable_get('force_https', '0', "This variable is set to 0 (default) if us
$fatalcsrf=false;
if (count($_POST) && !defined("NOCSRF")) {
if (csrf_check()<=0) {
$error=$err->errstr();
// We will trigger the error LATER in the code => need initialization of classes
$fatalcsrf=true;
}
@ -200,7 +200,6 @@ if (!defined('NOCHECK')) {
header('HTTP/1.0 401 Unauthorized');
exit();
}
$error = $err->errstr();
include("$root/admin/index.php");
exit();
}

View File

@ -68,7 +68,6 @@ class DB_Sql {
* @return the class variable $Link_ID
*/
function connect($Database = "", $Host = "", $User = "", $Password = "") {
global $err;
$this->halt('Mysql::connect() : This function should no longer be used');
/* Handle defaults */
if ("" == $Database)
@ -348,8 +347,8 @@ class DB_Sql {
/* public: return table metadata */
function metadata($table='',$full=false) {
global $err;
$err->raise('Mysql', 'function is no longer implemented (metadata())');
global $msg;
$msg->raise("Error", 'Mysql', 'function is no longer implemented (metadata())');
return FALSE;
}

View File

@ -848,16 +848,40 @@ function pager($offset, $count, $total, $url, $before = "", $after = "", $echo =
/**
*
* @param int $length
* @param int $classcount
* @return string
*/
function create_pass($length = 8) {
$chars = "1234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
$i = 0;
$password = "";
while ($i <= $length) {
$password .= @$chars{mt_rand(0, strlen($chars))};
$i++;
function create_pass($length = 10, $classcount = 3) {
$sets = array();
// Si classcount policy est 4 catégories différents, on utilise les 4 cat, sinon, on en utilise 3
if ($classcount < 4)
$available_sets='lud';
else
$available_sets='luds';
if(strpos($available_sets, 'l') !== false)
$sets[] = 'abcdefghijklmnopqrstuvwxyz';
if(strpos($available_sets, 'u') !== false)
$sets[] = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
if(strpos($available_sets, 'd') !== false)
$sets[] = '0123456789';
if(strpos($available_sets, 's') !== false)
$sets[] = '(!#$%)*+,-./:;<=>?@[\]^_';
$all = '';
$password = '';
foreach($sets as $set) {
$password .= $set[array_rand(str_split($set))];
$all .= $set;
}
$all = str_split($all);
for($i = 0; $i < $length - count($sets); $i++)
$password .= $all[array_rand($all)];
$password = str_shuffle($password);
return $password;
}