This repository has been archived by the owner on Aug 3, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathregexp.php
87 lines (79 loc) · 2.74 KB
/
regexp.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
<?php
include('./inc/_prepend.php');
include('./inc/panel_filter.php');
$oma->current_user->domain_set = $oma->get_domain_set($oma->current_user->mbox, $oma->current_user->domains);
$oma->current_user->used_regexp = $oma->user_get_used_regexp($oma->current_user->mbox);
// PERFORM ACTION
if(isset($_POST['frm']) && $_POST['frm'] == 'virtual_regexp') {
if(!isset($_POST['action'])) {
error(txt('112'));
} else {
if($oma->current_user->max_regexp != 0 && $oma->authenticated_user->max_regexp != 0) {
if($_POST['action'] == 'new' || $_POST['action'] == 'dest') {
// Set at least one valid destination.
if(isset($_POST['dest_is_mbox']) && $_POST['dest_is_mbox'] == '1') {
$destination = array($oma->current_user->mbox);
} else {
$destination = $oma->get_valid_destinations($_POST['dest']);
if(count($destination) < 1) {
$destination = array($oma->current_user->mbox);
error(txt('10'));
}
}
}
// On every action except 'new' and 'probe' at least one expression
// must be selected for manipulation and thus $_POST['expr'] be an array.
if($_POST['action'] != 'new' && $_POST['action'] != 'probe'
&& !(isset($_POST['expr']) && is_array($_POST['expr']))) {
error(txt('11'));
} else {
switch($_POST['action']) {
case 'new':
$oma->regexp_create(trim($_POST['reg_exp']), $destination);
break;
case 'delete':
$oma->regexp_delete($_POST['expr']);
break;
case 'dest':
$oma->regexp_change_destination($_POST['expr'], $destination);
break;
case 'active':
$oma->regexp_toggle_active($_POST['expr']);
break;
}
if($ErrorHandler->errors_occured()) {
error($ErrorHandler->errors_get());
}
if($ErrorHandler->info_occured()) {
info($ErrorHandler->info_get());
}
}
if(isset($destination)) unset($destination);
} else {
error(txt('16'));
}
}
}
// DATA
// We need to determine whether an string for matching shall be provided.
if(isset($_POST['frm']) && isset($_POST['action'])
&& $_POST['frm'] == 'virtual_regexp' && $_POST['action'] == 'probe') {
$regexp = $oma->get_regexp($_POST['probe']);
} else {
$regexp = $oma->get_regexp();
}
// DISPLAY
include('./templates/'.$cfg['theme'].'/regexp/list.tpl');
// ADMIN PANEL
if($oma->current_user->max_regexp != 0 && $oma->authenticated_user->max_regexp != 0) {
// This is the action handler for 'probing'.
if(isset($_POST['frm']) && isset($_POST['action'])
&& $_POST['frm'] == 'virtual_regexp' && $_POST['action'] == 'probe'
&& trim($_POST['reg_exp']) != '' && trim($_POST['probe']) != ''
&& @preg_match($_POST['reg_exp'], $_POST['probe'])) {
info(txt('36'));
}
include('./templates/'.$cfg['theme'].'/regexp/admin.tpl');
}
include('./inc/_append.php');
?>