b7d35c2b61e5bf5d45253b64382b1cc394bad6a6
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.'%';
28)         $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid AND (listname LIKE :filter OR fqdn LIKE :filter OR admin LIKE :filter) ORDER BY listname", array('uid' => $uid, 'filter' => $filter));
29)     } else {
30)         $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid ORDER BY listname", array('uid' => $uid));
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']);
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

45)     $result = db_query("SELECT id, created, status, listname, fqdn, admin, archivesize FROM mail.v_mailman_lists WHERE owner=:uid AND id=:id", $args);
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)     }
80)     $result = db_query("SELECT id FROM mail.mailman_lists WHERE listname LIKE ?", array($listname));
81)     if ($result->rowCount() > 0) {
82)         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.');
83)     }
84) 
85)     $args = array(":listname" => $listname,
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

86)                 ":maildomain" => $maildomain,
87)                 ":owner" => $_SESSION['userinfo']['uid'],
88)                 ":admin" => $admin);
89) 
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

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

bernd authored 15 years ago

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

Bernd Wurst authored 5 years ago

94) function get_possible_mailmandomains()
95) {
96)     DEBUG('get_possible_mailmandomains()');
97)     $uid = (int) $_SESSION['userinfo']['uid'];
98)     $result = db_query("SELECT d.id, CONCAT_WS('.',d.domainname,d.tld) AS fqdn 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));
99)     $ret = array();
100)     while ($dom = $result->fetch()) {
101)         $ret[] = $dom;
102)     }
103)     DEBUG($ret);
104)     return $ret;
105) }
106) 
107) 
108) function insert_mailman_domain($subdomain, $domainid)
109) {
110)     DEBUG("insert_mailman_domain($subdomain, $domainid)");
111)     $possible = get_possible_mailmandomains();
112)     $found = false;
113)     foreach ($possible as $dom) {
114)         if ($domainid == $dom['id']) {
115)             $found = true;
116)         }
117)     }
118)     if (! $found) {
119)         system_failue('invalid domain id');
120)     }
121)     db_query("INSERT INTO mail.mailman_domains (hostname, domain) VALUES (:hostname, :domain)", array(":hostname" => $subdomain, ":domain" => $domainid));
122)     return db_insert_id();
123) }
124) 
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

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

Bernd Wurst authored 5 years ago

126) function lists_on_domain($domainid)
127) {
128)     DEBUG("lists_on_domain()");
129)     $result = db_query("SELECT id, listname FROM mail.mailman_lists WHERE status != 'delete' AND maildomain=(SELECT id FROM mail.mailman_domains WHERE domain=?)", array($domainid));
130)     $ret = array();
131)     while ($l = $result->fetch()) {
132)         $ret[] = $l;
133)     }
134)     return $ret;
135) }
136) 
137) 
138) function delete_mailman_domain($domainid)
139) {
140)     DEBUG("delete_mailman_domain()");
141)     $lists = lists_on_domain($domainid);
142)     if (count($lists) > 0) {
143)         system_failure("Es gibt noch Mailinglisten unter diesem Domainnamen, er kann daher nicht gelöscht werden");
144)     } else {
145)         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));
146)     }
147) }
148) 
bernd Neues Modul für Mailman-Ver...

bernd authored 15 years ago

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

Bernd Wurst authored 5 years ago

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

Hanno authored 6 years ago

152)     $uid = (int) $_SESSION['userinfo']['uid'];
153)     $result = db_query("SELECT md.id, md.fqdn FROM mail.v_mailman_domains AS md left join mail.v_domains AS d on (d.id=md.domain) where d.user=?", array($uid));
154)     $ret = array();
155)     while ($dom = $result->fetch()) {
156)         $ret[] = $dom;
157)     }
158)     DEBUG($ret);
159)     return $ret;