f12aba6daa6e2848a8ed60ea57b26874d6675f52
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");
18) require_once("inc/db_connect.php");
bernd input-filtering

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

22) 
23) function get_jabber_accounts() {
24)   require_role(ROLE_CUSTOMER);
25)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
bernd Zeige letzte Aktivität bei...

bernd authored 12 years ago

26)   $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

27)   $accounts = array();
28)   if (@mysql_num_rows($result) > 0)
bernd Zeige letzte Aktivität bei...

bernd authored 12 years ago

29)     while ($acc = @mysql_fetch_assoc($result))
30)       array_push($accounts, $acc);
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

31)   return $accounts;
32) }
33) 
34) 
35) 
36) function get_jabberaccount_details($id)
37) {
38)   require_role(ROLE_CUSTOMER);
39)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
40) 
41)   $id = (int) $id;
42) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

43)   $result = db_query("SELECT id, local, domain FROM jabber.accounts WHERE customerno={$customerno} AND id={$id} LIMIT 1");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

44)   if (mysql_num_rows($result) != 1)
45)     system_failure("Invalid account");
46)   $data = mysql_fetch_assoc($result);
bernd Parse Error, hatte ich gar...

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 14 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

69) 
70) function create_jabber_account($local, $domain, $password)
71) {
72)   require_role(ROLE_CUSTOMER);
73)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
74) 
bernd input-filtering

bernd authored 16 years ago

75)   $local = mysql_real_escape_string( filter_input_username($local) );
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

80)     return;
81)   }
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

82)   $password = mysql_real_escape_string( $password );
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

bernd authored 16 years ago

86)     $result = db_query("SELECT id FROM kundendaten.domains WHERE kunde={$customerno} AND jabber=1 AND id={$domain};");
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

87)     if (mysql_num_rows($result) == 0)
88)     {
bernd Logger mit Logleveln

bernd authored 14 years ago

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

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

bernd authored 16 years ago

94)   $domainquery = "domain={$domain}";
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

bernd authored 16 years ago

96)   {
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

97)     $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 sql-abfragen abstrahiert

bernd authored 16 years ago

100)   $result = db_query("SELECT id FROM jabber.accounts WHERE local='{$local}' AND {$domainquery}");
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

101)   if (mysql_num_rows($result) > 0)
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 sql-abfragen abstrahiert

bernd authored 16 years ago

107)   db_query("INSERT INTO jabber.accounts (customerno,local,domain,password) VALUES ({$customerno}, '{$local}', {$domain}, '{$password}');");
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);
116)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
117)   $id = (int) $id;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

121)     return;
122)   }
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

123)   $password = mysql_real_escape_string( $password );
bernd Jabber-Passwort ändern

bernd authored 16 years ago

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

bernd authored 16 years ago

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

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);
134)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
135) 
136)   $id = (int) $id;
137) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

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();
147)   db_query("UPDATE kundendaten.domains SET jabber=2 WHERE jabber=0 AND id={$d->id} LIMIT 1");
148) }
149) 
150)