Alternc  3.2
Alternc logiel libre pour l'hébergement
 All Data Structures Namespaces Files Functions Variables Pages
ftp_edit.php
Go to the documentation of this file.
1 <?php
2 /*
3  $Id: ftp_edit.php,v 1.5 2006/01/12 01:10:48 anarcat Exp $
4  ----------------------------------------------------------------------
5  AlternC - Web Hosting System
6  Copyright (C) 2002 by the AlternC Development Team.
7  http://alternc.org/
8  ----------------------------------------------------------------------
9  Based on:
10  Valentin Lacambre's web hosting softwares: http://altern.org/
11  ----------------------------------------------------------------------
12  LICENSE
13 
14  This program is free software; you can redistribute it and/or
15  modify it under the terms of the GNU General Public License (GPL)
16  as published by the Free Software Foundation; either version 2
17  of the License, or (at your option) any later version.
18 
19  This program is distributed in the hope that it will be useful,
20  but WITHOUT ANY WARRANTY; without even the implied warranty of
21  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22  GNU General Public License for more details.
23 
24  To read the license please visit http://www.gnu.org/copyleft/gpl.html
25  ----------------------------------------------------------------------
26  Original Author of file: Benjamin Sonntag
27  Purpose of file: Edit an FTP account
28  ----------------------------------------------------------------------
29 */
30 require_once("../class/config.php");
31 include_once("head.php");
32 
33 if ( !isset($is_include) ) {
34  $fields = array (
35  "id" => array ("request", "integer", ""),
36  "create" => array ("get", "integer", "0"),
37  "dir" => array ("get", "string", "0"),
38  );
40 }
41 
42 if (!$id && !$create) {
43  $error=_("Neither a creation nor a edition");
44  echo "<h3>"._("Create a FTP account")."</h3>";
45  echo "<p class=\"alert alert-danger\">$error</p>";
46  include_once("foot.php");
47  exit();
48 }
49 
50 if (!$id && $create) { //creation
51  echo "<h3>"._("Create a FTP account")."</h3>";
52  $rr=false;
53 } else {
54  echo "<h3>"._("Editing a FTP account")."</h3>";
55  $rr=$ftp->get_ftp_details($id);
56  if (!$rr) {
57  $error=$err->errstr();
58  }
59 }
60 
61 ?>
62 <?php
63 if (isset($error) && $error) {
64  echo "<p class=\"alert alert-danger\">$error</p>";
65 }
66 ?>
67 <form method="post" action="ftp_doedit.php" name="main" id="main">
68  <input type="hidden" name="id" value="<?php echo $id ?>" />
69  <input type="hidden" name="create" value="<?php echo $create ?>" />
70  <table border="1" cellspacing="0" cellpadding="4" class="tedit">
71  <tr>
72  <th><label for="login"><?php __("Username"); ?></label></th>
73  <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>
74  </tr>
75  <tr>
76  <th><label for="dir"><?php __("Folder"); ?></label></th>
77  <td>
78  <input type="text" class="int" name="dir" id="dir" value="<?php empty($dir)?@ehe("/".$rr[0]["dir"]):@ehe($dir); ?>" size="20" maxlength="64" />
79  <?php display_browser( empty($dir)?("/".( isset($rr[0]["dir"])?$rr[0]["dir"]:'') ):$dir , "main.dir" ); ?>
80  <p><?php __("This is the root folder for this FTP user. i.e. this FTP user can access to this forlder and all its sub-folders."); ?></p>
81 
82  </td>
83  </tr>
84  <tr id='ftp_tr_pass1'>
85  <th><label for="pass"><?php __("Password"); ?></label></th>
86  <td><input type="password" class="int" name="pass" id="pass" size="20" maxlength="64" value=""/><?php display_div_generate_password(DEFAULT_PASS_SIZE,"#pass","#passconf"); ?></td>
87  </tr>
88  <tr id='ftp_tr_pass2'>
89  <th><label for="passconf"><?php __("Confirm password"); ?></label></th>
90  <td><input type="password" class="int" name="passconf" id="passconf" size="20" maxlength="64" value=""/></td>
91  </tr>
92  <tr id='ftp_tr_editpass' style='display: none;'>
93  <th><label for="pass"><?php __("Password"); ?></label></th>
94  <td><a href="javascript:ftp_edit_pass_toggle();"><?php __("Click here if you want to edit password");?></a></td>
95  </tr>
96  </table>
97  <p>
98  <input type="submit" class="inb ok" name="submit" value="<?php __("Save"); ?>" onclick='return ftp_check_pass();' /> &nbsp;
99  <input type="button" class="inb cancel" name="cancel" value="<?php __("Cancel"); ?>" onclick="document.location='ftp_list.php'"/>
100  </p>
101 </form>
102 
103 <script type="text/javascript">
104 document.forms['main'].login.focus();
105 document.forms['main'].setAttribute('autocomplete', 'off');
106 
107 function ftp_edit_pass_toggle() {
108  $('#ftp_tr_pass1').toggle();
109  $('#ftp_tr_pass2').toggle();
110  $('#ftp_tr_editpass').toggle();
111 }
112 
113 function ftp_check_pass() {
114  if ( $('#pass').val() != $('#passconf').val() ) {
115  alert('<?php __("Password do not match"); ?>');
116  return false;
117  }
118  if ( $('#pass').val() == '' ) {
119  // Check if it's a edtion or a creation
120  if ( <?php echo (isset($id) && ! empty($id))?'true':'false' ?> ) { return true ; }
121  alert('<?php __("Please enter a password"); ?>');
122  return false;
123  }
124  return true;
125 }
126 
127 </script>
128 <?php
129 
130 if (isset($id) && ! empty($id)) {
131  echo '<script type="text/javascript">ftp_edit_pass_toggle();</script>';
132 }
133 
134 include_once("foot.php");
135 ?>