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
|
||||
|
||||
/*
|
||||
$Id: config.php,v 1.12 2005/12/18 09:51:32 benjamin Exp $
|
||||
----------------------------------------------------------------------
|
||||
|
@ -29,7 +30,9 @@
|
|||
*/
|
||||
|
||||
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 :
|
||||
// # touch /etc/alternc/alternc_display_php_error
|
||||
|
@ -58,7 +61,8 @@ if (ini_get("safe_mode")) {
|
|||
}
|
||||
|
||||
// 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 (empty($_SERVER['PHP_AUTH_USER']) || empty($_SERVER['PHP_AUTH_PW'])) {
|
||||
header('WWW-Authenticate: Basic realm="AlternC Authentication"');
|
||||
|
@ -89,8 +93,9 @@ require_once(dirname(__FILE__)."/local.php");
|
|||
define("DEFAULT_PASS_SIZE", 8);
|
||||
define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
|
||||
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', "$L_ALTERNC_LOGS");
|
||||
define('ALTERNC_PANEL', "/usr/share/alternc/panel");
|
||||
define('ALTERNC_LOCALES', ALTERNC_PANEL . "/locales");
|
||||
|
@ -114,16 +119,15 @@ if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on" && $host!=$L_FQDN) {
|
|||
header("Location: https://$L_FQDN/");
|
||||
}
|
||||
|
||||
|
||||
// Classe h<>rit<69>e de la classe db de la phplib.
|
||||
// child class of the phplib parent DB class
|
||||
/**
|
||||
* Class for MySQL management in the bureau
|
||||
*
|
||||
* This class heriting from the db class of the phplib manages
|
||||
* the connection to the MySQL database.
|
||||
*/
|
||||
|
||||
class DB_system extends DB_Sql {
|
||||
|
||||
var $Host = null;
|
||||
var $Database = null;
|
||||
var $User = null;
|
||||
|
@ -139,6 +143,7 @@ class DB_system extends DB_Sql {
|
|||
$this->User = $L_MYSQL_LOGIN;
|
||||
$this->Password = $L_MYSQL_PWD;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$db = new DB_system();
|
||||
|
@ -165,7 +170,8 @@ foreach ( glob( $root."class/m_*.php") as $di ) {
|
|||
// or files operations
|
||||
// We can imagine load those class only for command-line scripts.
|
||||
foreach (glob($root . "class/class_system_*.php") as $fcs) {
|
||||
if (is_readable($fcs)) require_once($fcs);
|
||||
if (is_readable($fcs))
|
||||
require_once($fcs);
|
||||
}
|
||||
|
||||
/* Language */
|
||||
|
@ -192,14 +198,16 @@ if (!defined('NOCHECK')) {
|
|||
|
||||
for ($i = 0; $i < count($classes); $i++) {
|
||||
$name2 = $classes[$i];
|
||||
if (isset($$name2)) continue; // for already instancied class like mem, err or authip
|
||||
if (isset($$name2))
|
||||
continue; // for already instancied class like mem, err or authip
|
||||
$name1 = "m_" . $name2;
|
||||
$$name2 = new $name1();
|
||||
}
|
||||
|
||||
$oldid = intval(isset($_COOKIE['oldid']) ? $_COOKIE['oldid'] : '');
|
||||
$isinvited = false;
|
||||
if ($admin->enabled) $isinvited=true;
|
||||
if ($admin->enabled)
|
||||
$isinvited = true;
|
||||
|
||||
if ($oldid && $oldid != $cuid) {
|
||||
$isinvited = true;
|
||||
|
@ -213,5 +221,3 @@ variable_get('hosting_tld', '','This is a FQDN that designates the main hostname
|
|||
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'));
|
||||
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
$Id: config_nochk.php,v 1.2 2004/11/04 06:56:49 anonymous Exp $
|
||||
----------------------------------------------------------------------
|
||||
|
@ -31,4 +32,3 @@
|
|||
define('NOCHECK', 1);
|
||||
require_once("config.php");
|
||||
|
||||
?>
|
||||
|
|
|
@ -9,10 +9,9 @@
|
|||
* $Id: db_mysql.php,v 1.3 2005/03/05 16:27:30 said Exp $
|
||||
*
|
||||
*/
|
||||
|
||||
class DB_Sql {
|
||||
|
||||
/* public: connection parameters */
|
||||
|
||||
var $Host = "";
|
||||
var $Database = "";
|
||||
var $User = "";
|
||||
|
@ -42,8 +41,6 @@ class DB_Sql {
|
|||
var $Query_ID = 0;
|
||||
var $Query_String = "";
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
|
@ -79,14 +76,18 @@ class DB_Sql {
|
|||
*/
|
||||
function connect($Database = "", $Host = "", $User = "", $Password = "") {
|
||||
/* Handle defaults */
|
||||
if ("" == $Database)
|
||||
if ("" == $Database) {
|
||||
$Database = $this->Database;
|
||||
if ("" == $Host)
|
||||
}
|
||||
if ("" == $Host) {
|
||||
$Host = $this->Host;
|
||||
if ("" == $User)
|
||||
}
|
||||
if ("" == $User) {
|
||||
$User = $this->User;
|
||||
if ("" == $Password)
|
||||
}
|
||||
if ("" == $Password) {
|
||||
$Password = $this->Password;
|
||||
}
|
||||
|
||||
/* establish connection, select database */
|
||||
if (0 == $this->Link_ID) {
|
||||
|
@ -134,16 +135,17 @@ class DB_Sql {
|
|||
global $debug_alternc;
|
||||
|
||||
/* 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,
|
||||
* when calling the class without a query, e.g. in situations
|
||||
* like these: '$db = new DB_Sql_Subclass;'
|
||||
*/
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!$this->connect()) {
|
||||
return 0; /* we already complained in connect() about that. */
|
||||
};
|
||||
}
|
||||
|
||||
# New query, discard previous result.
|
||||
if ($this->Query_ID) {
|
||||
|
@ -151,8 +153,9 @@ class DB_Sql {
|
|||
$this->Query_String = $Query_String;
|
||||
}
|
||||
|
||||
if ($this->Debug)
|
||||
if ($this->Debug) {
|
||||
printf("Debug: query = %s<br />\n", $Query_String);
|
||||
}
|
||||
|
||||
$debug_chrono_start = microtime(true);
|
||||
$this->Query_ID = @mysql_query($Query_String, $this->Link_ID);
|
||||
|
@ -211,12 +214,11 @@ class DB_Sql {
|
|||
*
|
||||
* public: position in result set
|
||||
*/
|
||||
|
||||
function seek($pos = 0) {
|
||||
$status = @mysql_data_seek($this->Query_ID, $pos);
|
||||
if ($status)
|
||||
if ($status) {
|
||||
$this->Row = $pos;
|
||||
else {
|
||||
} else {
|
||||
$this->halt("seek($pos) failed: result has " . $this->num_rows() . " rows");
|
||||
|
||||
/* half assed attempt to save the day,
|
||||
|
@ -231,7 +233,7 @@ class DB_Sql {
|
|||
return 1;
|
||||
}
|
||||
|
||||
/* public: table locking */
|
||||
/** public: table locking */
|
||||
function lock($table, $mode = "write") {
|
||||
$this->connect();
|
||||
|
||||
|
@ -267,8 +269,7 @@ class DB_Sql {
|
|||
return $res;
|
||||
}
|
||||
|
||||
|
||||
/* public: evaluate the result (size, width) */
|
||||
/** public: evaluate the result (size, width) */
|
||||
function affected_rows() {
|
||||
return @mysql_affected_rows($this->Link_ID);
|
||||
}
|
||||
|
@ -281,7 +282,7 @@ class DB_Sql {
|
|||
return @mysql_num_fields($this->Query_ID);
|
||||
}
|
||||
|
||||
/* public: shorthand notation */
|
||||
/** public: shorthand notation */
|
||||
function nf() {
|
||||
return $this->num_rows();
|
||||
}
|
||||
|
@ -309,34 +310,26 @@ class DB_Sql {
|
|||
return @mysql_insert_id($this->Link_ID);
|
||||
}
|
||||
|
||||
/* public: sequence numbers */
|
||||
/** public: sequence numbers */
|
||||
function nextid($seq_name) {
|
||||
$this->connect();
|
||||
|
||||
if ($this->lock($this->Seq_Table)) {
|
||||
/* get sequence number (locked) and increment */
|
||||
$q = sprintf("select nextid from %s where seq_name = '%s'",
|
||||
$this->Seq_Table,
|
||||
$seq_name);
|
||||
$q = sprintf("select nextid from %s where seq_name = '%s'", $this->Seq_Table, $seq_name);
|
||||
$id = @mysql_query($q, $this->Link_ID);
|
||||
$res = @mysql_fetch_array($id);
|
||||
|
||||
/* No current value, make one */
|
||||
if (!is_array($res)) {
|
||||
$currentid = 0;
|
||||
$q = sprintf("insert into %s values('%s', %s)",
|
||||
$this->Seq_Table,
|
||||
$seq_name,
|
||||
$currentid);
|
||||
$q = sprintf("insert into %s values('%s', %s)", $this->Seq_Table, $seq_name, $currentid);
|
||||
@mysql_query($q, $this->Link_ID);
|
||||
} else {
|
||||
$currentid = $res["nextid"];
|
||||
}
|
||||
$nextid = $currentid + 1;
|
||||
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
|
||||
$this->Seq_Table,
|
||||
$nextid,
|
||||
$seq_name);
|
||||
$q = sprintf("update %s set nextid = '%s' where seq_name = '%s'", $this->Seq_Table, $nextid, $seq_name);
|
||||
@mysql_query($q, $this->Link_ID);
|
||||
$this->unlock();
|
||||
} else {
|
||||
|
@ -346,7 +339,7 @@ class DB_Sql {
|
|||
return $nextid;
|
||||
}
|
||||
|
||||
/* public: return table metadata */
|
||||
/** public: return table metadata */
|
||||
function metadata($table = '', $full = false) {
|
||||
$res = array();
|
||||
|
||||
|
@ -414,51 +407,13 @@ class DB_Sql {
|
|||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
/********************************************************************************************************/
|
||||
// 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 */
|
||||
/** private: error handling */
|
||||
function halt($msg) {
|
||||
$this->Error = @mysql_error($this->Link_ID);
|
||||
$this->Errno = @mysql_errno($this->Link_ID);
|
||||
|
@ -467,23 +422,21 @@ class DB_Sql {
|
|||
|
||||
$this->haltmsg($msg);
|
||||
|
||||
if ($this->Halt_On_Error != "report")
|
||||
if ($this->Halt_On_Error != "report") {
|
||||
die("Session halted.");
|
||||
}
|
||||
}
|
||||
|
||||
function haltmsg($msg) {
|
||||
printf("</td></tr></table><b>Database error:</b> %s<br />\n", $msg);
|
||||
printf("<b>MySQL Error</b>: %s (%s)<br />\n",
|
||||
$this->Errno,
|
||||
$this->Error);
|
||||
printf("<b>MySQL Error</b>: %s (%s)<br />\n", $this->Errno, $this->Error);
|
||||
}
|
||||
|
||||
function table_names() {
|
||||
$this->query("SHOW TABLES");
|
||||
$i = 0;
|
||||
$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]["tablespace_name"] = $this->Database;
|
||||
$return[$i]["database"] = $this->Database;
|
||||
|
@ -491,5 +444,5 @@ class DB_Sql {
|
|||
}
|
||||
return $return;
|
||||
}
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
----------------------------------------------------------------------
|
||||
AlternC - Web Hosting System
|
||||
|
@ -33,8 +34,9 @@ mt_srand((float) $sec + ((float) $usec * 100000));
|
|||
* @param string $str
|
||||
* @return string
|
||||
*/
|
||||
function fl($str) { return str_replace("<","<",str_replace("\"",""",$str)); }
|
||||
|
||||
function fl($str) {
|
||||
return str_replace("<", "<", str_replace("\"", """, $str));
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if a domain can be hosted on this server :
|
||||
|
@ -64,24 +66,34 @@ function checkhostallow($domain,$dns) {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( $dom->tld_no_check_at_all )
|
||||
if ($dom->tld_no_check_at_all) {
|
||||
return 0; // OK , the boss say that you can.
|
||||
|
||||
if (!$found || $fmode==0) // TLD not allowed at all
|
||||
return -1;
|
||||
if (($fmode!=4) && (!is_array($dns))) // NO dns found in the whois, and domain MUST exists
|
||||
return -2;
|
||||
if ($fmode>2) // OK, in the case 3 4 5
|
||||
return $found;
|
||||
$n1 = false; $n2 = false;
|
||||
for ($i = 0;$i<count($dns);$i++) {
|
||||
if (strtolower($dns[$i])==strtolower($L_NS1)) $n1 = true;
|
||||
if (strtolower($dns[$i])==strtolower($L_NS2)) $n2 = true;
|
||||
}
|
||||
if ($fmode==1 && $n1) // OK
|
||||
if (!$found || $fmode == 0) { // TLD not allowed at all
|
||||
return -1;
|
||||
}
|
||||
if (($fmode != 4) && (!is_array($dns))) { // NO dns found in the whois, and domain MUST exists
|
||||
return -2;
|
||||
}
|
||||
if ($fmode > 2) { // OK, in the case 3 4 5
|
||||
return $found;
|
||||
if ($fmode==2 && $n1 && $n2) // OK
|
||||
}
|
||||
$n1 = false;
|
||||
$n2 = false;
|
||||
for ($i = 0; $i < count($dns); $i++) {
|
||||
if (strtolower($dns[$i]) == strtolower($L_NS1)) {
|
||||
$n1 = true;
|
||||
}
|
||||
if (strtolower($dns[$i]) == strtolower($L_NS2)) {
|
||||
$n2 = true;
|
||||
}
|
||||
}
|
||||
if ($fmode == 1 && $n1) {
|
||||
return $found;
|
||||
}
|
||||
if ($fmode == 2 && $n1 && $n2) {
|
||||
return $found;
|
||||
}
|
||||
return -3; // DNS incorrect in the whois
|
||||
}
|
||||
|
||||
|
@ -108,8 +120,9 @@ function checkhostallow_nodns($domain) {
|
|||
}
|
||||
}
|
||||
// If we found a correct tld, let's find how many . before ;)
|
||||
if (!$found || $fmode==0) // TLD not allowed at all
|
||||
if (!$found || $fmode == 0) { // TLD not allowed at all
|
||||
return 1;
|
||||
}
|
||||
if (count(explode(".", substr($domain, 0, -$sizefound))) > 2) {
|
||||
return 1;
|
||||
}
|
||||
|
@ -117,11 +130,11 @@ function checkhostallow_nodns($domain) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Return the remote IP.
|
||||
* If you are behind a proxy, use X_FORWARDED_FOR instead of REMOTE_ADDR
|
||||
* @return string
|
||||
*/
|
||||
function get_remote_ip() {
|
||||
// Return the remote IP.
|
||||
// If you are behind a proxy, use X_FORWARDED_FOR instead of REMOTE_ADDR
|
||||
return getenv('REMOTE_ADDR');
|
||||
}
|
||||
|
||||
|
@ -133,15 +146,24 @@ function get_remote_ip() {
|
|||
*/
|
||||
function checkurl($url) {
|
||||
// TODO : add a path/file check
|
||||
if (substr($url,0,7)!="http://" && substr($url,0,8)!="https://" && substr($url,0,6)!="ftp://") return false;
|
||||
if (substr($url,0,7)=="http://" ) $fq = substr($url,7);
|
||||
if (substr($url,0,8)=="https://") $fq = substr($url,8);
|
||||
if (substr($url,0,6)=="ftp://" ) $fq = substr($url,6);
|
||||
if (substr($url, 0, 7) != "http://" && substr($url, 0, 8) != "https://" && substr($url, 0, 6) != "ftp://") {
|
||||
return false;
|
||||
}
|
||||
if (substr($url, 0, 7) == "http://") {
|
||||
$fq = substr($url, 7);
|
||||
}
|
||||
if (substr($url, 0, 8) == "https://") {
|
||||
$fq = substr($url, 8);
|
||||
}
|
||||
if (substr($url, 0, 6) == "ftp://") {
|
||||
$fq = substr($url, 6);
|
||||
}
|
||||
$f = explode("/", $fq);
|
||||
if (!is_array($f)) $f = array($f);
|
||||
if (!is_array($f)) {
|
||||
$f = array($f);
|
||||
}
|
||||
$t = checkfqdn($f[0]);
|
||||
if ($t) return false;
|
||||
return true;
|
||||
return !$t;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -153,13 +175,14 @@ function checkurl($url) {
|
|||
function checksubtxt($txt) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that CNAME domain is correct
|
||||
* @param string $cname
|
||||
* @return boolean
|
||||
*/
|
||||
function checkcname($cname) {
|
||||
if ($check=checkfqdn(rtrim($cname,"."))) {
|
||||
if (($check = checkfqdn(rtrim($cname, ".")))) {
|
||||
if ($check != 4) { // ALLOW non-fully qualified (no .)
|
||||
return false; // bad FQDN
|
||||
}
|
||||
|
@ -234,15 +257,20 @@ function checkfqdn($fqdn) {
|
|||
// 2. L'un des membres est trop long.
|
||||
// 3. Caractere interdit dans l'un des membres.
|
||||
// 4. Le fqdn ne fait qu'un seul membre (il n'est donc pas fq...)
|
||||
if (strlen($fqdn)>255)
|
||||
if (strlen($fqdn) > 255) {
|
||||
return 1;
|
||||
}
|
||||
$members = explode(".", $fqdn);
|
||||
if (count($members)>1) $ret = 0; else $ret = 4;
|
||||
if (count($members) > 1) {
|
||||
$ret = 0;
|
||||
} else {
|
||||
$ret = 4;
|
||||
}
|
||||
reset($members);
|
||||
while (list ($key, $val) = each($members)) {
|
||||
if (strlen($val)>63)
|
||||
if (strlen($val) > 63) {
|
||||
return 2;
|
||||
|
||||
}
|
||||
// Note: a.foo.net is a valid domain
|
||||
// Note: RFC1035 tells us that a domain should not start by a digit, but every registrar allows such a domain to be created ... too bad.
|
||||
if (!preg_match("#^[a-z0-9_]([a-z0-9-_]*[a-z0-9_])?$#i", $val)) {
|
||||
|
@ -253,7 +281,6 @@ function checkfqdn($fqdn) {
|
|||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @global m_mem $mem
|
||||
* @param string $path
|
||||
* @return int
|
||||
|
@ -265,9 +292,9 @@ function checkuserpath($path) {
|
|||
global $mem;
|
||||
$user = $mem->user["login"];
|
||||
$usar = substr($user, 0, 1);
|
||||
if (substr($path,0,1)!="/")
|
||||
if (substr($path, 0, 1) != "/") {
|
||||
$path = "/" . $path;
|
||||
|
||||
}
|
||||
$rpath = realpath(ALTERNC_HTML . "/$usar/$user$path");
|
||||
if (!$rpath) { // if file or directory does not exist
|
||||
return 1; // FIXME is it safe to say OK in this case ?
|
||||
|
@ -307,7 +334,7 @@ function getuserpath($user = null) {
|
|||
* @param boolean $test
|
||||
* @param boolean $echo
|
||||
*/
|
||||
function cbox($test, $echo = TRUE) {
|
||||
function cbox($test, $echo = true) {
|
||||
if ($test) {
|
||||
$return = " checked=\"checked\"";
|
||||
} else {
|
||||
|
@ -319,7 +346,6 @@ function cbox($test, $echo = TRUE) {
|
|||
return $return;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* ECHOes selected="selected" only if the parameter is true
|
||||
* useful for checkboxes and radio buttons
|
||||
|
@ -351,8 +377,7 @@ function selected($bool, $echo = TRUE) {
|
|||
function ecif($test, $tr, $fa = "", $affiche = 1) {
|
||||
if ($test) {
|
||||
$retour = $tr;
|
||||
}
|
||||
else{
|
||||
} else {
|
||||
$retour = $fa;
|
||||
}
|
||||
if ($affiche) {
|
||||
|
@ -435,6 +460,7 @@ function format_size($size,$html = 0) {
|
|||
function getlinkhelp($hid) {
|
||||
return "(<a href=\"javascript:help($hid);\">?</a>)";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param int $hid
|
||||
|
@ -442,6 +468,7 @@ function getlinkhelp($hid) {
|
|||
function linkhelp($hid) {
|
||||
echo getlinkhelp($hid);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $format
|
||||
|
@ -478,6 +505,7 @@ function ssla($str) {
|
|||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
/** Hashe un mot de passe en clair en MD5 avec un salt al<EFBFBD>atoire
|
||||
* @param string $pass Mot de passe <EFBFBD> crypter (max 32 caract<EFBFBD>res)
|
||||
* @return string Retourne le mot de passe crypt<EFBFBD>
|
||||
|
@ -504,8 +532,8 @@ function split_mysql_database_name($dbname) {
|
|||
implode("_", array_slice($db_exploded_name, 1)));
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
/** Echappe les caract<EFBFBD>res pouvant perturber un flux XML standard :
|
||||
* @param string $string Chaine de caract<EFBFBD>re <EFBFBD> encoder en valeur xml.
|
||||
* @return string Retourne la cha<EFBFBD>ne modifi<EFBFBD>e si besoin.
|
||||
|
@ -516,6 +544,7 @@ function xml_entities($string) {
|
|||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
/** Converti un nombre de mois en une chaine plus lisible
|
||||
* @param integer $months Nombre de mois
|
||||
* @return string Cha<EFBFBD>ne repr<EFBFBD>sentant le nombre de mois
|
||||
|
@ -531,6 +560,7 @@ function pretty_months($months) {
|
|||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
|
||||
/** Fabrique un drop-down pour les dur<EFBFBD>es de comptes
|
||||
* @name string $name Nom pour le composasnt
|
||||
* @selected number Option selection<EFBFBD>e du composant
|
||||
|
@ -572,15 +602,18 @@ function duration_list($name, $selected = 0) {
|
|||
function eoption($values, $cur, $onedim = false) {
|
||||
if (is_array($values)) {
|
||||
foreach ($values as $k => $v) {
|
||||
if ( $onedim ) $k = $v;
|
||||
if ($onedim) {
|
||||
$k = $v;
|
||||
}
|
||||
echo "<option value=\"$k\"";
|
||||
if ($k==$cur) echo " selected=\"selected\"";
|
||||
if ($k == $cur) {
|
||||
echo " selected=\"selected\"";
|
||||
}
|
||||
echo ">" . $v . "</option>";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
/* Echo the HTMLSpecialChars version of a value.
|
||||
* Must be called when pre-filling fields values in forms such as :
|
||||
|
@ -604,6 +637,7 @@ function ehe($str,$affiche = TRUE) {
|
|||
/* Get the Fields of the posted form from $_REQUEST or POST or GET
|
||||
* and check their type
|
||||
*/
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $fields
|
||||
|
@ -615,14 +649,14 @@ function getFields($fields, $requestOnly = false) {
|
|||
$methodType = array("get", "post", "request", "files", "server");
|
||||
|
||||
foreach ($fields AS $name => $options) {
|
||||
if (in_array(strtolower($options[0]), $methodType) === false)
|
||||
if (in_array(strtolower($options[0]), $methodType) === false) {
|
||||
die("Unrecognized method type used for field " . $name . " : " . $options[0]);
|
||||
|
||||
if ($requestOnly === true)
|
||||
}
|
||||
if ($requestOnly === true) {
|
||||
$method = "_REQUEST";
|
||||
else
|
||||
} else {
|
||||
$method = "_" . strtoupper($options[0]);
|
||||
|
||||
}
|
||||
switch ($options[1]) {
|
||||
case "integer":
|
||||
$vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? intval($GLOBALS[$method][$name]) : $options[2]);
|
||||
|
@ -648,9 +682,9 @@ function getFields($fields, $requestOnly = false) {
|
|||
}
|
||||
|
||||
// Insert into $GLOBALS.
|
||||
foreach ($vars AS $var => $value)
|
||||
foreach ($vars AS $var => $value) {
|
||||
$GLOBALS[$var] = $value;
|
||||
|
||||
}
|
||||
return $vars;
|
||||
}
|
||||
|
||||
|
@ -663,6 +697,7 @@ function printVar($array) {
|
|||
print_r($array);
|
||||
echo "</pre>\n";
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param array $a
|
||||
|
@ -674,9 +709,7 @@ function list_properties_order($a, $b) {
|
|||
return 0;
|
||||
}
|
||||
return ($a['label'] < $b['label']) ? -1 : 1;
|
||||
} // end private function list_properties_order
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows a pager : Previous page 0 1 2 ... 16 17 18 19 20 ... 35 36 37 Next page
|
||||
|
@ -698,16 +731,23 @@ function list_properties_order($a, $b) {
|
|||
* @param boolean $echo
|
||||
* @return string
|
||||
*/
|
||||
function pager($offset,$count,$total,$url,$before = "",$after = "",$echo = TRUE) {
|
||||
function pager($offset, $count, $total, $url, $before = "", $after = "", $echo = true) {
|
||||
$return = "";
|
||||
$offset = intval($offset);
|
||||
$count = intval($count);
|
||||
$total = intval($total);
|
||||
if ($offset<=0) $offset = "0";
|
||||
if ($count<=1) $count = "1";
|
||||
if ($total<=0) $total = "0";
|
||||
if ($total<$offset) $offset = max(0,$total-$count);
|
||||
|
||||
if ($offset <= 0) {
|
||||
$offset = "0";
|
||||
}
|
||||
if ($count <= 1) {
|
||||
$count = "1";
|
||||
}
|
||||
if ($total <= 0) {
|
||||
$total = "0";
|
||||
}
|
||||
if ($total < $offset) {
|
||||
$offset = max(0, $total - $count);
|
||||
}
|
||||
if ($total <= $count) { // When there is less element than 1 complete page, just don't do anything :-D
|
||||
return true;
|
||||
}
|
||||
|
@ -744,7 +784,9 @@ function pager($offset,$count,$total,$url,$before = "",$after = "",$echo = TRUE)
|
|||
// On affiche 2 avant jusque 2 apr<70>s l'offset courant mais sans d<>border sur les indices affich<63>s autour
|
||||
$start = max(3, intval($offset / $count) - 2);
|
||||
$end = min(intval($offset / $count) + 3, intval($total / $count) - 3);
|
||||
if ($start!=3) $return .= " ... ";
|
||||
if ($start != 3) {
|
||||
$return .= " ... ";
|
||||
}
|
||||
for ($i = $start; $i < $end; $i++) {
|
||||
$o = $i * $count;
|
||||
if ($offset == $o) {
|
||||
|
@ -753,7 +795,9 @@ function pager($offset,$count,$total,$url,$before = "",$after = "",$echo = TRUE)
|
|||
$return .= "<a href=\"" . str_replace("%%offset%%", $o, $url) . "\">$i</a> ";
|
||||
}
|
||||
}
|
||||
if ($end!=intval($total/$count)-3) $return .= " ... ";
|
||||
if ($end != intval($total / $count) - 3) {
|
||||
$return .= " ... ";
|
||||
}
|
||||
} else {
|
||||
$return .= " ... ";
|
||||
}
|
||||
|
@ -780,7 +824,6 @@ function pager($offset,$count,$total,$url,$before = "",$after = "",$echo = TRUE)
|
|||
echo $return;
|
||||
}
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -799,8 +842,6 @@ function create_pass($length = 8){
|
|||
return $password;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Affiche un bouton qui permet de generer automatiquement des mots de passes
|
||||
*
|
||||
|
@ -861,7 +902,6 @@ function display_browser($dir = "", $caller = "main.dir", $width = 350, $height
|
|||
// -->
|
||||
</script>
|
||||
";
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -883,12 +923,24 @@ function display_browser($dir = "", $caller = "main.dir", $width = 350, $height
|
|||
*/
|
||||
function fHSVtoRGB($iH, $iS, $iV) {
|
||||
|
||||
if($iH < 0) $iH = 0; // Hue:
|
||||
if($iH > 360) $iH = 360; // 0-360
|
||||
if($iS < 0) $iS = 0; // Saturation:
|
||||
if($iS > 100) $iS = 100; // 0-100
|
||||
if($iV < 0) $iV = 0; // Lightness:
|
||||
if($iV > 100) $iV = 100; // 0-100
|
||||
if ($iH < 0) {
|
||||
$iH = 0; // Hue:
|
||||
}
|
||||
if ($iH > 360) {
|
||||
$iH = 360; // 0-360
|
||||
}
|
||||
if ($iS < 0) {
|
||||
$iS = 0; // Saturation:
|
||||
}
|
||||
if ($iS > 100) {
|
||||
$iS = 100; // 0-100
|
||||
}
|
||||
if ($iV < 0) {
|
||||
$iV = 0; // Lightness:
|
||||
}
|
||||
if ($iV > 100) {
|
||||
$iV = 100; // 0-100
|
||||
}
|
||||
|
||||
$dS = $iS / 100.0; // Saturation: 0.0-1.0
|
||||
$dV = $iV / 100.0; // Lightness: 0.0-1.0
|
||||
|
@ -896,29 +948,56 @@ function fHSVtoRGB($iH, $iS, $iV) {
|
|||
$dH = $iH / 60.0; // H-Prime: 0.0-6.0
|
||||
$dT = $dH; // Temp variable
|
||||
|
||||
while($dT >= 2.0) $dT -= 2.0; // php modulus does not work with float
|
||||
while ($dT >= 2.0) {
|
||||
$dT -= 2.0; // php modulus does not work with float
|
||||
}
|
||||
$dX = $dC * (1 - abs($dT - 1)); // as used in the Wikipedia link
|
||||
|
||||
switch ($dH) {
|
||||
case($dH >= 0.0 && $dH < 1.0):
|
||||
$dR = $dC; $dG = $dX; $dB = 0.0; break;
|
||||
$dR = $dC;
|
||||
$dG = $dX;
|
||||
$dB = 0.0;
|
||||
break;
|
||||
case($dH >= 1.0 && $dH < 2.0):
|
||||
$dR = $dX; $dG = $dC; $dB = 0.0; break;
|
||||
$dR = $dX;
|
||||
$dG = $dC;
|
||||
$dB = 0.0;
|
||||
break;
|
||||
case($dH >= 2.0 && $dH < 3.0):
|
||||
$dR = 0.0; $dG = $dC; $dB = $dX; break;
|
||||
$dR = 0.0;
|
||||
$dG = $dC;
|
||||
$dB = $dX;
|
||||
break;
|
||||
case($dH >= 3.0 && $dH < 4.0):
|
||||
$dR = 0.0; $dG = $dX; $dB = $dC; break;
|
||||
$dR = 0.0;
|
||||
$dG = $dX;
|
||||
$dB = $dC;
|
||||
break;
|
||||
case($dH >= 4.0 && $dH < 5.0):
|
||||
$dR = $dX; $dG = 0.0; $dB = $dC; break;
|
||||
$dR = $dX;
|
||||
$dG = 0.0;
|
||||
$dB = $dC;
|
||||
break;
|
||||
case($dH >= 5.0 && $dH < 6.0):
|
||||
$dR = $dC; $dG = 0.0; $dB = $dX; break;
|
||||
$dR = $dC;
|
||||
$dG = 0.0;
|
||||
$dB = $dX;
|
||||
break;
|
||||
default:
|
||||
$dR = 0.0; $dG = 0.0; $dB = 0.0; break;
|
||||
$dR = 0.0;
|
||||
$dG = 0.0;
|
||||
$dB = 0.0;
|
||||
break;
|
||||
}
|
||||
|
||||
$dM = $dV - $dC;
|
||||
$dR += $dM; $dG += $dM; $dB += $dM;
|
||||
$dR *= 255; $dG *= 255; $dB *= 255;
|
||||
$dR += $dM;
|
||||
$dG += $dM;
|
||||
$dB += $dM;
|
||||
$dR *= 255;
|
||||
$dG *= 255;
|
||||
$dB *= 255;
|
||||
|
||||
return array('r' => round($dR), 'g' => round($dG), 'b' => round($dB));
|
||||
}
|
||||
|
@ -928,8 +1007,7 @@ function fHSVtoRGB($iH, $iS, $iV) {
|
|||
* @param int $hex
|
||||
* @return int
|
||||
*/
|
||||
function hexa($hex)
|
||||
{
|
||||
function hexa($hex) {
|
||||
$num = dechex($hex);
|
||||
return (strlen("$num") >= 2) ? "$num" : "0$num";
|
||||
}
|
||||
|
@ -940,8 +1018,12 @@ function hexa($hex)
|
|||
* @return string
|
||||
*/
|
||||
function PercentToColor($p = 0) {
|
||||
if ($p>100) $p = 100;
|
||||
if ($p<0) $p = 0;
|
||||
if ($p > 100) {
|
||||
$p = 100;
|
||||
}
|
||||
if ($p < 0) {
|
||||
$p = 0;
|
||||
}
|
||||
// Pour aller de vert a rouge en passant par jaune et orange
|
||||
$h = 1 + ((100 - $p) * 130 / 100);
|
||||
|
||||
|
@ -959,8 +1041,10 @@ function PercentToColor($p = 0) {
|
|||
* @return boolean
|
||||
*/
|
||||
function panel_lock() {
|
||||
global $err,$mem,$cuid;
|
||||
if ($cuid!=2000) return false;
|
||||
global $cuid;
|
||||
if ($cuid != 2000) {
|
||||
return false;
|
||||
}
|
||||
return touch(ALTERNC_LOCK_PANEL);
|
||||
}
|
||||
|
||||
|
@ -972,8 +1056,10 @@ function panel_lock() {
|
|||
* @return boolean
|
||||
*/
|
||||
function panel_unlock() {
|
||||
global $err,$mem,$cuid;
|
||||
if ($cuid!=2000) return false;
|
||||
global $cuid;
|
||||
if ($cuid != 2000) {
|
||||
return false;
|
||||
}
|
||||
return unlink(ALTERNC_LOCK_PANEL);
|
||||
}
|
||||
|
||||
|
@ -984,5 +1070,3 @@ function panel_unlock() {
|
|||
function panel_islocked() {
|
||||
return file_exists(ALTERNC_LOCK_PANEL);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -17,10 +17,14 @@ function update_locale($langpath) {
|
|||
global $arr_lang_translation;
|
||||
$locales = array();
|
||||
$file = file("/etc/locale.gen", FILE_SKIP_EMPTY_LINES);
|
||||
if (! is_array($file) ) return $locales;
|
||||
if (!is_array($file)) {
|
||||
return $locales;
|
||||
}
|
||||
foreach ($file as $v) {
|
||||
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;
|
||||
if (!array_key_exists($mat[1], $arr_lang_translation)) {
|
||||
continue;
|
||||
}
|
||||
$locales[$mat[1]] = $mat[1];
|
||||
}
|
||||
}
|
||||
|
@ -64,8 +68,9 @@ if (! isset($locales[$lang])) { // Requested language not found in locales
|
|||
}
|
||||
}
|
||||
|
||||
if (!isset($locales[$lang])) list($lang)=each($locales);
|
||||
|
||||
if (!isset($locales[$lang])) {
|
||||
list($lang) = each($locales);
|
||||
}
|
||||
if (isset($setlang) && isset($lang)) {
|
||||
setcookie("lang", $lang);
|
||||
}
|
||||
|
@ -87,7 +92,7 @@ $empty="";
|
|||
if (_($empty) && preg_match("#charset=([A-Za-z0-9\.-]*)#", _($empty), $mat)) {
|
||||
$charset = $mat[1];
|
||||
}
|
||||
if (! isset($charset) || !$charset) $charset="UTF-8";
|
||||
if (!isset($charset) || !$charset) {
|
||||
$charset = "UTF-8";
|
||||
}
|
||||
bind_textdomain_codeset("alternc", "$charset");
|
||||
|
||||
?>
|
||||
|
|
|
@ -28,7 +28,7 @@ while (FALSE !== ($line = fgets($config_file))) {
|
|||
fclose($config_file);
|
||||
|
||||
$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)) {
|
||||
switch ($regs[1]) {
|
||||
case "user":
|
||||
|
@ -48,4 +48,3 @@ while (FALSE !== ($line = fgets($config_file))) {
|
|||
}
|
||||
|
||||
fclose($config_file);
|
||||
?>
|
||||
|
|
|
@ -270,7 +270,6 @@ class m_action {
|
|||
return false;
|
||||
}
|
||||
return $db->num_rows($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -352,7 +351,7 @@ class m_action {
|
|||
* @return boolean
|
||||
*/
|
||||
function get_job() {
|
||||
global $db, $err;
|
||||
global $db;
|
||||
$tab = array();
|
||||
$db->query("Select * from actions where begin !=0 and end = 0 ;");
|
||||
if ($db->next_record()) {
|
||||
|
@ -371,7 +370,6 @@ class m_action {
|
|||
* @return boolean
|
||||
*/
|
||||
function cancel($id) {
|
||||
global $db;
|
||||
$this->finish($id, 666);
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -79,9 +79,9 @@ class m_admin {
|
|||
*/
|
||||
function hook_menu() {
|
||||
global $mem, $cuid, $debug_alternc, $L_INOTIFY_UPDATE_DOMAIN;
|
||||
if (!$mem->checkRight())
|
||||
if (!$mem->checkRight()) {
|
||||
return false;
|
||||
|
||||
}
|
||||
$obj = array(
|
||||
'title' => _("Administration"),
|
||||
'ico' => 'images/admin.png',
|
||||
|
@ -343,38 +343,36 @@ class m_admin {
|
|||
|
||||
$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);
|
||||
|
||||
if ($creator)
|
||||
}
|
||||
if ($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 .= ' GROUP BY uid';
|
||||
} elseif ($pattern_type === 'login') {
|
||||
|
||||
$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);
|
||||
|
||||
if ($creator)
|
||||
}
|
||||
if ($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 .= ' ORDER BY login;';
|
||||
} else {
|
||||
|
||||
$err->raise("admin", _("Invalid pattern type provided. Are you even performing a legitimate action?"));
|
||||
return FALSE;
|
||||
}
|
||||
} else {
|
||||
|
||||
if ($creator) {
|
||||
// Limit listing to a specific reseller
|
||||
$request = "SELECT uid FROM membres WHERE creator='" . $creator . "' ORDER BY login;";
|
||||
|
@ -411,7 +409,7 @@ class m_admin {
|
|||
* @return boolean
|
||||
*/
|
||||
function mailallmembers($subject, $message, $from) {
|
||||
global $err, $mem, $cuid, $db;
|
||||
global $err, $db;
|
||||
$err->log("admin", "mailallmembers");
|
||||
if (!$this->enabled) {
|
||||
$err->raise("admin", _("-- Only administrators can access this page! --"));
|
||||
|
@ -453,7 +451,7 @@ class m_admin {
|
|||
* @return boolean
|
||||
*/
|
||||
function get_creator_list() {
|
||||
global $err, $mem, $cuid;
|
||||
global $err, $cuid;
|
||||
|
||||
$creators = array();
|
||||
|
||||
|
@ -488,7 +486,7 @@ class m_admin {
|
|||
* @return boolean TRUE if I am the creator of that account. FALSE else.
|
||||
*/
|
||||
function checkcreator($uid) {
|
||||
global $err, $mem, $db, $cuid;
|
||||
global $err, $db, $cuid;
|
||||
if ($cuid == 2000) {
|
||||
return true;
|
||||
}
|
||||
|
@ -514,7 +512,7 @@ class m_admin {
|
|||
* @return boolean
|
||||
*/
|
||||
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);
|
||||
|
||||
if (!$mem->checkright()) {
|
||||
|
@ -575,7 +573,7 @@ class m_admin {
|
|||
* @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) {
|
||||
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);
|
||||
if (!$this->enabled) {
|
||||
$err->raise("admin", _("-- Only administrators can access this page! --"));
|
||||
|
@ -629,9 +627,10 @@ class m_admin {
|
|||
$uid = 2000;
|
||||
} else {
|
||||
$uid = $db->Record["nextid"];
|
||||
if ($uid <= 2000)
|
||||
if ($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 local(uid,nom,prenom) VALUES('$uid','$nom','$prenom');");
|
||||
$this->renew_update($uid, $duration);
|
||||
|
@ -749,8 +748,7 @@ EOF;
|
|||
* @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) {
|
||||
global $err, $db;
|
||||
global $cuid, $quota;
|
||||
global $err, $db, $quota;
|
||||
|
||||
$notes = addslashes($notes);
|
||||
|
||||
|
@ -853,7 +851,7 @@ EOF;
|
|||
* @return boolean Returns FALSE if an error occurs, TRUE if not.
|
||||
*/
|
||||
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);
|
||||
|
||||
if (!$this->enabled) {
|
||||
|
@ -904,9 +902,9 @@ EOF;
|
|||
global $err, $db;
|
||||
|
||||
$periods = intval($periods);
|
||||
if ($periods == 0)
|
||||
if ($periods == 0) {
|
||||
return false;
|
||||
|
||||
}
|
||||
$query = "UPDATE membres SET renewed = renewed + INTERVAL (duration * $periods) MONTH WHERE uid=${uid};";
|
||||
if ($db->query($query)) {
|
||||
return true;
|
||||
|
@ -929,13 +927,15 @@ EOF;
|
|||
global $err, $db;
|
||||
|
||||
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;
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
$err->raise("admin", _("Account not found"));
|
||||
return false;
|
||||
|
@ -992,12 +992,13 @@ EOF;
|
|||
" WHEN m.renewed <= NOW() THEN 2" .
|
||||
" ELSE 1 END 'status' FROM membres m, local l" .
|
||||
" 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;
|
||||
else {
|
||||
} else {
|
||||
$res = array();
|
||||
while ($db->next_record())
|
||||
while ($db->next_record()) {
|
||||
$res[] = $db->Record;
|
||||
}
|
||||
return $res;
|
||||
}
|
||||
}
|
||||
|
@ -1025,7 +1026,6 @@ EOF;
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Turns a super-admin account into a common account
|
||||
*
|
||||
|
@ -1238,8 +1238,9 @@ EOF;
|
|||
function selecttldmode($current = false) {
|
||||
for ($i = 0; $i < count($this->tldmode); $i++) {
|
||||
echo "<option value=\"$i\"";
|
||||
if ($current == $i)
|
||||
if ($current == $i) {
|
||||
echo " selected=\"selected\"";
|
||||
}
|
||||
echo ">" . _($this->tldmode[$i]) . "</option>\n";
|
||||
}
|
||||
}
|
||||
|
@ -1294,11 +1295,13 @@ EOF;
|
|||
$err->raise("admin", _("This TLD already exist"));
|
||||
return false;
|
||||
}
|
||||
if (substr($tld, 0, 1) == ".")
|
||||
if (substr($tld, 0, 1) == ".") {
|
||||
$tld = substr($tld, 1);
|
||||
}
|
||||
$mode = intval($mode);
|
||||
if ($mode == 0)
|
||||
if ($mode == 0) {
|
||||
$mode = "0";
|
||||
}
|
||||
$db->query("INSERT INTO tld (tld,mode) VALUES ('$tld','$mode');");
|
||||
return true;
|
||||
}
|
||||
|
@ -1322,8 +1325,9 @@ EOF;
|
|||
return false;
|
||||
}
|
||||
$mode = intval($mode);
|
||||
if ($mode == 0)
|
||||
if ($mode == 0) {
|
||||
$mode = "0";
|
||||
}
|
||||
$db->query("UPDATE tld SET mode='$mode' WHERE tld='$tld';");
|
||||
return true;
|
||||
}
|
||||
|
@ -1350,7 +1354,7 @@ EOF;
|
|||
* @return array an indexed array of associative array from the MySQL "policy" table
|
||||
*/
|
||||
function listPasswordPolicies() {
|
||||
global $db, $classes, $hooks;
|
||||
global $db, $hooks;
|
||||
$tmp1 = array();
|
||||
$tmp2 = array();
|
||||
$policies = array();
|
||||
|
@ -1358,16 +1362,6 @@ EOF;
|
|||
while ($db->next_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");
|
||||
foreach ($tmp3 as $v) {
|
||||
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.
|
||||
*/
|
||||
function checkPolicy($policy, $login, $password) {
|
||||
global $db, $err;
|
||||
global $err;
|
||||
|
||||
if (empty($login)) {
|
||||
$err->raise("admin", _("Please enter a login"));
|
||||
|
@ -1468,7 +1462,9 @@ EOF;
|
|||
$logins = preg_split("/[@_-]/", $login);
|
||||
$logins[] = $login;
|
||||
foreach ($logins as $l) {
|
||||
if (!$l) continue;
|
||||
if (!$l) {
|
||||
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"));
|
||||
return false;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
$Id: mime.php,v 1.3 2004/06/03 14:32:20 anonymous Exp $
|
||||
----------------------------------------------------------------------
|
||||
|
@ -42,8 +43,7 @@
|
|||
if (!IsSet($MIME_H)) {
|
||||
$MIME_H = 1;
|
||||
|
||||
$bro_mime=
|
||||
array(
|
||||
$bro_mime = array(
|
||||
"css" => "text/css",
|
||||
"csv" => "text/comma-separated-values",
|
||||
"dia" => "application/x-dia",
|
||||
|
@ -86,8 +86,7 @@ $MIME_H=1;
|
|||
"zip" => "application/zip",
|
||||
);
|
||||
|
||||
$bro_icon=
|
||||
array(
|
||||
$bro_icon = array(
|
||||
"css" => "txt",
|
||||
"csv" => "xls",
|
||||
"dia" => "jpg",
|
||||
|
@ -130,8 +129,7 @@ $MIME_H=1;
|
|||
"zip" => "zip",
|
||||
);
|
||||
|
||||
$bro_type=
|
||||
array(
|
||||
$bro_type = array(
|
||||
"css" => _("CSS Stylesheet"),
|
||||
"csv" => _("Comma Separated Values data"),
|
||||
"dia" => _("DIA Diagram"),
|
||||
|
@ -173,6 +171,4 @@ $MIME_H=1;
|
|||
"rm" => _("Real Media File"),
|
||||
"ram" => _("Real Media File"),
|
||||
);
|
||||
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -13,8 +13,7 @@ while ($db->next_record()) {
|
|||
$d[] = $db->Record;
|
||||
}
|
||||
foreach ($d as $r) {
|
||||
echo "Stats de ".$r[0]." ".$r[1]." <br>\n"; flush();
|
||||
echo "Stats de " . $r[0] . " " . $r[1] . " <br>\n";
|
||||
flush();
|
||||
$stats->_createconf($r[0], 1);
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
|
@ -143,9 +143,7 @@ function variable_set($name, $value, $comment=null) {
|
|||
*/
|
||||
function variable_del($name) {
|
||||
global $conf, $db;
|
||||
|
||||
$db->query("DELETE FROM `variable` WHERE name = '" . $name . "'");
|
||||
|
||||
unset($conf[$name]);
|
||||
}
|
||||
|
||||
|
@ -158,5 +156,3 @@ function variables_list() {
|
|||
}
|
||||
return $t;
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue