f1f231f5e074dfa038e70a67d39849e80f2b4b4d
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 Updated copyright notice (2...

Bernd Wurst authored 11 years ago

5) Written 2008-2013 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 Zeige letzte Aktivität bei...

bernd authored 12 years ago

25)   $result = db_query("SELECT id, `create`, created, lastactivity, local, domain FROM jabber.accounts WHERE customerno='$customerno' AND `delete`=0;");
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);
38)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
39) 
40)   $id = (int) $id;
41) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

42)   $result = db_query("SELECT id, local, domain FROM jabber.accounts WHERE customerno={$customerno} AND id={$id} LIMIT 1");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

68) 
69) function create_jabber_account($local, $domain, $password)
70) {
71)   require_role(ROLE_CUSTOMER);
72)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
73) 
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

74)   $local = db_escape_string( filter_input_username($local) );
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

75)   $domain = (int) $domain;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

78)     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

79)     return;
80)   }
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

81)   $password = db_escape_string( $password );
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

82)   
83)   if ($domain > 0)
84)   {
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

85)     $result = db_query("SELECT id FROM kundendaten.domains WHERE kunde={$customerno} AND jabber=1 AND id={$domain};");
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

87)     {
bernd Logger mit Logleveln

bernd authored 14 years ago

88)       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

89)       system_failure("Invalid domain!");
90)     }
91)   }
92) 
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

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 Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

96)     $domain = 'NULL';
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

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

bernd authored 16 years ago

98)   }
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

Bernd Wurst authored 10 years ago

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

bernd authored 16 years ago

101)   {
bernd Logger mit Logleveln

bernd authored 14 years ago

102)     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

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

bernd authored 16 years ago

105) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

106)   db_query("INSERT INTO jabber.accounts (customerno,local,domain,password) VALUES ({$customerno}, '{$local}', {$domain}, '{$password}');");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

113) {
114)   require_role(ROLE_CUSTOMER);
115)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
116)   $id = (int) $id;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

119)     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

120)     return;
121)   }
Bernd Wurst Umstellung auf PDO-Datenban...

Bernd Wurst authored 10 years ago

122)   $password = db_escape_string( $password );
bernd Jabber-Passwort ändern

bernd authored 16 years ago

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

bernd authored 16 years ago

124)   db_query("UPDATE jabber.accounts SET password='{$password}' WHERE customerno={$customerno} AND id={$id} LIMIT 1");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

130) function delete_jabber_account($id)
131) {
132)   require_role(ROLE_CUSTOMER);
133)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
134) 
135)   $id = (int) $id;
136) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

137)   db_query("UPDATE jabber.accounts SET `delete`=1 WHERE customerno={$customerno} AND id={$id} LIMIT 1");
bernd Logger mit Logleveln

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

141) 
142) function new_jabber_domain($id)
143) {
144)   $d = new Domain( (int) $id );
145)   $d->ensure_customerdomain();
146)   db_query("UPDATE kundendaten.domains SET jabber=2 WHERE jabber=0 AND id={$d->id} LIMIT 1");
147) }
148) 
149)