dcc202fb249a446ac15c7cf413b9f1b4a3f31b58
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

1) <?php
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

2) /*
3) This file belongs to the Webinterface of schokokeks.org Hosting
4) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

5) Written by schokokeks.org Hosting, namely
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

6)   Bernd Wurst <bernd@schokokeks.org>
7)   Hanno Böck <hanno@schokokeks.org>
8) 
Hanno Böck Change license from CC0 to...

Hanno Böck authored 2 years ago

9) This code is published under a 0BSD license.
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

10) 
11) Nevertheless, in case you use a significant part of this code, we ask (but not require, see the license) that you keep the authors' names in place and return your changes to the public. We would be especially happy if you tell us what you're going to do with this code.
12) */
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

13) 
14) require_once('inc/base.php');
15) require_once('inc/debug.php');
16) require_once('inc/security.php');
17) 
18) 
Bernd Wurst Mailman-Interface

Bernd Wurst authored 6 years ago

19) function get_lists($filter)
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

20) {
Bernd Wurst error handling

Bernd Wurst authored 2 years ago

21)     if (! isset($_SESSION['userinfo'])) {
22)         return [];
23)     }
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

24)     $uid = (int) $_SESSION['userinfo']['uid'];
25)     $result = null;
26)     if ($filter) {
27)         $filter = '%'.$filter.'%';
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

28)         $result = db_query("SELECT id, created, status, listname, fqdn, urlhost, admin, archivesize, subscribers, lastactivity, backend FROM mail.v_mailman_lists WHERE status!='deleted' AND owner=:uid AND (listname LIKE :filter OR fqdn LIKE :filter OR admin LIKE :filter) ORDER BY listname", ['uid' => $uid, 'filter' => $filter]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

29)     } else {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

30)         $result = db_query("SELECT id, created, status, listname, fqdn, urlhost, admin, archivesize, subscribers, lastactivity, backend FROM mail.v_mailman_lists WHERE status!='deleted' AND owner=:uid ORDER BY listname", ['uid' => $uid]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

31)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

32)     $ret = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

33)     while ($list = $result->fetch()) {
34)         $ret[] = $list;
35)     }
36)     DEBUG($ret);
37)     return $ret;
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

38) }
39) 
40) 
41) function get_list($id)
42) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

43)     $args = [":id" => $id,
44)                 ":uid" => $_SESSION['userinfo']['uid'], ];
Bernd Wurst basic mailman3 support (no...

Bernd Wurst authored 3 years ago

45)     $result = db_query("SELECT id, created, status, listname, fqdn, urlhost, admin, archivesize, subscribers, lastactivity, backend FROM mail.v_mailman_lists WHERE owner=:uid AND id=:id", $args);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

46)     if ($result->rowCount() < 1) {
47)         system_failure('Die gewünschte Mailingliste konnte nicht gefunden werden');
48)     }
49)     $list = $result->fetch();
50)     DEBUG($list);
51) 
52)     return $list;
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

53) }
54) 
55) 
56) function delete_list($id)
57) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

58)     $args = [":id" => $id,
59)                 ":uid" => $_SESSION['userinfo']['uid'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

60)     db_query("UPDATE mail.mailman_lists SET status='delete' WHERE owner=:uid AND id=:id", $args);
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

61) }
62) 
Bernd Wurst Ermögliche das Rücksetzen d...

Bernd Wurst authored 7 years ago

63) function request_new_password($id)
64) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

65)     $args = [":id" => $id,
66)                 ":uid" => $_SESSION['userinfo']['uid'], ];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

67)     db_query("UPDATE mail.mailman_lists SET status='newpw' WHERE owner=:uid AND id=:id", $args);
Bernd Wurst Ermögliche das Rücksetzen d...

Bernd Wurst authored 7 years ago

68) }
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

69) 
70) function create_list($listname, $maildomain, $admin)
71) {
Bernd Wurst Mailman-Interface

Bernd Wurst authored 6 years ago

72)     $listname = strtolower($listname);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

73)     verify_input_username($listname);
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

74)     if (in_array($listname, ["admin", "administrator", "webmaster", "hostmaster", "postmaster"])) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

75)         system_failure('Der Mailinglistenname '.$listname.' ist unzulässig.');
76)     }
77)     if (! check_emailaddr($admin)) {
78)         system_failure('Der Verwalter muss eine gültige E-Mail-Adresse sein ('.$admin.').');
79)     }
Bernd Wurst basic mailman3 support (no...

Bernd Wurst authored 3 years ago

80)     # FIXME: Zukünftig soll diese Beschränkung weg fallen!
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

81)     $result = db_query("SELECT id FROM mail.mailman_lists WHERE listname LIKE ?", [$listname]);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

