51e1fd485f13c8f4eccaf41fa136a148f51330f5
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 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 5 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 Jabber-Modul (noch ni...

bernd authored 16 years ago

16) 
17) require_once("inc/debug.php");
bernd input-filtering

bernd authored 16 years ago

18) require_once("inc/security.php");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

19) 
bernd Parse Error, hatte ich gar...

bernd authored 16 years ago

20) require_once('class/domain.php');
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

Hanno authored 5 years ago

22) function get_jabber_accounts()
23) {
24)     require_role(ROLE_CUSTOMER);
25)     $customerno = (int) $_SESSION['customerinfo']['customerno'];
26)     $result = db_query("SELECT id, `create`, created, lastactivity, local, domain FROM jabber.accounts WHERE customerno=? AND `delete`=0", array($customerno));
27)     $accounts = array();
28)     if (@$result->rowCount() > 0) {
29)         while ($acc = @$result->fetch()) {
30)             array_push($accounts, $acc);
31)         }
32)     }
33)     return $accounts;
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

34) }
35) 
36) 
37) 
38) function get_jabberaccount_details($id)
39) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

40)     require_role(ROLE_CUSTOMER);
41)     $args = array(":customerno" => $_SESSION['customerinfo']['customerno'],
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

42)                 ":id" => $id);
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

Hanno authored 5 years ago

44)     $result = db_query("SELECT id, local, domain FROM jabber.accounts WHERE customerno=:customerno AND id=:id", $args);
45)     if ($result->rowCount() != 1) {
46)         system_failure("Invalid account");
47)     }
48)     $data = $result->fetch();
49)     if ($data['domain'] == null) {
50)         $data['domain'] = config('masterdomain');
51)     } else {
52)         $dom = new Domain((int) $data['domain']);
53)         $dom->ensure_customerdomain();
54)         $data['domain'] = $dom->fqdn;
55)     }
56)     return $data;
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

57) }
58) 
59) 
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

60) function valid_jabber_password($pass)
61) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

62)     // Hier könnten erweiterte Checks stehen wenn nötig.
63)     /*$foo = ereg_replace('["\']', '', $pass);
64)     DEBUG("\$foo = {$foo} / \$pass = {$pass}");
65)     return ($foo == $pass);
66)     */
67)     return true;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

68) }
69) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

70) 
71) function create_jabber_account($local, $domain, $password)
72) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

73)     require_role(ROLE_CUSTOMER);
74)     $data = array(":customerno" => $_SESSION['customerinfo']['customerno'],
Bernd Wurst Jabber-accounts immer lower...

Bernd Wurst authored 5 years ago

75)                 ":local" => filter_input_username(strtolower($local)),
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

76)                 ":domain" => $domain);
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

77)     if (! valid_jabber_password($password)) {
78)         input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
79)         return;
80)     }
81)     $data[':password'] = $password;
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

83)     if ($domain > 0) {
84)         $args = array(":domain" => $data[":domain"], ":customerno" => $data[":customerno"]);
85)         $result = db_query("SELECT id FROM kundendaten.domains WHERE kunde=:customerno AND jabber=1 AND id=:domain", $args);
86)         if ($result->rowCount() == 0) {
87)             logger(LOG_WARNING, "modules/jabber/include/jabberaccounts", "jabber", "attempt to create account for invalid domain »{$domain}«");
88)             system_failure("Invalid domain!");
89)         }
90)     }
91) 
92)     $args = array(":domain" => $data[":domain"], ":local" => $data[":local"]);
93)     $domainquery = "domain=:domain";
94)     if ($domain == 0) {
95)         unset($args[":domain"]);
96)         $data[":domain"] = null;
97)         $domainquery = 'domain IS NULL';
98)     }
99)     $result = db_query("SELECT id FROM jabber.accounts WHERE local=:local AND {$domainquery}", $args);
100)     if ($result->rowCount() > 0) {
101)         logger(LOG_WARNING, "modules/jabber/include/jabberaccounts", "jabber", "attempt to create already existing account »{$local}@{$domain}«");
102)         system_failure("Diesen Account gibt es bereits!");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

103)     }
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

104) 
105)     db_query("INSERT INTO jabber.accounts (customerno,local,domain,password) VALUES (:customerno, :local, :domain, :password);", $data);
106)     logger(LOG_INFO, "modules/jabber/include/jabberaccounts", "jabber", "created account »{$local}@{$domain}«");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

107) }
108) 
109) 
bernd Jabber-Passwort ändern

bernd authored 16 years ago

110) 
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

111) function change_jabber_password($id, $password)
bernd Jabber-Passwort ändern

bernd authored 16 years ago

112) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

113)     require_role(ROLE_CUSTOMER);
114)     if (! valid_jabber_password($password)) {
115)         input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
116)         return;
117)     }
118)     $args = array(":customerno" => $_SESSION['customerinfo']['customerno'],
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

119)                 ":id" => $id,
120)                 ":password" => $password);
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

122)     db_query("UPDATE jabber.accounts SET password=:password WHERE customerno=:customerno AND id=:id", $args);
123)     logger(LOG_INFO, "modules/jabber/include/jabberaccounts", "jabber", "changed password for account  »{$id}«");
bernd Jabber-Passwort ändern

bernd authored 16 years ago

124) }
125) 
126) 
127) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

128) function delete_jabber_account($id)
129) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

130)     require_role(ROLE_CUSTOMER);
Hanno remove whitespace in empty...

Hanno authored 5 years ago

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

Hanno authored 5 years ago

132)     $args = array(":customerno" => $_SESSION['customerinfo']['customerno'],
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

133)                 ":id" => $id);
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

Hanno authored 5 years ago

135)     db_query("UPDATE jabber.accounts SET `delete`=1 WHERE customerno=:customerno AND id=:id", $args);
136)     logger(LOG_INFO, "modules/jabber/include/jabberaccounts", "jabber", "deleted account »{$id}«");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

137) }
138) 
bernd Neue Jabber-Domains selbst...

bernd authored 14 years ago

139) 
140) function new_jabber_domain($id)
141) {
Hanno Fix coding style with php-c...

Hanno authored 5 years ago

142)     $d = new Domain((int) $id);
143)     $d->ensure_customerdomain();
144)     db_query("UPDATE kundendaten.domains SET jabber=2 WHERE jabber=0 AND id=?", array($d->id));