-
Notifications
You must be signed in to change notification settings - Fork 4
/
tiki-admin_mailin.php
134 lines (123 loc) · 3.92 KB
/
tiki-admin_mailin.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<?php
// (c) Copyright 2002-2012 by authors of the Tiki Wiki CMS Groupware Project
//
// All Rights Reserved. See copyright.txt for details and a complete list of authors.
// Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details.
// $Id: tiki-admin_mailin.php 40224 2012-03-17 09:29:15Z pkdille $
require_once ('tiki-setup.php');
include_once ('lib/mailin/mailinlib.php');
//check if feature is on
$access->check_feature('feature_mailin');
$access->check_permission(array('tiki_p_admin_mailin'));
function account_ok($pop, $user, $pass)
{
include_once ('lib/webmail/net_pop3.php');
$pop3 = new Net_POP3();
$pop3->connect($pop);
$pop3->login($user, $pass);
if (!$pop3) {
$pop3->disconnect();
return false;
} else {
$pop3->disconnect();
return true;
}
}
// Add a new mail account for the user here
if (!isset($_REQUEST['accountId'])) $_REQUEST['accountId'] = 0;
$smarty->assign('accountId', $_REQUEST['accountId']);
if (isset($_REQUEST['new_acc'])) {
check_ticket('admin-mailin');
if (!account_ok($_REQUEST['pop'], $_REQUEST['username'], $_REQUEST['pass'])) $tikifeedback[] = array(
'num' => 1,
'mes' => sprintf(tra('Mail-in account %s incorrect'), $_REQUEST['account'])
);
else {
$mailinlib->replace_mailin_account(
$_REQUEST['accountId'],
$_REQUEST['account'],
$_REQUEST['pop'],
$_REQUEST['port'],
$_REQUEST['username'],
$_REQUEST['pass'],
$_REQUEST['smtp'],
$_REQUEST['useAuth'],
$_REQUEST['smtpPort'],
$_REQUEST['type'],
$_REQUEST['active'],
$_REQUEST['anonymous'],
$_REQUEST['attachments'],
$_REQUEST['article_topicId'],
$_REQUEST['article_type'],
$_REQUEST['discard_after']
);
$tikifeedback[] = array(
'num' => 1,
'mes' => sprintf(tra('Mail-in account %s saved'), $_REQUEST['account'])
);
}
} else {
$smarty->assign('confirmation', 0);
}
if (isset($_REQUEST['remove'])) {
$access->check_authenticity();
$mailinlib->remove_mailin_account($_REQUEST['remove']);
}
if ($_REQUEST['accountId']) {
$info = $mailinlib->get_mailin_account($_REQUEST['accountId']);
} else {
$info['account'] = '';
$info['username'] = '';
$info['pass'] = '';
$info['pop'] = '';
$info['smtp'] = '';
$info['useAuth'] = 'n';
$info['port'] = 110;
$info['smtpPort'] = 25;
$info['type'] = 'article-put';
$info['active'] = 'y';
$info['anonymous'] = 'y';
$info['anonymous'] = 'y';
$info['attachments'] = 'n';
$info['article_topicId'] = '';
$info['article_type'] = '';
}
$smarty->assign('info', $info);
// List
$accounts = $mailinlib->list_mailin_accounts(0, -1, 'account_asc', '');
$smarty->assign('accounts', $accounts['data']);
if (isset($_REQUEST['mailin_autocheck'])) {
if ($_REQUEST['mailin_autocheck'] == 'y' && !(preg_match('/[0-9]+/', $_REQUEST['mailin_autocheckFreq']) && $_REQUEST['mailin_autocheckFreq'] > 0)) {
$smarty->assign('msg', tra('Frequency should be a positive integer!'));
$smarty->display('error.tpl');
die;
} else {
$tikilib->set_preference('mailin_autocheck', $_REQUEST['mailin_autocheck']);
$tikilib->set_preference('mailin_autocheckFreq', $_REQUEST['mailin_autocheckFreq']);
if ($prefs['mailin_autocheck'] == 'y') {
$tikifeedback[] = array(
'num' => 1,
'mes' => sprintf(tra('Mail-in accounts set to be checked every %s minutes'), $prefs['mailin_autocheckFreq'])
);
} else {
$tikifeedback[] = array(
'num' => 1,
'mes' => sprintf(tra('Automatic Mail-in accounts checking disabled'))
);
}
}
}
global $artlib;
if (!is_object($artlib)) {
include_once ('lib/articles/artlib.php');
}
$topics = $artlib->list_topics();
$smarty->assign_by_ref('topics', $topics);
$types = $artlib->list_types();
$smarty->assign_by_ref('types', $types);
$smarty->assign_by_ref('tikifeedback', $tikifeedback);
ask_ticket('admin-mailin');
// disallow robots to index page:
$smarty->assign('metatag_robots', 'NOINDEX, NOFOLLOW');
$smarty->assign('mid', 'tiki-admin_mailin.tpl');
$smarty->display('tiki.tpl');