82)     if ($result->rowCount() > 0) {
83)         system_failure('Eine Liste mit diesem Namen existiert bereits auf unserem Mailinglisten-Server (unter einer Ihrer Domains oder unter einer Domain eines anderen Kunden). Jeder Listenname kann auf dem gesamten Server nur einmal verwendet werden.');
84)     }
85) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

86)     $args = [":listname" => $listname,
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

87)                 ":maildomain" => $maildomain,
88)                 ":owner" => $_SESSION['userinfo']['uid'],
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

89)                 ":admin" => $admin, ];
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

90) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

91)     db_query("INSERT INTO mail.mailman_lists (status, listname, maildomain, owner, admin) VALUES ('pending', :listname, :maildomain, :owner, :admin)", $args);
92)     DEBUG('Neue ID: '.db_insert_id());
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

93) }
94) 
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 5 years ago

95) function get_possible_mailmandomains()
96) {
97)     DEBUG('get_possible_mailmandomains()');
98)     $uid = (int) $_SESSION['userinfo']['uid'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

99)     $result = db_query("SELECT d.id, CONCAT_WS('.',d.domainname,d.tld) AS fqdn, m.backend AS backend FROM kundendaten.domains AS d LEFT JOIN mail.mailman_domains AS m ON (m.domain=d.id) WHERE d.useraccount=:uid AND m.id IS NULL ORDER BY CONCAT_WS('.',d.domainname,d.tld)", [":uid" => $uid]);
100)     $ret = [];
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 5 years ago

101)     while ($dom = $result->fetch()) {
102)         $ret[] = $dom;
103)     }
104)     DEBUG($ret);
105)     return $ret;
106) }
107) 
108) 
Bernd Wurst basic mailman3 support (no...

Bernd Wurst authored 3 years ago

109) function insert_mailman_domain($subdomain, $domainid, $backend = 'mailman')
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 5 years ago

110) {
Bernd Wurst basic mailman3 support (no...

Bernd Wurst authored 3 years ago

111)     DEBUG("insert_mailman_domain($subdomain, $domainid, $backend)");
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 5 years ago

112)     $possible = get_possible_mailmandomains();
113)     $found = false;
114)     foreach ($possible as $dom) {
115)         if ($domainid == $dom['id']) {
116)             $found = true;
117)         }
118)     }
119)     if (! $found) {
120)         system_failue('invalid domain id');
121)     }
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

122)     db_query("INSERT INTO mail.mailman_domains (hostname, domain, backend) VALUES (:hostname, :domain, :backend)", [":hostname" => $subdomain, ":domain" => $domainid, ":backend" => $backend]);
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 5 years ago

123)     return db_insert_id();
124) }
125) 
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

126) 
Bernd Wurst Funktion zum Löschen einer...

Bernd Wurst authored 5 years ago

127) function lists_on_domain($domainid)
128) {
129)     DEBUG("lists_on_domain()");
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

130)     $result = db_query("SELECT id, listname FROM mail.mailman_lists WHERE status != 'delete' AND status != 'deleted' AND maildomain=(SELECT id FROM mail.mailman_domains WHERE domain=?)", [$domainid]);
131)     $ret = [];
Bernd Wurst Funktion zum Löschen einer...

Bernd Wurst authored 5 years ago

132)     while ($l = $result->fetch()) {
133)         $ret[] = $l;
134)     }
135)     return $ret;
136) }
137) 
138) 
139) function delete_mailman_domain($domainid)
140) {
141)     DEBUG("delete_mailman_domain()");
142)     $lists = lists_on_domain($domainid);
143)     if (count($lists) > 0) {
144)         system_failure("Es gibt noch Mailinglisten unter diesem Domainnamen, er kann daher nicht gelöscht werden");
145)     } else {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

146)         db_query("DELETE FROM mail.mailman_domains WHERE domain=? AND (SELECT COUNT(*) FROM mail.mailman_lists WHERE maildomain=mail.mailman_domains.id)=0;", [$domainid]);
Bernd Wurst Funktion zum Löschen einer...

Bernd Wurst authored 5 years ago

147)     }
148) }
149) 
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

150) function get_mailman_domains()
151) {
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 5 years ago

152)     DEBUG('get_mailman_domains()');
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

153)     $uid = (int) $_SESSION['userinfo']['uid'];
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

154)     $result = db_query("SELECT md.id, md.fqdn, md.is_webhost, md.backend FROM mail.v_mailman_domains AS md left join mail.v_domains AS d on (d.id=md.domain) where d.user=?", [$uid]);
155)     $ret = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

156)     while ($dom = $result->fetch()) {
157)         $ret[] = $dom;
158)     }
159)     DEBUG($ret);
160)     return $ret;