Skip to content

Commit b0711a4

Browse files
committed
Implemented: FS#350 - Mailuser interface
1 parent 31e0d15 commit b0711a4

36 files changed

+1587
-23
lines changed

interface/lib/lang/en.lng

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ $wb['top_menu_dns'] = 'DNS';
3434
$wb['top_menu_tools'] = 'Tools';
3535
$wb['top_menu_help'] = 'Help';
3636
$wb['top_menu_billing'] = 'Billing';
37+
$wb['top_menu_mailuser'] = 'Mailuser';
3738
$wb['top_menu_domain'] = 'Domains';
3839
$wb['top_menu_dashboard'] = 'Home';
3940
$wb['top_menu_vm'] = 'VServer';

interface/lib/plugins/mail_user_filter_plugin.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,9 @@ function onLoad() {
4747
$app->plugin->registerEvent('mail:mail_user_filter:on_after_insert','mail_user_filter_plugin','mail_user_filter_edit');
4848
$app->plugin->registerEvent('mail:mail_user_filter:on_after_update','mail_user_filter_plugin','mail_user_filter_edit');
4949
$app->plugin->registerEvent('mail:mail_user_filter:on_after_delete','mail_user_filter_plugin','mail_user_filter_del');
50+
$app->plugin->registerEvent('mailuser:mail_user_filter:on_after_insert','mail_user_filter_plugin','mail_user_filter_edit');
51+
$app->plugin->registerEvent('mailuser:mail_user_filter:on_after_update','mail_user_filter_plugin','mail_user_filter_edit');
52+
$app->plugin->registerEvent('mailuser:mail_user_filter:on_after_delete','mail_user_filter_plugin','mail_user_filter_del');
5053

5154
}
5255

