diff --git a/bureau/admin/adm_panel.php b/bureau/admin/adm_panel.php index ae048ec4..3e9b8b47 100644 --- a/bureau/admin/adm_panel.php +++ b/bureau/admin/adm_panel.php @@ -1,13 +1,5 @@ enabled) { diff --git a/bureau/class/class_system_bind.php b/bureau/class/class_system_bind.php index 7d2cb9c0..34d045b4 100644 --- a/bureau/class/class_system_bind.php +++ b/bureau/class/class_system_bind.php @@ -1,6 +1,28 @@ cache_conf_db; } + /** * Return full path of the zone configuration file * @@ -72,6 +89,7 @@ class system_bind { return $this->zone_file_directory.$domain; } + /** * * @param string $domain @@ -89,6 +107,7 @@ class system_bind { return $this->cache_zone_file[$domain] ; } + /** * * @param string $domain @@ -113,6 +132,7 @@ class system_bind { return max(array($calc,$old)) + 1 ; } + /** * Return lines that are after ;;; END ALTERNC AUTOGENERATE CONFIGURATION * @@ -131,6 +151,7 @@ class system_bind { return $this->cache_get_persistent[$domain]; } + /** * * @return string @@ -139,6 +160,7 @@ class system_bind { return file_get_contents($this->ZONE_TEMPLATE); } + /** * * @global m_dom $dom @@ -157,6 +179,7 @@ class system_bind { else return $this->cache_domain_summary; } + /** * * @param string $domain @@ -172,6 +195,7 @@ class system_bind { return true; } + /** * Generate the domain DKIM key * @@ -202,6 +226,7 @@ class system_bind { return true; // FIXME handle error } + /** * Refresh DKIM configuration: be sure to list the domain having a private key (and only them) */ @@ -259,6 +284,8 @@ class system_bind { } } + + /** * * @param string $domain @@ -273,6 +300,7 @@ class system_bind { return @file_get_contents($keyfile); } + /** * Conditionnal generation autoconfig entry for outlook / thunderbird * If entry with the same name allready exist, skip it. @@ -349,6 +377,7 @@ class system_bind { return $zone; } + /** * * @param string $domain @@ -360,6 +389,7 @@ class system_bind { } } + /** * return true if zone is locked * @@ -374,6 +404,7 @@ class system_bind { return false; } + /** * * @global m_mysql $db @@ -401,6 +432,7 @@ class system_bind { return true; // fixme add tests } + /** * Delete the zone configuration file * @@ -416,6 +448,7 @@ class system_bind { return true; } + /** * * @global m_hooks $hooks @@ -446,6 +479,7 @@ class system_bind { return true; } + /** * Regenerate bind configuration and load it * @@ -478,6 +512,7 @@ class system_bind { return true; } + /** * */ @@ -485,7 +520,6 @@ class system_bind { _("The zone file of this domain is locked. Contact your administrator."); } -} // class +} /* Class system_bind */ -?> diff --git a/bureau/class/config.php b/bureau/class/config.php index 7e571425..89bc42ed 100755 --- a/bureau/class/config.php +++ b/bureau/class/config.php @@ -1,14 +1,6 @@ - Merci de revenir plus tard."; - exit(); - } - /* */ 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 !!"); @@ -71,7 +56,7 @@ if (isset($http_auth)) { } } if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { - // Gruiiik + // Gruiiik does http-auth : simulate a posted-login/pass $_REQUEST["username"] = $_SERVER['PHP_AUTH_USER']; $_REQUEST["password"] = $_SERVER['PHP_AUTH_PW']; } @@ -88,9 +73,11 @@ $host = getenv("HTTP_HOST"); /* Global variables (AlternC configuration) */ require_once(dirname(__FILE__) . "/local.php"); -// Define constants from vars of /etc/alternc/local.sh -// The you can't choose where is the AlternC Panel +/** + * Define constants from vars of /etc/alternc/local.sh + * The you can't choose where is the AlternC Panel + */ define("DEFAULT_PASS_SIZE", 10); define('ALTERNC_MAIL', "$L_ALTERNC_MAIL"); define('ALTERNC_HTML', "$L_ALTERNC_HTML"); @@ -116,14 +103,12 @@ require_once($root . "/class/functions.php"); require_once($root . "/class/variables.php"); -// Classe h�rit�e de la classe db de la phplib. -/** - * Class for MySQL management in the bureau +/** + * Class for MySQL management in the panel * * This class heriting from the db class of the phplib manages * the connection to the MySQL database. - */ - + */ class DB_system extends DB_Sql { function __construct() { global $L_MYSQL_HOST,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$L_MYSQL_PWD; @@ -132,22 +117,23 @@ class DB_system extends DB_Sql { } $db = new DB_system(); -// $db = new Sql($L_MYSQL_DATABASE, $L_MYSQL_HOST, $L_MYSQL_LOGIN, $L_MYSQL_PWD); // Current User ID = the user whose commands are made on behalf of. $cuid = 0; $classes = array(); -/* CLASSES PHP : automatic include : */ + +/* PHP CLASSES : automatic include : */ foreach (glob($root . "class/m_*.php") as $di) { if (preg_match("#${root}class/m_(.*)\\.php$#", $di, $match)) { // $ $classes[] = $match[1]; require_once($di); } } + /* THE DEFAULT CLASSES ARE : - dom, ftp, mail, quota, bro, admin, mem, mysql, err, variables + dom, ftp, mail, quota, bro, admin, mem, mysql, messages, variables */ // Load file for the system class. @@ -160,7 +146,7 @@ foreach (glob($root . "class/class_system_*.php") as $fcs) { require_once($fcs); } -/* Language */ +/* Language environment setup */ include_once("lang_env.php"); $mem = new m_mem(); @@ -181,9 +167,10 @@ if ((variable_get('force_https', '0', "This variable is set to 0 (default) if us } } -// CHECK CSRF for ALL POSTS : -// you MUST add csrf_get(); after ALL
in AlternC ! - +/** + * Check csrf token for all posts: + * you MUST add csrf_get(); after ALL in AlternC ! + */ $fatalcsrf=false; if (count($_POST) && !defined("NOCSRF")) { if (csrf_check()<=0) { @@ -192,7 +179,7 @@ if (count($_POST) && !defined("NOCSRF")) { } } -/* Check the User identity (if required) */ +/* Check the User identity (if not disabled) */ if (!defined('NOCHECK')) { if (!$mem->checkid()) { if (!empty($_SERVER['PHP_AUTH_USER']) && !empty($_SERVER['PHP_AUTH_PW'])) { @@ -241,6 +228,7 @@ if ((variable_get('sql_max_username_length', NULL)==NULL)||(variable_get('sql_ma } + if ($fatalcsrf) { require_once("main.php"); exit(); diff --git a/bureau/class/config_nochk.php b/bureau/class/config_nochk.php index 5d2da96f..22cdd4b1 100644 --- a/bureau/class/config_nochk.php +++ b/bureau/class/config_nochk.php @@ -1,14 +1,6 @@ pdo_query->closeCursor(); } + function is_connected() { return $this->pdo_instance != FALSE; } + function last_error() { return $this->Error; } + + /** * Perform a query * @@ -169,6 +189,7 @@ class DB_Sql { return TRUE; } + /** * walk result set @@ -198,7 +219,10 @@ class DB_Sql { return TRUE; } - /* public: table locking */ + + /** + * table locking + */ function lock($table, $mode="write") { if (!$this->is_connected()) return FALSE; @@ -227,6 +251,9 @@ class DB_Sql { } + /** + * table unlocking + */ function unlock() { if (!$this->is_connected()) return FALSE; @@ -238,11 +265,12 @@ class DB_Sql { } - /* public: evaluate the result (size, width) */ + /** + * evaluate the result (size, width) + */ function affected_rows() { return $this->pdo_query->rowCount(); } - function num_rows() { return $this->pdo_query->rowCount(); } @@ -251,7 +279,9 @@ class DB_Sql { return $this->pdo_query->columnCount(); } - /* public: shorthand notation */ + /** + * shorthand notation + */ function nf() { return $this->num_rows(); } @@ -260,6 +290,7 @@ class DB_Sql { print $this->num_rows(); } + /** * @param string $Name * @return integer @@ -271,18 +302,22 @@ class DB_Sql { return false; } + function current_record() { return $this->Record; } + function p($Name) { print $this->Record[$Name]; } + function lastid() { return $this->pdo_instance->lastInsertId(); } + /** * Escape a string to use it into a SQL PDO query * @param string string to escape @@ -303,7 +338,9 @@ class DB_Sql { } - /* public: sequence numbers */ + /** + * get next sequence numbers + */ function nextid($seq_name) { if (!$this->is_connected()) return FALSE; @@ -345,14 +382,19 @@ class DB_Sql { return $nextid; } - /* public: return table metadata */ + + /** + * DEPRECATED return table metadata + */ function metadata($table='',$full=false) { global $msg; $msg->raise("ERROR", 'Mysql', 'function is no longer implemented (metadata())'); return FALSE; } - /* private: error handling */ + /** + * private: error handling + */ function halt($msg) { if ($this->Halt_On_Error == "no") return; @@ -363,6 +405,10 @@ class DB_Sql { die("Session halted."); } + + /** + * private: error handling + */ function haltmsg($msg) { printf("Database error: %s
\n", $msg); printf("MySQL Error: %s (%s)
\n", @@ -370,6 +416,7 @@ class DB_Sql { implode("\n", $this->Error)); } + function table_names() { $this->query("SHOW TABLES"); $return = array(); @@ -378,5 +425,6 @@ class DB_Sql { return $return; } -} -?> + +} /* Class DB_Sql */ + diff --git a/bureau/class/functions.php b/bureau/class/functions.php index bba64034..0627744e 100755 --- a/bureau/class/functions.php +++ b/bureau/class/functions.php @@ -1,10 +1,6 @@ ?)"; } + /** * * @param int $hid @@ -465,6 +484,7 @@ function linkhelp($hid) { echo getlinkhelp($hid); } + /** * * @param string $format @@ -490,6 +510,7 @@ function format_date($format, $date) { return sprintf($format, $d, $m, $y, $h, $i, $hh, $am); } + /** * Strip slashes if needed : * @param string $str @@ -503,11 +524,10 @@ function ssla($str) { } } -/* ----------------------------------------------------------------- */ -/** Hashe un mot de passe en clair en MD5 avec un salt al�atoire - * @param string $pass Mot de passe � crypter (max 32 caract�res) - * @return string Retourne le mot de passe crypt� +/** Hashe a password using proper crypto function + * @param string $pass a cleartext password to hash + * @return string the hash * @access private */ function _md5cr($pass, $salt = "") { @@ -521,6 +541,7 @@ function _md5cr($pass, $salt = "") { return crypt($pass, $salt); } + /** split mysql database name between username and custom database name * @param string $dbname database name * @return array returns username as first element, custom name as second @@ -531,7 +552,6 @@ function split_mysql_database_name($dbname) { implode("_", array_slice($db_exploded_name, 1))); } -/* ----------------------------------------------------------------- */ /** Echappe les caract�res pouvant perturber un flux XML standard : * @param string $string Chaine de caract�re � encoder en valeur xml. @@ -542,7 +562,6 @@ function xml_entities($string) { return str_replace("<", "<", str_replace(">", ">", str_replace("&", "&", $string))); } -/* ----------------------------------------------------------------- */ /** Converti un nombre de mois en une chaine plus lisible * @param integer $months Nombre de mois @@ -558,7 +577,6 @@ function pretty_months($months) { } } -/* ----------------------------------------------------------------- */ /** Fabrique un drop-down pour les dur�es de comptes * @name string $name Nom pour le composasnt @@ -589,6 +607,7 @@ function duration_list($name, $selected = 0) { return $res; } + /** * select_values($arr,$cur) echo des