Erlaube unverschlüsselte FTP-Zugänge
bernd

bernd commited on 2011-09-30 18:56:41
Zeige 4 geänderte Dateien mit 19 Einfügungen und 8 Löschungen.


git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@2059 87cf0b9e-d624-0410-a070-f6ee81989793
... ...
@@ -23,8 +23,9 @@ if (count($ftpusers) > 0)
23 23
 
24 24
   foreach ($ftpusers AS $f)
25 25
   {
26
+    $sslwarning = ($f['forcessl'] == 0 ? icon_warning('Unverschlüsselte Verbindungen werden erlaubt') : '');
26 27
     $active = ($f['active'] == 1 ? icon_enabled('Ja') : '-');
27
-    output("<tr><td>".internal_link("edit?id={$f['id']}", $f['username'])."</td><td>{$f['homedir']}</td><td style=\"text-align: center;\">{$active}</td><td>".internal_link("save?delete={$f['id']}", icon_delete("{$f['username']} löschen"))."</td></tr>");
28
+    output("<tr><td>".internal_link("edit?id={$f['id']}", $f['username'])."</td><td>{$f['homedir']}</td><td style=\"text-align: center;\">{$active} {$sslwarning}</td><td>".internal_link("save?delete={$f['id']}", icon_delete("{$f['username']} löschen"))."</td></tr>");
28 29
   }
29 30
   output('</table>');
30 31
 }
... ...
@@ -26,7 +26,8 @@ $user_home = $_SESSION['userinfo']['homedir'];
26 26
 $homedir = substr($ftpuser['homedir'], strlen($user_home)+1);
27 27
 DEBUG($user_home.' / '.$homedir.' / '.$ftpuser['homedir']);
28 28
 
29
-$checked = ($ftpuser['active'] == 1 ? 'checked="checked" ' : '');
29
+$active = ($ftpuser['active'] == 1 ? 'checked="checked" ' : '');
30
+$forcessl = ($ftpuser['forcessl'] == 1 ? 'checked="checked" ' : '');
30 31
 
31 32
 $servers = server_names();
32 33
 $available_servers = array_merge(array(my_server_id()), additional_servers());
... ...
@@ -58,10 +59,12 @@ output(html_form('ftpusers_edit', 'save', 'id='.$ftpuser['id'], '
58 59
   </tr>
59 60
   <tr>
60 61
     <td>Zugang aktivieren:</td>
61
-    <td><input type="checkbox" id="active" name="active" value="1" '.$checked.'/> auf Server '.$whichserver.'</td>
62
+    <td><input type="checkbox" id="active" name="active" value="1" '.$active.'/> auf Server '.$whichserver.'<br/><input type="checkbox" id="forcessl" name="forcessl" value="1" '.$forcessl.'/>&#160;<label for="forcessl">SSL-Verschlüsselung erforderlich<sup>*</sup></label></td>
62 63
   </tr>
63 64
   </table>
64 65
   <p><input type="submit" name="save" value="Speichern" /></p>
66
+  
67
+  <p><sup>*</sup>) Wenn die Verschlüsselung nicht erforderlich ist, können Sie mit diesen Zugangsdaten eine ungesicherte Verbindung auf TCP-port 1021 aufbauen. Auf dem Standard-Port 21 wird grundsätzlich eine Verschlüsselung benötigt.</p>
65 68
 '));
66 69
 
67 70
 
... ...
@@ -5,7 +5,7 @@ require_once('inc/base.php');
5 5
 function list_ftpusers()
6 6
 {
7 7
   $uid = (int) $_SESSION['userinfo']['uid'];
8
-  $result = db_query("SELECT id, username, homedir, active FROM system.ftpusers WHERE uid=$uid");
8
+  $result = db_query("SELECT id, username, homedir, active, forcessl FROM system.ftpusers WHERE uid=$uid");
9 9
   $ftpusers = array();
10 10
   while ($u = mysql_fetch_assoc($result)) {
11 11
     $ftpusers[] = $u;
... ...
@@ -16,7 +16,7 @@ function list_ftpusers()
16 16
 function empty_ftpuser()
17 17
 {
18 18
   $myserver = my_server_id();
19
-  return array("id" => "0", "username" => "", "password" => "", "homedir" => "", "active" => "1", "server" => $myserver);
19
+  return array("id" => "0", "username" => "", "password" => "", "homedir" => "", "active" => "1", "forcessl" => "1", "server" => $myserver);
20 20
 }
21 21
 
22 22
 function load_ftpuser($id)
... ...
@@ -25,7 +25,7 @@ function load_ftpuser($id)
25 25
     return empty_ftpuser();
26 26
   $uid = (int) $_SESSION['userinfo']['uid'];
27 27
   $id = (int) $id;
28
-  $result = db_query("SELECT id, username, password, homedir, active, server FROM system.ftpusers WHERE uid={$uid} AND id='{$id}' LIMIT 1");
28
+  $result = db_query("SELECT id, username, password, homedir, active, forcessl, server FROM system.ftpusers WHERE uid={$uid} AND id='{$id}' LIMIT 1");
29 29
   if (mysql_num_rows($result) != 1)
30 30
     system_failure("Fehler beim auslesen des Accounts");
31 31
   $account = mysql_fetch_assoc($result);
... ...
@@ -50,6 +50,8 @@ function save_ftpuser($data)
50 50
     system_failure('Pfad scheint nicht in Ihrem Home zu sein oder enthielt ungültige Zeichen.');
51 51
   $active = ($data['active'] == 1 ? '1' : '0');
52 52
 
53
+  $forcessl = ($data['forcessl'] == 0 ? '0' : '1');
54
+
53 55
   $server = NULL;
54 56
   if ($data['server'] == my_server_id())
55 57
   {
... ...
@@ -85,9 +87,9 @@ function save_ftpuser($data)
85 87
     
86 88
   
87 89
   if ($id)
88
-    db_query("UPDATE system.ftpusers SET username='{$username}', {$password_query} homedir='{$homedir}', active='{$active}', server={$server} WHERE id={$id} AND uid={$uid} LIMIT 1");
90
+    db_query("UPDATE system.ftpusers SET username='{$username}', {$password_query} homedir='{$homedir}', active='{$active}', forcessl='{$forcessl}', server={$server} WHERE id={$id} AND uid={$uid} LIMIT 1");
89 91
   else
90
-    db_query("INSERT INTO system.ftpusers (username, password, homedir, uid, active, server) VALUES ('{$username}', '{$password_hash}', '{$homedir}', '{$uid}', '{$active}', {$server})");
92
+    db_query("INSERT INTO system.ftpusers (username, password, homedir, uid, active, forcessl, server) VALUES ('{$username}', '{$password_hash}', '{$homedir}', '{$uid}', '{$active}', '{$forcessl}', {$server})");
91 93
 }
92 94
 
93 95
 
... ...
@@ -48,6 +48,11 @@ if (isset($_REQUEST['active']))
48 48
 else
49 49
   $ftpuser['active'] = 0;
50 50
 
51
+if (isset($_REQUEST['forcessl']))
52
+  $ftpuser['forcessl'] = $_REQUEST['forcessl'];
53
+else
54
+  $ftpuser['forcessl'] = 0;
55
+
51 56
 if (isset($_REQUEST['server']))
52 57
   $ftpuser['server'] = $_REQUEST['server'];
53 58
 
54 59