5effc2bd7685822df276c1372dab480cff321941
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 Lizenzinfos in eigenes Modu...

Bernd Wurst authored 10 years ago

5) Written 2008-2014 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) 
11) You should have received a copy of the CC0 Public Domain Dedication along with this software. If not, see 
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) 
22) function get_jabber_accounts() {
23)   require_role(ROLE_CUSTOMER);
24)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

25)   $result = db_query("SELECT id, `create`, created, lastactivity, local, domain FROM jabber.accounts WHERE customerno=? AND `delete`=0", array($customerno));
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

26)   $accounts = array();
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

27)   if (@$result->rowCount() > 0)
28)     while ($acc = @$result->fetch())
bernd Zeige letzte Aktivität bei...

bernd authored 12 years ago

29)       array_push($accounts, $acc);
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

30)   return $accounts;
31) }
32) 
33) 
34) 
35) function get_jabberaccount_details($id)
36) {
37)   require_role(ROLE_CUSTOMER);
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

38)   $args = array(":customerno" => $_SESSION['customerinfo']['customerno'],
39)                 ":id" => $id);
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

40) 
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

41)   $result = db_query("SELECT id, local, domain FROM jabber.accounts WHERE customerno=:customerno AND id=:id", $args);
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

42)   if ($result->rowCount() != 1)
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

43)     system_failure("Invalid account");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

44)   $data = $result->fetch();
bernd Parse Error, hatte ich gar...

bernd authored 16 years ago

45)   if ($data['domain'] == NULL)
bernd Mehr config-optionen und co...

bernd authored 14 years ago

46)     $data['domain'] = config('masterdomain');
bernd Parse Error, hatte ich gar...

bernd authored 16 years ago

47)   else
48)   {
49)     $dom = new Domain((int) $data['domain']);
bernd Prüfe, ob Domain wirklich d...

bernd authored 14 years ago

50)     $dom->ensure_customerdomain();
bernd Parse Error, hatte ich gar...

bernd authored 16 years ago

51)     $data['domain'] = $dom->fqdn;
52)   }
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

53)   return $data;
54) }
55) 
56) 
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

57) function valid_jabber_password($pass)
58) {
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

59)   // Hier könnten erweiterte Checks stehen wenn nötig.
bernd stripslashes und erlaube An...

bernd authored 16 years ago

60)   /*$foo = ereg_replace('["\']', '', $pass);
bernd Anführungszeichen filtern

bernd authored 16 years ago

61)   DEBUG("\$foo = {$foo} / \$pass = {$pass}");
62)   return ($foo == $pass);
bernd stripslashes und erlaube An...

bernd authored 16 years ago

63)   */
64)   return true;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

65) }
66) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

67) 
68) function create_jabber_account($local, $domain, $password)
69) {
70)   require_role(ROLE_CUSTOMER);
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

71)   $data = array(":customerno" => $_SESSION['customerinfo']['customerno'],
72)                 ":local" => filter_input_username($local),
73)                 ":domain" => $domain);
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

74)   if (! valid_jabber_password($password))
bernd Bei falschen Daten auch abb...

bernd authored 16 years ago

75)   {
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

76)     input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
bernd Bei falschen Daten auch abb...

bernd authored 16 years ago

77)     return;
78)   }
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

79)   $data[':password'] = $password;
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

80)   
81)   if ($domain > 0)
82)   {
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

83)     $args = array(":domain" => $data[":domain"], ":customerno" => $data[":customerno"]);
84)     $result = db_query("SELECT id FROM kundendaten.domains WHERE kunde=:customerno AND jabber=1 AND id=:domain", $args);
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

85)     if ($result->rowCount() == 0)
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

86)     {
bernd Logger mit Logleveln

bernd authored 14 years ago

87)       logger(LOG_WARNING, "modules/jabber/include/jabberaccounts", "jabber", "attempt to create account for invalid domain »{$domain}«");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

88)       system_failure("Invalid domain!");
89)     }
90)   }
91) 
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

92)   $args = array(":domain" => $data[":domain"], ":local" => $data[":local"]);
93)   $domainquery = "domain=:domain";
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

94)   if ($domain == 0)
bernd Ich hasse PHP

bernd authored 16 years ago

95)   {
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

96)     unset($args[":domain"]);
97)     $data[":domain"] = NULL;
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

98)     $domainquery = 'domain IS NULL'; 
bernd Ich hasse PHP

bernd authored 16 years ago

99)   }
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

100)   $result = db_query("SELECT id FROM jabber.accounts WHERE local=:local AND {$domainquery}", $args);
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

101)   if ($result->rowCount() > 0)
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

102)   {
bernd Logger mit Logleveln

bernd authored 14 years ago

103)     logger(LOG_WARNING, "modules/jabber/include/jabberaccounts", "jabber", "attempt to create already existing account »{$local}@{$domain}«");
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

104)     system_failure("Diesen Account gibt es bereits!");
105)   }
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

106) 
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

107)   db_query("INSERT INTO jabber.accounts (customerno,local,domain,password) VALUES (:customerno, :local, :domain, :password);", $data);
bernd Logger mit Logleveln

bernd authored 14 years ago

108)   logger(LOG_INFO, "modules/jabber/include/jabberaccounts", "jabber", "created account »{$local}@{$domain}«");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

109) }
110) 
111) 
bernd Jabber-Passwort ändern

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

114) {
115)   require_role(ROLE_CUSTOMER);
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

116)   if (! valid_jabber_password($password))
bernd Bei falschen Daten auch abb...

bernd authored 16 years ago

117)   {
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

118)     input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
bernd Bei falschen Daten auch abb...

bernd authored 16 years ago

119)     return;
120)   }
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

121)   $args = array(":customerno" => $_SESSION['customerinfo']['customerno'],
122)                 ":id" => $id,
123)                 ":password" => $password);
bernd Jabber-Passwort ändern

bernd authored 16 years ago

124)   
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

125)   db_query("UPDATE jabber.accounts SET password=:password WHERE customerno=:customerno AND id=:id", $args);
bernd Logger mit Logleveln

bernd authored 14 years ago

126)   logger(LOG_INFO, "modules/jabber/include/jabberaccounts", "jabber", "changed password for account  »{$id}«");
bernd Jabber-Passwort ändern

bernd authored 16 years ago

127) }
128) 
129) 
130) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

131) function delete_jabber_account($id)
132) {
133)   require_role(ROLE_CUSTOMER);
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

134)   
135)   $args = array(":customerno" => $_SESSION['customerinfo']['customerno'],
136)                 ":id" => $id);
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

137) 
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

138)   db_query("UPDATE jabber.accounts SET `delete`=1 WHERE customerno=:customerno AND id=:id", $args);
bernd Logger mit Logleveln

bernd authored 14 years ago

139)   logger(LOG_INFO, "modules/jabber/include/jabberaccounts", "jabber", "deleted account »{$id}«");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

140) }
141) 
bernd Neue Jabber-Domains selbst...

bernd authored 14 years ago

142) 
143) function new_jabber_domain($id)
144) {
145)   $d = new Domain( (int) $id );
146)   $d->ensure_customerdomain();
Bernd Wurst Weitere Umstellungen auf pr...

Bernd Wurst authored 10 years ago

147)   db_query("UPDATE kundendaten.domains SET jabber=2 WHERE jabber=0 AND id=?", array($d->id));
bernd Neue Jabber-Domains selbst...

bernd authored 14 years ago

148) }
149) 
150)