1a3cabbe732725e943f9991c2e5266ec23768389
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 Anführungszeichen filtern

bernd authored 16 years ago

47)   $foo = ereg_replace('["\']', '', $pass);
48)   DEBUG("\$foo = {$foo} / \$pass = {$pass}");
49)   return ($foo == $pass);
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

50) }
51) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

60)   if (! valid_jabber_password($password))
61)     input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

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

bernd authored 16 years ago

63)   
64)   if ($domain > 0)
65)   {
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

67)     if (mysql_num_rows($result) == 0)
68)     {
bernd Logging in allen Modulen

bernd authored 16 years ago

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

bernd authored 16 years ago

70)       system_failure("Invalid domain!");
71)     }
72)   }
73) 
bernd Duplikate-Problem gefixed....

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

79)   }
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

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

bernd authored 16 years ago

81)   if (mysql_num_rows($result) > 0)
82)   {
bernd Logging in allen Modulen

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

86) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

87)   db_query("INSERT INTO jabber.accounts (customerno,local,domain,password) VALUES ({$customerno}, '{$local}', {$domain}, '{$password}');");
bernd Logging in allen Modulen

bernd authored 16 years ago

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

bernd authored 16 years ago

89) }
90) 
91) 
bernd Jabber-Passwort ändern

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

94) {
95)   require_role(ROLE_CUSTOMER);
96)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
97)   $id = (int) $id;
bernd erlaube Jabber-Passwörter m...

bernd authored 16 years ago

98)   if (! valid_jabber_password($password))
99)     input_error('Das Passwort enthält Zeichen, die aufgrund technischer Beschränkungen momentan nicht benutzt werden können.');
bernd htmlspecialchars ist nicht...

bernd authored 16 years ago

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

bernd authored 16 years ago

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

bernd authored 16 years ago

102)   db_query("UPDATE jabber.accounts SET password='{$password}' WHERE customerno={$customerno} AND id={$id} LIMIT 1");
bernd Logging in allen Modulen

bernd authored 16 years ago

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

bernd authored 16 years ago

104) }
105) 
106) 
107) 
bernd Neues Jabber-Modul (noch ni...

bernd authored 16 years ago

108) function delete_jabber_account($id)
109) {
110)   require_role(ROLE_CUSTOMER);
111)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
112) 
113)   $id = (int) $id;
114) 
bernd sql-abfragen abstrahiert

bernd authored 16 years ago

115)   db_query("UPDATE jabber.accounts SET `delete`=1 WHERE customerno={$customerno} AND id={$id} LIMIT 1");
bernd Logging in allen Modulen

bernd authored 16 years ago

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