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

View File

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

View File

@ -848,16 +848,40 @@ function pager($offset, $count, $total, $url, $before = "", $after = "", $echo =
/** /**
* *
* @param int $length * @param int $length
* @param int $classcount
* @return string * @return string
*/ */
function create_pass($length = 8) { function create_pass($length = 10, $classcount = 3) {
$chars = "1234567890abcdefghijkmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; $sets = array();
$i = 0;
$password = ""; // Si classcount policy est 4 catégories différents, on utilise les 4 cat, sinon, on en utilise 3
while ($i <= $length) { if ($classcount < 4)
$password .= @$chars{mt_rand(0, strlen($chars))}; $available_sets='lud';
$i++; 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; return $password;
} }