X-Git-Url: https://git.defcon.no/?a=blobdiff_plain;f=api%2Flib%2Fphone_functions.php;h=9f05ac53ed5b1f17b6aba6e728abc934aa2d8eaf;hb=3b7b5ca848177cc351e0ee623cd9621b7a46eb7b;hp=17fbe10fac8e7ce9e4293eccd3c14df481e03dfa;hpb=220a8d4c07bfb4cb6be8122fda7dc6ceb0d1da8f;p=hermes diff --git a/api/lib/phone_functions.php b/api/lib/phone_functions.php index 17fbe10..9f05ac5 100644 --- a/api/lib/phone_functions.php +++ b/api/lib/phone_functions.php @@ -7,23 +7,23 @@ function get_user_phones ( $username, $domain ) { global $config; $query = sprintf("SELECT id FROM %s WHERE username = '%s' AND domain = '%s'", - $config['provision_users_table'], + $config['hermes_users_table'], sql_clean( $username ), sql_clean( $domain ) ); - $user = sql_dbquery_single( $config['provision_db'], $query ); + $user = sql_dbquery_single( $config['hermes_db'], $query ); if ( ! $user ) return null; $user_id = $user['id']; $query = sprintf("SELECT mac FROM %s WHERE user_rel = %d", - $config['provision_phones_table'], + $config['hermes_phones_table'], $user_id ); - $result = sql_dbquery( $config['provision_db'], $query ); + $result = sql_dbquery( $config['hermes_db'], $query ); if ( !$result ) return null; - if (mysql_num_rows($result) < 1 ) return null; + if ( @mysql_num_rows($result) < 1 ) return null; $rows = array(); while ( $row = mysql_fetch_assoc( $result ) ) array_push( $rows, $row['mac'] ); @@ -33,16 +33,16 @@ function get_user_phones ( $username, $domain ) function get_phone_users ( $macaddress ) { global $config; - $ptbl = $config['provision_phones_table']; - $utbl = $config['provision_users_table']; + $ptbl = $config['hermes_phones_table']; + $utbl = $config['hermes_users_table']; $query = "SELECT ".$ptbl.".mac as mac, CONCAT( ".$utbl.".username, '@', ".$utbl.".domain ) as user FROM ".$ptbl." INNER JOIN ".$utbl." ON ".$ptbl.".user_rel = ".$utbl.".id WHERE ".$ptbl.".mac = '".sql_clean($macaddress ). "'"; - $result = sql_dbquery( $config['provision_db'], $query ); + $result = sql_dbquery( $config['hermes_db'], $query ); if ( !$result ) return null; - if (mysql_num_rows($result) < 1 ) return null; + if ( @mysql_num_rows($result) < 1 ) return null; $rows = array(); while ( $row = mysql_fetch_assoc( $result ) ) { @@ -70,8 +70,8 @@ function add_phone_user( $mac, $username, $domain ) // OK, so we have the User ID, a valid MAC, and no previous registration // of that combination. Going to add. $query = sprintf("INSERT INTO %s ( mac, user_rel ) VALUES ( '%s', %d )", - $config['provision_phones_table'], $mac, $user_id); - return sql_dbexec( $config['provision_db'], $query ); + $config['hermes_phones_table'], $mac, $user_id); + return sql_dbexec( $config['hermes_db'], $query ); } function delete_phone_user( $mac, $username, $domain ) @@ -93,8 +93,8 @@ function delete_phone_user( $mac, $username, $domain ) // OK, so we have the User ID, a valid MAC, and no previous registration // of that combination. Going to remove. $query = sprintf("DELETE FROM %s WHERE mac = '%s' AND user_rel = %d", - $config['provision_phones_table'], $mac, $user_id); - return sql_dbexec( $config['provision_db'], $query ); + $config['hermes_phones_table'], $mac, $user_id); + return sql_dbexec( $config['hermes_db'], $query ); } @@ -102,13 +102,13 @@ function delete_phone_user( $mac, $username, $domain ) function list_phones ( $search = null ) { global $config; - $query = sprintf("SELECT mac FROM %s", $config['provision_phones_table']); + $query = sprintf("SELECT mac FROM %s", $config['hermes_phones_table']); if ( $search ) $query .= sprintf(" WHERE mac LIKE '%s%%'", sql_clean($search)); - $result = sql_dbquery( $config['provision_db'], $query ); + $result = sql_dbquery( $config['hermes_db'], $query ); if ( !$result ) return null; - if (mysql_num_rows($result) < 1 ) return null; + if ( @mysql_num_rows($result) < 1 ) return null; $rows = array(); while ( $row = mysql_fetch_assoc( $result ) ) {