bernd commited on 2008-03-11 11:04:59
Zeige 4 geänderte Dateien mit 239 Einfügungen und 0 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@985 87cf0b9e-d624-0410-a070-f6ee81989793
| ... | ... |
@@ -0,0 +1,69 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+function whitelist_entries() |
|
| 4 |
+{
|
|
| 5 |
+ $uid = (int) $_SESSION['userinfo']['uid']; |
|
| 6 |
+ $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid};");
|
|
| 7 |
+ $return = array(); |
|
| 8 |
+ while ($line = mysql_fetch_assoc($res)) |
|
| 9 |
+ array_push($return, $line); |
|
| 10 |
+ return $return; |
|
| 11 |
+} |
|
| 12 |
+ |
|
| 13 |
+ |
|
| 14 |
+function get_whitelist_details($id) |
|
| 15 |
+{
|
|
| 16 |
+ $id = (int) $id; |
|
| 17 |
+ $uid = (int) $_SESSION['userinfo']['uid']; |
|
| 18 |
+ $res = db_query("SELECT id,local,domain,date,expire FROM mail.greylisting_manual_whitelist WHERE uid={$uid} AND id={$id};");
|
|
| 19 |
+ if (mysql_num_rows($res) != 1) |
|
| 20 |
+ system_failure('Kann diesen Eintrag nicht finden');
|
|
| 21 |
+ return mysql_fetch_assoc($res); |
|
| 22 |
+} |
|
| 23 |
+ |
|
| 24 |
+ |
|
| 25 |
+function delete_from_whitelist($id) |
|
| 26 |
+{
|
|
| 27 |
+ $id = (int) $id; |
|
| 28 |
+ // Check if the ID is valid: This will die if not. |
|
| 29 |
+ $entry = get_whitelist_details($id); |
|
| 30 |
+ |
|
| 31 |
+ db_query("DELETE FROM mail.greylisting_manual_whitelist WHERE id={$id} LIMIT 1;");
|
|
| 32 |
+} |
|
| 33 |
+ |
|
| 34 |
+ |
|
| 35 |
+function valid_entry($local, $domain) |
|
| 36 |
+{
|
|
| 37 |
+ if ($domain == 'schokokeks.org') |
|
| 38 |
+ {
|
|
| 39 |
+ if (($local != $_SESSION['userinfo']['username']) && |
|
| 40 |
+ (strpos($local, $_SESSION['userinfo']['username'].'-') !== 0)) |
|
| 41 |
+ system_failure('Diese E-Mail-Adresse gehört Ihnen nicht!');
|
|
| 42 |
+ return true; |
|
| 43 |
+ } |
|
| 44 |
+ $d = mysql_real_escape_string($domain); |
|
| 45 |
+ $res = db_query("SELECT id FROM mail.v_domains WHERE domainname='{$d}' AND user={$_SESSION['userinfo']['uid']} LIMIT 1");
|
|
| 46 |
+ if (mysql_num_rows($res) != 1) |
|
| 47 |
+ system_failure('Diese domain gehört Ihnen nicht!');
|
|
| 48 |
+ return true; |
|
| 49 |
+} |
|
| 50 |
+ |
|
| 51 |
+ |
|
| 52 |
+function new_whitelist_entry($local, $domain, $minutes) |
|
| 53 |
+{
|
|
| 54 |
+ valid_entry($local, $domain); |
|
| 55 |
+ $uid = (int) $_SESSION['userinfo']['uid']; |
|
| 56 |
+ $local = maybe_null($local); |
|
| 57 |
+ $domain = mysql_real_escape_string($domain); |
|
| 58 |
+ |
|
| 59 |
+ $expire = ''; |
|
| 60 |
+ if ($minutes == 'none') |
|
| 61 |
+ $expire = 'NULL'; |
|
| 62 |
+ else |
|
| 63 |
+ $expire = "NOW() + INTERVAL ". (int) $minutes ." MINUTE"; |
|
| 64 |
+ db_query("INSERT INTO mail.greylisting_manual_whitelist (local,domain,date,expire,uid) VALUES ".
|
|
| 65 |
+ "({$local}, '{$domain}', NOW(), {$expire}, $uid);");
|
|
| 66 |
+} |
|
| 67 |
+ |
|
| 68 |
+ |
|
| 69 |
+?> |
| ... | ... |
@@ -0,0 +1,51 @@ |
| 1 |
+<?php |
|
| 2 |
+require_once('inc/debug.php');
|
|
| 3 |
+require_once('inc/security.php');
|
|
| 4 |
+ |
|
| 5 |
+require_once('greylisting.php');
|
|
| 6 |
+ |
|
| 7 |
+ |
|
| 8 |
+if ($_GET['action'] == 'delete') |
|
| 9 |
+{
|
|
| 10 |
+ $entry = get_whitelist_details($_GET['id']); |
|
| 11 |
+ $sure = user_is_sure(); |
|
| 12 |
+ if ($sure === NULL) |
|
| 13 |
+ {
|
|
| 14 |
+ are_you_sure("action=delete&id={$entry['id']}", "Möchten Sie die E-Mail-Adresse »{$entry['local']}@{$entry['domain']}« von der Ausnahmeliste entfernen?");
|
|
| 15 |
+ } |
|
| 16 |
+ elseif ($sure === true) |
|
| 17 |
+ {
|
|
| 18 |
+ delete_from_whitelist($entry['id']); |
|
| 19 |
+ if (! $debugmode) |
|
| 20 |
+ header("Location: whitelist.php");
|
|
| 21 |
+ } |
|
| 22 |
+ elseif ($sure === false) |
|
| 23 |
+ {
|
|
| 24 |
+ if (! $debugmode) |
|
| 25 |
+ header("Location: whitelist.php");
|
|
| 26 |
+ } |
|
| 27 |
+} |
|
| 28 |
+elseif ($_GET['action'] == 'add') |
|
| 29 |
+{
|
|
| 30 |
+ check_form_token('greylisting_add');
|
|
| 31 |
+ if ( !filter_var($_POST['address'], FILTER_VALIDATE_EMAIL ) |
|
| 32 |
+ && !filter_var("x@".$_POST['address'], FILTER_VALIDATE_EMAIL) )
|
|
| 33 |
+ system_failure("Sie haben eine ungültige Mailadresse eingegeben.");
|
|
| 34 |
+ $local = false; |
|
| 35 |
+ $domain = ''; |
|
| 36 |
+ $at = strrpos($_POST['address'], '@'); |
|
| 37 |
+ if ($at === false) |
|
| 38 |
+ $domain = $_POST['address']; |
|
| 39 |
+ else |
|
| 40 |
+ {
|
|
| 41 |
+ $local = substr($_POST['address'], 0, $at); |
|
| 42 |
+ $domain = substr($_POST['address'], $at+1); |
|
| 43 |
+ } |
|
| 44 |
+ DEBUG("Whitelisting {$local}@{$domain} for {$_POST['expire']} minutes");
|
|
| 45 |
+ new_whitelist_entry($local, $domain, $_POST['expire']); |
|
| 46 |
+ if (! $debugmode) |
|
| 47 |
+ header("Location: whitelist.php");
|
|
| 48 |
+ |
|
| 49 |
+} |
|
| 50 |
+ |
|
| 51 |
+?> |
| ... | ... |
@@ -0,0 +1,109 @@ |
| 1 |
+<?php |
|
| 2 |
+ |
|
| 3 |
+require_once('inc/debug.php');
|
|
| 4 |
+require_once('inc/security.php');
|
|
| 5 |
+ |
|
| 6 |
+require_once('greylisting.php');
|
|
| 7 |
+ |
|
| 8 |
+$title = "Ausnahmeliste für greylisting"; |
|
| 9 |
+ |
|
| 10 |
+require_role(ROLE_SYSTEMUSER); |
|
| 11 |
+ |
|
| 12 |
+$whitelist = whitelist_entries(); |
|
| 13 |
+DEBUG($whitelist); |
|
| 14 |
+ |
|
| 15 |
+output("<h3>Ausnahmeliste für Greylisting</h3>
|
|
| 16 |
+<p>Als mittlerweile sehr bewährte Methode gegen unerwünschte E-Mails (»Spam«) |
|
| 17 |
+setzen wir Greylisting ein. Diese Technik arbeitet sehr erfolgreich bei vergleichsweise |
|
| 18 |
+geringem Aufwand.</p> |
|
| 19 |
+<p>Ein möglicher Nachteil für den Empfänger besteht allerdings darin, dass E-Mails |
|
| 20 |
+von einem eigentlich legitimen Absender, der an keinen unserer Benutzer bisher |
|
| 21 |
+E-Mails gesendet hat, einige Zeit verspätet zugestellt werden.</p> |
|
| 22 |
+<p>Sofern Sie eine derartige E-Mail erwarten, also z.B. sich auf einer fremden Website |
|
| 23 |
+mit Ihrer E-Mail-Adresse anmelden möchten oder ähnliches, dann können Sie hier Ihre |
|
| 24 |
+dafür benutzte Adresse eintragen. E-Mails an diese Adresse werden dann umgehend zugestellt.</p> |
|
| 25 |
+<p>Dabei können Sie Adressen wahlweise nur kurzzeitig oder dauerhaft vom Greylisting ausnehmen. |
|
| 26 |
+Sie können auch lediglich einen Domainnamen angeben, dann sind sämtliche Adressen innerhalb |
|
| 27 |
+dieser Domain ausgenommen.</p> |
|
| 28 |
+"); |
|
| 29 |
+ |
|
| 30 |
+$form = "<table> |
|
| 31 |
+ <tr><th>Adresse</th><th>seit</th><th>bis</th><th> </th></tr> |
|
| 32 |
+ "; |
|
| 33 |
+ |
|
| 34 |
+foreach ($whitelist AS $entry) |
|
| 35 |
+{
|
|
| 36 |
+ $end = $entry['expire']; |
|
| 37 |
+ if (! $end) |
|
| 38 |
+ $end = '<em>unbegrenzt</em>'; |
|
| 39 |
+ $form .= "<tr><td>{$entry['local']}@{$entry['domain']}</td><td>{$entry['date']}</td><td>{$end}</td><td><a href=\"save.php?action=delete&id={$entry['id']}\"><img src=\"{$prefix}images/delete.png\" alt=\"Eintrag löschen\" title=\"Diesen Eintrag löschen\" style=\"width: 16px; height: 16px;\" /></a></td></tr>\n";
|
|
| 40 |
+} |
|
| 41 |
+ |
|
| 42 |
+$form .= '<tr><td><input type="text" name="address" /></td><td>-</td><td>'.html_select('expire', array('none' => 'Unbegrenzt', '5' => '5 Minuten', '10' => '10 Minuten', '20' => '20 Minuten', '30' => '30 Minuten', '60' => '1 Stunde', '120' => '2 Stunden', '1440' => '1 Tag'), '10').'</td><td></td></tr>';
|
|
| 43 |
+ |
|
| 44 |
+$form .= '</table>'; |
|
| 45 |
+ |
|
| 46 |
+$form .= '<p><input type="submit" value="Speichern" /></p>'; |
|
| 47 |
+ |
|
| 48 |
+output(html_form('greylisting_add', 'save.php', 'action=add', $form));
|
|
| 49 |
+ |
|
| 50 |
+output('<p></p>');
|
|
| 51 |
+ |
|
| 52 |
+/***************************** |
|
| 53 |
+$form = " |
|
| 54 |
+ <table> |
|
| 55 |
+ <tr><th>Adresse</th><th>Verhalten</th><th> </th></tr> |
|
| 56 |
+ <tr><td><strong>{$vhost['fqdn']}</strong>{$mainalias}</td><td>Haupt-Adresse</td><td> </td></tr>
|
|
| 57 |
+"; |
|
| 58 |
+ |
|
| 59 |
+foreach ($aliases AS $alias) {
|
|
| 60 |
+ $aliastype = 'Zusätzliche Adresse'; |
|
| 61 |
+ if (strstr($alias['options'], 'forward')) {
|
|
| 62 |
+ $aliastype = 'Umleitung auf Haupt-Adresse'; |
|
| 63 |
+ } |
|
| 64 |
+ $formtoken = generate_form_token('aliases_toggle');
|
|
| 65 |
+ $havewww = '<br />www.'.$alias['fqdn'].'   ('.internal_link('aliasoptions.php', 'WWW-Alias entfernen', "alias={$alias['id']}&aliaswww=0&formtoken={$formtoken}").')';
|
|
| 66 |
+ $nowww = '<br />'.internal_link('aliasoptions.php', 'Auch mit WWW', "alias={$alias['id']}&aliaswww=1&formtoken={$formtoken}");
|
|
| 67 |
+ $wwwalias = (strstr($alias['options'], 'aliaswww') ? $havewww : $nowww); |
|
| 68 |
+ |
|
| 69 |
+ $to_forward = internal_link('aliasoptions.php', 'In Umleitung umwandeln', "alias={$alias['id']}&forward=1&formtoken={$formtoken}");
|
|
| 70 |
+ $remove_forward = internal_link('aliasoptions.php', 'In zusätzliche Adresse umwandeln', "alias={$alias['id']}&forward=0&formtoken={$formtoken}");
|
|
| 71 |
+ $typetoggle = (strstr($alias['options'], 'forward') ? $remove_forward : $to_forward); |
|
| 72 |
+ |
|
| 73 |
+ |
|
| 74 |
+ $form .= "<tr> |
|
| 75 |
+ <td>{$alias['fqdn']}{$wwwalias}</td>
|
|
| 76 |
+ <td>{$aliastype}<br />{$typetoggle}</td>
|
|
| 77 |
+ <td>".internal_link('save.php', 'Aliasname löschen', "action=deletealias&alias={$alias['id']}")."</td></tr>
|
|
| 78 |
+ "; |
|
| 79 |
+} |
|
| 80 |
+ |
|
| 81 |
+$form .= " |
|
| 82 |
+<tr> |
|
| 83 |
+ <td> |
|
| 84 |
+ <strong>Neuen Aliasnamen hinzufügen</strong><br /> |
|
| 85 |
+ <input type=\"text\" name=\"hostname\" id=\"hostname\" size=\"10\" value=\"\" /> |
|
| 86 |
+ <strong>.</strong>".domainselect()."<br /> |
|
| 87 |
+ <input type=\"checkbox\" name=\"options[]\" id=\"aliaswww\" value=\"aliaswww\" /> |
|
| 88 |
+ <label for=\"aliaswww\">Auch mit <strong>www</strong> davor.</label> |
|
| 89 |
+ </td> |
|
| 90 |
+ <td> |
|
| 91 |
+ <select name=\"options[]\"> |
|
| 92 |
+ <option value=\"\">zusätzliche Adresse</option> |
|
| 93 |
+ <option value=\"forward\">Umleitung auf Haupt-Adresse</option> |
|
| 94 |
+ </select> |
|
| 95 |
+ </td> |
|
| 96 |
+ <td> |
|
| 97 |
+ <input type=\"submit\" value=\"Hinzufügen\" /> |
|
| 98 |
+ </td> |
|
| 99 |
+</tr> |
|
| 100 |
+</table>"; |
|
| 101 |
+ |
|
| 102 |
+output(html_form('vhosts_add_alias', 'save.php', 'action=addalias&vhost='.$vhost['id'], $form));
|
|
| 103 |
+ |
|
| 104 |
+output("<p>
|
|
| 105 |
+ <a href=\"vhosts.php\">Zurück zur Übersicht</a> |
|
| 106 |
+</p>"); |
|
| 107 |
+ |
|
| 108 |
+*/ |
|
| 109 |
+?> |
|
| 0 | 110 |