c42127d3cab5c78430e578a07038f54f8cdff459
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) 
94) 
95) function get_mailman_domains()
96) {
Hanno Fix coding style with php-c...

Hanno authored 6 years ago

97)     $uid = (int) $_SESSION['userinfo']['uid'];
98)     $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));
99)     $ret = array();
100)     while ($dom = $result->fetch()) {
101)         $ret[] = $dom;
102)     }
103)     DEBUG($ret);
104)     return $ret;