Fusion des formulaire d'édition/création FTP.

Fix #1402
This commit is contained in:
Alan Garcia 2013-01-17 10:09:48 +00:00
parent e3772abacb
commit cfd495d1f2
8 changed files with 51 additions and 175 deletions

2
.gitattributes vendored
View File

@ -150,9 +150,7 @@ bureau/admin/dom_substatus.php -text
bureau/admin/domlist.php -text
bureau/admin/favicon.ico -text
bureau/admin/foot.php -text
bureau/admin/ftp_add.php -text
bureau/admin/ftp_del.php -text
bureau/admin/ftp_doadd.php -text
bureau/admin/ftp_doedit.php -text
bureau/admin/ftp_edit.php -text
bureau/admin/ftp_list.php -text

View File

@ -588,7 +588,7 @@ else {
else {
?>
<span class="ina">
<a href="ftp_add.php?dir=<?php ehe($R); ?>"><?php __("Create an ftp account in this folder"); ?></a>
<a href="ftp_edit.php?create=1&dir=<?php ehe($R); ?>"><?php __("Create an ftp account in this folder"); ?></a>
</span> &nbsp;
<?php
}

View File

@ -1,83 +0,0 @@
<?php
/*
$Id: ftp_add.php,v 1.5 2006/01/12 01:10:48 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
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
Original Author of file: Benjamin Sonntag
Purpose of file: Ask the required values to add a ftp account
----------------------------------------------------------------------
*/
require_once("../class/config.php");
include_once("head.php");
if (!$quota->cancreate("ftp")) {
$error=_("You cannot add any new ftp account, your quota is over.");
$fatal=1;
}
$fields = array (
"id" => array ("post", "integer", 0),
"prefixe" => array ("post", "string", ""),
"login" => array ("post", "string", ""),
"dir" => array ("post", "string", ""),
"pass" => array ("post", "string", ""),
"passconf" => array ("post", "string", ""),
"submit" => array ("post", "string", ""),
);
getFields($fields);
?>
<h3><?php __("Create a new ftp account"); ?></h3>
<hr id="topbar"/>
<br />
<?php
if (isset($error) && $error) {
echo "<p class=\"error\">$error</p>";
if (isset($fatal) && $fatal) {
include_once("foot.php");
exit();
}
}
?>
<form method="post" action="ftp_doadd.php" name="main" id="main">
<table class="tedit">
<tr><th><input type="hidden" name="id" value="<?php echo $id ?>" />
<label for="login"><?php __("Username"); ?></label></th><td>
<select class="inl" name="prefixe"><?php $ftp->select_prefix_list($prefixe); ?></select>&nbsp;<b>_</b>&nbsp;<input type="text" class="int" name="login" id="login" value="" size="20" maxlength="64" />
</td></tr>
<tr><th><label for="dir"><?php __("Folder"); ?></label></th><td><input type="text" class="int" name="dir" id="dir" value="" size="20" maxlength="255" /></td></tr>
<tr><th><label for="pass"><?php __("Password"); ?></label></th><td><input type="password" class="int" name="pass" id="pass" value="" size="20" maxlength="64" /><?php display_div_generate_password(); ?></td></tr>
<tr><th><label for="passconf"><?php __("Confirm password"); ?></label></th><td><input type="password" class="int" name="passconf" id="passconf" value="" size="20" maxlength="64" /></td></tr>
<tr class="trbtn"><td colspan="2">
<input type="submit" class="inb" name="submit" value="<?php __("Create this new FTP account."); ?>" />
<input type="button" class="inb" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location='ftp_list.php'"/>
</td></tr>
</table>
</form>
<?php $mem->show_help("ftp_add"); ?>
<script type="text/javascript">
document.forms['main'].login.focus();
document.forms['main'].setAttribute('autocomplete', 'off');
</script>
<?php include_once("foot.php"); ?>

View File

@ -1,57 +0,0 @@
<?php
/*
$Id: ftp_doadd.php,v 1.2 2006/01/12 01:10:48 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
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License (GPL)
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
To read the license please visit http://www.gnu.org/copyleft/gpl.html
----------------------------------------------------------------------
Original Author of file: Benjamin Sonntag
Purpose of file: Create a new ftp account
----------------------------------------------------------------------
*/
require_once("../class/config.php");
$fields = array (
"prefixe" => array ("post", "string", ""),
"login" => array ("post", "string", ""),
"dir" => array ("post", "string", ""),
"pass" => array ("post", "string", ""),
"passconf" => array ("post", "string", ""),
);
getFields($fields);
if ($pass != $passconf) {
$error = _("Passwords do not match");
include("ftp_add.php");
exit();
}
$r=$ftp->add_ftp($prefixe,$login,$pass,$dir);
if (!$r) {
$error=$err->errstr();
include("ftp_add.php");
exit();
} else {
$error=_("The FTP account has been successfully created");
include("ftp_list.php");
exit();
}
?>

View File

@ -30,6 +30,7 @@
require_once("../class/config.php");
$fields = array (
"id" => array ("post", "integer", ""),
"create" => array ("post", "integer", ""),
"pass" => array ("post", "string", ""),
"passconf" => array ("post", "string", ""),
"prefixe" => array ("post", "string", ""),
@ -39,25 +40,32 @@ $fields = array (
getFields($fields);
if (!$id) {
$error=_("No account selected!");
} else {
if ($pass != $passconf) {
$error = _("Passwords do not match");
include("ftp_edit.php");
exit();
}
if ($pass != $passconf) {
$error = _("Passwords do not match");
include("ftp_edit.php");
exit();
}
$r=$ftp->put_ftp_details($id,$prefixe,$login,$pass,$dir);
if (!$r) {
$error=$err->errstr();
include("ftp_edit.php");
exit();
} else {
$error=_("The ftp account has been successfully changed");
include("ftp_list.php");
exit();
}
if (! $id && !$create) { //not a creation and not an edit
$error=_("Error: neither a creation nor an edition");
include("ftp_list.php");
exit();
}
if (! $id ) { //create
$r=$ftp->add_ftp($prefixe,$login,$pass,$dir);
} else { // edit
$r=$ftp->put_ftp_details($id,$prefixe,$login,$pass,$dir);
}
if (!$r) {
$error=$err->errstr();
include("ftp_edit.php");
exit();
} else {
$error=_("The ftp account has been successfully changed");
include("ftp_list.php");
exit();
}
include_once("head.php");

View File

@ -31,20 +31,29 @@ require_once("../class/config.php");
include_once("head.php");
$fields = array (
"id" => array ("request", "integer", ""),
"id" => array ("request", "integer", ""),
"create" => array ("get", "integer", "0"),
"dir" => array ("get", "string", "0"),
);
getFields($fields);
if (!$id) {
$error=_("No account selected!");
} else {
$r=$ftp->get_ftp_details($id);
if (!$r) {
$error=$err->errstr();
}
if (!$id && !$create) {
$error=_("Neither a creation nor a edition");
include_once("foot.php");
exit();
}
if (!$id && $create) { //creation
echo "<h3>"._("Create a FTP account")."</h3>";
} else {
echo "<h3>"._("Editing a FTP account")."</h3>";
$r=$ftp->get_ftp_details($id);
if (!$r) {
$error=$err->errstr();
}
}
?>
<h3><?php __("Editing an FTP account"); ?></h3>
<?php
if (isset($error) && $error) {
echo "<p class=\"error\">$error</p>";
@ -55,10 +64,11 @@ if (isset($error) && $error) {
<form method="post" action="ftp_doedit.php" name="main" id="main">
<table border="1" cellspacing="0" cellpadding="4" class="tedit">
<tr><th><input type="hidden" name="id" value="<?php echo $id ?>" />
<tr><th><input type="hidden" name="create" value="<?php echo $create ?>" />
<label for="login"><?php __("Username"); ?></label></th><td>
<select class="inl" name="prefixe"><?php $ftp->select_prefix_list($r["prefixe"]); ?></select>&nbsp;<b>_</b>&nbsp;<input type="text" class="int" name="login" id="login" value="<?php ehe($r[0]["login"]); ?>" size="20" maxlength="64" />
<select class="inl" name="prefixe"><?php @$ftp->select_prefix_list($r["prefixe"]); ?></select>&nbsp;<b>_</b>&nbsp;<input type="text" class="int" name="login" id="login" value="<?php @ehe($r[0]["login"]); ?>" size="20" maxlength="64" />
</td></tr>
<tr><th><label for="dir"><?php __("Folder"); ?></label></th><td><input type="text" class="int" name="dir" id="dir" value="<?php ehe("/".$r[0]["dir"]); ?>" size="20" maxlength="64" />
<tr><th><label for="dir"><?php __("Folder"); ?></label></th><td><input type="text" class="int" name="dir" id="dir" value="<?php empty($dir)?@ehe("/".$r[0]["dir"]):@ehe($dir); ?>" size="20" maxlength="64" />
<script type="text/javascript">
<!--
@ -70,7 +80,7 @@ if (isset($error) && $error) {
<tr><th><label for="passconf"><?php __("Confirm password"); ?></label></th><td><input type="password" class="int" name="passconf" id="passconf" size="20" maxlength="64" value=""/></td></tr>
<tr class="trbtn"><td colspan="2">
<input type="submit" class="inb" name="submit" value="<?php __("Change this FTP account"); ?>" />
<input type="submit" class="inb" name="submit" value="<?php __("Save"); ?>" />
<input type="button" class="inb" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location='ftp_list.php'"/>
</td></tr>
</table>

View File

@ -54,7 +54,7 @@ if (isset($error) && $error && !$noftp) {
<?php if ($quota->cancreate("ftp")) { ?>
<p>
<span class="inb"><a href="ftp_add.php"><?php __("Create a new ftp account"); ?></a></span>
<span class="inb"><a href="ftp_edit.php?create=1"><?php __("Create a new ftp account"); ?></a></span>
</p>
<?php } ?>

View File

@ -37,7 +37,7 @@ if ($q["t"] > 0 || $q['u'] > 0) {
<div class="menu-content" id="menu-ftp">
<ul>
<?php if ($quota->cancreate("ftp")) { ?>
<li><a href="ftp_add.php"><img src="images/new.png" alt="<?php __("Create a new ftp account"); ?>" />&nbsp;<?php __("Create a new ftp account"); ?></a></li>
<li><a href="ftp_edit.php?create=1"><img src="images/new.png" alt="<?php __("Create a new ftp account"); ?>" />&nbsp;<?php __("Create a new ftp account"); ?></a></li>
<?php } ?>
<li><a href="ftp_list.php"><?php __("FTP accounts list"); ?></a></li>
</ul>