ajout classe m_export + script export_account afin de générer un export de compte. Correction de bugs divers.
This commit is contained in:
parent
7c7f808972
commit
20103063b3
|
@ -316,6 +316,7 @@ bureau/class/m_authip.php -text
|
|||
bureau/class/m_bro.php -text
|
||||
bureau/class/m_dom.php -text
|
||||
bureau/class/m_err.php -text
|
||||
bureau/class/m_export.php -text
|
||||
bureau/class/m_ftp.php -text
|
||||
bureau/class/m_hooks.php -text
|
||||
bureau/class/m_hta.php -text
|
||||
|
@ -465,6 +466,7 @@ src/alternc-dboptimize -text
|
|||
src/alternc-passwd -text
|
||||
src/alternc_reload -text
|
||||
src/du.pl -text
|
||||
src/export_account.php -text
|
||||
src/fixperms.sh -text
|
||||
src/functions.sh -text
|
||||
src/functions_dns.sh -text
|
||||
|
|
|
@ -51,4 +51,4 @@ if ($submit) {
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -329,16 +329,17 @@ class m_bro {
|
|||
global $db,$cuid,$err;
|
||||
$file=ssla($file);
|
||||
$absolute=$this->convertabsolute($dir."/".$file,0);
|
||||
if ($absolute && !file_exists($absolute)) {
|
||||
if (!@mkdir($absolute,00777)) {
|
||||
$err->raise("bro",4);
|
||||
return false;
|
||||
}
|
||||
$db->query("UPDATE browser SET crff=1 WHERE uid='$cuid';");
|
||||
return true;
|
||||
echo "$absolute";
|
||||
if ($absolute && (!file_exists($absolute))) {
|
||||
if (!mkdir($absolute,00777)) {
|
||||
$err->raise("bro",4);
|
||||
return false;
|
||||
}
|
||||
$db->query("UPDATE browser SET crff=1 WHERE uid='$cuid';");
|
||||
return true;
|
||||
} else {
|
||||
$err->raise("bro",1);
|
||||
return false;
|
||||
$err->raise("bro",1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -357,6 +358,7 @@ class m_bro {
|
|||
$err->raise("bro",1);
|
||||
return false;
|
||||
}
|
||||
print_r($absolute);
|
||||
if (!file_exists($absolute)) {
|
||||
if (!@touch($absolute)) {
|
||||
$err->raise("bro",3);
|
||||
|
@ -918,29 +920,56 @@ class m_bro {
|
|||
unlink($file);
|
||||
}
|
||||
}
|
||||
/*----------------------------------------------------------*/
|
||||
/** Function d'exportation de configuration appelé par la classe m_export via un hooks
|
||||
*Produit en sorti un tableau formatté ( pour le moment) en HTML
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Exporte toutes les informations ftp du compte AlternC
|
||||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export() {
|
||||
function alternc_export_conf() {
|
||||
global $db,$err;
|
||||
$err->log("bro","export");
|
||||
$str="<bro>\n";
|
||||
$err->log("bro","export_conf");
|
||||
$str="<table border=\"1\"><caption> Browser </caption>\n";
|
||||
$pref=$this->GetPrefs();
|
||||
|
||||
$i=1;
|
||||
foreach ($pref as $k=>$v) {
|
||||
$str.=" <pref>\n";
|
||||
$str.=" <".$k.">".xml_entities($v)."</".$k.">\n";
|
||||
$str.=" </pref>\n";
|
||||
if (($i % 2)==0){
|
||||
$str.=" <tr>\n";
|
||||
$str.=" <td>".$k."</td><td>".$v."</td>\n";
|
||||
$str.=" </tr>\n";
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
$str.="</bro>\n";
|
||||
$str.="</table>\n";
|
||||
|
||||
return $str;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------*/
|
||||
/** Function d'exportation des données appelé par la classe m_export via un hooks
|
||||
*@param : le chemin destination du tarball produit.
|
||||
*/
|
||||
function alternc_export_data($dir){
|
||||
global $mem,$L_ALTERNC_LOC,$err;
|
||||
$err->log("bro","export_data");
|
||||
$dir.="html/";
|
||||
if(!is_dir($dir)){
|
||||
if(!mkdir($dir))
|
||||
$err->raise("bro",4);
|
||||
}
|
||||
$timestamp=date("H:i:s");
|
||||
|
||||
if(exec("/bin/tar cvf - ".$L_ALTERNC_LOC."/html/".substr($mem->user['login'],0,1)."/".$mem->user['login']."/ | gzip -9c > ".$dir."/".$mem->user['login']."_html_".$timestamp.".tar.gz")){
|
||||
$err->log("bro","export_data_succes");
|
||||
}else{
|
||||
$err->log("bro","export_data_failed");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
} /* Classe BROUTEUR */
|
||||
|
||||
|
|
|
@ -1279,36 +1279,51 @@ class m_dom {
|
|||
} else return false;
|
||||
}
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Exporte toutes les informations domaine du compte.
|
||||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export() {
|
||||
/*---------------------------------------------------------------------*/
|
||||
/**
|
||||
* Returns the global domain(s) configuration(s) of a particular user
|
||||
* No parameters needed
|
||||
*
|
||||
**/
|
||||
function alternc_export_conf() {
|
||||
global $db,$err;
|
||||
$err->log("dom","export");
|
||||
$this->enum_domains();
|
||||
$str="<dom>\n";
|
||||
$str="<table border=\"1\"><caption>Domaines</caption><tr><th>Domaine</th><th>DNS</th><th>MX</th><th>mail</th></tr> \n";
|
||||
foreach ($this->domains as $d) {
|
||||
$str.=" <domain>\n <name>".xml_entities($d)."</name>\n";
|
||||
$s=$this->get_domain_all($d);
|
||||
$str.=" <hasdns>".xml_entities($s[dns])."</hasdns>\n";
|
||||
$str.=" <hasmx>".xml_entities($s[mx])."</hasmx>\n";
|
||||
$str.=" <mx>".xml_entities($s[mail])."</mx>\n";
|
||||
if (is_array($s[sub])) {
|
||||
foreach ($s[sub] as $sub) {
|
||||
$str.=" <subdomain>";
|
||||
$str.="<name>".xml_entities($sub[name])."</name>";
|
||||
$str.="<dest>".xml_entities($sub[dest])."</dest>";
|
||||
$str.="<type>".xml_entities($sub[type])."</type>";
|
||||
$str.="</subdomain>\n";
|
||||
$str.="<tr>";
|
||||
$str.="<td>".$d."</td>";
|
||||
$this->lock();
|
||||
$s=$this->get_domain_all($d);
|
||||
$this->unlock();
|
||||
if(empty($s[dns])){
|
||||
$s[dns]="non";
|
||||
}
|
||||
}
|
||||
$str.=" </domain>\n";
|
||||
$str.=" <td>".$s[dns]."</td>\n";
|
||||
|
||||
if(empty($s[mx])){
|
||||
$s[mx]="non";
|
||||
}
|
||||
$str.="<td>".$s[mx]."</td>\n";
|
||||
|
||||
if(empty($s[mail])){
|
||||
$s[mail]="non";
|
||||
}
|
||||
$str.="<td>".$s[mail]."</td>\n";
|
||||
if (is_array($s[sub])) {
|
||||
$str.="<table border=\"1\"><th>nom sous domaine</th><th>destination</th><th>type</th><tr>";
|
||||
|
||||
foreach ($s[sub] as $sub) {
|
||||
$str.="<tr><td>".$sub["enable"]." </td>";
|
||||
$str.="<td>".$sub["dest"]." </td>";
|
||||
$str.="<td>".$sub["type"]." </td></tr>";
|
||||
}
|
||||
|
||||
$str.="</tr>\n";
|
||||
}
|
||||
$str.="</table>\n";
|
||||
}
|
||||
$str.="</dom>\n";
|
||||
$str.="</table>\n";
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
<?php
|
||||
/*---------------------------------------------------------------------------*/
|
||||
/** Constructor
|
||||
Classe d'export de compte Alternc.
|
||||
Cette classe ce contente d'invoquer les fonctions d'exportation de configuration et de données d'un compte,
|
||||
presentes dans les classes concernées.
|
||||
*/
|
||||
Class m_export {
|
||||
function m_export() {
|
||||
}
|
||||
|
||||
function export_conf(){
|
||||
global $hooks;
|
||||
$conf = array();
|
||||
$conf=$hooks->invoke('alternc_export_conf');
|
||||
return $conf;
|
||||
}
|
||||
|
||||
/** le repertoire de base est passé en paramettre puis en construit une arborescence de la forme
|
||||
<dir>/<user>/<timestamp/ qui contiendra les dossier de dump html et sql
|
||||
*/
|
||||
function export_data($dir){
|
||||
global $hooks, $mem;
|
||||
|
||||
|
||||
$hooks->invoke('alternc_export_data', Array($dir));
|
||||
}
|
||||
|
||||
}// export Class end
|
||||
?>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -95,7 +95,8 @@ class m_ftp {
|
|||
$r[]=array(
|
||||
"id"=>$db->f("id"),
|
||||
"login"=>$db->f("name"),
|
||||
"dir"=>$match[1]
|
||||
//"dir"=>$match[1]
|
||||
"dir"=>$db->f("homedir")
|
||||
);
|
||||
}
|
||||
return $r;
|
||||
|
@ -378,19 +379,20 @@ class m_ftp {
|
|||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export() {
|
||||
function alternc_export_conf() {
|
||||
global $db,$err;
|
||||
$err->log("ftp","export");
|
||||
$f=$this->get_list();
|
||||
$str="<ftp>\n";
|
||||
foreach ($f as $d) {
|
||||
$str.=" <account>\n";
|
||||
$str.=" <login>".xml_entities($s[login])."</login>\n";
|
||||
$str.=" <pass>".xml_entities($s[pass])."</pass>\n";
|
||||
$str.=" <dir>".xml_entities($s[dir])."</dir>\n";
|
||||
$str.=" </account>\n";
|
||||
$str="<table border=\"1\"><caption> FTP </caption>\n";
|
||||
foreach ($f as $d=>$v) {
|
||||
$str.=" <tr>\n";
|
||||
$str.=" <td>".$v["id"]."</td>\n";
|
||||
$str.=" <td>".($v["encrypted_password"])."</td>\n";
|
||||
$str.=" <td>".($v["login"])."</td>\n";
|
||||
$str.=" <td>".($v["dir"])."<td>\n";
|
||||
$str.=" </tr>\n";
|
||||
}
|
||||
$str.="</ftp>\n";
|
||||
$str.="</table>\n";
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@ class m_hooks {
|
|||
}
|
||||
|
||||
/**
|
||||
* run_hook()
|
||||
* invoke() permet de lancer une fonction donné en parametre dans toute les classes
|
||||
* connues de alternc, avec les parametres donnés.
|
||||
* $hname nom de la fonction "hooks" que l'on cherche dans les classes
|
||||
* $hparam tableau contenant les parametres
|
||||
* $hclass tableau contenant les classes spécifique qu'on veux appeler (si on veux pas TOUTE les appeler)
|
||||
|
|
|
@ -751,44 +751,45 @@ class m_mail {
|
|||
global $db,$err;
|
||||
$err->log("mail","export");
|
||||
$domain=$this->enum_domains();
|
||||
$str="<mail>\n";
|
||||
$str="<table border=\"1\"><caption> Mail</caption>\n";
|
||||
$tmpfile=$tmpdir."/mail_filelist.txt";
|
||||
$f=fopen($tmpfile,"wb");
|
||||
$onepop=false;
|
||||
foreach ($domain as $d) {
|
||||
$str.=" <domain>\n <name>".xml_entities($d)."</name>\n";
|
||||
$s=$this->enum_doms_mails($d);
|
||||
unset($s["count"]);
|
||||
if (count($s)) {
|
||||
foreach($s as $e) {
|
||||
$str.=" <address>\n";
|
||||
$str.=" <mail>".xml_entities($e["mail"])."</mail>\n";
|
||||
$str.=" <ispop>".xml_entities($e["pop"])."</ispop>\n";
|
||||
$acc=explode("\n",$e["alias"]);
|
||||
foreach($acc as $f) {
|
||||
$f=trim($f);
|
||||
if ($f) {
|
||||
$str.=" <alias>".xml_entities($f)."</alias>\n";
|
||||
}
|
||||
}
|
||||
if ($e["pop"]) {
|
||||
$db->query("SELECT path FROM mail_users WHERE alias='".str_replace("@","_",$e["mail"])."';");
|
||||
if ($db->next_record()) {
|
||||
fputs($f,$db->Record["path"]."\n");
|
||||
$onepop=true;
|
||||
}
|
||||
}
|
||||
$str.=" </address>\n";
|
||||
}
|
||||
$str.=" <tr>\n <td>".($d)."</td>\n";
|
||||
$s=$this->enum_doms_mails($d);
|
||||
unset($s["count"]);
|
||||
if (count($s)) {
|
||||
foreach($s as $e) {
|
||||
$str.=" <table><tr>\n";
|
||||
$str.=" <td>".($e["mail"])."</td>\n";
|
||||
$str.=" <td>".($e["pop"])."</td>\n";
|
||||
$acc=explode("\n",$e["alias"]);
|
||||
foreach($acc as $f) {
|
||||
$f=trim($f);
|
||||
$str.="<ul>";
|
||||
if ($f) {
|
||||
$str.=" <li>".($f)."</li>\n</ul>";
|
||||
}
|
||||
}
|
||||
if ($e["pop"]) {
|
||||
$db->query("SELECT path FROM mail_users WHERE alias='".str_replace("@","_",$e["mail"])."';");
|
||||
if ($db->next_record()) {
|
||||
fputs($f,$db->Record["path"]."\n");
|
||||
$onepop=true;
|
||||
}
|
||||
}
|
||||
$str.=" </tr>\n";
|
||||
}
|
||||
}
|
||||
$str.=" </domain>\n";
|
||||
$str.=" </tr>\n";
|
||||
}
|
||||
$str.="</mail>\n";
|
||||
$str.="</table>\n";
|
||||
fclose($f);
|
||||
if ($onepop) {
|
||||
/*if ($onepop) {
|
||||
// Now do the tarball of all pop accounts :
|
||||
exec("/bin/tar -czf ".escapeshellarg($tmpdir."/mail.tar.gz")." -T ".escapeshellarg($tmpfile));
|
||||
}
|
||||
}*/
|
||||
@unlink($tmpfile);
|
||||
return $str;
|
||||
}
|
||||
|
|
|
@ -550,17 +550,23 @@ Cordialement.
|
|||
/**
|
||||
* Exports all the personnal user related information for an account.
|
||||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export($tmpdir) {
|
||||
function alternc_export_conf() {
|
||||
global $db,$err;
|
||||
$err->log("mem","export");
|
||||
$str="<mem>\n";
|
||||
|
||||
foreach ($this->user as $k=>$v) {
|
||||
$str.=" <$k>".xml_entities($v)."</$k>\n";
|
||||
}
|
||||
$str.="</mem>\n";
|
||||
$str="<table border=\"1\"><caption > Member </caption>\n";
|
||||
$users=$this->user;
|
||||
$str.=" <tr> <td>".$users["uid"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["login"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["enabled"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["su"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["pass"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["mail"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["created"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["lastip"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["lastlogin"]."</td></tr>\n";
|
||||
$str.=" <tr> <td>".$users["lastfail"]."</td></tr>\n";
|
||||
$str.="</table>\n";
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
*/
|
||||
|
||||
class DB_users extends DB_Sql {
|
||||
var $Host,$HumanHostname,$User,$Password;
|
||||
var $Host,$HumanHostname,$User,$Password,$client;
|
||||
|
||||
/**
|
||||
* Creator
|
||||
|
@ -81,15 +81,16 @@ class DB_users extends DB_Sql {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
# Create the object
|
||||
$this->Host = $host;
|
||||
$this->client = $GLOBALS['L_MYSQL_CLIENT'];
|
||||
$this->User = $user;
|
||||
$this->Password = $password;
|
||||
// TODO BUG BUG BUG
|
||||
// c'est pas étanche : $db se retrouve avec Database de $sql->dbu . Danger, faut comprendre pourquoi
|
||||
// Si on veux que ca marche, il faut Database=alternc.
|
||||
$this->Database = "mysql";
|
||||
//$this->Database = "mysql";
|
||||
$this->Database = "alternc";
|
||||
$this->HumanHostname = $human_hostname;
|
||||
|
||||
}
|
||||
|
@ -219,13 +220,15 @@ class m_mysql {
|
|||
$pa=addslashes($db->f("pass"));
|
||||
}
|
||||
if ($this->dbus->query("CREATE DATABASE `$dbname`;")) {
|
||||
$err->log("mysql","add_db_succes",$dbn);
|
||||
// Ok, database does not exist, quota is ok and dbname is compliant. Let's proceed
|
||||
$db->query("INSERT INTO db (uid,login,pass,db,bck_mode) VALUES ('$cuid','$lo','$pa','$dbname',0);");
|
||||
// give everything but GRANT on db.*
|
||||
// we assume there's already a user
|
||||
$this->dbus->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$lo."'@'$this->client'");
|
||||
$this->dbus->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$lo."'@'$this->dbus->client'");
|
||||
return true;
|
||||
} else {
|
||||
$err->log("mysql","add_db",$dbn);
|
||||
$err->raise("mysql",3);
|
||||
return false;
|
||||
}
|
||||
|
@ -257,7 +260,7 @@ class m_mysql {
|
|||
$this->dbus->query("DROP DATABASE `$dbname`;");
|
||||
$db->query("SELECT COUNT(*) AS cnt FROM db WHERE uid='$cuid';");
|
||||
$db->next_record();
|
||||
$this->dbus->query("REVOKE ALL PRIVILEGES ON `".$dbname."`.* FROM '".$login."'@'$this->client'");
|
||||
$this->dbus->query("REVOKE ALL PRIVILEGES ON `".$dbname."`.* FROM '".$login."'@".$this->dbus->client."");
|
||||
if ($this->dbus->f("cnt")==0) {
|
||||
$this->dbus->query("DELETE FROM mysql.user WHERE User='".$login."';");
|
||||
$this->dbus->query("FLUSH PRIVILEGES;");
|
||||
|
@ -344,7 +347,7 @@ class m_mysql {
|
|||
|
||||
// Update all the "pass" fields for this user :
|
||||
$db->query("UPDATE db SET pass='$password' WHERE uid='$cuid';");
|
||||
$this->dbus->query("SET PASSWORD FOR '$login'@'$this->client' = PASSWORD('$password')");
|
||||
$this->dbus->query("SET PASSWORD FOR '$login'@'$this->dbus->client' = PASSWORD('$password')");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -389,7 +392,7 @@ class m_mysql {
|
|||
// OK, creation now...
|
||||
$db->query("INSERT INTO db (uid,login,pass,db) VALUES ('$cuid','".$login."','$password','".$dbname."');");
|
||||
// give everything but GRANT on $user.*
|
||||
$this->dbus->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$login."'@'$this->client' IDENTIFIED BY '".addslashes($password)."'");
|
||||
$this->dbus->query("GRANT ALL PRIVILEGES ON `".$dbname."`.* TO '".$login."'@".$this->dbus->client." IDENTIFIED BY '".addslashes($password)."'");
|
||||
$this->dbus->query("CREATE DATABASE `".$dbname."`;");
|
||||
return true;
|
||||
}
|
||||
|
@ -532,7 +535,7 @@ class m_mysql {
|
|||
}
|
||||
|
||||
// We create the user account (the "file" right is the only one we need globally to be able to use load data into outfile)
|
||||
$this->dbus->query("GRANT file ON *.* TO '$user'@'$this->client' IDENTIFIED BY '$pass';");
|
||||
$this->dbus->query("GRANT file ON *.* TO '$user'@".$this->dbus->client." IDENTIFIED BY '$pass';");
|
||||
// We add him to the user table
|
||||
$db->query("INSERT INTO dbusers (uid,name) VALUES($cuid,'$user');");
|
||||
return true;
|
||||
|
@ -564,8 +567,7 @@ class m_mysql {
|
|||
return false; // The error has been raised by checkPolicy()
|
||||
}
|
||||
}
|
||||
|
||||
$this->dbus->query("SET PASSWORD FOR '$user'@'$this->client' = PASSWORD('$pass')");
|
||||
$this->dbus->query("SET PASSWORD FOR ".$user."@".$this->dbus->client." = PASSWORD(".$pass.")");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -593,9 +595,9 @@ class m_mysql {
|
|||
$login=$db->f("name");
|
||||
|
||||
// Ok, database exists and dbname is compliant. Let's proceed
|
||||
$this->dbus->query("REVOKE ALL PRIVILEGES ON *.* FROM '".$mem->user["login"]."_$user'@'$this->client';");
|
||||
$this->dbus->query("DELETE FROM mysql.db WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';");
|
||||
$this->dbus->query("DELETE FROM mysql.user WHERE User='".$mem->user["login"]."_$user' AND Host='$this->client';");
|
||||
$this->dbus->query("REVOKE ALL PRIVILEGES ON *.* FROM '".$mem->user["login"]."_$user'@".$this->dbus->client.";");
|
||||
$this->dbus->query("DELETE FROM mysql.db WHERE User='".$mem->user["login"]."_$user' AND Host=".$this->dbus->client.";");
|
||||
$this->dbus->query("DELETE FROM mysql.user WHERE User='".$mem->user["login"]."_$user' AND Host=".$this->dbus->client.";");
|
||||
$this->dbus->query("FLUSH PRIVILEGES");
|
||||
$this->dbus->query("DELETE FROM dbusers WHERE uid='$cuid' AND name='".$mem->user["login"]."_$user';");
|
||||
return true;
|
||||
|
@ -616,7 +618,7 @@ class m_mysql {
|
|||
$dblist=$this->get_dblist();
|
||||
|
||||
for ( $i=0 ; $i<count($dblist) ; $i++ ) {
|
||||
$this->dbus->query("SELECT Db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv FROM mysql.db WHERE User='".$mem->user["login"].($user?"_":"").$user."' AND Host='$this->client' AND Db='".$dblist[$i]["db"]."';");
|
||||
$this->dbus->query("SELECT Db, Select_priv, Insert_priv, Update_priv, Delete_priv, Create_priv, Drop_priv, References_priv, Index_priv, Alter_priv, Create_tmp_table_priv, Lock_tables_priv FROM mysql.db WHERE User='".$mem->user["login"].($user?"_":"").$user."' AND Host=".$this->dbus->client." AND Db='".$dblist[$i]["db"]."';");
|
||||
if ($this->dbus->next_record())
|
||||
$r[]=array("db"=>$dblist[$i]["name"], "select"=>$this->dbus->f("Select_priv"), "insert"=>$this->dbus->f("Insert_priv"), "update"=>$this->dbus->f("Update_priv"), "delete"=>$this->dbus->f("Delete_priv"), "create"=>$this->dbus->f("Create_priv"), "drop"=>$this->dbus->f("Drop_priv"), "references"=>$this->dbus->f("References_priv"), "index"=>$this->dbus->f("Index_priv"), "alter"=>$this->dbus->f("Alter_priv"), "create_tmp"=>$this->dbus->f("Create_tmp_table_priv"), "lock"=>$this->dbus->f("Lock_tables_priv"));
|
||||
else
|
||||
|
@ -682,10 +684,10 @@ class m_mysql {
|
|||
// We reset all user rights on this DB :
|
||||
$this->dbus->query("SELECT * FROM mysql.db WHERE User = '$usern' AND Db = '$dbname';");
|
||||
if($this->dbus->num_rows())
|
||||
$this->dbus->query("REVOKE ALL PRIVILEGES ON $dbname.* FROM '$usern'@'$this->client';");
|
||||
$this->dbus->query("REVOKE ALL PRIVILEGES ON $dbname.* FROM '$usern'@'".$this->dbus->client."';");
|
||||
if( $strrights ){
|
||||
$strrights=substr($strrights,0,strlen($strrights)-1);
|
||||
$this->dbus->query("GRANT $strrights ON $dbname.* TO '$usern'@'$this->client';");
|
||||
$this->dbus->query("GRANT $strrights ON $dbname.* TO '$usern'@'".$this->dbus->client."';");
|
||||
}
|
||||
$this->dbus->query("FLUSH PRIVILEGES");
|
||||
return TRUE;
|
||||
|
@ -761,36 +763,62 @@ class m_mysql {
|
|||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export($tmpdir) {
|
||||
function alternc_export_conf() {
|
||||
//TODO don't work with separated sql server for dbusers
|
||||
global $db,$err,$cuid;
|
||||
$err->log("mysql","export");
|
||||
$db->query("SELECT login, pass, db, bck_mode, bck_dir, bck_history, bck_gzip FROM db WHERE uid='$cuid';");
|
||||
$str.="<table border=\"1\"><caption>MyQSL</caption><th>login</th><th>pass</th>";
|
||||
if ($db->next_record()) {
|
||||
$str="<mysql>\n";
|
||||
$str.=" <login>".xml_entities($db->Record["login"])."</login>";
|
||||
$str.=" <pass>".xml_entities($db->Record["pass"])."</pass>";
|
||||
$str.="<tr>\n";
|
||||
$str.=" <td>".$db->Record["login"]."</td>";
|
||||
$str.=" <td>".$db->Record["pass"]."</td>";
|
||||
$str.="</tr>\n";
|
||||
do {
|
||||
// Do the dump :
|
||||
$filename=$tmpdir."/mysql.".$db->Record["db"].".sql.gz";
|
||||
exec("/usr/bin/mysqldump --add-drop-table --allow-keywords -Q -f -q -a -e -u".escapeshellarg($db->Record["login"])." -p".escapeshellarg($db->Record["pass"])." ".escapeshellarg($db->Record["db"])." |/bin/gzip >".escapeshellarg($filename));
|
||||
$str.=" <db>\n";
|
||||
$str.=" <name>".xml_entities($db->Record["db"])."</name>\n";
|
||||
$str.=" <tr>\n";
|
||||
$str.=" <td>".($db->Record["db"])."</td>\n";
|
||||
$str.=" <td>".($db->Record["pass"])."</td>\n";
|
||||
if ($s["bck_mode"]!=0) {
|
||||
$str.=" <backup>\n";
|
||||
$str.=" <mode>".xml_entities($db->Record["bck_mode"])."</mode>\n";
|
||||
$str.=" <dir>".xml_entities($db->Record["bck_dir"])."</dir>\n";
|
||||
$str.=" <history>".xml_entities($db->Record["bck_history"])."</history>\n";
|
||||
$str.=" <gzip>".xml_entities($db->Record["bck_gzip"])."</gzip>\n";
|
||||
$str.=" </backup>\n";
|
||||
$str.=" <table>\n";
|
||||
$str.=" <td>".($db->Record["bck_mode"])."</td>\n";
|
||||
$str.=" <td>".($db->Record["bck_dir"])."</td>\n";
|
||||
$str.=" <td>".($db->Record["bck_history"])."</td>\n";
|
||||
$str.=" <td>".($db->Record["bck_gzip"])."</td>\n";
|
||||
$str.=" </table>\n";
|
||||
}
|
||||
$str.=" </db>\n";
|
||||
$str.=" </tr>\n";
|
||||
} while ($db->next_record());
|
||||
$str.="</mysql>\n";
|
||||
$str.="</table>\n";
|
||||
}
|
||||
return $str;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------- */
|
||||
/**
|
||||
* Exporte all the mysql databases a of give account to $dir directory
|
||||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export_data ($dir){
|
||||
global $db, $err, $cuid,$mem;
|
||||
$err->log("mysql","export_data");
|
||||
$db->query("SELECT db.login, db.pass, db.db, dbusers.name FROM db,dbusers WHERE db.uid='$cuid' AND dbusers.uid=db.uid;");
|
||||
$dir.="sql/";
|
||||
if(!is_dir($dir)){
|
||||
if(!mkdir($dir)){
|
||||
$err->raise('mysql',4);
|
||||
}
|
||||
}
|
||||
// on exporte toutes les bases utilisateur.
|
||||
while($db->next_record()){
|
||||
$filename=$dir."mysql.".$db->Record["db"].".".date("H:i:s").".sql.gz";
|
||||
exec ("/usr/bin/mysqldump --defaults-file=/etc/alternc/my.cnf --add-drop-table --allow-keywords -Q -f -q -a -e ".escapeshellarg($db->Record["db"])." |/bin/gzip >".escapeshellarg($filename));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
} /* Class m_mysql */
|
||||
|
||||
|
|
|
@ -176,9 +176,12 @@ class m_quota {
|
|||
if (isset($this->disk[$ressource])) {
|
||||
// It's a disk resource, update it with shell command
|
||||
exec("/usr/lib/alternc/quota_edit $cuid $size");
|
||||
echo "quota set :::::ciud: $cuid :::: size: $size :::: \n ";
|
||||
// Now we check that the value has been written properly :
|
||||
exec("/usr/lib/alternc/quota_get ".$cuid,$a);
|
||||
if ($size!=$a[1]) {
|
||||
echo "quota get :::::ciud: $cuid :::: size: $size :::: a?: $a ";
|
||||
print_r($a);
|
||||
if ($size!=$a[1]) {
|
||||
$err->raise("quota",1);
|
||||
return false;
|
||||
}
|
||||
|
@ -362,17 +365,18 @@ class m_quota {
|
|||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export($tmpdir) {
|
||||
function alternc_export_conf($tmpdir) {
|
||||
global $db,$err;
|
||||
$err->log("quota","export");
|
||||
$str="<quota>\n";
|
||||
$str="<table border=\"1\" ><caption>QUOTA</caption>\n";
|
||||
|
||||
$q=$this->getquota();
|
||||
foreach ($q as $k=>$v) {
|
||||
$str.=" <service>\n <name>".xml_entities($k)."</name>\n";
|
||||
$str.=" <total>".xml_entities($v)."</total>\n </service>\n";
|
||||
$str.=" <tr>\n <td>".($k)."</td>\n";
|
||||
$str.=" <td>".($v[u])."</td>\n \n";
|
||||
$str.=" <td>".($v[t])."</td>\n </tr>\n";
|
||||
}
|
||||
$str.="</quota>\n";
|
||||
$str.="</table>\n";
|
||||
return $str;
|
||||
}
|
||||
|
||||
|
|
|
@ -290,15 +290,15 @@ class m_sta2 {
|
|||
* @access private
|
||||
* EXPERIMENTAL 'sid' function ;)
|
||||
*/
|
||||
function alternc_export($tmpdir) {
|
||||
function alternc_export_conf() {
|
||||
global $db,$err;
|
||||
$err->log("sta2","export");
|
||||
$this->get_list_raw();
|
||||
$f=$this->get_list_raw();
|
||||
$str="<sta2>\n";
|
||||
foreach ($f as $d) {
|
||||
$str.=" <stats>\n";
|
||||
$str.=" <hostname>".xml_entities($s[hostname])."</hostname>\n";
|
||||
$str.=" <folder>".xml_entities($s[folder])."</folder>\n";
|
||||
$str.=" <hostname>".($s[hostname])."</hostname>\n";
|
||||
$str.=" <folder>".($s[folder])."</folder>\n";
|
||||
$str.=" </stats>\n";
|
||||
}
|
||||
$str.="</sta2>\n";
|
||||
|
@ -308,4 +308,4 @@ class m_sta2 {
|
|||
|
||||
} /* CLASSE m_sta2 */
|
||||
|
||||
?>
|
||||
?>
|
||||
|
|
|
@ -1,9 +1,18 @@
|
|||
alternc (1.1+nmu1) stable; urgency=low
|
||||
|
||||
* Dev in progres.
|
||||
* New class: m_export allowing account exporting given it's iud and a path : http://www.alternc.org/wiki/AlterncExport
|
||||
* Adding script export_account.php usind the above class to export an account.
|
||||
* Bugfixes: quota's scripts udpated ( mostly concerning LVM partitions), and lots of others (permissions, browser ...)
|
||||
|
||||
-- Lerider Steven <squidly@nnx.com> Tue, 28 Feb 2012 14:57:48 +0100
|
||||
|
||||
alternc (1.1) stable; urgency=low
|
||||
* Dev in progress
|
||||
* New class : access security. Allow to restrict some function to specific IP or subnet
|
||||
* Access security management on the ftp account.
|
||||
|
||||
-- Alan Garcia <fufroma@mailfr.com> Wed, 25 May 2011 09:24:30 +0200
|
||||
-- Alan Garcia (nickname) <fufroma@mailfr.com> Wed, 25 May 2011 09:24:30 +0200
|
||||
|
||||
alternc (1.0.3) stable; urgency=high
|
||||
* Bugfix : the 'connect' button in the list of installed domains didn't work, make it work
|
||||
|
|
|
@ -15,7 +15,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: AlternC 0.9.5\n"
|
||||
"Report-Msgid-Bugs-To: alternc@packages.debian.org\n"
|
||||
"POT-Creation-Date: 2011-06-04 11:00+0200\n"
|
||||
"POT-Creation-Date: 2012-02-07 17:23+0100\n"
|
||||
"PO-Revision-Date: 2006-04-26 11:16+0200\n"
|
||||
"Last-Translator: Benjamin Sonntag <benjamin@sonntag.fr>\n"
|
||||
"Language-Team: Team AlternC <team@alternc.org>\n"
|
||||
|
@ -33,10 +33,16 @@ msgstr "Etes-vous CERTAIN de vouloir installer AlternC sur cet ordinateur ?"
|
|||
#. Type: boolean
|
||||
#. Description
|
||||
#: ../templates:1001
|
||||
#, fuzzy
|
||||
#| msgid ""
|
||||
#| "You are currently trying to install AlternC on your computer. Be aware "
|
||||
#| "that this package will overwrite critical system files, including but not "
|
||||
#| "limited to the config files of bind, postfix, courier, squirrelmail and "
|
||||
#| "proftpd."
|
||||
msgid ""
|
||||
"You are currently trying to install AlternC on your computer. Be aware that "
|
||||
"this package will overwrite critical system files, including but not limited "
|
||||
"to the config files of bind, postfix, courier, squirrelmail and proftpd."
|
||||
"to the config files of bind, postfix, dovecot, squirrelmail and proftpd."
|
||||
msgstr ""
|
||||
"Vous tes en train d'installer AlternC sur cet ordinateur. Comprenez que ce "
|
||||
"paquetage va craser plusieurs fichiers de configuration critiques, incluant, "
|
||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
|||
msgstr ""
|
||||
"Project-Id-Version: PACKAGE VERSION\n"
|
||||
"Report-Msgid-Bugs-To: alternc@packages.debian.org\n"
|
||||
"POT-Creation-Date: 2011-06-04 11:00+0200\n"
|
||||
"POT-Creation-Date: 2012-02-07 17:23+0100\n"
|
||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||
|
@ -29,7 +29,7 @@ msgstr ""
|
|||
msgid ""
|
||||
"You are currently trying to install AlternC on your computer. Be aware that "
|
||||
"this package will overwrite critical system files, including but not limited "
|
||||
"to the config files of bind, postfix, courier, squirrelmail and proftpd."
|
||||
"to the config files of bind, postfix, dovecot, squirrelmail and proftpd."
|
||||
msgstr ""
|
||||
|
||||
#. Type: boolean
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
# ----------------------------------------------------------------------
|
||||
#
|
||||
SETUID=mail_add mail_del quota_edit quota_get mem_add mem_del
|
||||
SCRIPTS=sqlbackup.sh rawstat.daily quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize
|
||||
SCRIPTS=sqlbackup.sh rawstat.daily quota_init quota_delete update_domains.sh slave_dns sendmail spoolsize.php fixperms.sh alternc-dboptimize export_account.php
|
||||
LIBS=functions.sh functions_hosting.sh functions_dns.sh
|
||||
BIN=$(DESTDIR)/usr/lib/alternc/
|
||||
|
||||
|
|
|
@ -0,0 +1,92 @@
|
|||
#!/usr/bin/php -q
|
||||
<?php
|
||||
/**
|
||||
* Script permettant d'exporter la configuration d'un compte Alternc ainsi que les données associé
|
||||
* A lancer par exemple avant une suppression de compte.
|
||||
* Les seuls arguments necessaires sont l'iud du compte à exporter, ainsi que le repertoire ou le dump sera effectué.
|
||||
* l'export ce fait sous l'arborescence <dir>/<login>/date/ ou les dumps de configuration sont déposées.
|
||||
* Deux sous dossier sont ensuite crée : html ( dump des fichiers web et de la configuration du compte )
|
||||
* et un dossier sql contenant toutes les bases de données de l'utilisateur.
|
||||
*/
|
||||
|
||||
|
||||
require("/var/alternc/bureau/class/config_nochk.php");
|
||||
|
||||
global $L_VERSION;
|
||||
|
||||
if(!chdir("/var/alternc/bureau")){
|
||||
exit(1);
|
||||
}
|
||||
if($argc != 3 ){
|
||||
echo "usage : export.php <uid> <directory>\n";
|
||||
exit (1);
|
||||
}
|
||||
|
||||
$my_id=$argv[1];
|
||||
# TODO here test $my_id is numeric
|
||||
if((intval($my_id))==0 || (intval($myid)==1)){
|
||||
echo "bad argument: expecting a 4 digit IUD";
|
||||
exit (1);
|
||||
}
|
||||
|
||||
$dir=$argv[2];
|
||||
echo "\n === Export of account $my_id === to $dir\n\n";
|
||||
|
||||
|
||||
# Connect in this user
|
||||
$admin->enabled=1;
|
||||
$mem->su($my_id);
|
||||
|
||||
|
||||
|
||||
if(!is_dir($dir)){
|
||||
if(!mkdir($dir)){
|
||||
echo "creating dir : ".$dir." failed";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$dir.=$mem->user["login"]."/";
|
||||
if(!is_dir($dir)){
|
||||
if(!mkdir($dir)){
|
||||
echo "creating dir : ".$dir." failed";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
$timestamp=date("Y:m:d");
|
||||
$dir.=$timestamp."/";
|
||||
if(!is_dir($dir)){
|
||||
if(!mkdir($dir)){
|
||||
echo "creating dir : ".$dir." failed";
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
# Get the conf
|
||||
$conf_user=Array();
|
||||
$conf_user=$export->export_conf();
|
||||
|
||||
$file_conf=$dir."dump_conf_".date("H:i:s");
|
||||
echo $file_conf;
|
||||
$file=fopen($file_conf."dump","ab");
|
||||
fputs($file,"dump of ::".$mem->user["login"]."\n");
|
||||
|
||||
fputs($file,"alternc version:".$L_VERSION."\n\n");
|
||||
fputs($file,"<html><body>");
|
||||
foreach($conf_user as $string){
|
||||
fputs($file,$string);
|
||||
}
|
||||
fputs($file,"</html></body>");
|
||||
fclose($file);
|
||||
|
||||
|
||||
|
||||
# Get the data
|
||||
$export->export_data($dir);
|
||||
$mem->unsu();
|
||||
exit(0);
|
||||
|
||||
?>
|
|
@ -1,5 +1,4 @@
|
|||
#!/bin/bash -e
|
||||
|
||||
#
|
||||
# $Id: fixperms.sh,v 1.1 2005/08/29 19:21:31 benjamin Exp $
|
||||
# ----------------------------------------------------------------------
|
||||
|
@ -97,8 +96,8 @@ doone() {
|
|||
|
||||
# Delete existings ACL
|
||||
# Set the defaults acl on all the files
|
||||
setfacl -b -k -m d:g:alterncpanel:rw- -m d:u:$GID:rw- -m d:g:$GID:rw- \
|
||||
-m g:alterncpanel:rw- -m u:$GID:rw- -m g:$GID:rw- \
|
||||
setfacl -b -k -m d:g:alterncpanel:rwx -m d:u:$GID:rw- -m d:g:$GID:rw- \
|
||||
-m g:alterncpanel:rwx -m u:$GID:rw- -m g:$GID:rw- \
|
||||
-R "$REP"
|
||||
|
||||
read GID LOGIN
|
||||
|
|
|
@ -1,17 +1,17 @@
|
|||
#!/bin/bash
|
||||
. /etc/alternc/local.sh
|
||||
|
||||
# Set disk quota to an user
|
||||
# Won't work over NFS
|
||||
|
||||
MID=$1
|
||||
SIZE=$2
|
||||
|
||||
AWK=/usr/bin/awk
|
||||
QUOTA=/usr/sbin/setquota
|
||||
if [ $# -ne 2 ] || [[ ! "$MID" =~ ^[0-9]+$ ]] || [[ ! "$SIZE" =~ ^[0-9]+$ ]]; then
|
||||
echo "Usage: quota_edit <uid> <size>"
|
||||
echo "Edit the quota of the AlternC account having uid <uid> the the available space to <size>"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DATA_PART=`$DF "${ALTERNC_LOC}/html" 2>/dev/null | $AWK 'NR==2 { print $1 }'`
|
||||
/usr/sbin/setquota -r -g $MID $SIZE $SIZE 0 0 $DATA_PART 2>/dev/null || echo "Group quota are not enabled on /var/alternc." >&2
|
||||
DATA_PART=`df "${ALTERNC_LOC}/html" 2>/dev/null | $AWK 'NR==2 { print $1; }'`
|
||||
`sudo $QUOTA -r -g $MID $SIZE $SIZE 0 0 $DATA_PART 2>/dev/null || echo "Group quota are not enabled on /var/alternc." >&2`
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/bash
|
||||
. /etc/alternc/local.sh
|
||||
|
||||
AWK=/usr/bin/awk
|
||||
DF=/bin/df
|
||||
SED=/bin/sed
|
||||
|
@ -8,7 +7,7 @@ MOUNT=/bin/mount
|
|||
QUOTA=/usr/bin/quota
|
||||
GREP=/bin/grep
|
||||
WC=/usr/bin/wc
|
||||
|
||||
BLKID=/sbin/blkid
|
||||
MID=$1
|
||||
|
||||
if [ "x$MID" == "x" ] ; then
|
||||
|
@ -21,22 +20,36 @@ fi
|
|||
# We look precisely on the HTML directory. Why ? because it's surely
|
||||
# the bigger one, and if someone separate it we need to look this one
|
||||
# particulary. It should be interesting to cumulate quota of all mounted directory.
|
||||
|
||||
DATA_PART=`$DF "${ALTERNC_LOC}/html" 2>/dev/null | $AWK 'NR==2 { print $1 }'`
|
||||
|
||||
# quota will give over NFS will print the partition using the full NFS name
|
||||
# (e.g. 10.0.0.1:/var/alternc) so we need to lookup first with mount
|
||||
# to convert DATA_PART if needed.
|
||||
|
||||
QUOTA_PART=`$MOUNT | $SED -n -e "s,\([^ ]*\) on ${DATA_PART} type nfs.*,\1,p"`
|
||||
|
||||
if [ -z "$QUOTA_PART" ]; then
|
||||
QUOTA_PART="$DATA_PART"
|
||||
#if the partition is an LVM one we need to adress the partition by its UUID
|
||||
UUID=$( $BLKID | grep "$QUOTA_PART" | cut -f2 -s -d" " | sed 's/\(UUID="\)\(.*\)\(\"$\)/\2/')
|
||||
fi
|
||||
|
||||
# Now we get the quota
|
||||
val=$(quota -A -wg "$MID" |grep "$QUOTA_PART" | awk '{ print $2 "\n" $3; }')
|
||||
|
||||
# If the quota aren't activated, I return something anyway
|
||||
|
||||
# Now we get the quota
|
||||
#first by testing if the partition is referenced by UUID
|
||||
val=$(sudo quota -A -wg "$MID" |grep "$UUID" | awk '{ print $2 "\n" $3; }')
|
||||
if [ -z "$val" ] ; then
|
||||
val=$(sudo quota -A -wg "$MID" |grep "$QUOTA_PART" | awk '{ print $2 "\n" $3; }')
|
||||
|
||||
# If the quota aren't activated, I return something anyway
|
||||
if [ -z "$val" ] ; then
|
||||
echo -e "0\n0"
|
||||
else
|
||||
echo -e "0\n0"
|
||||
fi
|
||||
|
||||
else
|
||||
echo -e "$val"
|
||||
fi
|
||||
|
|
Loading…
Reference in New Issue