commit | author | age
|
e22f1e
|
1 |
<?php |
T |
2 |
/* |
|
3 |
Copyright (c) 2005, Till Brehm, projektfarm Gmbh |
|
4 |
All rights reserved. |
|
5 |
|
|
6 |
Redistribution and use in source and binary forms, with or without modification, |
|
7 |
are permitted provided that the following conditions are met: |
|
8 |
|
|
9 |
* Redistributions of source code must retain the above copyright notice, |
|
10 |
this list of conditions and the following disclaimer. |
|
11 |
* Redistributions in binary form must reproduce the above copyright notice, |
|
12 |
this list of conditions and the following disclaimer in the documentation |
|
13 |
and/or other materials provided with the distribution. |
|
14 |
* Neither the name of ISPConfig nor the names of its contributors |
|
15 |
may be used to endorse or promote products derived from this software without |
|
16 |
specific prior written permission. |
|
17 |
|
|
18 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
|
19 |
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
|
20 |
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
|
21 |
IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, |
|
22 |
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
|
23 |
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
|
24 |
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
|
25 |
OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING |
|
26 |
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, |
|
27 |
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
|
28 |
*/ |
|
29 |
|
|
30 |
|
|
31 |
/****************************************** |
|
32 |
* Begin Form configuration |
|
33 |
******************************************/ |
|
34 |
|
|
35 |
$tform_def_file = "form/mail_spamfilter.tform.php"; |
|
36 |
|
|
37 |
/****************************************** |
|
38 |
* End Form configuration |
|
39 |
******************************************/ |
|
40 |
|
7fe908
|
41 |
require_once '../../lib/config.inc.php'; |
MC |
42 |
require_once '../../lib/app.inc.php'; |
e22f1e
|
43 |
|
910093
|
44 |
//* Check permissions for module |
T |
45 |
$app->auth->check_module_permissions('mail'); |
e22f1e
|
46 |
|
T |
47 |
// Loading classes |
|
48 |
$app->uses('tpl,tform,tform_actions'); |
|
49 |
$app->load('tform_actions'); |
|
50 |
|
|
51 |
class page_action extends tform_actions { |
7fe908
|
52 |
|
e22f1e
|
53 |
function onShowEnd() { |
T |
54 |
global $app, $conf; |
7fe908
|
55 |
|
e22f1e
|
56 |
// Getting email from data record |
T |
57 |
$email = $this->dataRecord["email"]; |
7fe908
|
58 |
$email_parts = explode("@", $email); |
MC |
59 |
$app->tpl->setVar("email_local_part", $email_parts[0]); |
|
60 |
|
e22f1e
|
61 |
// Getting Domains of the user |
T |
62 |
$sql = "SELECT domain FROM mail_domain WHERE type = 'local' AND ".$app->tform->getAuthSQL('r'); |
|
63 |
$domains = $app->db->queryAllRecords($sql); |
|
64 |
$domain_select = ''; |
|
65 |
foreach( $domains as $domain) { |
|
66 |
$selected = ($domain["domain"] == $email_parts[1])?'SELECTED':''; |
|
67 |
$domain_select .= "<option value='$domain[domain]' $selected>$domain[domain]</option>\r\n"; |
|
68 |
} |
7fe908
|
69 |
$app->tpl->setVar("email_domain", $domain_select); |
MC |
70 |
|
e22f1e
|
71 |
// calculate scores |
T |
72 |
if(count($this->dataRecord) > 0) { |
7fe908
|
73 |
$app->tpl->setVar("spam_rewrite_score_int", number_format($this->dataRecord["spam_rewrite_score_int"] / 100, 2, '.', '')); |
MC |
74 |
$app->tpl->setVar("spam_redirect_score_int", number_format($this->dataRecord["spam_redirect_score_int"] / 100, 2, '.', '')); |
|
75 |
$app->tpl->setVar("spam_delete_score_int", number_format($this->dataRecord["spam_delete_score_int"] / 100, 2, '.', '')); |
e22f1e
|
76 |
} |
7fe908
|
77 |
|
e22f1e
|
78 |
// Changing maildir to mailbox_id |
2af58c
|
79 |
$sql = "SELECT mailbox_id FROM mail_box WHERE maildir = ? AND ".$app->tform->getAuthSQL('r'); |
MC |
80 |
$mailbox = $app->db->queryOneRecord($sql, $this->dataRecord["spam_redirect_maildir"]); |
e22f1e
|
81 |
$this->dataRecord["spam_redirect_maildir"] = $mailbox["mailbox_id"]; |
7fe908
|
82 |
|
e22f1e
|
83 |
parent::onShowEnd(); |
T |
84 |
} |
7fe908
|
85 |
|
e22f1e
|
86 |
function onSubmit() { |
T |
87 |
global $app, $conf; |
7fe908
|
88 |
|
e22f1e
|
89 |
// Check if Domain belongs to user |
2af58c
|
90 |
$domain = $app->db->queryOneRecord("SELECT server_id, domain FROM mail_domain WHERE domain = ? AND ".$app->tform->getAuthSQL('r'), $_POST["email_domain"]); |
e22f1e
|
91 |
if($domain["domain"] != $_POST["email_domain"]) $app->tform->errorMessage .= $app->tform->wordbook["no_domain_perm"]; |
7fe908
|
92 |
|
e22f1e
|
93 |
// compose the email field |
T |
94 |
if($_POST["email_local_part"] != '') { |
|
95 |
$this->dataRecord["email"] = $_POST["email_local_part"]."@".$_POST["email_domain"]; |
|
96 |
} else { |
|
97 |
$this->dataRecord["email"] = $_POST["email_domain"]; |
|
98 |
} |
|
99 |
// Set the server id of the mailbox = server ID of mail domain. |
|
100 |
$this->dataRecord["server_id"] = $domain["server_id"]; |
7fe908
|
101 |
|
e22f1e
|
102 |
unset($this->dataRecord["email_local_part"]); |
T |
103 |
unset($this->dataRecord["email_domain"]); |
7fe908
|
104 |
|
e22f1e
|
105 |
// calculate scores |
7fe908
|
106 |
$this->dataRecord["spam_rewrite_score_int"] = $_POST["spam_rewrite_score_int"] * 100; |
MC |
107 |
$this->dataRecord["spam_redirect_score_int"] = $_POST["spam_redirect_score_int"] * 100; |
|
108 |
$this->dataRecord["spam_delete_score_int"] = $_POST["spam_delete_score_int"] * 100; |
|
109 |
|
e22f1e
|
110 |
// Changing mailbox_id to maildir |
2af58c
|
111 |
$sql = "SELECT maildir FROM mail_box WHERE mailbox_id = ? AND ".$app->tform->getAuthSQL('r'); |
MC |
112 |
$mailbox = $app->db->queryOneRecord($sql, $_POST["spam_redirect_maildir"]); |
e22f1e
|
113 |
$this->dataRecord["spam_redirect_maildir"] = $mailbox["maildir"]; |
7fe908
|
114 |
|
e22f1e
|
115 |
parent::onSubmit(); |
T |
116 |
} |
7fe908
|
117 |
|
e22f1e
|
118 |
} |
T |
119 |
|
|
120 |
$app->tform_actions = new page_action; |
|
121 |
$app->tform_actions->onLoad(); |
|
122 |
|
|
123 |
|
7fe908
|
124 |
?> |