a5753affaccb6fabc7a0de0b2451fa0101d84f7e
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) {
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.'%';
Bernd Wurst remove obsolete code

Bernd Wurst 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", array('uid' => $uid, 'filter' => $filter));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

29)     } else {
Bernd Wurst remove obsolete code

Bernd Wurst 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", array('uid' => $uid));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

31)     }
32)     $ret = array();
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 Fix coding style with php-c...

Hanno authored 6 years ago

43)     $args = array(":id" => $id,
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

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 Fix coding style with php-c...

Hanno authored 6 years ago

58)     $args = array(":id" => $id,
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

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 Fix coding style with php-c...

Hanno authored 6 years ago

65)     $args = array(":id" => $id,
Bernd Wurst Ermögliche das Rücksetzen d...

Bernd Wurst authored 7 years ago

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);
74)     if (in_array($listname, array("admin", "administrator", "webmaster", "hostmaster", "postmaster"))) {
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 Fix coding style with php-c...

Hanno authored 6 years ago

81)     $result = db_query("SELECT id FROM mail.mailman_lists WHERE listname LIKE ?", array($listname));
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) 
86)     $args = array(":listname" => $listname,
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

87)                 ":maildomain" => $maildomain,
88)                 ":owner" => $_SESSION['userinfo']['uid'],
89)                 ":admin" => $admin);
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 4 years ago

95) function get_possible_mailmandomains()
96) {
97)     DEBUG('get_possible_mailmandomains()');
98)     $uid = (int) $_SESSION['userinfo']['uid'];
Bernd Wurst basic mailman3 support (no...

Bernd Wurst 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)", array(":uid" => $uid));
Bernd Wurst Erstelle Mailinglisten-Doma...

Bernd Wurst authored 4 years ago

100)     $ret = array();
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 4 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 4 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)     }
Bernd Wurst basic mailman3 support (no...

Bernd Wurst authored 3 years ago

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

Bernd Wurst authored 4 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 4 years ago

127) function lists_on_domain($domainid)
128) {
129)     DEBUG("lists_on_domain()");
Bernd Wurst remove obsolete code

Bernd Wurst 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=?)", array($domainid));
Bernd Wurst Funktion zum Löschen einer...

Bernd Wurst authored 4 years ago

131)     $ret = array();
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 {
146)         db_query("DELETE FROM mail.mailman_domains WHERE domain=? AND (SELECT COUNT(*) FROM mail.mailman_lists WHERE maildomain=mail.mailman_domains.id)=0;", array($domainid));
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 4 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'];
Bernd Wurst basic mailman3 support (no...

Bernd Wurst 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=?", array($uid));
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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