[cosm] reindent, check language of comments, ensure /** phpdoc style comments, simplify file header (license only) etc.
This commit is contained in:
parent
8dac9a499d
commit
3de55aca37
|
@ -27,7 +27,7 @@
|
||||||
Original Author of file: Benjamin Sonntag
|
Original Author of file: Benjamin Sonntag
|
||||||
Purpose of file: General configuration file for AlternC Desktop
|
Purpose of file: General configuration file for AlternC Desktop
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('DO_XHPROF_STATS', FALSE);
|
define('DO_XHPROF_STATS', FALSE);
|
||||||
if (DO_XHPROF_STATS) {
|
if (DO_XHPROF_STATS) {
|
||||||
|
@ -45,7 +45,7 @@ session_start();
|
||||||
/*
|
/*
|
||||||
Si vous voulez mettre le bureau en maintenance, decommentez le code ci-dessous
|
Si vous voulez mettre le bureau en maintenance, decommentez le code ci-dessous
|
||||||
et mettez votre ip dans le IF pour que seule votre ip puisse acceder au bureau :
|
et mettez votre ip dans le IF pour que seule votre ip puisse acceder au bureau :
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* * /
|
/* * /
|
||||||
if (getenv("REMOTE_ADDR")!="127.0.0.1") {
|
if (getenv("REMOTE_ADDR")!="127.0.0.1") {
|
||||||
|
@ -148,7 +148,7 @@ foreach (glob($root . "class/m_*.php") as $di) {
|
||||||
}
|
}
|
||||||
/* THE DEFAULT CLASSES ARE :
|
/* THE DEFAULT CLASSES ARE :
|
||||||
dom, ftp, mail, quota, bro, admin, mem, mysql, err, variables
|
dom, ftp, mail, quota, bro, admin, mem, mysql, err, variables
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// Load file for the system class.
|
// Load file for the system class.
|
||||||
// Those class will not be build by default.
|
// Those class will not be build by default.
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
Original Author of file: Benjamin Sonntag
|
Original Author of file: Benjamin Sonntag
|
||||||
Purpose of file: General configuration file for AlternC Desktop
|
Purpose of file: General configuration file for AlternC Desktop
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
define('NOCHECK', 1);
|
define('NOCHECK', 1);
|
||||||
require_once("config.php");
|
require_once("config.php");
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Miscellaneous functions globally used
|
Purpose of file: Miscellaneous functions globally used
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Format a field value for input or textarea :
|
* Format a field value for input or textarea :
|
||||||
|
|
|
@ -4,10 +4,10 @@ $lang_translation = array(# If you comment lang here, it won't be displayed.
|
||||||
"fr_FR" => "Français",
|
"fr_FR" => "Français",
|
||||||
"en_US" => "English",
|
"en_US" => "English",
|
||||||
"es_ES" => "Español",
|
"es_ES" => "Español",
|
||||||
# "it_IT" => "Italiano",
|
# "it_IT" => "Italiano",
|
||||||
# "de_DE" => "Deutsch",
|
# "de_DE" => "Deutsch",
|
||||||
# "pt_BR" => "Portuguese",
|
# "pt_BR" => "Portuguese",
|
||||||
# "nl_NL" => "Dutch",
|
# "nl_NL" => "Dutch",
|
||||||
);
|
);
|
||||||
|
|
||||||
global $arr_lang_translation;
|
global $arr_lang_translation;
|
||||||
|
|
|
@ -9,10 +9,10 @@ $L_VERSION_HELP = "3.0";
|
||||||
|
|
||||||
/* To ease the transition, we define a lookup table for old names */
|
/* To ease the transition, we define a lookup table for old names */
|
||||||
$compat = array('DEFAULT_MX' => 'MX',
|
$compat = array('DEFAULT_MX' => 'MX',
|
||||||
'MYSQL_USER' => 'MYSQL_LOGIN',
|
'MYSQL_USER' => 'MYSQL_LOGIN',
|
||||||
'MYSQL_PASS' => 'MYSQL_PWD',
|
'MYSQL_PASS' => 'MYSQL_PWD',
|
||||||
'NS1_HOSTNAME' => 'NS1',
|
'NS1_HOSTNAME' => 'NS1',
|
||||||
'NS2_HOSTNAME' => 'NS2');
|
'NS2_HOSTNAME' => 'NS2');
|
||||||
|
|
||||||
|
|
||||||
$config_file = fopen('/etc/alternc/local.sh', 'r');
|
$config_file = fopen('/etc/alternc/local.sh', 'r');
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
Original Author of file: Lerider Steven
|
Original Author of file: Lerider Steven
|
||||||
Purpose of file: Manage generic actions.
|
Purpose of file: Manage generic actions.
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manage actions to be performed on the file system on behalf of alternc Classes
|
* This class manage actions to be performed on the file system on behalf of alternc Classes
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Administrate members and rights.
|
Purpose of file: Administrate members and rights.
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/* ----------------------------------------------------------------- */
|
||||||
|
|
||||||
|
@ -692,18 +692,18 @@ class m_admin {
|
||||||
if ($db->next_record()) {
|
if ($db->next_record()) {
|
||||||
// TODO: put that string into gettext !
|
// TODO: put that string into gettext !
|
||||||
$mail = <<<EOF
|
$mail = <<<EOF
|
||||||
A new AlternC account was created on %fqdn by %creator.
|
A new AlternC account was created on %fqdn by %creator.
|
||||||
|
|
||||||
Account details
|
Account details
|
||||||
---------------
|
---------------
|
||||||
|
|
||||||
login: %login (%uid)
|
login: %login (%uid)
|
||||||
email: %mail
|
email: %mail
|
||||||
createor: %creator (%cuid)
|
createor: %creator (%cuid)
|
||||||
can change password: %canpass
|
can change password: %canpass
|
||||||
type: %type
|
type: %type
|
||||||
notes: %notes
|
notes: %notes
|
||||||
EOF;
|
EOF;
|
||||||
$mail = strtr($mail, array('%fqdn' => $L_FQDN,
|
$mail = strtr($mail, array('%fqdn' => $L_FQDN,
|
||||||
'%creator' => $db->Record['parentlogin'],
|
'%creator' => $db->Record['parentlogin'],
|
||||||
'%uid' => $db->Record['uid'],
|
'%uid' => $db->Record['uid'],
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Original Author of file: Fufroma
|
Original Author of file: Fufroma
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe de gestion des IP authorisée
|
* Classe de gestion des IP authorisée
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: file browser class.
|
Purpose of file: file browser class.
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Add the mime type list */
|
/* Add the mime type list */
|
||||||
@include("mime.php");
|
@include("mime.php");
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage hook system.
|
Purpose of file: Manage hook system.
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manage web-cron tasks
|
* This class manage web-cron tasks
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
This program is free software; you can redistribute it and/or
|
This program is free software; you can redistribute it and/or
|
||||||
|
@ -15,10 +16,7 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Original Author of file: Camille Lafitte
|
*/
|
||||||
Purpose of file: Manage hook system.
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manage debug.
|
* This class manage debug.
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,9 +16,7 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: PHP Class that manage domain names installed on the server
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
define('SLAVE_FLAG', "/var/run/alternc/refresh_slave");
|
define('SLAVE_FLAG', "/var/run/alternc/refresh_slave");
|
||||||
|
|
||||||
|
@ -34,17 +28,20 @@ define('SLAVE_FLAG', "/var/run/alternc/refresh_slave");
|
||||||
*/
|
*/
|
||||||
class m_dom {
|
class m_dom {
|
||||||
|
|
||||||
/** $domains : Cache des domaines du membre
|
/**
|
||||||
|
* $domains : Cache des domaines du membre
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $domains;
|
var $domains;
|
||||||
|
|
||||||
/** $dns : Liste des dns trouvés par la fonction whois
|
/**
|
||||||
|
* $dns : Liste des dns trouvés par la fonction whois
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $dns;
|
var $dns;
|
||||||
|
|
||||||
/** Flag : a-t-on trouvé un sous-domaine Webmail pour ce domaine ?
|
/**
|
||||||
|
* Flag : a-t-on trouvé un sous-domaine Webmail pour ce domaine ?
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $webmail;
|
var $webmail;
|
||||||
|
@ -79,7 +76,6 @@ class m_dom {
|
||||||
var $tld_no_check_at_all = "1";
|
var $tld_no_check_at_all = "1";
|
||||||
var $cache_domains_type_lst = false;
|
var $cache_domains_type_lst = false;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
|
@ -90,6 +86,7 @@ class m_dom {
|
||||||
variable_get('mailname_bounce', $L_FQDN, 'FQDN of the mail server, used to create vhost virtual mail_adress.', array('desc' => 'FQDN', 'type' => 'string'));
|
variable_get('mailname_bounce', $L_FQDN, 'FQDN of the mail server, used to create vhost virtual mail_adress.', array('desc' => 'FQDN', 'type' => 'string'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_panel_url_list() {
|
function get_panel_url_list() {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
$msg->log("dom", "get_panel_url_list");
|
$msg->log("dom", "get_panel_url_list");
|
||||||
|
@ -101,6 +98,7 @@ class m_dom {
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $fqdn
|
* @param string $fqdn
|
||||||
*/
|
*/
|
||||||
|
@ -114,6 +112,11 @@ class m_dom {
|
||||||
return array('sub_id' => intval($db->f('id')), 'member_id' => intval($db->f('compte')));
|
return array('sub_id' => intval($db->f('id')), 'member_id' => intval($db->f('compte')));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hook function called by the menu class
|
||||||
|
* to add menu to the left panel
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $quota;
|
global $quota;
|
||||||
$obj = array(
|
$obj = array(
|
||||||
|
@ -142,7 +145,6 @@ class m_dom {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne un tableau contenant les types de domaines
|
* Retourne un tableau contenant les types de domaines
|
||||||
|
@ -163,6 +165,7 @@ class m_dom {
|
||||||
return $this->cache_domains_type_lst;
|
return $this->cache_domains_type_lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function domains_type_enable_values() {
|
function domains_type_enable_values() {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$msg->log("dom", "domains_type_target_values");
|
$msg->log("dom", "domains_type_target_values");
|
||||||
|
@ -179,6 +182,7 @@ class m_dom {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $type
|
* @param integer $type
|
||||||
*/
|
*/
|
||||||
|
@ -206,6 +210,7 @@ class m_dom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function import_manual_dns_zone($zone, $domain, $detect_redirect = true, $save = false) {
|
function import_manual_dns_zone($zone, $domain, $detect_redirect = true, $save = false) {
|
||||||
global $msg;
|
global $msg;
|
||||||
if ($save) {
|
if ($save) {
|
||||||
|
@ -226,6 +231,7 @@ class m_dom {
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $zone
|
* @param string $zone
|
||||||
*/
|
*/
|
||||||
|
@ -408,6 +414,7 @@ class m_dom {
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function import_manual_dns_entry_doit($entry) {
|
private function import_manual_dns_entry_doit($entry) {
|
||||||
$entry['did_it'] = 0;
|
$entry['did_it'] = 0;
|
||||||
if ($entry['status'] == 'err') {
|
if ($entry['status'] == 'err') {
|
||||||
|
@ -445,6 +452,7 @@ class m_dom {
|
||||||
return $entry;
|
return $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function import_manual_dns_prep_zone($domain) {
|
private function import_manual_dns_prep_zone($domain) {
|
||||||
global $msg;
|
global $msg;
|
||||||
// Prepare a domain to be importer :
|
// Prepare a domain to be importer :
|
||||||
|
@ -472,6 +480,7 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Take an URL, and return FALSE is there is no redirection,
|
// Take an URL, and return FALSE is there is no redirection,
|
||||||
// and the target URL if there is one (HTTP CODE 301 & 302)
|
// and the target URL if there is one (HTTP CODE 301 & 302)
|
||||||
// CURL is needed
|
// CURL is needed
|
||||||
|
@ -518,6 +527,7 @@ class m_dom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function domains_type_regenerate($name) {
|
function domains_type_regenerate($name) {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$db->query("update sub_domaines set web_action='UPDATE' where lower(type) = lower(?) ;", array($name));
|
$db->query("update sub_domaines set web_action='UPDATE' where lower(type) = lower(?) ;", array($name));
|
||||||
|
@ -525,6 +535,7 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function domains_type_get($name) {
|
function domains_type_get($name) {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query("select * from domaines_type where name= ?;", array($name));
|
$db->query("select * from domaines_type where name= ?;", array($name));
|
||||||
|
@ -532,12 +543,14 @@ class m_dom {
|
||||||
return $db->Record;
|
return $db->Record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function domains_type_del($name) {
|
function domains_type_del($name) {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query("delete domaines_type where name= ? ;", array($name));
|
$db->query("delete domaines_type where name= ? ;", array($name));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns, $advanced, $create_tmpdir, $create_targetdir) {
|
function domains_type_update($name, $description, $target, $entry, $compatibility, $enable, $only_dns, $need_dns, $advanced, $create_tmpdir, $create_targetdir) {
|
||||||
global $msg, $db;
|
global $msg, $db;
|
||||||
// The name MUST contain only letter and digits, it's an identifier after all ...
|
// The name MUST contain only letter and digits, it's an identifier after all ...
|
||||||
|
@ -554,6 +567,7 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function sub_domain_change_status($sub_id, $status) {
|
function sub_domain_change_status($sub_id, $status) {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
$msg->log("dom", "sub_domain_change_status");
|
$msg->log("dom", "sub_domain_change_status");
|
||||||
|
@ -577,7 +591,6 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne un tableau contenant les domaines d'un membre.
|
* Retourne un tableau contenant les domaines d'un membre.
|
||||||
|
@ -613,7 +626,6 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Efface un domaine du membre courant, et tous ses sous-domaines
|
* Efface un domaine du membre courant, et tous ses sous-domaines
|
||||||
|
@ -652,11 +664,11 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function domshort($dom, $sub = "") {
|
function domshort($dom, $sub = "") {
|
||||||
return str_replace("-", "", str_replace(".", "", empty($sub) ? "" : "$sub.") . $dom);
|
return str_replace("-", "", str_replace(".", "", empty($sub) ? "" : "$sub.") . $dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Installe un domaine sur le compte courant.
|
* Installe un domaine sur le compte courant.
|
||||||
|
@ -799,6 +811,7 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $domain
|
* @param string $domain
|
||||||
*/
|
*/
|
||||||
|
@ -823,6 +836,7 @@ class m_dom {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $domain
|
* @param string $domain
|
||||||
*/
|
*/
|
||||||
|
@ -830,12 +844,14 @@ class m_dom {
|
||||||
return "/www/" . $this->domshort($domain);
|
return "/www/" . $this->domshort($domain);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function dump_axfr($domain, $ns = 'localhost') {
|
function dump_axfr($domain, $ns = 'localhost') {
|
||||||
$axfr = array();
|
$axfr = array();
|
||||||
exec('/usr/bin/dig AXFR "' . escapeshellcmd($domain) . '" @"' . escapeshellcmd($ns) . '"', $axfr);
|
exec('/usr/bin/dig AXFR "' . escapeshellcmd($domain) . '" @"' . escapeshellcmd($ns) . '"', $axfr);
|
||||||
return $axfr;
|
return $axfr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function lst_default_subdomains() {
|
function lst_default_subdomains() {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
$msg->log("dom", "lst_default_subdomains");
|
$msg->log("dom", "lst_default_subdomains");
|
||||||
|
@ -855,6 +871,7 @@ class m_dom {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function update_default_subdomains($arr) {
|
function update_default_subdomains($arr) {
|
||||||
global $msg;
|
global $msg;
|
||||||
$msg->log("dom", "update_default_subdomains");
|
$msg->log("dom", "update_default_subdomains");
|
||||||
|
@ -876,6 +893,7 @@ class m_dom {
|
||||||
return $ok;
|
return $ok;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function update_one_default($domain_type, $sub, $domain_type_parameter, $concerned, $enabled, $id = null) {
|
function update_one_default($domain_type, $sub, $domain_type_parameter, $concerned, $enabled, $id = null) {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
$msg->log("dom", "update_one_default");
|
$msg->log("dom", "update_one_default");
|
||||||
|
@ -889,6 +907,7 @@ class m_dom {
|
||||||
//update
|
//update
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function del_default_type($id) {
|
function del_default_type($id) {
|
||||||
global $msg, $db;
|
global $msg, $db;
|
||||||
$msg->log("dom", "del_default_type");
|
$msg->log("dom", "del_default_type");
|
||||||
|
@ -901,7 +920,6 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les entrées DNS du domaine $domain issues du WHOIS.
|
* Retourne les entrées DNS du domaine $domain issues du WHOIS.
|
||||||
|
@ -1075,12 +1093,8 @@ class m_dom {
|
||||||
$msg->raise("ALERT", "dom", _("The domain cannot be found in the Whois database"));
|
$msg->raise("ALERT", "dom", _("The domain cannot be found in the Whois database"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
} // whois
|
||||||
|
|
||||||
// whois
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vérifie la presence d'un champs mx valide sur un serveur DNS
|
* vérifie la presence d'un champs mx valide sur un serveur DNS
|
||||||
|
@ -1127,7 +1141,6 @@ class m_dom {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* retourne TOUTES les infos d'un domaine
|
* retourne TOUTES les infos d'un domaine
|
||||||
|
@ -1201,12 +1214,8 @@ class m_dom {
|
||||||
}
|
}
|
||||||
$db->free();
|
$db->free();
|
||||||
return $r;
|
return $r;
|
||||||
}
|
} // get_domain_all
|
||||||
|
|
||||||
// get_domain_all
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne TOUTES les infos d'un sous domaine du compte courant.
|
* 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"];
|
$r["web_action"] = $db->Record["web_action"];
|
||||||
$db->free();
|
$db->free();
|
||||||
return $r;
|
return $r;
|
||||||
}
|
} // get_sub_domain_all
|
||||||
|
|
||||||
// get_sub_domain_all
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $type
|
* @param integer $type
|
||||||
|
@ -1322,7 +1330,6 @@ class m_dom {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check the compatibility of the POSTed parameters with the chosen
|
* Check the compatibility of the POSTed parameters with the chosen
|
||||||
|
@ -1361,7 +1368,6 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifier les information du sous-domaine demandé.
|
* Modifier les information du sous-domaine demandé.
|
||||||
|
@ -1455,7 +1461,6 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Supprime le sous-domaine demandé
|
* Supprime le sous-domaine demandé
|
||||||
|
@ -1481,6 +1486,7 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $dom_id
|
* @param integer $dom_id
|
||||||
*/
|
*/
|
||||||
|
@ -1496,7 +1502,6 @@ class m_dom {
|
||||||
return $j;
|
return $j;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Modifie les information du domaine précisé.
|
* 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) {
|
if ($ttl == 0) {
|
||||||
$ttl = 86400;
|
$ttl = 86400;
|
||||||
}
|
}
|
||||||
|
@ -1559,7 +1564,7 @@ class m_dom {
|
||||||
return true;
|
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) {
|
if ($dns == "0" && $gesmx == "1" && !$force) {
|
||||||
$vmx = $this->checkmx($dom);
|
$vmx = $this->checkmx($dom);
|
||||||
if ($vmx == 1) {
|
if ($vmx == 1) {
|
||||||
|
@ -1586,11 +1591,9 @@ class m_dom {
|
||||||
return true;
|
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
|
/** Return the list of ip addresses and classes that are allowed access to domain list
|
||||||
* through AXFR Transfers from the bind server.
|
* through AXFR Transfers from the bind server.
|
||||||
|
@ -1608,9 +1611,9 @@ class m_dom {
|
||||||
return $res;
|
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") {
|
function add_slave_ip($ip, $class = "32") {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
|
@ -1634,9 +1637,9 @@ class m_dom {
|
||||||
return true;
|
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) {
|
function del_slave_ip($ip) {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
|
@ -1651,9 +1654,9 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Check for a slave account
|
/**
|
||||||
|
* Check for a slave account
|
||||||
*/
|
*/
|
||||||
function check_slave_account($login, $pass) {
|
function check_slave_account($login, $pass) {
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -1664,9 +1667,8 @@ class m_dom {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/**
|
||||||
|
* Out (echo) the complete hosted domain list :
|
||||||
/** Out (echo) the complete hosted domain list :
|
|
||||||
*/
|
*/
|
||||||
function echo_domain_list($integrity = false) {
|
function echo_domain_list($integrity = false) {
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -1683,9 +1685,9 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Returns the complete hosted domain list :
|
/**
|
||||||
|
* Returns the complete hosted domain list :
|
||||||
*/
|
*/
|
||||||
function get_domain_list($uid = -1) {
|
function get_domain_list($uid = -1) {
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -1726,7 +1728,6 @@ class m_dom {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Returns the name of a domain for the current user, from it's domain_id
|
/** 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
|
* @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
|
/** Returns the id of a domain for the current user, from it's domain name
|
||||||
* @param $domain string the domain name to search for
|
* @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() {
|
function count_domains_all() {
|
||||||
global $db;
|
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() {
|
function enum_slave_account() {
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -1805,9 +1805,9 @@ class m_dom {
|
||||||
return $res;
|
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) {
|
function add_slave_account($login, $pass) {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
|
@ -1820,9 +1820,9 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Remove a slave account
|
/**
|
||||||
|
* Remove a slave account
|
||||||
*/
|
*/
|
||||||
function del_slave_account($login) {
|
function del_slave_account($login) {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
|
@ -1830,14 +1830,11 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* * ********** */
|
|
||||||
/* Private */
|
/* Private */
|
||||||
/* * ********** */
|
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/**
|
||||||
|
* Try to lock a domain
|
||||||
/** Try to lock a domain
|
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function lock() {
|
function lock() {
|
||||||
|
@ -1853,9 +1850,9 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Unlock the cron for domain management
|
/**
|
||||||
|
* Unlock the cron for domain management
|
||||||
* return true
|
* return true
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -1869,9 +1866,9 @@ class m_dom {
|
||||||
return true;
|
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)
|
* This adds 2 MX entries in this domain (if required)
|
||||||
*/
|
*/
|
||||||
function hook_dom_add_mx_domain($dom_id) {
|
function hook_dom_add_mx_domain($dom_id) {
|
||||||
|
@ -1885,7 +1882,6 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete an account (all his domains)
|
* Delete an account (all his domains)
|
||||||
|
@ -1900,9 +1896,9 @@ class m_dom {
|
||||||
return true;
|
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
|
* @param $name string name of the quota
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -1918,11 +1914,11 @@ class m_dom {
|
||||||
return $q;
|
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
|
* No parameters needed
|
||||||
* */
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
global $msg;
|
global $msg;
|
||||||
$msg->log("dom", "export");
|
$msg->log("dom", "export");
|
||||||
|
@ -1967,6 +1963,7 @@ class m_dom {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array with all the needed parameters to generate conf
|
* Return an array with all the needed parameters to generate conf
|
||||||
* of a vhost.
|
* of a vhost.
|
||||||
|
@ -2023,6 +2020,7 @@ class m_dom {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return an array with all informations of the domains_type
|
* Return an array with all informations of the domains_type
|
||||||
* used to generate Apache conf.
|
* used to generate Apache conf.
|
||||||
|
@ -2046,7 +2044,11 @@ class m_dom {
|
||||||
return $d;
|
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) {
|
function generate_conf_oldhook($action, $lst_sub, $sub_obj = null) {
|
||||||
if (is_null($sub_obj)) {
|
if (is_null($sub_obj)) {
|
||||||
$sub_obj = $this->generation_parameters(null, false);
|
$sub_obj = $this->generation_parameters(null, false);
|
||||||
|
@ -2072,6 +2074,7 @@ class m_dom {
|
||||||
} // foreach $lst_by_type
|
} // foreach $lst_by_type
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Generate apache configuration.
|
* Generate apache configuration.
|
||||||
* Die if a specific FQDN have 2 vhost conf.
|
* Die if a specific FQDN have 2 vhost conf.
|
||||||
|
@ -2124,7 +2127,10 @@ class m_dom {
|
||||||
return $ret;
|
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() {
|
function generation_todo() {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
$msg->log("dom", "generation_todo");
|
$msg->log("dom", "generation_todo");
|
||||||
|
@ -2136,6 +2142,7 @@ class m_dom {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function subdomain_modif_are_done($sub_domain_id, $action) {
|
function subdomain_modif_are_done($sub_domain_id, $action) {
|
||||||
global $db;
|
global $db;
|
||||||
$sub_domain_id = intval($sub_domain_id);
|
$sub_domain_id = intval($sub_domain_id);
|
||||||
|
@ -2150,6 +2157,7 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $dns_action
|
* @param string $dns_action
|
||||||
*/
|
*/
|
||||||
|
@ -2159,13 +2167,13 @@ class m_dom {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function set_dns_result($domain, $dns_result) {
|
function set_dns_result($domain, $dns_result) {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query("UPDATE domaines SET dns_result= ? WHERE domaine= ?; ", array($dns_result, $domain));
|
$db->query("UPDATE domaines SET dns_result= ? WHERE domaine= ?; ", array($dns_result, $domain));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** hook function called by AlternC-upnp to know which open
|
/** hook function called by AlternC-upnp to know which open
|
||||||
* tcp or udp ports this class requires or suggests
|
* 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) {
|
function get_problems($domain) {
|
||||||
$this->lock();
|
$this->lock();
|
||||||
$da = $this->get_domain_all($domain);
|
$da = $this->get_domain_all($domain);
|
||||||
|
@ -2218,6 +2229,7 @@ class m_dom {
|
||||||
return $errors;
|
return $errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function default_domain_type() {
|
function default_domain_type() {
|
||||||
// This function is only used to allow translation of default domain types:
|
// This function is only used to allow translation of default domain types:
|
||||||
_("Locally hosted");
|
_("Locally hosted");
|
||||||
|
@ -2236,6 +2248,4 @@ class m_dom {
|
||||||
_("AlternC panel access");
|
_("AlternC panel access");
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* Class m_domains */
|
||||||
|
|
||||||
/* Class m_domains */
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
/*
|
/*
|
||||||
$Id: m_err.php,v 1.4 2004/05/19 14:23:06 benjamin Exp $
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -16,23 +15,22 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Original Author of file: Benjamin Sonntag, Franck Missoum
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe de gestion des erreurs apparaissant lors d'appels API.
|
* Classe de gestion des erreurs apparaissant lors d'appels API.
|
||||||
*
|
*
|
||||||
* <p>Cette classe gère les erreurs qui peuvent apparaitre lors d'appels
|
* <p>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
|
* à 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é.
|
* (Classe ID et Numéro d'erreur) ainsi qu'un texte facultatif associé.
|
||||||
* Des textes d'erreurs localisés sont aussi disponibles.</p>
|
* Des textes d'erreurs localisés sont aussi disponibles.</p>
|
||||||
* <p>Cette classe se charge aussi d'insérer les appels à l'API d'AlternC
|
* <p>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
|
* dans les logs du système dans /var/log/alternc/bureau.log
|
||||||
* </p>
|
* </p>
|
||||||
* Copyleft {@link http://alternc.net/ AlternC Team}
|
* Copyleft {@link http://alternc.net/ AlternC Team}
|
||||||
*
|
*
|
||||||
* @copyright AlternC-Team 2002-11-01 http://alternc.net/
|
* @copyright AlternC-Team 2002-11-01 http://alternc.net/
|
||||||
*/
|
*/
|
||||||
class m_err {
|
class m_err {
|
||||||
|
|
||||||
/** Numero de classe d'erreur actuelle */
|
/** Numero de classe d'erreur actuelle */
|
||||||
|
@ -150,6 +148,7 @@ class m_err {
|
||||||
$caller = $trace[2];
|
$caller = $trace[2];
|
||||||
$msg->raise( "error","err","Deprecation warning: The old messaging class is still used by ".json_encode( $caller ));
|
$msg->raise( "error","err","Deprecation warning: The old messaging class is still used by ".json_encode( $caller ));
|
||||||
}
|
}
|
||||||
}; /* Classe m_err */
|
|
||||||
|
|
||||||
?>
|
} /* Classe m_err */
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
Classe d'export de compte Alternc.
|
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,
|
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.
|
presentes dans les classes concernées.
|
||||||
*/
|
*/
|
||||||
Class m_export {
|
Class m_export {
|
||||||
|
|
||||||
function m_export() {
|
function m_export() {
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,9 +16,7 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage FTP accounts
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* FTP account management class
|
* FTP account management class
|
||||||
|
@ -31,17 +25,15 @@ class m_ftp {
|
||||||
|
|
||||||
var $srv_name;
|
var $srv_name;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructor
|
||||||
*/
|
*/
|
||||||
function m_ftp() {
|
function m_ftp() {
|
||||||
global $L_FQDN;
|
global $L_FQDN;
|
||||||
$this->srv_name = variable_get('ftp_human_name', $L_FQDN, 'Human name for FTP server', array('desc' => 'Name', 'type' => 'string'));
|
$this->srv_name = variable_get('ftp_human_name', $L_FQDN, 'Human name for FTP server', array('desc' => 'Name', 'type' => 'string'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password kind used in this class (hook for admin class)
|
* Password kind used in this class (hook for admin class)
|
||||||
|
@ -50,6 +42,11 @@ class m_ftp {
|
||||||
return array("ftp" => "FTP accounts");
|
return array("ftp" => "FTP accounts");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hook function called by menu class
|
||||||
|
* to add menu to the left panel
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $quota;
|
global $quota;
|
||||||
$q = $quota->getquota("ftp");
|
$q = $quota->getquota("ftp");
|
||||||
|
@ -81,8 +78,11 @@ class m_ftp {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Return the values needed to activate security access. See get_auth_class()
|
|
||||||
// in authip for more informations
|
/**
|
||||||
|
* Return the values needed to activate security access. See get_auth_class()
|
||||||
|
* in authip for more informations
|
||||||
|
*/
|
||||||
function authip_class() {
|
function authip_class() {
|
||||||
$c = Array();
|
$c = Array();
|
||||||
$c['name'] = "FTP";
|
$c['name'] = "FTP";
|
||||||
|
@ -100,7 +100,10 @@ class m_ftp {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Switch enabled status of an account
|
|
||||||
|
/**
|
||||||
|
* Switch enabled status of an account
|
||||||
|
*/
|
||||||
function switch_enabled($id, $status = null) {
|
function switch_enabled($id, $status = null) {
|
||||||
global $cuid, $db, $msg;
|
global $cuid, $db, $msg;
|
||||||
if (!$jj = $this->get_ftp_details($id)) {
|
if (!$jj = $this->get_ftp_details($id)) {
|
||||||
|
@ -114,7 +117,6 @@ class m_ftp {
|
||||||
$status = 1;
|
$status = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Be sure what is in $status, in case of it was a parameter
|
// Be sure what is in $status, in case of it was a parameter
|
||||||
$status = ($status ? 1 : 0);
|
$status = ($status ? 1 : 0);
|
||||||
|
|
||||||
|
@ -126,9 +128,9 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Retourne la liste des comptes FTP du compte h<EFBFBD>berg<EFBFBD>
|
/**
|
||||||
|
* Retourne la liste des comptes FTP du compte h<EFBFBD>berg<EFBFBD>
|
||||||
* Retourne la liste des comptes FTP sous forme de tableau index<EFBFBD> de
|
* Retourne la liste des comptes FTP sous forme de tableau index<EFBFBD> de
|
||||||
* tableaus associatifs comme suit :
|
* tableaus associatifs comme suit :
|
||||||
* $a["id"]= ID du compte ftp
|
* $a["id"]= ID du compte ftp
|
||||||
|
@ -158,9 +160,9 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Retourne les details d'un compte FTP (voir get_list)
|
/**
|
||||||
|
* Retourne les details d'un compte FTP (voir get_list)
|
||||||
* Le tableau est celui du compte d'id specifie
|
* Le tableau est celui du compte d'id specifie
|
||||||
* @param integer $id Numero du compte dont on souhaite obtenir les d<EFBFBD>tails
|
* @param integer $id Numero du compte dont on souhaite obtenir les d<EFBFBD>tails
|
||||||
* @return array Tableau associatif contenant les infos du comptes ftp
|
* @return array Tableau associatif contenant les infos du comptes ftp
|
||||||
|
@ -196,9 +198,9 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Retourne la liste des prefixes utilisables par le compte courant
|
/**
|
||||||
|
* Retourne la liste des prefixes utilisables par le compte courant
|
||||||
* @return array tableau contenant la liste des prefixes (domaines + login)
|
* @return array tableau contenant la liste des prefixes (domaines + login)
|
||||||
* du compte actuel.
|
* du compte actuel.
|
||||||
*/
|
*/
|
||||||
|
@ -213,14 +215,13 @@ class m_ftp {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the login is fine (syntax)
|
* Check if the login is fine (syntax)
|
||||||
*
|
|
||||||
* @param string $l
|
* @param string $l
|
||||||
*/
|
*/
|
||||||
function check_login($l) {
|
function check_login($l) {
|
||||||
global $msg;
|
global $msg;
|
||||||
|
|
||||||
// special chars and the max numbers of them allowed
|
// special chars and the max numbers of them allowed
|
||||||
// to be able to give a specific error
|
// to be able to give a specific error
|
||||||
$vv = array('_' => '1', ' ' => 0);
|
$vv = array('_' => '1', ' ' => 0);
|
||||||
|
@ -230,7 +231,6 @@ class m_ftp {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Explicitly look for only allowed chars
|
// Explicitly look for only allowed chars
|
||||||
if (!preg_match("/^[A-Za-z0-9]+[A-Za-z0-9_\.\-]*$/", $l)) {
|
if (!preg_match("/^[A-Za-z0-9]+[A-Za-z0-9_\.\-]*$/", $l)) {
|
||||||
$msg->raise("ERROR", 'ftp', _("FTP login is incorrect"));
|
$msg->raise("ERROR", 'ftp', _("FTP login is incorrect"));
|
||||||
|
@ -239,9 +239,9 @@ class m_ftp {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Affiche (ECHO) la liste des prefixes disponibles sous forme de champs d'option
|
/**
|
||||||
|
* Affiche (ECHO) la liste des prefixes disponibles sous forme de champs d'option
|
||||||
* Les champs sont affich<EFBFBD>s sous la forme <option>prefixe</option>...
|
* Les champs sont affich<EFBFBD>s sous la forme <option>prefixe</option>...
|
||||||
* La valeur $current se voit affubl<EFBFBD>e de la balise SELECTED.
|
* La valeur $current se voit affubl<EFBFBD>e de la balise SELECTED.
|
||||||
* @param string $current Prefixe s<EFBFBD>lectionn<EFBFBD> par d<EFBFBD>faut
|
* @param string $current Prefixe s<EFBFBD>lectionn<EFBFBD> par d<EFBFBD>faut
|
||||||
|
@ -261,9 +261,9 @@ class m_ftp {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Modifie les param<EFBFBD>tres du comptes FTP $id.
|
/**
|
||||||
|
* Modifie les param<EFBFBD>tres du comptes FTP $id.
|
||||||
* @param integer $id Num<EFBFBD>ro du compte dont on veut modifier les param<EFBFBD>tres
|
* @param integer $id Num<EFBFBD>ro du compte dont on veut modifier les param<EFBFBD>tres
|
||||||
* @param string $prefixe Prefixe du compte FTP
|
* @param string $prefixe Prefixe du compte FTP
|
||||||
* @param string $login login ajout<EFBFBD> au pr<EFBFBD>fixe ($prefixe_$login)
|
* @param string $login login ajout<EFBFBD> au pr<EFBFBD>fixe ($prefixe_$login)
|
||||||
|
@ -327,9 +327,9 @@ class m_ftp {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Efface le compte ftp specifie
|
/**
|
||||||
|
* Efface le compte ftp specifie
|
||||||
* @param integer $id Numero du compte FTP a supprimer.
|
* @param integer $id Numero du compte FTP a supprimer.
|
||||||
* @return boolean TRUE si le compte a ete efface, FALSE sinon.
|
* @return boolean TRUE si le compte a ete efface, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
@ -347,15 +347,14 @@ class m_ftp {
|
||||||
return $name;
|
return $name;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Cree un nouveau compte FTP.
|
/**
|
||||||
|
* Cree un nouveau compte FTP.
|
||||||
* @param string $prefixe Prefixe au login
|
* @param string $prefixe Prefixe au login
|
||||||
* @param string $login Login ftp (login=prefixe_login)
|
* @param string $login Login ftp (login=prefixe_login)
|
||||||
* @param string $pass Mot de passe FTP
|
* @param string $pass Mot de passe FTP
|
||||||
* @param string $dir Repertoire racine du compte relatif à la racine du membre
|
* @param string $dir Repertoire racine du compte relatif à la racine du membre
|
||||||
* @return boolean TRUE si le compte a ete cree, FALSE sinon.
|
* @return boolean TRUE si le compte a ete cree, FALSE sinon.
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
function add_ftp($prefixe, $login, $pass, $dir) {
|
function add_ftp($prefixe, $login, $pass, $dir) {
|
||||||
global $db, $msg, $quota, $bro, $cuid, $admin;
|
global $db, $msg, $quota, $bro, $cuid, $admin;
|
||||||
|
@ -414,9 +413,9 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Retourne TRUE si $dir possee un compte FTP
|
/**
|
||||||
|
* Retourne TRUE si $dir possee un compte FTP
|
||||||
* @param string $dir Dossier a tester, relatif a la racine du compte courant
|
* @param string $dir Dossier a tester, relatif a la racine du compte courant
|
||||||
* @return boolean retourne TRUE si $dir a un compte FTP, FALSE sinon.
|
* @return boolean retourne TRUE si $dir a un compte FTP, FALSE sinon.
|
||||||
*/
|
*/
|
||||||
|
@ -435,9 +434,9 @@ class m_ftp {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Fonction appellee par domains quand un domaine est supprime pour le membre
|
/**
|
||||||
|
* Fonction appellee par domains quand un domaine est supprime pour le membre
|
||||||
* @param string $dom Domaine à detruire.
|
* @param string $dom Domaine à detruire.
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -448,9 +447,9 @@ class m_ftp {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Fonction appellee par membres quand un membre est efface
|
/**
|
||||||
|
* Fonction appellee par membres quand un membre est efface
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function alternc_del_member() {
|
function alternc_del_member() {
|
||||||
|
@ -460,7 +459,6 @@ class m_ftp {
|
||||||
return true;
|
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.
|
||||||
|
@ -479,7 +477,6 @@ class m_ftp {
|
||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exporte toutes les informations ftp du compte AlternC
|
* Exporte toutes les informations ftp du compte AlternC
|
||||||
|
@ -500,9 +497,9 @@ class m_ftp {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** hook function called by AlternC-upnp to know which open
|
/**
|
||||||
|
* hook function called by AlternC-upnp to know which open
|
||||||
* tcp or udp ports this class requires or suggests
|
* tcp or udp ports this class requires or suggests
|
||||||
* @return array a key => value list of port protocol name mandatory values
|
* @return array a key => value list of port protocol name mandatory values
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -513,6 +510,5 @@ class m_ftp {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* Class m_ftp */
|
||||||
|
|
||||||
/* Class m_ftp */
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,26 +16,14 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage hook system.
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manage hooks.
|
* This class manage hooks.
|
||||||
*
|
*
|
||||||
* @copyright AlternC-Team 2002-2005 http://alternc.org/
|
|
||||||
*/
|
*/
|
||||||
class m_hooks {
|
class m_hooks {
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Constructor
|
|
||||||
* hooks([$mid]) Constructeur de la classe hooks, ne fait rien pour le moment
|
|
||||||
*/
|
|
||||||
function m_hooks() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* invoke() permet de lancer une fonction donné en parametre dans toute les classes
|
* invoke() permet de lancer une fonction donné en parametre dans toute les classes
|
||||||
|
@ -79,7 +63,6 @@ class m_hooks {
|
||||||
return $val;
|
return $val;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* invoke each executable script of the directory (or the specified script)
|
* invoke each executable script of the directory (or the specified script)
|
||||||
|
@ -119,7 +102,5 @@ class m_hooks {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* Class hooks */
|
||||||
|
|
||||||
/* Class hooks */
|
|
||||||
|
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id: m_hta.php,v 1.5 2004/11/29 17:15:37 anonymous Exp $
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2002 by the AlternC Development Team.
|
|
||||||
http://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Based on:
|
|
||||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -24,40 +16,28 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Original Author of file:
|
*/
|
||||||
Purpose of file:
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class handle folder web restricted access through .htaccess/.htpassword
|
* This class handle folder web restricted access through .htaccess/.htpassword
|
||||||
* files.
|
* files.
|
||||||
*
|
*
|
||||||
* Copyleft {@link http://alternc.net/ AlternC Team}
|
|
||||||
*
|
|
||||||
* @copyright AlternC-Team 2002-11-01 http://alternc.org/
|
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
class m_hta {
|
class m_hta {
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructor
|
|
||||||
*/
|
|
||||||
function m_webaccess() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password kind used in this class (hook for admin class)
|
* Password kind used in this class (hook for admin class)
|
||||||
*
|
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function alternc_password_policy() {
|
function alternc_password_policy() {
|
||||||
return array("hta" => "Protected folders passwords");
|
return array("hta" => "Protected folders passwords");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
* hook called by menu class to add a menu
|
||||||
|
* to the left panel
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
|
@ -71,6 +51,7 @@ class m_hta {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a protected folder (.htaccess et .htpasswd)
|
* Create a protected folder (.htaccess et .htpasswd)
|
||||||
* @param string $dir Folder to protect (relative to user root)
|
* @param string $dir Folder to protect (relative to user root)
|
||||||
|
@ -115,6 +96,7 @@ class m_hta {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of all user folder currently protected by a .htpasswd file
|
* Returns the list of all user folder currently protected by a .htpasswd file
|
||||||
*
|
*
|
||||||
|
@ -144,6 +126,7 @@ class m_hta {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tells if a folder is protected.
|
* Tells if a folder is protected.
|
||||||
*
|
*
|
||||||
|
@ -163,6 +146,7 @@ class m_hta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of login for a protected folder.
|
* Returns the list of login for a protected folder.
|
||||||
*
|
*
|
||||||
|
@ -187,7 +171,7 @@ class m_hta {
|
||||||
if (!$file) {
|
if (!$file) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// TODO: Tester la validité du .htpasswd
|
// TODO: Test the validity of a .htpasswd
|
||||||
while (!feof($file)) {
|
while (!feof($file)) {
|
||||||
$s = fgets($file, 1024);
|
$s = fgets($file, 1024);
|
||||||
$t = explode(":", $s);
|
$t = explode(":", $s);
|
||||||
|
@ -200,6 +184,7 @@ class m_hta {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unprotect a folder
|
* Unprotect a folder
|
||||||
*
|
*
|
||||||
|
@ -261,6 +246,7 @@ class m_hta {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a user to a protected folder
|
* Add a user to a protected folder
|
||||||
*
|
*
|
||||||
|
@ -326,6 +312,7 @@ class m_hta {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a user from a protected folder.
|
* Delete a user from a protected folder.
|
||||||
*
|
*
|
||||||
|
@ -367,6 +354,7 @@ class m_hta {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change the password of a user in a protected folder
|
* Change the password of a user in a protected folder
|
||||||
* @param string $user The users whose password should be changed
|
* @param string $user The users whose password should be changed
|
||||||
|
@ -412,6 +400,7 @@ class m_hta {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that a .htaccess file is valid (for authentication)
|
* Check that a .htaccess file is valid (for authentication)
|
||||||
*
|
*
|
||||||
|
@ -455,6 +444,5 @@ class m_hta {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* class m_hta */
|
||||||
|
|
||||||
/* CLASS m_hta */
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,19 +16,16 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage Log files for users
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Classe de gestion des erreurs apparaissant lors d'appels API.
|
* This class shows error or access logs of web server to the web panel
|
||||||
*/
|
*/
|
||||||
class m_log {
|
class m_log {
|
||||||
|
|
||||||
function m_log() {
|
/**
|
||||||
|
* List all logs files in a directory
|
||||||
}
|
*/
|
||||||
|
|
||||||
function list_logs_directory($dir) {
|
function list_logs_directory($dir) {
|
||||||
global $cuid, $msg;
|
global $cuid, $msg;
|
||||||
$msg->log("log", "list_logs_directory");
|
$msg->log("log", "list_logs_directory");
|
||||||
|
@ -50,16 +43,27 @@ class m_log {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by list_logs_directory to sort
|
|
||||||
|
/**
|
||||||
|
* Used by list_logs_directory to sort
|
||||||
|
*/
|
||||||
private function compare_logname($a, $b) {
|
private function compare_logname($a, $b) {
|
||||||
return strcmp($a['name'], $b['name']);
|
return strcmp($a['name'], $b['name']);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Used by list_logs_directory to sort
|
|
||||||
|
/**
|
||||||
|
* Used by list_logs_directory to sort
|
||||||
|
*/
|
||||||
private function compare_logtime($a, $b) {
|
private function compare_logtime($a, $b) {
|
||||||
return $b['mtime'] - $a['mtime'];
|
return $b['mtime'] - $a['mtime'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hook called by the menu class
|
||||||
|
* to add menu to the left panel
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Logs"),
|
'title' => _("Logs"),
|
||||||
|
@ -71,6 +75,9 @@ class m_log {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list all log files in all log directories
|
||||||
|
*/
|
||||||
function list_logs_directory_all($dirs) {
|
function list_logs_directory_all($dirs) {
|
||||||
global $msg;
|
global $msg;
|
||||||
$msg->log("log", "get_logs_directory_all");
|
$msg->log("log", "get_logs_directory_all");
|
||||||
|
@ -81,6 +88,7 @@ class m_log {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_logs_directory() {
|
function get_logs_directory() {
|
||||||
global $cuid, $mem, $msg;
|
global $cuid, $mem, $msg;
|
||||||
$msg->log("log", "get_logs_directory");
|
$msg->log("log", "get_logs_directory");
|
||||||
|
@ -93,6 +101,10 @@ class m_log {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* download a log file
|
||||||
|
*/
|
||||||
function download_link($file) {
|
function download_link($file) {
|
||||||
global $msg;
|
global $msg;
|
||||||
$msg->log("log", "download_link");
|
$msg->log("log", "download_link");
|
||||||
|
@ -105,6 +117,9 @@ class m_log {
|
||||||
readfile($ff);
|
readfile($ff);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* show the last lines of a file
|
||||||
|
*/
|
||||||
function tail($file, $lines = 20) {
|
function tail($file, $lines = 20) {
|
||||||
global $msg;
|
global $msg;
|
||||||
$msg->log("log", "tail");
|
$msg->log("log", "tail");
|
||||||
|
@ -119,6 +134,4 @@ class m_log {
|
||||||
return implode("\n", $out);
|
return implode("\n", $out);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* class m_log */
|
||||||
|
|
||||||
// end class
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2013 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,13 +16,12 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage LXC-based virtual machine through an inetd-based protocol
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
include_once(dirname(__FILE__) . '/vm.class.php');
|
include_once(dirname(__FILE__) . '/vm.class.php');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
*
|
||||||
* Manage AlternC's virtual machine start/stop using our own inetd-based protocol.
|
* Manage AlternC's virtual machine start/stop using our own inetd-based protocol.
|
||||||
*/
|
*/
|
||||||
class m_lxc implements vm {
|
class m_lxc implements vm {
|
||||||
|
@ -38,6 +33,7 @@ class m_lxc implements vm {
|
||||||
public $TIMEOUT = 5;
|
public $TIMEOUT = 5;
|
||||||
public $error = array();
|
public $error = array();
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor, initialize the class informations from AlternC's variables
|
* Constructor, initialize the class informations from AlternC's variables
|
||||||
*/
|
*/
|
||||||
|
@ -48,6 +44,7 @@ class m_lxc implements vm {
|
||||||
$this->maxtime = variable_get('lxc_maxtime', '4', "How many hours do we allow to have a server before shutting it down", array('desc' => 'Max time', 'type' => 'integer'));
|
$this->maxtime = variable_get('lxc_maxtime', '4', "How many hours do we allow to have a server before shutting it down", array('desc' => 'Max time', 'type' => 'integer'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HOOK: add the "Console Access" to AlternC's main menu
|
* HOOK: add the "Console Access" to AlternC's main menu
|
||||||
*/
|
*/
|
||||||
|
@ -65,6 +62,7 @@ class m_lxc implements vm {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* HOOK: remove VM history for AlternC account
|
* HOOK: remove VM history for AlternC account
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +73,7 @@ class m_lxc implements vm {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Send a message to a remote VM manager instance
|
* Send a message to a remote VM manager instance
|
||||||
* $params are the parameters to send as serialized data
|
* $params are the parameters to send as serialized data
|
||||||
|
@ -118,6 +117,7 @@ class m_lxc implements vm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* START a Virtual Machine on the remote VM manager
|
* START a Virtual Machine on the remote VM manager
|
||||||
* for user $login having hashed password $pass and uid $uid
|
* for user $login having hashed password $pass and uid $uid
|
||||||
|
@ -158,6 +158,7 @@ class m_lxc implements vm {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
@ -173,6 +174,7 @@ class m_lxc implements vm {
|
||||||
return unserialize($res);
|
return unserialize($res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop the currently running VM
|
* Stop the currently running VM
|
||||||
*/
|
*/
|
||||||
|
@ -187,6 +189,5 @@ class m_lxc implements vm {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* class m_lxc */
|
||||||
|
|
||||||
// class m_lxc
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,50 +16,48 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage Email accounts and aliases.
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class handle emails (pop and/or aliases and even wrapper for internal
|
* This class handle emails (pop and/or aliases and even wrapper for internal
|
||||||
* classes) of hosted users.
|
* classes) of hosted users.
|
||||||
*
|
*
|
||||||
* @copyright AlternC-Team 2012-09-01 http://alternc.com/
|
|
||||||
* This class is directly using the following alternc MySQL tables:
|
* This class is directly using the following alternc MySQL tables:
|
||||||
* address = any used email address will be defined here, mailbox = pop/imap mailboxes, recipient = redirection from an email to another
|
* address = any used email address will be defined here, mailbox = pop/imap mailboxes, recipient = redirection from an email to another
|
||||||
* and indirectly the domain class, to know domain names from their id in the DB.
|
* and indirectly the domain class, to know domain names from their id in the DB.
|
||||||
* This class is also defining a few hooks, search ->invoke in the code.
|
* This class is also defining a few hooks, search ->invoke in the code.
|
||||||
*/
|
*/
|
||||||
class m_mail {
|
class m_mail {
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** domain list for this account
|
/**
|
||||||
|
* domain list for this account
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $domains;
|
var $domains;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** If an email has those chars, 'not nice in shell env' ;)
|
/**
|
||||||
|
* If an email has those chars, 'not nice in shell env' ;)
|
||||||
* we don't store the email in $mail/u/{user}_domain, but in $mail/_/{address_id}_domain
|
* we don't store the email in $mail/u/{user}_domain, but in $mail/_/{address_id}_domain
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $specialchars = array('"', "'", '\\', '/');
|
var $specialchars = array('"', "'", '\\', '/');
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** If an email has those chars, we will ONLY allow RECIPIENTS, NOT POP/IMAP for DOVECOT !
|
/**
|
||||||
|
* If an email has those chars, we will ONLY allow RECIPIENTS, NOT POP/IMAP for DOVECOT !
|
||||||
* Since Dovecot doesn't allow those characters
|
* Since Dovecot doesn't allow those characters
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
var $forbiddenchars = array('"', "'", '\\', '/', '?', '!', '*', '$', '|', '#', '+');
|
var $forbiddenchars = array('"', "'", '\\', '/', '?', '!', '*', '$', '|', '#', '+');
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Number of results for a pager display
|
/**
|
||||||
|
* Number of results for a pager display
|
||||||
* @access public
|
* @access public
|
||||||
*/
|
*/
|
||||||
var $total;
|
var $total;
|
||||||
|
|
||||||
// Human server name for help
|
// Human server name for help
|
||||||
var $srv_submission;
|
var $srv_submission;
|
||||||
var $srv_smtp;
|
var $srv_smtp;
|
||||||
|
@ -75,7 +69,6 @@ class m_mail {
|
||||||
var $cache_domain_mail_size = array();
|
var $cache_domain_mail_size = array();
|
||||||
var $enum_domains = array();
|
var $enum_domains = array();
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructeur
|
* Constructeur
|
||||||
|
@ -91,6 +84,10 @@ class m_mail {
|
||||||
$this->srv_pop3s = variable_get('mail_human_pop3s', $L_FQDN, 'Human name for POP3s mail server', array('desc' => 'Name', 'type' => 'string'));
|
$this->srv_pop3s = variable_get('mail_human_pop3s', $L_FQDN, 'Human name for POP3s mail server', array('desc' => 'Name', 'type' => 'string'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hook called by menu class to add the email menu to the left pane
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Email Addresses"),
|
'title' => _("Email Addresses"),
|
||||||
|
@ -110,6 +107,7 @@ class m_mail {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_total_size_for_domain($domain) {
|
function get_total_size_for_domain($domain) {
|
||||||
global $db;
|
global $db;
|
||||||
if (empty($this->cache_domain_mail_size)) {
|
if (empty($this->cache_domain_mail_size)) {
|
||||||
|
@ -125,7 +123,6 @@ class m_mail {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME documenter
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $domain_id
|
* @param string $domain_id
|
||||||
|
@ -157,6 +154,7 @@ class m_mail {
|
||||||
return $rr;
|
return $rr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $domain_id
|
* @param string $domain_id
|
||||||
*/
|
*/
|
||||||
|
@ -168,6 +166,7 @@ class m_mail {
|
||||||
return $this->delete($catch['mail_id']);
|
return $this->delete($catch['mail_id']);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $domain_id
|
* @param string $domain_id
|
||||||
* @param string $target
|
* @param string $target
|
||||||
|
@ -179,9 +178,9 @@ class m_mail {
|
||||||
$target = '@' . $target;
|
$target = '@' . $target;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr($target, 0, 1) == '@') { // le premier caractere est un @
|
if (substr($target, 0, 1) == '@') { // the first character is @
|
||||||
// FIXME validate domain
|
// FIXME validate domain
|
||||||
} else { // ca doit être un mail
|
} else { // it MUST be an email
|
||||||
if (!filter_var($target, FILTER_VALIDATE_EMAIL)) {
|
if (!filter_var($target, FILTER_VALIDATE_EMAIL)) {
|
||||||
$msg->raise("ERROR", "mail", _("The email you entered is syntaxically incorrect"));
|
$msg->raise("ERROR", "mail", _("The email you entered is syntaxically incorrect"));
|
||||||
return false;
|
return false;
|
||||||
|
@ -191,9 +190,9 @@ class m_mail {
|
||||||
return $this->create_alias($domain_id, '', $target, "catchall", true);
|
return $this->create_alias($domain_id, '', $target, "catchall", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** get_quota (hook for quota class), returns the number of used
|
/**
|
||||||
|
* get_quota (hook for quota class), returns the number of used
|
||||||
* service for a quota-bound service
|
* service for a quota-bound service
|
||||||
* @param $name string the named quota we want
|
* @param $name string the named quota we want
|
||||||
* @return the number of used service for the specified quota,
|
* @return the number of used service for the specified quota,
|
||||||
|
@ -211,18 +210,18 @@ class m_mail {
|
||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Password policy kind used in this class (hook for admin class)
|
/**
|
||||||
|
* Password policy kind used in this class (hook for admin class)
|
||||||
* @return array an array of policykey => "policy name (for humans)"
|
* @return array an array of policykey => "policy name (for humans)"
|
||||||
*/
|
*/
|
||||||
function alternc_password_policy() {
|
function alternc_password_policy() {
|
||||||
return array("pop" => _("Email account password"));
|
return array("pop" => _("Email account password"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Returns the list of mail-hosting domains for a user
|
/**
|
||||||
|
* Returns the list of mail-hosting domains for a user
|
||||||
* @return array indexed array of hosted domains
|
* @return array indexed array of hosted domains
|
||||||
*/
|
*/
|
||||||
function enum_domains($uid = -1) {
|
function enum_domains($uid = -1) {
|
||||||
|
@ -254,9 +253,9 @@ ORDER BY
|
||||||
return $this->enum_domains;
|
return $this->enum_domains;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** available: tells if an email address can be installed in the server
|
/**
|
||||||
|
* available: tells if an email address can be installed in the server
|
||||||
* check the domain part (is it mine too), the syntax, and the availability.
|
* check the domain part (is it mine too), the syntax, and the availability.
|
||||||
* @param $mail string email to check
|
* @param $mail string email to check
|
||||||
* @return boolean true if the email can be installed on the server
|
* @return boolean true if the email can be installed on the server
|
||||||
|
@ -283,15 +282,15 @@ ORDER BY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/* function used to list every mail address hosted on a domain.
|
/**
|
||||||
|
* function used to list every mail address hosted on a domain.
|
||||||
* @param $dom_id integer the domain id.
|
* @param $dom_id integer the domain id.
|
||||||
* @param $search string search that string in recipients or address.
|
* @param $search string search that string in recipients or address.
|
||||||
* @param $offset integer skip THAT much emails in the result.
|
* @param $offset integer skip THAT much emails in the result.
|
||||||
* @param $count integer return no more than THAT much emails. -1 for ALL. Offset is ignored then.
|
* @param $count integer return no more than THAT much emails. -1 for ALL. Offset is ignored then.
|
||||||
* @result an array of each mail hosted under the domain.
|
* @result an array of each mail hosted under the domain.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function enum_domain_mails($dom_id = null, $search = "", $offset = 0, $count = 30, $show_systemmails = false) {
|
function enum_domain_mails($dom_id = null, $search = "", $offset = 0, $count = 30, $show_systemmails = false) {
|
||||||
global $db, $msg, $hooks;
|
global $db, $msg, $hooks;
|
||||||
$msg->log("mail", "enum_domains_mail");
|
$msg->log("mail", "enum_domains_mail");
|
||||||
|
@ -343,9 +342,9 @@ ORDER BY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Function used to insert a new mail into the db
|
/**
|
||||||
|
* Function used to insert a new mail into the db
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
* This function calls the hook "hooks_mail_cancreate"
|
* This function calls the hook "hooks_mail_cancreate"
|
||||||
|
@ -403,9 +402,9 @@ ORDER BY
|
||||||
return $id;
|
return $id;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** function used to get every information we can on a mail
|
/**
|
||||||
|
* function used to get every information we can on a mail
|
||||||
* @param $mail_id integer
|
* @param $mail_id integer
|
||||||
* @return array a hashtable with all the informations for that email
|
* @return array a hashtable with all the informations for that email
|
||||||
*/
|
*/
|
||||||
|
@ -435,9 +434,9 @@ ORDER BY
|
||||||
|
|
||||||
private $isitmy_cache = array();
|
private $isitmy_cache = array();
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Check if an email is mine ...
|
/**
|
||||||
|
* Check if an email is mine ...
|
||||||
*
|
*
|
||||||
* @param $mail_id integer the number of the email to check
|
* @param $mail_id integer the number of the email to check
|
||||||
* @return string the complete email address if that's mine, false if not
|
* @return string the complete email address if that's mine, false if not
|
||||||
|
@ -459,9 +458,9 @@ ORDER BY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook called when the DOMAIN class will delete a domain.
|
/**
|
||||||
|
* Hook called when the DOMAIN class will delete a domain.
|
||||||
* OR when the DOMAIN class tells us we don't host the emails of this domain anymore.
|
* OR when the DOMAIN class tells us we don't host the emails of this domain anymore.
|
||||||
* @param $dom the ID of the domain to delete
|
* @param $dom the ID of the domain to delete
|
||||||
* @return boolean if the email has been properly deleted
|
* @return boolean if the email has been properly deleted
|
||||||
|
@ -485,7 +484,10 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the alternc account's ID of the mail_id
|
|
||||||
|
/**
|
||||||
|
* return the alternc account's ID of the mail_id
|
||||||
|
*/
|
||||||
function get_account_by_mail_id($mail_id) {
|
function get_account_by_mail_id($mail_id) {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query("select compte as uid from domaines d, address a where a.domain_id = d.id and a.id = ? ;", array($mail_id));
|
$db->query("select compte as uid from domaines d, address a where a.domain_id = d.id and a.id = ? ;", array($mail_id));
|
||||||
|
@ -495,9 +497,9 @@ ORDER BY
|
||||||
return $db->f('uid');
|
return $db->f('uid');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Function used to delete a mail from the db
|
/**
|
||||||
|
* Function used to delete a mail from the db
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
* @param $mail_id integer the number of the email to delete
|
* @param $mail_id integer the number of the email to delete
|
||||||
|
@ -547,9 +549,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Function used to undelete a pending deletion mail from the db
|
/**
|
||||||
|
* Function used to undelete a pending deletion mail from the db
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
* @param $mail_id integer the email id
|
* @param $mail_id integer the email id
|
||||||
|
@ -598,9 +600,9 @@ ORDER BY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** set the password of an email address.
|
/**
|
||||||
|
* set the password of an email address.
|
||||||
* @param $mail_id integer email ID
|
* @param $mail_id integer email ID
|
||||||
* @param $pass string the new password.
|
* @param $pass string the new password.
|
||||||
* @return boolean true if the password has been set, false else, raise an error.
|
* @return boolean true if the password has been set, false else, raise an error.
|
||||||
|
@ -623,9 +625,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Enables an email address.
|
/**
|
||||||
|
* Enables an email address.
|
||||||
* @param $mail_id integer Email ID
|
* @param $mail_id integer Email ID
|
||||||
* @return boolean true if the email has been enabled.
|
* @return boolean true if the email has been enabled.
|
||||||
*/
|
*/
|
||||||
|
@ -641,9 +643,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Disables an email address.
|
/**
|
||||||
|
* Disables an email address.
|
||||||
* @param $mail_id integer Email ID
|
* @param $mail_id integer Email ID
|
||||||
* @return boolean true if the email has been enabled.
|
* @return boolean true if the email has been enabled.
|
||||||
*/
|
*/
|
||||||
|
@ -659,9 +661,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Function used to update an email settings
|
/**
|
||||||
|
* Function used to update an email settings
|
||||||
* should be used by the web interface, not by third-party programs.
|
* should be used by the web interface, not by third-party programs.
|
||||||
*
|
*
|
||||||
* @param $mail_id integer the number of the email to delete
|
* @param $mail_id integer the number of the email to delete
|
||||||
|
@ -733,9 +735,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** A wrapper used by mailman class to create it's needed addresses
|
/**
|
||||||
|
* A wrapper used by mailman class to create it's needed addresses
|
||||||
* @ param : $dom_id , the domain id associated to a given address
|
* @ param : $dom_id , the domain id associated to a given address
|
||||||
* @ param : $m , the left part of the mail address being created
|
* @ param : $m , the left part of the mail address being created
|
||||||
* @ param : $delivery , the delivery used to deliver the mail
|
* @ param : $delivery , the delivery used to deliver the mail
|
||||||
|
@ -749,9 +751,9 @@ ORDER BY
|
||||||
// FIXME return error code
|
// FIXME return error code
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** A function used to create an alias for a specific address
|
/**
|
||||||
|
* A function used to create an alias for a specific address
|
||||||
* @ param : $dom_id , the domain sql identifier
|
* @ param : $dom_id , the domain sql identifier
|
||||||
* @ param : $m , the alias we want to create
|
* @ param : $m , the alias we want to create
|
||||||
* @ param : $alias , the already existing aliased address
|
* @ param : $alias , the already existing aliased address
|
||||||
|
@ -772,9 +774,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** A wrapper used by mailman class to create it's needed addresses
|
/**
|
||||||
|
* A wrapper used by mailman class to create it's needed addresses
|
||||||
* @ param : $mail_id , the mysql id of the mail address we want to delete
|
* @ param : $mail_id , the mysql id of the mail address we want to delete
|
||||||
* of the email for the current acccount.
|
* of the email for the current acccount.
|
||||||
*/
|
*/
|
||||||
|
@ -784,9 +786,9 @@ ORDER BY
|
||||||
$this->delete($mail_id);
|
$this->delete($mail_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Export the mail information of an account
|
/**
|
||||||
|
* Export the mail information of an account
|
||||||
* @return: str, string containing the complete configuration
|
* @return: str, string containing the complete configuration
|
||||||
* of the email for the current acccount.
|
* of the email for the current acccount.
|
||||||
*/
|
*/
|
||||||
|
@ -825,7 +827,6 @@ ORDER BY
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of allowed slave accounts (secondary-mx)
|
* Return the list of allowed slave accounts (secondary-mx)
|
||||||
|
@ -844,7 +845,6 @@ ORDER BY
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check for a slave account (secondary mx)
|
* Check for a slave account (secondary mx)
|
||||||
|
@ -861,9 +861,9 @@ ORDER BY
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Out (echo) the complete hosted domain list :
|
/**
|
||||||
|
* Out (echo) the complete hosted domain list :
|
||||||
*/
|
*/
|
||||||
function echo_domain_list($format = null) {
|
function echo_domain_list($format = null) {
|
||||||
global $db;
|
global $db;
|
||||||
|
@ -875,7 +875,7 @@ ORDER BY
|
||||||
$tt.=$db->f("domaine");
|
$tt.=$db->f("domaine");
|
||||||
}
|
}
|
||||||
|
|
||||||
# Generate an integrity check
|
// Generate an integrity check
|
||||||
$obj = array('integrity' => md5($tt), 'items' => $lst);
|
$obj = array('integrity' => md5($tt), 'items' => $lst);
|
||||||
|
|
||||||
switch ($format) {
|
switch ($format) {
|
||||||
|
@ -889,7 +889,6 @@ ORDER BY
|
||||||
} // switch
|
} // switch
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add a slave account that will be allowed to access the mxdomain list
|
* Add a slave account that will be allowed to access the mxdomain list
|
||||||
|
@ -908,7 +907,6 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Remove a slave account
|
* Remove a slave account
|
||||||
|
@ -920,9 +918,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** hook function called by AlternC when a domain is created for
|
/**
|
||||||
|
* hook function called by AlternC when a domain is created for
|
||||||
* the current user account using the SLAVE DOMAIN feature
|
* the current user account using the SLAVE DOMAIN feature
|
||||||
* This function create a CATCHALL to the master domain
|
* This function create a CATCHALL to the master domain
|
||||||
* @param string $domain_id Domain that has just been created
|
* @param string $domain_id Domain that has just been created
|
||||||
|
@ -936,9 +934,9 @@ ORDER BY
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** hook function called by AlternC when a domain is created for
|
/**
|
||||||
|
* hook function called by AlternC when a domain is created for
|
||||||
* the current user account
|
* the current user account
|
||||||
* This function create a postmaster mail which is an alias to LOGIN @ FQDN
|
* This function create a postmaster mail which is an alias to LOGIN @ FQDN
|
||||||
* wich is a dynamic alias to the alternc's account mail
|
* wich is a dynamic alias to the alternc's account mail
|
||||||
|
@ -968,9 +966,9 @@ ORDER BY
|
||||||
return $this->create_alias($domain_id, 'postmaster', $mem->user['login'] . '@' . $mailname);
|
return $this->create_alias($domain_id, 'postmaster', $mem->user['login'] . '@' . $mailname);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** hook function called by variables when a variable is changed
|
/**
|
||||||
|
* hook function called by variables when a variable is changed
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function hook_variable_set($name, $old, $new) {
|
function hook_variable_set($name, $old, $new) {
|
||||||
|
@ -1000,9 +998,9 @@ ORDER BY
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Set or UPDATE the DNS record for the domain $dom(str) to be $spf
|
/**
|
||||||
|
* Set or UPDATE the DNS record for the domain $dom(str) to be $spf
|
||||||
* account's login is current and if not it's $login.
|
* account's login is current and if not it's $login.
|
||||||
* don't change spf if current value is not $old
|
* don't change spf if current value is not $old
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -1030,9 +1028,9 @@ ORDER BY
|
||||||
$db->query("UPDATE domaines SET dns_action='UPDATE' WHERE domaine= ?;", array($domain));
|
$db->query("UPDATE domaines SET dns_action='UPDATE' WHERE domaine= ?;", array($domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Set or UPDATE the DNS record for the domain $dom(str) to be $dmarc
|
/**
|
||||||
|
* Set or UPDATE the DNS record for the domain $dom(str) to be $dmarc
|
||||||
* account's login is current and if not it's $login.
|
* account's login is current and if not it's $login.
|
||||||
* don't change dmarc if current value is not $old
|
* don't change dmarc if current value is not $old
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -1063,9 +1061,9 @@ ORDER BY
|
||||||
$db->query("UPDATE domaines SET dns_action='UPDATE' WHERE domaine= ?;", array($domain));
|
$db->query("UPDATE domaines SET dns_action='UPDATE' WHERE domaine= ?;", array($domain));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** hook function called by AlternC-upnp to know which open
|
/**
|
||||||
|
* hook function called by AlternC-upnp to know which open
|
||||||
* tcp or udp ports this class requires or suggests
|
* tcp or udp ports this class requires or suggests
|
||||||
* @return array a key => value list of port protocol name mandatory values
|
* @return array a key => value list of port protocol name mandatory values
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -1082,6 +1080,5 @@ ORDER BY
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Class m_mail */
|
} /* Class m_mail */
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id: m_mem.php,v 1.19 2006/01/12 08:04:43 anarcat Exp $
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -17,11 +16,7 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Original Author of file: Benjamin Sonntag
|
*/
|
||||||
Purpose of file: Manage Login session on the virtual desktop and
|
|
||||||
member parameters
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manage user sessions in the web desktop.
|
* This class manage user sessions in the web desktop.
|
||||||
|
@ -35,27 +30,17 @@ class m_mem {
|
||||||
/** Original uid for the temporary uid swapping (for administrators) */
|
/** Original uid for the temporary uid swapping (for administrators) */
|
||||||
var $olduid = 0;
|
var $olduid = 0;
|
||||||
|
|
||||||
/** This array contains the Tableau contenant les champs de la table "membres" du membre courant
|
/**
|
||||||
* Ce tableau est utilisable globalement par toutes les classes filles.
|
* This array contains the Tableau contenant les champs de la table "membres" du membre courant
|
||||||
*/
|
*/
|
||||||
var $user;
|
var $user;
|
||||||
|
|
||||||
/** Tableau contenant les champs de la table "local" du membre courant
|
/**
|
||||||
* Ce tableau est utilisable globalement par toutes les classes filles.
|
* contains all the fields of the "local" table for an account in AlternC.
|
||||||
* Note : les champs de "local" sont specifiques a l'hebergeur.
|
* they are specific to the hosting provider
|
||||||
*/
|
*/
|
||||||
var $local;
|
var $local;
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Constructeur
|
|
||||||
*/
|
|
||||||
function m_mem() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password kind used in this class (hook for admin class)
|
* Password kind used in this class (hook for admin class)
|
||||||
|
@ -64,6 +49,10 @@ class m_mem {
|
||||||
return array("mem" => "AlternC's account password");
|
return array("mem" => "AlternC's account password");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* hook called by the m_menu class to add menu to the left of the panel
|
||||||
|
*/
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
$obj = array(
|
$obj = array(
|
||||||
'title' => _("Settings"),
|
'title' => _("Settings"),
|
||||||
|
@ -75,18 +64,18 @@ class m_mem {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Check that the current user is an admnistrator.
|
/**
|
||||||
|
* Check that the current user is an admnistrator.
|
||||||
* @return boolean TRUE if we are super user, or FALSE if we are not.
|
* @return boolean TRUE if we are super user, or FALSE if we are not.
|
||||||
*/
|
*/
|
||||||
function checkright() {
|
function checkright() {
|
||||||
return ($this->user["su"] == "1");
|
return ($this->user["su"] == "1");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Start a session in the web desktop. Check username and password.
|
/**
|
||||||
|
* Start a session in the web desktop. Check username and password.
|
||||||
* <b>Note : </b>If the user entered a bas password, the failure will be logged
|
* <b>Note : </b>If the user entered a bas password, the failure will be logged
|
||||||
* and told to the corresponding user on next successfull login.
|
* and told to the corresponding user on next successfull login.
|
||||||
* @param $username string Username that want to get connected.
|
* @param $username string Username that want to get connected.
|
||||||
|
@ -96,8 +85,7 @@ class m_mem {
|
||||||
function login($username, $password, $restrictip = 0, $authip_token = false) {
|
function login($username, $password, $restrictip = 0, $authip_token = false) {
|
||||||
global $db, $msg, $cuid, $authip;
|
global $db, $msg, $cuid, $authip;
|
||||||
$msg->log("mem", "login", $username);
|
$msg->log("mem", "login", $username);
|
||||||
// $username=addslashes($username);
|
|
||||||
// $password=addslashes($password);
|
|
||||||
$db->query("select * from membres where login= ? ;", array($username));
|
$db->query("select * from membres where login= ? ;", array($username));
|
||||||
if ($db->num_rows() == 0) {
|
if ($db->num_rows() == 0) {
|
||||||
$msg->raise("ERROR", "mem", _("User or password incorrect"));
|
$msg->raise("ERROR", "mem", _("User or password incorrect"));
|
||||||
|
@ -168,9 +156,9 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Start a session as another user from an administrator account.
|
/**
|
||||||
|
* Start a session as another user from an administrator account.
|
||||||
* This function is not the same as su. setid connect the current user in the destination
|
* This function is not the same as su. setid connect the current user in the destination
|
||||||
* account (for good), and su allow any user to become another account for some commands only.
|
* account (for good), and su allow any user to become another account for some commands only.
|
||||||
* (del_user, add_user ...) and allow to bring back admin rights with unsu
|
* (del_user, add_user ...) and allow to bring back admin rights with unsu
|
||||||
|
@ -208,9 +196,9 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Suite <EFBFBD> la connexion de l'utilisateur, r<EFBFBD>initialise ses param<EFBFBD>tres de derni<EFBFBD>re connexion
|
/**
|
||||||
|
* After a successful connection, reset the user's last connection date
|
||||||
*/
|
*/
|
||||||
function resetlast() {
|
function resetlast() {
|
||||||
global $db, $cuid;
|
global $db, $cuid;
|
||||||
|
@ -221,6 +209,7 @@ class m_mem {
|
||||||
$db->query("UPDATE membres SET lastlogin=NOW(), lastfail=0, lastip= ? WHERE uid= ?;", array($ip, $cuid));
|
$db->query("UPDATE membres SET lastlogin=NOW(), lastfail=0, lastip= ? WHERE uid= ?;", array($ip, $cuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function authip_token($bis = false) {
|
function authip_token($bis = false) {
|
||||||
global $db, $cuid;
|
global $db, $cuid;
|
||||||
$db->query("select pass from membres where uid= ?;", array($cuid));
|
$db->query("select pass from membres where uid= ?;", array($cuid));
|
||||||
|
@ -232,6 +221,7 @@ class m_mem {
|
||||||
return md5("$i--" . $db->f('pass'));
|
return md5("$i--" . $db->f('pass'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param boolean $t
|
* @param boolean $t
|
||||||
*/
|
*/
|
||||||
|
@ -251,16 +241,16 @@ class m_mem {
|
||||||
}
|
}
|
||||||
/* */
|
/* */
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Verifie que la session courante est correcte (cookie ok et ip valide).
|
/**
|
||||||
* Si besoin, et si reception des champs username & password, cree une nouvelle
|
* Check that the current session is correct (valid cookie)
|
||||||
* session pour l'utilisateur annonce.
|
* If necessary, and if we received username & password fields,
|
||||||
* Cette fonction doit etre appellee a chaque page devant etre authentifiee.
|
* create a new session for the user.
|
||||||
* et AVANT d'emettre des donnees. (un cookie peut etre envoye)
|
* This function MUST be called by each page to authenticate the user.
|
||||||
* @global string $session Le cookie de session eventuel
|
* and BEFORE sending any data (since a cookie can be sent)
|
||||||
* @global string $username/password le login/pass de l'utilisateur
|
* @global string $session the session cookie
|
||||||
* @return boolean TRUE si la session est correcte, FALSE sinon.
|
* @global string $username & $password the login / pass of the user
|
||||||
|
* @return boolean TRUE if the session is OK, FALSE if it is not.
|
||||||
*/
|
*/
|
||||||
function checkid($show_msg = true) {
|
function checkid($show_msg = true) {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
|
@ -273,12 +263,15 @@ class m_mem {
|
||||||
return $this->login($_REQUEST["username"], $_REQUEST["password"], (isset($_REQUEST["restrictip"]) ? $_REQUEST["restrictip"] : 0));
|
return $this->login($_REQUEST["username"], $_REQUEST["password"], (isset($_REQUEST["restrictip"]) ? $_REQUEST["restrictip"] : 0));
|
||||||
}
|
}
|
||||||
} // end isset
|
} // end isset
|
||||||
|
|
||||||
$_COOKIE["session"] = isset($_COOKIE["session"]) ? $_COOKIE["session"] : "";
|
$_COOKIE["session"] = isset($_COOKIE["session"]) ? $_COOKIE["session"] : "";
|
||||||
|
|
||||||
if (strlen($_COOKIE["session"]) != 32) {
|
if (strlen($_COOKIE["session"]) != 32) {
|
||||||
if ($show_msg)
|
if ($show_msg)
|
||||||
$msg->raise("ERROR", "mem", _("Identity lost or unknown, please login"));
|
$msg->raise("ERROR", "mem", _("Identity lost or unknown, please login"));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$ip = get_remote_ip();
|
$ip = get_remote_ip();
|
||||||
$db->query("select uid, ? as me,ip from sessions where sid= ?;", array($ip, $_COOKIE["session"]));
|
$db->query("select uid, ? as me,ip from sessions where sid= ?;", array($ip, $_COOKIE["session"]));
|
||||||
if ($db->num_rows() == 0) {
|
if ($db->num_rows() == 0) {
|
||||||
|
@ -298,7 +291,8 @@ class m_mem {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
$this->user = $db->Record;
|
$this->user = $db->Record;
|
||||||
$msg->init_msgs();
|
$msg->init_msgs();
|
||||||
/* Remplissage de $local */
|
|
||||||
|
/* Fills $local */
|
||||||
$db->query("SELECT * FROM local WHERE uid= ? ;", array($cuid));
|
$db->query("SELECT * FROM local WHERE uid= ? ;", array($cuid));
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$db->next_record();
|
$db->next_record();
|
||||||
|
@ -307,11 +301,11 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Change l'identite d'un utilisateur temporairement.
|
/**
|
||||||
* @global string $uid Utilisateur dont on prends l'identite
|
* Change the identity of the user temporarily (SUDO)
|
||||||
* @return TRUE si la session est correcte, FALSE sinon.
|
* @global string $uid User that we want to impersonate
|
||||||
|
* @return boolean TRUE if it's okay, FALSE if it's not.
|
||||||
*/
|
*/
|
||||||
function su($uid) {
|
function su($uid) {
|
||||||
global $cuid, $db, $msg, $mysql;
|
global $cuid, $db, $msg, $mysql;
|
||||||
|
@ -332,10 +326,10 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Retourne a l'identite d'origine de l'utilisateur apres su.
|
/**
|
||||||
* @return boolean TRUE si la session est correcte, FALSE sinon.
|
* Goes back to the original identity (of an admin, usually)
|
||||||
|
* @return boolean TRUE if it's okay, FALSE if it's not.
|
||||||
*/
|
*/
|
||||||
function unsu() {
|
function unsu() {
|
||||||
global $mysql;
|
global $mysql;
|
||||||
|
@ -349,10 +343,10 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Termine une session du bureau virtuel (logout)
|
/**
|
||||||
* @return boolean TRUE si la session a bien ete detruite, FALSE sinon.
|
* Ends a session on the panel (logout)
|
||||||
|
* @return boolean TRUE if it's okay, FALSE if it's not.
|
||||||
*/
|
*/
|
||||||
function del_session() {
|
function del_session() {
|
||||||
global $db, $user, $msg, $cuid, $hooks;
|
global $db, $user, $msg, $cuid, $hooks;
|
||||||
|
@ -382,14 +376,6 @@ class m_mem {
|
||||||
$db->query("delete from sessions where sid= ? ;", array($_COOKIE["session"]));
|
$db->query("delete from sessions where sid= ? ;", array($_COOKIE["session"]));
|
||||||
$msg->init_msgs();
|
$msg->init_msgs();
|
||||||
|
|
||||||
# Invoker le logout dans toutes les autres classes
|
|
||||||
/*
|
|
||||||
foreach($classes as $c) {
|
|
||||||
if (method_exists($GLOBALS[$c],"alternc_del_session")) {
|
|
||||||
$GLOBALS[$c]->alternc_del_session();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
$hooks->invoke("alternc_del_session");
|
$hooks->invoke("alternc_del_session");
|
||||||
|
|
||||||
session_unset();
|
session_unset();
|
||||||
|
@ -397,13 +383,13 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Change le mot de passe de l'utilisateur courant.
|
/**
|
||||||
* @param string $oldpass Ancien mot de passe.
|
* Change the password of the current user
|
||||||
* @param string $newpass Nouveau mot de passe
|
* @param string $oldpass Old password
|
||||||
* @param string $newpass2 Nouveau mot de passe (a nouveau)
|
* @param string $newpass New password
|
||||||
* @return boolean TRUE si le mot de passe a ete change, FALSE sinon.
|
* @param string $newpass2 New password (again)
|
||||||
|
* @return boolean TRUE if the password has been change, FALSE if not.
|
||||||
*/
|
*/
|
||||||
function passwd($oldpass, $newpass, $newpass2) {
|
function passwd($oldpass, $newpass, $newpass2) {
|
||||||
global $db, $msg, $cuid, $admin;
|
global $db, $msg, $cuid, $admin;
|
||||||
|
@ -432,11 +418,11 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Change les preferences administrateur d'un compte
|
/**
|
||||||
* @param integer $admlist Mode de visualisation des membres (0=large 1=courte)
|
* Change the administrator preferences of an admin account
|
||||||
* @return boolean TRUE si les preferences ont ete changees, FALSE sinon.
|
* @param integer $admlist visualisation mode of the account list (0=large 1=short)
|
||||||
|
* @return boolean TRUE if the preferences has been changed, FALSE if not.
|
||||||
*/
|
*/
|
||||||
function adminpref($admlist) {
|
function adminpref($admlist) {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
|
@ -450,13 +436,13 @@ class m_mem {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Envoie en mail le mot de passe d'un compte.
|
/**
|
||||||
* <b>Note : </b>On ne peut demander le mot de passe qu'une seule fois par jour.
|
* Send a mail with a password to an account
|
||||||
|
* <b>Note : </b>We can ask for a password only once a day
|
||||||
* TODO : Translate this mail into the localization program.
|
* TODO : Translate this mail into the localization program.
|
||||||
* TODO : Check this function's !
|
* TODO : Check this function's !
|
||||||
* @return boolean TRUE si le mot de passe a ete envoye avec succes, FALSE sinon.
|
* @return boolean TRUE if the password has been sent, FALSE if not.
|
||||||
*/
|
*/
|
||||||
function send_pass($login) {
|
function send_pass($login) {
|
||||||
global $msg, $db, $L_HOSTING, $L_FQDN;
|
global $msg, $db, $L_HOSTING, $L_FQDN;
|
||||||
|
@ -495,12 +481,12 @@ Cordially.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Change le mail d'un membre (premiere etape, envoi du CookiE)
|
/**
|
||||||
|
* Change the email of an account (first step: sending of a Cookie)
|
||||||
* TODO : insert this mail string into the localization system
|
* TODO : insert this mail string into the localization system
|
||||||
* @param string $newmail Nouveau mail souhaite pour le membre.
|
* @param string $newmail New mail we want to set for this account
|
||||||
* @return string le cookie si le mail a bien ete envoye, FALSE sinon
|
* @return boolean TRUE if the email with a link has been sent, FALSE if not
|
||||||
*/
|
*/
|
||||||
function ChangeMail1($newmail) {
|
function ChangeMail1($newmail) {
|
||||||
global $msg, $db, $L_HOSTING, $L_FQDN, $cuid;
|
global $msg, $db, $L_HOSTING, $L_FQDN, $cuid;
|
||||||
|
@ -537,22 +523,22 @@ again, please contact your server's administrator.
|
||||||
Cordially.
|
Cordially.
|
||||||
"), $db->f("login"), $L_HOSTING, $link);
|
"), $db->f("login"), $L_HOSTING, $link);
|
||||||
mail($newmail, "Email modification request on $L_HOSTING", $txt, "From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN");
|
mail($newmail, "Email modification request on $L_HOSTING", $txt, "From: postmaster@$L_FQDN\nReply-to: postmaster@$L_FQDN");
|
||||||
// Supprime les demandes pr<70>c<EFBFBD>dentes de ce compte !
|
|
||||||
$db->query("DELETE FROM chgmail WHERE uid= ? ;", array($cuid));
|
$db->query("DELETE FROM chgmail WHERE uid= ? ;", array($cuid));
|
||||||
$db->query("INSERT INTO chgmail (cookie,ckey,uid,mail,ts) VALUES ( ?, ?, ?, ?, ?);", array($COOKIE, $KEY, $cuid, $newmail, time()));
|
$db->query("INSERT INTO chgmail (cookie,ckey,uid,mail,ts) VALUES ( ?, ?, ?, ?, ?);", array($COOKIE, $KEY, $cuid, $newmail, time()));
|
||||||
// Supprime les cookies de la veille :)
|
|
||||||
$lts = time() - 86400;
|
$lts = time() - 86400;
|
||||||
$db->query("DELETE FROM chgmail WHERE ts< ? ;", array($lts));
|
$db->query("DELETE FROM chgmail WHERE ts< ? ;", array($lts));
|
||||||
return $KEY;
|
return $KEY;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Change le mail d'un membre (seconde etape, CookiE+cle = application)
|
/**
|
||||||
* @param string $COOKIE Cookie envoye par mail
|
* Change the email of a member (second step, Cookie + key change)
|
||||||
* @param string $KEY cle affichee a l'ecran
|
* @param string $COOKIE Cookie sent by mail
|
||||||
* @param integer $uid Utilisateur concerne (on est hors session)
|
* @param string $KEY cle shown on the screen
|
||||||
* @return boolean TRUE si le mail a bien ete modifie, FALSE sinon
|
* @param integer $uid User id (we may not be connected)
|
||||||
|
* @return boolean TRUE if the email has been changed, FALSE if not.
|
||||||
*/
|
*/
|
||||||
function ChangeMail2($COOKIE, $KEY, $uid) {
|
function ChangeMail2($COOKIE, $KEY, $uid) {
|
||||||
global $msg, $db;
|
global $msg, $db;
|
||||||
|
@ -574,10 +560,10 @@ Cordially.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Modifie le parametre d'aide en ligne (1/0)
|
/**
|
||||||
* @param integer $show Faut-il (1) ou non (0) afficher l'aide en ligne
|
* Change the help parameter
|
||||||
|
* @param integer $show Shall we (1) or not (0) show the online help
|
||||||
*/
|
*/
|
||||||
function set_help_param($show) {
|
function set_help_param($show) {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
|
@ -585,20 +571,20 @@ Cordially.
|
||||||
$db->query("UPDATE membres SET show_help= ? WHERE uid= ? ;", array($show, $cuid));
|
$db->query("UPDATE membres SET show_help= ? WHERE uid= ? ;", array($show, $cuid));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Dit si l'aide en ligne est demandee
|
/**
|
||||||
* @return boolean TRUE si l'aide en ligne est demandee, FALSE sinon.
|
* tell if the help parameter is set
|
||||||
|
* @return boolean TRUE if the account want online help, FALSE if not.
|
||||||
*/
|
*/
|
||||||
function get_help_param() {
|
function get_help_param() {
|
||||||
return $this->user["show_help"];
|
return $this->user["show_help"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Affiche (echo) l'aide contextuelle
|
/**
|
||||||
* @param integer $file Numero de fichier d'aide a afficher.
|
* show (echo) a contextual help
|
||||||
* @return boolean TRUE si l'aide contextuelle a ete trouvee, FALSE sinon
|
* @param integer $file File number in the help system to show
|
||||||
|
* @return boolean TRUE if the help has been shown, FALSE if not.
|
||||||
*/
|
*/
|
||||||
function show_help($file, $force = false) {
|
function show_help($file, $force = false) {
|
||||||
if ($this->user["show_help"] || $force) {
|
if ($this->user["show_help"] || $force) {
|
||||||
|
@ -615,6 +601,7 @@ Cordially.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param integer $uid
|
* @param integer $uid
|
||||||
*/
|
*/
|
||||||
|
@ -628,7 +615,6 @@ Cordially.
|
||||||
return intval($db->f('creator'));
|
return intval($db->f('creator'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exports all the personal user related information for an account.
|
* Exports all the personal user related information for an account.
|
||||||
|
@ -689,6 +675,4 @@ Cordially.
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* Class m_mem */
|
||||||
|
|
||||||
/* Classe Membre */
|
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,25 +16,19 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage hook system.
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class manage menu.
|
* This class manage the left menu of AlternC
|
||||||
*
|
*
|
||||||
* @copyright AlternC-Team 2002-2005 http://alternc.org/
|
* @copyright AlternC-Team 2002-2005 http://alternc.org/
|
||||||
*/
|
*/
|
||||||
class m_menu {
|
class m_menu {
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Constructor
|
/**
|
||||||
* menu([$mid]) Constructeur de la classe menu, ne fait rien pour le moment
|
* get all menus to display,
|
||||||
|
* uses hooks
|
||||||
*/
|
*/
|
||||||
function m_menu() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function getmenu() {
|
function getmenu() {
|
||||||
global $hooks, $quota, $mem;
|
global $hooks, $quota, $mem;
|
||||||
|
|
||||||
|
@ -102,13 +92,17 @@ class m_menu {
|
||||||
return $lst;
|
return $lst;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* utilitary function used by usort() to order menus
|
||||||
|
*/
|
||||||
function order_menu($a, $b) {
|
function order_menu($a, $b) {
|
||||||
// Use to order the menu with a usort
|
|
||||||
return $a['pos'] > $b['pos'];
|
return $a['pos'] > $b['pos'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* some menus that don't have an attached class
|
||||||
|
*/
|
||||||
function system_menu() {
|
function system_menu() {
|
||||||
// Here some needed menu who don't have a class
|
|
||||||
global $help_baseurl, $lang_translation, $locales;
|
global $help_baseurl, $lang_translation, $locales;
|
||||||
|
|
||||||
$m = array(
|
$m = array(
|
||||||
|
@ -150,6 +144,4 @@ class m_menu {
|
||||||
return $m;
|
return $m;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* Class m_menu */
|
||||||
|
|
||||||
/* Class menu */
|
|
||||||
|
|
|
@ -52,6 +52,7 @@ class m_messages {
|
||||||
$this->init_msgs();
|
$this->init_msgs();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Record a message, insert it into the logfile.
|
* Record a message, insert it into the logfile.
|
||||||
*
|
*
|
||||||
|
@ -83,6 +84,7 @@ class m_messages {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset the stored messages array
|
* Reset the stored messages array
|
||||||
*/
|
*/
|
||||||
|
@ -92,6 +94,7 @@ class m_messages {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tell if there are stored messages for a specific level
|
* Tell if there are stored messages for a specific level
|
||||||
* or for all levels (if level is empty)
|
* 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
|
* Return a string of concateneted messages of all recorded messages
|
||||||
* or only the last message
|
* or only the last message
|
||||||
|
@ -162,6 +166,7 @@ class m_messages {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a message in HTML form with associated CSS
|
* Return a message in HTML form with associated CSS
|
||||||
*
|
*
|
||||||
|
@ -186,6 +191,7 @@ class m_messages {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return all the messages of all levels in HTML form with associated CSS
|
* Return all the messages of all levels in HTML form with associated CSS
|
||||||
*
|
*
|
||||||
|
@ -207,6 +213,7 @@ class m_messages {
|
||||||
return $msg;
|
return $msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Log a message into /var/log/alternc/bureau.log
|
* 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
|
* Log an API function call into /var/log/alternc/bureau.log
|
||||||
*
|
*
|
||||||
|
@ -255,6 +263,4 @@ class m_messages {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* Class m_messages */
|
||||||
|
|
||||||
/* Class m_messages */
|
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id: m_mysql.php,v 1.35 2005/12/18 09:51:32 benjamin Exp $
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2002 by the AlternC Development Team.
|
|
||||||
http://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Based on:
|
|
||||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -24,16 +16,13 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Original Author of file: Benjamin Sonntag
|
*/
|
||||||
Purpose of file: Manage mysql database for users.
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* MySQL user database management for AlternC.
|
* MySQL user database management for AlternC.
|
||||||
* This class manage user's databases in MySQL, and user's MySQL accounts.
|
* This class manage user's databases in MySQL, and user's MySQL accounts.
|
||||||
*
|
*
|
||||||
* @copyright AlternC-Team 2002-2005 http://alternc.org/
|
* @copyright AlternC-Team 2000-2017 https://alternc.com/
|
||||||
*/
|
*/
|
||||||
class DB_users extends DB_Sql {
|
class DB_users extends DB_Sql {
|
||||||
|
|
||||||
|
@ -42,7 +31,8 @@ class DB_users extends DB_Sql {
|
||||||
/**
|
/**
|
||||||
* Creator
|
* Creator
|
||||||
*/
|
*/
|
||||||
function __construct() { // Sometimes we need to create this object with empty parameters, but by default we fill them with those of the current user's DB
|
function __construct() {
|
||||||
|
// Sometimes we need to create this object with empty parameters, but by default we fill them with those of the current user's DB
|
||||||
global $cuid, $db, $msg;
|
global $cuid, $db, $msg;
|
||||||
|
|
||||||
$db->query("select db_servers.* from db_servers, membres where membres.uid= ? and membres.db_server_id=db_servers.id;", array($cuid));
|
$db->query("select db_servers.* from db_servers, membres where membres.uid= ? and membres.db_server_id=db_servers.id;", array($cuid));
|
||||||
|
@ -51,7 +41,7 @@ class DB_users extends DB_Sql {
|
||||||
die();
|
die();
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create the object
|
// Create the object
|
||||||
$this->HumanHostname = $db->f('name');
|
$this->HumanHostname = $db->f('name');
|
||||||
$this->Host = $db->f('host');
|
$this->Host = $db->f('host');
|
||||||
$this->User = $db->f('login');
|
$this->User = $db->f('login');
|
||||||
|
@ -69,12 +59,12 @@ class m_mysql {
|
||||||
|
|
||||||
var $dbus;
|
var $dbus;
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Constructor
|
/**
|
||||||
|
* Constructor
|
||||||
* m_mysql([$mid]) Constructeur de la classe m_mysql, initialise le membre concerne
|
* m_mysql([$mid]) Constructeur de la classe m_mysql, initialise le membre concerne
|
||||||
*/
|
*/
|
||||||
function m_mysql() {
|
function __construct() {
|
||||||
global $cuid;
|
global $cuid;
|
||||||
if (!empty($cuid)) {
|
if (!empty($cuid)) {
|
||||||
$this->dbus = new DB_users();
|
$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');
|
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() {
|
function reload_dbus() {
|
||||||
$this->dbus = new DB_users();
|
$this->dbus = new DB_users();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function list_db_servers() {
|
function list_db_servers() {
|
||||||
global $db;
|
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;");
|
$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;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $quota;
|
global $quota;
|
||||||
$q = $quota->getquota("mysql");
|
$q = $quota->getquota("mysql");
|
||||||
|
@ -126,7 +119,6 @@ class m_mysql {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Password kind used in this class (hook for admin class)
|
* Password kind used in this class (hook for admin class)
|
||||||
|
@ -135,9 +127,9 @@ class m_mysql {
|
||||||
return array("mysql" => "MySQL users");
|
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 : <br>
|
* @return array returns an associative array as follow : <br>
|
||||||
* "db" => database name "bck" => backup mode for this db
|
* "db" => database name "bck" => backup mode for this db
|
||||||
* "dir" => Backup folder.
|
* "dir" => Backup folder.
|
||||||
|
@ -156,9 +148,9 @@ class m_mysql {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Get the login and password of the special user able to connect to phpmyadmin
|
/**
|
||||||
|
* Get the login and password of the special user able to connect to phpmyadmin
|
||||||
* @return array returns an associative array with login and password
|
* @return array returns an associative array with login and password
|
||||||
* Returns FALSE if error
|
* Returns FALSE if error
|
||||||
*/
|
*/
|
||||||
|
@ -179,9 +171,9 @@ class m_mysql {
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Returns the details of a user's database.
|
/**
|
||||||
|
* Returns the details of a user's database.
|
||||||
* $dbn is the name of the database (after the _) or nothing for the database "$user"
|
* $dbn is the name of the database (after the _) or nothing for the database "$user"
|
||||||
* @return string returns an associative array as follow :
|
* @return string returns an associative array as follow :
|
||||||
* "db" => Name of the database
|
* "db" => Name of the database
|
||||||
|
@ -216,9 +208,9 @@ class m_mysql {
|
||||||
return array("enabled" => true, "login" => $db->f("login"), "db" => $db->f("db"), "name" => $dbn, "bck" => $db->f("bck_mode"), "dir" => substr($db->f("bck_dir"), strlen($root)), "size" => $size, "pass" => $db->f("pass"), "history" => $db->f("bck_history"), "gzip" => $db->f("bck_gzip"));
|
return array("enabled" => true, "login" => $db->f("login"), "db" => $db->f("db"), "name" => $dbn, "bck" => $db->f("bck_mode"), "dir" => substr($db->f("bck_dir"), strlen($root)), "size" => $size, "pass" => $db->f("pass"), "history" => $db->f("bck_history"), "gzip" => $db->f("bck_gzip"));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Create a new database for the current user.
|
/**
|
||||||
|
* Create a new database for the current user.
|
||||||
* @param $dbn string Database name ($user_$dbn is the mysql db name)
|
* @param $dbn string Database name ($user_$dbn is the mysql db name)
|
||||||
* @return boolean if the database $user_$db has been successfully created, or FALSE if
|
* @return boolean if the database $user_$db has been successfully created, or FALSE if
|
||||||
* an error occured, such as over quota user.
|
* an error occured, such as over quota user.
|
||||||
|
@ -310,9 +302,9 @@ class m_mysql {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Delete a database for the current user.
|
/**
|
||||||
|
* Delete a database for the current user.
|
||||||
* @param $dbname string Name of the database to delete. The db name is $user_$dbn
|
* @param $dbname string Name of the database to delete. The db name is $user_$dbn
|
||||||
* @return boolean if the database $user_$db has been successfully deleted, or FALSE if
|
* @return boolean if the database $user_$db has been successfully deleted, or FALSE if
|
||||||
* an error occured, such as db does not exist.
|
* an error occured, such as db does not exist.
|
||||||
|
@ -343,9 +335,9 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Set the backup parameters for the database $db
|
/**
|
||||||
|
* Set the backup parameters for the database $db
|
||||||
* @param $dbn string database name
|
* @param $dbn string database name
|
||||||
* @param $bck_mode integer Backup mode (0 = none 1 = daily 2 = weekly)
|
* @param $bck_mode integer Backup mode (0 = none 1 = daily 2 = weekly)
|
||||||
* @param $bck_history integer How many backup should we keep ?
|
* @param $bck_history integer How many backup should we keep ?
|
||||||
|
@ -402,9 +394,9 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* --------------------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Change the password of the user in MySQL
|
/**
|
||||||
|
* Change the password of the user in MySQL
|
||||||
* @param $password string new password (cleartext)
|
* @param $password string new password (cleartext)
|
||||||
* @return boolean TRUE if the password has been successfully changed, FALSE else.
|
* @return boolean TRUE if the password has been successfully changed, FALSE else.
|
||||||
*/
|
*/
|
||||||
|
@ -443,6 +435,7 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function used to grant SQL rights to users:
|
* Function used to grant SQL rights to users:
|
||||||
* @base :database
|
* @base :database
|
||||||
|
@ -496,9 +489,9 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Restore a sql database.
|
/**
|
||||||
|
* Restore a sql database.
|
||||||
* @param $file string The filename, relative to the user root dir, which contains a sql dump
|
* @param $file string The filename, relative to the user root dir, which contains a sql dump
|
||||||
* @param $stdout boolean shall-we dump the error to stdout ?
|
* @param $stdout boolean shall-we dump the error to stdout ?
|
||||||
* @param $id integer The ID of the database to dump to.
|
* @param $id integer The ID of the database to dump to.
|
||||||
|
@ -546,9 +539,9 @@ class m_mysql {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Get the size of a database
|
/**
|
||||||
|
* Get the size of a database
|
||||||
* @param $dbname name of the database
|
* @param $dbname name of the database
|
||||||
* @return integer database size
|
* @return integer database size
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -565,11 +558,10 @@ class m_mysql {
|
||||||
return $size;
|
return $size;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the list of database users of an account
|
* Returns the list of database users of an account
|
||||||
* */
|
*/
|
||||||
function get_userslist($all = null) {
|
function get_userslist($all = null) {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$msg->log("mysql", "get_userslist");
|
$msg->log("mysql", "get_userslist");
|
||||||
|
@ -592,6 +584,7 @@ class m_mysql {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_defaultsparam($dbn) {
|
function get_defaultsparam($dbn) {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$msg->log("mysql", "getdefaults");
|
$msg->log("mysql", "getdefaults");
|
||||||
|
@ -645,7 +638,6 @@ class m_mysql {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new user in MySQL rights tables
|
* Create a new user in MySQL rights tables
|
||||||
|
@ -653,7 +645,7 @@ class m_mysql {
|
||||||
* @param string $password The password for this username
|
* @param string $password The password for this username
|
||||||
* @param string $passconf The password confirmation
|
* @param string $passconf The password confirmation
|
||||||
* @return boolean if the user has been created in MySQL or FALSE if an error occurred
|
* @return boolean if the user has been created in MySQL or FALSE if an error occurred
|
||||||
* */
|
*/
|
||||||
function add_user($usern, $password, $passconf) {
|
function add_user($usern, $password, $passconf) {
|
||||||
global $db, $msg, $mem, $cuid, $admin;
|
global $db, $msg, $mem, $cuid, $admin;
|
||||||
$msg->log("mysql", "add_user", $usern);
|
$msg->log("mysql", "add_user", $usern);
|
||||||
|
@ -708,7 +700,6 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Change a user's MySQL password
|
* Change a user's MySQL password
|
||||||
|
@ -716,7 +707,7 @@ class m_mysql {
|
||||||
* @param $password The password for this username
|
* @param $password The password for this username
|
||||||
* @param $passconf The password confirmation
|
* @param $passconf The password confirmation
|
||||||
* @return boolean if the password has been changed in MySQL or FALSE if an error occurred
|
* @return boolean if the password has been changed in MySQL or FALSE if an error occurred
|
||||||
* */
|
*/
|
||||||
function change_user_password($usern, $password, $passconf) {
|
function change_user_password($usern, $password, $passconf) {
|
||||||
global $db, $msg, $cuid, $admin;
|
global $db, $msg, $cuid, $admin;
|
||||||
$msg->log("mysql", "change_user_pass", $usern);
|
$msg->log("mysql", "change_user_pass", $usern);
|
||||||
|
@ -738,14 +729,13 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Delete a user in MySQL rights tables
|
* Delete a user in MySQL rights tables
|
||||||
* @param $user the username (we will add "[alternc-account]_" to it) to delete
|
* @param $user the username (we will add "[alternc-account]_" to it) to delete
|
||||||
* @param integer $all
|
* @param integer $all
|
||||||
* @return boolean if the user has been deleted in MySQL or FALSE if an error occurred
|
* @return boolean if the user has been deleted in MySQL or FALSE if an error occurred
|
||||||
* */
|
*/
|
||||||
function del_user($user, $all = false, $caller_is_deldb = false) {
|
function del_user($user, $all = false, $caller_is_deldb = false) {
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$msg->log("mysql", "del_user", $user);
|
$msg->log("mysql", "del_user", $user);
|
||||||
|
@ -782,13 +772,12 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the list of the database rights of user $user
|
* Return the list of the database rights of user $user
|
||||||
* @param $user the username
|
* @param $user the username
|
||||||
* @return array An array of database name and rights
|
* @return array An array of database name and rights
|
||||||
* */
|
*/
|
||||||
function get_user_dblist($user) {
|
function get_user_dblist($user) {
|
||||||
global $db, $msg;
|
global $db, $msg;
|
||||||
|
|
||||||
|
@ -821,7 +810,6 @@ class m_mysql {
|
||||||
return $r;
|
return $r;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ------------------------------------------------------------ */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set the access rights of user $user to database $dbn to be rights $rights
|
* Set the access rights of user $user to database $dbn to be rights $rights
|
||||||
|
@ -829,13 +817,12 @@ class m_mysql {
|
||||||
* @param $dbn The database to give rights to
|
* @param $dbn The database to give rights to
|
||||||
* @param $rights The rights as an array of MySQL keywords (insert, select ...)
|
* @param $rights The rights as an array of MySQL keywords (insert, select ...)
|
||||||
* @return boolean TRUE if the rights has been applied or FALSE if an error occurred
|
* @return boolean TRUE if the rights has been applied or FALSE if an error occurred
|
||||||
*
|
*/
|
||||||
* */
|
|
||||||
function set_user_rights($user, $dbn, $rights) {
|
function set_user_rights($user, $dbn, $rights) {
|
||||||
global $msg;
|
global $msg;
|
||||||
$msg->log("mysql", "set_user_rights");
|
$msg->log("mysql", "set_user_rights");
|
||||||
|
|
||||||
// On genere les droits en fonction du tableau de droits
|
// We generate the rights array depending on the rights list:
|
||||||
$strrights = "";
|
$strrights = "";
|
||||||
for ($i = 0; $i < count($rights); $i++) {
|
for ($i = 0; $i < count($rights); $i++) {
|
||||||
switch ($rights[$i]) {
|
switch ($rights[$i]) {
|
||||||
|
@ -911,13 +898,16 @@ class m_mysql {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* list of all possible SQL rights
|
||||||
|
*/
|
||||||
function available_sql_rights() {
|
function available_sql_rights() {
|
||||||
return Array('select', 'insert', 'update', 'delete', 'create', 'drop', 'references', 'index', 'alter', 'create_tmp', 'lock', 'create_view', 'show_view', 'create_routine', 'alter_routine', 'execute', 'event', 'trigger');
|
return Array('select', 'insert', 'update', 'delete', 'create', 'drop', 'references', 'index', 'alter', 'create_tmp', 'lock', 'create_view', 'show_view', 'create_routine', 'alter_routine', 'execute', 'event', 'trigger');
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook function called by the lxc class to set mysql_host and port
|
/**
|
||||||
|
* Hook function called by the lxc class to set mysql_host and port
|
||||||
* parameters
|
* parameters
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -932,9 +922,9 @@ class m_mysql {
|
||||||
return $p;
|
return $p;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook function called by the quota class to compute user used quota
|
/**
|
||||||
|
* Hook function called by the quota class to compute user used quota
|
||||||
* 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
|
* @param $name string name of the quota
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
|
@ -952,16 +942,16 @@ class m_mysql {
|
||||||
return $q;
|
return $q;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook function called when a user is created.
|
/**
|
||||||
|
* Hook function called when a user is created.
|
||||||
* AlternC's standard function that create a member
|
* AlternC's standard function that create a member
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
function alternc_add_member() {
|
function alternc_add_member() {
|
||||||
global $db, $msg, $cuid, $mem;
|
global $db, $msg, $cuid, $mem;
|
||||||
$msg->log("mysql", "alternc_add_member");
|
$msg->log("mysql", "alternc_add_member");
|
||||||
//checking for the phpmyadmin user
|
// checking for the phpmyadmin user
|
||||||
$db->query("SELECT name,password FROM dbusers WHERE uid= ? AND Type='ADMIN';", array($cuid));
|
$db->query("SELECT name,password FROM dbusers WHERE uid= ? AND Type='ADMIN';", array($cuid));
|
||||||
if ($db->num_rows()) {
|
if ($db->num_rows()) {
|
||||||
$myadm = $db->f("name");
|
$myadm = $db->f("name");
|
||||||
|
@ -976,9 +966,9 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook function called when a user is deleted.
|
/**
|
||||||
|
* Hook function called when a user is deleted.
|
||||||
* AlternC's standard function that delete a member
|
* AlternC's standard function that delete a member
|
||||||
* @access private
|
* @access private
|
||||||
*/
|
*/
|
||||||
|
@ -1000,11 +990,11 @@ class m_mysql {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook function called when a user is logged out.
|
/**
|
||||||
|
* Hook function called when a user is logged out.
|
||||||
* We just remove the cookie created in admin/sql_admin.php
|
* We just remove the cookie created in admin/sql_admin.php
|
||||||
a @access private
|
* a @access private
|
||||||
*/
|
*/
|
||||||
function alternc_del_session() {
|
function alternc_del_session() {
|
||||||
$_SESSION['PMA_single_signon_user'] = '';
|
$_SESSION['PMA_single_signon_user'] = '';
|
||||||
|
@ -1012,15 +1002,14 @@ class m_mysql {
|
||||||
$_SESSION['PMA_single_signon_host'] = '';
|
$_SESSION['PMA_single_signon_host'] = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exporte all the mysql information of an account
|
* Exports all the mysql information of an account
|
||||||
* @access private
|
* @access private
|
||||||
* EXPERIMENTAL 'sid' function ;)
|
* EXPERIMENTAL 'sid' function ;)
|
||||||
*/
|
*/
|
||||||
function alternc_export_conf() {
|
function alternc_export_conf() {
|
||||||
//TODO don't work with separated sql server for dbusers
|
// TODO don't work with separated sql server for dbusers
|
||||||
global $db, $msg, $cuid;
|
global $db, $msg, $cuid;
|
||||||
$msg->log("mysql", "export");
|
$msg->log("mysql", "export");
|
||||||
$db->query("SELECT login, pass, db, bck_mode, bck_dir, bck_history, bck_gzip FROM db WHERE uid= ? ;", array($cuid));
|
$db->query("SELECT login, pass, db, bck_mode, bck_dir, bck_history, bck_gzip FROM db WHERE uid= ? ;", array($cuid));
|
||||||
|
@ -1045,10 +1034,9 @@ class m_mysql {
|
||||||
return $str;
|
return $str;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Exporte all the mysql databases a of give account to $dir directory
|
* Exports all the mysql databases a of give account to $dir directory
|
||||||
* @access private
|
* @access private
|
||||||
* EXPERIMENTAL 'sid' function ;)
|
* EXPERIMENTAL 'sid' function ;)
|
||||||
*/
|
*/
|
||||||
|
@ -1069,7 +1057,6 @@ class m_mysql {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the size of each databases in a SQL Host given in parameter
|
* Return the size of each databases in a SQL Host given in parameter
|
||||||
|
@ -1104,6 +1091,4 @@ class m_mysql {
|
||||||
return $res;
|
return $res;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
} /* Class m_mysql */
|
||||||
|
|
||||||
/* Class m_mysql */
|
|
||||||
|
|
|
@ -1,9 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -19,8 +16,6 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage piwik Statistics set
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -50,8 +45,9 @@ class m_piwik {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*---------------------------------------------------------------------------*/
|
|
||||||
/** Constructor
|
/**
|
||||||
|
* Constructor
|
||||||
*/
|
*/
|
||||||
function m_piwik() {
|
function m_piwik() {
|
||||||
$this->piwik_server_uri=variable_get('piwik_server_uri',null,'Remote Piwik server uri');
|
$this->piwik_server_uri=variable_get('piwik_server_uri',null,'Remote Piwik server uri');
|
||||||
|
@ -60,8 +56,9 @@ class m_piwik {
|
||||||
$this->alternc_sites = $this->get_alternc_sites();
|
$this->alternc_sites = $this->get_alternc_sites();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
/** hook called when an AlternC account is deleted
|
/**
|
||||||
|
* hook called when an AlternC account is deleted
|
||||||
*/
|
*/
|
||||||
function hook_admin_del_member() {
|
function hook_admin_del_member() {
|
||||||
//FIXME : implement the hook_admin_del_member for piwik
|
//FIXME : implement the hook_admin_del_member for piwik
|
||||||
|
@ -69,8 +66,8 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
/**
|
||||||
/** 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
|
* @param $name string name of the quota
|
||||||
* @return integer the number of service used or false if an error occured
|
* @return integer the number of service used or false if an error occured
|
||||||
* @access private
|
* @access private
|
||||||
|
@ -95,7 +92,6 @@ class m_piwik {
|
||||||
/* User-related tasks */
|
/* User-related tasks */
|
||||||
/***********************/
|
/***********************/
|
||||||
|
|
||||||
|
|
||||||
function user_add($user_login, $user_mail) {
|
function user_add($user_login, $user_mail) {
|
||||||
global $db, $mem, $cuid, $msg;
|
global $db, $mem, $cuid, $msg;
|
||||||
|
|
||||||
|
@ -133,9 +129,10 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Edite un user
|
/**
|
||||||
|
* Change a user @TODO: code this
|
||||||
|
*/
|
||||||
function user_edit() {
|
function user_edit() {
|
||||||
//FIXME
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +167,7 @@ class m_piwik {
|
||||||
else return FALSE;
|
else return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $user_login
|
* @param string $user_login
|
||||||
*/
|
*/
|
||||||
|
@ -182,6 +180,7 @@ class m_piwik {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_alternc_users() {
|
function get_alternc_users() {
|
||||||
global $db, $cuid, $msg;
|
global $db, $cuid, $msg;
|
||||||
|
|
||||||
|
@ -195,6 +194,7 @@ class m_piwik {
|
||||||
return $alternc_users;
|
return $alternc_users;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_users_url_infos() {
|
function get_users_url_infos() {
|
||||||
global $db,$cuid, $msg;
|
global $db,$cuid, $msg;
|
||||||
$infos_user = array();
|
$infos_user = array();
|
||||||
|
@ -221,6 +221,7 @@ class m_piwik {
|
||||||
return $infos_user;
|
return $infos_user;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* does this user has piwik websites configured in AlternC ?
|
* does this user has piwik websites configured in AlternC ?
|
||||||
*/
|
*/
|
||||||
|
@ -239,7 +240,9 @@ class m_piwik {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Delete a piwik user
|
|
||||||
|
/**
|
||||||
|
* Delete a piwik user
|
||||||
* don't delete it locally unless it has been remotely deleted.
|
* don't delete it locally unless it has been remotely deleted.
|
||||||
*/
|
*/
|
||||||
function user_delete($piwik_user_login) {
|
function user_delete($piwik_user_login) {
|
||||||
|
@ -301,13 +304,10 @@ class m_piwik {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***********************/
|
/***********************/
|
||||||
/* Site-related tasks */
|
/* Site-related tasks */
|
||||||
/***********************/
|
/***********************/
|
||||||
|
|
||||||
|
|
||||||
function site_list() {
|
function site_list() {
|
||||||
global $msg;
|
global $msg;
|
||||||
|
|
||||||
|
@ -343,10 +343,12 @@ class m_piwik {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function site_js_tag($site_id) {
|
function site_js_tag($site_id) {
|
||||||
return $this->call_privileged_page('API', 'SitesManager.getJavascriptTag', array('idSite' => $site_id, 'piwikUrl' => $this->piwik_server_uri))->value;
|
return $this->call_privileged_page('API', 'SitesManager.getJavascriptTag', array('idSite' => $site_id, 'piwikUrl' => $this->piwik_server_uri))->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_alternc_sites() {
|
function get_alternc_sites() {
|
||||||
global $db, $cuid, $msg;
|
global $db, $cuid, $msg;
|
||||||
|
|
||||||
|
@ -360,6 +362,7 @@ class m_piwik {
|
||||||
return $alternc_sites;
|
return $alternc_sites;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function get_site_list()
|
function get_site_list()
|
||||||
{
|
{
|
||||||
return $this->call_privileged_page('API', 'SitesManager.getAllSites');
|
return $this->call_privileged_page('API', 'SitesManager.getAllSites');
|
||||||
|
@ -437,6 +440,8 @@ class m_piwik {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Ajoute un alias sur un site existant
|
// Ajoute un alias sur un site existant
|
||||||
function site_alias_add() {
|
function site_alias_add() {
|
||||||
// FIXME
|
// FIXME
|
||||||
|
@ -444,8 +449,9 @@ class m_piwik {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
/* return a clean username with a unique prefix per account */
|
* return a clean username with a unique prefix per account
|
||||||
|
*/
|
||||||
function clean_user_name($username) {
|
function clean_user_name($username) {
|
||||||
global $admin, $cuid, $db;
|
global $admin, $cuid, $db;
|
||||||
$escaped_name=$db->quote(trim($username));
|
$escaped_name=$db->quote(trim($username));
|
||||||
|
|
|
@ -1,10 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2000-2012 by the AlternC Development Team.
|
|
||||||
https://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -20,9 +16,7 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Purpose of file: Manage user quota
|
*/
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class for hosting quotas management
|
* Class for hosting quotas management
|
||||||
|
@ -44,7 +38,6 @@ class m_quota {
|
||||||
var $quotas;
|
var $quotas;
|
||||||
var $clquota; // Which class manage which quota.
|
var $clquota; // Which class manage which quota.
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
|
@ -58,10 +51,12 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private function dummy_for_translation() {
|
private function dummy_for_translation() {
|
||||||
_("quota_web");
|
_("quota_web");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function hook_menu() {
|
function hook_menu() {
|
||||||
global $cuid, $mem, $quota;
|
global $cuid, $mem, $quota;
|
||||||
|
|
||||||
|
@ -93,6 +88,7 @@ class m_quota {
|
||||||
return $obj;
|
return $obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function hook_homepageblock() {
|
function hook_homepageblock() {
|
||||||
return (object)Array(
|
return (object)Array(
|
||||||
'pos' => 20,
|
'pos' => 20,
|
||||||
|
@ -103,7 +99,6 @@ class m_quota {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Check if a user can use a ressource.
|
/** Check if a user can use a ressource.
|
||||||
* @param string $ressource the ressource name (a named quota)
|
* @param string $ressource the ressource name (a named quota)
|
||||||
|
@ -115,7 +110,6 @@ class m_quota {
|
||||||
return $t["u"] < $t["t"];
|
return $t["u"] < $t["t"];
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** List the quota-managed services in the server
|
/** List the quota-managed services in the server
|
||||||
* @Return array the quota names and description (translated)
|
* @Return array the quota names and description (translated)
|
||||||
|
@ -135,6 +129,7 @@ class m_quota {
|
||||||
return $qlist;
|
return $qlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Synchronise the quotas of the users with the quota of the
|
* Synchronise the quotas of the users with the quota of the
|
||||||
* user's profile.
|
* user's profile.
|
||||||
|
@ -152,12 +147,11 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create default quota in the profile
|
* Create default quota in the profile
|
||||||
* when a new quota appear
|
* when a new quota appear
|
||||||
*
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function create_missing_quota_profile() {
|
function create_missing_quota_profile() {
|
||||||
global $db, $quota, $msg;
|
global $db, $quota, $msg;
|
||||||
$msg->log("quota", "create_missing_quota_profile");
|
$msg->log("quota", "create_missing_quota_profile");
|
||||||
|
@ -171,7 +165,6 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Return a ressource usage (u) and total quota (t)
|
/** Return a ressource usage (u) and total quota (t)
|
||||||
* @param string $ressource ressource to get quota of
|
* @param string $ressource ressource to get quota of
|
||||||
|
@ -191,7 +184,7 @@ class m_quota {
|
||||||
$res = $hooks->invoke("hook_quota_get");
|
$res = $hooks->invoke("hook_quota_get");
|
||||||
foreach ($res as $r) {
|
foreach ($res as $r) {
|
||||||
$this->quotas[$r['name']] = $r;
|
$this->quotas[$r['name']] = $r;
|
||||||
$this->quotas[$r['name']]['u'] = $r['used']; // retrocompatibilité
|
$this->quotas[$r['name']]['u'] = $r['used']; // retrocompatibility
|
||||||
if (isset($r['sizeondisk']))
|
if (isset($r['sizeondisk']))
|
||||||
$this->quotas[$r['name']]['s'] = $r['sizeondisk'];
|
$this->quotas[$r['name']]['s'] = $r['sizeondisk'];
|
||||||
$this->quotas[$r['name']]['t'] = 0; // Default quota = 0
|
$this->quotas[$r['name']]['t'] = 0; // Default quota = 0
|
||||||
|
@ -247,7 +240,6 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Set the quota for a user (and for a ressource)
|
/** Set the quota for a user (and for a ressource)
|
||||||
* @param string $ressource ressource to set quota of
|
* @param string $ressource ressource to set quota of
|
||||||
|
@ -280,7 +272,6 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Erase all quota information about the user.
|
* Erase all quota information about the user.
|
||||||
|
@ -292,9 +283,9 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Get the default quotas as an associative array
|
/**
|
||||||
|
* Get the default quotas as an associative array
|
||||||
* @return array the array of the default quotas
|
* @return array the array of the default quotas
|
||||||
*/
|
*/
|
||||||
function getdefaults() {
|
function getdefaults() {
|
||||||
|
@ -313,9 +304,9 @@ class m_quota {
|
||||||
return $c;
|
return $c;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Set the default quotas
|
/**
|
||||||
|
* Set the default quotas
|
||||||
* @param array associative array of quota (key=>val)
|
* @param array associative array of quota (key=>val)
|
||||||
*/
|
*/
|
||||||
function setdefaults($newq) {
|
function setdefaults($newq) {
|
||||||
|
@ -334,9 +325,9 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Add an account type for quotas
|
/**
|
||||||
|
* Add an account type for quotas
|
||||||
* @param string $type account type to be added
|
* @param string $type account type to be added
|
||||||
* @return boolean true if all went ok
|
* @return boolean true if all went ok
|
||||||
*/
|
*/
|
||||||
|
@ -359,9 +350,9 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** List for quotas
|
/**
|
||||||
|
* List types of quotas
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function listtype() {
|
function listtype() {
|
||||||
|
@ -374,7 +365,6 @@ class m_quota {
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Delete an account type for quotas
|
/** Delete an account type for quotas
|
||||||
* @param string $type account type to be deleted
|
* @param string $type account type to be deleted
|
||||||
|
@ -391,7 +381,6 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Create default quotas entries for a new user.
|
/** Create default quotas entries for a new user.
|
||||||
* The user we are talking about is in the global $cuid.
|
* The user we are talking about is in the global $cuid.
|
||||||
|
@ -418,7 +407,6 @@ class m_quota {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Return a quota value with its unit (when it is a space quota)
|
/** Return a quota value with its unit (when it is a space quota)
|
||||||
* in MB, GB, TB ...
|
* in MB, GB, TB ...
|
||||||
|
@ -437,8 +425,8 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get size_xx function (filled by spoolsize.php) */
|
|
||||||
|
|
||||||
|
/* get size_xx function (filled by spoolsize.php) */
|
||||||
function _get_sum_sql($sql) {
|
function _get_sum_sql($sql) {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
|
@ -451,6 +439,7 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _get_count_sql($sql) {
|
function _get_count_sql($sql) {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
|
@ -463,6 +452,7 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function _get_size_and_record_sql($sql) {
|
function _get_size_and_record_sql($sql) {
|
||||||
global $db;
|
global $db;
|
||||||
$db->query($sql);
|
$db->query($sql);
|
||||||
|
@ -477,129 +467,129 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get the quota from one user for a cat */
|
|
||||||
|
|
||||||
|
/* get the quota from one user for a cat */
|
||||||
function get_quota_user_cat($uid, $name) {
|
function get_quota_user_cat($uid, $name) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(total) AS sum FROM quotas WHERE uid='$uid' AND name='$name';");
|
return $this->_get_sum_sql("SELECT SUM(total) AS sum FROM quotas WHERE uid='$uid' AND name='$name';");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of websites sizes from all users */
|
|
||||||
|
|
||||||
|
/* sum of websites sizes from all users */
|
||||||
function get_size_web_sum_all() {
|
function get_size_web_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of websites sizes from one user */
|
|
||||||
|
|
||||||
|
/* sum of websites sizes from one user */
|
||||||
function get_size_web_sum_user($u) {
|
function get_size_web_sum_user($u) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_web WHERE uid='$u';");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailbox sizes from all domains */
|
|
||||||
|
|
||||||
|
/* sum of mailbox sizes from all domains */
|
||||||
function get_size_mail_sum_all() {
|
function get_size_mail_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(quota_dovecot) AS sum FROM dovecot_quota ;");
|
return $this->_get_sum_sql("SELECT SUM(quota_dovecot) AS sum FROM dovecot_quota ;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailbox sizes for one domain */
|
|
||||||
|
|
||||||
|
/* sum of mailbox sizes for one domain */
|
||||||
function get_size_mail_sum_domain($dom) {
|
function get_size_mail_sum_domain($dom) {
|
||||||
global $mail;
|
global $mail;
|
||||||
return $mail->get_total_size_for_domain($dom);
|
return $mail->get_total_size_for_domain($dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailbox size for ine user */
|
|
||||||
|
|
||||||
|
/* sum of mailbox size for ine user */
|
||||||
function get_size_mail_sum_user($u) {
|
function get_size_mail_sum_user($u) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(quota_dovecot) as sum FROM dovecot_quota WHERE user IN (SELECT CONCAT(a.address, '@', d.domaine) as mail FROM `address` as a INNER JOIN domaines as d ON a.domain_id = d.id WHERE d.compte = '$u' AND a.type ='')");
|
return $this->_get_sum_sql("SELECT SUM(quota_dovecot) as sum FROM dovecot_quota WHERE user IN (SELECT CONCAT(a.address, '@', d.domaine) as mail FROM `address` as a INNER JOIN domaines as d ON a.domain_id = d.id WHERE d.compte = '$u' AND a.type ='')");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailbox sizes from all domains */
|
|
||||||
|
|
||||||
|
/* count of mailbox sizes from all domains */
|
||||||
function get_size_mail_count_all() {
|
function get_size_mail_count_all() {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_quota;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_quota;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailbox for one domain */
|
|
||||||
|
|
||||||
|
/* count of mailbox for one domain */
|
||||||
function get_size_mail_count_domain($dom) {
|
function get_size_mail_count_domain($dom) {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_quota WHERE user LIKE '%@{$dom}'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM dovecot_quota WHERE user LIKE '%@{$dom}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get list of mailbox alias and size for one domain */
|
|
||||||
|
|
||||||
|
/* get list of mailbox alias and size for one domain */
|
||||||
function get_size_mail_details_domain($dom) {
|
function get_size_mail_details_domain($dom) {
|
||||||
return $this->_get_size_and_record_sql("SELECT user as alias,quota_dovecot as size FROM dovecot_quota WHERE user LIKE '%@{$dom}' ORDER BY alias;");
|
return $this->_get_size_and_record_sql("SELECT user as alias,quota_dovecot as size FROM dovecot_quota WHERE user LIKE '%@{$dom}' ORDER BY alias;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailman lists sizes from all domains */
|
|
||||||
|
|
||||||
|
/* sum of mailman lists sizes from all domains */
|
||||||
function get_size_mailman_sum_all() {
|
function get_size_mailman_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailman lists sizes for one domain */
|
|
||||||
|
|
||||||
|
/* sum of mailman lists sizes for one domain */
|
||||||
function get_size_mailman_sum_domain($dom) {
|
function get_size_mailman_sum_domain($dom) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman s INNER JOIN mailman m ON s.list = m.list AND s.uid = m.uid WHERE m.domain = '$dom'");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman s INNER JOIN mailman m ON s.list = m.list AND s.uid = m.uid WHERE m.domain = '$dom'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of mailman lists for one user */
|
|
||||||
|
|
||||||
|
/* sum of mailman lists for one user */
|
||||||
function get_size_mailman_sum_user($u) {
|
function get_size_mailman_sum_user($u) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE uid = '{$u}'");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_mailman WHERE uid = '{$u}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailman lists sizes from all domains */
|
|
||||||
|
|
||||||
|
/* count of mailman lists sizes from all domains */
|
||||||
function get_size_mailman_count_all() {
|
function get_size_mailman_count_all() {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of mailman lists for one user */
|
|
||||||
|
|
||||||
|
/* count of mailman lists for one user */
|
||||||
function get_size_mailman_count_user($u) {
|
function get_size_mailman_count_user($u) {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_mailman WHERE uid = '{$u}'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get list of mailman list and size for one user */
|
|
||||||
|
|
||||||
|
/* get list of mailman list and size for one user */
|
||||||
function get_size_mailman_details_user($u) {
|
function get_size_mailman_details_user($u) {
|
||||||
return $this->_get_size_and_record_sql("SELECT s.size,CONCAT(m.list,'@',m.domain) as list FROM size_mailman s LEFT JOIN mailman m ON s.list=m.name WHERE s.uid='{$u}' ORDER BY s.list ASC");
|
return $this->_get_size_and_record_sql("SELECT s.size,CONCAT(m.list,'@',m.domain) as list FROM size_mailman s LEFT JOIN mailman m ON s.list=m.name WHERE s.uid='{$u}' ORDER BY s.list ASC");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of databases sizes from all users */
|
|
||||||
|
|
||||||
|
/* sum of databases sizes from all users */
|
||||||
function get_size_db_sum_all() {
|
function get_size_db_sum_all() {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* sum of databases sizes for one user */
|
|
||||||
|
|
||||||
|
/* sum of databases sizes for one user */
|
||||||
function get_size_db_sum_user($u) {
|
function get_size_db_sum_user($u) {
|
||||||
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
return $this->_get_sum_sql("SELECT SUM(size) AS sum FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of databases from all users */
|
|
||||||
|
|
||||||
|
/* count of databases from all users */
|
||||||
function get_size_db_count_all() {
|
function get_size_db_count_all() {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db;");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* count of databases for one user */
|
|
||||||
|
|
||||||
|
/* count of databases for one user */
|
||||||
function get_size_db_count_user($u) {
|
function get_size_db_count_user($u) {
|
||||||
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
return $this->_get_count_sql("SELECT COUNT(*) AS count FROM size_db WHERE db = '{$u}' OR db LIKE '{$u}\_%'");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* get list of databases name and size for one user */
|
|
||||||
|
|
||||||
|
/* get list of databases name and size for one user */
|
||||||
function get_size_db_details_user($u) {
|
function get_size_db_details_user($u) {
|
||||||
return $this->_get_size_and_record_sql("SELECT db,size FROM size_db WHERE db='{$u}' OR db LIKE '{$u}\_%';");
|
return $this->_get_size_and_record_sql("SELECT db,size FROM size_db WHERE db='{$u}' OR db LIKE '{$u}\_%';");
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Return appropriate value and unit of a size given in Bytes (e.g. 1024 Bytes -> return 1 KB) */
|
|
||||||
|
|
||||||
|
/* Return appropriate value and unit of a size given in Bytes (e.g. 1024 Bytes -> return 1 KB) */
|
||||||
function get_size_unit($size) {
|
function get_size_unit($size) {
|
||||||
$units = array(1073741824 => _("GB"), 1048576 => _("MB"), 1024 => _("KB"), 0 => _("B"));
|
$units = array(1073741824 => _("GB"), 1048576 => _("MB"), 1024 => _("KB"), 0 => _("B"));
|
||||||
foreach ($units as $value => $unit) {
|
foreach ($units as $value => $unit) {
|
||||||
|
@ -610,11 +600,13 @@ class m_quota {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Affiche des barres de progression
|
/**
|
||||||
// color_type :
|
* show a progress-bar
|
||||||
// 0 = Pas de changement de couleur
|
* color_type :
|
||||||
// 1 = Progression du vert vers le rouge en fonction du porcentage
|
* 0 = No colo change
|
||||||
// 2 = Progression du rouge vers le vert en fonction du porcentage
|
* 1 = Progress from green to red depending on percentage
|
||||||
|
* 2 = Progress from red to green depending on percentage
|
||||||
|
*/
|
||||||
function quota_displaybar($usage, $color_type = 1) {
|
function quota_displaybar($usage, $color_type = 1) {
|
||||||
if ($color_type == 1) {
|
if ($color_type == 1) {
|
||||||
$csscolor = " background-color:" . PercentToColor($usage);
|
$csscolor = " background-color:" . PercentToColor($usage);
|
||||||
|
@ -624,16 +616,15 @@ class m_quota {
|
||||||
$csscolor = "";
|
$csscolor = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
echo '<div class="progress-bar">';
|
echo '<div class="progress-bar">';
|
||||||
echo '<div class="barre" style="width:' . $usage . '%;' . $csscolor . '" ></div>';
|
echo '<div class="barre" style="width:' . $usage . '%;' . $csscolor . '" ></div>';
|
||||||
echo '<div class="txt">' . $usage . '%</div>';
|
echo '<div class="txt">' . $usage . '%</div>';
|
||||||
echo '</div>';
|
echo '</div>';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* ==== Hook functions ==== */
|
/* ==== Hook functions ==== */
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook function call when a user is deleted
|
/** Hook function call when a user is deleted
|
||||||
* AlternC's standard function called when a user is deleted
|
* AlternC's standard function called when a user is deleted
|
||||||
|
@ -643,7 +634,6 @@ class m_quota {
|
||||||
$this->delquotas();
|
$this->delquotas();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Hook function called when a user is created
|
/** Hook function called when a user is created
|
||||||
* This function initialize the user's quotas.
|
* This function initialize the user's quotas.
|
||||||
|
@ -656,7 +646,6 @@ class m_quota {
|
||||||
$this->getquota('', true); // actualise quota
|
$this->getquota('', true); // actualise quota
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ----------------------------------------------------------------- */
|
|
||||||
|
|
||||||
/** Exports all the quota related information for an account.
|
/** Exports all the quota related information for an account.
|
||||||
* @access private
|
* @access private
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
$Id: mime.php,v 1.3 2004/06/03 14:32:20 anonymous Exp $
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2002 by the AlternC Development Team.
|
|
||||||
http://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Based on:
|
|
||||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -24,21 +16,10 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
Original Author of file: Benjamin Sonntag 23/12/2001
|
*/
|
||||||
Purpose of file: Brouteur php3 pour AlternC
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
Brouteur php3 pour AlternC (voir http://www.alternc.org)
|
|
||||||
|
|
||||||
Version 0.1
|
|
||||||
|
|
||||||
Notes :
|
|
||||||
Benjamin Sonntag 23/12/2001 Version initiale
|
|
||||||
|
|
||||||
Fichier :
|
|
||||||
mime.php3 : gestion de la liste des types mime des fichiers.
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Browser mime function to detect mime types and show icons or type names
|
||||||
*/
|
*/
|
||||||
if (!IsSet($MIME_H)) {
|
if (!IsSet($MIME_H)) {
|
||||||
$MIME_H = 1;
|
$MIME_H = 1;
|
||||||
|
|
|
@ -1,14 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* $Id: variables.php,v 1.8 2005/04/02 00:26:36 anarcat Exp $
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
AlternC - Web Hosting System
|
|
||||||
Copyright (C) 2002 by the AlternC Development Team.
|
|
||||||
http://alternc.org/
|
|
||||||
----------------------------------------------------------------------
|
|
||||||
Based on:
|
|
||||||
Valentin Lacambre's web hosting softwares: http://altern.org/
|
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
LICENSE
|
LICENSE
|
||||||
|
|
||||||
|
@ -24,7 +16,7 @@
|
||||||
|
|
||||||
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
To read the license please visit http://www.gnu.org/copyleft/gpl.html
|
||||||
----------------------------------------------------------------------
|
----------------------------------------------------------------------
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Persistent variable table
|
* Persistent variable table
|
||||||
|
@ -33,6 +25,7 @@
|
||||||
* @link http://cvs.drupal.org/viewcvs/drupal/drupal/includes/bootstrap.inc?rev=1.38&view=auto
|
* @link http://cvs.drupal.org/viewcvs/drupal/drupal/includes/bootstrap.inc?rev=1.38&view=auto
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the persistent variable table.
|
* Load the persistent variable table.
|
||||||
*
|
*
|
||||||
|
@ -59,6 +52,7 @@ function variable_init($conf = array()) {
|
||||||
return $variables;
|
return $variables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the global $conf array if necessary
|
* Initialize the global $conf array if necessary
|
||||||
*
|
*
|
||||||
|
@ -72,6 +66,7 @@ function variable_init_maybe() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return a persistent variable.
|
* Return a persistent variable.
|
||||||
*
|
*
|
||||||
|
@ -100,6 +95,7 @@ function variable_get($name, $default = null, $createit_comment = null) {
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set a persistent variable.
|
* Set a persistent variable.
|
||||||
*
|
*
|
||||||
|
@ -140,6 +136,7 @@ function variable_set($name, $value, $comment = null) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unset a persistent variable.
|
* Unset a persistent variable.
|
||||||
*
|
*
|
||||||
|
@ -152,6 +149,10 @@ function variable_del($name) {
|
||||||
unset($conf[$name]);
|
unset($conf[$name]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List all variables
|
||||||
|
*/
|
||||||
function variables_list() {
|
function variables_list() {
|
||||||
global $db;
|
global $db;
|
||||||
$t = array();
|
$t = array();
|
||||||
|
@ -161,3 +162,4 @@ function variables_list() {
|
||||||
}
|
}
|
||||||
return $t;
|
return $t;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue