]> git.defcon.no Git - hermes/blob - api/lib/domain_functions.php
Added domain/list, domain/get_server, domain/set_servers, updated sample SQL data...
[hermes] / api / lib / domain_functions.php
1 <?php
2 require_once('config.php');
3 require_once('lib/common_functions.php');
4 require_once('lib/db_functions.php');
5
6 function get_domains()
7 {
8 global $config;
9 $query = sprintf("SELECT domain FROM %s",
10 $config['kamailio_domain_table']);
11
12 $result = sql_dbquery( $config['kamailio_db'], $query);
13 if ( ! $result ) return -1;
14
15 $domains = array();
16 while ( $row = mysql_fetch_row($result) ) { array_push($domains, $row[0]); }
17 return $domains;
18 }
19
20 function set_servers ( $domain, $registrar, $r_port, $proxy, $p_port, $prov_url )
21 {
22 global $config;
23
24 $query = "";
25
26 $prev_servers = get_servers( $domain );
27 if ( $prev_servers )
28 {
29 $query = sprintf("UPDATE %s SET
30 registrar = '%s', r_port = %d,
31 proxy = '%s', p_port = %d,
32 prov_url = '%s'
33 WHERE domain = '%s'",
34 $config['provision_servers_table'],
35 sql_clean($registrar),
36 $r_port,
37 sql_clean($proxy),
38 $p_port,
39 sql_clean($prov_url),
40 sql_clean($domain)
41 );
42 }
43 else
44 {
45 $query = sprintf("INSERT INTO %s
46 (domain, registrar, r_port, proxy, p_port, prov_url)
47 VALUES ('%s', '%s', %d, '%s', %d, '%s')",
48 $config['provision_servers_table'],
49 sql_clean($domain),
50 sql_clean($registrar),
51 $r_port,
52 sql_clean($proxy),
53 $p_port,
54 sql_clean($prov_url)
55 );
56
57 }
58 return sql_dbexec( $config['provision_db'], $query );
59 return false;
60 }
61 ?>