17c7269a397f7686433bdeb475f39f487dc351aa
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");
5) 
6) 
7) 
8) function get_jabber_accounts() {
9)   require_role(ROLE_CUSTOMER);
10)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
11)   $query = "SELECT id, created, local, domain FROM jabber.accounts WHERE customerno='$customerno' AND `delete`=0;";
12)   DEBUG($query);
13)   $result = mysql_query($query);
14)   $accounts = array();
15)   if (@mysql_num_rows($result) > 0)
16)     while ($acc = @mysql_fetch_object($result))
17)       array_push($accounts, array('id'=> $acc->id, 'created' => $acc->created, 'local' => $acc->local, 'domain' => $acc->domain));
18)   return $accounts;
19) }
20) 
21) 
22) 
23) function get_jabberaccount_details($id)
24) {
25)   require_role(ROLE_CUSTOMER);
26)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
27) 
28)   $id = (int) $id;
29) 
30)   $query = "SELECT id, local, domain FROM jabber.accounts WHERE customerno={$customerno} AND id={$id} LIMIT 1";
31)   DEBUG($query);
32)   $result = mysql_query($query);
33)   if (mysql_num_rows($result) != 1)
34)     system_failure("Invalid account");
35)   $data = mysql_fetch_assoc($result);
36)   $data['domain'] = get_domain_name($data['domain']);
37)   return $data;
38) }
39) 
40) 
41) 
42) function create_jabber_account($local, $domain, $password)
43) {
44)   require_role(ROLE_CUSTOMER);
45)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
46) 
47)   $local = mysql_real_escape_string($local);
48)   $domain = (int) $domain;
49)   $password = mysql_real_escape_string($password);
50)   
51)   if ($domain > 0)
52)   {
53)     $query = "SELECT id FROM kundendaten.domains WHERE kunde={$customerno} AND jabber=1 AND id={$domain};";
54)     DEBUG($query);
55)     $result = mysql_query($query);
56)     if (mysql_num_rows($result) == 0)
57)     {
58)       system_failure("Invalid domain!");
59)     }
60)   }
61) 
62)   if ($domain == 0)
63)     $domain = 'NULL';
64) 
65)   $query = "INSERT INTO jabber.accounts (customerno,local,domain,password) VALUES ({$customerno}, '{$local}', {$domain}, '{$password}');";
66)   DEBUG($query);
67)   mysql_query($query);
68) }
69) 
70) 
bernd Jabber-Passwort ändern

bernd authored 16 years ago

71) 
72) function change_jabber_password($id, $newpass)
73) {
74)   require_role(ROLE_CUSTOMER);
75)   $customerno = (int) $_SESSION['customerinfo']['customerno'];
76)   $id = (int) $id;
77)   $newpass = mysql_real_escape_string($newpass);
78)   
79)   $query = "UPDATE jabber.accounts SET password='{$newpass}' WHERE customerno={$customerno} AND id={$id} LIMIT 1";
80)   DEBUG($query);
81)   mysql_query($query);
82) }
83) 
84) 
85)