63a0529b21bfd97a4ef395e8d3d3f513526357c6
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

1) <?php
2) 
3) require_once("inc/debug.php");
4) require_once("inc/db_connect.php");
bernd input-filtering

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

8) 
9) function get_jabber_accounts() {
10)   require_role(ROLE_CUSTOMER);
11)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

bernd authored 16 years ago

13)   $accounts = array();
14)   if (@mysql_num_rows($result) > 0)
15)     while ($acc = @mysql_fetch_object($result))
16)       array_push($accounts, array('id'=> $acc->id, 'created' => $acc->created, 'local' => $acc->local, 'domain' => $acc->domain));
17)   return $accounts;
18) }
19) 
20) 
21) 
22) function get_jabberaccount_details($id)
23) {
24)   require_role(ROLE_CUSTOMER);
25)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
26) 
27)   $id = (int) $id;
28) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

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

bernd authored 16 years ago

33)   if ($data['domain'] == NULL)
34)     $data['domain'] = 'schokokeks.org';
35)   else
36)   {
37)     $dom = new Domain((int) $data['domain']);
38)     $data['domain'] = $dom->fqdn;
39)   }
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

40)   return $data;
41) }
42) 
43) 
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

44) function valid_jabber_password($pass)
45) {
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

50)   */
51)   return true;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

52) }
53) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

54) 
55) function create_jabber_account($local, $domain, $password)
56) {
57)   require_role(ROLE_CUSTOMER);
58)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
59) 
bernd input-filtering

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

65)     return;
66)   }
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

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

bernd authored 16 years ago

68)   
69)   if ($domain > 0)
70)   {
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

72)     if (mysql_num_rows($result) == 0)
73)     {
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

75)       system_failure("Invalid domain!");
76)     }
77)   }
78) 
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

84)   }
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

bernd authored 16 years ago

86)   if (mysql_num_rows($result) > 0)
87)   {
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

91) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

92)   db_query("INSERT INTO jabber.accounts (customerno,local,domain,password) VALUES ({$customerno}, '{$local}', {$domain}, '{$password}');");
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

94) }
95) 
96) 
bernd Jabber-Passwort ändern

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

99) {
100)   require_role(ROLE_CUSTOMER);
101)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
102)   $id = (int) $id;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

106)     return;
107)   }
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

110)   db_query("UPDATE jabber.accounts SET password='{$password}' WHERE customerno={$customerno} AND id={$id} LIMIT 1");
bernd eliminate .php extensions f...

bernd authored 15 years ago

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

bernd authored 16 years ago

112) }
113) 
114) 
115) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

116) function delete_jabber_account($id)
117) {
118)   require_role(ROLE_CUSTOMER);
119)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
120) 
121)   $id = (int) $id;
122) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

123)   db_query("UPDATE jabber.accounts SET `delete`=1 WHERE customerno={$customerno} AND id={$id} LIMIT 1");
bernd eliminate .php extensions f...

bernd authored 15 years ago

124)   logger("modules/jabber/include/jabberaccounts", "jabber", "deleted account »{$id}«");