bernd commited on 2007-07-30 17:15:58
Zeige 4 geänderte Dateien mit 47 Einfügungen und 28 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@574 87cf0b9e-d624-0410-a070-f6ee81989793
| ... | ... |
@@ -1,11 +1,13 @@ |
| 1 | 1 |
<?php |
| 2 | 2 |
|
| 3 |
+require_once("inc/security.php");
|
|
| 4 |
+ |
|
| 3 | 5 |
function system_failure($reason) |
| 4 | 6 |
{
|
| 5 | 7 |
include('inc/top.php');
|
| 6 | 8 |
echo '<div class="error"> |
| 7 | 9 |
<h3>Fehler</h3> |
| 8 |
- <p>Es ist ein Fehler aufgetreten: '.$reason.'</p> |
|
| 10 |
+ <p>Es ist ein Fehler aufgetreten: '.filter_input_general($reason).'</p> |
|
| 9 | 11 |
</div>'; |
| 10 | 12 |
include('inc/bottom.php');
|
| 11 | 13 |
die(); |
| ... | ... |
@@ -51,7 +53,7 @@ function show_messages() |
| 51 | 53 |
'; |
| 52 | 54 |
foreach ($input_error as $error) |
| 53 | 55 |
{
|
| 54 |
- echo '<li>'.$error."</li>\n"; |
|
| 56 |
+ echo '<li>'.filter_input_general($error)."</li>\n"; |
|
| 55 | 57 |
} |
| 56 | 58 |
echo '</ul> |
| 57 | 59 |
</div>'; |
| ... | ... |
@@ -63,7 +65,7 @@ function show_messages() |
| 63 | 65 |
'; |
| 64 | 66 |
foreach ($warning as $msg) |
| 65 | 67 |
{
|
| 66 |
- echo '<li>'.$msg."</li>\n"; |
|
| 68 |
+ echo '<li>'.filter_input_general($msg)."</li>\n"; |
|
| 67 | 69 |
} |
| 68 | 70 |
echo '</ul> |
| 69 | 71 |
</div>'; |
| ... | ... |
@@ -75,7 +77,7 @@ function show_messages() |
| 75 | 77 |
'; |
| 76 | 78 |
foreach ($success_msg as $msg) |
| 77 | 79 |
{
|
| 78 |
- echo '<li>'.$msg."</li>\n"; |
|
| 80 |
+ echo '<li>'.filter_input_general($msg)."</li>\n"; |
|
| 79 | 81 |
} |
| 80 | 82 |
echo '</ul> |
| 81 | 83 |
</div>'; |
| ... | ... |
@@ -50,6 +50,23 @@ function filter_shell( $input ) |
| 50 | 50 |
return ereg_replace('[^-[:alnum:]\_\.\+ßäöüÄÖÜ/%§=]', '', $input );
|
| 51 | 51 |
} |
| 52 | 52 |
|
| 53 |
+function check_path( $input ) |
|
| 54 |
+{
|
|
| 55 |
+ if ($input != filter_input_general($input)) |
|
| 56 |
+ return False; |
|
| 57 |
+ DEBUG("checking {$input} for valid path name");
|
|
| 58 |
+ $components = explode("/", $input);
|
|
| 59 |
+ foreach ($components AS $item) |
|
| 60 |
+ {
|
|
| 61 |
+ if ($item == '..') |
|
| 62 |
+ {
|
|
| 63 |
+ return False; |
|
| 64 |
+ } |
|
| 65 |
+ } |
|
| 66 |
+ return (preg_match('/^[a-z0-9.\/_-]*$/',$input) == 1);
|
|
| 67 |
+} |
|
| 68 |
+ |
|
| 69 |
+ |
|
| 53 | 70 |
function check_emailaddr( $input ) |
| 54 | 71 |
{
|
| 55 | 72 |
return (preg_match("/^[a-z]+[a-z0-9]*[\.|\-|_]?[a-z0-9]+@([a-z0-9]*[\.|\-]?[a-z0-9]+){1,4}\.[a-z]{2,4}$/i", $input ) == 1);
|
| ... | ... |
@@ -73,24 +73,24 @@ if (isset($_GET['action']) && $_GET['action'] == 'save') |
| 73 | 73 |
} |
| 74 | 74 |
elseif (isset($_GET['action']) && $_GET['action'] == 'create') |
| 75 | 75 |
{
|
| 76 |
+ $options = ''; |
|
| 77 |
+ $domains = get_domain_list($user['customerno'], $user['uid']); |
|
| 78 |
+ if (count($domains) > 0) |
|
| 79 |
+ $options .= '<option>----------------------------</option>'; |
|
| 80 |
+ foreach ($domains as $dom) |
|
| 81 |
+ $options .= '<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>'; |
|
| 82 |
+ |
|
| 76 | 83 |
output('<h3>E-Mail-Account anlegen</h3>
|
| 77 | 84 |
<p>Hier können Sie ein neues POP3/IMAP-Konto anlegen.</p> |
| 78 |
- <form action="accounts.php?action=save&'.$param.'" method="post"> |
|
| 79 |
- '.generate_form_token('imap_accounts_create').'
|
|
| 85 |
+ '.html_form('imap_accounts_create', 'accounts.php', 'action=save', '
|
|
| 80 | 86 |
<table style="margin-bottom: 1em;"> |
| 81 | 87 |
<tr><th>Einstellung:</th><th>Wert:</th><th> </th></tr> |
| 82 | 88 |
<tr> |
| 83 | 89 |
<td>Benutzername:</td> |
| 84 | 90 |
<td><input type="text" id="user" name="user" />@<select name="domain" size="1"> |
| 85 | 91 |
<option value="schokokeks.org">schokokeks.org</option> |
| 86 |
- '); |
|
| 87 |
- $domains = get_domain_list($user['customerno'], $user['uid']); |
|
| 88 |
- if (count($domains) > 0) |
|
| 89 |
- output('<option>----------------------------</option>');
|
|
| 90 |
- foreach ($domains as $dom) |
|
| 91 |
- output('<option value="'.$dom->fqdn.'">'.$dom->fqdn.'</option>');
|
|
| 92 |
- output('</select></td>
|
|
| 93 |
- |
|
| 92 |
+ '.$options.' |
|
| 93 |
+ </select></td> |
|
| 94 | 94 |
</tr> |
| 95 | 95 |
<tr> |
| 96 | 96 |
<td>Mailbox:</td> |
| ... | ... |
@@ -106,8 +106,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'create') |
| 106 | 106 |
</tr> |
| 107 | 107 |
</table> |
| 108 | 108 |
<p><input type="submit" name="create" value="Anlegen" /><br /> |
| 109 |
- </form> |
|
| 110 |
- '); |
|
| 109 |
+ ')); |
|
| 111 | 110 |
} |
| 112 | 111 |
elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account'] != '') |
| 113 | 112 |
{
|
| ... | ... |
@@ -127,14 +126,13 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account' |
| 127 | 126 |
$_GET['account'] = (int) $_GET['account']; |
| 128 | 127 |
$account = get_mailaccount($_GET['account']); |
| 129 | 128 |
$enabled = ($account['enabled'] ? 'Ja' : 'Nein'); |
| 130 |
- output('<form action="accounts.php?action=delete&account='.$_GET['account'].'&'.$param.'" method="post">
|
|
| 131 |
- '.generate_form_token('imap_accounts_delete').'
|
|
| 132 |
- <table style="margin-bottom: 1em;"> |
|
| 129 |
+ output(html_form('imap_accounts_delete', "accounts.php", "action=delete&account=".$_GET['account'],
|
|
| 130 |
+ '<table style="margin-bottom: 1em;"> |
|
| 133 | 131 |
<tr><td>Benutzername:</td> |
| 134 |
- <td>'.$account['account'].'</td> |
|
| 132 |
+ <td>'.filter_input_general($account['account']).'</td> |
|
| 135 | 133 |
</tr> |
| 136 | 134 |
<tr><td>Mailbox:</td> |
| 137 |
- <td>'.$account['mailbox'].'</td> |
|
| 135 |
+ <td>'.filter_input_general($account['mailbox']).'</td> |
|
| 138 | 136 |
</tr> |
| 139 | 137 |
<tr><td>Konto aktiv:</td> |
| 140 | 138 |
<td>'.$enabled.'</td> |
| ... | ... |
@@ -143,8 +141,7 @@ elseif (isset($_GET['action']) && $_GET['action'] == 'delete' && $_GET['account' |
| 143 | 141 |
<p><input type="hidden" name="confirm" value="yes" /> |
| 144 | 142 |
<input type="submit" value="Wirklich löschen" /> |
| 145 | 143 |
</p> |
| 146 |
- </form> |
|
| 147 |
- '); |
|
| 144 |
+ ')); |
|
| 148 | 145 |
} |
| 149 | 146 |
} |
| 150 | 147 |
elseif (isset($_GET['edit'])) |
| ... | ... |
@@ -3,6 +3,7 @@ |
| 3 | 3 |
require_once('inc/debug.php');
|
| 4 | 4 |
require_once('inc/db_connect.php');
|
| 5 | 5 |
require_once('inc/base.php');
|
| 6 |
+require_once('inc/security.php');
|
|
| 6 | 7 |
|
| 7 | 8 |
require_once('class/domain.php');
|
| 8 | 9 |
|
| ... | ... |
@@ -133,17 +134,19 @@ function check_valid($acc) |
| 133 | 134 |
if ($acc['mailbox'] != '') |
| 134 | 135 |
{
|
| 135 | 136 |
if (substr($acc['mailbox'], 0, strlen($user['homedir'])+1) != $user['homedir'].'/') |
| 136 |
- return "Die Mailbox muss innerhalb des Home-Verzeichnisses liegen. Sie haben \"".$acc['mailbox']."\" als Mailbox angegeben, Ihre Home-Verzeichnis ist \"".$user['homedir']."/\"."; |
|
| 137 |
- if (strstr($acc['mailbox'], '..') or ! preg_match('/^[a-z0-9.\/_-]*$/', $acc['mailbox']))
|
|
| 137 |
+ return "Die Mailbox muss innerhalb des Home-Verzeichnisses liegen. Sie haben »".$acc['mailbox']."« als Mailbox angegeben, Ihr Home-Verzeichnis ist »".$user['homedir']."/«."; |
|
| 138 |
+ if (! check_path($acc['mailbox'])) |
|
| 138 | 139 |
return "Sie verwenden ungültige Zeichen in Ihrem Mailbox-Pfad."; |
| 139 | 140 |
} |
| 140 | 141 |
|
| 141 | 142 |
if ($acc['account'] == '' || strpos($acc['account'], '@') == 0) |
| 142 | 143 |
return "Es wurde kein Benutzername angegeben!"; |
| 143 | 144 |
if (strpos($acc['account'], '@') === false) |
| 144 |
- return "Es wurde kein Domain-Teil im Account-Name angegeben. Account-Namen müssen einen Domain-Teil enthalten. Im Zweifel versuchen Sie "@schokokeks.org"."; |
|
| 145 |
+ return "Es wurde kein Domain-Teil im Account-Name angegeben. Account-Namen müssen einen Domain-Teil enthalten. Im Zweifel versuchen Sie »@schokokeks.org«."; |
|
| 145 | 146 |
|
| 146 | 147 |
list($local, $domain) = explode('@', $acc['account'], 2);
|
| 148 |
+ if ($local != filter_input_username($local)) |
|
| 149 |
+ return "Sie haben ungültige Zeichen im Accountname benutzt!"; |
|
| 147 | 150 |
$tmpdomains = get_domain_list($user['customerno'], $user['uid']); |
| 148 | 151 |
$domains = array(); |
| 149 | 152 |
foreach ($tmpdomains as $dom) |
| ... | ... |
@@ -155,11 +158,11 @@ function check_valid($acc) |
| 155 | 158 |
{
|
| 156 | 159 |
if (substr($local, 0, strlen($user['username'])) != $user['username'] || ($acc['account'][strlen($user['username'])] != '-' && $acc['account'][strlen($user['username'])] != '@')) |
| 157 | 160 |
{
|
| 158 |
- return "Sie haben "@schokokeks.org" als Domain-Teil angegeben, aber der Benutzer-Teil beginnt nicht mit Ihrem Benutzername!"; |
|
| 161 |
+ return "Sie haben »@schokokeks.org« als Domain-Teil angegeben, aber der Benutzer-Teil beginnt nicht mit Ihrem Benutzername!"; |
|
| 159 | 162 |
} |
| 160 | 163 |
} |
| 161 | 164 |
else |
| 162 |
- return "Der angegebene Domain-Teil (".htmlentities($domain, ENT_QUOTES, "UTF-8").") ist nicht für Ihren Account eingetragen. Sollte dies ein Fehler sein, wenden sie sich bitte an einen Administrator!";
|
|
| 165 |
+ return "Der angegebene Domain-Teil (»".htmlentities($domain, ENT_QUOTES, "UTF-8")."«) ist nicht für Ihren Account eingetragen. Sollte dies ein Fehler sein, wenden sie sich bitte an einen Administrator!"; |
|
| 163 | 166 |
} |
| 164 | 167 |
|
| 165 | 168 |
return ''; |
| 166 | 169 |