8e3107cd3a86994d92235cd8cdb94e1e59d840c0
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) 
Bernd Wurst Copyright year update

Bernd Wurst authored 6 years ago

5) Written 2008-2018 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) 
9) To the extent possible under law, the author(s) have dedicated all copyright and related and neighboring rights to this software to the public domain worldwide. This software is distributed without any warranty.
10) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see
Bernd Wurst Added license tags for CC0,...

Bernd Wurst authored 12 years ago

12) http://creativecommons.org/publicdomain/zero/1.0/
13) 
14) 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.
15) */
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

16) 
17) require_once('inc/base.php');
18) require_once('inc/debug.php');
19) require_once('inc/security.php');
20) 
21) 
Bernd Wurst Mailman-Interface

Bernd Wurst authored 6 years ago

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

bernd authored 15 years ago

23) {
Bernd Wurst error handling

Bernd Wurst authored 2 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

31)         $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

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

Hanno Böck authored 3 years ago

33)         $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

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

bernd authored 15 years ago

41) }
42) 
43) 
44) function get_list($id)
45) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 3 years ago

48)     $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

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

bernd authored 15 years ago

56) }
57) 
58) 
59) function delete_list($id)
60) {
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

63)     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

64) }
65) 
Bernd Wurst Ermögliche das Rücksetzen d...

Bernd Wurst authored 7 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

70)     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

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

bernd authored 15 years ago

72) 
73) function create_list($listname, $maildomain, $admin)
74) {
Bernd Wurst Mailman-Interface

Bernd Wurst authored 6 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

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

Hanno authored 6 years ago

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

Bernd Wurst authored 3 years ago

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

Hanno Böck authored 3 years ago

84)     $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

85)     if ($result->rowCount() > 0) {
86)         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.');
87)     }
88) 
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno Böck authored 3 years ago

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

Bernd Wurst authored 10 years ago

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

Hanno authored 6 years ago

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

bernd authored 15 years ago

96) }
97) 
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 4 years ago

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

Hanno Böck authored 3 years ago

102)     $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]);
103)     $ret = [];
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 4 years ago

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

Bernd Wurst authored 3 years ago

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

Bernd Wurst authored 4 years ago

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

Bernd Wurst authored 3 years ago

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

Bernd Wurst authored 4 years ago

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

Hanno Böck authored 3 years ago

125)     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 4 years ago

126)     return db_insert_id();
127) }
128) 
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

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

Bernd Wurst authored 4 years ago

130) function lists_on_domain($domainid)
131) {
132)     DEBUG("lists_on_domain()");
Hanno Böck Codingstyle PSR12 + array s...

Hanno Böck authored 3 years ago

133)     $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]);
134)     $ret = [];
Bernd Wurst Funktion zum Löschen einer...

Bernd Wurst authored 4 years ago

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

Hanno Böck authored 3 years ago

149)         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 4 years ago

150)     }
151) }
152) 
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

153) function get_mailman_domains()
154) {
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 4 years ago

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

Hanno authored 6 years ago

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

Hanno Böck authored 3 years ago

157)     $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]);
158)     $ret = [];
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

159)     while ($dom = $result->fetch()) {
160)         $ret[] = $dom;
161)     }
162)     DEBUG($ret);
163)     return $ret;