REFACTORING: code formatting of the panel + braces on if/while/for + fixe some missing or too many Globals in functions
This commit is contained in:
parent
d4be9fddbf
commit
3e42567048
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id: config.php,v 1.12 2005/12/18 09:51:32 benjamin Exp $
|
$Id: config.php,v 1.12 2005/12/18 09:51:32 benjamin Exp $
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
@ -26,10 +27,12 @@
|
||||||
Original Author of file: Benjamin Sonntag
|
Original Author of file: Benjamin Sonntag
|
||||||
Purpose of file: General configuration file for AlternC Desktop
|
Purpose of file: General configuration file for AlternC Desktop
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('DO_XHPROF_STATS', FALSE);
|
define('DO_XHPROF_STATS', FALSE);
|
||||||
if (DO_XHPROF_STATS) require_once('/usr/share/alternc/panel/admin/xhprof_header.php');
|
if (DO_XHPROF_STATS) {
|
||||||
|
require_once('/usr/share/alternc/panel/admin/xhprof_header.php');
|
||||||
|
}
|
||||||
|
|
||||||
// To enable the display of the alternc debug error, do the following :
|
// To enable the display of the alternc debug error, do the following :
|
||||||
// # touch /etc/alternc/alternc_display_php_error
|
// # touch /etc/alternc/alternc_display_php_error
|
||||||
|
@ -42,15 +45,15 @@ session_start();
|
||||||
/*
|
/*
|
||||||
Si vous voulez mettre le bureau en maintenance, decommentez le code ci-dessous
|
Si vous voulez mettre le bureau en maintenance, decommentez le code ci-dessous
|
||||||
et mettez votre ip dans le IF pour que seule votre ip puisse acceder au bureau :
|
et mettez votre ip dans le IF pour que seule votre ip puisse acceder au bureau :
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* * /
|
/* * /
|
||||||
if (getenv("REMOTE_ADDR")!="127.0.0.1") {
|
if (getenv("REMOTE_ADDR")!="127.0.0.1") {
|
||||||
echo "Le bureau AlternC est en vacances jusqu'a minuit pour maintenance.<br>
|
echo "Le bureau AlternC est en vacances jusqu'a minuit pour maintenance.<br>
|
||||||
Merci de revenir plus tard.";
|
Merci de revenir plus tard.";
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
if (ini_get("safe_mode")) {
|
if (ini_get("safe_mode")) {
|
||||||
echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!";
|
echo "SAFE MODE IS ENABLED for the web panel ! It's a bug in your php or apache configuration, please fix it !!";
|
||||||
|
@ -58,7 +61,8 @@ if (ini_get("safe_mode")) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// For people who want to authenticate with HTTP AUTH
|
// For people who want to authenticate with HTTP AUTH
|
||||||
if (isset($_GET['http_auth'])) $http_auth=strval($_GET['http_auth']);
|
if (isset($_GET['http_auth']))
|
||||||
|
$http_auth = strval($_GET['http_auth']);
|
||||||
if (isset($http_auth)) {
|
if (isset($http_auth)) {
|
||||||
if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) {
|
if (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) {
|
||||||
header('WWW-Authenticate: Basic realm="AlternC Authentication"');
|
header('WWW-Authenticate: Basic realm="AlternC Authentication"');
|
||||||
|
@ -68,62 +72,62 @@ if (isset($http_auth)) {
|
||||||
}
|
}
|
||||||
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
|
if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) {
|
||||||
// Gruiiik
|
// Gruiiik
|
||||||
$_REQUEST["username"]=$_SERVER['PHP_AUTH_USER'];
|
$_REQUEST["username"] = $_SERVER['PHP_AUTH_USER'];
|
||||||
$_REQUEST["password"]=$_SERVER['PHP_AUTH_PW'];
|
$_REQUEST["password"] = $_SERVER['PHP_AUTH_PW'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// proper srand (not using time(), which is what PHP does!)
|
// proper srand (not using time(), which is what PHP does!)
|
||||||
list($usec, $sec) = explode(" ", microtime());
|
list($usec, $sec) = explode(" ", microtime());
|
||||||
srand($usec*1000000);
|
srand($usec * 1000000);
|
||||||
|
|
||||||
$help_baseurl="http://www.aide-alternc.org/";
|
$help_baseurl = "http://www.aide-alternc.org/";
|
||||||
|
|
||||||
/* Server Domain Name */
|
/* Server Domain Name */
|
||||||
$host=getenv("HTTP_HOST");
|
$host = getenv("HTTP_HOST");
|
||||||
|
|
||||||
/* Global variables (AlternC configuration) */
|
/* Global variables (AlternC configuration) */
|
||||||
require_once(dirname(__FILE__)."/local.php");
|
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", 8);
|
||||||
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)) {
|
||||||
define('ALTERNC_LOGS_ARCHIVE', "$L_ALTERNC_LOGS_ARCHIVE");
|
define('ALTERNC_LOGS_ARCHIVE', "$L_ALTERNC_LOGS_ARCHIVE");
|
||||||
|
}
|
||||||
define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
|
define('ALTERNC_LOGS', "$L_ALTERNC_LOGS");
|
||||||
define('ALTERNC_PANEL', "/usr/share/alternc/panel");
|
define('ALTERNC_PANEL', "/usr/share/alternc/panel");
|
||||||
define('ALTERNC_LOCALES', ALTERNC_PANEL."/locales");
|
define('ALTERNC_LOCALES', ALTERNC_PANEL . "/locales");
|
||||||
define('ALTERNC_LOCK_JOBS', '/var/run/alternc/jobs-lock');
|
define('ALTERNC_LOCK_JOBS', '/var/run/alternc/jobs-lock');
|
||||||
define('ALTERNC_LOCK_PANEL', '/var/lib/alternc/panel/nologin.lock');
|
define('ALTERNC_LOCK_PANEL', '/var/lib/alternc/panel/nologin.lock');
|
||||||
define('ALTERNC_APACHE2_GEN_TMPL_DIR', '/etc/alternc/templates/apache2/');
|
define('ALTERNC_APACHE2_GEN_TMPL_DIR', '/etc/alternc/templates/apache2/');
|
||||||
define('ALTERNC_VHOST_DIR',"/var/lib/alternc/apache-vhost/");
|
define('ALTERNC_VHOST_DIR', "/var/lib/alternc/apache-vhost/");
|
||||||
define('ALTERNC_VHOST_FILE',ALTERNC_VHOST_DIR."vhosts_all.conf");
|
define('ALTERNC_VHOST_FILE', ALTERNC_VHOST_DIR . "vhosts_all.conf");
|
||||||
define('ALTERNC_VHOST_MANUALCONF',ALTERNC_VHOST_DIR."manual/");
|
define('ALTERNC_VHOST_MANUALCONF', ALTERNC_VHOST_DIR . "manual/");
|
||||||
|
|
||||||
|
|
||||||
/* PHPLIB inclusions : */
|
/* PHPLIB inclusions : */
|
||||||
$root=ALTERNC_PANEL."/";
|
$root = ALTERNC_PANEL . "/";
|
||||||
|
|
||||||
require_once($root."/class/db_mysql.php");
|
require_once($root . "/class/db_mysql.php");
|
||||||
require_once($root."/class/functions.php");
|
require_once($root . "/class/functions.php");
|
||||||
require_once($root."/class/variables.php");
|
require_once($root . "/class/variables.php");
|
||||||
|
|
||||||
// Redirection si appel <20> https://(!fqdn)/
|
// Redirection si appel <20> https://(!fqdn)/
|
||||||
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on" && $host!=$L_FQDN) {
|
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == "on" && $host != $L_FQDN) {
|
||||||
header("Location: https://$L_FQDN/");
|
header("Location: https://$L_FQDN/");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// child class of the phplib parent DB class
|
||||||
// Classe h<>rit<69>e de la classe db de la phplib.
|
|
||||||
/**
|
/**
|
||||||
* Class for MySQL management in the bureau
|
* Class for MySQL management in the bureau
|
||||||
*
|
*
|
||||||
* This class heriting from the db class of the phplib manages
|
* This class heriting from the db class of the phplib manages
|
||||||
* the connection to the MySQL database.
|
* the connection to the MySQL database.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class DB_system extends DB_Sql {
|
class DB_system extends DB_Sql {
|
||||||
|
|
||||||
var $Host = null;
|
var $Host = null;
|
||||||
var $Database = null;
|
var $Database = null;
|
||||||
var $User = null;
|
var $User = null;
|
||||||
|
@ -133,48 +137,50 @@ class DB_system extends DB_Sql {
|
||||||
* Creator
|
* Creator
|
||||||
*/
|
*/
|
||||||
function DB_system() {
|
function DB_system() {
|
||||||
global $L_MYSQL_HOST,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$L_MYSQL_PWD;
|
global $L_MYSQL_HOST, $L_MYSQL_DATABASE, $L_MYSQL_LOGIN, $L_MYSQL_PWD;
|
||||||
$this->Host = $L_MYSQL_HOST;
|
$this->Host = $L_MYSQL_HOST;
|
||||||
$this->Database = $L_MYSQL_DATABASE;
|
$this->Database = $L_MYSQL_DATABASE;
|
||||||
$this->User = $L_MYSQL_LOGIN;
|
$this->User = $L_MYSQL_LOGIN;
|
||||||
$this->Password = $L_MYSQL_PWD;
|
$this->Password = $L_MYSQL_PWD;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
$db= new DB_system();
|
$db = new DB_system();
|
||||||
|
|
||||||
// Current User ID = the user whose commands are made on behalf of.
|
// Current User ID = the user whose commands are made on behalf of.
|
||||||
$cuid=0;
|
$cuid = 0;
|
||||||
|
|
||||||
|
|
||||||
$classes=array();
|
$classes = array();
|
||||||
/* CLASSES PHP : automatic include : */
|
/* CLASSES PHP : automatic include : */
|
||||||
foreach ( glob( $root."class/m_*.php") as $di ) {
|
foreach (glob($root . "class/m_*.php") as $di) {
|
||||||
if (preg_match("#${root}class/m_(.*)\\.php$#",$di,$match)) { // $
|
if (preg_match("#${root}class/m_(.*)\\.php$#", $di, $match)) { // $
|
||||||
$classes[]=$match[1];
|
$classes[] = $match[1];
|
||||||
require_once($di);
|
require_once($di);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* THE DEFAULT CLASSES ARE :
|
/* THE DEFAULT CLASSES ARE :
|
||||||
dom, ftp, mail, quota, bro, admin, mem, mysql, err, variables
|
dom, ftp, mail, quota, bro, admin, mem, mysql, err, variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Load file for the system class.
|
// Load file for the system class.
|
||||||
// Those class will not be build by default.
|
// Those class will not be build by default.
|
||||||
// They may contain forbidden action for the panel, for example: exec, system
|
// They may contain forbidden action for the panel, for example: exec, system
|
||||||
// or files operations
|
// or files operations
|
||||||
// We can imagine load those class only for command-line scripts.
|
// We can imagine load those class only for command-line scripts.
|
||||||
foreach ( glob( $root."class/class_system_*.php") as $fcs ) {
|
foreach (glob($root . "class/class_system_*.php") as $fcs) {
|
||||||
if (is_readable($fcs)) require_once($fcs);
|
if (is_readable($fcs))
|
||||||
|
require_once($fcs);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Language */
|
/* Language */
|
||||||
include_once("lang_env.php");
|
include_once("lang_env.php");
|
||||||
|
|
||||||
$mem=new m_mem();
|
$mem = new m_mem();
|
||||||
$err=new m_err();
|
$err = new m_err();
|
||||||
$authip=new m_authip();
|
$authip = new m_authip();
|
||||||
$hooks=new m_hooks();
|
$hooks = new m_hooks();
|
||||||
|
|
||||||
/* Check the User identity (if required) */
|
/* Check the User identity (if required) */
|
||||||
if (!defined('NOCHECK')) {
|
if (!defined('NOCHECK')) {
|
||||||
|
@ -184,34 +190,34 @@ if (!defined('NOCHECK')) {
|
||||||
header('HTTP/1.0 401 Unauthorized');
|
header('HTTP/1.0 401 Unauthorized');
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
$error=$err->errstr();
|
$error = $err->errstr();
|
||||||
include("$root/admin/index.php");
|
include("$root/admin/index.php");
|
||||||
exit();
|
exit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for($i=0;$i<count($classes);$i++) {
|
for ($i = 0; $i < count($classes); $i++) {
|
||||||
$name2=$classes[$i];
|
$name2 = $classes[$i];
|
||||||
if (isset($$name2)) continue; // for already instancied class like mem, err or authip
|
if (isset($$name2))
|
||||||
$name1="m_".$name2;
|
continue; // for already instancied class like mem, err or authip
|
||||||
$$name2= new $name1();
|
$name1 = "m_" . $name2;
|
||||||
|
$$name2 = new $name1();
|
||||||
}
|
}
|
||||||
|
|
||||||
$oldid=intval(isset($_COOKIE['oldid'])?$_COOKIE['oldid']:'');
|
$oldid = intval(isset($_COOKIE['oldid']) ? $_COOKIE['oldid'] : '');
|
||||||
$isinvited=false;
|
$isinvited = false;
|
||||||
if ($admin->enabled) $isinvited=true;
|
if ($admin->enabled)
|
||||||
|
$isinvited = true;
|
||||||
|
|
||||||
if ($oldid && $oldid!=$cuid) {
|
if ($oldid && $oldid != $cuid) {
|
||||||
$isinvited=true;
|
$isinvited = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
variable_get('aaa1', '','plop');
|
variable_get('aaa1', '', 'plop');
|
||||||
|
|
||||||
// Init some vars
|
// Init some vars
|
||||||
variable_get('hosting_tld', '','This is a FQDN that designates the main hostname of the service. For example, hosting_tld determines in what TLD the "free" user domain is created. If this is set to "example.com", a checkbox will appear in the user creation dialog requesting the creator if he wants to create the domain "username.example.com".', array('desc'=>'Wanted FQDN','type'=>'string'));
|
variable_get('hosting_tld', '', 'This is a FQDN that designates the main hostname of the service. For example, hosting_tld determines in what TLD the "free" user domain is created. If this is set to "example.com", a checkbox will appear in the user creation dialog requesting the creator if he wants to create the domain "username.example.com".', array('desc' => 'Wanted FQDN', 'type' => 'string'));
|
||||||
|
|
||||||
variable_get('subadmin_restriction', '0', "This variable set the way the account list works for accounts other than 'admin' (2000). 0 (default) = admin other than admin/2000 can see their own account, but not the other one 1 = admin other than admin/2000 can see any account by clicking the ''show all accounts'' link.", array('desc'=>'Shared access activated?','type'=>'boolean'));
|
variable_get('subadmin_restriction', '0', "This variable set the way the account list works for accounts other than 'admin' (2000). 0 (default) = admin other than admin/2000 can see their own account, but not the other one 1 = admin other than admin/2000 can see any account by clicking the ''show all accounts'' link.", array('desc' => 'Shared access activated?', 'type' => 'boolean'));
|
||||||
|
|
||||||
variable_get('auth_ip_ftp_default_yes', '1', "This variable set if you want to allow all IP address to access FTP by default. If the user start to define some IP or subnet in the allow list, only those he defined will be allowed.", array('desc'=>'Allow by default?','type'=>'boolean'));
|
variable_get('auth_ip_ftp_default_yes', '1', "This variable set if you want to allow all IP address to access FTP by default. If the user start to define some IP or subnet in the allow list, only those he defined will be allowed.", array('desc' => 'Allow by default?', 'type' => 'boolean'));
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id: config_nochk.php,v 1.2 2004/11/04 06:56:49 anonymous Exp $
|
$Id: config_nochk.php,v 1.2 2004/11/04 06:56:49 anonymous Exp $
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
@ -26,9 +27,8 @@
|
||||||
Original Author of file: Benjamin Sonntag
|
Original Author of file: Benjamin Sonntag
|
||||||
Purpose of file: General configuration file for AlternC Desktop
|
Purpose of file: General configuration file for AlternC Desktop
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('NOCHECK', 1);
|
define('NOCHECK', 1);
|
||||||
require_once("config.php");
|
require_once("config.php");
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -9,10 +9,9 @@
|
||||||
* $Id: db_mysql.php,v 1.3 2005/03/05 16:27:30 said Exp $
|
* $Id: db_mysql.php,v 1.3 2005/03/05 16:27:30 said Exp $
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
class DB_Sql {
|
class DB_Sql {
|
||||||
|
|
||||||
/* public: connection parameters */
|
/* public: connection parameters */
|
||||||
|
|
||||||
var $Host = "";
|
var $Host = "";
|
||||||
var $Database = "";
|
var $Database = "";
|
||||||
var $User = "";
|
var $User = "";
|
||||||
|
@ -42,8 +41,6 @@ class DB_Sql {
|
||||||
var $Query_ID = 0;
|
var $Query_ID = 0;
|
||||||
var $Query_String = "";
|
var $Query_String = "";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*/
|
*/
|
||||||
|
@ -79,35 +76,39 @@ class DB_Sql {
|
||||||
*/
|
*/
|
||||||
function connect($Database = "", $Host = "", $User = "", $Password = "") {
|
function connect($Database = "", $Host = "", $User = "", $Password = "") {
|
||||||
/* Handle defaults */
|
/* Handle defaults */
|
||||||
if ("" == $Database)
|
if ("" == $Database) {
|
||||||
$Database = $this->Database;
|
$Database = $this->Database;
|
||||||
if ("" == $Host)
|
}
|
||||||
|
if ("" == $Host) {
|
||||||
$Host = $this->Host;
|
$Host = $this->Host;
|
||||||
if ("" == $User)
|
}
|
||||||
|
if ("" == $User) {
|
||||||
$User = $this->User;
|
$User = $this->User;
|
||||||
if ("" == $Password)
|
}
|
||||||
|
if ("" == $Password) {
|
||||||
$Password = $this->Password;
|
$Password = $this->Password;
|
||||||
|
}
|
||||||
|
|
||||||
/* establish connection, select database */
|
/* establish connection, select database */
|
||||||
if ( 0 == $this->Link_ID ) {
|
if (0 == $this->Link_ID) {
|
||||||
|
|
||||||
$this->Link_ID=mysql_pconnect($Host, $User, $Password);
|
$this->Link_ID = mysql_pconnect($Host, $User, $Password);
|
||||||
if (!$this->Link_ID) {
|
if (!$this->Link_ID) {
|
||||||
$this->halt("pconnect($Host, $User, \$Password) failed.");
|
$this->halt("pconnect($Host, $User, \$Password) failed.");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!@mysql_select_db($Database,$this->Link_ID)) {
|
if (!@mysql_select_db($Database, $this->Link_ID)) {
|
||||||
$this->halt("cannot use database ".$this->Database);
|
$this->halt("cannot use database " . $this->Database);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//persistent connection don't conserve database selection
|
//persistent connection don't conserve database selection
|
||||||
//if needed do a correct database selection
|
//if needed do a correct database selection
|
||||||
$db_connected = @mysql_fetch_array(@mysql_query("SELECT DATABASE();",$this->Link_ID));
|
$db_connected = @mysql_fetch_array(@mysql_query("SELECT DATABASE();", $this->Link_ID));
|
||||||
if ($db_connected[0] != $this->Database)
|
if ($db_connected[0] != $this->Database)
|
||||||
mysql_select_db($Database,$this->Link_ID);
|
mysql_select_db($Database, $this->Link_ID);
|
||||||
|
|
||||||
return $this->Link_ID;
|
return $this->Link_ID;
|
||||||
}
|
}
|
||||||
|
@ -134,16 +135,17 @@ class DB_Sql {
|
||||||
global $debug_alternc;
|
global $debug_alternc;
|
||||||
|
|
||||||
/* No empty queries, please, since PHP4 chokes on them. */
|
/* No empty queries, please, since PHP4 chokes on them. */
|
||||||
if ($Query_String == "")
|
if ($Query_String == "") {
|
||||||
/* The empty query string is passed on from the constructor,
|
/* The empty query string is passed on from the constructor,
|
||||||
* when calling the class without a query, e.g. in situations
|
* when calling the class without a query, e.g. in situations
|
||||||
* like these: '$db = new DB_Sql_Subclass;'
|
* like these: '$db = new DB_Sql_Subclass;'
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
if (!$this->connect()) {
|
if (!$this->connect()) {
|
||||||
return 0; /* we already complained in connect() about that. */
|
return 0; /* we already complained in connect() about that. */
|
||||||
};
|
}
|
||||||
|
|
||||||
# New query, discard previous result.
|
# New query, discard previous result.
|
||||||
if ($this->Query_ID) {
|
if ($this->Query_ID) {
|
||||||
|
@ -151,28 +153,29 @@ class DB_Sql {
|
||||||
$this->Query_String = $Query_String;
|
$this->Query_String = $Query_String;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($this->Debug)
|
if ($this->Debug) {
|
||||||
printf("Debug: query = %s<br />\n", $Query_String);
|
printf("Debug: query = %s<br />\n", $Query_String);
|
||||||
|
}
|
||||||
|
|
||||||
$debug_chrono_start = microtime(true);
|
$debug_chrono_start = microtime(true);
|
||||||
$this->Query_ID = @mysql_query($Query_String,$this->Link_ID);
|
$this->Query_ID = @mysql_query($Query_String, $this->Link_ID);
|
||||||
$debug_chrono_start = (microtime(true) - $debug_chrono_start)*1000;
|
$debug_chrono_start = (microtime(true) - $debug_chrono_start) * 1000;
|
||||||
$this->Row = 0;
|
$this->Row = 0;
|
||||||
$this->Errno = mysql_errno();
|
$this->Errno = mysql_errno();
|
||||||
$this->Error = mysql_error();
|
$this->Error = mysql_error();
|
||||||
if( 0 != $this->Errno ){
|
if (0 != $this->Errno) {
|
||||||
if( defined("THROW_EXCEPTIONS") && THROW_EXCEPTIONS ){
|
if (defined("THROW_EXCEPTIONS") && THROW_EXCEPTIONS) {
|
||||||
throw new \Exception("Mysql query failed : $this->Error");
|
throw new \Exception("Mysql query failed : $this->Error");
|
||||||
}
|
}
|
||||||
$this->halt("SQL Error: ".$Query_String);
|
$this->halt("SQL Error: " . $Query_String);
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (!$this->Query_ID) {
|
if (!$this->Query_ID) {
|
||||||
$this->halt("Invalid SQL: ".$Query_String);
|
$this->halt("Invalid SQL: " . $Query_String);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset($debug_alternc)) {
|
if (isset($debug_alternc)) {
|
||||||
$debug_alternc->add("SQL Query : (".substr($debug_chrono_start,0,5)." ms)\t $Query_String");
|
$debug_alternc->add("SQL Query : (" . substr($debug_chrono_start, 0, 5) . " ms)\t $Query_String");
|
||||||
$debug_alternc->nb_sql_query++;
|
$debug_alternc->nb_sql_query++;
|
||||||
$debug_alternc->tps_sql_query += $debug_chrono_start;
|
$debug_alternc->tps_sql_query += $debug_chrono_start;
|
||||||
}
|
}
|
||||||
|
@ -211,13 +214,12 @@ class DB_Sql {
|
||||||
*
|
*
|
||||||
* public: position in result set
|
* public: position in result set
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function seek($pos = 0) {
|
function seek($pos = 0) {
|
||||||
$status = @mysql_data_seek($this->Query_ID, $pos);
|
$status = @mysql_data_seek($this->Query_ID, $pos);
|
||||||
if ($status)
|
if ($status) {
|
||||||
$this->Row = $pos;
|
$this->Row = $pos;
|
||||||
else {
|
} else {
|
||||||
$this->halt("seek($pos) failed: result has ".$this->num_rows()." rows");
|
$this->halt("seek($pos) failed: result has " . $this->num_rows() . " rows");
|
||||||
|
|
||||||
/* half assed attempt to save the day,
|
/* half assed attempt to save the day,
|
||||||
* but do not consider this documented or even
|
* but do not consider this documented or even
|
||||||
|
@ -231,20 +233,20 @@ class DB_Sql {
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: table locking */
|
/** public: table locking */
|
||||||
function lock($table, $mode="write") {
|
function lock($table, $mode = "write") {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
$query="lock tables ";
|
$query = "lock tables ";
|
||||||
if (is_array($table)) {
|
if (is_array($table)) {
|
||||||
while (list($key,$value)=each($table)) {
|
while (list($key, $value) = each($table)) {
|
||||||
if ($key=="read" && $key!=0) {
|
if ($key == "read" && $key != 0) {
|
||||||
$query.="$value read, ";
|
$query.="$value read, ";
|
||||||
} else {
|
} else {
|
||||||
$query.="$value $mode, ";
|
$query.="$value $mode, ";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$query=substr($query,0,-2);
|
$query = substr($query, 0, -2);
|
||||||
} else {
|
} else {
|
||||||
$query.="$table $mode";
|
$query.="$table $mode";
|
||||||
}
|
}
|
||||||
|
@ -267,8 +269,7 @@ class DB_Sql {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** public: evaluate the result (size, width) */
|
||||||
/* public: evaluate the result (size, width) */
|
|
||||||
function affected_rows() {
|
function affected_rows() {
|
||||||
return @mysql_affected_rows($this->Link_ID);
|
return @mysql_affected_rows($this->Link_ID);
|
||||||
}
|
}
|
||||||
|
@ -281,7 +282,7 @@ class DB_Sql {
|
||||||
return @mysql_num_fields($this->Query_ID);
|
return @mysql_num_fields($this->Query_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: shorthand notation */
|
/** public: shorthand notation */
|
||||||
function nf() {
|
function nf() {
|
||||||
return $this->num_rows();
|
return $this->num_rows();
|
||||||
}
|
}
|
||||||
|
@ -309,45 +310,37 @@ class DB_Sql {
|
||||||
return @mysql_insert_id($this->Link_ID);
|
return @mysql_insert_id($this->Link_ID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: sequence numbers */
|
/** public: sequence numbers */
|
||||||
function nextid($seq_name) {
|
function nextid($seq_name) {
|
||||||
$this->connect();
|
$this->connect();
|
||||||
|
|
||||||
if ($this->lock($this->Seq_Table)) {
|
if ($this->lock($this->Seq_Table)) {
|
||||||
/* get sequence number (locked) and increment */
|
/* get sequence number (locked) and increment */
|
||||||
$q = sprintf("select nextid from %s where seq_name = '%s'",
|
$q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name);
|
||||||
$this->Seq_Table,
|
|
||||||
$seq_name);
|
|
||||||
$id = @mysql_query($q, $this->Link_ID);
|
$id = @mysql_query($q, $this->Link_ID);
|
||||||
$res = @mysql_fetch_array($id);
|
$res = @mysql_fetch_array($id);
|
||||||
|
|
||||||
/* No current value, make one */
|
/* No current value, make one */
|
||||||
if (!is_array($res)) {
|
if (!is_array($res)) {
|
||||||
$currentid = 0;
|
$currentid = 0;
|
||||||
$q = sprintf("insert into %s values('%s', %s)",
|
$q = sprintf("insert into %s values('%s', %s)", $this->Seq_Table, $seq_name, $currentid);
|
||||||
$this->Seq_Table,
|
|
||||||
$seq_name,
|
|
||||||
$currentid);
|
|
||||||
@mysql_query($q, $this->Link_ID);
|
@mysql_query($q, $this->Link_ID);
|
||||||
} else {
|
} else {
|
||||||
$currentid = $res["nextid"];
|
$currentid = $res["nextid"];
|
||||||
}
|
}
|
||||||
$nextid = $currentid + 1;
|
$nextid = $currentid + 1;
|
||||||
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
|
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'", $this->Seq_Table, $nextid, $seq_name);
|
||||||
$this->Seq_Table,
|
|
||||||
$nextid,
|
|
||||||
$seq_name);
|
|
||||||
@mysql_query($q, $this->Link_ID);
|
@mysql_query($q, $this->Link_ID);
|
||||||
$this->unlock();
|
$this->unlock();
|
||||||
} else {
|
} else {
|
||||||
$this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
|
$this->halt("cannot lock " . $this->Seq_Table . " - has it been created?");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
return $nextid;
|
return $nextid;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* public: return table metadata */
|
/** public: return table metadata */
|
||||||
function metadata($table='',$full=false) {
|
function metadata($table = '', $full = false) {
|
||||||
$res = array();
|
$res = array();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -393,72 +386,34 @@ class DB_Sql {
|
||||||
|
|
||||||
// made this IF due to performance (one if is faster than $count if's)
|
// made this IF due to performance (one if is faster than $count if's)
|
||||||
if (!$full) {
|
if (!$full) {
|
||||||
for ($i=0; $i<$count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$res[$i]["table"] = @mysql_field_table ($id, $i);
|
$res[$i]["table"] = @mysql_field_table($id, $i);
|
||||||
$res[$i]["name"] = @mysql_field_name ($id, $i);
|
$res[$i]["name"] = @mysql_field_name($id, $i);
|
||||||
$res[$i]["type"] = @mysql_field_type ($id, $i);
|
$res[$i]["type"] = @mysql_field_type($id, $i);
|
||||||
$res[$i]["len"] = @mysql_field_len ($id, $i);
|
$res[$i]["len"] = @mysql_field_len($id, $i);
|
||||||
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
|
$res[$i]["flags"] = @mysql_field_flags($id, $i);
|
||||||
}
|
}
|
||||||
} else { // full
|
} else { // full
|
||||||
$res["num_fields"]= $count;
|
$res["num_fields"] = $count;
|
||||||
|
|
||||||
for ($i=0; $i<$count; $i++) {
|
for ($i = 0; $i < $count; $i++) {
|
||||||
$res[$i]["table"] = @mysql_field_table ($id, $i);
|
$res[$i]["table"] = @mysql_field_table($id, $i);
|
||||||
$res[$i]["name"] = @mysql_field_name ($id, $i);
|
$res[$i]["name"] = @mysql_field_name($id, $i);
|
||||||
$res[$i]["type"] = @mysql_field_type ($id, $i);
|
$res[$i]["type"] = @mysql_field_type($id, $i);
|
||||||
$res[$i]["len"] = @mysql_field_len ($id, $i);
|
$res[$i]["len"] = @mysql_field_len($id, $i);
|
||||||
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
|
$res[$i]["flags"] = @mysql_field_flags($id, $i);
|
||||||
$res["meta"][$res[$i]["name"]] = $i;
|
$res["meta"][$res[$i]["name"]] = $i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// free the result only if we were called on a table
|
// free the result only if we were called on a table
|
||||||
if ($table) @mysql_free_result($id);
|
if ($table) {
|
||||||
|
@mysql_free_result($id);
|
||||||
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/********************************************************************************************************/
|
/** private: error handling */
|
||||||
// AJOUT PERSO : TEST
|
|
||||||
|
|
||||||
/* public: return table metadata
|
|
||||||
function retourneNameField($this->Query_ID,$full=false) {
|
|
||||||
$count = 0;
|
|
||||||
$id = 0;
|
|
||||||
$res = array();
|
|
||||||
|
|
||||||
|
|
||||||
$count = @mysql_num_fields($this->Query_ID);
|
|
||||||
|
|
||||||
// made this IF due to performance (one if is faster than $count if's)
|
|
||||||
if (!$full) {
|
|
||||||
for ($i=0; $i<$count; $i++) {
|
|
||||||
$res[$i]["table"] = @mysql_field_table ($id, $i);
|
|
||||||
$res[$i]["name"] = @mysql_field_name ($id, $i);
|
|
||||||
$res[$i]["type"] = @mysql_field_type ($id, $i);
|
|
||||||
$res[$i]["len"] = @mysql_field_len ($id, $i);
|
|
||||||
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
|
|
||||||
}
|
|
||||||
} else { // full
|
|
||||||
$res["num_fields"]= $count;
|
|
||||||
|
|
||||||
for ($i=0; $i<$count; $i++) {
|
|
||||||
$res[$i]["table"] = @mysql_field_table ($id, $i);
|
|
||||||
$res[$i]["name"] = @mysql_field_name ($id, $i);
|
|
||||||
$res[$i]["type"] = @mysql_field_type ($id, $i);
|
|
||||||
$res[$i]["len"] = @mysql_field_len ($id, $i);
|
|
||||||
$res[$i]["flags"] = @mysql_field_flags ($id, $i);
|
|
||||||
$res["meta"][$res[$i]["name"]] = $i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// free the result only if we were called on a table
|
|
||||||
if ($table) @mysql_free_result($id);
|
|
||||||
return $res;
|
|
||||||
}*/
|
|
||||||
|
|
||||||
/********************************************************************************************************/
|
|
||||||
/* private: error handling */
|
|
||||||
function halt($msg) {
|
function halt($msg) {
|
||||||
$this->Error = @mysql_error($this->Link_ID);
|
$this->Error = @mysql_error($this->Link_ID);
|
||||||
$this->Errno = @mysql_errno($this->Link_ID);
|
$this->Errno = @mysql_errno($this->Link_ID);
|
||||||
|
@ -467,29 +422,27 @@ class DB_Sql {
|
||||||
|
|
||||||
$this->haltmsg($msg);
|
$this->haltmsg($msg);
|
||||||
|
|
||||||
if ($this->Halt_On_Error != "report")
|
if ($this->Halt_On_Error != "report") {
|
||||||
die("Session halted.");
|
die("Session halted.");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function haltmsg($msg) {
|
function haltmsg($msg) {
|
||||||
printf("</td></tr></table><b>Database error:</b> %s<br />\n", $msg);
|
printf("</td></tr></table><b>Database error:</b> %s<br />\n", $msg);
|
||||||
printf("<b>MySQL Error</b>: %s (%s)<br />\n",
|
printf("<b>MySQL Error</b>: %s (%s)<br />\n", $this->Errno, $this->Error);
|
||||||
$this->Errno,
|
|
||||||
$this->Error);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function table_names() {
|
function table_names() {
|
||||||
$this->query("SHOW TABLES");
|
$this->query("SHOW TABLES");
|
||||||
$i=0;
|
$i = 0;
|
||||||
$return=array();
|
$return = array();
|
||||||
while ($info=mysql_fetch_row($this->Query_ID))
|
while ($info = mysql_fetch_row($this->Query_ID)) {
|
||||||
{
|
$return[$i]["table_name"] = $info[0];
|
||||||
$return[$i]["table_name"]= $info[0];
|
$return[$i]["tablespace_name"] = $this->Database;
|
||||||
$return[$i]["tablespace_name"]=$this->Database;
|
$return[$i]["database"] = $this->Database;
|
||||||
$return[$i]["database"]=$this->Database;
|
|
||||||
$i++;
|
$i++;
|
||||||
}
|
}
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
$lang_translation=array( # If you comment lang here, it won't be displayed.
|
$lang_translation = array(# If you comment lang here, it won't be displayed.
|
||||||
"fr_FR" => "Français",
|
"fr_FR" => "Français",
|
||||||
"en_US" => "English",
|
"en_US" => "English",
|
||||||
# "es_ES" => "Español",
|
# "es_ES" => "Español",
|
||||||
|
@ -8,34 +8,38 @@ $lang_translation=array( # If you comment lang here, it won't be displayed.
|
||||||
# "de_DE" => "Deutsch",
|
# "de_DE" => "Deutsch",
|
||||||
# "pt_BR" => "Portuguese",
|
# "pt_BR" => "Portuguese",
|
||||||
"nl_NL" => "Dutch",
|
"nl_NL" => "Dutch",
|
||||||
);
|
);
|
||||||
|
|
||||||
global $arr_lang_translation ;
|
global $arr_lang_translation;
|
||||||
$arr_lang_translation = $lang_translation; // not pretty but I don't want side effect right now
|
$arr_lang_translation = $lang_translation; // not pretty but I don't want side effect right now
|
||||||
|
|
||||||
function update_locale($langpath) {
|
function update_locale($langpath) {
|
||||||
global $arr_lang_translation;
|
global $arr_lang_translation;
|
||||||
$locales=array();
|
$locales = array();
|
||||||
$file=file("/etc/locale.gen", FILE_SKIP_EMPTY_LINES);
|
$file = file("/etc/locale.gen", FILE_SKIP_EMPTY_LINES);
|
||||||
if (! is_array($file) ) return $locales;
|
if (!is_array($file)) {
|
||||||
foreach ($file as $v ) {
|
return $locales;
|
||||||
if ( (preg_match("/^([a-z][a-z]_[A-Z][A-Z])/",trim($v),$mat) && file_exists($langpath . '/' . $mat[1]) ) ) {
|
}
|
||||||
if (! array_key_exists($mat[1], $arr_lang_translation) ) continue;
|
foreach ($file as $v) {
|
||||||
$locales[$mat[1]]=$mat[1];
|
if ((preg_match("/^([a-z][a-z]_[A-Z][A-Z])/", trim($v), $mat) && file_exists($langpath . '/' . $mat[1]))) {
|
||||||
|
if (!array_key_exists($mat[1], $arr_lang_translation)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
$locales[$mat[1]] = $mat[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!count($locales)) {
|
if (!count($locales)) {
|
||||||
$locales=array("en_US"=>"en_US");
|
$locales = array("en_US" => "en_US");
|
||||||
}
|
}
|
||||||
return $locales;
|
return $locales;
|
||||||
}
|
}
|
||||||
|
|
||||||
// setlang is on the link at the login page
|
// setlang is on the link at the login page
|
||||||
if (isset($_REQUEST["setlang"])) {
|
if (isset($_REQUEST["setlang"])) {
|
||||||
$lang=$_REQUEST["setlang"];
|
$lang = $_REQUEST["setlang"];
|
||||||
$setlang=$_REQUEST["setlang"];
|
$setlang = $_REQUEST["setlang"];
|
||||||
} elseif (isset($_COOKIE['lang'])) {
|
} elseif (isset($_COOKIE['lang'])) {
|
||||||
$lang=$_COOKIE['lang'];
|
$lang = $_COOKIE['lang'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$langpath = bindtextdomain("alternc", ALTERNC_LOCALES);
|
$langpath = bindtextdomain("alternc", ALTERNC_LOCALES);
|
||||||
|
@ -45,29 +49,30 @@ $locales = update_locale($langpath);
|
||||||
|
|
||||||
// Default to en_US :
|
// Default to en_US :
|
||||||
if (!isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
|
if (!isset($_SERVER["HTTP_ACCEPT_LANGUAGE"])) {
|
||||||
$_SERVER["HTTP_ACCEPT_LANGUAGE"]="en_US";
|
$_SERVER["HTTP_ACCEPT_LANGUAGE"] = "en_US";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(isset($lang))) { // Use the browser first preferred language
|
if (!(isset($lang))) { // Use the browser first preferred language
|
||||||
$lang=strtolower(substr(trim($_SERVER["HTTP_ACCEPT_LANGUAGE"]),0,5));
|
$lang = strtolower(substr(trim($_SERVER["HTTP_ACCEPT_LANGUAGE"]), 0, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (! isset($locales[$lang])) { // Requested language not found in locales
|
if (!isset($locales[$lang])) { // Requested language not found in locales
|
||||||
// treat special cases such as en_AU or fr_BF : use the language only, not the country.
|
// treat special cases such as en_AU or fr_BF : use the language only, not the country.
|
||||||
$ll=substr($lang,0,2);
|
$ll = substr($lang, 0, 2);
|
||||||
foreach($locales as $l) {
|
foreach ($locales as $l) {
|
||||||
if (substr($l,0,2)==$ll) {
|
if (substr($l, 0, 2) == $ll) {
|
||||||
$lang=$l;
|
$lang = $l;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isset($locales[$lang])) list($lang)=each($locales);
|
if (!isset($locales[$lang])) {
|
||||||
|
list($lang) = each($locales);
|
||||||
|
}
|
||||||
if (isset($setlang) && isset($lang)) {
|
if (isset($setlang) && isset($lang)) {
|
||||||
setcookie("lang",$lang);
|
setcookie("lang", $lang);
|
||||||
}
|
}
|
||||||
|
|
||||||
// User chose a non existent language, select the first available one
|
// User chose a non existent language, select the first available one
|
||||||
|
@ -76,18 +81,18 @@ if ($lang == NULL) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Language ok, set the locale environment */
|
/* Language ok, set the locale environment */
|
||||||
putenv("LC_MESSAGES=".$lang);
|
putenv("LC_MESSAGES=" . $lang);
|
||||||
putenv("LANG=".$lang);
|
putenv("LANG=" . $lang);
|
||||||
putenv("LANGUAGE=".$lang);
|
putenv("LANGUAGE=" . $lang);
|
||||||
// this locale MUST be selected in "dpkg-reconfigure locales"
|
// this locale MUST be selected in "dpkg-reconfigure locales"
|
||||||
setlocale(LC_ALL,$lang);
|
setlocale(LC_ALL, $lang);
|
||||||
textdomain("alternc");
|
textdomain("alternc");
|
||||||
|
|
||||||
$empty="";
|
$empty = "";
|
||||||
if (_($empty) && preg_match("#charset=([A-Za-z0-9\.-]*)#",_($empty),$mat)) {
|
if (_($empty) && preg_match("#charset=([A-Za-z0-9\.-]*)#", _($empty), $mat)) {
|
||||||
$charset=$mat[1];
|
$charset = $mat[1];
|
||||||
}
|
}
|
||||||
if (! isset($charset) || !$charset) $charset="UTF-8";
|
if (!isset($charset) || !$charset) {
|
||||||
bind_textdomain_codeset("alternc","$charset");
|
$charset = "UTF-8";
|
||||||
|
}
|
||||||
?>
|
bind_textdomain_codeset("alternc", "$charset");
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* Read global variables (AlternC configuration) */
|
/* Read global variables (AlternC configuration) */
|
||||||
$L_VERSION="@@REPLACED_DURING_BUILD@@";
|
$L_VERSION = "@@REPLACED_DURING_BUILD@@";
|
||||||
|
|
||||||
// To be able to have displayer version != help version
|
// To be able to have displayer version != help version
|
||||||
// (usefull during RC, etc...)
|
// (usefull during RC, etc...)
|
||||||
$L_VERSION_HELP="3.0";
|
$L_VERSION_HELP = "3.0";
|
||||||
|
|
||||||
/* To ease the transition, we define a lookup table for old names */
|
/* To ease the transition, we define a lookup table for old names */
|
||||||
$compat = array('DEFAULT_MX' => 'MX',
|
$compat = array('DEFAULT_MX' => 'MX',
|
||||||
|
@ -18,9 +18,9 @@ $compat = array('DEFAULT_MX' => 'MX',
|
||||||
$config_file = fopen('/etc/alternc/local.sh', 'r');
|
$config_file = fopen('/etc/alternc/local.sh', 'r');
|
||||||
while (FALSE !== ($line = fgets($config_file))) {
|
while (FALSE !== ($line = fgets($config_file))) {
|
||||||
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
|
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
|
||||||
$GLOBALS['L_'.$regs[1]] = $regs[2];
|
$GLOBALS['L_' . $regs[1]] = $regs[2];
|
||||||
if (isset($compat[$regs[1]])) {
|
if (isset($compat[$regs[1]])) {
|
||||||
$GLOBALS['L_'.$compat[$regs[1]]] = $regs[2];
|
$GLOBALS['L_' . $compat[$regs[1]]] = $regs[2];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@ while (FALSE !== ($line = fgets($config_file))) {
|
||||||
fclose($config_file);
|
fclose($config_file);
|
||||||
|
|
||||||
$config_file = fopen('/etc/alternc/my.cnf', 'r');
|
$config_file = fopen('/etc/alternc/my.cnf', 'r');
|
||||||
while (FALSE !== ($line = fgets($config_file))) {
|
while (false!== ($line = fgets($config_file))) {
|
||||||
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
|
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
|
||||||
switch ($regs[1]) {
|
switch ($regs[1]) {
|
||||||
case "user":
|
case "user":
|
||||||
|
@ -48,4 +48,3 @@ while (FALSE !== ($line = fgets($config_file))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($config_file);
|
fclose($config_file);
|
||||||
?>
|
|
||||||
|
|
|
@ -50,7 +50,7 @@ class m_action {
|
||||||
function do_action() {
|
function do_action() {
|
||||||
global $err, $L_INOTIFY_DO_ACTION;
|
global $err, $L_INOTIFY_DO_ACTION;
|
||||||
$err->log("action", "do_action");
|
$err->log("action", "do_action");
|
||||||
if( ! @touch($L_INOTIFY_DO_ACTION) ){
|
if (!@touch($L_INOTIFY_DO_ACTION)) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -77,7 +77,7 @@ class m_action {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function chmod($filename, $perms, $user = "root") {
|
function chmod($filename, $perms, $user = "root") {
|
||||||
return $this->set('chmod', $user, array('filename' => $filename,"perms"=>$perms));
|
return $this->set('chmod', $user, array('filename' => $filename, "perms" => $perms));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -243,11 +243,11 @@ class m_action {
|
||||||
|
|
||||||
$purge = "select * from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
|
$purge = "select * from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
|
||||||
$result = $db->query($purge);
|
$result = $db->query($purge);
|
||||||
if (! $result) {
|
if (!$result) {
|
||||||
$err->raise("action", _("Error selecting old actions"));
|
$err->raise("action", _("Error selecting old actions"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $db->num_rows($result) ;
|
return $db->num_rows($result);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -265,12 +265,11 @@ class m_action {
|
||||||
$purge = "delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
|
$purge = "delete from actions where TO_DAYS(curdate()) - TO_DAYS(creation) > 2;";
|
||||||
}
|
}
|
||||||
$result = $db->query($purge);
|
$result = $db->query($purge);
|
||||||
if (! $result) {
|
if (!$result) {
|
||||||
$err->raise("action", _("Error purging old actions"));
|
$err->raise("action", _("Error purging old actions"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return $db->num_rows($result) ;
|
return $db->num_rows($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -352,7 +351,7 @@ class m_action {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function get_job() {
|
function get_job() {
|
||||||
global $db, $err;
|
global $db;
|
||||||
$tab = array();
|
$tab = array();
|
||||||
$db->query("Select * from actions where begin !=0 and end = 0 ;");
|
$db->query("Select * from actions where begin !=0 and end = 0 ;");
|
||||||
if ($db->next_record()) {
|
if ($db->next_record()) {
|
||||||
|
@ -371,7 +370,6 @@ class m_action {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function cancel($id) {
|
function cancel($id) {
|
||||||
global $db;
|
|
||||||
$this->finish($id, 666);
|
$this->finish($id, 666);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -79,9 +79,9 @@ class m_admin {
|
||||||
*/
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $mem, $cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN;
|
global $mem, $cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN;
|
||||||
if (!$mem->checkRight())
|
if (!$mem->checkRight()) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Administration"),
|
'title' => _("Administration"),
|
||||||
'ico' => 'images/admin.png',
|
'ico' => 'images/admin.png',
|
||||||
|
@ -343,38 +343,36 @@ class m_admin {
|
||||||
|
|
||||||
$request = 'SELECT compte AS uid FROM domaines WHERE 1';
|
$request = 'SELECT compte AS uid FROM domaines WHERE 1';
|
||||||
|
|
||||||
if ($pattern && preg_match('/[.a-zA-Z0-9]+/', $pattern))
|
if ($pattern && preg_match('/[.a-zA-Z0-9]+/', $pattern)) {
|
||||||
$request .= sprintf(' AND domaine LIKE "%%%s%%"', $pattern);
|
$request .= sprintf(' AND domaine LIKE "%%%s%%"', $pattern);
|
||||||
|
}
|
||||||
if ($creator)
|
if ($creator) {
|
||||||
$request .= sprintf(' AND compte in (select uid from membres where creator = "%s" ) ', $creator);
|
$request .= sprintf(' AND compte in (select uid from membres where creator = "%s" ) ', $creator);
|
||||||
|
}
|
||||||
if ($mem->user['uid'] != 2000 && !$all)
|
if ($mem->user['uid'] != 2000 && !$all) {
|
||||||
$request .= sprintf(' AND compte in (select uid from membres where creator = "%s") ', $cuid);
|
$request .= sprintf(' AND compte in (select uid from membres where creator = "%s") ', $cuid);
|
||||||
|
}
|
||||||
|
|
||||||
$request .= ' GROUP BY uid';
|
$request .= ' GROUP BY uid';
|
||||||
} elseif ($pattern_type === 'login') {
|
} elseif ($pattern_type === 'login') {
|
||||||
|
|
||||||
$request = 'SELECT uid FROM membres WHERE 1';
|
$request = 'SELECT uid FROM membres WHERE 1';
|
||||||
|
|
||||||
if ($pattern && preg_match('/[a-zA-Z0-9]+/', $pattern))
|
if ($pattern && preg_match('/[a-zA-Z0-9]+/', $pattern)) {
|
||||||
$request .= sprintf(' AND login LIKE "%%%s%%"', $pattern);
|
$request .= sprintf(' AND login LIKE "%%%s%%"', $pattern);
|
||||||
|
}
|
||||||
if ($creator)
|
if ($creator) {
|
||||||
$request .= sprintf(' AND creator = "%s"', $creator);
|
$request .= sprintf(' AND creator = "%s"', $creator);
|
||||||
|
}
|
||||||
if ($mem->user['uid'] != 2000 && !$all)
|
if ($mem->user['uid'] != 2000 && !$all) {
|
||||||
$request .= sprintf(' AND creator = "%s"', $cuid);
|
$request .= sprintf(' AND creator = "%s"', $cuid);
|
||||||
|
}
|
||||||
$request .= ' ORDER BY login;';
|
$request .= ' ORDER BY login;';
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
$err->raise("admin", _("Invalid pattern type provided. Are you even performing a legitimate action?"));
|
$err->raise("admin", _("Invalid pattern type provided. Are you even performing a legitimate action?"));
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if ($creator) {
|
if ($creator) {
|
||||||
// Limit listing to a specific reseller
|
// Limit listing to a specific reseller
|
||||||
$request = "SELECT uid FROM membres WHERE creator='" . $creator . "' ORDER BY login;";
|
$request = "SELECT uid FROM membres WHERE creator='" . $creator . "' ORDER BY login;";
|
||||||
|
@ -411,7 +409,7 @@ class m_admin {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function mailallmembers($subject, $message, $from) {
|
function mailallmembers($subject, $message, $from) {
|
||||||
global $err, $mem, $cuid, $db;
|
global $err, $db;
|
||||||
$err->log("admin", "mailallmembers");
|
$err->log("admin", "mailallmembers");
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
$err->raise("admin", _("-- Only administrators can access this page! --"));
|
$err->raise("admin", _("-- Only administrators can access this page! --"));
|
||||||
|
@ -453,7 +451,7 @@ class m_admin {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function get_creator_list() {
|
function get_creator_list() {
|
||||||
global $err, $mem, $cuid;
|
global $err, $cuid;
|
||||||
|
|
||||||
$creators = array();
|
$creators = array();
|
||||||
|
|
||||||
|
@ -488,7 +486,7 @@ class m_admin {
|
||||||
* @return boolean TRUE if I am the creator of that account. FALSE else.
|
* @return boolean TRUE if I am the creator of that account. FALSE else.
|
||||||
*/
|
*/
|
||||||
function checkcreator($uid) {
|
function checkcreator($uid) {
|
||||||
global $err, $mem, $db, $cuid;
|
global $err, $db, $cuid;
|
||||||
if ($cuid == 2000) {
|
if ($cuid == 2000) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -514,7 +512,7 @@ class m_admin {
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
function add_shared_domain($u, $domain_name) {
|
function add_shared_domain($u, $domain_name) {
|
||||||
global $db, $err, $dom, $mem, $cuid;
|
global $err, $dom, $mem;
|
||||||
$err->log("admin", "add_shared_domain", $u . "/" . $domain_name);
|
$err->log("admin", "add_shared_domain", $u . "/" . $domain_name);
|
||||||
|
|
||||||
if (!$mem->checkright()) {
|
if (!$mem->checkright()) {
|
||||||
|
@ -575,7 +573,7 @@ class m_admin {
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||||
*/
|
*/
|
||||||
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass = 1, $type = 'default', $duration = 0, $notes = "", $force = 0, $create_dom = '', $db_server_id) {
|
function add_mem($login, $pass, $nom, $prenom, $mail, $canpass = 1, $type = 'default', $duration = 0, $notes = "", $force = 0, $create_dom = '', $db_server_id) {
|
||||||
global $err, $quota, $classes, $cuid, $mem, $L_MYSQL_DATABASE, $L_MYSQL_LOGIN, $hooks, $action;
|
global $err, $cuid, $mem, $L_MYSQL_DATABASE, $L_MYSQL_LOGIN, $hooks, $action;
|
||||||
$err->log("admin", "add_mem", $login . "/" . $mail);
|
$err->log("admin", "add_mem", $login . "/" . $mail);
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
$err->raise("admin", _("-- Only administrators can access this page! --"));
|
$err->raise("admin", _("-- Only administrators can access this page! --"));
|
||||||
|
@ -629,9 +627,10 @@ class m_admin {
|
||||||
$uid = 2000;
|
$uid = 2000;
|
||||||
} else {
|
} else {
|
||||||
$uid = $db->Record["nextid"];
|
$uid = $db->Record["nextid"];
|
||||||
if ($uid <= 2000)
|
if ($uid <= 2000) {
|
||||||
$uid = 2000;
|
$uid = 2000;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');");
|
$db->query("INSERT INTO membres (uid,login,pass,mail,creator,canpass,type,created,notes,db_server_id) VALUES ('$uid','$login','$pass','$mail','$cuid','$canpass', '$type', NOW(), '$notes', '$db_server_id');");
|
||||||
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
|
$db->query("INSERT INTO local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
|
||||||
$this->renew_update($uid, $duration);
|
$this->renew_update($uid, $duration);
|
||||||
|
@ -749,8 +748,7 @@ EOF;
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not
|
* @return boolean Returns FALSE if an error occurs, TRUE if not
|
||||||
*/
|
*/
|
||||||
function update_mem($uid, $mail, $nom, $prenom, $pass, $enabled, $canpass, $type = 'default', $duration = 0, $notes = "", $reset_quotas = false) {
|
function update_mem($uid, $mail, $nom, $prenom, $pass, $enabled, $canpass, $type = 'default', $duration = 0, $notes = "", $reset_quotas = false) {
|
||||||
global $err, $db;
|
global $err, $db, $quota;
|
||||||
global $cuid, $quota;
|
|
||||||
|
|
||||||
$notes = addslashes($notes);
|
$notes = addslashes($notes);
|
||||||
|
|
||||||
|
@ -853,7 +851,7 @@ EOF;
|
||||||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||||
*/
|
*/
|
||||||
function del_mem($uid) {
|
function del_mem($uid) {
|
||||||
global $err, $quota, $classes, $cuid, $mem, $dom, $hooks, $action;
|
global $err, $mem, $dom, $hooks, $action;
|
||||||
$err->log("admin", "del_mem", $uid);
|
$err->log("admin", "del_mem", $uid);
|
||||||
|
|
||||||
if (!$this->enabled) {
|
if (!$this->enabled) {
|
||||||
|
@ -904,9 +902,9 @@ EOF;
|
||||||
global $err, $db;
|
global $err, $db;
|
||||||
|
|
||||||
$periods = intval($periods);
|
$periods = intval($periods);
|
||||||
if ($periods == 0)
|
if ($periods == 0) {
|
||||||
return false;
|
return false;
|
||||||
|
}
|
||||||
$query = "UPDATE membres SET renewed = renewed + INTERVAL (duration * $periods) MONTH WHERE uid=${uid};";
|
$query = "UPDATE membres SET renewed = renewed + INTERVAL (duration * $periods) MONTH WHERE uid=${uid};";
|
||||||
if ($db->query($query)) {
|
if ($db->query($query)) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -929,13 +927,15 @@ EOF;
|
||||||
global $err, $db;
|
global $err, $db;
|
||||||
|
|
||||||
if ($duration == 0) {
|
if ($duration == 0) {
|
||||||
if ($db->query("UPDATE membres SET duration = NULL, renewed = NULL WHERE uid=$uid;"))
|
if ($db->query("UPDATE membres SET duration = NULL, renewed = NULL WHERE uid=$uid;")) {
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
if ($db->query("UPDATE membres SET duration = $duration WHERE uid=$uid") &&
|
if ($db->query("UPDATE membres SET duration = $duration WHERE uid=$uid") &&
|
||||||
$db->query("UPDATE membres SET renewed = NOW() WHERE uid=$uid and renewed is null;"))
|
$db->query("UPDATE membres SET renewed = NOW() WHERE uid=$uid and renewed is null;")) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$err->raise("admin", _("Account not found"));
|
$err->raise("admin", _("Account not found"));
|
||||||
return false;
|
return false;
|
||||||
|
@ -992,12 +992,13 @@ EOF;
|
||||||
" WHEN m.renewed <= NOW() THEN 2" .
|
" WHEN m.renewed <= NOW() THEN 2" .
|
||||||
" ELSE 1 END 'status' FROM membres m, local l" .
|
" ELSE 1 END 'status' FROM membres m, local l" .
|
||||||
" WHERE m.uid = l.uid" .
|
" WHERE m.uid = l.uid" .
|
||||||
" HAVING status=2 or status=3 ORDER BY status DESC, expiry;"))
|
" HAVING status=2 or status=3 ORDER BY status DESC, expiry;")) {
|
||||||
return false;
|
return false;
|
||||||
else {
|
} else {
|
||||||
$res = array();
|
$res = array();
|
||||||
while ($db->next_record())
|
while ($db->next_record()) {
|
||||||
$res[] = $db->Record;
|
$res[] = $db->Record;
|
||||||
|
}
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1025,7 +1026,6 @@ EOF;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Turns a super-admin account into a common account
|
* Turns a super-admin account into a common account
|
||||||
*
|
*
|
||||||
|
@ -1238,8 +1238,9 @@ EOF;
|
||||||
function selecttldmode($current = false) {
|
function selecttldmode($current = false) {
|
||||||
for ($i = 0; $i < count($this->tldmode); $i++) {
|
for ($i = 0; $i < count($this->tldmode); $i++) {
|
||||||
echo "<option value=\"$i\"";
|
echo "<option value=\"$i\"";
|
||||||
if ($current == $i)
|
if ($current == $i) {
|
||||||
echo " selected=\"selected\"";
|
echo " selected=\"selected\"";
|
||||||
|
}
|
||||||
echo ">" . _($this->tldmode[$i]) . "</option>\n";
|
echo ">" . _($this->tldmode[$i]) . "</option>\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1294,11 +1295,13 @@ EOF;
|
||||||
$err->raise("admin", _("This TLD already exist"));
|
$err->raise("admin", _("This TLD already exist"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (substr($tld, 0, 1) == ".")
|
if (substr($tld, 0, 1) == ".") {
|
||||||
$tld = substr($tld, 1);
|
$tld = substr($tld, 1);
|
||||||
|
}
|
||||||
$mode = intval($mode);
|
$mode = intval($mode);
|
||||||
if ($mode == 0)
|
if ($mode == 0) {
|
||||||
$mode = "0";
|
$mode = "0";
|
||||||
|
}
|
||||||
$db->query("INSERT INTO tld (tld,mode) VALUES ('$tld','$mode');");
|
$db->query("INSERT INTO tld (tld,mode) VALUES ('$tld','$mode');");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1322,8 +1325,9 @@ EOF;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$mode = intval($mode);
|
$mode = intval($mode);
|
||||||
if ($mode == 0)
|
if ($mode == 0) {
|
||||||
$mode = "0";
|
$mode = "0";
|
||||||
|
}
|
||||||
$db->query("UPDATE tld SET mode='$mode' WHERE tld='$tld';");
|
$db->query("UPDATE tld SET mode='$mode' WHERE tld='$tld';");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -1350,7 +1354,7 @@ EOF;
|
||||||
* @return array an indexed array of associative array from the MySQL "policy" table
|
* @return array an indexed array of associative array from the MySQL "policy" table
|
||||||
*/
|
*/
|
||||||
function listPasswordPolicies() {
|
function listPasswordPolicies() {
|
||||||
global $db, $classes, $hooks;
|
global $db, $hooks;
|
||||||
$tmp1 = array();
|
$tmp1 = array();
|
||||||
$tmp2 = array();
|
$tmp2 = array();
|
||||||
$policies = array();
|
$policies = array();
|
||||||
|
@ -1358,16 +1362,6 @@ EOF;
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$tmp1[$db->Record["name"]] = $db->Record;
|
$tmp1[$db->Record["name"]] = $db->Record;
|
||||||
}
|
}
|
||||||
/* * /
|
|
||||||
foreach($classes as $c) {
|
|
||||||
if (method_exists($GLOBALS[$c],"alternc_password_policy")) {
|
|
||||||
$res=$GLOBALS[$c]->alternc_password_policy(); // returns an array
|
|
||||||
foreach($res as $k=>$v) {
|
|
||||||
$tmp2[$k]=$v;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* */
|
|
||||||
$tmp3 = $hooks->invoke("alternc_password_policy");
|
$tmp3 = $hooks->invoke("alternc_password_policy");
|
||||||
foreach ($tmp3 as $v) {
|
foreach ($tmp3 as $v) {
|
||||||
foreach ($v as $l => $m) {
|
foreach ($v as $l => $m) {
|
||||||
|
@ -1433,7 +1427,7 @@ EOF;
|
||||||
* @return boolean TRUE if the password if OK for this login and this policy, FALSE if it is not.
|
* @return boolean TRUE if the password if OK for this login and this policy, FALSE if it is not.
|
||||||
*/
|
*/
|
||||||
function checkPolicy($policy, $login, $password) {
|
function checkPolicy($policy, $login, $password) {
|
||||||
global $db, $err;
|
global $err;
|
||||||
|
|
||||||
if (empty($login)) {
|
if (empty($login)) {
|
||||||
$err->raise("admin", _("Please enter a login"));
|
$err->raise("admin", _("Please enter a login"));
|
||||||
|
@ -1468,8 +1462,10 @@ EOF;
|
||||||
$logins = preg_split("/[@_-]/", $login);
|
$logins = preg_split("/[@_-]/", $login);
|
||||||
$logins[] = $login;
|
$logins[] = $login;
|
||||||
foreach ($logins as $l) {
|
foreach ($logins as $l) {
|
||||||
if (!$l) continue;
|
if (!$l) {
|
||||||
if (strpos($password, $l) !== false || strpos($l,$password) !== false) {
|
continue;
|
||||||
|
}
|
||||||
|
if (strpos($password, $l) !== false || strpos($l, $password) !== false) {
|
||||||
$err->raise("admin", _("The password policy prevents you to use your login name inside your password or the other way around"));
|
$err->raise("admin", _("The password policy prevents you to use your login name inside your password or the other way around"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id: mime.php,v 1.3 2004/06/03 14:32:20 anonymous Exp $
|
$Id: mime.php,v 1.3 2004/06/03 14:32:20 anonymous Exp $
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
|
@ -26,7 +27,7 @@
|
||||||
Original Author of file: Benjamin Sonntag 23/12/2001
|
Original Author of file: Benjamin Sonntag 23/12/2001
|
||||||
Purpose of file: Brouteur php3 pour AlternC
|
Purpose of file: Brouteur php3 pour AlternC
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
Brouteur php3 pour AlternC (voir http://www.alternc.org)
|
Brouteur php3 pour AlternC (voir http://www.alternc.org)
|
||||||
|
|
||||||
|
@ -38,12 +39,11 @@
|
||||||
Fichier :
|
Fichier :
|
||||||
mime.php3 : gestion de la liste des types mime des fichiers.
|
mime.php3 : gestion de la liste des types mime des fichiers.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
if (!IsSet($MIME_H)) {
|
if (!IsSet($MIME_H)) {
|
||||||
$MIME_H=1;
|
$MIME_H = 1;
|
||||||
|
|
||||||
$bro_mime=
|
$bro_mime = array(
|
||||||
array(
|
|
||||||
"css" => "text/css",
|
"css" => "text/css",
|
||||||
"csv" => "text/comma-separated-values",
|
"csv" => "text/comma-separated-values",
|
||||||
"dia" => "application/x-dia",
|
"dia" => "application/x-dia",
|
||||||
|
@ -53,7 +53,7 @@ $MIME_H=1;
|
||||||
"gif" => "image/gif",
|
"gif" => "image/gif",
|
||||||
"hqx" => "application/mac-binhex40",
|
"hqx" => "application/mac-binhex40",
|
||||||
"htm" => "text/html",
|
"htm" => "text/html",
|
||||||
"html"=> "text/html",
|
"html" => "text/html",
|
||||||
"jpeg" => "image/jpeg",
|
"jpeg" => "image/jpeg",
|
||||||
"jpg" => "image/jpeg",
|
"jpg" => "image/jpeg",
|
||||||
"m3u" => "audio/mpegurl",
|
"m3u" => "audio/mpegurl",
|
||||||
|
@ -86,8 +86,7 @@ $MIME_H=1;
|
||||||
"zip" => "application/zip",
|
"zip" => "application/zip",
|
||||||
);
|
);
|
||||||
|
|
||||||
$bro_icon=
|
$bro_icon = array(
|
||||||
array(
|
|
||||||
"css" => "txt",
|
"css" => "txt",
|
||||||
"csv" => "xls",
|
"csv" => "xls",
|
||||||
"dia" => "jpg",
|
"dia" => "jpg",
|
||||||
|
@ -97,7 +96,7 @@ $MIME_H=1;
|
||||||
"gif" => "jpg",
|
"gif" => "jpg",
|
||||||
"hqx" => "exe",
|
"hqx" => "exe",
|
||||||
"htm" => "htm",
|
"htm" => "htm",
|
||||||
"html"=> "htm",
|
"html" => "htm",
|
||||||
"jpeg" => "jpg",
|
"jpeg" => "jpg",
|
||||||
"jpg" => "jpg",
|
"jpg" => "jpg",
|
||||||
"m3u" => "m3u",
|
"m3u" => "m3u",
|
||||||
|
@ -130,8 +129,7 @@ $MIME_H=1;
|
||||||
"zip" => "zip",
|
"zip" => "zip",
|
||||||
);
|
);
|
||||||
|
|
||||||
$bro_type=
|
$bro_type = array(
|
||||||
array(
|
|
||||||
"css" => _("CSS Stylesheet"),
|
"css" => _("CSS Stylesheet"),
|
||||||
"csv" => _("Comma Separated Values data"),
|
"csv" => _("Comma Separated Values data"),
|
||||||
"dia" => _("DIA Diagram"),
|
"dia" => _("DIA Diagram"),
|
||||||
|
@ -141,7 +139,7 @@ $MIME_H=1;
|
||||||
"gif" => _("GIF Image"),
|
"gif" => _("GIF Image"),
|
||||||
"hqx" => _("Macintosh Executable"),
|
"hqx" => _("Macintosh Executable"),
|
||||||
"htm" => _("HTML Document"),
|
"htm" => _("HTML Document"),
|
||||||
"html"=> _("HTML Document"),
|
"html" => _("HTML Document"),
|
||||||
"jpeg" => _("JPEG Image"),
|
"jpeg" => _("JPEG Image"),
|
||||||
"jpg" => _("JPEG Image"),
|
"jpg" => _("JPEG Image"),
|
||||||
"m3u" => _("Music Playlist"),
|
"m3u" => _("Music Playlist"),
|
||||||
|
@ -173,6 +171,4 @@ $MIME_H=1;
|
||||||
"rm" => _("Real Media File"),
|
"rm" => _("Real Media File"),
|
||||||
"ram" => _("Real Media File"),
|
"ram" => _("Real Media File"),
|
||||||
);
|
);
|
||||||
|
|
||||||
}
|
}
|
||||||
?>
|
|
||||||
|
|
|
@ -8,13 +8,12 @@ if (!$admin->enabled) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$db->query("SELECT id,hostname FROM stats;");
|
$db->query("SELECT id,hostname FROM stats;");
|
||||||
$d=array();
|
$d = array();
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$d[]=$db->Record;
|
$d[] = $db->Record;
|
||||||
}
|
}
|
||||||
foreach ($d as $r) {
|
foreach ($d as $r) {
|
||||||
echo "Stats de ".$r[0]." ".$r[1]." <br>\n"; flush();
|
echo "Stats de " . $r[0] . " " . $r[1] . " <br>\n";
|
||||||
$stats->_createconf($r[0],1);
|
flush();
|
||||||
|
$stats->_createconf($r[0], 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
|
@ -108,30 +108,30 @@ function variable_get($name, $default = null, $createit_comment = null) {
|
||||||
* The value to set. This can be any PHP data type; these functions take care
|
* The value to set. This can be any PHP data type; these functions take care
|
||||||
* of serialization as necessary.
|
* of serialization as necessary.
|
||||||
*/
|
*/
|
||||||
function variable_set($name, $value, $comment=null) {
|
function variable_set($name, $value, $comment = null) {
|
||||||
global $conf, $db, $err, $hooks;
|
global $conf, $db, $err, $hooks;
|
||||||
$err->log('variable', 'variable_set', '+'.serialize($value).'+'.$comment.'+');
|
$err->log('variable', 'variable_set', '+' . serialize($value) . '+' . $comment . '+');
|
||||||
|
|
||||||
variable_init_maybe();
|
variable_init_maybe();
|
||||||
|
|
||||||
if (is_object($value) || is_array($value)) {
|
if (is_object($value) || is_array($value)) {
|
||||||
$value2 = serialize($value);
|
$value2 = serialize($value);
|
||||||
}
|
}
|
||||||
if (array_key_exists($name,$conf)) {
|
if (array_key_exists($name, $conf)) {
|
||||||
$previous=$conf[$name];
|
$previous = $conf[$name];
|
||||||
} else {
|
} else {
|
||||||
$previous=null;
|
$previous = null;
|
||||||
}
|
}
|
||||||
if (!array_key_exists($name,$conf) || $value!=$conf[$name]) {
|
if (!array_key_exists($name, $conf) || $value != $conf[$name]) {
|
||||||
$conf[$name] = $value;
|
$conf[$name] = $value;
|
||||||
if ( empty($comment) ) {
|
if (empty($comment)) {
|
||||||
$query = "INSERT INTO variable (name, value) values ('".$name."', '".addslashes($value2)."') on duplicate key update name='$name', value='$value';";
|
$query = "INSERT INTO variable (name, value) values ('" . $name . "', '" . addslashes($value2) . "') on duplicate key update name='$name', value='$value';";
|
||||||
} else {
|
} else {
|
||||||
$comment=mysql_real_escape_string($comment);
|
$comment = mysql_real_escape_string($comment);
|
||||||
$query = "INSERT INTO variable (name, value, comment) values ('".$name."', '".addslashes($value2)."', '$comment') on duplicate key update name='$name', value='$value', comment='$comment';";
|
$query = "INSERT INTO variable (name, value, comment) values ('" . $name . "', '" . addslashes($value2) . "', '$comment') on duplicate key update name='$name', value='$value', comment='$comment';";
|
||||||
}
|
}
|
||||||
$db->query($query);
|
$db->query($query);
|
||||||
$hooks->invoke("hook_variable_set", array("name" => $name, "old"=> $previous, "new"=>$value ) );
|
$hooks->invoke("hook_variable_set", array("name" => $name, "old" => $previous, "new" => $value));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,20 +143,16 @@ function variable_set($name, $value, $comment=null) {
|
||||||
*/
|
*/
|
||||||
function variable_del($name) {
|
function variable_del($name) {
|
||||||
global $conf, $db;
|
global $conf, $db;
|
||||||
|
$db->query("DELETE FROM `variable` WHERE name = '" . $name . "'");
|
||||||
$db->query("DELETE FROM `variable` WHERE name = '".$name."'");
|
|
||||||
|
|
||||||
unset($conf[$name]);
|
unset($conf[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
function variables_list() {
|
function variables_list() {
|
||||||
global $db;
|
global $db;
|
||||||
$t=array();
|
$t = array();
|
||||||
$db->query("SELECT * FROM `variable` WHERE `comment` IS NOT NULL ORDER BY `name`");
|
$db->query("SELECT * FROM `variable` WHERE `comment` IS NOT NULL ORDER BY `name`");
|
||||||
while ($db->next_record()) {
|
while ($db->next_record()) {
|
||||||
$t[]=$db->Record;
|
$t[] = $db->Record;
|
||||||
}
|
}
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
|
||||||
|
|
Loading…
Reference in New Issue