Alternc  latest
Alternc logiel libre pour l'hébergement
ftp_edit.php
Go to the documentation of this file.
1 <?php
2 /*
3  ----------------------------------------------------------------------
4  LICENSE
5 
6  This program is free software; you can redistribute it and/or
7  modify it under the terms of the GNU General Public License (GPL)
8  as published by the Free Software Foundation; either version 2
9  of the License, or (at your option) any later version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  To read the license please visit http://www.gnu.org/copyleft/gpl.html
17  ----------------------------------------------------------------------
18 */
19 
20 /**
21  * Form to edit an FTP account
22  *
23  * @copyright AlternC-Team 2000-2017 https://alternc.com/
24  */
25 
26 require_once("../class/config.php");
27 include_once("head.php");
28 
29 if ( !isset($is_include) ) {
30  $fields = array (
31  "id" => array ("request", "integer", ""),
32  "create" => array ("get", "integer", "0"),
33  "dir" => array ("get", "string", "0"),
34  );
36 }
37 
38 if (!$id && !$create) {
39  $msg->raise("ERROR", "ftp", _("Neither a creation nor a edition"));
40  echo "<h3>"._("Create a FTP account")."</h3>";
41  echo $msg->msg_html_all();
42  include_once("foot.php");
43  exit();
44 }
45 
46 if (!$id && $create) { //creation
47  echo "<h3>"._("Create a FTP account")."</h3>";
48  if ( !isset($is_include) )
49  $rr=false;
50 } else {
51  echo "<h3>"._("Editing a FTP account")."</h3>";
52  $rr=$ftp->get_ftp_details($id);
53 }
54 
55 echo $msg->msg_html_all();
56 
57 $c=$admin->listPasswordPolicies();
58 $passwd_classcount = $c['ftp']['classcount'];
59 
60 ?>
61 <form method="post" action="ftp_doedit.php" name="main" id="main" autocomplete="off">
62 <?php csrf_get(); ?>
63 <!-- honeypot fields -->
64 <input type="text" style="display: none" id="fakeUsername" name="fakeUsername" value="" />
65 <input type="password" style="display: none" id="fakePassword" name="fakePassword" value="" />
66 
67  <input type="hidden" name="id" value="<?php ehe($id); ?>" />
68  <input type="hidden" name="create" value="<?php ehe($create); ?>" />
69  <table border="1" cellspacing="0" cellpadding="4" class="tedit">
70  <tr>
71  <th><label for="login"><?php __("Username"); ?></label></th>
72  <td><select class="inl" name="prefixe"><?php $ftp->select_prefix_list($rr[0]["prefixe"]); ?></select>&nbsp;<b>_</b>&nbsp;<input type="text" class="int" name="login" id="login" value="<?php ehe($rr[0]["login"]); ?>" size="20" maxlength="64" /></td>
73  </tr>
74  <tr>
75  <th><label for="dir"><?php __("Folder"); ?></label></th>
76  <td>
77  <input type="text" class="int" name="dir" id="dir" value="<?php empty($dir)?ehe("/".$rr[0]["dir"]):ehe($dir); ?>" size="20" maxlength="64" />
78  <?php display_browser( empty($dir)?("/".( isset($rr[0]["dir"])?$rr[0]["dir"]:'') ):$dir , "dir" ); ?>
79  <p><?php __("This is the root folder for this FTP user. i.e. this FTP user can access to this folder and all its sub-folders."); ?></p>
80 
81  </td>
82  </tr>
83  <tr id='ftp_tr_pass1'>
84  <th><label for="pass"><?php __("Password"); ?></label></th>
85  <td><input type="password" class="int" name="pass" autocomplete="off" id="pass" size="20" maxlength="64" value=""/><?php display_div_generate_password(DEFAULT_PASS_SIZE,"#pass","#passconf",$passwd_classcount); ?></td>
86  </tr>
87  <tr id='ftp_tr_pass2'>
88  <th><label for="passconf"><?php __("Confirm password"); ?></label></th>
89  <td><input type="password" class="int" name="passconf" autocomplete="off" id="passconf" size="20" maxlength="64" value=""/></td>
90  </tr>
91  <tr id='ftp_tr_editpass' style='display: none;'>
92  <th><label for="pass"><?php __("Password"); ?></label></th>
93  <td><a href="javascript:ftp_edit_pass_toggle();"><?php __("Click here if you want to edit password");?></a></td>
94  </tr>
95  </table>
96  <p>
97  <input type="submit" class="inb ok" name="submit" value="<?php __("Save"); ?>" onclick='return ftp_check_pass();' /> &nbsp;
98  <input type="button" class="inb cancel" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location='ftp_list.php'"/>
99  </p>
100 </form>
101 
102 <script type="text/javascript">
103 document.forms['main'].login.focus();
104 
105 function ftp_edit_pass_toggle() {
106  $('#ftp_tr_pass1').toggle();
107  $('#ftp_tr_pass2').toggle();
108  $('#ftp_tr_editpass').toggle();
109 }
110 
111 function ftp_check_pass() {
112  if ( $('#pass').val() != $('#passconf').val() ) {
113  alert('<?php __("Password do not match"); ?>');
114  return false;
115  }
116  if ( $('#pass').val() == '' ) {
117  // Check if it's a edtion or a creation
118  if ( <?php echo (isset($id) && ! empty($id))?'true':'false' ?> ) { return true ; }
119  alert('<?php __("Please enter a password"); ?>');
120  return false;
121  }
122  return true;
123 }
124 
125 </script>
126 <?php
127 
128 if (isset($id) && ! empty($id)) {
129  echo '<script type="text/javascript">ftp_edit_pass_toggle();</script>';
130 }
131 
132 include_once("foot.php");
133 ?>
exit
Definition: adm_doadd.php:70
$msg
Definition: bootstrap.php:75
$fields
Definition: aws_add.php:27
if(! $r=$aws->get_list()) $create
Definition: aws_list.php:34
const DEFAULT_PASS_SIZE
Define constants from vars of /etc/alternc/local.sh The you can't choose where is the AlternC Panel.
Definition: config.php:81
return true
if you do not wish to use encryption via TLS mechanisms (i.e.
Definition: ftp_edit.php:122
$c
Definition: ftp_edit.php:57
$rr
Definition: ftp_edit.php:52
$passwd_classcount
Definition: ftp_edit.php:58
display_div_generate_password($pass_size=DEFAULT_PASS_SIZE, $fields_to_fill1="", $fields_to_fill2="", $classcount=3)
Show a button to set a random password for a password field.
Definition: functions.php:922
__($str)
Definition: functions.php:404
display_browser($dir="", $caller="main.dir", $width=350, $height=450)
Show a button to select a folder on the server.
Definition: functions.php:941
getFields($fields, $requestOnly=false)
Get the Fields of the posted form from $_REQUEST or POST or GET and check their type.
Definition: functions.php:688
csrf_get($return=false)
Give a new CSRF uniq token for a form the session must be up since the CSRF is linked to the session ...
Definition: functions.php:1159
if(!isset($is_include)) if(! $key &&! $crt) $id
if($error) $is_include
Definition: ssl_donew.php:55