<?php
+/*
+# Copyright (c) 2012, Gjøvik University College
+# All rights reserved.
+
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions are met:
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+# * Neither the name of the Gjøvik University College nor the
+# names of its contributors may be used to endorse or promote products
+# derived from this software without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY Gjøvik University College ''AS IS'' AND ANY
+# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+# DISCLAIMED. IN NO EVENT SHALL Gjøvik University College BE LIABLE FOR ANY
+# DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+# (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*/
require_once('config.php');
require_once('lib/common_functions.php');
require_once('lib/db_functions.php');
{
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;
$rows = array();
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;
$rows = array();
// 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 )
// 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 );
}
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;
$rows = array();