diff --git a/.gitattributes b/.gitattributes index 01dd5d2b..f182ccda 100644 --- a/.gitattributes +++ b/.gitattributes @@ -150,6 +150,7 @@ bureau/admin/ftp_del.php -text bureau/admin/ftp_doedit.php -text bureau/admin/ftp_edit.php -text bureau/admin/ftp_list.php -text +bureau/admin/ftp_switch_enable.php -text bureau/admin/head.php -text bureau/admin/hippo_bleue.gif -text bureau/admin/hta_add.php -text diff --git a/bureau/admin/ftp_list.php b/bureau/admin/ftp_list.php index 5e0bb806..7234841c 100644 --- a/bureau/admin/ftp_list.php +++ b/bureau/admin/ftp_list.php @@ -69,7 +69,7 @@ if (isset($error) && $error && !$noftp) {
- + " name="del_" value="" /> + diff --git a/bureau/admin/ftp_switch_enable.php b/bureau/admin/ftp_switch_enable.php new file mode 100644 index 00000000..a0ba0ef4 --- /dev/null +++ b/bureau/admin/ftp_switch_enable.php @@ -0,0 +1,36 @@ +array ("get","integer",""), + "status" =>array ("get","integer",null), +); + +getFields($fields); + +$ftp->switch_enabled($id,$status); + +require_once('ftp_list.php'); diff --git a/bureau/class/m_ftp.php b/bureau/class/m_ftp.php index 60128457..8ad7d359 100644 --- a/bureau/class/m_ftp.php +++ b/bureau/class/m_ftp.php @@ -98,6 +98,30 @@ class m_ftp { return $c; } + // Switch enabled status of an account + function switch_enabled($id,$status=null) { + global $cuid, $db, $err; + if (! $jj = $this->get_ftp_details($id)) { + $err->raise('ftp', _("This account do not exist or is not of this account")); + return false; + } + if ( $status == null ){ + if ($jj[0]['enabled'] == true ) { $status=0;} + else { $status=1; } + } + + // Be sure what is in $status, in case of it was a parameter + $status = ($status?'true':'false'); + + if ( ! $db->query("UPDATE ftpusers SET enabled = $status WHERE uid = '$cuid' AND id = '$id' ;") ) { + $err->raise('ftp', _("Error during update")); + return false; + } else { + return true ; + } + } + + /* ----------------------------------------------------------------- */ /** Retourne la liste des comptes FTP du compte hébergé * Retourne la liste des comptes FTP sous forme de tableau indexé de @@ -112,12 +136,13 @@ class m_ftp { global $db,$err,$cuid, $bro; $err->log("ftp","get_list"); $r=array(); - $db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' ORDER BY name;"); + $db->query("SELECT id, name, homedir, enabled FROM ftpusers WHERE uid='$cuid' ORDER BY name;"); if ($db->num_rows()) { while ($db->next_record()) { $r[]=array( "id"=>$db->f("id"), "login"=>$db->f("name"), + "enabled"=>$db->f("enabled"), //"dir"=>$match[1] "dir"=>$db->f("homedir") ); @@ -139,7 +164,7 @@ class m_ftp { global $db,$err,$cuid; $err->log("ftp","get_ftp_details",$id); $r=array(); - $db->query("SELECT id, name, homedir FROM ftpusers WHERE uid='$cuid' AND id='$id';"); + $db->query("SELECT id, name, homedir, enabled FROM ftpusers WHERE uid='$cuid' AND id='$id';"); if ($db->num_rows()) { $db->next_record(); @@ -155,7 +180,8 @@ class m_ftp { "id"=>$db->f("id"), "prefixe"=> $lg[0], "login"=>$lg[1], - "dir"=>$match[1] + "dir"=>$match[1], + "enabled"=>$db->f("enabled") ); return $r; } else { diff --git a/etc/alternc/templates/proftpd/proftpd.conf b/etc/alternc/templates/proftpd/proftpd.conf index 6ab929da..c8fc10f5 100644 --- a/etc/alternc/templates/proftpd/proftpd.conf +++ b/etc/alternc/templates/proftpd/proftpd.conf @@ -80,6 +80,7 @@ AuthPAM off # - check that the user's ip is in an allowed range # - add the IP range who are defined as "always from everyone" (uid=0. Not uid=2000, because we could want to have some limitation for the root account) SQLUserWhereClause " \ +enabled = true and \ true in ( \ select if(count(*)>0,false,(select value from variable where name='auth_ip_ftp_default_yes')) \ from authorised_ip_affected aia, ftpusers f \ diff --git a/install/upgrades/3.1.0~a.sql b/install/upgrades/3.1.0~a.sql index c7126be3..b7d397e7 100644 --- a/install/upgrades/3.1.0~a.sql +++ b/install/upgrades/3.1.0~a.sql @@ -12,3 +12,6 @@ CREATE TABLE IF NOT EXISTS `db_servers` ( -- Alter table membres to add ALTER TABLE `membres` ADD db_server_id int(10) DEFAULT NULL; +-- Alter table FTP to add 'enabled' +ALTER TABLE `ftpusers` ADD `enabled` boolean NOT NULL DEFAULT TRUE ; +
' onClick='return confirm("");'>"; +} else { + echo "\""._("Disabled")."\"/"; +} + + +?> ]' value='' >