diff --git a/bureau/class/class_system_bind.php b/bureau/class/class_system_bind.php
index d488e1ab..7d2cb9c0 100644
--- a/bureau/class/class_system_bind.php
+++ b/bureau/class/class_system_bind.php
@@ -2,40 +2,40 @@
class system_bind {
- var $ZONE_TEMPLATE ="/etc/alternc/templates/bind/templates/zone.template";
- var $NAMED_TEMPLATE ="/etc/alternc/templates/bind/templates/named.template";
- var $NAMED_CONF ="/var/lib/alternc/bind/automatic.conf";
- var $RNDC ="/usr/sbin/rndc";
+ var $ZONE_TEMPLATE ="/etc/alternc/templates/bind/templates/zone.template";
+ var $NAMED_TEMPLATE ="/etc/alternc/templates/bind/templates/named.template";
+ var $NAMED_CONF ="/var/lib/alternc/bind/automatic.conf";
+ var $RNDC ="/usr/sbin/rndc";
- var $dkim_trusted_host_file = "/etc/opendkim/TrustedHosts";
- var $dkim_keytable_file = "/etc/opendkim/KeyTable";
- var $dkim_signingtable_file = "/etc/opendkim/SigningTable";
+ var $dkim_trusted_host_file = "/etc/opendkim/TrustedHosts";
+ var $dkim_keytable_file = "/etc/opendkim/KeyTable";
+ var $dkim_signingtable_file = "/etc/opendkim/SigningTable";
- var $cache_conf_db = array();
- var $cache_get_persistent = array();
- var $cache_zone_file = array();
- var $cache_domain_summary = array();
- var $zone_file_directory = '/var/lib/alternc/bind/zones/';
+ var $cache_conf_db = array();
+ var $cache_get_persistent = array();
+ var $cache_zone_file = array();
+ var $cache_domain_summary = array();
+ var $zone_file_directory = '/var/lib/alternc/bind/zones/';
- /**
- *
- */
- function system_bind() {
- // Constructeur
- }
+ /**
+ *
+ */
+ function system_bind() {
+ // Constructeur
+ }
- /**
- * 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
- if (empty($this->cache_conf_db)) {
- $db->query("
+ /**
+ * 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
+ if (empty($this->cache_conf_db)) {
+ $db->query("
select
sd.domaine,
replace(replace(dt.entry,'%TARGET%',sd.valeur), '%SUB%', if(length(sd.sub)>0,sd.sub,'@')) as entry
@@ -46,290 +46,290 @@ class system_bind {
sd.type=dt.name
and sd.enable in ('ENABLE', 'ENABLED')
order by entry ;");
- $t=array();
- while ($db->next_record()) {
- $t[$db->f('domaine')][] = $db->f('entry');
- }
- $this->cache_conf_db = $t;
+ $t=array();
+ while ($db->next_record()) {
+ $t[$db->f('domaine')][] = $db->f('entry');
+ }
+ $this->cache_conf_db = $t;
+ }
+ if ($domain) {
+ if (isset($this->cache_conf_db[$domain])) {
+ return $this->cache_conf_db[$domain];
+ } else {
+ return array();
+ }
+ } // if domain
+ return $this->cache_conf_db;
}
- if ($domain) {
- if (isset($this->cache_conf_db[$domain])) {
- return $this->cache_conf_db[$domain];
- } else {
- return array();
- }
- } // if domain
- return $this->cache_conf_db;
- }
- /**
- * 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]) ) {
- if (file_exists($this->get_zone_file_uri($domain))) {
- $this->cache_zone_file[$domain] = @file_get_contents($this->get_zone_file_uri($domain));
- } else {
- $this->cache_zone_file[$domain] = false;
- }
+ /**
+ * 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;
}
- 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.
+ /**
+ *
+ * @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]) ) {
+ if (file_exists($this->get_zone_file_uri($domain))) {
+ $this->cache_zone_file[$domain] = @file_get_contents($this->get_zone_file_uri($domain));
+ } else {
+ $this->cache_zone_file[$domain] = false;
+ }
+ }
+ 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.
- // Calculated :
- $calc = date('Ymd').'00'."\n";
+ // Calculated :
+ $calc = date('Ymd').'00'."\n";
- // Old one :
- $old=$calc; // default value
- $file = $this->get_zone_file($domain);
- preg_match_all("/\s*(\d{10})\s+\;\sserial\s?/", $file, $output_array);
- if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
- $old = $output_array[1][0];
+ // Old one :
+ $old=$calc; // default value
+ $file = $this->get_zone_file($domain);
+ preg_match_all("/\s*(\d{10})\s+\;\sserial\s?/", $file, $output_array);
+ if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
+ $old = $output_array[1][0];
+ }
+
+ // Return max between newly calculated, and old one incremented
+ return max(array($calc,$old)) + 1 ;
}
- // Return max between newly calculated, and old one incremented
- return max(array($calc,$old)) + 1 ;
- }
-
- /**
- * 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);
- if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
- $this->cache_get_persistent[$domain] = $output_array[1][0];
- } else {
- $this->cache_get_persistent[$domain] = false;
- }
- } // isset
- return $this->cache_get_persistent[$domain];
- }
+ /**
+ * 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);
+ if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
+ $this->cache_get_persistent[$domain] = $output_array[1][0];
+ } else {
+ $this->cache_get_persistent[$domain] = false;
+ }
+ } // isset
+ return $this->cache_get_persistent[$domain];
+ }
- /**
- *
- * @return string
- */
- function get_zone_header() {
- return file_get_contents($this->ZONE_TEMPLATE);
- }
+ /**
+ *
+ * @return string
+ */
+ function get_zone_header() {
+ return file_get_contents($this->ZONE_TEMPLATE);
+ }
- /**
- *
- * @global m_dom $dom
- * @param string $domain
- * @return array Retourne un tableau
- */
- function get_domain_summary($domain=false) {
- global $dom;
+ /**
+ *
+ * @global m_dom $dom
+ * @param string $domain
+ * @return array Retourne un tableau
+ */
+ function get_domain_summary($domain=false) {
+ global $dom;
- // Use cache if is filled, if not, fill it
- if (empty($this->cache_domain_summary)) {
- $this->cache_domain_summary = $dom->get_domain_all_summary();
+ // Use cache if is filled, if not, fill it
+ if (empty($this->cache_domain_summary)) {
+ $this->cache_domain_summary = $dom->get_domain_all_summary();
+ }
+
+ if ($domain) return $this->cache_domain_summary[$domain];
+ else return $this->cache_domain_summary;
}
- if ($domain) return $this->cache_domain_summary[$domain];
- 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)) {
- @unlink("$target_dir/alternc_private");
- @unlink("$target_dir/alternc.txt");
- @rmdir($target_dir);
+ /**
+ *
+ * @param string $domain
+ * @return boolean
+ */
+ function dkim_delete($domain) {
+ $target_dir = "/etc/opendkim/keys/$domain";
+ if (file_exists($target_dir)) {
+ @unlink("$target_dir/alternc_private");
+ @unlink("$target_dir/alternc.txt");
+ @rmdir($target_dir);
+ }
+ return true;
}
- return true;
- }
- /**
- * Generate the domain DKIM key
- *
- * @param string $domain
- * @return null|boolean
- */
- function dkim_generate_key($domain) {
- // Stop here if we do not manage the mail
- $domainInfo = $this->get_domain_summary($domain);
- if ( ! $domainInfo['gesmx'] ) return;
+ /**
+ * Generate the domain DKIM key
+ *
+ * @param string $domain
+ * @return null|boolean
+ */
+ function dkim_generate_key($domain) {
+ // Stop here if we do not manage the mail
+ $domainInfo = $this->get_domain_summary($domain);
+ if ( ! $domainInfo['gesmx'] ) return;
- $target_dir = "/etc/opendkim/keys/$domain";
+ $target_dir = "/etc/opendkim/keys/$domain";
- if (file_exists($target_dir.'/alternc.txt')) return; // Do not generate if exist
+ if (file_exists($target_dir.'/alternc.txt')) return; // Do not generate if exist
- if (! is_dir($target_dir)) mkdir($target_dir); // create dir
+ if (! is_dir($target_dir)) mkdir($target_dir); // create dir
- // Generate the key
- $old_dir=getcwd();
- chdir($target_dir);
- exec('opendkim-genkey -r -d '.escapeshellarg($domain).' -s "alternc" ');
- chdir($old_dir);
+ // Generate the key
+ $old_dir=getcwd();
+ chdir($target_dir);
+ exec('opendkim-genkey -r -d '.escapeshellarg($domain).' -s "alternc" ');
+ chdir($old_dir);
- // opendkim must be owner of the key
- chown("$target_dir/alternc.private", 'opendkim');
- chgrp("$target_dir/alternc.private", 'opendkim');
+ // opendkim must be owner of the key
+ chown("$target_dir/alternc.private", 'opendkim');
+ chgrp("$target_dir/alternc.private", 'opendkim');
- 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.
- $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";
-
- # Generate automatic entry
- foreach ($this->get_domain_summary() as $domain => $ds ) {
- // Skip if delete in progress, or if we do not manage dns or mail
- if ( ! $ds['gesdns'] || ! $ds['gesmx'] || strtoupper($ds['dns_action']) == 'DELETE' ) continue;
-
- // Skip if there is no key generated
- if (! file_exists("/etc/opendkim/keys/$domain/alternc.txt")) continue;
-
- // Modif the files.
- $trusted_host_new.="$domain\n";
- $keytable_new .="alternc._domainkey.$domain $domain:alternc:/etc/opendkim/keys/$domain/alternc.private\n";
- $signingtable_new.="$domain alternc._domainkey.$domain\n";
+ return true; // FIXME handle error
}
- $trusted_host_new.="# END AUTOMATIC FILE. ADD YOUR CHANGES AFTER THIS LINE\n";
- $keytable_new .="# END AUTOMATIC FILE. ADD YOUR CHANGES AFTER THIS LINE\n";
- $signingtable_new.="# END AUTOMATIC FILE. ADD YOUR CHANGES AFTER THIS LINE\n";
- # Get old files
- $trusted_host_old=@file_get_contents($this->dkim_trusted_host_file);
- $keytable_old =@file_get_contents($this->dkim_keytable_file);
- $signingtable_old=@file_get_contents($this->dkim_signingtable_file);
+ /**
+ * 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";
+
+ # Generate automatic entry
+ foreach ($this->get_domain_summary() as $domain => $ds ) {
+ // Skip if delete in progress, or if we do not manage dns or mail
+ if ( ! $ds['gesdns'] || ! $ds['gesmx'] || strtoupper($ds['dns_action']) == 'DELETE' ) continue;
+
+ // Skip if there is no key generated
+ if (! file_exists("/etc/opendkim/keys/$domain/alternc.txt")) continue;
+
+ // Modif the files.
+ $trusted_host_new.="$domain\n";
+ $keytable_new .="alternc._domainkey.$domain $domain:alternc:/etc/opendkim/keys/$domain/alternc.private\n";
+ $signingtable_new.="$domain alternc._domainkey.$domain\n";
+ }
+ $trusted_host_new.="# END AUTOMATIC FILE. ADD YOUR CHANGES AFTER THIS LINE\n";
+ $keytable_new .="# END AUTOMATIC FILE. ADD YOUR CHANGES AFTER THIS LINE\n";
+ $signingtable_new.="# END AUTOMATIC FILE. ADD YOUR CHANGES AFTER THIS LINE\n";
+
+ # Get old files
+ $trusted_host_old=@file_get_contents($this->dkim_trusted_host_file);
+ $keytable_old =@file_get_contents($this->dkim_keytable_file);
+ $signingtable_old=@file_get_contents($this->dkim_signingtable_file);
- # Keep manuel entry
- preg_match_all('/\#\s*END\ AUTOMATIC\ FILE\.\ ADD\ YOUR\ CHANGES\ AFTER\ THIS\ LINE(.*)/s', $trusted_host_old, $output_array);
- if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
- $trusted_host_new.=$output_array[1][0];
- }
- preg_match_all('/\#\s*END\ AUTOMATIC\ FILE\.\ ADD\ YOUR\ CHANGES\ AFTER\ THIS\ LINE(.*)/s', $keytable_old, $output_array);
- if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
- $keytable_new.=$output_array[1][0];
- }
- preg_match_all('/\#\s*END\ AUTOMATIC\ FILE\.\ ADD\ YOUR\ CHANGES\ AFTER\ THIS\ LINE(.*)/s', $signingtable_old, $output_array);
- if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
- $signingtable_new.=$output_array[1][0];
- }
+ # Keep manuel entry
+ preg_match_all('/\#\s*END\ AUTOMATIC\ FILE\.\ ADD\ YOUR\ CHANGES\ AFTER\ THIS\ LINE(.*)/s', $trusted_host_old, $output_array);
+ if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
+ $trusted_host_new.=$output_array[1][0];
+ }
+ preg_match_all('/\#\s*END\ AUTOMATIC\ FILE\.\ ADD\ YOUR\ CHANGES\ AFTER\ THIS\ LINE(.*)/s', $keytable_old, $output_array);
+ if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
+ $keytable_new.=$output_array[1][0];
+ }
+ preg_match_all('/\#\s*END\ AUTOMATIC\ FILE\.\ ADD\ YOUR\ CHANGES\ AFTER\ THIS\ LINE(.*)/s', $signingtable_old, $output_array);
+ if (isset($output_array[1][0]) && !empty($output_array[1][0])) {
+ $signingtable_new.=$output_array[1][0];
+ }
- // Save if there are some diff
- if ( $trusted_host_new != $trusted_host_old ) {
- file_put_contents($this->dkim_trusted_host_file, $trusted_host_new);
+ // Save if there are some diff
+ if ( $trusted_host_new != $trusted_host_old ) {
+ file_put_contents($this->dkim_trusted_host_file, $trusted_host_new);
+ }
+ if ( $keytable_new != $keytable_old ) {
+ file_put_contents($this->dkim_keytable_file, $keytable_new);
+ }
+ if ( $signingtable_new != $signingtable_old ) {
+ file_put_contents($this->dkim_signingtable_file, $signingtable_new);
+ }
+
}
- if ( $keytable_new != $keytable_old ) {
- file_put_contents($this->dkim_keytable_file, $keytable_new);
- }
- if ( $signingtable_new != $signingtable_old ) {
- file_put_contents($this->dkim_signingtable_file, $signingtable_new);
+ /**
+ *
+ * @param string $domain
+ * @return string
+ */
+ function dkim_entry($domain) {
+ $keyfile="/etc/opendkim/keys/$domain/alternc.txt";
+ $domainInfo = $this->get_domain_summary($domain);
+ if (! file_exists($keyfile) && $domainInfo['gesmx'] ) {
+ $this->dkim_generate_key($domain);
+ }
+ return @file_get_contents($keyfile);
}
- }
- /**
- *
- * @param string $domain
- * @return string
- */
- function dkim_entry($domain) {
- $keyfile="/etc/opendkim/keys/$domain/alternc.txt";
- $domainInfo = $this->get_domain_summary($domain);
- if (! file_exists($keyfile) && $domainInfo['gesmx'] ) {
- $this->dkim_generate_key($domain);
+ /**
+ * 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);
+
+ $entry='';
+ $domainInfo = $this->get_domain_summary($domain);
+ if ( $domainInfo['gesmx'] ) {
+ // If we manage the mail
+
+ // Check if there is no the same entry (defined or manual)
+ // can be toto IN A or toto.fqdn.tld. IN A
+ if (! preg_match("/autoconfig(\s|\.".str_replace('.','\.',$domain)."\.)/", $zone )) {
+ $entry.="autoconfig IN CNAME %%fqdn%%.\n";
+ }
+ if (! preg_match("/autodiscover(\s|\.".str_replace('.','\.',$domain)."\.)/", $zone )) {
+ $entry.="autodiscover IN CNAME %%fqdn%%.\n";
+ }
+ } // if gesmx
+ return $entry;
}
- return @file_get_contents($keyfile);
- }
-
- /**
- * 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);
-
- $entry='';
- $domainInfo = $this->get_domain_summary($domain);
- if ( $domainInfo['gesmx'] ) {
- // If we manage the mail
-
- // Check if there is no the same entry (defined or manual)
- // can be toto IN A or toto.fqdn.tld. IN A
- if (! preg_match("/autoconfig(\s|\.".str_replace('.','\.',$domain)."\.)/", $zone )) {
- $entry.="autoconfig IN CNAME %%fqdn%%.\n";
- }
- if (! preg_match("/autodiscover(\s|\.".str_replace('.','\.',$domain)."\.)/", $zone )) {
- $entry.="autodiscover IN CNAME %%fqdn%%.\n";
- }
- } // if gesmx
- return $entry;
- }
- /**
- *
- * 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;
+ /**
+ *
+ * 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;
- $zone =$this->get_zone_header();
- $zone.=implode("\n",$this->conf_from_db($domain));
- $zone.="\n;;;HOOKED ENTRY\n";
+ $zone =$this->get_zone_header();
+ $zone.=implode("\n",$this->conf_from_db($domain));
+ $zone.="\n;;;HOOKED ENTRY\n";
- $zone.= $this->dkim_entry($domain);
- $zone.= $this->mail_autoconfig_entry($domain);
+ $zone.= $this->dkim_entry($domain);
+ $zone.= $this->mail_autoconfig_entry($domain);
- $zone.="\n;;; END ALTERNC AUTOGENERATE CONFIGURATION\n";
- $zone.=$this->get_persistent($domain);
- $domainInfo = $this->get_domain_summary($domain);
+ $zone.="\n;;; END ALTERNC AUTOGENERATE CONFIGURATION\n";
+ $zone.=$this->get_persistent($domain);
+ $domainInfo = $this->get_domain_summary($domain);
- // FIXME check those vars
- $zone = strtr($zone, array(
+ // FIXME check those vars
+ $zone = strtr($zone, array(
"%%fqdn%%"=>"$L_FQDN",
"%%ns1%%"=>"$L_NS1_HOSTNAME",
"%%ns2%%"=>"$L_NS2_HOSTNAME",
@@ -344,146 +344,146 @@ class system_bind {
"@@SERIAL@@"=>$this->get_serial($domain),
"@@PUBLIC_IP@@"=>"$L_PUBLIC_IP",
"@@ZONETTL@@"=> $domainInfo['zonettl'],
- ));
+ ));
- return $zone;
- }
-
- /**
- *
- * @param string $domain
- */
- function reload_zone($domain) {
- exec($this->RNDC." reload ".escapeshellarg($domain), $output, $return_value);
- if ($return_value != 0 ) {
- echo "ERROR: Reload zone failed for zone $domain\n";
+ return $zone;
}
- }
- /**
- * 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])) {
- return true;
+ /**
+ *
+ * @param string $domain
+ */
+ function reload_zone($domain) {
+ exec($this->RNDC." reload ".escapeshellarg($domain), $output, $return_value);
+ if ($return_value != 0 ) {
+ echo "ERROR: Reload zone failed for zone $domain\n";
+ }
}
- return false;
- }
- /**
- *
- * @global m_mysql $db
- * @global m_dom $dom
- * @param string $domain
- * @return boolean
- */
- function save_zone($domain) {
- global $db, $dom;
+ /**
+ * 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])) {
+ return true;
+ }
+ return false;
+ }
- // Do not save if the zone is LOCKED
- if ( $this->is_locked($domain)) {
- $dom->set_dns_result($domain, "The zone file of this domain is locked. Contact your administrator."); // If edit, change dummy_for_translation
- $dom->set_dns_action($domain, 'OK');
- return false;
- }
+ /**
+ *
+ * @global m_mysql $db
+ * @global m_dom $dom
+ * @param string $domain
+ * @return boolean
+ */
+ function save_zone($domain) {
+ global $db, $dom;
+
+ // Do not save if the zone is LOCKED
+ if ( $this->is_locked($domain)) {
+ $dom->set_dns_result($domain, "The zone file of this domain is locked. Contact your administrator."); // If edit, change dummy_for_translation
+ $dom->set_dns_action($domain, 'OK');
+ return false;
+ }
- // Save file, and apply chmod/chown
- $file=$this->get_zone_file_uri($domain);
- file_put_contents($file, $this->get_zone($domain));
- chown($file, 'bind');
- chmod($file, 0640);
+ // Save file, and apply chmod/chown
+ $file=$this->get_zone_file_uri($domain);
+ file_put_contents($file, $this->get_zone($domain));
+ chown($file, 'bind');
+ chmod($file, 0640);
- $dom->set_dns_action($domain, 'OK');
- return true; // fixme add tests
- }
-
- /**
- * 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 true;
- }
-
- /**
- *
- * @global m_hooks $hooks
- * @return boolean
- */
- function reload_named() {
- global $hooks;
- // Generate the new conf file
- $new_named_conf="// DO NOT EDIT\n// This file is generated by Alternc.\n// Every changes you'll make will be overwrited.\n";
- $tpl=file_get_contents($this->NAMED_TEMPLATE);
- foreach ($this->get_domain_summary() as $domain => $ds ) {
- if ( ! $ds['gesdns'] || strtoupper($ds['dns_action']) == 'DELETE' ) continue;
- $new_named_conf.=strtr($tpl, array("@@DOMAINE@@"=>$domain, "@@ZONE_FILE@@"=>$this->get_zone_file_uri($domain)));
+ $dom->set_dns_action($domain, 'OK');
+ return true; // fixme add tests
}
- // Get the actual conf file
- $old_named_conf = @file_get_contents($this->NAMED_CONF);
-
- // Apply new configuration only if there are some differences
- if ($old_named_conf != $new_named_conf ) {
- file_put_contents($this->NAMED_CONF,$new_named_conf);
- chown($this->NAMED_CONF, 'bind');
- chmod($this->NAMED_CONF, 0640);
- exec($this->RNDC." reconfig");
- $hooks->invoke_scripts("/usr/lib/alternc/reload.d", array('dns_reconfig') );
+ /**
+ * 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 true;
}
- return true;
- }
+ /**
+ *
+ * @global m_hooks $hooks
+ * @return boolean
+ */
+ function reload_named() {
+ global $hooks;
+ // Generate the new conf file
+ $new_named_conf="// DO NOT EDIT\n// This file is generated by Alternc.\n// Every changes you'll make will be overwrited.\n";
+ $tpl=file_get_contents($this->NAMED_TEMPLATE);
+ foreach ($this->get_domain_summary() as $domain => $ds ) {
+ if ( ! $ds['gesdns'] || strtoupper($ds['dns_action']) == 'DELETE' ) continue;
+ $new_named_conf.=strtr($tpl, array("@@DOMAINE@@"=>$domain, "@@ZONE_FILE@@"=>$this->get_zone_file_uri($domain)));
+ }
- /**
- * Regenerate bind configuration and load it
- *
- * @global m_hooks $hooks
- * @param boolean $all
- * @return boolean
- */
- function regenerate_conf($all=false) {
- global $hooks;
+ // Get the actual conf file
+ $old_named_conf = @file_get_contents($this->NAMED_CONF);
- foreach ($this->get_domain_summary() as $domain => $ds ) {
- if ( ! $ds['gesdns'] && strtoupper($ds['dns_action']) == 'OK' ) continue; // Skip if we do not manage DNS and is up-to-date for this domain
+ // Apply new configuration only if there are some differences
+ if ($old_named_conf != $new_named_conf ) {
+ file_put_contents($this->NAMED_CONF,$new_named_conf);
+ chown($this->NAMED_CONF, 'bind');
+ chmod($this->NAMED_CONF, 0640);
+ exec($this->RNDC." reconfig");
+ $hooks->invoke_scripts("/usr/lib/alternc/reload.d", array('dns_reconfig') );
+ }
- if ( (strtoupper($ds['dns_action']) == 'DELETE' ) ||
- (strtoupper($ds['dns_action']) == 'UPDATE' && $ds['gesdns']==false ) // in case we update the zone to disable DNS management
- ) {
- $this->delete_zone($domain);
- continue;
- }
+ return true;
+ }
- if ( ( $all || strtoupper($ds['dns_action']) == 'UPDATE' ) && $ds['gesdns'] ) {
- $this->save_zone($domain);
- $this->reload_zone($domain);
- $hooks->invoke_scripts("/usr/lib/alternc/reload.d", array('dns_reload_zone', $domain) );
- }
- } // end foreach domain
+ /**
+ * Regenerate bind configuration and load it
+ *
+ * @global m_hooks $hooks
+ * @param boolean $all
+ * @return boolean
+ */
+ function regenerate_conf($all=false) {
+ global $hooks;
- $this->dkim_refresh_list();
- $this->reload_named();
- return true;
- }
+ foreach ($this->get_domain_summary() as $domain => $ds ) {
+ if ( ! $ds['gesdns'] && strtoupper($ds['dns_action']) == 'OK' ) continue; // Skip if we do not manage DNS and is up-to-date for this domain
- /**
- *
- */
- private function dummy_for_translation() {
- _("The zone file of this domain is locked. Contact your administrator.");
- }
+ if ( (strtoupper($ds['dns_action']) == 'DELETE' ) ||
+ (strtoupper($ds['dns_action']) == 'UPDATE' && $ds['gesdns']==false ) // in case we update the zone to disable DNS management
+ ) {
+ $this->delete_zone($domain);
+ continue;
+ }
+
+ if ( ( $all || strtoupper($ds['dns_action']) == 'UPDATE' ) && $ds['gesdns'] ) {
+ $this->save_zone($domain);
+ $this->reload_zone($domain);
+ $hooks->invoke_scripts("/usr/lib/alternc/reload.d", array('dns_reload_zone', $domain) );
+ }
+ } // end foreach domain
+
+ $this->dkim_refresh_list();
+ $this->reload_named();
+ return true;
+ }
+
+ /**
+ *
+ */
+ private function dummy_for_translation() {
+ _("The zone file of this domain is locked. Contact your administrator.");
+ }
} // class
diff --git a/bureau/class/config.php b/bureau/class/config.php
index 1d937dd6..220da71e 100755
--- a/bureau/class/config.php
+++ b/bureau/class/config.php
@@ -27,7 +27,7 @@
Original Author of file: Benjamin Sonntag
Purpose of file: General configuration file for AlternC Desktop
----------------------------------------------------------------------
- */
+*/
define('DO_XHPROF_STATS', FALSE);
if (DO_XHPROF_STATS) {
@@ -45,15 +45,15 @@ session_start();
/*
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 :
- */
+*/
/* * /
- if (getenv("REMOTE_ADDR")!="127.0.0.1") {
- echo "Le bureau AlternC est en vacances jusqu'a minuit pour maintenance.
- Merci de revenir plus tard.";
- exit();
- }
- /* */
+ if (getenv("REMOTE_ADDR")!="127.0.0.1") {
+ echo "Le bureau AlternC est en vacances jusqu'a minuit pour maintenance.
+ 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 !!");
@@ -125,10 +125,10 @@ require_once($root . "/class/variables.php");
*/
class DB_system extends DB_Sql {
- function __construct() {
- global $L_MYSQL_HOST,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$L_MYSQL_PWD;
- parent::__construct($L_MYSQL_DATABASE, $L_MYSQL_HOST, $L_MYSQL_LOGIN, $L_MYSQL_PWD);
- }
+ function __construct() {
+ global $L_MYSQL_HOST,$L_MYSQL_DATABASE,$L_MYSQL_LOGIN,$L_MYSQL_PWD;
+ parent::__construct($L_MYSQL_DATABASE, $L_MYSQL_HOST, $L_MYSQL_LOGIN, $L_MYSQL_PWD);
+ }
}
$db = new DB_system();
@@ -147,8 +147,8 @@ foreach (glob($root . "class/m_*.php") as $di) {
}
}
/* 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.
// Those class will not be build by default.
@@ -176,8 +176,8 @@ if (isset($_SERVER["HTTP_X_FORWARDED_PROTO"]) && $_SERVER["HTTP_X_FORWARDED_PROT
if ((variable_get('force_https', '0', "This variable is set to 0 (default) if users can access the management desktop through HTTP, otherwise we force HTTPS")&&(!isset($_SERVER["HTTPS"])|| ($_SERVER["HTTPS"] != "on")))) {
// do not redirect if access is not by HTTP(s)
if (isset($_SERVER['REQUEST_URI'])) {
- header("Location: https://".$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI']);
- exit;
+ header("Location: https://".$_SERVER["HTTP_HOST"].$_SERVER['REQUEST_URI']);
+ exit;
}
}
@@ -186,10 +186,10 @@ if ((variable_get('force_https', '0', "This variable is set to 0 (default) if us
$fatalcsrf=false;
if (count($_POST) && !defined("NOCSRF")) {
- if (csrf_check()<=0) {
- // We will trigger the error LATER in the code => need initialization of classes
- $fatalcsrf=true;
- }
+ if (csrf_check()<=0) {
+ // We will trigger the error LATER in the code => need initialization of classes
+ $fatalcsrf=true;
+ }
}
/* Check the User identity (if required) */
@@ -233,10 +233,10 @@ if ((variable_get('sql_max_username_length', NULL)==NULL)||(variable_get('sql_ma
$result = $db->query("SELECT (SELECT CHARACTER_MAXIMUM_LENGTH length FROM information_schema.columns WHERE TABLE_SCHEMA='mysql' and TABLE_NAME='user' and COLUMN_NAME='User') username, (SELECT CHARACTER_MAXIMUM_LENGTH length FROM information_schema.columns WHERE TABLE_SCHEMA='mysql' and TABLE_NAME='db' and COLUMN_NAME='Db') `database`");
if ($db->next_record($result)) {
$variable = $db->Record;
- $variable['username']=min(128, $variable['username']);
- $variable['database']=min($variable['database'], $variable['username']);
- variable_set('sql_max_username_length', $variable['username'], 'Maximum length allowed for SQL usernames by your SQL server (do not modify unless you know what you do)');
- variable_set('sql_max_database_length', $variable['database'], 'Maximum length allowed for SQL database names by your SQL server (do not modify unless you know what you do)');
+ $variable['username']=min(128, $variable['username']);
+ $variable['database']=min($variable['database'], $variable['username']);
+ variable_set('sql_max_username_length', $variable['username'], 'Maximum length allowed for SQL usernames by your SQL server (do not modify unless you know what you do)');
+ variable_set('sql_max_database_length', $variable['database'], 'Maximum length allowed for SQL database names by your SQL server (do not modify unless you know what you do)');
}
}
diff --git a/bureau/class/config_nochk.php b/bureau/class/config_nochk.php
index ec8208bf..5d2da96f 100644
--- a/bureau/class/config_nochk.php
+++ b/bureau/class/config_nochk.php
@@ -27,7 +27,7 @@
Original Author of file: Benjamin Sonntag
Purpose of file: General configuration file for AlternC Desktop
----------------------------------------------------------------------
- */
+*/
define('NOCHECK', 1);
require_once("config.php");
diff --git a/bureau/class/db_mysql.php b/bureau/class/db_mysql.php
index a54f8f2f..37ec6614 100644
--- a/bureau/class/db_mysql.php
+++ b/bureau/class/db_mysql.php
@@ -10,287 +10,287 @@
class DB_Sql {
- /* public: connection parameters */
- private $Host;
- private $Database;
- private $User;
- private $Password;
+ /* public: connection parameters */
+ private $Host;
+ private $Database;
+ private $User;
+ private $Password;
- /* public: configuration parameters */
- private $Auto_Free = False; // Set to True for automatic mysql_free_result()
- private $Debug = False; // Set to 1 for debugging messages.
- private $Halt_On_Error = "no"; // "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
- private $Seq_Table = "db_sequence";
+ /* public: configuration parameters */
+ private $Auto_Free = False; // Set to True for automatic mysql_free_result()
+ private $Debug = False; // Set to 1 for debugging messages.
+ private $Halt_On_Error = "no"; // "yes" (halt with message), "no" (ignore errors quietly), "report" (ignore errror, but spit a warning)
+ private $Seq_Table = "db_sequence";
- /* public: result array and current row number */
- public /* FIXME */ $Record = array();
- private $Row = 0;
- private $num_rows;
+ /* public: result array and current row number */
+ public /* FIXME */ $Record = array();
+ private $Row = 0;
+ private $num_rows;
- /* public: current error number and error text */
- private $Errno;
- private $Error;
+ /* public: current error number and error text */
+ private $Errno;
+ private $Error;
- /* private: link and query handles */
- private $Query_String;
+ /* private: link and query handles */
+ private $Query_String;
- /* PDO related variables */
- private $pdo_instance = NULL;
- private $pdo_query = NULL;
+ /* PDO related variables */
+ private $pdo_instance = NULL;
+ private $pdo_query = NULL;
- /**
- * Constructor
- */
- function __construct($db, $host, $user, $passwd) {
+ /**
+ * Constructor
+ */
+ function __construct($db, $host, $user, $passwd) {
$dsn = sprintf('mysql:dbname=%s;host=%s', $db, $host);
try {
- $this->pdo_instance = new PDO($dsn, $user, $passwd);
+ $this->pdo_instance = new PDO($dsn, $user, $passwd);
} catch (PDOException $e) {
- echo "Mysql", "PDO instance", $e->getMessage();
- return FALSE;
- }
- }
-
- /**
- * function for MySQL database connection management
- *
- * This function manages the connection to the MySQL database.
- *
- * @param $Database name of the database
- * @param $Host DNS of the MySQL hosting server
- * @param $User the user's name
- * @param $Password the user's password
- *
- * @return the class variable $Link_ID
- */
- function connect($Database = "", $Host = "", $User = "", $Password = "") {
- $this->halt('Mysql::connect() : This function should no longer be used');
- /* Handle defaults */
- if ("" == $Database)
- $Database = $this->Database;
- if ("" == $Host)
- $Host = $this->Host;
- if ("" == $User)
- $User = $this->User;
- if ("" == $Password)
- $Password = $this->Password;
-
- if (!$this->pdo_instance) {
- $dsn = sprintf('mysql:dbname=%s;host=%s', $Database, $Host);
-
- try {
- $this->pdo_instance = new PDO($dsn, $User, $Password);
- } catch (PDOException $e) {
- $this->halt("Mysql::PDO_instance" . $e->getMessage());
- return FALSE;
+ echo "Mysql", "PDO instance", $e->getMessage();
+ return FALSE;
}
}
+
+ /**
+ * function for MySQL database connection management
+ *
+ * This function manages the connection to the MySQL database.
+ *
+ * @param $Database name of the database
+ * @param $Host DNS of the MySQL hosting server
+ * @param $User the user's name
+ * @param $Password the user's password
+ *
+ * @return the class variable $Link_ID
+ */
+ function connect($Database = "", $Host = "", $User = "", $Password = "") {
+ $this->halt('Mysql::connect() : This function should no longer be used');
+ /* Handle defaults */
+ if ("" == $Database)
+ $Database = $this->Database;
+ if ("" == $Host)
+ $Host = $this->Host;
+ if ("" == $User)
+ $User = $this->User;
+ if ("" == $Password)
+ $Password = $this->Password;
+
+ if (!$this->pdo_instance) {
+ $dsn = sprintf('mysql:dbname=%s;host=%s', $Database, $Host);
+
+ try {
+ $this->pdo_instance = new PDO($dsn, $User, $Password);
+ } catch (PDOException $e) {
+ $this->halt("Mysql::PDO_instance" . $e->getMessage());
+ return FALSE;
+ }
+ }
- return True;
- }
+ return True;
+ }
- /**
- * Discard the query result
- *
- * This function discards the last query result.
- */
- function free() {
- $this->pdo_query->closeCursor();
- }
+ /**
+ * Discard the query result
+ *
+ * This function discards the last query result.
+ */
+ function free() {
+ $this->pdo_query->closeCursor();
+ }
- function is_connected() {
- return $this->pdo_instance != FALSE;
- }
+ function is_connected() {
+ return $this->pdo_instance != FALSE;
+ }
- function last_error() {
- return $this->Error;
- }
- /**
- * Perform a query
- *
- * This function performs the MySQL query described in the string parameter
- *
- * @param a string describing the MySQL query
- * @param arguments is an optionnal array for future use with PDO parametrized requests
- * @return the $Query_ID class variable (null if fails)
- */
- function query($Query_String, $arguments = false) {
- global $debug_alternc;
+ function last_error() {
+ return $this->Error;
+ }
+ /**
+ * Perform a query
+ *
+ * This function performs the MySQL query described in the string parameter
+ *
+ * @param a string describing the MySQL query
+ * @param arguments is an optionnal array for future use with PDO parametrized requests
+ * @return the $Query_ID class variable (null if fails)
+ */
+ function query($Query_String, $arguments = false) {
+ global $debug_alternc;
- if (empty($Query_String) || !$this->is_connected())
- return FALSE;
+ if (empty($Query_String) || !$this->is_connected())
+ return FALSE;
- $this->Query_String = $Query_String;
- if ($this->Debug)
- printf("Debug: query = %s
\n", $Query_String);
+ $this->Query_String = $Query_String;
+ if ($this->Debug)
+ printf("Debug: query = %s
\n", $Query_String);
- $debug_chrono_start = microtime(true);
+ $debug_chrono_start = microtime(true);
- if ($arguments===false) {
- $this->pdo_query = $this->pdo_instance->query($Query_String);
- $exec_state = is_object($this->pdo_query);
+ if ($arguments===false) {
+ $this->pdo_query = $this->pdo_instance->query($Query_String);
+ $exec_state = is_object($this->pdo_query);
- } else {
+ } else {
- $this->pdo_query = $this->pdo_instance->prepare($this->Query_String);
- $exec_state = ($arguments) ? $this->pdo_query->execute($arguments)
- : $this->pdo_query->execute();
- // WARNING: this ternary is when we pass array() as $arguments
- }
+ $this->pdo_query = $this->pdo_instance->prepare($this->Query_String);
+ $exec_state = ($arguments) ? $this->pdo_query->execute($arguments)
+ : $this->pdo_query->execute();
+ // WARNING: this ternary is when we pass array() as $arguments
+ }
- $debug_chrono_start = (microtime(true) - $debug_chrono_start)*1000;
- $this->Row = 0;
+ $debug_chrono_start = (microtime(true) - $debug_chrono_start)*1000;
+ $this->Row = 0;
- if ($exec_state == FALSE) {
- if (is_object($this->pdo_query)) {
+ if ($exec_state == FALSE) {
+ if (is_object($this->pdo_query)) {
+ $this->Errno = $this->pdo_query->errorCode();
+ $this->Error = $this->pdo_query->errorInfo();
+ } else {
+ $this->Errno = $this->pdo_instance->errorCode();
+ $this->Error = $this->pdo_instance->errorInfo();
+ }
+
+ if( defined("THROW_EXCEPTIONS") && THROW_EXCEPTIONS ){
+ throw new \Exception("Mysql query failed : $this->Error");
+ }
+ $this->halt("SQL Error: ".$Query_String);
+ return FALSE;
+ }
+
+ if (isset($debug_alternc)) {
+ $debug_alternc->add("SQL Query : (".substr($debug_chrono_start,0,5)." ms)\t $Query_String");
+ $debug_alternc->nb_sql_query++;
+ $debug_alternc->tps_sql_query += $debug_chrono_start;
+ }
+
+ return TRUE;
+ }
+
+ /**
+ * walk result set
+ *
+ * This function tests if a new record is available in the current
+ * query result.
+ *
+ * @return TRUE if a new record is available
+ */
+ function next_record() {
+ if (!$this->pdo_query) {
+ $this->halt("next_record called with no query pending.");
+ return FALSE;
+ }
+
+ $this->Record = $this->pdo_query->fetch(PDO::FETCH_BOTH);
+ $this->Row++;
$this->Errno = $this->pdo_query->errorCode();
$this->Error = $this->pdo_query->errorInfo();
- } else {
- $this->Errno = $this->pdo_instance->errorCode();
- $this->Error = $this->pdo_instance->errorInfo();
- }
- if( defined("THROW_EXCEPTIONS") && THROW_EXCEPTIONS ){
- throw new \Exception("Mysql query failed : $this->Error");
+ if ($this->Record == FALSE) {
+ if ($this->Auto_Free)
+ $this->free();
+ return FALSE;
}
- $this->halt("SQL Error: ".$Query_String);
- return FALSE;
- }
-
- if (isset($debug_alternc)) {
- $debug_alternc->add("SQL Query : (".substr($debug_chrono_start,0,5)." ms)\t $Query_String");
- $debug_alternc->nb_sql_query++;
- $debug_alternc->tps_sql_query += $debug_chrono_start;
- }
- return TRUE;
- }
-
- /**
- * walk result set
- *
- * This function tests if a new record is available in the current
- * query result.
- *
- * @return TRUE if a new record is available
- */
- function next_record() {
- if (!$this->pdo_query) {
- $this->halt("next_record called with no query pending.");
- return FALSE;
- }
-
- $this->Record = $this->pdo_query->fetch(PDO::FETCH_BOTH);
- $this->Row++;
- $this->Errno = $this->pdo_query->errorCode();
- $this->Error = $this->pdo_query->errorInfo();
-
- if ($this->Record == FALSE) {
- if ($this->Auto_Free)
- $this->free();
- return FALSE;
+ return TRUE;
}
- return TRUE;
- }
-
- /* public: table locking */
- function lock($table, $mode="write") {
- if (!$this->is_connected())
- return FALSE;
+ /* public: table locking */
+ function lock($table, $mode="write") {
+ if (!$this->is_connected())
+ return FALSE;
- $query="lock tables ";
- if (is_array($table)) {
- while (list($key,$value)=each($table)) {
- if ($key=="read" && $key!=0) {
- $query.="$value read, ";
- } else {
- $query.="$value $mode, ";
- }
+ $query="lock tables ";
+ if (is_array($table)) {
+ while (list($key,$value)=each($table)) {
+ if ($key=="read" && $key!=0) {
+ $query.="$value read, ";
+ } else {
+ $query.="$value $mode, ";
+ }
+ }
+ $query=substr($query,0,-2);
+ } else {
+ $query.="$table $mode";
}
- $query=substr($query,0,-2);
- } else {
- $query.="$table $mode";
- }
- if (!$this->query($query)) {
- $this->halt("lock($table, $mode) failed.");
- return FALSE;
- }
+ if (!$this->query($query)) {
+ $this->halt("lock($table, $mode) failed.");
+ return FALSE;
+ }
- return TRUE;
+ return TRUE;
- }
+ }
- function unlock() {
- if (!$this->is_connected())
- return FALSE;
+ function unlock() {
+ if (!$this->is_connected())
+ return FALSE;
- if (!$this->query('unlock tables')) {
- $this->halt("unlock() failed.");
- return FALSE;
- }
- }
+ if (!$this->query('unlock tables')) {
+ $this->halt("unlock() failed.");
+ return FALSE;
+ }
+ }
- /* public: evaluate the result (size, width) */
- function affected_rows() {
- return $this->pdo_query->rowCount();
- }
+ /* public: evaluate the result (size, width) */
+ function affected_rows() {
+ return $this->pdo_query->rowCount();
+ }
- function num_rows() {
- return $this->pdo_query->rowCount();
- }
+ function num_rows() {
+ return $this->pdo_query->rowCount();
+ }
- function num_fields() {
- return $this->pdo_query->columnCount();
- }
+ function num_fields() {
+ return $this->pdo_query->columnCount();
+ }
- /* public: shorthand notation */
- function nf() {
- return $this->num_rows();
- }
+ /* public: shorthand notation */
+ function nf() {
+ return $this->num_rows();
+ }
- function np() {
- print $this->num_rows();
- }
+ function np() {
+ print $this->num_rows();
+ }
- /**
- * @param string $Name
- * @return integer
- */
- function f($Name) {
- if (isset($this->Record[$Name]))
- return $this->Record[$Name];
- else
- return false;
- }
+ /**
+ * @param string $Name
+ * @return integer
+ */
+ function f($Name) {
+ if (isset($this->Record[$Name]))
+ return $this->Record[$Name];
+ else
+ return false;
+ }
- function current_record() {
- return $this->Record;
- }
+ function current_record() {
+ return $this->Record;
+ }
- function p($Name) {
- print $this->Record[$Name];
- }
+ function p($Name) {
+ print $this->Record[$Name];
+ }
- function lastid() {
- return $this->pdo_instance->lastInsertId();
- }
+ function lastid() {
+ return $this->pdo_instance->lastInsertId();
+ }
/**
* Escape a string to use it into a SQL PDO query
* @param string string to escape
* @return string escaped string
*/
- function quote($string) {
- return $this->pdo_instance->quote($string);
- }
+ function quote($string) {
+ return $this->pdo_instance->quote($string);
+ }
/**
@@ -298,85 +298,85 @@ class DB_Sql {
* @param query string query to execute
* @return integer the number of affected rows
*/
- function exec($query) {
- return $this->pdo_instance->exec($query);
- }
+ function exec($query) {
+ return $this->pdo_instance->exec($query);
+ }
- /* public: sequence numbers */
- function nextid($seq_name) {
- if (!$this->is_connected())
- return FALSE;
+ /* public: sequence numbers */
+ function nextid($seq_name) {
+ if (!$this->is_connected())
+ return FALSE;
- 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);
- $this->query($q);
- $this->next_record();
+ 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);
+ $this->query($q);
+ $this->next_record();
- $id = $this->f('nextid');
+ $id = $this->f('nextid');
- /* No current value, make one */
- if (!$id) {
- $currentid = 0;
- $q = sprintf("insert into %s values('%s', %s)",
- $this->Seq_Table,
- $seq_name,
- $currentid);
- $this->query($q);
- } else {
- $currentid = $id;
- }
+ /* No current value, make one */
+ if (!$id) {
+ $currentid = 0;
+ $q = sprintf("insert into %s values('%s', %s)",
+ $this->Seq_Table,
+ $seq_name,
+ $currentid);
+ $this->query($q);
+ } else {
+ $currentid = $id;
+ }
- $nextid = $currentid + 1;
- $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
- $this->Seq_Table,
- $nextid,
- $seq_name);
- $this->query($q);
- $this->unlock();
- } else {
- $this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
- return FALSE;
- }
+ $nextid = $currentid + 1;
+ $q = sprintf("update %s set nextid = '%s' where seq_name = '%s'",
+ $this->Seq_Table,
+ $nextid,
+ $seq_name);
+ $this->query($q);
+ $this->unlock();
+ } else {
+ $this->halt("cannot lock ".$this->Seq_Table." - has it been created?");
+ return FALSE;
+ }
- return $nextid;
- }
+ return $nextid;
+ }
- /* public: return table metadata */
- function metadata($table='',$full=false) {
- global $msg;
- $msg->raise("ERROR", 'Mysql', 'function is no longer implemented (metadata())');
- return FALSE;
- }
+ /* public: 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 */
- function halt($msg) {
- if ($this->Halt_On_Error == "no")
- return;
+ /* private: error handling */
+ function halt($msg) {
+ if ($this->Halt_On_Error == "no")
+ return;
- $this->haltmsg($msg);
+ $this->haltmsg($msg);
- if ($this->Halt_On_Error != "report")
- die("Session halted.");
- }
+ if ($this->Halt_On_Error != "report")
+ die("Session halted.");
+ }
- function haltmsg($msg) {
- printf("Database error: %s
\n", $msg);
- printf("MySQL Error: %s (%s)
\n",
- $this->Errno,
- implode("\n", $this->Error));
- }
+ function haltmsg($msg) {
+ printf("Database error: %s
\n", $msg);
+ printf("MySQL Error: %s (%s)
\n",
+ $this->Errno,
+ implode("\n", $this->Error));
+ }
- function table_names() {
- $this->query("SHOW TABLES");
- $return = array();
- while ($this->next_record())
- $return[] = array('table_name' => $this->p(0), 'tablespace_name' => $this->Database, 'database' => $this->Database);
+ function table_names() {
+ $this->query("SHOW TABLES");
+ $return = array();
+ while ($this->next_record())
+ $return[] = array('table_name' => $this->p(0), 'tablespace_name' => $this->Database, 'database' => $this->Database);
- return $return;
- }
+ return $return;
+ }
}
?>
diff --git a/bureau/class/functions.php b/bureau/class/functions.php
index 1f9679d9..bba64034 100755
--- a/bureau/class/functions.php
+++ b/bureau/class/functions.php
@@ -22,7 +22,7 @@
----------------------------------------------------------------------
Purpose of file: Miscellaneous functions globally used
----------------------------------------------------------------------
- */
+*/
/**
* Format a field value for input or textarea :
@@ -528,7 +528,7 @@ function _md5cr($pass, $salt = "") {
function split_mysql_database_name($dbname) {
$db_exploded_name = explode("_", $dbname);
return array($db_exploded_name[0],
- implode("_", array_slice($db_exploded_name, 1)));
+ implode("_", array_slice($db_exploded_name, 1)));
}
/* ----------------------------------------------------------------- */
@@ -614,16 +614,16 @@ function eoption($values, $cur, $onedim = false) {
}
/**
- /* Echo the HTMLSpecialChars version of a value.
- * Must be called when pre-filling fields values in forms such as :
- *
- * Use the charset of the current language for transcription
- *
- * @global string $charset
- * @param string $str
- * @param boolean $affiche
- * @return string
- */
+ /* Echo the HTMLSpecialChars version of a value.
+ * Must be called when pre-filling fields values in forms such as :
+ *
+ * Use the charset of the current language for transcription
+ *
+ * @global string $charset
+ * @param string $str
+ * @param boolean $affiche
+ * @return string
+ */
function ehe($str, $affiche = TRUE) {
global $charset;
$retour = htmlspecialchars($str, ENT_QUOTES|ENT_SUBSTITUTE, $charset);
@@ -634,16 +634,16 @@ function ehe($str, $affiche = TRUE) {
}
/**
- /* Echo the URLENCODED version of a value.
- * Must be called when pre-filling fields values in URLS such as :
- * document.location='logs_tail.php?file=
- * Use the charset of the current language for transcription
- *
- * @global string $charset
- * @param string $str
- * @param boolean $affiche
- * @return string
- */
+ /* Echo the URLENCODED version of a value.
+ * Must be called when pre-filling fields values in URLS such as :
+ * document.location='logs_tail.php?file=
+ * Use the charset of the current language for transcription
+ *
+ * @global string $charset
+ * @param string $str
+ * @param boolean $affiche
+ * @return string
+ */
function eue($str, $affiche = TRUE) {
global $charset;
$retour = urlencode($str);
@@ -677,26 +677,26 @@ function getFields($fields, $requestOnly = false) {
$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]);
- break;
- case "float":
- $vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? floatval($GLOBALS[$method][$name]) : $options[2]);
- break;
- case "string":
- $vars[$name] = (isset($GLOBALS[$method][$name]) ? trim($GLOBALS[$method][$name]) : $options[2]);
- break;
- case "array":
- $vars[$name] = (isset($GLOBALS[$method][$name]) && is_array($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
- break;
- case "boolean":
- $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
- break;
- case "file":
- $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
- break;
- default:
- die("Illegal method type used for field " . $name . " : " . $options[1]);
+ case "integer":
+ $vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? intval($GLOBALS[$method][$name]) : $options[2]);
+ break;
+ case "float":
+ $vars[$name] = (isset($GLOBALS[$method][$name]) && is_numeric($GLOBALS[$method][$name]) ? floatval($GLOBALS[$method][$name]) : $options[2]);
+ break;
+ case "string":
+ $vars[$name] = (isset($GLOBALS[$method][$name]) ? trim($GLOBALS[$method][$name]) : $options[2]);
+ break;
+ case "array":
+ $vars[$name] = (isset($GLOBALS[$method][$name]) && is_array($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
+ break;
+ case "boolean":
+ $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
+ break;
+ case "file":
+ $vars[$name] = (isset($GLOBALS[$method][$name]) ? $GLOBALS[$method][$name] : $options[2]);
+ break;
+ default:
+ die("Illegal method type used for field " . $name . " : " . $options[1]);
}
}
@@ -1000,41 +1000,41 @@ function fHSVtoRGB($iH, $iS, $iV) {
$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;
- case($dH >= 1.0 && $dH < 2.0):
- $dR = $dX;
- $dG = $dC;
- $dB = 0.0;
- break;
- case($dH >= 2.0 && $dH < 3.0):
- $dR = 0.0;
- $dG = $dC;
- $dB = $dX;
- break;
- case($dH >= 3.0 && $dH < 4.0):
- $dR = 0.0;
- $dG = $dX;
- $dB = $dC;
- break;
- case($dH >= 4.0 && $dH < 5.0):
- $dR = $dX;
- $dG = 0.0;
- $dB = $dC;
- break;
- case($dH >= 5.0 && $dH < 6.0):
- $dR = $dC;
- $dG = 0.0;
- $dB = $dX;
- break;
- default:
- $dR = 0.0;
- $dG = 0.0;
- $dB = 0.0;
- break;
+ case($dH >= 0.0 && $dH < 1.0):
+ $dR = $dC;
+ $dG = $dX;
+ $dB = 0.0;
+ break;
+ case($dH >= 1.0 && $dH < 2.0):
+ $dR = $dX;
+ $dG = $dC;
+ $dB = 0.0;
+ break;
+ case($dH >= 2.0 && $dH < 3.0):
+ $dR = 0.0;
+ $dG = $dC;
+ $dB = $dX;
+ break;
+ case($dH >= 3.0 && $dH < 4.0):
+ $dR = 0.0;
+ $dG = $dX;
+ $dB = $dC;
+ break;
+ case($dH >= 4.0 && $dH < 5.0):
+ $dR = $dX;
+ $dG = 0.0;
+ $dB = $dC;
+ break;
+ case($dH >= 5.0 && $dH < 6.0):
+ $dR = $dC;
+ $dG = 0.0;
+ $dB = $dX;
+ break;
+ default:
+ $dR = 0.0;
+ $dG = 0.0;
+ $dB = 0.0;
+ break;
}
$dM = $dV - $dC;
@@ -1130,8 +1130,8 @@ function csrf_get($return=false) {
$_SESSION["csrf"]=md5(mt_rand().mt_rand().mt_rand());
}
if ($token=="") {
- $token=md5(mt_rand().mt_rand().mt_rand());
- $db->query("INSERT INTO csrf SET cookie=?, token=?, created=NOW(), used=0;",array($_SESSION["csrf"],$token));
+ $token=md5(mt_rand().mt_rand().mt_rand());
+ $db->query("INSERT INTO csrf SET cookie=?, token=?, created=NOW(), used=0;",array($_SESSION["csrf"],$token));
}
if ($return)
return $token;
diff --git a/bureau/class/lang_env.php b/bureau/class/lang_env.php
index 4c171b20..a76aab2d 100644
--- a/bureau/class/lang_env.php
+++ b/bureau/class/lang_env.php
@@ -3,11 +3,11 @@
$lang_translation = array(# If you comment lang here, it won't be displayed.
"fr_FR" => "Français",
"en_US" => "English",
- "es_ES" => "Español",
-# "it_IT" => "Italiano",
-# "de_DE" => "Deutsch",
-# "pt_BR" => "Portuguese",
-# "nl_NL" => "Dutch",
+ "es_ES" => "Español",
+ # "it_IT" => "Italiano",
+ # "de_DE" => "Deutsch",
+ # "pt_BR" => "Portuguese",
+ # "nl_NL" => "Dutch",
);
global $arr_lang_translation;
diff --git a/bureau/class/local.php b/bureau/class/local.php
index b3e6dabd..0f355091 100755
--- a/bureau/class/local.php
+++ b/bureau/class/local.php
@@ -9,10 +9,10 @@ $L_VERSION_HELP = "3.0";
/* To ease the transition, we define a lookup table for old names */
$compat = array('DEFAULT_MX' => 'MX',
- 'MYSQL_USER' => 'MYSQL_LOGIN',
- 'MYSQL_PASS' => 'MYSQL_PWD',
- 'NS1_HOSTNAME' => 'NS1',
- 'NS2_HOSTNAME' => 'NS2');
+'MYSQL_USER' => 'MYSQL_LOGIN',
+'MYSQL_PASS' => 'MYSQL_PWD',
+'NS1_HOSTNAME' => 'NS1',
+'NS2_HOSTNAME' => 'NS2');
$config_file = fopen('/etc/alternc/local.sh', 'r');
@@ -31,18 +31,18 @@ $config_file = fopen('/etc/alternc/my.cnf', 'r');
while (false!== ($line = fgets($config_file))) {
if (preg_match('/^([A-Za-z0-9_]*) *= *"?(.*?)"?$/', trim($line), $regs)) {
switch ($regs[1]) {
- case "user":
- $GLOBALS['L_MYSQL_LOGIN'] = $regs[2];
- break;
- case "password":
- $GLOBALS['L_MYSQL_PWD'] = $regs[2];
- break;
- case "host":
- $GLOBALS['L_MYSQL_HOST'] = $regs[2];
- break;
- case "database":
- $GLOBALS['L_MYSQL_DATABASE'] = $regs[2];
- break;
+ case "user":
+ $GLOBALS['L_MYSQL_LOGIN'] = $regs[2];
+ break;
+ case "password":
+ $GLOBALS['L_MYSQL_PWD'] = $regs[2];
+ break;
+ case "host":
+ $GLOBALS['L_MYSQL_HOST'] = $regs[2];
+ break;
+ case "database":
+ $GLOBALS['L_MYSQL_DATABASE'] = $regs[2];
+ break;
}
}
}
diff --git a/bureau/class/m_action.php b/bureau/class/m_action.php
index 6052d9c7..caf88d5d 100644
--- a/bureau/class/m_action.php
+++ b/bureau/class/m_action.php
@@ -18,7 +18,7 @@
Original Author of file: Lerider Steven
Purpose of file: Manage generic actions.
----------------------------------------------------------------------
- */
+*/
/**
* This class manage actions to be performed on the file system on behalf of alternc Classes
@@ -197,19 +197,19 @@ class m_action {
global $db, $msg;
$msg->log("action", "set", $type);
$serialized = serialize($parameters);
- $type = strtoupper($type);
- if (in_array($type, array('CHMOD',
- 'CREATE_FILE',
- 'CREATE_DIR',
- 'MOVE',
- 'FIX_USER',
- 'FIX_FILE',
- 'FIX_DIR',
- 'DELETE'))) {
- $query = "INSERT INTO `actions` (type, parameters, creation, user) VALUES('$type', '$serialized', now(), '$user');";
- } else {
- return False;
- }
+ $type = strtoupper($type);
+ if (in_array($type, array('CHMOD',
+ 'CREATE_FILE',
+ 'CREATE_DIR',
+ 'MOVE',
+ 'FIX_USER',
+ 'FIX_FILE',
+ 'FIX_DIR',
+ 'DELETE'))) {
+ $query = "INSERT INTO `actions` (type, parameters, creation, user) VALUES('$type', '$serialized', now(), '$user');";
+ } else {
+ return False;
+ }
if (!$db->query($query)) {
$msg->raise("ERROR", "action", _("Error setting actions"));
diff --git a/bureau/class/m_admin.php b/bureau/class/m_admin.php
index a0326687..c44b0ace 100644
--- a/bureau/class/m_admin.php
+++ b/bureau/class/m_admin.php
@@ -22,7 +22,7 @@
----------------------------------------------------------------------
Purpose of file: Administrate members and rights.
----------------------------------------------------------------------
- */
+*/
/* ----------------------------------------------------------------- */
@@ -692,27 +692,27 @@ class m_admin {
if ($db->next_record()) {
// TODO: put that string into gettext !
$mail = <<
";
switch ($ext) {
- case "org":
- case "com":
- case "net":
- case "info":
- case "biz":
- case "name":
- case "cc":
- if (preg_match("#Name Server:#", $ligne)) {
- $found = true;
- $tmp = strtolower(str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", str_replace("Name Server:", "", $ligne)))));
- if ($tmp) {
- $serveurList[] = $tmp;
- }
- }
- break;
- case "co":
- if (preg_match("#Name Server:#", $ligne)) {
- $found = true;
- $tmp = strtolower(str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", str_replace("Name Server:", "", $ligne)))));
- if ($tmp)
- $serveurList[] = $tmp;
- }
- break;
- case "cx":
- $ligne = str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", $ligne)));
- if ($ligne == "" && $state == 1) {
- $state = 2;
- }
- if ($state == 1) {
- $serveurList[] = strtolower($ligne);
- }
- if ($ligne == "Nameservers:" && $state == 0) {
- $state = 1;
- $found = true;
- }
- break;
- case "eu":
- case "be":
- $ligne = preg_replace("/^ *([^ ]*) \(.*\)$/", "\\1", trim($ligne));
- $tmp="";
- if ($found) {
- $tmp = trim($ligne);
- }
+ case "org":
+ case "com":
+ case "net":
+ case "info":
+ case "biz":
+ case "name":
+ case "cc":
+ if (preg_match("#Name Server:#", $ligne)) {
+ $found = true;
+ $tmp = strtolower(str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", str_replace("Name Server:", "", $ligne)))));
if ($tmp) {
$serveurList[] = $tmp;
}
- if ($ligne == "Nameservers:") {
- $state = 1;
- $found = true;
+ }
+ break;
+ case "co":
+ if (preg_match("#Name Server:#", $ligne)) {
+ $found = true;
+ $tmp = strtolower(str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", str_replace("Name Server:", "", $ligne)))));
+ if ($tmp)
+ $serveurList[] = $tmp;
+ }
+ break;
+ case "cx":
+ $ligne = str_replace(chr(10), "", str_replace(chr(13), "", str_replace(" ", "", $ligne)));
+ if ($ligne == "" && $state == 1) {
+ $state = 2;
+ }
+ if ($state == 1) {
+ $serveurList[] = strtolower($ligne);
+ }
+ if ($ligne == "Nameservers:" && $state == 0) {
+ $state = 1;
+ $found = true;
+ }
+ break;
+ case "eu":
+ case "be":
+ $ligne = preg_replace("/^ *([^ ]*) \(.*\)$/", "\\1", trim($ligne));
+ $tmp="";
+ if ($found) {
+ $tmp = trim($ligne);
+ }
+ if ($tmp) {
+ $serveurList[] = $tmp;
+ }
+ if ($ligne == "Nameservers:") {
+ $state = 1;
+ $found = true;
+ }
+ break;
+ case "im":
+ if (preg_match('/Name Server:/', $ligne)) {
+ $found = true;
+ // weird regexp (trailing garbage after name server), but I could not make it work otherwise
+ $tmp = strtolower(preg_replace('/Name Server: ([^ ]+)\..$/', "\\1", $ligne));
+ $tmp = preg_replace('/[^-_a-z0-9\.]/', '', $tmp);
+ if ($tmp) {
+ $serveurList[] = $tmp;
}
- break;
- case "im":
- if (preg_match('/Name Server:/', $ligne)) {
- $found = true;
- // weird regexp (trailing garbage after name server), but I could not make it work otherwise
- $tmp = strtolower(preg_replace('/Name Server: ([^ ]+)\..$/', "\\1", $ligne));
- $tmp = preg_replace('/[^-_a-z0-9\.]/', '', $tmp);
- if ($tmp) {
- $serveurList[] = $tmp;
- }
+ }
+ break;
+ case "it":
+ if (preg_match("#nserver:#", $ligne)) {
+ $found = true;
+ $tmp = strtolower(preg_replace("/nserver:\s*[^ ]*\s*([^\s]*)$/", "\\1", $ligne));
+ if ($tmp) {
+ $serveurList[] = $tmp;
}
- break;
- case "it":
- if (preg_match("#nserver:#", $ligne)) {
- $found = true;
- $tmp = strtolower(preg_replace("/nserver:\s*[^ ]*\s*([^\s]*)$/", "\\1", $ligne));
- if ($tmp) {
- $serveurList[] = $tmp;
- }
- }
- break;
- case "fr":
- case "re":
- if (preg_match("#nserver:#", $ligne)) {
- $found = true;
- $tmp = strtolower(preg_replace("#nserver:\s*([^\s]*)\s*.*$#", "\\1", $ligne));
- if ($tmp) {
- $serveurList[] = $tmp;
- }
- }
- break;
- case "ca":
- case "ws";
- if (preg_match('#Name servers#', $ligne)) {
- // found the server
- $state = 1;
- } elseif ($state) {
- if (preg_match('#^[^%]#', $ligne) && $ligne = preg_replace('#[[:space:]]#', "", $ligne)) {
- // first non-whitespace line is considered to be the nameservers themselves
- $found = true;
- $serveurList[] = $ligne;
- }
- }
- break;
- case "coop":
- if (preg_match('#Host Name:\s*([^\s]+)#', $ligne, $matches)) {
- $found = true;
- $serveurList[] = $matches[1];
+ }
+ break;
+ case "fr":
+ case "re":
+ if (preg_match("#nserver:#", $ligne)) {
+ $found = true;
+ $tmp = strtolower(preg_replace("#nserver:\s*([^\s]*)\s*.*$#", "\\1", $ligne));
+ if ($tmp) {
+ $serveurList[] = $tmp;
}
+ }
+ break;
+ case "ca":
+ case "ws";
+ if (preg_match('#Name servers#', $ligne)) {
+ // found the server
+ $state = 1;
+ } elseif ($state) {
+ if (preg_match('#^[^%]#', $ligne) && $ligne = preg_replace('#[[:space:]]#', "", $ligne)) {
+ // first non-whitespace line is considered to be the nameservers themselves
+ $found = true;
+ $serveurList[] = $ligne;
+ }
+ }
+ break;
+ case "coop":
+ if (preg_match('#Host Name:\s*([^\s]+)#', $ligne, $matches)) {
+ $found = true;
+ $serveurList[] = $matches[1];
+ }
} // switch
} // while
fclose($fp);
@@ -1075,12 +1093,8 @@ class m_dom {
$msg->raise("ALERT", "dom", _("The domain cannot be found in the Whois database"));
return false;
}
- }
+ } // whois
-// whois
-
-
- /* ----------------------------------------------------------------- */
/**
* vérifie la presence d'un champs mx valide sur un serveur DNS
@@ -1127,7 +1141,6 @@ class m_dom {
return 0;
}
- /* ----------------------------------------------------------------- */
/**
* retourne TOUTES les infos d'un domaine
@@ -1201,12 +1214,8 @@ class m_dom {
}
$db->free();
return $r;
- }
+ } // get_domain_all
-// get_domain_all
-
-
- /* ----------------------------------------------------------------- */
/**
* Retourne TOUTES les infos d'un sous domaine du compte courant.
@@ -1246,9 +1255,8 @@ class m_dom {
$r["web_action"] = $db->Record["web_action"];
$db->free();
return $r;
- }
+ } // get_sub_domain_all
-// get_sub_domain_all
/**
* @param integer $type
@@ -1259,70 +1267,69 @@ class m_dom {
// check the type we can have in domaines_type.target
switch ($this->domains_type_target_values($type)) {
- case 'NONE':
- if (empty($value) or is_null($value)) {
- return true;
- }
- break;
- case 'URL':
- if ($value == strval($value)) {
- if (filter_var($value, FILTER_VALIDATE_URL)) {
- return true;
- } else {
- $msg->raise("ERROR", "dom", _("invalid url"));
- return false;
- }
- }
- break;
- case 'DIRECTORY':
- if (substr($value, 0, 1) != "/") {
- $value = "/" . $value;
- }
- if (!checkuserpath($value)) {
- $msg->raise("ERROR", "dom", _("The folder you entered is incorrect or does not exist"));
- return false;
- }
+ case 'NONE':
+ if (empty($value) or is_null($value)) {
return true;
- case 'IP':
- if (checkip($value)) {
+ }
+ break;
+ case 'URL':
+ if ($value == strval($value)) {
+ if (filter_var($value, FILTER_VALIDATE_URL)) {
return true;
} else {
- $msg->raise("ERROR", "dom", _("The ip address is invalid"));
+ $msg->raise("ERROR", "dom", _("invalid url"));
return false;
}
- break;
- case 'IPV6':
- if (checkipv6($value)) {
- return true;
- } else {
- $msg->raise("ERROR", "dom", _("The ip address is invalid"));
- return false;
- }
- break;
- case 'DOMAIN':
- if (checkcname($value)) {
- return true;
- } else {
- $msg->raise("ERROR", "dom", _("The name you entered is incorrect or not fully qualified (it must end with a DOT, like example.com.)"));
- return false;
- }
- break;
- case 'TXT':
- if ($value == strval($value)) {
- return true;
- } else {
- $msg->raise("ERROR", "dom", _("The TXT value you entered is incorrect"));
- return false;
- }
- break;
- default:
- $msg->raise("ERROR", "dom", _("Invalid domain type selected, please check"));
+ }
+ break;
+ case 'DIRECTORY':
+ if (substr($value, 0, 1) != "/") {
+ $value = "/" . $value;
+ }
+ if (!checkuserpath($value)) {
+ $msg->raise("ERROR", "dom", _("The folder you entered is incorrect or does not exist"));
return false;
+ }
+ return true;
+ case 'IP':
+ if (checkip($value)) {
+ return true;
+ } else {
+ $msg->raise("ERROR", "dom", _("The ip address is invalid"));
+ return false;
+ }
+ break;
+ case 'IPV6':
+ if (checkipv6($value)) {
+ return true;
+ } else {
+ $msg->raise("ERROR", "dom", _("The ip address is invalid"));
+ return false;
+ }
+ break;
+ case 'DOMAIN':
+ if (checkcname($value)) {
+ return true;
+ } else {
+ $msg->raise("ERROR", "dom", _("The name you entered is incorrect or not fully qualified (it must end with a DOT, like example.com.)"));
+ return false;
+ }
+ break;
+ case 'TXT':
+ if ($value == strval($value)) {
+ return true;
+ } else {
+ $msg->raise("ERROR", "dom", _("The TXT value you entered is incorrect"));
+ return false;
+ }
+ break;
+ default:
+ $msg->raise("ERROR", "dom", _("Invalid domain type selected, please check"));
+ return false;
}
return false;
}
- /* ----------------------------------------------------------------- */
/**
* Check the compatibility of the POSTed parameters with the chosen
@@ -1353,7 +1360,7 @@ class m_dom {
}
}
- // Forbidden to create a CNAME RR on the domain APEX (RFC 1912)
+ // Forbidden to create a CNAME RR on the domain APEX (RFC 1912)
if ($type == 'cname' && $sub == '')
return false;
@@ -1361,7 +1368,6 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
/**
* Modifier les information du sous-domaine demandé.
@@ -1399,7 +1405,7 @@ class m_dom {
if (!$this->check_type_value($type, $dest)) {
//plutot verifier si la chaine d'erreur est vide avant de raise sinon sa veut dire que l(erruer est deja remonté
- // error raised by check_type_value
+ // error raised by check_type_value
return false;
}
@@ -1455,7 +1461,6 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
/**
* Supprime le sous-domaine demandé
@@ -1481,6 +1486,7 @@ class m_dom {
return true;
}
+
/**
* @param integer $dom_id
*/
@@ -1496,7 +1502,6 @@ class m_dom {
return $j;
}
- /* ----------------------------------------------------------------- */
/**
* Modifie les information du domaine précisé.
@@ -1535,7 +1540,7 @@ class m_dom {
}
}
- # Can't have ttl == 0. There is also a check in function_dns
+ // Can't have ttl == 0. There is also a check in function_dns
if ($ttl == 0) {
$ttl = 86400;
}
@@ -1559,7 +1564,7 @@ class m_dom {
return true;
}
- //si gestion mx uniquement, vérification du dns externe
+ // si gestion mx uniquement, vérification du dns externe
if ($dns == "0" && $gesmx == "1" && !$force) {
$vmx = $this->checkmx($dom);
if ($vmx == 1) {
@@ -1586,11 +1591,9 @@ class m_dom {
return true;
}
- /* * ************************* */
- /* Slave dns ip managment */
- /* * ************************* */
- /* ----------------------------------------------------------------- */
+ /* Slave dns ip managment */
+
/** Return the list of ip addresses and classes that are allowed access to domain list
* through AXFR Transfers from the bind server.
@@ -1608,9 +1611,9 @@ class m_dom {
return $res;
}
- /* ----------------------------------------------------------------- */
- /** Add an ip address (or a ip class) to the list of allowed slave ip access list.
+ /**
+ * Add an ip address (or a ip class) to the list of allowed slave ip access list.
*/
function add_slave_ip($ip, $class = "32") {
global $db, $msg;
@@ -1634,9 +1637,9 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
- /** Remove an ip address (or a ip class) from the list of allowed slave ip access list.
+ /**
+ * Remove an ip address (or a ip class) from the list of allowed slave ip access list.
*/
function del_slave_ip($ip) {
global $db, $msg;
@@ -1651,9 +1654,9 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
- /** Check for a slave account
+ /**
+ * Check for a slave account
*/
function check_slave_account($login, $pass) {
global $db;
@@ -1664,9 +1667,8 @@ class m_dom {
return false;
}
- /* ----------------------------------------------------------------- */
-
- /** Out (echo) the complete hosted domain list :
+ /**
+ * Out (echo) the complete hosted domain list :
*/
function echo_domain_list($integrity = false) {
global $db;
@@ -1683,9 +1685,9 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
- /** Returns the complete hosted domain list :
+ /**
+ * Returns the complete hosted domain list :
*/
function get_domain_list($uid = -1) {
global $db;
@@ -1726,7 +1728,6 @@ class m_dom {
return $res;
}
- /* ----------------------------------------------------------------- */
/** Returns the name of a domain for the current user, from it's domain_id
* @param $dom_id integer the domain_id to search for
@@ -1750,7 +1751,6 @@ class m_dom {
}
}
- /* ----------------------------------------------------------------- */
/** Returns the id of a domain for the current user, from it's domain name
* @param $domain string the domain name to search for
@@ -1774,9 +1774,9 @@ class m_dom {
}
}
- /* ----------------------------------------------------------------- */
- /** Count all domains, for all users
+ /**
+ * Count all domains, for all users
*/
function count_domains_all() {
global $db;
@@ -1788,9 +1788,9 @@ class m_dom {
}
}
- /* ----------------------------------------------------------------- */
- /** Return the list of allowed slave accounts
+ /**
+ * Return the list of allowed slave accounts
*/
function enum_slave_account() {
global $db;
@@ -1805,9 +1805,9 @@ class m_dom {
return $res;
}
- /* ----------------------------------------------------------------- */
- /** Add a slave account that will be allowed to access the domain list
+ /**
+ * Add a slave account that will be allowed to access the domain list
*/
function add_slave_account($login, $pass) {
global $db, $msg;
@@ -1820,9 +1820,9 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
- /** Remove a slave account
+ /**
+ * Remove a slave account
*/
function del_slave_account($login) {
global $db, $msg;
@@ -1830,14 +1830,11 @@ class m_dom {
return true;
}
- /* * ********** */
/* Private */
- /* * ********** */
- /* ----------------------------------------------------------------- */
-
- /** Try to lock a domain
+ /**
+ * Try to lock a domain
* @access private
*/
function lock() {
@@ -1853,9 +1850,9 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
- /** Unlock the cron for domain management
+ /**
+ * Unlock the cron for domain management
* return true
* @access private
*/
@@ -1869,9 +1866,9 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
- /** Declare that a domain's emails are hosted in this server :
+ /**
+ * Declare that a domain's emails are hosted in this server :
* This adds 2 MX entries in this domain (if required)
*/
function hook_dom_add_mx_domain($dom_id) {
@@ -1885,7 +1882,6 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
/**
* Delete an account (all his domains)
@@ -1900,9 +1896,9 @@ class m_dom {
return true;
}
- /* ----------------------------------------------------------------- */
- /** Returns the used quota for the $name service for the current user.
+ /**
+ * Returns the used quota for the $name service for the current user.
* @param $name string name of the quota
* @return integer the number of service used or false if an error occured
* @access private
@@ -1918,11 +1914,11 @@ class m_dom {
return $q;
}
- /* --------------------------------------------------------------------- */
- /** Returns the global domain(s) configuration(s) of a particular user
+ /**
+ * Returns the global domain(s) configuration(s) of a particular user
* No parameters needed
- * */
+ */
function alternc_export_conf() {
global $msg;
$msg->log("dom", "export");
@@ -1967,6 +1963,7 @@ class m_dom {
return $str;
}
+
/**
* Return an array with all the needed parameters to generate conf
* of a vhost.
@@ -2023,6 +2020,7 @@ class m_dom {
return $r;
}
+
/**
* Return an array with all informations of the domains_type
* used to generate Apache conf.
@@ -2046,7 +2044,11 @@ class m_dom {
return $d;
}
-// Launch old fashionned hooks as there was in AlternC 1.0
+
+ /**
+ * Launch old fashionned hooks as there was in AlternC 1.0
+ * @TODO: do we still need that?
+ */
function generate_conf_oldhook($action, $lst_sub, $sub_obj = null) {
if (is_null($sub_obj)) {
$sub_obj = $this->generation_parameters(null, false);
@@ -2072,6 +2074,7 @@ class m_dom {
} // foreach $lst_by_type
}
+
/**
* Generate apache configuration.
* Die if a specific FQDN have 2 vhost conf.
@@ -2124,7 +2127,10 @@ class m_dom {
return $ret;
}
- // Return an array with the list of id of sub_domains waiting for an action
+
+ /**
+ * Return an array with the list of id of sub_domains waiting for an action
+ */
function generation_todo() {
global $db, $msg;
$msg->log("dom", "generation_todo");
@@ -2136,20 +2142,22 @@ class m_dom {
return $r;
}
+
function subdomain_modif_are_done($sub_domain_id, $action) {
global $db;
$sub_domain_id = intval($sub_domain_id);
switch (strtolower($action)) {
- case "delete":
- $sql = "DELETE FROM sub_domaines WHERE id =$sub_domain_id;";
- break;
- default:
- $sql = "UPDATE sub_domaines SET web_action='OK' WHERE id='$sub_domain_id'; ";
+ case "delete":
+ $sql = "DELETE FROM sub_domaines WHERE id =$sub_domain_id;";
+ break;
+ default:
+ $sql = "UPDATE sub_domaines SET web_action='OK' WHERE id='$sub_domain_id'; ";
}
$db->query($sql);
return true;
}
+
/**
* @param string $dns_action
*/
@@ -2159,13 +2167,13 @@ class m_dom {
return true;
}
+
function set_dns_result($domain, $dns_result) {
global $db;
$db->query("UPDATE domaines SET dns_result= ? WHERE domaine= ?; ", array($dns_result, $domain));
return true;
}
- /* ----------------------------------------------------------------- */
/** hook function called by AlternC-upnp to know which open
* tcp or udp ports this class requires or suggests
@@ -2179,8 +2187,11 @@ class m_dom {
);
}
- // List if there is problems in the domains.
- // Problems can appear when editing domains type properties
+
+ /**
+ * List if there is problems in the domains.
+ * Problems can appear when editing domains type properties
+ */
function get_problems($domain) {
$this->lock();
$da = $this->get_domain_all($domain);
@@ -2218,6 +2229,7 @@ class m_dom {
return $errors;
}
+
function default_domain_type() {
// This function is only used to allow translation of default domain types:
_("Locally hosted");
@@ -2236,6 +2248,4 @@ class m_dom {
_("AlternC panel access");
}
-}
-
-/* Class m_domains */
+} /* Class m_domains */
diff --git a/bureau/class/m_err.php b/bureau/class/m_err.php
index e68d6adb..2b741426 100644
--- a/bureau/class/m_err.php
+++ b/bureau/class/m_err.php
@@ -1,155 +1,154 @@
Cette classe gère les erreurs qui peuvent apparaitre lors d'appels
-* à l'API d'AlternC. Ces erreurs sont stockées sous la forme de 2 nombres
-* (Classe ID et Numéro d'erreur) ainsi qu'un texte facultatif associé.
-* Des textes d'erreurs localisés sont aussi disponibles.
Cette classe se charge aussi d'insérer les appels à l'API d'AlternC -* dans les logs du système dans /var/log/alternc/bureau.log -*
-* Copyleft {@link http://alternc.net/ AlternC Team} -* -* @copyright AlternC-Team 2002-11-01 http://alternc.net/ -*/ + * Classe de gestion des erreurs apparaissant lors d'appels API. + * + *Cette classe gère les erreurs qui peuvent apparaitre lors d'appels + * à l'API d'AlternC. Ces erreurs sont stockées sous la forme de 2 nombres + * (Classe ID et Numéro d'erreur) ainsi qu'un texte facultatif associé. + * Des textes d'erreurs localisés sont aussi disponibles.
+ *Cette classe se charge aussi d'insérer les appels à l'API d'AlternC + * dans les logs du système dans /var/log/alternc/bureau.log + *
+ * Copyleft {@link http://alternc.net/ AlternC Team} + * + * @copyright AlternC-Team 2002-11-01 http://alternc.net/ + */ class m_err { - /** Numero de classe d'erreur actuelle */ - var $clsid=0; + /** Numero de classe d'erreur actuelle */ + var $clsid=0; - /** Dernière erreur enregistrée par la classe */ - var $error=0; + /** Dernière erreur enregistrée par la classe */ + var $error=0; - /** Paramètre chaine eventuellement associé à la dernière erreur */ - var $param=""; + /** Paramètre chaine eventuellement associé à la dernière erreur */ + var $param=""; - /** Emplacement du fichier de logs d'AlternC */ - var $logfile="/var/log/alternc/bureau.log"; + /** Emplacement du fichier de logs d'AlternC */ + var $logfile="/var/log/alternc/bureau.log"; - /** - * Leve une erreur, signale celle-ci dans les logs et stocke le code erreur - * - * Cette fonction lance une erreur, l'ajoute dans les logs d'AlternC, - * et la met à disposition pour le bureau virtuel pour affichage ultérieur. - * - * @todo ne plus utiliser $error de façon numérique, nulle part - * - * @param integer $clsid Classe qui lève l'erreur - * @param mixed $error Numéro de l'erreur ou chaîne décrivant l'erreur - * @param string $param Paramètre chaine associé à l'erreur (facultatif) - * @return boolean TRUE si l'erreur est connue, FALSE sinon. - * - */ - function raise($clsid,$error,$param="") { + /** + * Leve une erreur, signale celle-ci dans les logs et stocke le code erreur + * + * Cette fonction lance une erreur, l'ajoute dans les logs d'AlternC, + * et la met à disposition pour le bureau virtuel pour affichage ultérieur. + * + * @todo ne plus utiliser $error de façon numérique, nulle part + * + * @param integer $clsid Classe qui lève l'erreur + * @param mixed $error Numéro de l'erreur ou chaîne décrivant l'erreur + * @param string $param Paramètre chaine associé à l'erreur (facultatif) + * @return boolean TRUE si l'erreur est connue, FALSE sinon. + * + */ + function raise($clsid,$error,$param="") { - // This is the old method, deprecation warning - $this->deprecated(); - /* Leve une exception. Si elle existe, sinon, stocke un message d'erreur sur erreur ...*/ - if (_("err_".$clsid."_".$error)!="err_".$clsid."_".$error || is_string($error)) { - $this->clsid=$clsid; - $this->error=$error; - $args = func_get_args(); - $this->param=array_slice($args, 2); - $this->logerr(); - return true; - } else { - $this->clsid="err"; - $this->error=1; - $this->param="Error # $error in Class $clsid, Value is $param. (sorry, no text for this error in your language at the moment)"; - $this->logerr(); - return false; + // This is the old method, deprecation warning + $this->deprecated(); + /* Leve une exception. Si elle existe, sinon, stocke un message d'erreur sur erreur ...*/ + if (_("err_".$clsid."_".$error)!="err_".$clsid."_".$error || is_string($error)) { + $this->clsid=$clsid; + $this->error=$error; + $args = func_get_args(); + $this->param=array_slice($args, 2); + $this->logerr(); + return true; + } else { + $this->clsid="err"; + $this->error=1; + $this->param="Error # $error in Class $clsid, Value is $param. (sorry, no text for this error in your language at the moment)"; + $this->logerr(); + return false; + } } - } - /** - * Retourne la chaine d'erreur correspondant à la dernière erreur rencontrée - * - * Si la dernière erreur rencontrée est connue, retourne l'erreur en toute lettre - * dans la langue actuellement sélectionnée, ou en anglais par défaut. - * Si l'erreur n'est pas connue, retourne son numéro de classe et d'ereur. - * - * @return string Chaine d'erreur. - * - */ - function errstr() { - if (is_string($this->error)) { - // new way of handling errors: message directly in the class - $str = $this->error."\n"; - } else { - // old way: message in the locales files (ugly) - $str = _("err_".$this->clsid."_".$this->error)."\n"; + /** + * Retourne la chaine d'erreur correspondant à la dernière erreur rencontrée + * + * Si la dernière erreur rencontrée est connue, retourne l'erreur en toute lettre + * dans la langue actuellement sélectionnée, ou en anglais par défaut. + * Si l'erreur n'est pas connue, retourne son numéro de classe et d'ereur. + * + * @return string Chaine d'erreur. + * + */ + function errstr() { + if (is_string($this->error)) { + // new way of handling errors: message directly in the class + $str = $this->error."\n"; + } else { + // old way: message in the locales files (ugly) + $str = _("err_".$this->clsid."_".$this->error)."\n"; + } + $args = $this->param; + if (is_array($args)) { + array_unshift($args, $str); + $msg = call_user_func_array("sprintf", $args); + return $msg; + } else { + return $args; + } } - $args = $this->param; - if (is_array($args)) { - array_unshift($args, $str); - $msg = call_user_func_array("sprintf", $args); - return $msg; - } else { - return $args; + + /** + * Envoi un log d'erreur dans /var/log/alternc/bureau.log + * + * Cette fonction Loggue la dernière erreur dans /var/log sur la machine, + * permettant ainsi aux admins de savoir ce qu'il se passe... + * Elle est appelée automatiquement par error + * @access private + */ + function logerr() { + global $mem; + @file_put_contents($this->logfile, date("d/m/Y H:i:s")." - ERROR - ".$mem->user["login"]." - ".$this->errstr(), FILE_APPEND ); } - } - /** - * Envoi un log d'erreur dans /var/log/alternc/bureau.log - * - * Cette fonction Loggue la dernière erreur dans /var/log sur la machine, - * permettant ainsi aux admins de savoir ce qu'il se passe... - * Elle est appelée automatiquement par error - * @access private - */ - function logerr() { - global $mem; - @file_put_contents($this->logfile, date("d/m/Y H:i:s")." - ERROR - ".$mem->user["login"]." - ".$this->errstr(), FILE_APPEND ); - } + /** + * Envoi un log d'appel d'API dans /var/log/alternc/bureau.log + * + * Cette fonction loggue dans /var/log l'appel à la fonction de l'API + * d'AlternC. + * + * @param integer $clsid Numéro de la classe dont on a appelé une fonction + * @param string $function Nom de la fonction appelée + * @param string $param Paramètre (facultatif) passés à la fonction de l'API. + * @return boolean TRUE si le log a été ajouté, FALSE sinon + * + */ + function log($clsid,$function,$param="") { + global $mem,$cuid; + // This is the old method, deprecation warning + $this->deprecated(); + return @file_put_contents($this->logfile,date("d/m/Y H:i:s")." - " .get_remote_ip(). " - CALL - ".$mem->user["login"]." - $clsid - $function - $param\n", FILE_APPEND ); + } + /** + * This method is present in order to allow slow deprecation + */ + function deprecated(){ + global $msg; + $trace = debug_backtrace(); + $caller = $trace[2]; + $msg->raise( "error","err","Deprecation warning: The old messaging class is still used by ".json_encode( $caller )); + } + +} /* Classe m_err */ - /** - * Envoi un log d'appel d'API dans /var/log/alternc/bureau.log - * - * Cette fonction loggue dans /var/log l'appel à la fonction de l'API - * d'AlternC. - * - * @param integer $clsid Numéro de la classe dont on a appelé une fonction - * @param string $function Nom de la fonction appelée - * @param string $param Paramètre (facultatif) passés à la fonction de l'API. - * @return boolean TRUE si le log a été ajouté, FALSE sinon - * - */ - function log($clsid,$function,$param="") { - global $mem,$cuid; - // This is the old method, deprecation warning - $this->deprecated(); - return @file_put_contents($this->logfile,date("d/m/Y H:i:s")." - " .get_remote_ip(). " - CALL - ".$mem->user["login"]." - $clsid - $function - $param\n", FILE_APPEND ); - } - /** - * This method is present in order to allow slow deprecation - */ - function deprecated(){ - global $msg; - $trace = debug_backtrace(); - $caller = $trace[2]; - $msg->raise( "error","err","Deprecation warning: The old messaging class is still used by ".json_encode( $caller )); - } -}; /* Classe m_err */ -?> diff --git a/bureau/class/m_export.php b/bureau/class/m_export.php index dfb0c2a4..a4a93839 100644 --- a/bureau/class/m_export.php +++ b/bureau/class/m_export.php @@ -3,10 +3,10 @@ /* --------------------------------------------------------------------------- */ /** Constructor - Classe d'export de compte Alternc. - Cette classe ce contente d'invoquer les fonctions d'exportation de configuration et de données d'un compte, - presentes dans les classes concernées. - */ + Classe d'export de compte Alternc. + Cette classe ce contente d'invoquer les fonctions d'exportation de configuration et de données d'un compte, + presentes dans les classes concernées. +*/ Class m_export { function m_export() { @@ -20,8 +20,8 @@ Class m_export { } /** le repertoire de base est passé en paramettre puis en construit une arborescence de la forme -" . $hlp . "
"; return true; } @@ -615,6 +601,7 @@ Cordially. } } + /** * @param integer $uid */ @@ -628,7 +615,6 @@ Cordially. return intval($db->f('creator')); } - /* ----------------------------------------------------------------- */ /** * Exports all the personal user related information for an account. @@ -689,6 +675,4 @@ Cordially. return true; } -} - -/* Classe Membre */ +} /* Class m_mem */ diff --git a/bureau/class/m_menu.php b/bureau/class/m_menu.php index 597a1027..bce4ebf9 100644 --- a/bureau/class/m_menu.php +++ b/bureau/class/m_menu.php @@ -1,10 +1,6 @@ $b['pos']; } + /** + * some menus that don't have an attached class + */ function system_menu() { - // Here some needed menu who don't have a class global $help_baseurl, $lang_translation, $locales; $m = array( @@ -150,6 +144,4 @@ class m_menu { return $m; } -} - -/* Class menu */ +} /* Class m_menu */ diff --git a/bureau/class/m_messages.php b/bureau/class/m_messages.php index 10f43eb4..065fad06 100644 --- a/bureau/class/m_messages.php +++ b/bureau/class/m_messages.php @@ -52,6 +52,7 @@ class m_messages { $this->init_msgs(); } + /** * Record a message, insert it into the logfile. * @@ -83,6 +84,7 @@ class m_messages { return true; } + /** * Reset the stored messages array */ @@ -92,6 +94,7 @@ class m_messages { } } + /** * Tell if there are stored messages for a specific level * or for all levels (if level is empty) @@ -113,6 +116,7 @@ class m_messages { } } + /** * Return a string of concateneted messages of all recorded messages * or only the last message @@ -162,6 +166,7 @@ class m_messages { return $str; } + /** * Return a message in HTML form with associated CSS * @@ -186,6 +191,7 @@ class m_messages { return $str; } + /** * Return all the messages of all levels in HTML form with associated CSS * @@ -207,6 +213,7 @@ class m_messages { return $msg; } + /** * Log a message into /var/log/alternc/bureau.log * @@ -235,6 +242,7 @@ class m_messages { ); } + /** * Log an API function call into /var/log/alternc/bureau.log * @@ -255,6 +263,4 @@ class m_messages { ); } -} - -/* Class m_messages */ +} /* Class m_messages */ diff --git a/bureau/class/m_mysql.php b/bureau/class/m_mysql.php index 8ab46fce..697ce557 100644 --- a/bureau/class/m_mysql.php +++ b/bureau/class/m_mysql.php @@ -1,14 +1,6 @@ query("select db_servers.* from db_servers, membres where membres.uid= ? and membres.db_server_id=db_servers.id;", array($cuid)); - if (!$db->next_record()) { - $msg->raise("ERROR", 'db_user', _("There are no databases in db_servers for this user. Please contact your administrator.")); - die(); - } + $db->query("select db_servers.* from db_servers, membres where membres.uid= ? and membres.db_server_id=db_servers.id;", array($cuid)); + if (!$db->next_record()) { + $msg->raise("ERROR", 'db_user', _("There are no databases in db_servers for this user. Please contact your administrator.")); + die(); + } - # Create the object - $this->HumanHostname = $db->f('name'); - $this->Host = $db->f('host'); - $this->User = $db->f('login'); - $this->Password = $db->f('password'); - $this->Client = $db->f('client'); - $this->Database = "mysql"; + // Create the object + $this->HumanHostname = $db->f('name'); + $this->Host = $db->f('host'); + $this->User = $db->f('login'); + $this->Password = $db->f('password'); + $this->Client = $db->f('client'); + $this->Database = "mysql"; - parent::__construct("mysql", $db->f('host'), $db->f('login'), $db->f('password') ); + parent::__construct("mysql", $db->f('host'), $db->f('login'), $db->f('password') ); } @@ -69,12 +59,12 @@ class m_mysql { var $dbus; - /* --------------------------------------------------------------------------- */ - /** Constructor + /** + * Constructor * m_mysql([$mid]) Constructeur de la classe m_mysql, initialise le membre concerne */ - function m_mysql() { + function __construct() { global $cuid; if (!empty($cuid)) { $this->dbus = new DB_users(); @@ -82,10 +72,12 @@ class m_mysql { variable_get('sql_allow_users_backups', 1, 'Set 1 to allow users to configure backup of their databases, 0 if you want do disable this feature. Warning: it will not stop configured backup made by sqlbackup.sh'); } + function reload_dbus() { $this->dbus = new DB_users(); } + function list_db_servers() { global $db; $db->query("select d.*, IFNULL(count(m.uid),0) as nb_users from db_servers d left join membres m on d.id = m.db_server_id group by d.id,m.db_server_id order by d.name,d.id;"); @@ -96,6 +88,7 @@ class m_mysql { return $c; } + function hook_menu() { global $quota; $q = $quota->getquota("mysql"); @@ -126,7 +119,6 @@ class m_mysql { return $obj; } - /* ----------------------------------------------------------------- */ /** * Password kind used in this class (hook for admin class) @@ -135,9 +127,9 @@ class m_mysql { return array("mysql" => "MySQL users"); } - /* --------------------------------------------------------------------------- */ - /** Get the list of the database for the current user. + /** + * Get the list of the database for the current user. * @return array returns an associative array as follow :