Commit 6adef177 authored by alban's avatar alban
Browse files

[fix] code documentation, comments and cosmetic changes

parent 3b1e0a35
......@@ -17,11 +17,20 @@ class system_bind {
var $cache_domain_summary = array();
var $zone_file_directory = '/var/lib/alternc/bind/zones/';
/**
*
*/
function system_bind() {
// Constructeur
}
// Return the part of the conf we got from the database
/**
* Return the part of the conf we got from the database
*
* @global m_mysql $db
* @param string $domain
* @return array $this->cache_conf_db
*/
function conf_from_db($domain=false) {
global $db;
// Use cache, fill cache if empty
......@@ -53,11 +62,21 @@ class system_bind {
return $this->cache_conf_db;
}
// Return full path of the zone configuration file
/**
* Return full path of the zone configuration file
*
* @param string $domain
* @return string
*/
function get_zone_file_uri($domain) {
return $this->zone_file_directory.$domain;
}
/**
*
* @param string $domain
* @return string zone file path
*/
function get_zone_file($domain) {
// Use cache, fill cache if empty
if (!isset($this->cache_zone_file[$domain]) ) {
......@@ -70,6 +89,11 @@ class system_bind {
return $this->cache_zone_file[$domain] ;
}
/**
*
* @param string $domain
* @return string
*/
function get_serial($domain) {
// Return the next serial the domain must have.
// Choose between a generated and an incremented.
......@@ -89,7 +113,12 @@ class system_bind {
return max(array($calc,$old)) + 1 ;
}
// Return lines that are after ;;;END ALTERNC AUTOGENERATE CONFIGURATION
/**
* Return lines that are after ;;;END ALTERNC AUTOGENERATE CONFIGURATION
*
* @param string $domain
* @return string
*/
function get_persistent($domain) {
if ( ! isset($this->cache_get_persistent[$domain] )) {
preg_match_all('/\;\s*END\sALTERNC\sAUTOGENERATE\sCONFIGURATION(.*)/s', $this->get_zone_file($domain), $output_array);
......@@ -101,11 +130,22 @@ class system_bind {
} // isset
return $this->cache_get_persistent[$domain];
}
/**
*
* @param string $domain
* @return string
*/
function get_zone_header($domain) {
return file_get_contents($this->ZONE_TEMPLATE);
}
/**
*
* @global m_dom $dom
* @param string $domain
* @return string
*/
function get_domain_summary($domain=false) {
global $dom;
......@@ -118,6 +158,11 @@ class system_bind {
else return $this->cache_domain_summary;
}
/**
*
* @param string $domain
* @return boolean
*/
function dkim_delete($domain) {
$target_dir = "/etc/opendkim/keys/$domain";
if (file_exists($target_dir)) {
......@@ -128,7 +173,12 @@ class system_bind {
return true;
}
// Generate the domain DKIM key
/**
* Generate the domain DKIM key
*
* @param string $domain
* @return boolean
*/
function dkim_generate_key($domain) {
// Stop here if we do not manage the mail
if ( ! $this->get_domain_summary($domain)['gesmx'] ) return;
......@@ -152,8 +202,11 @@ class system_bind {
return true; // FIXME handle error
}
// Refresh DKIM configuration: be sure to list the domain having a private key (and only them)
function dkim_refresh_list() { // so ugly... but there is only 1 pass, not 3. Still ugly.
/**
* Refresh DKIM configuration: be sure to list the domain having a private key (and only them)
*/
function dkim_refresh_list() {
// so ugly... but there is only 1 pass, not 3. Still ugly.
$trusted_host_new = "# WARNING: this file is auto generated by AlternC.\n# Add your changes after the last line\n";
$keytable_new = "# WARNING: this file is auto generated by AlternC.\n# Add your changes after the last line\n";
$signingtable_new = "# WARNING: this file is auto generated by AlternC.\n# Add your changes after the last line\n";
......@@ -206,7 +259,11 @@ class system_bind {
}
}
/**
*
* @param string $domain
* @return string
*/
function dkim_entry($domain) {
$keyfile="/etc/opendkim/keys/$domain/alternc.txt";
if (! file_exists($keyfile) && $this->get_domain_summary($domain)['gesmx'] ) {
......@@ -215,8 +272,13 @@ 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.
/**
* Conditionnal generation autoconfig entry for outlook / thunderbird
* If entry with the same name allready exist, skip it.
*
* @param string $domain
* @return string
*/
function mail_autoconfig_entry($domain) {
$zone= implode("\n",$this->conf_from_db($domain))."\n".$this->get_persistent($domain);
......@@ -236,7 +298,20 @@ class system_bind {
return $entry;
}
// Return a fully generated zone
/**
*
* Return a fully generated zone
*
* @global string $L_FQDN
* @global string $L_NS1_HOSTNAME
* @global string $L_NS2_HOSTNAME
* @global string $L_DEFAULT_MX
* @global string $L_DEFAULT_SECONDARY_MX
* @global string $L_PUBLIC_IP
* @param string $domain
* @return string
*/
function get_zone($domain) {
global $L_FQDN, $L_NS1_HOSTNAME, $L_NS2_HOSTNAME, $L_DEFAULT_MX, $L_DEFAULT_SECONDARY_MX, $L_PUBLIC_IP;
......@@ -271,6 +346,10 @@ class system_bind {
return $zone;
}
/**
*
* @param string $domain
*/
function reload_zone($domain) {
exec($this->RNDC." reload ".escapeshellarg($domain), $output, $return_value);
if ($return_value != 0 ) {
......@@ -278,7 +357,12 @@ class system_bind {
}
}
// return true if zone is locked
/**
* return true if zone is locked
*
* @param string $domain
* @return boolean
*/
function is_locked($domain) {
preg_match_all("/(\;\s*LOCKED:YES)/i", $this->get_zone_file($domain), $output_array);
if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
......@@ -287,6 +371,13 @@ class system_bind {
return false;
}
/**
*
* @global m_mysql $db
* @global m_dom $dom
* @param string $domain
* @return boolean
*/
function save_zone($domain) {
global $db, $dom;
......@@ -307,16 +398,26 @@ class system_bind {
return true; // fixme add tests
}
// Delete the zone configuration file
/**
* Delete the zone configuration file
*
* @param string $domain
* @return boolean
*/
function delete_zone($domain) {
$file=$this->get_zone_file_uri($domain);
if (file_exists($file)) {
unlink($file);
}
$this->dkim_delete($domain);
return;
return true;
}
/**
*
* @global m_hooks $hooks
* @return boolean
*/
function reload_named() {
global $hooks;
// Generate the new conf file
......@@ -342,7 +443,13 @@ class system_bind {
return true;
}
// Regenerate bind configuration and load it
/**
* Regenerate bind configuration and load it
*
* @global m_hooks $hooks
* @param boolean $all
* @return boolean
*/
function regenerate_conf($all=false) {
global $hooks;
......@@ -365,10 +472,12 @@ class system_bind {
$this->dkim_refresh_list();
$this->reload_named();
return;
return true;
}
/**
*
*/
private function dummy_for_translation() {
_("The zone file of this domain is locked. Contact your administrator.");
}
......
......@@ -40,8 +40,8 @@ session_name('AlternC_Panel');
session_start();
/*
Si vous voulez mettre le bureau en maintenance, dcommentez le code ci-dessous
et mettez votre ip dans le IF pour que seule votre ip puisse accder au bureau :
Si vous voulez mettre le bureau en maintenance, d�commentez le code ci-dessous
et mettez votre ip dans le IF pour que seule votre ip puisse acc�der au bureau :
*/
/* * /
......@@ -52,8 +52,8 @@ Merci de revenir plus tard.";
}
/* */
/* Toutes les pages du bureau passent ici. On utilise une smaphore pour
s'assurer que personne ne pourra accder 2 pages du bureau en mme temps.
/* Toutes les pages du bureau passent ici. On utilise une s�maphore pour
s'assurer que personne ne pourra acc�der � 2 pages du bureau en m�me temps.
*/
/* * /
// 1. Get a semaphore id for the alternc magic number (18577)
......@@ -100,6 +100,7 @@ require_once(dirname(__FILE__)."/local.php");
// Define constants from vars of /etc/alternc/local.sh
// The you can't choose where is the AlternC Panel
define("DEFAULT_PASS_SIZE", 8);
define('ALTERNC_MAIL', "$L_ALTERNC_MAIL");
define('ALTERNC_HTML', "$L_ALTERNC_HTML");
if(isset($L_ALTERNC_LOGS_ARCHIVE))
......@@ -121,13 +122,13 @@ $root=ALTERNC_PANEL."/";
require_once($root."/class/db_mysql.php");
require_once($root."/class/functions.php");
// Redirection si appel https://(!fqdn)/
// Redirection si appel � https://(!fqdn)/
if (isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"]=="on" && $host!=$L_FQDN) {
header("Location: https://$L_FQDN/");
}
// Classe hrite de la classe db de la phplib.
// Classe h�rit�e de la classe db de la phplib.
/**
* Class for MySQL management in the bureau
*
......
This diff is collapsed.
......@@ -380,7 +380,7 @@ class m_admin {
$err->raise("admin",_("Subject, message and sender are mandatory"));
return false;
}
//@todo remove cf functions.php
if (checkmail($from) != 0) {
$err->raise("admin",_("Sender is syntaxically incorrect"));
return false;
......@@ -512,6 +512,7 @@ class m_admin {
$err->raise("admin",_("All fields are mandatory"));
return false;
}
//@todo remove cf functions.php
if (checkmail($mail)!=0){
$err->raise("admin",_("Please enter a valid email address"));
return false;
......
......@@ -129,6 +129,8 @@ class m_cron {
$user=urlencode($user);
if (empty($user)) $password='';
$password=urlencode($password);
//@todo remove checkmail cf functions.php
if (!empty($email) && ! checkmail($email) == 0 ){
$err->raise("cron",_("Email address is not valid"));
return false;
......
......@@ -178,7 +178,7 @@ class m_hta {
if (!$file) {
return false;
}
// TODO: Tester la validit du .htpasswd
// TODO: Tester la validit du .htpasswd
while (!feof($file)) {
$s=fgets($file,1024);
$t=explode(":",$s);
......@@ -242,6 +242,7 @@ class m_hta {
$err->raise("hta",printf(("The folder '%s' does not exist"),$dir));
return false;
}
// @todo delete cf!. functions.php checkloginemail definition
if (checkloginmail($user)){
// Check this password against the password policy using common API :
if (is_callable(array($admin,"checkPolicy"))) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment