<?php
require_once("inc/debug.php");
require_once("inc/db_connect.php");
require_once("inc/security.php");
function get_jabber_accounts() {
require_role(ROLE_CUSTOMER);
$customerno = (int) $_SESSION['customerinfo']['customerno'];
$result = db_query("SELECT id, created, local, domain FROM jabber.accounts WHERE customerno='$customerno' AND `delete`=0;");
$accounts = array();
if (@mysql_num_rows($result) > 0)
while ($acc = @mysql_fetch_object($result))
array_push($accounts, array('id'=> $acc->id, 'created' => $acc->created, 'local' => $acc->local, 'domain' => $acc->domain));
return $accounts;
}
function get_jabberaccount_details($id)
{
require_role(ROLE_CUSTOMER);
$customerno = (int) $_SESSION['customerinfo']['customerno'];
$id = (int) $id;
$result = db_query("SELECT id, local, domain FROM jabber.accounts WHERE customerno={$customerno} AND id={$id} LIMIT 1");
if (mysql_num_rows($result) != 1)
system_failure("Invalid account");
$data = mysql_fetch_assoc($result);
$data['domain'] = get_domain_name($data['domain']);
return $data;
}
function create_jabber_account($local, $domain, $password)
{
require_role(ROLE_CUSTOMER);
$customerno = (int) $_SESSION['customerinfo']['customerno'];
$local = mysql_real_escape_string( filter_input_username($local) );
$domain = (int) $domain;
$password = mysql_real_escape_string( filter_shell( $password ) );
if ($domain > 0)
{
$result = db_query("SELECT id FROM kundendaten.domains WHERE kunde={$customerno} AND jabber=1 AND id={$domain};");
if (mysql_num_rows($result) == 0)
{