bernd commited on 2008-02-02 14:03:07
Zeige 5 geänderte Dateien mit 63 Einfügungen und 6 Löschungen.
git-svn-id: https://svn.schokokeks.org/repos/tools/webinterface/trunk@928 87cf0b9e-d624-0410-a070-f6ee81989793
... | ... |
@@ -145,7 +145,7 @@ echo '<p class="userinfo">Angemeldet als:<br />'; |
145 | 145 |
echo '<br />'.$_SESSION['customerinfo']['name']; |
146 | 146 |
echo '<br />(Kunde)'; |
147 | 147 |
} |
148 |
- elseif ($role & ROLE_MAILACCOUNT) { |
|
148 |
+ elseif ($role & (ROLE_MAILACCOUNT | ROLE_VMAIL_ACCOUNT)) { |
|
149 | 149 |
echo '<strong>'.$_SESSION['mailaccount'].'</strong><br />(E-Mail-Account)'; |
150 | 150 |
} |
151 | 151 |
echo '</p>'; |
... | ... |
@@ -18,6 +18,9 @@ switch ($_SESSION['role']) |
18 | 18 |
case ROLE_ANONYMOUS: |
19 | 19 |
login_screen(''); |
20 | 20 |
break; |
21 |
+case ROLE_VMAIL_ACCOUNT: |
|
22 |
+ $role = "{$_SESSION['mailaccount']}, angemeldet als E-Mail-Account"; |
|
23 |
+ break; |
|
21 | 24 |
case ROLE_MAILACCOUNT: |
22 | 25 |
$role = "{$_SESSION['mailaccount']}, angemeldet als IMAP/POP3-Account"; |
23 | 26 |
break; |
... | ... |
@@ -19,11 +19,12 @@ function empty_account() |
19 | 19 |
|
20 | 20 |
} |
21 | 21 |
|
22 |
-function get_account_details($id) |
|
22 |
+function get_account_details($id, $checkuid = true) |
|
23 | 23 |
{ |
24 | 24 |
$id = (int) $id; |
25 | 25 |
$uid = (int) $_SESSION['userinfo']['uid']; |
26 |
- $result = db_query("SELECT id, local, domain, password, spamfilter, forwards from mail.v_vmail_accounts WHERE useraccount='{$uid}' AND id={$id} LIMIT 1"); |
|
26 |
+ $uid_check = ($checkuid ? "useraccount='{$uid}' AND " : ""); |
|
27 |
+ $result = db_query("SELECT id, local, domain, password, spamfilter, forwards from mail.v_vmail_accounts WHERE {$uid_check}id={$id} LIMIT 1"); |
|
27 | 28 |
if (mysql_num_rows($result) == 0) |
28 | 29 |
system_failure('Ungültige ID oder kein eigener Account'); |
29 | 30 |
$acc = empty_account(); |
... | ... |
@@ -70,6 +71,31 @@ function get_vmail_domains() |
70 | 71 |
} |
71 | 72 |
|
72 | 73 |
|
74 |
+function find_account_id($accname) |
|
75 |
+{ |
|
76 |
+ $accname = mysql_real_escape_string($accname); |
|
77 |
+ DEBUG($accname); |
|
78 |
+ $tmp = explode('@', $accname, 2); |
|
79 |
+ DEBUG($tmp); |
|
80 |
+ if (count($tmp) != 2) |
|
81 |
+ system_failure("Der Account hat nicht die korrekte Syntax"); |
|
82 |
+ list( $local, $domainname) = $tmp; |
|
83 |
+ |
|
84 |
+ $result = db_query("SELECT id FROM mail.v_vmail_accounts WHERE local='{$local}' AND domainname='{$domainname}' LIMIT 1"); |
|
85 |
+ if (mysql_num_rows($result) == 0) |
|
86 |
+ system_failure("Der Account konnte nicht gefunden werden"); |
|
87 |
+ $tmp = mysql_fetch_array($result); |
|
88 |
+ return $tmp[0]; |
|
89 |
+} |
|
90 |
+ |
|
91 |
+ |
|
92 |
+function change_vmail_password($accname, $newpass) |
|
93 |
+{ |
|
94 |
+ $accid = find_account_id($accname); |
|
95 |
+ $encpw = mysql_real_escape_string(encrypt_mail_password($newpass)); |
|
96 |
+ db_query("UPDATE mail.vmail_accounts SET password='{$encpw}' WHERE id={$accid} LIMIT 1;"); |
|
97 |
+} |
|
98 |
+ |
|
73 | 99 |
|
74 | 100 |
function domainselect($selected = NULL, $selectattribute = '') |
75 | 101 |
{ |
... | ... |
@@ -203,6 +229,9 @@ function save_vmail_account($account) |
203 | 229 |
db_query($query); |
204 | 230 |
if ($id) |
205 | 231 |
db_query("DELETE FROM mail.vmail_forward WHERE account={$id}"); |
232 |
+ else |
|
233 |
+ $id = mysql_insert_id(); |
|
234 |
+ |
|
206 | 235 |
if (count($account['forwards']) > 0) |
207 | 236 |
{ |
208 | 237 |
$forward_query = "INSERT INTO mail.vmail_forward (account,spamfilter,destination) VALUES "; |
... | ... |
@@ -8,5 +8,9 @@ if (($role & ROLE_SYSTEMUSER) && user_has_vmail_domain()) |
8 | 8 |
{ |
9 | 9 |
$menu["vmail_accounts"] = array("label" => "E-Mail", "file" => "accounts.php", "weight" => 10); |
10 | 10 |
} |
11 |
+if ($role & ROLE_VMAIL_ACCOUNT) |
|
12 |
+{ |
|
13 |
+ $menu['vmail_chpass'] = array("label" => "Passwort ändern", "file" => "chpass.php", "weight" => 15); |
|
14 |
+} |
|
11 | 15 |
|
12 | 16 |
?> |
... | ... |
@@ -8,9 +8,10 @@ require_once('inc/db_connect.php'); |
8 | 8 |
|
9 | 9 |
define('ROLE_ANONYMOUS', 0); |
10 | 10 |
define('ROLE_MAILACCOUNT', 1); |
11 |
-define('ROLE_SYSTEMUSER', 2); |
|
12 |
-define('ROLE_CUSTOMER', 4); |
|
13 |
-define('ROLE_SYSADMIN', 8); |
|
11 |
+define('ROLE_VMAIL_ACCOUNT', 2); |
|
12 |
+define('ROLE_SYSTEMUSER', 4); |
|
13 |
+define('ROLE_CUSTOMER', 8); |
|
14 |
+define('ROLE_SYSADMIN', 16); |
|
14 | 15 |
|
15 | 16 |
|
16 | 17 |
// Gibt die Rolle aus, wenn das Passwort stimmt |
... | ... |
@@ -68,6 +69,20 @@ function find_role($login, $password, $i_am_admin = False) |
68 | 69 |
} |
69 | 70 |
} |
70 | 71 |
|
72 |
+ // virtueller Mail-Account |
|
73 |
+ $account = $login; |
|
74 |
+ $result = db_query("SELECT cryptpass FROM mail.courier_virtual_accounts WHERE account='{$account}' LIMIT 1;"); |
|
75 |
+ if (@mysql_num_rows($result) > 0) |
|
76 |
+ { |
|
77 |
+ $entry = mysql_fetch_object($result); |
|
78 |
+ $db_password = $entry->cryptpass; |
|
79 |
+ $hash = crypt($password, $db_password); |
|
80 |
+ if ($hash == $db_password || $i_am_admin) |
|
81 |
+ { |
|
82 |
+ return ROLE_VMAIL_ACCOUNT; |
|
83 |
+ } |
|
84 |
+ } |
|
85 |
+ |
|
71 | 86 |
|
72 | 87 |
|
73 | 88 |
// Nothing? |
... | ... |
@@ -196,6 +211,12 @@ function setup_session($role, $useridentity) |
196 | 211 |
$_SESSION['mailaccount'] = $id; |
197 | 212 |
DEBUG("We are mailaccount: {$_SESSION['mailaccount']}"); |
198 | 213 |
} |
214 |
+ if ($role & ROLE_VMAIL_ACCOUNT) |
|
215 |
+ { |
|
216 |
+ $id = $useridentity; |
|
217 |
+ $_SESSION['mailaccount'] = $id; |
|
218 |
+ DEBUG("We are virtual mailaccount: {$_SESSION['mailaccount']}"); |
|
219 |
+ } |
|
199 | 220 |
|
200 | 221 |
} |
201 | 222 |
|
202 | 223 |