Add user_id and template variables for provisioning.

This commit is contained in:
Mark Crane 2015-04-06 07:38:24 +00:00
parent 0dfe0f6732
commit fbbc12baf1
1 changed files with 25 additions and 17 deletions

View File

@ -129,7 +129,7 @@ include "root.php";
function render() { function render() {
//debug //debug
$debug = $_GET['debug']; // array $debug = $_REQUEST['debug']; // array
//get the variables //get the variables
$domain_uuid = $this->domain_uuid; $domain_uuid = $this->domain_uuid;
@ -174,7 +174,7 @@ include "root.php";
} }
//check to see if the mac_address exists in devices //check to see if the mac_address exists in devices
if (!isset($_GET['user_id'])) { if (isset($_REQUEST['user_id']) or isset($_REQUEST['userid'])) {
if ($this->mac_exists($mac)) { if ($this->mac_exists($mac)) {
//get the device_template //get the device_template
if (strlen($device_template) == 0) { if (strlen($device_template) == 0) {
@ -297,21 +297,27 @@ include "root.php";
} }
//get the device uuid using the username and password //get the device uuid using the username and password
if (isset($_GET['user_id'])) { if (isset($_REQUEST['user_id']) or isset($_REQUEST['userid'])) {
$sql = "SELECT * FROM v_device_lines "; //set the variables
$sql .= "WHERE user_id = :user_id "; $user_id = $_REQUEST['user_id'];
$sql .= "AND password = :password "; $password = $_REQUEST['password'];
$sql .= "AND domain_uuid = :domain_uuid "; if (isset($_REQUEST['userid'])) { $user_id = $_REQUEST['userid']; }
$prep_statement = $this->db->prepare(check_sql($sql)); if (isset($_REQUEST['password'])) { $password = $_REQUEST['passwd']; }
$prep_statement->bindParam(':user_id', $_GET['user_id']); //get the device uuid
$prep_statement->bindParam(':password', $_GET['password']); $sql = "SELECT * FROM v_device_lines ";
$prep_statement->bindParam(':domain_uuid', $domain_uuid); $sql .= "WHERE user_id = :user_id ";
$prep_statement->execute(); $sql .= "AND password = :password ";
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $sql .= "AND domain_uuid = :domain_uuid ";
foreach($result as $row) { $prep_statement = $this->db->prepare(check_sql($sql));
$device_uuid = $row['device_uuid']; $prep_statement->bindParam(':user_id', $user_id);
} $prep_statement->bindParam(':password', $password);
unset ($prep_statement); $prep_statement->bindParam(':domain_uuid', $domain_uuid);
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach($result as $row) {
$device_uuid = $row['device_uuid'];
}
unset ($prep_statement);
} }
//get the device settings table in the provision category and update the provision array //get the device settings table in the provision category and update the provision array
@ -557,7 +563,9 @@ include "root.php";
$view->assign("project_path", PROJECT_PATH); $view->assign("project_path", PROJECT_PATH);
$view->assign("server1_address", $server1_address); $view->assign("server1_address", $server1_address);
$view->assign("proxy1_address", $proxy1_address); $view->assign("proxy1_address", $proxy1_address);
$view->assign("user_id",$user_id);
$view->assign("password",$password); $view->assign("password",$password);
$view->assign("template",$device_template);
//replace the dynamic provision variables that are defined in default, domain, and device settings //replace the dynamic provision variables that are defined in default, domain, and device settings
foreach($provision as $key=>$val) { foreach($provision as $key=>$val) {