36 $this->srv_proftpd =
variable_get(
'fqdn_proftpd', $L_FQDN,
'Human name for FTP server. If you change it, launch reload-certs', array(
'desc' =>
'Name',
'type' =>
'string'));
44 return array(
"ftp" =>
"FTP accounts");
54 $q = $quota->getquota(
"ftp");
57 'title' => _(
"FTP accounts"),
63 if ($quota->cancreate(
"ftp")) {
64 $obj[
'links'][] = array(
65 'txt' => _(
"Create a new ftp account"),
66 'url' =>
"ftp_edit.php?create=1",
72 $obj[
'links'][] = array(
73 'txt' => _(
"FTP accounts list"),
74 'url' =>
"ftp_list.php"
89 $c[
'protocol'] =
"ftp";
90 $c[
'values'] = Array();
93 if (empty($tt) || !is_array($tt)) {
97 $c[
'values'][$v[
'id']] = $v[
'login'];
110 $msg->raise(
"ERROR",
'ftp', _(
"This account do not exist or is not of this account"));
113 if ($status ==
null) {
114 if ($jj[0][
'enabled'] ==
true) {
121 $status = ($status ? 1 : 0);
123 if (!
$db->query(
"UPDATE ftpusers SET enabled = ? WHERE uid = ? AND id = ? ;", array($status,
$cuid,
$id))) {
124 $msg->raise(
"ERROR",
'ftp', _(
"Error during update"));
143 $msg->debug(
"ftp",
"get_list");
145 $db->query(
"SELECT id, name, homedir, enabled FROM ftpusers WHERE uid= ? ORDER BY name;", array(
$cuid));
146 if (
$db->num_rows()) {
147 while (
$db->next_record()) {
149 "id" =>
$db->f(
"id"),
150 "login" =>
$db->f(
"name"),
151 "enabled" =>
$db->f(
"enabled"),
153 "dir" =>
$db->f(
"homedir")
158 $msg->raise(
"INFO",
"ftp", _(
"No FTP account found"));
172 $msg->debug(
"ftp",
"get_ftp_details",
$id);
174 $db->query(
"SELECT id, name, homedir, enabled FROM ftpusers WHERE uid= ? AND id= ?;", array(
$cuid,
$id));
175 if (
$db->num_rows()) {
178 $regexp =
"/^" . preg_quote(
getuserpath(),
"/") .
"\/(.*)$/";
180 preg_match($regexp,
$db->f(
"homedir"), $match);
182 $lg = explode(
"_",
$db->f(
"name"));
183 if ((!is_array($lg)) || (count($lg) != 2)) {
184 $lg[0] =
$db->f(
"name");
188 "id" =>
$db->f(
"id"),
192 "enabled" =>
$db->f(
"enabled")
196 $msg->raise(
"ERROR",
"ftp", _(
"This FTP account does not exist"));
210 $r[] =
$mem->user[
"login"];
211 $db->query(
"SELECT domaine FROM domaines WHERE compte= ? ORDER BY domaine;", array(
$cuid));
212 while (
$db->next_record()) {
213 $r[] =
$db->f(
"domaine");
227 $vv = array(
'_' =>
'1',
' ' => 0);
228 foreach ($vv as $k => $n) {
229 if (substr_count($l, $k) > $n) {
230 $msg->raise(
"ERROR",
'ftp', sprintf(_(
"FTP login is incorrect: too many '%s'"), $k));
235 if (!preg_match(
"/^[A-Za-z0-9]+[A-Za-z0-9_\.\-]*$/", $l)) {
236 $msg->raise(
"ERROR",
'ftp', _(
"FTP login is incorrect"));
254 if ($current ==
$val) {
255 $c =
" selected=\"selected\"";
259 echo
"<option$c>$val</option>";
276 $msg->log(
"ftp",
"put_ftp_details",
$id);
277 $db->query(
"SELECT count(*) AS cnt FROM ftpusers WHERE id= ? and uid= ?;", array(
$id,
$cuid));
279 if (!
$db->f(
"cnt")) {
280 $msg->raise(
"ERROR",
"ftp", _(
"This FTP account does not exist"));
283 $dir =
$bro->convertabsolute($dir);
284 if (substr($dir, 0, 1) ==
"/") {
285 $dir = substr($dir, 1);
288 if (!in_array($prefixe,
$r)) {
289 $msg->raise(
"ERROR",
"ftp", _(
"The chosen prefix is not allowed"));
293 $full_login = $prefixe;
295 $full_login.=
"_" .
$login;
300 $db->query(
"SELECT COUNT(*) AS cnt FROM ftpusers WHERE id!= ? AND name= ?;", array(
$id, $full_login));
303 $msg->raise(
"ERROR",
"ftp", _(
"This FTP account already exists"));
307 if (!file_exists($absolute)) {
308 system(
"/bin/mkdir -p $absolute");
310 if (!is_dir($absolute)) {
311 $msg->raise(
"ERROR",
"ftp", _(
"The directory cannot be created"));
317 if (is_callable(array($admin,
"checkPolicy"))) {
318 if (!$admin->checkPolicy(
"ftp", $full_login, $pass)) {
323 $db->query(
"UPDATE ftpusers SET name= ? , password='', encrypted_password= ?, homedir= ?, uid= ? WHERE id= ?;", array($full_login, $encrypted_password, $absolute,
$cuid,
$id));
325 $db->query(
"UPDATE ftpusers SET name= ? , homedir= ? , uid= ? WHERE id= ? ;", array($full_login, $absolute,
$cuid,
$id));
338 $msg->log(
"ftp",
"delete_ftp",
$id);
339 $db->query(
"SELECT name FROM ftpusers WHERE id= ? and uid= ? ;", array(
$id,
$cuid));
341 $name =
$db->f(
"name");
343 $msg->raise(
"ERROR",
"ftp", _(
"This FTP account does not exist"));
346 $db->query(
"DELETE FROM ftpusers WHERE id= ? ;", array(
$id));
361 $msg->log(
"ftp",
"add_ftp", $prefixe .
"_" .
$login);
362 $dir =
$bro->convertabsolute($dir);
363 if (substr($dir, 0, 1) ==
"/") {
364 $dir = substr($dir, 1);
368 $msg->raise(
"ERROR",
"ftp", _(
"Password can't be empty"));
371 if (!in_array($prefixe,
$r) || $prefixe ==
"") {
372 $msg->raise(
"ERROR",
"ftp", _(
"The chosen prefix is not allowed"));
375 $full_login = $prefixe;
377 $full_login.=
"_" .
$login;
382 $db->query(
"SELECT count(*) AS cnt FROM ftpusers WHERE name= ? ;", array($full_login));
385 $msg->raise(
"ERROR",
"ftp", _(
"This FTP account already exists"));
388 $db->query(
"SELECT login FROM membres WHERE uid= ? ;", array(
$cuid));
391 if (!file_exists($absolute)) {
392 system(
"/bin/mkdir -p $absolute");
394 if (!is_dir($absolute)) {
395 $msg->raise(
"ERROR",
"ftp", _(
"The directory cannot be created"));
400 if (is_callable(array($admin,
"checkPolicy"))) {
401 if (!$admin->checkPolicy(
"ftp", $full_login, $pass)) {
406 if ($quota->cancreate(
"ftp")) {
408 $db->query(
"INSERT INTO ftpusers (name,password, encrypted_password,homedir,uid) VALUES ( ?, '', ?, ?, ?)", array($full_login, $encrypted_password, $absolute,
$cuid));
411 $msg->raise(
"ERROR",
"ftp", _(
"Your FTP account quota is over. You cannot create more FTP accounts"));
424 $msg->debug(
"ftp",
"is_ftp", $dir);
425 if (substr($dir, 0, 1) ==
"/") {
426 $dir = substr($dir, 1);
428 $db->query(
"SELECT id FROM ftpusers WHERE homedir= ? ;", array(
getuserpath() .
"/" .$dir ));
429 if (
$db->num_rows()) {
445 $msg->log(
"ftp",
"alternc_del_domain",
$dom);
446 $db->query(
"DELETE FROM ftpusers WHERE uid= ? AND ( name LIKE ? OR name LIKE ?) ", array(
$cuid,
$dom.
"\_%",
$dom));
457 $msg->log(
"ftp",
"alternc_del_member");
458 $db->query(
"DELETE FROM ftpusers WHERE uid= ?", array(
$cuid));
471 $msg->debug(
"ftp",
"getquota");
472 $q = Array(
"name" =>
"ftp",
"description" => _(
"FTP accounts"),
"used" => 0);
473 $db->query(
"SELECT COUNT(*) AS cnt FROM ftpusers WHERE uid= ? ", array(
$cuid));
474 if (
$db->next_record()) {
475 $q[
'used'] =
$db->f(
"cnt");
488 $msg->log(
"ftp",
"export");
491 foreach (
$f as
$d => $v) {
492 $str.=
" <login>" . ($v[
"login"]) .
"</login>\n";
493 $str.=
" <password>" . ($v[
"encrypted_password"]) .
"</password>\n";
494 $str.=
" <directory>" . ($v[
"dir"]) .
"<directory>\n";
variable_get($name, $default=null, $createit_comment=null)
Return a persistent variable.
FTP account management class.
hook_menu()
hook function called by menu class to add menu to the left panel
get_ftp_details($id)
Retourne les details d'un compte FTP (voir get_list) Le tableau est celui du compte d'id specifie.
alternc_export_conf()
Exporte toutes les informations ftp du compte AlternC @access private EXPERIMENTAL 'sid' function ;)
put_ftp_details($id, $prefixe, $login, $pass, $dir)
Modifie les param�tres du comptes FTP $id.
is_ftp($dir)
Retourne TRUE si $dir possee un compte FTP.
select_prefix_list($current)
Affiche (ECHO) la liste des prefixes disponibles sous forme de champs d'option Les champs sont affich...
hook_quota_get()
Returns the used quota for the $name service for the current user.
get_list()
Retourne la liste des comptes FTP du compte h�berg� Retourne la liste des comptes FTP sous forme de t...
prefix_list()
Retourne la liste des prefixes utilisables par le compte courant.
alternc_del_domain($dom)
Fonction appellee par domains quand un domaine est supprime pour le membre.
authip_class()
Return the values needed to activate security access.
check_login($l)
Check if the login is fine (syntax)
alternc_del_member()
Fonction appellee par membres quand un membre est efface @access private.
delete_ftp($id)
Efface le compte ftp specifie.
alternc_password_policy()
Password kind used in this class (hook for admin class)
switch_enabled($id, $status=null)
Switch enabled status of an account.
add_ftp($prefixe, $login, $pass, $dir)
Cree un nouveau compte FTP.
getuserpath($user=null)
get the home of the user
_sha512cr($password, $salt=NULL)
Create a SHA512-CRYPT hash of a string.
if(!isset($is_include)) if(! $key &&! $crt) $id
if(empty($_POST['key'])||empty($_POST['val'])) $key