interface/web/admin/form/users.tform.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
while ($file = @readdir ($handle)) {
8888
if ($file != '.' && $file != '..') {
8989
if(@is_dir(ISPC_WEB_PATH."/$file")) {
90-
if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login' && $file != 'designer') {
90+
if(is_file(ISPC_WEB_PATH."/$file/lib/module.conf.php") and $file != 'login' && $file != 'designer' && $file != 'mailuser') {
9191
$modules_list[$file] = $file;
9292
}
9393
}

interface/web/login/index.php

Lines changed: 51 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function render() {
6060
if(count($_POST) > 0) {
6161

6262
//** Check variables
63-
if(!preg_match("/^[\w\.\-\_]{1,64}$/", $_POST['username'])) $error = $app->lng('user_regex_error');
63+
if(!preg_match("/^[\w\.\-\_\@]{1,128}$/", $_POST['username'])) $error = $app->lng('user_regex_error');
6464
if(!preg_match("/^.{1,64}$/i", $_POST['passwort'])) $error = $app->lng('pw_error_length');
6565

6666
//** iporting variables
@@ -111,29 +111,57 @@ public function render() {
111111
$sql = "SELECT * FROM sys_user WHERE USERNAME = '$username' and PASSWORT = '". $passwort. "'";
112112
$user = $app->db->queryOneRecord($sql);
113113
} else {
114-
$sql = "SELECT * FROM sys_user WHERE USERNAME = '$username'";
115-
$user = $app->db->queryOneRecord($sql);
116-
117-
if($user) {
114+
if(stristr($username,'@')) {
115+
//* mailuser login
116+
$sql = "SELECT * FROM mail_user WHERE login = '$username'";
117+
$mailuser = $app->db->queryOneRecord($sql);
118+
$user = false;
119+
if($mailuser) {
120+
$saved_password = stripslashes($mailuser['password']);
121+
$salt = '$1$'.substr($saved_password,3,8).'$';
122+
//* Check if mailuser password is correct
123+
if(crypt(stripslashes($passwort),$salt) == $saved_password) {
124+
//* we build a fake user here which has access to the mailuser module only and userid 0
125+
$user = array();
126+
$user['userid'] = 0;
127+
$user['active'] = 1;
128+
$user['startmodule'] = 'mailuser';
129+
$user['modules'] = 'mailuser';
130+
$user['typ'] = 'user';
131+
$user['email'] = $mailuser['email'];
132+
$user['username'] = $username;
133+
$user['language'] = $conf['language'];
134+
$user['theme'] = $conf['theme'];
135+
$user['mailuser_id'] = $mailuser['mailuser_id'];
136+
$user['default_group'] = $mailuser['sys_groupid'];
137+
}
138+
}
118139

119-
$saved_password = stripslashes($user['passwort']);
140+
} else {
141+
//* normal cp user login
142+
$sql = "SELECT * FROM sys_user WHERE USERNAME = '$username'";
143+
$user = $app->db->queryOneRecord($sql);
120144

121-
if(substr($saved_password,0,3) == '$1$') {
122-
//* The password is crypt-md5 encrypted
123-
$salt = '$1$'.substr($saved_password,3,8).'$';
145+
if($user) {
146+
$saved_password = stripslashes($user['passwort']);
147+
148+
if(substr($saved_password,0,3) == '$1$') {
149+
//* The password is crypt-md5 encrypted
150+
$salt = '$1$'.substr($saved_password,3,8).'$';
124151

125-
if(crypt(stripslashes($passwort),$salt) != $saved_password) {
126-
$user = false;
127-
}
128-
} else {
152+
if(crypt(stripslashes($passwort),$salt) != $saved_password) {
153+
$user = false;
154+
}
155+
} else {
129156

130-
//* The password is md5 encrypted
131-
if(md5($passwort) != $saved_password) {
132-
$user = false;
157+
//* The password is md5 encrypted
158+
if(md5($passwort) != $saved_password) {
159+
$user = false;
160+
}
133161
}
162+
} else {
163+
$user = false;
134164
}
135-
} else {
136-
$user = false;
137165
}
138166
}
139167

@@ -143,12 +171,13 @@ public function render() {
143171
$sql = "DELETE FROM `attempts_login` WHERE `ip`='{$ip}'";
144172
$app->db->query($sql);
145173
$user = $app->db->toLower($user);
174+
146175
if ($loginAs) $oldSession = $_SESSION['s'];
147-
$_SESSION = array();
176+
$_SESSION = array();
148177
if ($loginAs) $_SESSION['s_old'] = $oldSession; // keep the way back!
149-
$_SESSION['s']['user'] = $user;
150-
$_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
151-
$_SESSION['s']['language'] = $user['language'];
178+
$_SESSION['s']['user'] = $user;
179+
$_SESSION['s']['user']['theme'] = isset($user['app_theme']) ? $user['app_theme'] : 'default';
180+
$_SESSION['s']['language'] = $user['language'];
152181
$_SESSION["s"]['theme'] = $_SESSION['s']['user']['theme'];
153182

154183
if(is_file($_SESSION['s']['user']['startmodule'].'/lib/module.conf.php')) {
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
<?php
2+
3+
/*
4+
Form Definition
5+
6+
Tabledefinition
7+
8+
Datatypes:
9+
- INTEGER (Forces the input to Int)
10+
- DOUBLE
11+
- CURRENCY (Formats the values to currency notation)
12+
- VARCHAR (no format check, maxlength: 255)
13+
- TEXT (no format check)
14+
- DATE (Dateformat, automatic conversion to timestamps)
15+
16+
Formtype:
17+
- TEXT (Textfield)
18+
- TEXTAREA (Textarea)
19+
- PASSWORD (Password textfield, input is not shown when edited)
20+
- SELECT (Select option field)
21+
- RADIO
22+
- CHECKBOX
23+
- CHECKBOXARRAY
24+
- FILE
25+
26+
VALUE:
27+
- Wert oder Array
28+
29+
Hint:
30+
The ID field of the database table is not part of the datafield definition.
31+
The ID field must be always auto incement (int or bigint).
32+
33+
34+
*/
35+
36+
$form["title"] = "mailbox_autoresponder_txt";
37+
$form["description"] = "";
38+
$form["name"] = "mail_user_autoresponder";
39+
$form["action"] = "mail_user_autoresponder_edit.php";
40+
$form["db_table"] = "mail_user";
41+
$form["db_table_idx"] = "mailuser_id";
42+
$form["db_history"] = "yes";
43+
$form["tab_default"] = "autoresponder";
44+
$form["list_default"] = "index.php";
45+
$form["auth"] = 'no'; // yes / no
46+
47+
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
48+
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
49+
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
50+
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
51+
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
52+
53+
54+
$form["tabs"]['autoresponder'] = array (
55+
'title' => "Autoresponder",
56+
'width' => 100,
57+
'template' => "templates/mail_user_autoresponder_edit.htm",
58+
'fields' => array (
59+
##################################
60+
# Begin Datatable fields
61+
##################################
62+
'autoresponder_subject' => array (
63+
'datatype' => 'VARCHAR',
64+
'formtype' => 'TEXT',
65+
'default' => 'Out of office reply',
66+
'value' => '',
67+
'width' => '30',
68+
'maxlength' => '255'
69+
),
70+
'autoresponder_text' => array (
71+
'datatype' => 'TEXT',
72+
'formtype' => 'TEXTAREA',
73+
'default' => '',
74+
'value' => '',
75+
'cols' => '30',
76+
'rows' => '15'
77+
),
78+
'autoresponder' => array (
79+
'datatype' => 'VARCHAR',
80+
'formtype' => 'CHECKBOX',
81+
'default' => 'n',
82+
'value' => array(1 => 'y',0 => 'n')
83+
),
84+
'autoresponder_start_date' => array (
85+
'datatype' => 'DATETIME',
86+
'formtype' => 'DATETIME',
87+
'validators'=> array ( 0 => array ( 'type' => 'CUSTOM',
88+
'class' => 'validate_autoresponder',
89+
'function' => 'start_date',
90+
'errmsg'=> 'autoresponder_start_date_isfuture'),
91+
),
92+
),
93+
'autoresponder_end_date' => array (
94+
'datatype' => 'DATETIME',
95+
'formtype' => 'DATETIME',
96+
'validators'=> array ( 0 => array ( 'type' => 'CUSTOM',
97+
'class' => 'validate_autoresponder',
98+
'function' => 'end_date',
99+
'errmsg'=> 'autoresponder_end_date_isgreater'),
100+
),
101+
),
102+
##################################
103+
# END Datatable fields
104+
##################################
105+
)
106+
);
107+
108+
109+
?>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?php
2+
3+
/*
4+
Form Definition
5+
6+
Tabledefinition
7+
8+
Datatypes:
9+
- INTEGER (Forces the input to Int)
10+
- DOUBLE
11+
- CURRENCY (Formats the values to currency notation)
12+
- VARCHAR (no format check, maxlength: 255)
13+
- TEXT (no format check)
14+
- DATE (Dateformat, automatic conversion to timestamps)
15+
16+
Formtype:
17+
- TEXT (Textfield)
18+
- TEXTAREA (Textarea)
19+
- PASSWORD (Password textfield, input is not shown when edited)
20+
- SELECT (Select option field)
21+
- RADIO
22+
- CHECKBOX
23+
- CHECKBOXARRAY
24+
- FILE
25+
26+
VALUE:
27+
- Wert oder Array
28+
29+
Hint:
30+
The ID field of the database table is not part of the datafield definition.
31+
The ID field must be always auto incement (int or bigint).
32+
33+
34+
*/
35+
36+
$form["title"] = "mailbox_cc_txt";
37+
$form["description"] = "";
38+
$form["name"] = "mail_user_cc";
39+
$form["action"] = "mail_user_cc_edit.php";
40+
$form["db_table"] = "mail_user";
41+
$form["db_table_idx"] = "mailuser_id";
42+
$form["db_history"] = "yes";
43+
$form["tab_default"] = "mailuser";
44+
$form["list_default"] = "index.php";
45+
$form["auth"] = 'no'; // yes / no
46+
47+
$form["auth_preset"]["userid"] = 0; // 0 = id of the user, > 0 id must match with id of current user
48+
$form["auth_preset"]["groupid"] = 0; // 0 = default groupid of the user, > 0 id must match with groupid of current user
49+
$form["auth_preset"]["perm_user"] = 'riud'; //r = read, i = insert, u = update, d = delete
50+
$form["auth_preset"]["perm_group"] = 'riud'; //r = read, i = insert, u = update, d = delete
51+
$form["auth_preset"]["perm_other"] = ''; //r = read, i = insert, u = update, d = delete
52+
53+
$form["tabs"]['mailuser'] = array (
54+
'title' => "cc_txt",
55+
'width' => 100,
56+
'template' => "templates/mail_user_cc_edit.htm",
57+
'fields' => array (
58+
##################################
59+
# Begin Datatable fields
60+
##################################
61+
'cc' => array (
62+
'datatype' => 'VARCHAR',
63+
'formtype' => 'TEXT',
64+
'validators' => array ( 0 => array ( 'type' => 'REGEX',
65+
'regex' => '/^(\w+[\w\.\-\+]*\w{0,}@\w+[\w.-]*\w+\.[a-z\-]{2,10}){0,1}$/i',
66+
'errmsg'=> 'cc_error_isemail'),
67+
),
68+
'default' => '',
69+
'value' => '',
70+
'width' => '30',
71+
'maxlength' => '255'
72+
),
73+
##################################
74+
# END Datatable fields
75+
##################################
76+
)
77+
);
78+
79+
80+
?>

0 commit comments

Comments
 (0)