From 7bdea2c30ced155970523c16a81808e5fec007b7 Mon Sep 17 00:00:00 2001 From: Mafoo Date: Tue, 13 Jun 2017 06:09:36 +0100 Subject: [PATCH] dos2unix (#2682) find . -name "*.php" | xargs dos2unix --- app/adminer/app_defaults.php | 64 +- app/calls/app_defaults.php | 62 +- app/conference_controls/app_defaults.php | 262 +- .../conference_control_delete.php | 96 +- .../conference_control_detail_delete.php | 82 +- .../conference_control_detail_edit.php | 452 +- .../conference_control_details.php | 320 +- .../conference_control_edit.php | 382 +- .../conference_controls.php | 318 +- app/database_transactions/app_config.php | 244 +- app/database_transactions/app_menu.php | 38 +- .../database_transaction_delete.php | 126 +- .../database_transaction_edit.php | 950 ++--- app/database_transactions/root.php | 178 +- app/devices/device_profile_edit.php | 1464 +++---- app/devices/device_vendor_delete.php | 126 +- app/devices/device_vendor_edit.php | 444 +- app/devices/device_vendor_function_delete.php | 128 +- app/devices/device_vendor_function_edit.php | 786 ++-- app/devices/device_vendor_functions.php | 436 +- app/devices/device_vendors.php | 370 +- app/fax/fax_files_remote.php | 498 +-- app/pin_numbers/pin_number_delete.php | 128 +- app/pin_numbers/pin_number_edit.php | 478 +-- app/pin_numbers/pin_numbers.php | 372 +- app/pin_numbers/root.php | 178 +- app/provision/resources/classes/provision.php | 2638 ++++++------ app/scripts/resources/classes/scripts.php | 682 +-- app/xml_cdr/resources/classes/xml_cdr.php | 1830 ++++---- resources/fonts/web_font_loader.php | 220 +- themes/default/app_defaults.php | 118 +- themes/default/css.php | 3674 ++++++++--------- 32 files changed, 9072 insertions(+), 9072 deletions(-) diff --git a/app/adminer/app_defaults.php b/app/adminer/app_defaults.php index c8c8463b27..d1b6f66361 100644 --- a/app/adminer/app_defaults.php +++ b/app/adminer/app_defaults.php @@ -1,32 +1,32 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//proccess this only one time -if ($domains_processed == 1) { - -} - -?> + + Portions created by the Initial Developer are Copyright (C) 2008-2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//proccess this only one time +if ($domains_processed == 1) { + +} + +?> diff --git a/app/calls/app_defaults.php b/app/calls/app_defaults.php index ce6c118ddd..ccd524720e 100644 --- a/app/calls/app_defaults.php +++ b/app/calls/app_defaults.php @@ -1,31 +1,31 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//process this only one time -if ($domains_processed == 1) { - -} -?> + + Portions created by the Initial Developer are Copyright (C) 2008-2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//process this only one time +if ($domains_processed == 1) { + +} +?> diff --git a/app/conference_controls/app_defaults.php b/app/conference_controls/app_defaults.php index cfe7066115..d4c8e80f64 100644 --- a/app/conference_controls/app_defaults.php +++ b/app/conference_controls/app_defaults.php @@ -1,131 +1,131 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - - if ($domains_processed == 1) { - - //add the conference controls list to the database - $sql = "select count(*) as num_rows from v_conference_controls; "; - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] == 0) { - - //set the directory - $xml_dir = $_SESSION["switch"]["conf"]["dir"].'/autoload_configs'; - $xml_file = $xml_dir."/conference.conf"; - $xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/resources/templates/conf/autoload_configs/conference.conf'; - - //rename the file - if (file_exists($xml_dir.'/conference.conf.xml.noload')) { - rename($xml_dir.'/conference.conf.xml.noload', $xml_dir.'/conference.conf'); - } - - //load the xml and save it into an array - if (file_exists($xml_file)) { - $xml_string = file_get_contents($xml_file); - } - elseif (file_exists($xml_file_alt)) { - $xml_string = file_get_contents($xml_file_alt); - } - $xml_object = simplexml_load_string($xml_string); - $json = json_encode($xml_object); - $conf_array = json_decode($json, true); - - //process the array - foreach ($conf_array['caller-controls']['group'] as $row) { - - //get the data from the array - $control_name = $row['@attributes']['name']; - //echo $profile_name."
\n"; - - //insert the data into the database - $conference_control_uuid = uuid(); - $sql = "insert into v_conference_controls "; - $sql .= "("; - //$sql .= "domain_uuid, "; - $sql .= "conference_control_uuid, "; - $sql .= "control_name, "; - $sql .= "control_enabled "; - $sql .= ") "; - $sql .= "values "; - $sql .= "( "; - //$sql .= "'".$domain_uuid."', "; - $sql .= "'".$conference_control_uuid."', "; - $sql .= "'".check_str($control_name)."', "; - $sql .= "'true' "; - $sql .= ");"; - //echo $sql."\n"; - $db->exec(check_sql($sql)); - unset($sql); - - //insert the profile params - foreach ($row['control'] as $p) { - - //get the name - //print_r($p); - $control_action = $p['@attributes']['action']; - $control_digits = $p['@attributes']['digits']; - $control_data = $p['@attributes']['data']; - $control_enabled = 'true'; - - //add the coference profile params - $conference_control_detail_uuid = uuid(); - $sql = "insert into v_conference_control_details "; - $sql .= "("; - $sql .= "conference_control_uuid, "; - $sql .= "conference_control_detail_uuid, "; - $sql .= "control_digits, "; - $sql .= "control_action, "; - if (strlen($control_data) > 0) { - $sql .= "control_data, "; - } - $sql .= "control_enabled "; - $sql .= ") "; - $sql .= "values "; - $sql .= "( "; - $sql .= "'".$conference_control_uuid."', "; - $sql .= "'".$conference_control_detail_uuid."', "; - $sql .= "'".$control_digits."', "; - $sql .= "'".$control_action."', "; - if (strlen($control_data) > 0) { - $sql .= "'".$control_data."', "; - } - $sql .= "'".$control_enabled."' "; - $sql .= ");"; - //echo $sql."\n"; - $db->exec(check_sql($sql)); - unset($sql); - } - - } - - } //if num_rows - } //if prep_statement - - } - -?> + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + + if ($domains_processed == 1) { + + //add the conference controls list to the database + $sql = "select count(*) as num_rows from v_conference_controls; "; + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] == 0) { + + //set the directory + $xml_dir = $_SESSION["switch"]["conf"]["dir"].'/autoload_configs'; + $xml_file = $xml_dir."/conference.conf"; + $xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/resources/templates/conf/autoload_configs/conference.conf'; + + //rename the file + if (file_exists($xml_dir.'/conference.conf.xml.noload')) { + rename($xml_dir.'/conference.conf.xml.noload', $xml_dir.'/conference.conf'); + } + + //load the xml and save it into an array + if (file_exists($xml_file)) { + $xml_string = file_get_contents($xml_file); + } + elseif (file_exists($xml_file_alt)) { + $xml_string = file_get_contents($xml_file_alt); + } + $xml_object = simplexml_load_string($xml_string); + $json = json_encode($xml_object); + $conf_array = json_decode($json, true); + + //process the array + foreach ($conf_array['caller-controls']['group'] as $row) { + + //get the data from the array + $control_name = $row['@attributes']['name']; + //echo $profile_name."
\n"; + + //insert the data into the database + $conference_control_uuid = uuid(); + $sql = "insert into v_conference_controls "; + $sql .= "("; + //$sql .= "domain_uuid, "; + $sql .= "conference_control_uuid, "; + $sql .= "control_name, "; + $sql .= "control_enabled "; + $sql .= ") "; + $sql .= "values "; + $sql .= "( "; + //$sql .= "'".$domain_uuid."', "; + $sql .= "'".$conference_control_uuid."', "; + $sql .= "'".check_str($control_name)."', "; + $sql .= "'true' "; + $sql .= ");"; + //echo $sql."\n"; + $db->exec(check_sql($sql)); + unset($sql); + + //insert the profile params + foreach ($row['control'] as $p) { + + //get the name + //print_r($p); + $control_action = $p['@attributes']['action']; + $control_digits = $p['@attributes']['digits']; + $control_data = $p['@attributes']['data']; + $control_enabled = 'true'; + + //add the coference profile params + $conference_control_detail_uuid = uuid(); + $sql = "insert into v_conference_control_details "; + $sql .= "("; + $sql .= "conference_control_uuid, "; + $sql .= "conference_control_detail_uuid, "; + $sql .= "control_digits, "; + $sql .= "control_action, "; + if (strlen($control_data) > 0) { + $sql .= "control_data, "; + } + $sql .= "control_enabled "; + $sql .= ") "; + $sql .= "values "; + $sql .= "( "; + $sql .= "'".$conference_control_uuid."', "; + $sql .= "'".$conference_control_detail_uuid."', "; + $sql .= "'".$control_digits."', "; + $sql .= "'".$control_action."', "; + if (strlen($control_data) > 0) { + $sql .= "'".$control_data."', "; + } + $sql .= "'".$control_enabled."' "; + $sql .= ");"; + //echo $sql."\n"; + $db->exec(check_sql($sql)); + unset($sql); + } + + } + + } //if num_rows + } //if prep_statement + + } + +?> diff --git a/app/conference_controls/conference_control_delete.php b/app/conference_controls/conference_control_delete.php index bc176015d6..eb8894f635 100644 --- a/app/conference_controls/conference_control_delete.php +++ b/app/conference_controls/conference_control_delete.php @@ -1,49 +1,49 @@ -get(); - -//get the id - if (count($_GET) > 0) { - $id = check_str($_GET["id"]); - } - -//delete the data - if (strlen($id) > 0) { - //delete conference_control_detail - $sql = "delete from v_conference_control_details "; - $sql .= "where conference_control_uuid = '$id' "; - //$sql .= "and domain_uuid = '$domain_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - unset($sql); - - //delete conference_control - $sql = "delete from v_conference_controls "; - $sql .= "where conference_control_uuid = '$id' "; - //$sql .= "and domain_uuid = '$domain_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - unset($sql); - } - -//redirect the user - messages::add($text['message-delete']); - header('Location: conference_controls.php'); - +get(); + +//get the id + if (count($_GET) > 0) { + $id = check_str($_GET["id"]); + } + +//delete the data + if (strlen($id) > 0) { + //delete conference_control_detail + $sql = "delete from v_conference_control_details "; + $sql .= "where conference_control_uuid = '$id' "; + //$sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + + //delete conference_control + $sql = "delete from v_conference_controls "; + $sql .= "where conference_control_uuid = '$id' "; + //$sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + messages::add($text['message-delete']); + header('Location: conference_controls.php'); + ?> \ No newline at end of file diff --git a/app/conference_controls/conference_control_detail_delete.php b/app/conference_controls/conference_control_detail_delete.php index 443cd6403f..6d8407fe5b 100644 --- a/app/conference_controls/conference_control_detail_delete.php +++ b/app/conference_controls/conference_control_detail_delete.php @@ -1,42 +1,42 @@ -get(); - -//get the id - if (count($_GET) > 0) { - $id = check_str($_GET["id"]); - $conference_control_uuid = check_str($_GET["conference_control_uuid"]); - } - -//delete the data - if (strlen($id) > 0) { - //delete conference_control_detail - $sql = "delete from v_conference_control_details "; - $sql .= "where conference_control_detail_uuid = '$id' "; - //$sql .= "and domain_uuid = '$domain_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - unset($sql); - } - -//redirect the user - messages::add($text['message-delete']); - header('Location: conference_control_detail_edit.php?id='.$conference_control_uuid); - +get(); + +//get the id + if (count($_GET) > 0) { + $id = check_str($_GET["id"]); + $conference_control_uuid = check_str($_GET["conference_control_uuid"]); + } + +//delete the data + if (strlen($id) > 0) { + //delete conference_control_detail + $sql = "delete from v_conference_control_details "; + $sql .= "where conference_control_detail_uuid = '$id' "; + //$sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + messages::add($text['message-delete']); + header('Location: conference_control_detail_edit.php?id='.$conference_control_uuid); + ?> \ No newline at end of file diff --git a/app/conference_controls/conference_control_detail_edit.php b/app/conference_controls/conference_control_detail_edit.php index f94e03dc66..a013dee354 100644 --- a/app/conference_controls/conference_control_detail_edit.php +++ b/app/conference_controls/conference_control_detail_edit.php @@ -1,226 +1,226 @@ -get(); - -//action add or update - if (isset($_REQUEST["id"])) { - $action = "update"; - $conference_control_detail_uuid = check_str($_REQUEST["id"]); - } - else { - $action = "add"; - } - -//set the parent uuid - if (strlen($_GET["conference_control_uuid"]) > 0) { - $conference_control_uuid = check_str($_GET["conference_control_uuid"]); - } - -//get http post variables and set them to php variables - if (count($_POST)>0) { - $control_digits = check_str($_POST["control_digits"]); - $control_action = check_str($_POST["control_action"]); - $control_data = check_str($_POST["control_data"]); - $control_enabled = check_str($_POST["control_enabled"]); - } - -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { - - //get the uuid - if ($action == "update") { - $conference_control_detail_uuid = check_str($_POST["conference_control_detail_uuid"]); - } - - //check for all required data - $msg = ''; - //if (strlen($control_digits) == 0) { $msg .= $text['message-required']." ".$text['label-control_digits']."
\n"; } - if (strlen($control_action) == 0) { $msg .= $text['message-required']." ".$text['label-control_action']."
\n"; } - //if (strlen($control_data) == 0) { $msg .= $text['message-required']." ".$text['label-control_data']."
\n"; } - if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - if ($action == "add" && permission_exists('conference_control_detail_add')) { - $sql = "insert into v_conference_control_details "; - $sql .= "("; - //$sql .= "domain_uuid, "; - $sql .= "conference_control_detail_uuid, "; - $sql .= "conference_control_uuid, "; - $sql .= "control_digits, "; - $sql .= "control_action, "; - $sql .= "control_data, "; - $sql .= "control_enabled "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - //$sql .= "'$domain_uuid', "; - $sql .= "'".uuid()."', "; - $sql .= "'$conference_control_uuid', "; - $sql .= "'$control_digits', "; - $sql .= "'$control_action', "; - $sql .= "'$control_data', "; - $sql .= "'$control_enabled' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-add']); - header('Location: conference_control_edit.php?id='.$conference_control_uuid); - return; - - } //if ($action == "add") - - if ($action == "update" && permission_exists('conference_control_detail_edit')) { - $sql = "update v_conference_control_details set "; - $sql .= "conference_control_uuid = '$conference_control_uuid', "; - $sql .= "control_digits = '$control_digits', "; - $sql .= "control_action = '$control_action', "; - $sql .= "control_data = '$control_data', "; - $sql .= "control_enabled = '$control_enabled' "; - $sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid'"; - //$sql .= "and domain_uuid = '$domain_uuid' "; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-update']); - header('Location: conference_control_edit.php?id='.$conference_control_uuid); - return; - - } //if ($action == "update") - } //if ($_POST["persistformvar"] != "true") -} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - -//pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $conference_control_detail_uuid = check_str($_GET["id"]); - $sql = "select * from v_conference_control_details "; - $sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid' "; - //$sql .= "and domain_uuid = '$domain_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $control_digits = $row["control_digits"]; - $control_action = $row["control_action"]; - $control_data = $row["control_data"]; - $control_enabled = $row["control_enabled"]; - } - unset ($prep_statement); - } - -//show the header - require_once "resources/header.php"; - -//show the content - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " "; - echo "
".$text['title-conference_control_detail']."

\n"; - echo " "; - echo " "; - echo "
\n"; - echo " ".$text['label-control_digits']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-control_digits']."\n"; - echo "
\n"; - echo " ".$text['label-control_action']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-control_action']."\n"; - echo "
\n"; - echo " ".$text['label-control_data']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-control_data']."\n"; - echo "
\n"; - echo " ".$text['label-control_enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-control_enabled']."\n"; - echo "
\n"; - echo " \n"; - if ($action == "update") { - echo " \n"; - } - echo " \n"; - echo "
"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; - -?> +get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $conference_control_detail_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//set the parent uuid + if (strlen($_GET["conference_control_uuid"]) > 0) { + $conference_control_uuid = check_str($_GET["conference_control_uuid"]); + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $control_digits = check_str($_POST["control_digits"]); + $control_action = check_str($_POST["control_action"]); + $control_data = check_str($_POST["control_data"]); + $control_enabled = check_str($_POST["control_enabled"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + //get the uuid + if ($action == "update") { + $conference_control_detail_uuid = check_str($_POST["conference_control_detail_uuid"]); + } + + //check for all required data + $msg = ''; + //if (strlen($control_digits) == 0) { $msg .= $text['message-required']." ".$text['label-control_digits']."
\n"; } + if (strlen($control_action) == 0) { $msg .= $text['message-required']." ".$text['label-control_action']."
\n"; } + //if (strlen($control_data) == 0) { $msg .= $text['message-required']." ".$text['label-control_data']."
\n"; } + if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('conference_control_detail_add')) { + $sql = "insert into v_conference_control_details "; + $sql .= "("; + //$sql .= "domain_uuid, "; + $sql .= "conference_control_detail_uuid, "; + $sql .= "conference_control_uuid, "; + $sql .= "control_digits, "; + $sql .= "control_action, "; + $sql .= "control_data, "; + $sql .= "control_enabled "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + //$sql .= "'$domain_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'$conference_control_uuid', "; + $sql .= "'$control_digits', "; + $sql .= "'$control_action', "; + $sql .= "'$control_data', "; + $sql .= "'$control_enabled' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-add']); + header('Location: conference_control_edit.php?id='.$conference_control_uuid); + return; + + } //if ($action == "add") + + if ($action == "update" && permission_exists('conference_control_detail_edit')) { + $sql = "update v_conference_control_details set "; + $sql .= "conference_control_uuid = '$conference_control_uuid', "; + $sql .= "control_digits = '$control_digits', "; + $sql .= "control_action = '$control_action', "; + $sql .= "control_data = '$control_data', "; + $sql .= "control_enabled = '$control_enabled' "; + $sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid'"; + //$sql .= "and domain_uuid = '$domain_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-update']); + header('Location: conference_control_edit.php?id='.$conference_control_uuid); + return; + + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $conference_control_detail_uuid = check_str($_GET["id"]); + $sql = "select * from v_conference_control_details "; + $sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid' "; + //$sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $control_digits = $row["control_digits"]; + $control_action = $row["control_action"]; + $control_data = $row["control_data"]; + $control_enabled = $row["control_enabled"]; + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
".$text['title-conference_control_detail']."

\n"; + echo " "; + echo " "; + echo "
\n"; + echo " ".$text['label-control_digits']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-control_digits']."\n"; + echo "
\n"; + echo " ".$text['label-control_action']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-control_action']."\n"; + echo "
\n"; + echo " ".$text['label-control_data']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-control_data']."\n"; + echo "
\n"; + echo " ".$text['label-control_enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-control_enabled']."\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/conference_controls/conference_control_details.php b/app/conference_controls/conference_control_details.php index d400fc63fa..53dbfc2fde 100644 --- a/app/conference_controls/conference_control_details.php +++ b/app/conference_controls/conference_control_details.php @@ -1,160 +1,160 @@ -get(); - -//get variables used to control the order - $order_by = check_str($_GET["order_by"]); - $order = check_str($_GET["order"]); - -//add the search term - $search = check_str($_GET["search"]); - if (strlen($search) > 0) { - $sql_search = "and ("; - $sql_search .= "control_digits like '%".$search."%'"; - $sql_search .= "or control_action like '%".$search."%'"; - $sql_search .= "or control_data like '%".$search."%'"; - $sql_search .= "or control_enabled like '%".$search."%'"; - $sql_search .= ")"; - } -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - -//prepare to page the results - $sql = "select count(*) as num_rows "; - $sql .= "from v_conference_control_details "; - $sql .= "where conference_control_uuid = '$conference_control_uuid' "; - //$sql .= "and domain_uuid = '$domain_uuid' "; - $sql .= $sql_search; - if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - -//prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - -//get the list - $sql = "select * from v_conference_control_details "; - $sql .= "where conference_control_uuid = '$conference_control_uuid' "; - //$sql .= "and domain_uuid = '$domain_uuid' "; - $sql .= $sql_search; - if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement, $sql); - -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - -//show the content - echo "\n"; - echo " \n"; - echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; - echo "
".$text['title-conference_control_details']."
\n"; - //echo " \n"; - //echo " \n"; - //echo "
\n"; - - echo "\n"; - echo "\n"; - echo th_order_by('control_digits', $text['label-control_digits'], $order_by, $order); - echo th_order_by('control_action', $text['label-control_action'], $order_by, $order); - echo th_order_by('control_data', $text['label-control_data'], $order_by, $order); - echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order); - echo "\n"; - echo "\n"; - - if (is_array($result)) { - foreach($result as $row) { - if (permission_exists('conference_control_detail_edit')) { - $tr_link = "href='conference_control_detail_edit.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."'"; - } - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); - } //end if results - - echo "\n"; - echo "\n"; - echo "\n"; - echo "
"; - if (permission_exists('conference_control_detail_add')) { - echo "$v_link_label_add"; - } - else { - echo " \n"; - } - echo "
".$row['control_digits']." ".$row['control_action']." ".$row['control_data']." ".$row['control_enabled']." "; - if (permission_exists('conference_control_detail_edit')) { - echo "$v_link_label_edit"; - } - if (permission_exists('conference_control_detail_delete')) { - echo "$v_link_label_delete"; - } - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; - if (permission_exists('conference_control_detail_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo "
\n"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; - -?> +get(); + +//get variables used to control the order + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//add the search term + $search = check_str($_GET["search"]); + if (strlen($search) > 0) { + $sql_search = "and ("; + $sql_search .= "control_digits like '%".$search."%'"; + $sql_search .= "or control_action like '%".$search."%'"; + $sql_search .= "or control_data like '%".$search."%'"; + $sql_search .= "or control_enabled like '%".$search."%'"; + $sql_search .= ")"; + } +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//prepare to page the results + $sql = "select count(*) as num_rows "; + $sql .= "from v_conference_control_details "; + $sql .= "where conference_control_uuid = '$conference_control_uuid' "; + //$sql .= "and domain_uuid = '$domain_uuid' "; + $sql .= $sql_search; + if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_conference_control_details "; + $sql .= "where conference_control_uuid = '$conference_control_uuid' "; + //$sql .= "and domain_uuid = '$domain_uuid' "; + $sql .= $sql_search; + if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//alternate the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo "
".$text['title-conference_control_details']."
\n"; + //echo " \n"; + //echo " \n"; + //echo "
\n"; + + echo "\n"; + echo "\n"; + echo th_order_by('control_digits', $text['label-control_digits'], $order_by, $order); + echo th_order_by('control_action', $text['label-control_action'], $order_by, $order); + echo th_order_by('control_data', $text['label-control_data'], $order_by, $order); + echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order); + echo "\n"; + echo "\n"; + + if (is_array($result)) { + foreach($result as $row) { + if (permission_exists('conference_control_detail_edit')) { + $tr_link = "href='conference_control_detail_edit.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."'"; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + if (permission_exists('conference_control_detail_add')) { + echo "$v_link_label_add"; + } + else { + echo " \n"; + } + echo "
".$row['control_digits']." ".$row['control_action']." ".$row['control_data']." ".$row['control_enabled']." "; + if (permission_exists('conference_control_detail_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('conference_control_detail_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('conference_control_detail_add')) { + echo "$v_link_label_add"; + } + else { + echo " "; + } + echo "
\n"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/conference_controls/conference_control_edit.php b/app/conference_controls/conference_control_edit.php index a320907e40..97b0b44e6e 100644 --- a/app/conference_controls/conference_control_edit.php +++ b/app/conference_controls/conference_control_edit.php @@ -1,191 +1,191 @@ -get(); - -//action add or update - if (isset($_REQUEST["id"])) { - $action = "update"; - $conference_control_uuid = check_str($_REQUEST["id"]); - } - else { - $action = "add"; - } - -//get http post variables and set them to php variables - if (is_array($_POST)) { - $control_name = check_str($_POST["control_name"]); - $control_enabled = check_str($_POST["control_enabled"]); - $control_description = check_str($_POST["control_description"]); - } - -//process the user data and save it to the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - - //get the uuid from the POST - if ($action == "update") { - $conference_control_uuid = check_str($_POST["conference_control_uuid"]); - } - - //check for all required data - $msg = ''; - if (strlen($control_name) == 0) { $msg .= $text['message-required']." ".$text['label-control_name']."
\n"; } - if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } - //if (strlen($control_description) == 0) { $msg .= $text['message-required']." ".$text['label-control_description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //add the conference_control_uuid - if (strlen($_POST["conference_control_uuid"]) == 0) { - $conference_control_uuid = uuid(); - $_POST["conference_control_uuid"] = $conference_control_uuid; - } - - //prepare the array - $array['conference_controls'][] = $_POST; - - //save to the data - $database = new database; - $database->app_name = 'conference_controls'; - $database->app_uuid = null; - if (strlen($conference_control_uuid) > 0) { - $database->uuid($conference_control_uuid); - } - $database->save($array); - $message = $database->message; - - //redirect the user - if (isset($action)) { - if ($action == "add") { - messages::add($text['message-add']); - } - if ($action == "update") { - messages::add($text['message-update']); - } - header("Location: conference_controls.php"); - return; - } - } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) - -//pre-populate the form - if (is_array($_GET) && $_POST["persistformvar"] != "true") { - $conference_control_uuid = check_str($_GET["id"]); - $sql = "select * from v_conference_controls "; - //$sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "where conference_control_uuid = '$conference_control_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $control_name = $row["control_name"]; - $control_enabled = $row["control_enabled"]; - $control_description = $row["control_description"]; - } - unset ($prep_statement); - } - -//show the header - require_once "resources/header.php"; - -//show the content - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " "; - echo "
".$text['title-conference_control']."

\n"; - echo " "; - echo " "; - echo "
\n"; - echo " ".$text['label-control_name']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-control_name']."\n"; - echo "
\n"; - echo " ".$text['label-control_enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-control_enabled']."\n"; - echo "
\n"; - echo " ".$text['label-control_description']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-control_description']."\n"; - echo "
\n"; - if ($action == "update") { - echo " \n"; - } - echo " \n"; - echo "
"; - echo "
"; - echo "

"; - - if ($action == "update") { - require "conference_control_details.php"; - } - -//include the footer - require_once "resources/footer.php"; - -?> +get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $conference_control_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (is_array($_POST)) { + $control_name = check_str($_POST["control_name"]); + $control_enabled = check_str($_POST["control_enabled"]); + $control_description = check_str($_POST["control_description"]); + } + +//process the user data and save it to the database + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + //get the uuid from the POST + if ($action == "update") { + $conference_control_uuid = check_str($_POST["conference_control_uuid"]); + } + + //check for all required data + $msg = ''; + if (strlen($control_name) == 0) { $msg .= $text['message-required']." ".$text['label-control_name']."
\n"; } + if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."
\n"; } + //if (strlen($control_description) == 0) { $msg .= $text['message-required']." ".$text['label-control_description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add the conference_control_uuid + if (strlen($_POST["conference_control_uuid"]) == 0) { + $conference_control_uuid = uuid(); + $_POST["conference_control_uuid"] = $conference_control_uuid; + } + + //prepare the array + $array['conference_controls'][] = $_POST; + + //save to the data + $database = new database; + $database->app_name = 'conference_controls'; + $database->app_uuid = null; + if (strlen($conference_control_uuid) > 0) { + $database->uuid($conference_control_uuid); + } + $database->save($array); + $message = $database->message; + + //redirect the user + if (isset($action)) { + if ($action == "add") { + messages::add($text['message-add']); + } + if ($action == "update") { + messages::add($text['message-update']); + } + header("Location: conference_controls.php"); + return; + } + } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (is_array($_GET) && $_POST["persistformvar"] != "true") { + $conference_control_uuid = check_str($_GET["id"]); + $sql = "select * from v_conference_controls "; + //$sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "where conference_control_uuid = '$conference_control_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $control_name = $row["control_name"]; + $control_enabled = $row["control_enabled"]; + $control_description = $row["control_description"]; + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
".$text['title-conference_control']."

\n"; + echo " "; + echo " "; + echo "
\n"; + echo " ".$text['label-control_name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-control_name']."\n"; + echo "
\n"; + echo " ".$text['label-control_enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-control_enabled']."\n"; + echo "
\n"; + echo " ".$text['label-control_description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-control_description']."\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "

"; + + if ($action == "update") { + require "conference_control_details.php"; + } + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/conference_controls/conference_controls.php b/app/conference_controls/conference_controls.php index c25eba4955..b304440ad3 100644 --- a/app/conference_controls/conference_controls.php +++ b/app/conference_controls/conference_controls.php @@ -1,159 +1,159 @@ -get(); - -//get variables used to control the order - $order_by = check_str($_GET["order_by"]); - $order = check_str($_GET["order"]); - -//add the search term - $search = strtolower(check_str($_GET["search"])); - if (strlen($search) > 0) { - $sql_search = "where ("; - $sql_search .= "lower(control_name) like '%".$search."%' "; - $sql_search .= "or lower(control_description) like '%".$search."%' "; - $sql_search .= ") "; - } - -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - -//prepare to page the results - $sql = "select count(conference_control_uuid) as num_rows "; - $sql .= "from v_conference_controls"; - $sql .= $sql_search; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - -//prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - -//get the list - $sql = "select * from v_conference_controls "; - //$sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; - $sql .= $sql_search; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement, $sql); - -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - -//show the content - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['title-conference_controls']."
\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['title_description-conference_control']."

\n"; - echo "
\n"; - - echo "\n"; - echo "\n"; - echo th_order_by('control_name', $text['label-control_name'], $order_by, $order); - echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order); - echo th_order_by('control_description', $text['label-control_description'], $order_by, $order); - echo "\n"; - echo "\n"; - - if (is_array($result)) { - foreach($result as $row) { - if (permission_exists('conference_control_edit')) { - $tr_link = "href='conference_control_edit.php?id=".$row['conference_control_uuid']."'"; - } - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); - } //end if results - - echo "\n"; - echo "\n"; - echo "\n"; - echo "
"; - if (permission_exists('conference_control_add')) { - echo "$v_link_label_add"; - } - else { - echo " \n"; - } - echo "
".$row['control_name']." ".$row['control_enabled']." ".$row['control_description']." "; - if (permission_exists('conference_control_edit')) { - echo "$v_link_label_edit"; - } - if (permission_exists('conference_control_delete')) { - echo "$v_link_label_delete"; - } - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; - if (permission_exists('conference_control_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo "
\n"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; - -?> +get(); + +//get variables used to control the order + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//add the search term + $search = strtolower(check_str($_GET["search"])); + if (strlen($search) > 0) { + $sql_search = "where ("; + $sql_search .= "lower(control_name) like '%".$search."%' "; + $sql_search .= "or lower(control_description) like '%".$search."%' "; + $sql_search .= ") "; + } + +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//prepare to page the results + $sql = "select count(conference_control_uuid) as num_rows "; + $sql .= "from v_conference_controls"; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_conference_controls "; + //$sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//alternate the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['title-conference_controls']."
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['title_description-conference_control']."

\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo th_order_by('control_name', $text['label-control_name'], $order_by, $order); + echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order); + echo th_order_by('control_description', $text['label-control_description'], $order_by, $order); + echo "\n"; + echo "\n"; + + if (is_array($result)) { + foreach($result as $row) { + if (permission_exists('conference_control_edit')) { + $tr_link = "href='conference_control_edit.php?id=".$row['conference_control_uuid']."'"; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + if (permission_exists('conference_control_add')) { + echo "$v_link_label_add"; + } + else { + echo " \n"; + } + echo "
".$row['control_name']." ".$row['control_enabled']." ".$row['control_description']." "; + if (permission_exists('conference_control_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('conference_control_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('conference_control_add')) { + echo "$v_link_label_add"; + } + else { + echo " "; + } + echo "
\n"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/database_transactions/app_config.php b/app/database_transactions/app_config.php index 1ba44e4d0f..aac3f92ded 100644 --- a/app/database_transactions/app_config.php +++ b/app/database_transactions/app_config.php @@ -1,122 +1,122 @@ - + diff --git a/app/database_transactions/app_menu.php b/app/database_transactions/app_menu.php index e2cf360084..bd67d6ba37 100644 --- a/app/database_transactions/app_menu.php +++ b/app/database_transactions/app_menu.php @@ -1,21 +1,21 @@ - \ No newline at end of file diff --git a/app/database_transactions/database_transaction_delete.php b/app/database_transactions/database_transaction_delete.php index 4cc45041e7..0677c0a531 100644 --- a/app/database_transactions/database_transaction_delete.php +++ b/app/database_transactions/database_transaction_delete.php @@ -1,64 +1,64 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('database_transaction_delete')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get the id - if (count($_GET)>0) { - $id = check_str($_GET["id"]); - } - -//delete database_transaction - if (strlen($id)>0) { - $sql = "delete from v_database_transactions "; - $sql .= "where database_transaction_uuid = '$id' "; - $sql .= "and domain_uuid = '$domain_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - unset($sql); - } - -//redirect the user - messages::add($text['message-delete']); - header('Location: database_transactions.php'); - + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('database_transaction_delete')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the id + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } + +//delete database_transaction + if (strlen($id)>0) { + $sql = "delete from v_database_transactions "; + $sql .= "where database_transaction_uuid = '$id' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + messages::add($text['message-delete']); + header('Location: database_transactions.php'); + ?> \ No newline at end of file diff --git a/app/database_transactions/database_transaction_edit.php b/app/database_transactions/database_transaction_edit.php index 9701ababca..95169961d7 100644 --- a/app/database_transactions/database_transaction_edit.php +++ b/app/database_transactions/database_transaction_edit.php @@ -1,475 +1,475 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - 2017 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('database_transaction_add') || permission_exists('database_transaction_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//action add or update - if (isset($_REQUEST["id"])) { - //$action = "update"; - $database_transaction_uuid = check_str($_REQUEST["id"]); - } - //else { - // $action = "add"; - //} - -//get http post variables and set them to php variables - /* - if (count($_POST) > 0) { - $user_uuid = check_str($_POST["user_uuid"]); - $app_uuid = check_str($_POST["app_uuid"]); - $transaction_code = check_str($_POST["transaction_code"]); - $transaction_address = check_str($_POST["transaction_address"]); - $transaction_type = check_str($_POST["transaction_type"]); - $transaction_date = check_str($_POST["transaction_date"]); - $transaction_old = check_str($_POST["transaction_old"]); - $transaction_new = check_str($_POST["transaction_new"]); - $transaction_result = check_str($_POST["transaction_result"]); - } - */ - -//process the data - /* - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - - $msg = ''; - if ($action == "update") { - $database_transaction_uuid = check_str($_POST["database_transaction_uuid"]); - } - - //check for all required data - if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } - if (strlen($user_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-user_uuid']."
\n"; } - if (strlen($app_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-app_uuid']."
\n"; } - if (strlen($transaction_code) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_code']."
\n"; } - if (strlen($transaction_address) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_address']."
\n"; } - if (strlen($transaction_type) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_type']."
\n"; } - if (strlen($transaction_date) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_date']."
\n"; } - if (strlen($transaction_old) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_old']."
\n"; } - if (strlen($transaction_new) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_new']."
\n"; } - if (strlen($transaction_result) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_result']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - if ($action == "add" && permission_exists('database_transaction_add')) { - $sql = "insert into v_database_transactions "; - $sql .= "("; - $sql .= "domain_uuid, "; - $sql .= "database_transaction_uuid, "; - $sql .= "domain_uuid, "; - $sql .= "user_uuid, "; - $sql .= "app_uuid, "; - $sql .= "transaction_code, "; - $sql .= "transaction_address, "; - $sql .= "transaction_type, "; - $sql .= "transaction_date, "; - $sql .= "transaction_old, "; - $sql .= "transaction_new, "; - $sql .= "transaction_result "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'$domain_uuid', "; - $sql .= "'".uuid()."', "; - $sql .= "'$domain_uuid', "; - $sql .= "'$user_uuid', "; - $sql .= "'$app_uuid', "; - $sql .= "'$transaction_code', "; - $sql .= "'$transaction_address', "; - $sql .= "'$transaction_type', "; - $sql .= "now(), "; - $sql .= "'$transaction_old', "; - $sql .= "'$transaction_new', "; - $sql .= "'$transaction_result' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-add']); - header("Location: database_transactions.php"); - return; - - } //if ($action == "add") - - if ($action == "update" && permission_exists('database_transaction_edit')) { - $sql = "update v_database_transactions set "; - $sql .= "domain_uuid = '$domain_uuid', "; - $sql .= "user_uuid = '$user_uuid', "; - $sql .= "app_uuid = '$app_uuid', "; - $sql .= "transaction_code = '$transaction_code', "; - $sql .= "transaction_address = '$transaction_address', "; - $sql .= "transaction_type = '$transaction_type', "; - $sql .= "transaction_date = now(), "; - $sql .= "transaction_old = '$transaction_old', "; - $sql .= "transaction_new = '$transaction_new', "; - $sql .= "transaction_result = '$transaction_result' "; - $sql .= "where database_transaction_uuid = '$database_transaction_uuid'"; - $sql .= "and domain_uuid = '$domain_uuid' "; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-update']); - header("Location: database_transactions.php"); - return; - - } //if ($action == "update") - } //if ($_POST["persistformvar"] != "true") - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - */ - -//pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $database_transaction_uuid = check_str($_GET["id"]); - - $sql = "select "; - $sql .= "t.database_transaction_uuid, d.domain_name, u.username, t.user_uuid, t.app_name, t.app_uuid, "; - $sql .= "t.transaction_code, t.transaction_address, t.transaction_type, t.transaction_date, "; - $sql .= "t.transaction_old, t.transaction_new, t.transaction_result "; - $sql .= "from v_database_transactions as t, v_domains as d, v_users as u "; - $sql .= "where t.domain_uuid = '$domain_uuid' "; - $sql .= "and t.database_transaction_uuid = '$database_transaction_uuid' "; - $sql .= "and t.user_uuid = u.user_uuid "; - $sql .= "and t.domain_uuid = d.domain_uuid "; - - //$sql = "select *, u.username from v_database_transactions as t, v_users as u "; - //$sql .= "where domain_uuid = '$domain_uuid' "; - //$sql .= "t.user_uuid = u.user_uuid "; - //$sql .= "and database_transaction_uuid = '$database_transaction_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $user_uuid = $row["user_uuid"]; - $app_name = $row["app_name"]; - $app_uuid = $row["app_uuid"]; - $domain_name = $row["domain_name"]; - $username = $row["username"]; - $transaction_code = $row["transaction_code"]; - $transaction_address = $row["transaction_address"]; - //$transaction_type = $row["transaction_type"]; - $transaction_date = $row["transaction_date"]; - $transaction_old = $row["transaction_old"]; - $transaction_new = $row["transaction_new"]; - $transaction_result = $row["transaction_result"]; - } - unset ($prep_statement); - } - -//show the header - require_once "resources/header.php"; - -//show the content - //echo "
\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['title-database_transaction']."

\n"; - echo " "; - //echo " "; - echo "
\n"; - - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - - /*echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - */ - - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['label-app_name']."\n"; - echo " \n"; - echo " ".$app_name."\n"; - //echo " \n"; - //echo "
\n"; - //echo " ".$text['description-app_uuid']."\n"; - echo "
\n"; - echo " ".$text['label-domain']."\n"; - echo " \n"; - echo " ".$domain_name; - //echo " \n"; - //echo "
\n"; - //echo " ".$text['description-domain']."\n"; - echo "
\n"; - echo " ".$text['label-user_uuid']."\n"; - echo " \n"; - echo " ".$username."\n"; - //echo " \n"; - //echo "
\n"; - //echo " ".$text['description-user_uuid']."\n"; - echo "
\n"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['label-transaction_code']."\n"; - echo " \n"; - echo " $transaction_code\n"; - //echo " \n"; - //echo "
\n"; - //echo " ".$text['description-transaction_code']."\n"; - echo "
\n"; - echo " ".$text['label-transaction_address']."\n"; - echo " \n"; - echo " $transaction_address\n"; - //echo " \n"; - //echo "
\n"; - //echo " ".$text['description-transaction_address']."\n"; - echo "
\n"; - echo "
\n"; - - //echo "\n"; - //echo "\n"; - //echo " ".$text['label-transaction_type']."\n"; - //echo "\n"; - //echo "\n"; - //echo " \n"; - //echo "
\n"; - //echo $text['description-transaction_type']."\n"; - //echo "\n"; - //echo "\n"; - - if ($_REQUEST["debug"] == "true") { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "
\n"; - echo " ".$text['label-transaction_old']."\n"; - echo "\n"; - //echo " \n"; - echo " \n"; - //echo "
\n"; - //echo $text['description-transaction_old']."\n"; - echo "
\n"; - echo " ".$text['label-transaction_new']."\n"; - echo "\n"; - //echo " \n"; - echo " \n"; - //echo "
\n"; - //echo $text['description-transaction_new']."\n"; - echo "
\n"; - echo " ".$text['label-transaction_result']."\n"; - echo "\n"; - //echo " \n"; - echo " \n"; - //echo "
\n"; - //echo $text['description-transaction_result']."\n"; - echo "
"; - } - - //echo " \n"; - //echo " \n"; - //if ($action == "update") { - // echo " \n"; - //} - //echo " \n"; - //echo " \n"; - //echo " "; - //echo ""; - //echo "
"; - //echo "

"; - -//define the array _difference function - //this adds old and new values to the array - function array_difference($array1, $array2) { - $difference = array(); - if (is_array($array1)) { - foreach($array1 as $key => $value) { - if(is_array($array2[$key])) { - $difference[$key] = array_difference($array1[$key], $array2[$key]); - } - else { - $difference[$key]['old'] = $value; - } - } - } - if (is_array($array2)) { - foreach($array2 as $key => $value) { - if(is_array($value)) { - $difference[$key] = array_difference($array1[$key], $array2[$key]); - } - else { - $difference[$key]['new'] = $value; - } - } - } - return $difference; - } - -//show the content from the difference array as a list - function show_difference($array) { - //loop through the array - foreach($array as $key => $value) { - if(is_array($value) && !isset($value['old']) && !isset($value['new'])) { - if (!is_numeric($key)) { - //get the table name - $_SESSION['name'] = $key; - } - else { - //get the row id - $_SESSION['row'] = $key; - } - $array = show_difference($value); - } - else { - //set the variables - $old = $value['old']; - $new = $value['new']; - if (is_null($old)) { $old = ''; } - if (is_null($new)) { $new = ''; } - //determine if the value has changed - if (strval($old) == strval($new) && isset($old)) { - $color = "#000000"; - } - else { - $color = "#ff0000"; - } - //set the table header - if ($_SESSION['previous_name'] != $_SESSION['name'] || $_SESSION['previous_row'] != $_SESSION['row']) { - echo str_replace("name","".$_SESSION['name']."",$_SESSION['table_header']); - //echo $_SESSION['table_header']; - } - $_SESSION['previous_name'] = $_SESSION['name']; - $_SESSION['previous_row'] = $_SESSION['row']; - //show the results - echo "\n"; - //echo " ".$_SESSION['name']."\n"; - //echo " ".$_SESSION['row']."\n"; - echo " $key\n"; - echo " ".$old."\n"; - echo " ".$new.""; - echo "\n"; - //echo "\n"; - } - } - } - -//decode the json to arrays - $before = json_decode($transaction_old, true); - $after = json_decode($transaction_new, true); - -//unset the sessions - unset($_SESSION['previous_name']); - unset($_SESSION['previous_row']); - -//show the add or update - if (count($before) > 0 && count($after) > 0) { - //create the table header - $array = array_difference($before, $after, 1); - $table_header = " \n"; - $table_header .= "\n"; - //$table_header .= " Table\n"; - //$table_header .= " Row\n"; - $table_header .= " name\n"; - $table_header .= " old\n"; - $table_header .= " new\n"; - $table_header .= "\n"; - $_SESSION['table_header'] = $table_header; - - //show the difference - echo "\n"; - show_difference($array); - echo "
\n"; - } - -//show the delete - if (count($before) > 0 && count($after) == 0) { - echo "

Record Deleted


\n"; - echo "
\n";
-		print_r($before);
-		echo "		
\n"; - } - -//add a few lines at the end - echo "
\n"; - echo "
\n"; - -//include the footer - require_once "resources/footer.php"; - -?> + + Portions created by the Initial Developer are Copyright (C) 2016 - 2017 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('database_transaction_add') || permission_exists('database_transaction_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//action add or update + if (isset($_REQUEST["id"])) { + //$action = "update"; + $database_transaction_uuid = check_str($_REQUEST["id"]); + } + //else { + // $action = "add"; + //} + +//get http post variables and set them to php variables + /* + if (count($_POST) > 0) { + $user_uuid = check_str($_POST["user_uuid"]); + $app_uuid = check_str($_POST["app_uuid"]); + $transaction_code = check_str($_POST["transaction_code"]); + $transaction_address = check_str($_POST["transaction_address"]); + $transaction_type = check_str($_POST["transaction_type"]); + $transaction_date = check_str($_POST["transaction_date"]); + $transaction_old = check_str($_POST["transaction_old"]); + $transaction_new = check_str($_POST["transaction_new"]); + $transaction_result = check_str($_POST["transaction_result"]); + } + */ + +//process the data + /* + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $database_transaction_uuid = check_str($_POST["database_transaction_uuid"]); + } + + //check for all required data + if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."
\n"; } + if (strlen($user_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-user_uuid']."
\n"; } + if (strlen($app_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-app_uuid']."
\n"; } + if (strlen($transaction_code) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_code']."
\n"; } + if (strlen($transaction_address) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_address']."
\n"; } + if (strlen($transaction_type) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_type']."
\n"; } + if (strlen($transaction_date) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_date']."
\n"; } + if (strlen($transaction_old) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_old']."
\n"; } + if (strlen($transaction_new) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_new']."
\n"; } + if (strlen($transaction_result) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_result']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('database_transaction_add')) { + $sql = "insert into v_database_transactions "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "database_transaction_uuid, "; + $sql .= "domain_uuid, "; + $sql .= "user_uuid, "; + $sql .= "app_uuid, "; + $sql .= "transaction_code, "; + $sql .= "transaction_address, "; + $sql .= "transaction_type, "; + $sql .= "transaction_date, "; + $sql .= "transaction_old, "; + $sql .= "transaction_new, "; + $sql .= "transaction_result "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'$domain_uuid', "; + $sql .= "'$user_uuid', "; + $sql .= "'$app_uuid', "; + $sql .= "'$transaction_code', "; + $sql .= "'$transaction_address', "; + $sql .= "'$transaction_type', "; + $sql .= "now(), "; + $sql .= "'$transaction_old', "; + $sql .= "'$transaction_new', "; + $sql .= "'$transaction_result' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-add']); + header("Location: database_transactions.php"); + return; + + } //if ($action == "add") + + if ($action == "update" && permission_exists('database_transaction_edit')) { + $sql = "update v_database_transactions set "; + $sql .= "domain_uuid = '$domain_uuid', "; + $sql .= "user_uuid = '$user_uuid', "; + $sql .= "app_uuid = '$app_uuid', "; + $sql .= "transaction_code = '$transaction_code', "; + $sql .= "transaction_address = '$transaction_address', "; + $sql .= "transaction_type = '$transaction_type', "; + $sql .= "transaction_date = now(), "; + $sql .= "transaction_old = '$transaction_old', "; + $sql .= "transaction_new = '$transaction_new', "; + $sql .= "transaction_result = '$transaction_result' "; + $sql .= "where database_transaction_uuid = '$database_transaction_uuid'"; + $sql .= "and domain_uuid = '$domain_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-update']); + header("Location: database_transactions.php"); + return; + + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + */ + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $database_transaction_uuid = check_str($_GET["id"]); + + $sql = "select "; + $sql .= "t.database_transaction_uuid, d.domain_name, u.username, t.user_uuid, t.app_name, t.app_uuid, "; + $sql .= "t.transaction_code, t.transaction_address, t.transaction_type, t.transaction_date, "; + $sql .= "t.transaction_old, t.transaction_new, t.transaction_result "; + $sql .= "from v_database_transactions as t, v_domains as d, v_users as u "; + $sql .= "where t.domain_uuid = '$domain_uuid' "; + $sql .= "and t.database_transaction_uuid = '$database_transaction_uuid' "; + $sql .= "and t.user_uuid = u.user_uuid "; + $sql .= "and t.domain_uuid = d.domain_uuid "; + + //$sql = "select *, u.username from v_database_transactions as t, v_users as u "; + //$sql .= "where domain_uuid = '$domain_uuid' "; + //$sql .= "t.user_uuid = u.user_uuid "; + //$sql .= "and database_transaction_uuid = '$database_transaction_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $user_uuid = $row["user_uuid"]; + $app_name = $row["app_name"]; + $app_uuid = $row["app_uuid"]; + $domain_name = $row["domain_name"]; + $username = $row["username"]; + $transaction_code = $row["transaction_code"]; + $transaction_address = $row["transaction_address"]; + //$transaction_type = $row["transaction_type"]; + $transaction_date = $row["transaction_date"]; + $transaction_old = $row["transaction_old"]; + $transaction_new = $row["transaction_new"]; + $transaction_result = $row["transaction_result"]; + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + +//show the content + //echo "
\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['title-database_transaction']."

\n"; + echo " "; + //echo " "; + echo "
\n"; + + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + /*echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + */ + + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-app_name']."\n"; + echo " \n"; + echo " ".$app_name."\n"; + //echo " \n"; + //echo "
\n"; + //echo " ".$text['description-app_uuid']."\n"; + echo "
\n"; + echo " ".$text['label-domain']."\n"; + echo " \n"; + echo " ".$domain_name; + //echo " \n"; + //echo "
\n"; + //echo " ".$text['description-domain']."\n"; + echo "
\n"; + echo " ".$text['label-user_uuid']."\n"; + echo " \n"; + echo " ".$username."\n"; + //echo " \n"; + //echo "
\n"; + //echo " ".$text['description-user_uuid']."\n"; + echo "
\n"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-transaction_code']."\n"; + echo " \n"; + echo " $transaction_code\n"; + //echo " \n"; + //echo "
\n"; + //echo " ".$text['description-transaction_code']."\n"; + echo "
\n"; + echo " ".$text['label-transaction_address']."\n"; + echo " \n"; + echo " $transaction_address\n"; + //echo " \n"; + //echo "
\n"; + //echo " ".$text['description-transaction_address']."\n"; + echo "
\n"; + echo "
\n"; + + //echo "\n"; + //echo "\n"; + //echo " ".$text['label-transaction_type']."\n"; + //echo "\n"; + //echo "\n"; + //echo " \n"; + //echo "
\n"; + //echo $text['description-transaction_type']."\n"; + //echo "\n"; + //echo "\n"; + + if ($_REQUEST["debug"] == "true") { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " ".$text['label-transaction_old']."\n"; + echo "\n"; + //echo " \n"; + echo " \n"; + //echo "
\n"; + //echo $text['description-transaction_old']."\n"; + echo "
\n"; + echo " ".$text['label-transaction_new']."\n"; + echo "\n"; + //echo " \n"; + echo " \n"; + //echo "
\n"; + //echo $text['description-transaction_new']."\n"; + echo "
\n"; + echo " ".$text['label-transaction_result']."\n"; + echo "\n"; + //echo " \n"; + echo " \n"; + //echo "
\n"; + //echo $text['description-transaction_result']."\n"; + echo "
"; + } + + //echo " \n"; + //echo " \n"; + //if ($action == "update") { + // echo " \n"; + //} + //echo " \n"; + //echo " \n"; + //echo " "; + //echo ""; + //echo "
"; + //echo "

"; + +//define the array _difference function + //this adds old and new values to the array + function array_difference($array1, $array2) { + $difference = array(); + if (is_array($array1)) { + foreach($array1 as $key => $value) { + if(is_array($array2[$key])) { + $difference[$key] = array_difference($array1[$key], $array2[$key]); + } + else { + $difference[$key]['old'] = $value; + } + } + } + if (is_array($array2)) { + foreach($array2 as $key => $value) { + if(is_array($value)) { + $difference[$key] = array_difference($array1[$key], $array2[$key]); + } + else { + $difference[$key]['new'] = $value; + } + } + } + return $difference; + } + +//show the content from the difference array as a list + function show_difference($array) { + //loop through the array + foreach($array as $key => $value) { + if(is_array($value) && !isset($value['old']) && !isset($value['new'])) { + if (!is_numeric($key)) { + //get the table name + $_SESSION['name'] = $key; + } + else { + //get the row id + $_SESSION['row'] = $key; + } + $array = show_difference($value); + } + else { + //set the variables + $old = $value['old']; + $new = $value['new']; + if (is_null($old)) { $old = ''; } + if (is_null($new)) { $new = ''; } + //determine if the value has changed + if (strval($old) == strval($new) && isset($old)) { + $color = "#000000"; + } + else { + $color = "#ff0000"; + } + //set the table header + if ($_SESSION['previous_name'] != $_SESSION['name'] || $_SESSION['previous_row'] != $_SESSION['row']) { + echo str_replace("name","".$_SESSION['name']."",$_SESSION['table_header']); + //echo $_SESSION['table_header']; + } + $_SESSION['previous_name'] = $_SESSION['name']; + $_SESSION['previous_row'] = $_SESSION['row']; + //show the results + echo "\n"; + //echo " ".$_SESSION['name']."\n"; + //echo " ".$_SESSION['row']."\n"; + echo " $key\n"; + echo " ".$old."\n"; + echo " ".$new.""; + echo "\n"; + //echo "\n"; + } + } + } + +//decode the json to arrays + $before = json_decode($transaction_old, true); + $after = json_decode($transaction_new, true); + +//unset the sessions + unset($_SESSION['previous_name']); + unset($_SESSION['previous_row']); + +//show the add or update + if (count($before) > 0 && count($after) > 0) { + //create the table header + $array = array_difference($before, $after, 1); + $table_header = " \n"; + $table_header .= "\n"; + //$table_header .= " Table\n"; + //$table_header .= " Row\n"; + $table_header .= " name\n"; + $table_header .= " old\n"; + $table_header .= " new\n"; + $table_header .= "\n"; + $_SESSION['table_header'] = $table_header; + + //show the difference + echo "\n"; + show_difference($array); + echo "
\n"; + } + +//show the delete + if (count($before) > 0 && count($after) == 0) { + echo "

Record Deleted


\n"; + echo "
\n";
+		print_r($before);
+		echo "		
\n"; + } + +//add a few lines at the end + echo "
\n"; + echo "
\n"; + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/database_transactions/root.php b/app/database_transactions/root.php index 62e2c52383..6fdf32f37b 100644 --- a/app/database_transactions/root.php +++ b/app/database_transactions/root.php @@ -1,90 +1,90 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -// make sure the PATH_SEPARATOR is defined - umask(2); - if (!defined("PATH_SEPARATOR")) { - if (strpos($_ENV["OS"], "Win") !== false) { - define("PATH_SEPARATOR", ";"); - } else { - define("PATH_SEPARATOR", ":"); - } - } - - if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; - - // make sure the document_root is set - $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); - if(PHP_SAPI == 'cli'){ - chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); - $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); - $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); - if (file_exists('/project_root.php')) { - $path = '/'; - } else { - $i = 1; - $path = ''; - while ($i < count($dirs)) { - $path .= '/' . $dirs[$i]; - if (file_exists($path. '/project_root.php')) { - break; - } - $i++; - } - } - $_SERVER["DOCUMENT_ROOT"] = $path; - }else{ - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - } - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// try to detect if a project path is being used - if (!defined('PROJECT_PATH')) { - if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { - define('PROJECT_PATH', '/fusionpbx'); - } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { - define('PROJECT_PATH', ''); - } else { - $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); - $i = 1; - $path = $_SERVER["DOCUMENT_ROOT"]; - while ($i < count($dirs)) { - $path .= '/' . $dirs[$i]; - if (file_exists($path. '/project_root.php')) { - break; - } - $i++; - } - if(!file_exists($path. '/project_root.php')){ - die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); - } - $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); - define('PROJECT_PATH', $project_path); - } - $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); - set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); - } - + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + if(!file_exists($path. '/project_root.php')){ + die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + ?> \ No newline at end of file diff --git a/app/devices/device_profile_edit.php b/app/devices/device_profile_edit.php index da50a3c87b..05a8cc7561 100644 --- a/app/devices/device_profile_edit.php +++ b/app/devices/device_profile_edit.php @@ -1,732 +1,732 @@ - - Copyright (C) 2008-2016 All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - require_once "resources/check_auth.php"; - -//check permissions - if (permission_exists('device_profile_add') || permission_exists('device_profile_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//action add or update - if (isset($_REQUEST["id"])) { - $action = "update"; - $device_profile_uuid = check_str($_REQUEST["id"]); - } - else { - $action = "add"; - } - -//get http post variables and set them to php variables - if (count($_POST) > 0) { - //echo ""; exit; - $device_profile_name = check_str($_POST["device_profile_name"]); - $device_profile_enabled = check_str($_POST["device_profile_enabled"]); - $device_profile_description = check_str($_POST["device_profile_description"]); - $device_key_category = check_str($_POST["device_key_category"]); - $device_key_id = check_str($_POST["device_key_id"]); - $device_key_type = check_str($_POST["device_key_type"]); - $device_key_line = check_str($_POST["device_key_line"]); - $device_key_value = check_str($_POST["device_key_value"]); - $device_key_extension = check_str($_POST["device_key_extension"]); - $device_key_label = check_str($_POST["device_key_label"]); - - //$device_setting_category = check_str($_POST["device_setting_category"]); - $device_setting_subcategory = check_str($_POST["device_setting_subcategory"]); - //$device_setting_name = check_str($_POST["device_setting_name"]); - $device_setting_value = check_str($_POST["device_setting_value"]); - $device_setting_enabled = check_str($_POST["device_setting_enabled"]); - $device_setting_description = check_str($_POST["device_setting_description"]); - - //allow the domain_uuid to be changed only with the device_profile_domain permission - if (permission_exists('device_profile_domain')) { - $domain_uuid = check_str($_POST["domain_uuid"]); - } - else { - $_POST["domain_uuid"] = $_SESSION['domain_uuid']; - } - } - -//add or update the database - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - - //check for all required data - $msg = ''; - if (strlen($device_profile_name) == 0) { $msg .= $text['message-required'].$text['label-profile_name']."
\n"; } - if (strlen($msg) > 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - //add domain_uuid to the array - foreach ($_POST as $key => $value) { - if (is_array($value)) { - $y = 0; - foreach ($value as $k => $v) { - if (!isset($v["domain_uuid"])) { - $_POST[$key][$y]["domain_uuid"] = $_POST["domain_uuid"]; - } - $y++; - } - } - } - - //array cleanup - $x = 0; - foreach ($_POST["device_keys"] as $row) { - //unset the empty row - if (strlen($row["device_key_category"]) == 0) { - unset($_POST["device_keys"][$x]); - } - //unset device_detail_uuid if the field has no value - if (strlen($row["device_key_uuid"]) == 0) { - unset($_POST["device_keys"][$x]["device_key_uuid"]); - } - //increment the row - $x++; - } - - $x = 0; - foreach ($_POST["device_settings"] as $row) { - //unset the empty row - if (strlen($row["device_setting_subcategory"]) == 0) { - unset($_POST["device_settings"][$x]); - } - //unset device_detail_uuid if the field has no value - if (strlen($row["device_setting_uuid"]) == 0) { - unset($_POST["device_settings"][$x]["device_setting_uuid"]); - } - //increment the row - $x++; - } - - - //prepare the array - $array['device_profiles'][] = $_POST; - - //set the default - $save = true; - - //save the profile - if ($save) { - $database = new database; - $database->app_name = 'devices'; - $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; - if (strlen($device_profile_uuid) > 0) { - $database->uuid($device_profile_uuid); - } - $database->save($array); - $response = $database->message; - if (strlen($response['uuid']) > 0) { - $device_profile_uuid = $response['uuid']; - } - } - - //write the provision files - if (strlen($_SESSION['provision']['path']['text']) > 0) { - $prov = new provision; - $prov->domain_uuid = $domain_uuid; - $response = $prov->write(); - } - - //set the message - if (!isset($_SESSION['message'])) { - if ($save) { - if ($action == "add") { - //save the message to a session variable - messages::add($text['message-add']); - } - if ($action == "update") { - //save the message to a session variable - messages::add($text['message-update']); - - } - //redirect the browser - header("Location: device_profile_edit.php?id=".$device_profile_uuid); - exit; - } - } - - } //if ($_POST["persistformvar"] != "true") - } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) - -//pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $sql = "select * from v_device_profiles "; - $sql .= "where device_profile_uuid = '$device_profile_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $device_profile_name = $row["device_profile_name"]; - $device_profile_domain_uuid = $row["domain_uuid"]; - $device_profile_enabled = $row["device_profile_enabled"]; - $device_profile_description = $row["device_profile_description"]; - } - unset ($prep_statement); - } - -//set the sub array index - $x = "999"; - -//get device keys - $sql = "SELECT * FROM v_device_keys "; - $sql .= "WHERE device_profile_uuid = '".$device_profile_uuid."' "; - $sql .= "ORDER by "; - $sql .= "device_key_vendor asc, "; - $sql .= "CASE device_key_category "; - $sql .= "WHEN 'line' THEN 1 "; - $sql .= "WHEN 'memory' THEN 2 "; - $sql .= "WHEN 'programmable' THEN 3 "; - $sql .= "WHEN 'expansion' THEN 4 "; - $sql .= "ELSE 100 END, "; - if ($db_type == "mysql") { - $sql .= "device_key_id asc "; - } - else { - $sql .= "cast(device_key_id as numeric) asc "; - } - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $device_keys[$x]['device_key_category'] = ''; - $device_keys[$x]['device_key_id'] = ''; - $device_keys[$x]['device_key_type'] = ''; - $device_keys[$x]['device_key_line'] = ''; - $device_keys[$x]['device_key_value'] = ''; - $device_keys[$x]['device_key_extension'] = ''; - $device_keys[$x]['device_key_protected'] = ''; - $device_keys[$x]['device_key_label'] = ''; - -//get the vendors - $sql = "SELECT * "; - $sql .= "FROM v_device_vendors as v "; - $sql .= "where enabled = 'true' "; - $sql .= "order by name asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $vendors = $prep_statement->fetchAll(PDO::FETCH_NAMED); - -//get the vendor functions - $sql = "SELECT v.name as vendor_name, f.name, f.value "; - $sql .= "FROM v_device_vendors as v, v_device_vendor_functions as f "; - $sql .= "where v.device_vendor_uuid = f.device_vendor_uuid "; - $sql .= "and v.enabled = 'true' "; - $sql .= "and f.enabled = 'true' "; - $sql .= "order by v.name asc, f.name asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); - -//get the vendor count - $vendor_count = 0; - foreach($device_keys as $row) { - if ($previous_vendor != $row['device_key_vendor']) { - $previous_vendor = $row['device_key_vendor']; - $vendor_count++; - } - } - -//get device settings - $sql = "SELECT * FROM v_device_settings "; - $sql .= "WHERE device_profile_uuid = '".$device_profile_uuid."' "; - $sql .= "ORDER by device_setting_subcategory asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $device_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $device_settings[$x]['device_setting_name'] = ''; - $device_settings[$x]['device_setting_value'] = ''; - $device_settings[$x]['enabled'] = ''; - $device_settings[$x]['device_setting_description'] = ''; - -//show the header - require_once "resources/header.php"; - $document['title'] = $text['title-profile']; - -//javascript to change select to input and back again - ?> - -\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo " "; - echo " "; - echo " "; - echo " "; - -//device settings - echo " "; - echo " "; - echo " \n"; - echo " \n"; - - - if (permission_exists('device_profile_domain')) { - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - } - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo ""; - echo "
"; - echo " ".$text['header-profile'].""; - echo "

"; - echo " ".$text['description-profile']; - echo "

"; - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['label-profile_name']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-profile_name']."\n"; - echo "
".$text['label-keys'].""; - echo " \n"; - if ($vendor_count == 0) { - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (permission_exists('device_key_extension')) { - echo " \n"; - } - if (permission_exists('device_key_protected')) { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - } - - $x = 0; - foreach($device_keys as $row) { - - //set the device vendor - $device_vendor = $row['device_key_vendor']; - - //get the device key vendor from the key type - foreach ($vendor_functions as $function) { - if ($row['device_key_vendor'] == $function['vendor_name'] && $row['device_key_type'] == $function['value']) { - $device_key_vendor = $function['vendor_name']; - } - } - - //set the column names - if ($previous_device_key_vendor != $row['device_key_vendor']) { - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (permission_exists('device_key_extension')) { - echo " \n"; - } - if (permission_exists('device_key_protected')) { - echo " \n"; - } - echo " \n"; - echo " \n"; - echo " \n"; - } - //determine whether to hide the element - if (strlen($device_key_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_key_uuid']) > 0) { - echo " \n"; - } - //show all the rows in the array - echo "\n"; - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - echo "\n"; - - echo "\n"; - - if (permission_exists('device_key_extension')) { - echo "\n"; - } - - if (permission_exists('device_key_protected')) { - echo " \n"; - } - - echo "\n"; - - echo "\n"; - echo " \n"; - //set the previous vendor - $previous_device_key_vendor = $row['device_key_vendor']; - //increment the array key - $x++; - } - echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_vendor']."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_protected']."".$text['label-device_key_label']." 
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_vendor']."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_protected']."".$text['label-device_key_label']." 
\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - if (strlen($row['device_key_uuid']) > 0) { - if (permission_exists('device_key_delete')) { - echo " $v_link_label_delete\n"; - } - } - echo "
\n"; - if (strlen($text['description-keys']) > 0) { - echo "
".$text['description-keys']."\n"; - } - echo "
".$text['label-settings'].""; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - - $x = 0; - foreach($device_settings as $row) { - //determine whether to hide the element - if (strlen($device_setting_uuid) == 0) { - $element['hidden'] = false; - $element['visibility'] = "visibility:visible;"; - } - else { - $element['hidden'] = true; - $element['visibility'] = "visibility:hidden;"; - } - //add the primary key uuid - if (strlen($row['device_setting_uuid']) > 0) { - echo " \n"; - } - - //show alls rows in the array - echo "\n"; - echo "\n"; - - echo "\n"; - - echo "\n"; - - echo "\n"; - - if (strlen($text['description-settings']) > 0) { - echo "
".$text['description-settings']."\n"; - } - echo " "; - - echo " \n"; - echo " \n"; - $x++; - } - /* - echo "
".$text['label-device_setting_name']."".$text['label-device_setting_value']."".$text['label-enabled']."".$text['label-device_setting_description']." 
\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - echo " \n"; - echo "\n"; - if (strlen($row['device_setting_uuid']) > 0) { - echo " $v_link_label_delete\n"; - } - echo "
\n"; - echo " \n"; - */ - echo "
\n"; - echo "
\n"; - echo " ".$text['label-profile_domain']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo " ".$text['label-profile_enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-profile_enabled']."\n"; - echo "
\n"; - echo " ".$text['label-profile_description']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-profile_description']."\n"; - echo "
\n"; - if ($action == "update") { - echo " \n"; - } - echo "
"; - echo " \n"; - echo "
"; - echo "

"; - echo ""; - -//show the footer - require_once "resources/footer.php"; - -?> + + Copyright (C) 2008-2016 All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; + +//check permissions + if (permission_exists('device_profile_add') || permission_exists('device_profile_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $device_profile_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST) > 0) { + //echo ""; exit; + $device_profile_name = check_str($_POST["device_profile_name"]); + $device_profile_enabled = check_str($_POST["device_profile_enabled"]); + $device_profile_description = check_str($_POST["device_profile_description"]); + $device_key_category = check_str($_POST["device_key_category"]); + $device_key_id = check_str($_POST["device_key_id"]); + $device_key_type = check_str($_POST["device_key_type"]); + $device_key_line = check_str($_POST["device_key_line"]); + $device_key_value = check_str($_POST["device_key_value"]); + $device_key_extension = check_str($_POST["device_key_extension"]); + $device_key_label = check_str($_POST["device_key_label"]); + + //$device_setting_category = check_str($_POST["device_setting_category"]); + $device_setting_subcategory = check_str($_POST["device_setting_subcategory"]); + //$device_setting_name = check_str($_POST["device_setting_name"]); + $device_setting_value = check_str($_POST["device_setting_value"]); + $device_setting_enabled = check_str($_POST["device_setting_enabled"]); + $device_setting_description = check_str($_POST["device_setting_description"]); + + //allow the domain_uuid to be changed only with the device_profile_domain permission + if (permission_exists('device_profile_domain')) { + $domain_uuid = check_str($_POST["domain_uuid"]); + } + else { + $_POST["domain_uuid"] = $_SESSION['domain_uuid']; + } + } + +//add or update the database + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + //check for all required data + $msg = ''; + if (strlen($device_profile_name) == 0) { $msg .= $text['message-required'].$text['label-profile_name']."
\n"; } + if (strlen($msg) > 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + //add domain_uuid to the array + foreach ($_POST as $key => $value) { + if (is_array($value)) { + $y = 0; + foreach ($value as $k => $v) { + if (!isset($v["domain_uuid"])) { + $_POST[$key][$y]["domain_uuid"] = $_POST["domain_uuid"]; + } + $y++; + } + } + } + + //array cleanup + $x = 0; + foreach ($_POST["device_keys"] as $row) { + //unset the empty row + if (strlen($row["device_key_category"]) == 0) { + unset($_POST["device_keys"][$x]); + } + //unset device_detail_uuid if the field has no value + if (strlen($row["device_key_uuid"]) == 0) { + unset($_POST["device_keys"][$x]["device_key_uuid"]); + } + //increment the row + $x++; + } + + $x = 0; + foreach ($_POST["device_settings"] as $row) { + //unset the empty row + if (strlen($row["device_setting_subcategory"]) == 0) { + unset($_POST["device_settings"][$x]); + } + //unset device_detail_uuid if the field has no value + if (strlen($row["device_setting_uuid"]) == 0) { + unset($_POST["device_settings"][$x]["device_setting_uuid"]); + } + //increment the row + $x++; + } + + + //prepare the array + $array['device_profiles'][] = $_POST; + + //set the default + $save = true; + + //save the profile + if ($save) { + $database = new database; + $database->app_name = 'devices'; + $database->app_uuid = '4efa1a1a-32e7-bf83-534b-6c8299958a8e'; + if (strlen($device_profile_uuid) > 0) { + $database->uuid($device_profile_uuid); + } + $database->save($array); + $response = $database->message; + if (strlen($response['uuid']) > 0) { + $device_profile_uuid = $response['uuid']; + } + } + + //write the provision files + if (strlen($_SESSION['provision']['path']['text']) > 0) { + $prov = new provision; + $prov->domain_uuid = $domain_uuid; + $response = $prov->write(); + } + + //set the message + if (!isset($_SESSION['message'])) { + if ($save) { + if ($action == "add") { + //save the message to a session variable + messages::add($text['message-add']); + } + if ($action == "update") { + //save the message to a session variable + messages::add($text['message-update']); + + } + //redirect the browser + header("Location: device_profile_edit.php?id=".$device_profile_uuid); + exit; + } + } + + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $sql = "select * from v_device_profiles "; + $sql .= "where device_profile_uuid = '$device_profile_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $device_profile_name = $row["device_profile_name"]; + $device_profile_domain_uuid = $row["domain_uuid"]; + $device_profile_enabled = $row["device_profile_enabled"]; + $device_profile_description = $row["device_profile_description"]; + } + unset ($prep_statement); + } + +//set the sub array index + $x = "999"; + +//get device keys + $sql = "SELECT * FROM v_device_keys "; + $sql .= "WHERE device_profile_uuid = '".$device_profile_uuid."' "; + $sql .= "ORDER by "; + $sql .= "device_key_vendor asc, "; + $sql .= "CASE device_key_category "; + $sql .= "WHEN 'line' THEN 1 "; + $sql .= "WHEN 'memory' THEN 2 "; + $sql .= "WHEN 'programmable' THEN 3 "; + $sql .= "WHEN 'expansion' THEN 4 "; + $sql .= "ELSE 100 END, "; + if ($db_type == "mysql") { + $sql .= "device_key_id asc "; + } + else { + $sql .= "cast(device_key_id as numeric) asc "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $device_keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $device_keys[$x]['device_key_category'] = ''; + $device_keys[$x]['device_key_id'] = ''; + $device_keys[$x]['device_key_type'] = ''; + $device_keys[$x]['device_key_line'] = ''; + $device_keys[$x]['device_key_value'] = ''; + $device_keys[$x]['device_key_extension'] = ''; + $device_keys[$x]['device_key_protected'] = ''; + $device_keys[$x]['device_key_label'] = ''; + +//get the vendors + $sql = "SELECT * "; + $sql .= "FROM v_device_vendors as v "; + $sql .= "where enabled = 'true' "; + $sql .= "order by name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $vendors = $prep_statement->fetchAll(PDO::FETCH_NAMED); + +//get the vendor functions + $sql = "SELECT v.name as vendor_name, f.name, f.value "; + $sql .= "FROM v_device_vendors as v, v_device_vendor_functions as f "; + $sql .= "where v.device_vendor_uuid = f.device_vendor_uuid "; + $sql .= "and v.enabled = 'true' "; + $sql .= "and f.enabled = 'true' "; + $sql .= "order by v.name asc, f.name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); + +//get the vendor count + $vendor_count = 0; + foreach($device_keys as $row) { + if ($previous_vendor != $row['device_key_vendor']) { + $previous_vendor = $row['device_key_vendor']; + $vendor_count++; + } + } + +//get device settings + $sql = "SELECT * FROM v_device_settings "; + $sql .= "WHERE device_profile_uuid = '".$device_profile_uuid."' "; + $sql .= "ORDER by device_setting_subcategory asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $device_settings = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $device_settings[$x]['device_setting_name'] = ''; + $device_settings[$x]['device_setting_value'] = ''; + $device_settings[$x]['enabled'] = ''; + $device_settings[$x]['device_setting_description'] = ''; + +//show the header + require_once "resources/header.php"; + $document['title'] = $text['title-profile']; + +//javascript to change select to input and back again + ?> + +\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " "; + echo " "; + echo " "; + echo " "; + +//device settings + echo " "; + echo " "; + echo " \n"; + echo " \n"; + + + if (permission_exists('device_profile_domain')) { + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + } + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo ""; + echo "
"; + echo " ".$text['header-profile'].""; + echo "

"; + echo " ".$text['description-profile']; + echo "

"; + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-profile_name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-profile_name']."\n"; + echo "
".$text['label-keys'].""; + echo " \n"; + if ($vendor_count == 0) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('device_key_extension')) { + echo " \n"; + } + if (permission_exists('device_key_protected')) { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + } + + $x = 0; + foreach($device_keys as $row) { + + //set the device vendor + $device_vendor = $row['device_key_vendor']; + + //get the device key vendor from the key type + foreach ($vendor_functions as $function) { + if ($row['device_key_vendor'] == $function['vendor_name'] && $row['device_key_type'] == $function['value']) { + $device_key_vendor = $function['vendor_name']; + } + } + + //set the column names + if ($previous_device_key_vendor != $row['device_key_vendor']) { + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('device_key_extension')) { + echo " \n"; + } + if (permission_exists('device_key_protected')) { + echo " \n"; + } + echo " \n"; + echo " \n"; + echo " \n"; + } + //determine whether to hide the element + if (strlen($device_key_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_key_uuid']) > 0) { + echo " \n"; + } + //show all the rows in the array + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + echo "\n"; + + echo "\n"; + + if (permission_exists('device_key_extension')) { + echo "\n"; + } + + if (permission_exists('device_key_protected')) { + echo " \n"; + } + + echo "\n"; + + echo "\n"; + echo " \n"; + //set the previous vendor + $previous_device_key_vendor = $row['device_key_vendor']; + //increment the array key + $x++; + } + echo "
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_vendor']."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_protected']."".$text['label-device_key_label']." 
".$text['label-device_key_category']."".$text['label-device_key_id']."".$text['label-device_vendor']."".$text['label-device_key_type']."".$text['label-device_key_line']."".$text['label-device_key_value']."".$text['label-device_key_extension']."".$text['label-device_key_protected']."".$text['label-device_key_label']." 
\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if (strlen($row['device_key_uuid']) > 0) { + if (permission_exists('device_key_delete')) { + echo " $v_link_label_delete\n"; + } + } + echo "
\n"; + if (strlen($text['description-keys']) > 0) { + echo "
".$text['description-keys']."\n"; + } + echo "
".$text['label-settings'].""; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + + $x = 0; + foreach($device_settings as $row) { + //determine whether to hide the element + if (strlen($device_setting_uuid) == 0) { + $element['hidden'] = false; + $element['visibility'] = "visibility:visible;"; + } + else { + $element['hidden'] = true; + $element['visibility'] = "visibility:hidden;"; + } + //add the primary key uuid + if (strlen($row['device_setting_uuid']) > 0) { + echo " \n"; + } + + //show alls rows in the array + echo "\n"; + echo "\n"; + + echo "\n"; + + echo "\n"; + + echo "\n"; + + if (strlen($text['description-settings']) > 0) { + echo "
".$text['description-settings']."\n"; + } + echo " "; + + echo " \n"; + echo " \n"; + $x++; + } + /* + echo "
".$text['label-device_setting_name']."".$text['label-device_setting_value']."".$text['label-enabled']."".$text['label-device_setting_description']." 
\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + echo " \n"; + echo "\n"; + if (strlen($row['device_setting_uuid']) > 0) { + echo " $v_link_label_delete\n"; + } + echo "
\n"; + echo " \n"; + */ + echo "
\n"; + echo "
\n"; + echo " ".$text['label-profile_domain']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo " ".$text['label-profile_enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-profile_enabled']."\n"; + echo "
\n"; + echo " ".$text['label-profile_description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-profile_description']."\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo "
"; + echo " \n"; + echo "
"; + echo "

"; + echo ""; + +//show the footer + require_once "resources/footer.php"; + +?> diff --git a/app/devices/device_vendor_delete.php b/app/devices/device_vendor_delete.php index fed2d0b488..b5b3dfa2cc 100644 --- a/app/devices/device_vendor_delete.php +++ b/app/devices/device_vendor_delete.php @@ -1,64 +1,64 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('device_vendor_delete')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get the id - if (count($_GET)>0) { - $id = check_str($_GET["id"]); - } - -//delete the data - if (strlen($id)>0) { - //delete device_vendor - $sql = "delete from v_device_vendors "; - $sql .= "where device_vendor_uuid = '$id' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - unset($sql); - } - -//redirect the user - messages::add($text['message-delete']); - header('Location: device_vendors.php'); - + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('device_vendor_delete')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the id + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } + +//delete the data + if (strlen($id)>0) { + //delete device_vendor + $sql = "delete from v_device_vendors "; + $sql .= "where device_vendor_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + messages::add($text['message-delete']); + header('Location: device_vendors.php'); + ?> \ No newline at end of file diff --git a/app/devices/device_vendor_edit.php b/app/devices/device_vendor_edit.php index ddd32770c4..455c77ed08 100644 --- a/app/devices/device_vendor_edit.php +++ b/app/devices/device_vendor_edit.php @@ -1,223 +1,223 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('device_vendor_add') || permission_exists('device_vendor_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//action add or update - if (isset($_REQUEST["id"])) { - $action = "update"; - $device_vendor_uuid = check_str($_REQUEST["id"]); - } - else { - $action = "add"; - } - -//get http post variables and set them to php variables - if (count($_POST)>0) { - $name = check_str($_POST["name"]); - $enabled = check_str($_POST["enabled"]); - $description = check_str($_POST["description"]); - } - -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { - - $msg = ''; - if ($action == "update") { - $device_vendor_uuid = check_str($_POST["device_vendor_uuid"]); - } - - //check for all required data - if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } - if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } - //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - if ($action == "add" && permission_exists('device_vendor_add')) { - $sql = "insert into v_device_vendors "; - $sql .= "("; - $sql .= "device_vendor_uuid, "; - $sql .= "name, "; - $sql .= "enabled, "; - $sql .= "description "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'".uuid()."', "; - $sql .= "'$name', "; - $sql .= "'$enabled', "; - $sql .= "'$description' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-add']); - header("Location: device_vendors.php"); - return; - - } //if ($action == "add") - - if ($action == "update" && permission_exists('device_vendor_edit')) { - $sql = "update v_device_vendors set "; - $sql .= "name = '$name', "; - $sql .= "enabled = '$enabled', "; - $sql .= "description = '$description' "; - $sql .= "where device_vendor_uuid = '$device_vendor_uuid'"; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-update']); - header("Location: device_vendors.php"); - return; - - } //if ($action == "update") - } //if ($_POST["persistformvar"] != "true") -} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - -//pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $device_vendor_uuid = check_str($_GET["id"]); - $sql = "select * from v_device_vendors "; - $sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $name = $row["name"]; - $enabled = $row["enabled"]; - $description = $row["description"]; - } - unset ($prep_statement); - } - -//show the header - require_once "resources/header.php"; - -//show the content - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " "; - echo "
".$text['title-device_vendor']."

\n"; - echo " "; - echo " "; - echo "
\n"; - echo " ".$text['label-name']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-name']."\n"; - echo "
\n"; - echo " ".$text['label-enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-enabled']."\n"; - echo "
\n"; - echo " ".$text['label-description']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-description']."\n"; - echo "
\n"; - if ($action == "update") { - echo " \n"; - } - echo " \n"; - echo "
"; - echo "
"; - echo "

"; - - if ($action == "update") { - require "device_vendor_functions.php"; - } - -//include the footer - require_once "resources/footer.php"; - + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('device_vendor_add') || permission_exists('device_vendor_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $device_vendor_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $name = check_str($_POST["name"]); + $enabled = check_str($_POST["enabled"]); + $description = check_str($_POST["description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $device_vendor_uuid = check_str($_POST["device_vendor_uuid"]); + } + + //check for all required data + if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } + if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } + //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('device_vendor_add')) { + $sql = "insert into v_device_vendors "; + $sql .= "("; + $sql .= "device_vendor_uuid, "; + $sql .= "name, "; + $sql .= "enabled, "; + $sql .= "description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".uuid()."', "; + $sql .= "'$name', "; + $sql .= "'$enabled', "; + $sql .= "'$description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-add']); + header("Location: device_vendors.php"); + return; + + } //if ($action == "add") + + if ($action == "update" && permission_exists('device_vendor_edit')) { + $sql = "update v_device_vendors set "; + $sql .= "name = '$name', "; + $sql .= "enabled = '$enabled', "; + $sql .= "description = '$description' "; + $sql .= "where device_vendor_uuid = '$device_vendor_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-update']); + header("Location: device_vendors.php"); + return; + + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $device_vendor_uuid = check_str($_GET["id"]); + $sql = "select * from v_device_vendors "; + $sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $name = $row["name"]; + $enabled = $row["enabled"]; + $description = $row["description"]; + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
".$text['title-device_vendor']."

\n"; + echo " "; + echo " "; + echo "
\n"; + echo " ".$text['label-name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-name']."\n"; + echo "
\n"; + echo " ".$text['label-enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-enabled']."\n"; + echo "
\n"; + echo " ".$text['label-description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-description']."\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "

"; + + if ($action == "update") { + require "device_vendor_functions.php"; + } + +//include the footer + require_once "resources/footer.php"; + ?> \ No newline at end of file diff --git a/app/devices/device_vendor_function_delete.php b/app/devices/device_vendor_function_delete.php index f7c4abda16..1c6490d793 100644 --- a/app/devices/device_vendor_function_delete.php +++ b/app/devices/device_vendor_function_delete.php @@ -1,65 +1,65 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('device_vendor_function_delete')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get the id - if (count($_GET)>0) { - $id = check_str($_GET["id"]); - $device_vendor_uuid = check_str($_GET["device_vendor_uuid"]); - } - -//delete the data - if (strlen($id)>0) { - //delete device_vendor_function - $sql = "delete from v_device_vendor_functions "; - $sql .= "where device_vendor_function_uuid = '$id' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - unset($sql); - } - -//redirect the user - messages::add($text['message-delete']); - header('Location: device_vendor_function_edit.php?id='.$device_vendor_uuid); - + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('device_vendor_function_delete')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the id + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + $device_vendor_uuid = check_str($_GET["device_vendor_uuid"]); + } + +//delete the data + if (strlen($id)>0) { + //delete device_vendor_function + $sql = "delete from v_device_vendor_functions "; + $sql .= "where device_vendor_function_uuid = '$id' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + messages::add($text['message-delete']); + header('Location: device_vendor_function_edit.php?id='.$device_vendor_uuid); + ?> \ No newline at end of file diff --git a/app/devices/device_vendor_function_edit.php b/app/devices/device_vendor_function_edit.php index 1b539f9ee3..4bbae27150 100644 --- a/app/devices/device_vendor_function_edit.php +++ b/app/devices/device_vendor_function_edit.php @@ -1,393 +1,393 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//delete the group from the menu item - if ($_REQUEST["a"] == "delete" && permission_exists("device_vendor_function_delete") && $_REQUEST["id"] != '') { - //get the id - $device_vendor_function_group_uuid = check_str($_REQUEST["id"]); - $device_vendor_function_uuid = check_str($_REQUEST["device_vendor_function_uuid"]); - $device_vendor_uuid = check_str($_REQUEST["device_vendor_uuid"]); - //delete the group from the users - $sql = "delete from v_device_vendor_function_groups "; - $sql .= "where device_vendor_function_group_uuid = '".$device_vendor_function_group_uuid."' "; - $db->exec(check_sql($sql)); - //redirect the browser - messages::add($text['message-delete']); - header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid); - return; - } - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//action add or update - if (isset($_REQUEST["id"])) { - $action = "update"; - $device_vendor_function_uuid = check_str($_REQUEST["id"]); - } - else { - $action = "add"; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//set the parent uuid - if (strlen($_GET["device_vendor_uuid"]) > 0) { - $device_vendor_uuid = check_str($_GET["device_vendor_uuid"]); - } - -//get http post variables and set them to php variables - if (count($_POST)>0) { - //$label = check_str($_POST["label"]); - $name = check_str($_POST["name"]); - $value = check_str($_POST["value"]); - $enabled = check_str($_POST["enabled"]); - $description = check_str($_POST["description"]); - } - -//process the http variables - if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { - - //get the uuid - if ($action == "update") { - $device_vendor_function_uuid = check_str($_POST["device_vendor_function_uuid"]); - } - - //check for all required data - $msg = ''; - //if (strlen($label) == 0) { $msg .= $text['message-required']." ".$text['label-label']."
\n"; } - if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } - if (strlen($value) == 0) { $msg .= $text['message-required']." ".$text['label-value']."
\n"; } - if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } - //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - - //add vendor functions - if ($action == "add" && permission_exists('device_vendor_function_add')) { - $device_vendor_function_uuid = uuid(); - $sql = "insert into v_device_vendor_functions "; - $sql .= "("; - $sql .= "device_vendor_function_uuid, "; - $sql .= "device_vendor_uuid, "; - //$sql .= "label, "; - $sql .= "name, "; - $sql .= "value, "; - $sql .= "enabled, "; - $sql .= "description "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'".$device_vendor_function_uuid."', "; - $sql .= "'$device_vendor_uuid', "; - //$sql .= "'$label', "; - $sql .= "'$name', "; - $sql .= "'$value', "; - $sql .= "'$enabled', "; - $sql .= "'$description' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - } //if ($action == "add") - - //update vendor functions - if ($action == "update" && permission_exists('device_vendor_function_edit')) { - $sql = "update v_device_vendor_functions set "; - $sql .= "device_vendor_uuid = '$device_vendor_uuid', "; - //$sql .= "label = '$label', "; - $sql .= "name = '$name', "; - $sql .= "value = '$value', "; - $sql .= "enabled = '$enabled', "; - $sql .= "description = '$description' "; - $sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid'"; - $db->exec(check_sql($sql)); - unset($sql); - } //if ($action == "update") - - //add a group to the menu - if (permission_exists('device_vendor_function_add') && $_REQUEST["group_uuid_name"] != '') { - - //get the group uuid and group_name - $group_data = explode('|', check_str($_REQUEST["group_uuid_name"])); - $group_uuid = $group_data[0]; - $group_name = $group_data[1]; - - //add the group to the menu - if (strlen($device_vendor_function_uuid) > 0) { - $device_vendor_function_group_uuid = uuid(); - $sql = "insert into v_device_vendor_function_groups "; - $sql .= "("; - $sql .= "device_vendor_function_group_uuid, "; - $sql .= "device_vendor_function_uuid, "; - $sql .= "device_vendor_uuid, "; - $sql .= "group_name, "; - $sql .= "group_uuid "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'".$device_vendor_function_group_uuid."', "; - $sql .= "'".$device_vendor_function_uuid."', "; - $sql .= "'".$device_vendor_uuid."', "; - $sql .= "'".$group_name."', "; - $sql .= "'".$group_uuid."' "; - $sql .= ")"; - $db->exec($sql); - } - } - - //redirect the user - $_SESSION["message"] = $text['message-'.$action]; - header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid); - return; - } //if ($_POST["persistformvar"] != "true") - } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - -//pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $device_vendor_function_uuid = check_str($_GET["id"]); - $sql = "select * from v_device_vendor_functions "; - $sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $device_vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($device_vendor_functions as &$row) { - //$label = $row["label"]; - $name = $row["name"]; - $value = $row["value"]; - $enabled = $row["enabled"]; - $description = $row["description"]; - } - unset ($prep_statement); - } - -//group groups assigned - $sql = "select "; - $sql .= " fg.*, g.domain_uuid as group_domain_uuid "; - $sql .= "from "; - $sql .= " v_device_vendor_function_groups as fg, "; - $sql .= " v_groups as g "; - $sql .= "where "; - $sql .= " fg.group_uuid = g.group_uuid "; - $sql .= " and fg.device_vendor_uuid = :device_vendor_uuid "; - //$sql .= " and fg.device_vendor_uuid = '$device_vendor_uuid' "; - $sql .= " and fg.device_vendor_function_uuid = :device_vendor_function_uuid "; - //$sql .= " and fg.device_vendor_function_uuid = '$device_vendor_function_uuid' "; - $sql .= "order by "; - $sql .= " g.domain_uuid desc, "; - $sql .= " g.group_name asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid); - $prep_statement->bindParam(':device_vendor_function_uuid', $device_vendor_function_uuid); - $prep_statement->execute(); - $function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($sql, $prep_statement); - -//set the assigned_groups array - if (is_array($menu_item_groups)) { - foreach($menu_item_groups as $field) { - if (strlen($field['group_name']) > 0) { - $assigned_groups[] = $field['group_uuid']; - } - } - } - -//get the groups - $sql = "select * from v_groups "; - if (sizeof($assigned_groups) > 0) { - $sql .= "where group_uuid not in ('".implode("','",$assigned_groups)."') "; - } - $sql .= "order by domain_uuid desc, group_name asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($sql, $prep_statement); - -//show the header - require_once "resources/header.php"; - -//show the content - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - //echo "\n"; - //echo "\n"; - //echo "\n"; - //echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - //echo "
\n";
-	//print_r($function_groups);
-	//echo "
\n"; - echo " "; - echo " "; - echo " "; - echo " "; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " "; - echo "
".$text['title-device_vendor_function']."

\n"; - echo " "; - echo " "; - echo "
\n"; - //echo " ".$text['label-label']."\n"; - //echo "\n"; - //echo " \n"; - //echo "
\n"; - //echo $text['description-label']."\n"; - //echo "
\n"; - echo " ".$text['label-name']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-name']."\n"; - echo "
\n"; - echo " ".$text['label-value']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-value']."\n"; - echo "
".$text['label-groups'].""; - if (is_array($function_groups)) { - echo "\n"; - foreach($function_groups as $field) { - if (strlen($field['group_name']) > 0) { - echo "\n"; - echo " \n"; - if (permission_exists('group_member_delete') || if_group("superadmin")) { - echo " "; - } - echo "\n"; - } - } - echo "
"; - echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); - echo " "; - echo "".$v_link_label_delete.""; - echo "
\n"; - } - if (is_array($groups)) { - echo "
\n"; - echo ""; - echo "\n"; - } - echo "
\n"; - echo " ".$text['label-enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-enabled']."\n"; - echo "
\n"; - echo " ".$text['label-description']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-description']."\n"; - echo "
\n"; - echo " \n"; - if ($action == "update") { - echo " \n"; - } - echo " \n"; - echo "
"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; - -?> + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//delete the group from the menu item + if ($_REQUEST["a"] == "delete" && permission_exists("device_vendor_function_delete") && $_REQUEST["id"] != '') { + //get the id + $device_vendor_function_group_uuid = check_str($_REQUEST["id"]); + $device_vendor_function_uuid = check_str($_REQUEST["device_vendor_function_uuid"]); + $device_vendor_uuid = check_str($_REQUEST["device_vendor_uuid"]); + //delete the group from the users + $sql = "delete from v_device_vendor_function_groups "; + $sql .= "where device_vendor_function_group_uuid = '".$device_vendor_function_group_uuid."' "; + $db->exec(check_sql($sql)); + //redirect the browser + messages::add($text['message-delete']); + header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid); + return; + } + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $device_vendor_function_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//set the parent uuid + if (strlen($_GET["device_vendor_uuid"]) > 0) { + $device_vendor_uuid = check_str($_GET["device_vendor_uuid"]); + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + //$label = check_str($_POST["label"]); + $name = check_str($_POST["name"]); + $value = check_str($_POST["value"]); + $enabled = check_str($_POST["enabled"]); + $description = check_str($_POST["description"]); + } + +//process the http variables + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + //get the uuid + if ($action == "update") { + $device_vendor_function_uuid = check_str($_POST["device_vendor_function_uuid"]); + } + + //check for all required data + $msg = ''; + //if (strlen($label) == 0) { $msg .= $text['message-required']." ".$text['label-label']."
\n"; } + if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."
\n"; } + if (strlen($value) == 0) { $msg .= $text['message-required']." ".$text['label-value']."
\n"; } + if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } + //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + + //add vendor functions + if ($action == "add" && permission_exists('device_vendor_function_add')) { + $device_vendor_function_uuid = uuid(); + $sql = "insert into v_device_vendor_functions "; + $sql .= "("; + $sql .= "device_vendor_function_uuid, "; + $sql .= "device_vendor_uuid, "; + //$sql .= "label, "; + $sql .= "name, "; + $sql .= "value, "; + $sql .= "enabled, "; + $sql .= "description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$device_vendor_function_uuid."', "; + $sql .= "'$device_vendor_uuid', "; + //$sql .= "'$label', "; + $sql .= "'$name', "; + $sql .= "'$value', "; + $sql .= "'$enabled', "; + $sql .= "'$description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($action == "add") + + //update vendor functions + if ($action == "update" && permission_exists('device_vendor_function_edit')) { + $sql = "update v_device_vendor_functions set "; + $sql .= "device_vendor_uuid = '$device_vendor_uuid', "; + //$sql .= "label = '$label', "; + $sql .= "name = '$name', "; + $sql .= "value = '$value', "; + $sql .= "enabled = '$enabled', "; + $sql .= "description = '$description' "; + $sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid'"; + $db->exec(check_sql($sql)); + unset($sql); + } //if ($action == "update") + + //add a group to the menu + if (permission_exists('device_vendor_function_add') && $_REQUEST["group_uuid_name"] != '') { + + //get the group uuid and group_name + $group_data = explode('|', check_str($_REQUEST["group_uuid_name"])); + $group_uuid = $group_data[0]; + $group_name = $group_data[1]; + + //add the group to the menu + if (strlen($device_vendor_function_uuid) > 0) { + $device_vendor_function_group_uuid = uuid(); + $sql = "insert into v_device_vendor_function_groups "; + $sql .= "("; + $sql .= "device_vendor_function_group_uuid, "; + $sql .= "device_vendor_function_uuid, "; + $sql .= "device_vendor_uuid, "; + $sql .= "group_name, "; + $sql .= "group_uuid "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'".$device_vendor_function_group_uuid."', "; + $sql .= "'".$device_vendor_function_uuid."', "; + $sql .= "'".$device_vendor_uuid."', "; + $sql .= "'".$group_name."', "; + $sql .= "'".$group_uuid."' "; + $sql .= ")"; + $db->exec($sql); + } + } + + //redirect the user + $_SESSION["message"] = $text['message-'.$action]; + header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid); + return; + } //if ($_POST["persistformvar"] != "true") + } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $device_vendor_function_uuid = check_str($_GET["id"]); + $sql = "select * from v_device_vendor_functions "; + $sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $device_vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($device_vendor_functions as &$row) { + //$label = $row["label"]; + $name = $row["name"]; + $value = $row["value"]; + $enabled = $row["enabled"]; + $description = $row["description"]; + } + unset ($prep_statement); + } + +//group groups assigned + $sql = "select "; + $sql .= " fg.*, g.domain_uuid as group_domain_uuid "; + $sql .= "from "; + $sql .= " v_device_vendor_function_groups as fg, "; + $sql .= " v_groups as g "; + $sql .= "where "; + $sql .= " fg.group_uuid = g.group_uuid "; + $sql .= " and fg.device_vendor_uuid = :device_vendor_uuid "; + //$sql .= " and fg.device_vendor_uuid = '$device_vendor_uuid' "; + $sql .= " and fg.device_vendor_function_uuid = :device_vendor_function_uuid "; + //$sql .= " and fg.device_vendor_function_uuid = '$device_vendor_function_uuid' "; + $sql .= "order by "; + $sql .= " g.domain_uuid desc, "; + $sql .= " g.group_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid); + $prep_statement->bindParam(':device_vendor_function_uuid', $device_vendor_function_uuid); + $prep_statement->execute(); + $function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($sql, $prep_statement); + +//set the assigned_groups array + if (is_array($menu_item_groups)) { + foreach($menu_item_groups as $field) { + if (strlen($field['group_name']) > 0) { + $assigned_groups[] = $field['group_uuid']; + } + } + } + +//get the groups + $sql = "select * from v_groups "; + if (sizeof($assigned_groups) > 0) { + $sql .= "where group_uuid not in ('".implode("','",$assigned_groups)."') "; + } + $sql .= "order by domain_uuid desc, group_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($sql, $prep_statement); + +//show the header + require_once "resources/header.php"; + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "\n"; + //echo "\n"; + //echo "\n"; + //echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + //echo "
\n";
+	//print_r($function_groups);
+	//echo "
\n"; + echo " "; + echo " "; + echo " "; + echo " "; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
".$text['title-device_vendor_function']."

\n"; + echo " "; + echo " "; + echo "
\n"; + //echo " ".$text['label-label']."\n"; + //echo "\n"; + //echo " \n"; + //echo "
\n"; + //echo $text['description-label']."\n"; + //echo "
\n"; + echo " ".$text['label-name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-name']."\n"; + echo "
\n"; + echo " ".$text['label-value']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-value']."\n"; + echo "
".$text['label-groups'].""; + if (is_array($function_groups)) { + echo "\n"; + foreach($function_groups as $field) { + if (strlen($field['group_name']) > 0) { + echo "\n"; + echo " \n"; + if (permission_exists('group_member_delete') || if_group("superadmin")) { + echo " "; + } + echo "\n"; + } + } + echo "
"; + echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); + echo " "; + echo "".$v_link_label_delete.""; + echo "
\n"; + } + if (is_array($groups)) { + echo "
\n"; + echo ""; + echo "\n"; + } + echo "
\n"; + echo " ".$text['label-enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-enabled']."\n"; + echo "
\n"; + echo " ".$text['label-description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-description']."\n"; + echo "
\n"; + echo " \n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/devices/device_vendor_functions.php b/app/devices/device_vendor_functions.php index f8ca29a03a..e825c25015 100644 --- a/app/devices/device_vendor_functions.php +++ b/app/devices/device_vendor_functions.php @@ -1,218 +1,218 @@ - - Portions created by the Initial Developer are Copyright (C) 2016-2017 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('device_vendor_function_view')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get variables used to control the order - $order_by = check_str($_GET["order_by"]); - $order = check_str($_GET["order"]); - -//add the search term - $search = check_str($_GET["search"]); - if (strlen($search) > 0) { - $sql_search = "and ("; - $sql_search .= "label like '%".$search."%'"; - $sql_search .= "or name like '%".$search."%'"; - $sql_search .= "or value like '%".$search."%'"; - $sql_search .= "or enabled like '%".$search."%'"; - $sql_search .= "or description like '%".$search."%'"; - $sql_search .= ")"; - } - -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - -//prepare to page the results - $sql = "select count(*) as num_rows from v_device_vendor_functions "; - $sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; - $sql .= $sql_search; - if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - -//prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - -//get the list - $sql = "select * from v_device_vendor_functions "; - $sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; - $sql .= $sql_search; - if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement, $sql); - -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - -//show the content - echo "\n"; - echo " \n"; - echo " \n"; - //echo " \n"; - //echo " \n"; - //echo " \n"; - echo " \n"; - echo "
".$text['title-device_vendor_functions']."
\n"; - //echo " \n"; - //echo " \n"; - //echo "
\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo th_order_by('name', $text['label-name'], $order_by, $order); - echo th_order_by('value', $text['label-value'], $order_by, $order); - echo "\n"; - echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); - echo th_order_by('description', $text['label-description'], $order_by, $order); - echo "\n"; - echo "\n"; - - if (is_array($vendor_functions)) { - foreach($vendor_functions as $row) { - - //get the groups that have been assigned to the vendor functions - $sql = "select "; - $sql .= " fg.*, g.domain_uuid as group_domain_uuid "; - $sql .= "from "; - $sql .= " v_device_vendor_function_groups as fg, "; - $sql .= " v_groups as g "; - $sql .= "where "; - $sql .= " fg.group_uuid = g.group_uuid "; - $sql .= " and fg.device_vendor_uuid = :device_vendor_uuid "; - //$sql .= " and fg.device_vendor_uuid = '$device_vendor_uuid' "; - $sql .= " and fg.device_vendor_function_uuid = :device_vendor_function_uuid "; - //$sql .= " and fg.device_vendor_function_uuid = '".$row['device_vendor_function_uuid']."' "; - $sql .= "order by "; - $sql .= " g.domain_uuid desc, "; - $sql .= " g.group_name asc "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid); - $prep_statement->bindParam(':device_vendor_function_uuid', $row['device_vendor_function_uuid']); - $prep_statement->execute(); - $vendor_function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($sql, $prep_statement); - unset($group_list); - foreach ($vendor_function_groups as &$sub_row) { - $group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null); - } - $group_list = isset($group_list) ? implode(', ', $group_list) : ''; - unset ($vendor_function_groups); - //build the edit link - if (permission_exists('device_vendor_function_edit')) { - $tr_link = "href='device_vendor_function_edit.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."'"; - } - //show the row of data - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - //toggle the value of the c variable - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); - } //end if results - - echo "\n"; - echo "\n"; - echo "\n"; - echo "
".$text['label-label']."".$text['label-groups'].""; - if (permission_exists('device_vendor_function_add')) { - echo "$v_link_label_add"; - } - else { - echo " \n"; - } - echo "
".$text['label-'.$row['name']]." ".$row['name']."  ".$row['value']." ".$group_list." ".$row['enabled']." ".$row['description']." "; - if (permission_exists('device_vendor_function_edit')) { - echo "$v_link_label_edit"; - } - if (permission_exists('device_vendor_function_delete')) { - echo "$v_link_label_delete"; - } - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; - if (permission_exists('device_vendor_function_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo "
\n"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; - -?> + + Portions created by the Initial Developer are Copyright (C) 2016-2017 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('device_vendor_function_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get variables used to control the order + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//add the search term + $search = check_str($_GET["search"]); + if (strlen($search) > 0) { + $sql_search = "and ("; + $sql_search .= "label like '%".$search."%'"; + $sql_search .= "or name like '%".$search."%'"; + $sql_search .= "or value like '%".$search."%'"; + $sql_search .= "or enabled like '%".$search."%'"; + $sql_search .= "or description like '%".$search."%'"; + $sql_search .= ")"; + } + +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//prepare to page the results + $sql = "select count(*) as num_rows from v_device_vendor_functions "; + $sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; + $sql .= $sql_search; + if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_device_vendor_functions "; + $sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; + $sql .= $sql_search; + if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//alternate the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + //echo " \n"; + //echo " \n"; + //echo " \n"; + echo " \n"; + echo "
".$text['title-device_vendor_functions']."
\n"; + //echo " \n"; + //echo " \n"; + //echo "
\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo th_order_by('name', $text['label-name'], $order_by, $order); + echo th_order_by('value', $text['label-value'], $order_by, $order); + echo "\n"; + echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); + echo th_order_by('description', $text['label-description'], $order_by, $order); + echo "\n"; + echo "\n"; + + if (is_array($vendor_functions)) { + foreach($vendor_functions as $row) { + + //get the groups that have been assigned to the vendor functions + $sql = "select "; + $sql .= " fg.*, g.domain_uuid as group_domain_uuid "; + $sql .= "from "; + $sql .= " v_device_vendor_function_groups as fg, "; + $sql .= " v_groups as g "; + $sql .= "where "; + $sql .= " fg.group_uuid = g.group_uuid "; + $sql .= " and fg.device_vendor_uuid = :device_vendor_uuid "; + //$sql .= " and fg.device_vendor_uuid = '$device_vendor_uuid' "; + $sql .= " and fg.device_vendor_function_uuid = :device_vendor_function_uuid "; + //$sql .= " and fg.device_vendor_function_uuid = '".$row['device_vendor_function_uuid']."' "; + $sql .= "order by "; + $sql .= " g.domain_uuid desc, "; + $sql .= " g.group_name asc "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid); + $prep_statement->bindParam(':device_vendor_function_uuid', $row['device_vendor_function_uuid']); + $prep_statement->execute(); + $vendor_function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($sql, $prep_statement); + unset($group_list); + foreach ($vendor_function_groups as &$sub_row) { + $group_list[] = $sub_row["group_name"].(($sub_row['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$sub_row['group_domain_uuid']]['domain_name'] : null); + } + $group_list = isset($group_list) ? implode(', ', $group_list) : ''; + unset ($vendor_function_groups); + //build the edit link + if (permission_exists('device_vendor_function_edit')) { + $tr_link = "href='device_vendor_function_edit.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."'"; + } + //show the row of data + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + //toggle the value of the c variable + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
".$text['label-label']."".$text['label-groups'].""; + if (permission_exists('device_vendor_function_add')) { + echo "$v_link_label_add"; + } + else { + echo " \n"; + } + echo "
".$text['label-'.$row['name']]." ".$row['name']."  ".$row['value']." ".$group_list." ".$row['enabled']." ".$row['description']." "; + if (permission_exists('device_vendor_function_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('device_vendor_function_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('device_vendor_function_add')) { + echo "$v_link_label_add"; + } + else { + echo " "; + } + echo "
\n"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/devices/device_vendors.php b/app/devices/device_vendors.php index 4b179441b3..889f232180 100644 --- a/app/devices/device_vendors.php +++ b/app/devices/device_vendors.php @@ -1,185 +1,185 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('device_vendor_view')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get variables used to control the order - $order_by = check_str($_GET["order_by"]); - $order = check_str($_GET["order"]); - -//add the search term - $search = check_str($_GET["search"]); - if (strlen($search) > 0) { - $sql_search = "where ("; - $sql_search .= "name like '%".$search."%'"; - $sql_search .= "or enabled like '%".$search."%'"; - $sql_search .= "or description like '%".$search."%'"; - $sql_search .= ")"; - } -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - -//prepare to page the results - $sql = "select count(*) as num_rows from v_device_vendors "; - $sql .= $sql_search; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - -//prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - -//get the list - $sql = "select * from v_device_vendors "; - $sql .= $sql_search; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement, $sql); - -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - -//show the content - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['title-device_vendors']."
\n"; - if (permission_exists('device_vendor_restore')) { - echo " "; - } - echo " "; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['title_description-device_vendor']."

\n"; - echo "
\n"; - - echo "\n"; - echo "\n"; - echo th_order_by('name', $text['label-name'], $order_by, $order); - echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); - echo th_order_by('description', $text['label-description'], $order_by, $order); - echo "\n"; - echo "\n"; - - if (is_array($result)) { - foreach($result as $row) { - if (permission_exists('device_vendor_edit')) { - $tr_link = "href='device_vendor_edit.php?id=".$row['device_vendor_uuid']."'"; - } - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); - } //end if results - - echo "\n"; - echo "\n"; - echo "\n"; - echo "
"; - if (permission_exists('device_vendor_add')) { - echo "$v_link_label_add"; - } - else { - echo " \n"; - } - echo "
".$row['name']." ".$row['enabled']." ".$row['description']." "; - if (permission_exists('device_vendor_edit')) { - echo "$v_link_label_edit"; - } - if (permission_exists('device_vendor_delete')) { - echo "$v_link_label_delete"; - } - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; - if (permission_exists('device_vendor_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo "
\n"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; - -?> + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('device_vendor_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get variables used to control the order + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//add the search term + $search = check_str($_GET["search"]); + if (strlen($search) > 0) { + $sql_search = "where ("; + $sql_search .= "name like '%".$search."%'"; + $sql_search .= "or enabled like '%".$search."%'"; + $sql_search .= "or description like '%".$search."%'"; + $sql_search .= ")"; + } +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//prepare to page the results + $sql = "select count(*) as num_rows from v_device_vendors "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_device_vendors "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//alternate the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['title-device_vendors']."
\n"; + if (permission_exists('device_vendor_restore')) { + echo " "; + } + echo " "; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['title_description-device_vendor']."

\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo th_order_by('name', $text['label-name'], $order_by, $order); + echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); + echo th_order_by('description', $text['label-description'], $order_by, $order); + echo "\n"; + echo "\n"; + + if (is_array($result)) { + foreach($result as $row) { + if (permission_exists('device_vendor_edit')) { + $tr_link = "href='device_vendor_edit.php?id=".$row['device_vendor_uuid']."'"; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + if (permission_exists('device_vendor_add')) { + echo "$v_link_label_add"; + } + else { + echo " \n"; + } + echo "
".$row['name']." ".$row['enabled']." ".$row['description']." "; + if (permission_exists('device_vendor_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('device_vendor_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('device_vendor_add')) { + echo "$v_link_label_add"; + } + else { + echo " "; + } + echo "
\n"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> diff --git a/app/fax/fax_files_remote.php b/app/fax/fax_files_remote.php index e1738ebe61..aa7bbc3f88 100644 --- a/app/fax/fax_files_remote.php +++ b/app/fax/fax_files_remote.php @@ -1,249 +1,249 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2012 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane - James Rose -*/ -include "root.php"; -require_once "resources/require.php"; -require_once "resources/check_auth.php"; -require_once "resources/functions/object_to_array.php"; -require_once "resources/functions/parse_message.php"; -if (permission_exists('fax_inbox_view')) { - //access granted -} -else { - echo "access denied"; - exit; -} - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get fax server uuid, set connection parameters - if (strlen($_GET['id']) > 0) { - $fax_uuid = check_str($_GET["id"]); - - if (if_group("superadmin") || if_group("admin")) { - //show all fax extensions - $sql = "select * from v_fax "; - $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and fax_uuid = '$fax_uuid' "; - } - else { - //show only assigned fax extensions - $sql = "select * from v_fax as f, v_fax_users as u "; - $sql .= "where f.fax_uuid = u.fax_uuid "; - $sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' "; - $sql .= "and f.fax_uuid = '$fax_uuid' "; - $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; - } - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - if (count($result) == 0) { - if (!if_group("superadmin") && !if_group("admin")) { - echo "access denied"; - exit; - } - } - foreach ($result as &$row) { - $fax_name = $row["fax_name"]; - $fax_extension = $row["fax_extension"]; - $fax_email_connection_type = $row["fax_email_connection_type"]; - $fax_email_connection_host = $row["fax_email_connection_host"]; - $fax_email_connection_port = $row["fax_email_connection_port"]; - $fax_email_connection_security = $row["fax_email_connection_security"]; - $fax_email_connection_validate = $row["fax_email_connection_validate"]; - $fax_email_connection_username = $row["fax_email_connection_username"]; - $fax_email_connection_password = $row["fax_email_connection_password"]; - $fax_email_connection_mailbox = $row["fax_email_connection_mailbox"]; - $fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"]; - break; - } - unset ($prep_statement); - - // make connection - $fax_email_connection = "{".$fax_email_connection_host.":".$fax_email_connection_port."/".$fax_email_connection_type; - $fax_email_connection .= ($fax_email_connection_security != '') ? "/".$fax_email_connection_security : "/notls"; - $fax_email_connection .= "/".(($fax_email_connection_validate == 'false') ? "no" : null)."validate-cert"; - $fax_email_connection .= "}".$fax_email_connection_mailbox; - if (!$connection = imap_open($fax_email_connection, $fax_email_connection_username, $fax_email_connection_password)) { - messages::add($text['message-cannot_connect']."(".imap_last_error().")", 'neative'); - header("Location: fax.php"); - exit; - } - - } - else { - header("Location: fax.php"); - exit; - } - -//message action - if ($_GET['email_id'] != '') { - $email_id = check_str($_GET['email_id']); - - //download attachment - if (isset($_GET['download'])) { - $message = parse_message($connection, $email_id, FT_UID); - $attachment = $message['attachments'][0]; - if ($attachment) { - $file_type = pathinfo($attachment['name'], PATHINFO_EXTENSION); - switch ($file_type) { - case "pdf" : header("Content-Type: application/pdf"); break; - case "tif" : header("Contet-Type: image/tiff"); break; - } - header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 - header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past - header("Content-Length: ".$attachment['size']); - $browser = $_SERVER["HTTP_USER_AGENT"]; - if (preg_match("/MSIE 5.5/", $browser) || preg_match("/MSIE 6.0/", $browser)) { - header("Content-Disposition: filename=\"".$attachment['name']."\""); - } - else { - header("Content-Disposition: attachment; filename=\"".$attachment['name']."\""); - } - header("Content-Transfer-Encoding: binary"); - echo $attachment['data']; - exit; - } - else{ - //redirect user - messages::add($text['message-download_failed'], 'negative'); - header("Location: ?id=".$fax_uuid); - exit; - } - - } - - //delete email - if (isset($_GET['delete']) && permission_exists('fax_inbox_delete')) { - $message = parse_message($connection, $email_id, FT_UID); - $attachment = $message['attachments'][0]; - if (imap_delete($connection, $email_id, FT_UID)) { - if (imap_expunge($connection)) { - //clean up local inbox copy - $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; - @unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment['name']); - //redirect user - messages::add($text['message-delete']); - header("Location: ?id=".$fax_uuid); - exit; - } - } - else { - //redirect user - messages::add($text['message-delete_failed'], 'negative'); - header("Location: ?id=".$fax_uuid); - exit; - } - } - else { - //redirect user - messages::add($text['message-delete_failed'], 'negative'); - header("Location: ?id=".$fax_uuid); - exit; - } - - } - -//get emails - $emails = imap_search($connection, "SUBJECT \"".$fax_email_inbound_subject_tag."\"", SE_UID); - -//show the header - require_once "resources/header.php"; - - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - -//show the inbox - $c = 0; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['header-inbox'].": ".$fax_name." (".$fax_extension.")\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo "

\n"; - - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (permission_exists('fax_inbox_delete')) { - echo " \n"; - } - echo " "; - - if ($emails) { - - rsort($emails); // most recent on top - - foreach ($emails as $email_id) { - $metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID)); - $message = parse_message($connection, $email_id, FT_UID); - $attachment = $message['attachments'][0]; - $file_name = $attachment['name']; - $caller_id_name = substr($file_name, 0, strpos($file_name, '-')); - $caller_id_number = (is_numeric($caller_id_name)) ? format_phone((int) $caller_id_name) : null; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - if (permission_exists('fax_inbox_delete')) { - echo " \n"; - } - echo " \n"; - $c = ($c) ? 0 : 1; - - } - - } - else { - echo "\n"; - echo " \n"; - echo "\n"; - } - - echo "
".$text['label-fax_caller_id_name']."".$text['label-fax_caller_id_number']."".$text['table-file']."".$text['label-email_size']."".$text['label-email_received']." 
".$caller_id_name."".$caller_id_number."".$file_name."".byte_convert($attachment['size'])."".$metadata[0]['date']."".$v_link_label_delete."


".$text['message-no_faxes_found']."

"; - echo "

"; - -/* close the connection */ -imap_close($connection); - - -//show the footer - require_once "resources/footer.php"; -?> + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane + James Rose +*/ +include "root.php"; +require_once "resources/require.php"; +require_once "resources/check_auth.php"; +require_once "resources/functions/object_to_array.php"; +require_once "resources/functions/parse_message.php"; +if (permission_exists('fax_inbox_view')) { + //access granted +} +else { + echo "access denied"; + exit; +} + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get fax server uuid, set connection parameters + if (strlen($_GET['id']) > 0) { + $fax_uuid = check_str($_GET["id"]); + + if (if_group("superadmin") || if_group("admin")) { + //show all fax extensions + $sql = "select * from v_fax "; + $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and fax_uuid = '$fax_uuid' "; + } + else { + //show only assigned fax extensions + $sql = "select * from v_fax as f, v_fax_users as u "; + $sql .= "where f.fax_uuid = u.fax_uuid "; + $sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' "; + $sql .= "and f.fax_uuid = '$fax_uuid' "; + $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; + } + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (count($result) == 0) { + if (!if_group("superadmin") && !if_group("admin")) { + echo "access denied"; + exit; + } + } + foreach ($result as &$row) { + $fax_name = $row["fax_name"]; + $fax_extension = $row["fax_extension"]; + $fax_email_connection_type = $row["fax_email_connection_type"]; + $fax_email_connection_host = $row["fax_email_connection_host"]; + $fax_email_connection_port = $row["fax_email_connection_port"]; + $fax_email_connection_security = $row["fax_email_connection_security"]; + $fax_email_connection_validate = $row["fax_email_connection_validate"]; + $fax_email_connection_username = $row["fax_email_connection_username"]; + $fax_email_connection_password = $row["fax_email_connection_password"]; + $fax_email_connection_mailbox = $row["fax_email_connection_mailbox"]; + $fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"]; + break; + } + unset ($prep_statement); + + // make connection + $fax_email_connection = "{".$fax_email_connection_host.":".$fax_email_connection_port."/".$fax_email_connection_type; + $fax_email_connection .= ($fax_email_connection_security != '') ? "/".$fax_email_connection_security : "/notls"; + $fax_email_connection .= "/".(($fax_email_connection_validate == 'false') ? "no" : null)."validate-cert"; + $fax_email_connection .= "}".$fax_email_connection_mailbox; + if (!$connection = imap_open($fax_email_connection, $fax_email_connection_username, $fax_email_connection_password)) { + messages::add($text['message-cannot_connect']."(".imap_last_error().")", 'neative'); + header("Location: fax.php"); + exit; + } + + } + else { + header("Location: fax.php"); + exit; + } + +//message action + if ($_GET['email_id'] != '') { + $email_id = check_str($_GET['email_id']); + + //download attachment + if (isset($_GET['download'])) { + $message = parse_message($connection, $email_id, FT_UID); + $attachment = $message['attachments'][0]; + if ($attachment) { + $file_type = pathinfo($attachment['name'], PATHINFO_EXTENSION); + switch ($file_type) { + case "pdf" : header("Content-Type: application/pdf"); break; + case "tif" : header("Contet-Type: image/tiff"); break; + } + header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 + header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past + header("Content-Length: ".$attachment['size']); + $browser = $_SERVER["HTTP_USER_AGENT"]; + if (preg_match("/MSIE 5.5/", $browser) || preg_match("/MSIE 6.0/", $browser)) { + header("Content-Disposition: filename=\"".$attachment['name']."\""); + } + else { + header("Content-Disposition: attachment; filename=\"".$attachment['name']."\""); + } + header("Content-Transfer-Encoding: binary"); + echo $attachment['data']; + exit; + } + else{ + //redirect user + messages::add($text['message-download_failed'], 'negative'); + header("Location: ?id=".$fax_uuid); + exit; + } + + } + + //delete email + if (isset($_GET['delete']) && permission_exists('fax_inbox_delete')) { + $message = parse_message($connection, $email_id, FT_UID); + $attachment = $message['attachments'][0]; + if (imap_delete($connection, $email_id, FT_UID)) { + if (imap_expunge($connection)) { + //clean up local inbox copy + $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; + @unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment['name']); + //redirect user + messages::add($text['message-delete']); + header("Location: ?id=".$fax_uuid); + exit; + } + } + else { + //redirect user + messages::add($text['message-delete_failed'], 'negative'); + header("Location: ?id=".$fax_uuid); + exit; + } + } + else { + //redirect user + messages::add($text['message-delete_failed'], 'negative'); + header("Location: ?id=".$fax_uuid); + exit; + } + + } + +//get emails + $emails = imap_search($connection, "SUBJECT \"".$fax_email_inbound_subject_tag."\"", SE_UID); + +//show the header + require_once "resources/header.php"; + + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the inbox + $c = 0; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['header-inbox'].": ".$fax_name." (".$fax_extension.")\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo "

\n"; + + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('fax_inbox_delete')) { + echo " \n"; + } + echo " "; + + if ($emails) { + + rsort($emails); // most recent on top + + foreach ($emails as $email_id) { + $metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID)); + $message = parse_message($connection, $email_id, FT_UID); + $attachment = $message['attachments'][0]; + $file_name = $attachment['name']; + $caller_id_name = substr($file_name, 0, strpos($file_name, '-')); + $caller_id_number = (is_numeric($caller_id_name)) ? format_phone((int) $caller_id_name) : null; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + if (permission_exists('fax_inbox_delete')) { + echo " \n"; + } + echo " \n"; + $c = ($c) ? 0 : 1; + + } + + } + else { + echo "\n"; + echo " \n"; + echo "\n"; + } + + echo "
".$text['label-fax_caller_id_name']."".$text['label-fax_caller_id_number']."".$text['table-file']."".$text['label-email_size']."".$text['label-email_received']." 
".$caller_id_name."".$caller_id_number."".$file_name."".byte_convert($attachment['size'])."".$metadata[0]['date']."".$v_link_label_delete."


".$text['message-no_faxes_found']."

"; + echo "

"; + +/* close the connection */ +imap_close($connection); + + +//show the footer + require_once "resources/footer.php"; +?> diff --git a/app/pin_numbers/pin_number_delete.php b/app/pin_numbers/pin_number_delete.php index 95efa1124e..42007fee04 100644 --- a/app/pin_numbers/pin_number_delete.php +++ b/app/pin_numbers/pin_number_delete.php @@ -1,65 +1,65 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('pin_number_delete')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get the id - if (count($_GET)>0) { - $id = check_str($_GET["id"]); - } - -//delete the data - if (strlen($id)>0) { - //delete pin_number - $sql = "delete from v_pin_numbers "; - $sql .= "where pin_number_uuid = '$id' "; - $sql .= "and domain_uuid = '$domain_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - unset($sql); - } - -//redirect the user - messages::add($text['message-delete']); - header('Location: pin_numbers.php'); - + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('pin_number_delete')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get the id + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } + +//delete the data + if (strlen($id)>0) { + //delete pin_number + $sql = "delete from v_pin_numbers "; + $sql .= "where pin_number_uuid = '$id' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//redirect the user + messages::add($text['message-delete']); + header('Location: pin_numbers.php'); + ?> \ No newline at end of file diff --git a/app/pin_numbers/pin_number_edit.php b/app/pin_numbers/pin_number_edit.php index 88573ccc8a..d29cbe8fe7 100644 --- a/app/pin_numbers/pin_number_edit.php +++ b/app/pin_numbers/pin_number_edit.php @@ -1,240 +1,240 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('pin_number_add') || permission_exists('pin_number_edit')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//action add or update - if (isset($_REQUEST["id"])) { - $action = "update"; - $pin_number_uuid = check_str($_REQUEST["id"]); - } - else { - $action = "add"; - } - -//get http post variables and set them to php variables - if (count($_POST)>0) { - $pin_number = check_str($_POST["pin_number"]); - $accountcode = check_str($_POST["accountcode"]); - $enabled = check_str($_POST["enabled"]); - $description = check_str($_POST["description"]); - } - -if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { - - $msg = ''; - if ($action == "update") { - $pin_number_uuid = check_str($_POST["pin_number_uuid"]); - } - - //check for all required data - if (strlen($pin_number) == 0) { $msg .= $text['message-required']." ".$text['label-pin_number']."
\n"; } - //if (strlen($accountcode) == 0) { $msg .= $text['message-required']." ".$text['label-accountcode']."
\n"; } - if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } - //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } - if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { - require_once "resources/header.php"; - require_once "resources/persist_form_var.php"; - echo "
\n"; - echo "
\n"; - echo $msg."
"; - echo "
\n"; - persistformvar($_POST); - echo "
\n"; - require_once "resources/footer.php"; - return; - } - - //add or update the database - if ($_POST["persistformvar"] != "true") { - if ($action == "add" && permission_exists('pin_number_add')) { - $sql = "insert into v_pin_numbers "; - $sql .= "("; - $sql .= "domain_uuid, "; - $sql .= "pin_number_uuid, "; - $sql .= "pin_number, "; - $sql .= "accountcode, "; - $sql .= "enabled, "; - $sql .= "description "; - $sql .= ")"; - $sql .= "values "; - $sql .= "("; - $sql .= "'$domain_uuid', "; - $sql .= "'".uuid()."', "; - $sql .= "'$pin_number', "; - $sql .= "'$accountcode', "; - $sql .= "'$enabled', "; - $sql .= "'$description' "; - $sql .= ")"; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-add']); - header("Location: pin_numbers.php"); - return; - - } //if ($action == "add") - - if ($action == "update" && permission_exists('pin_number_edit')) { - $sql = "update v_pin_numbers set "; - $sql .= "pin_number = '$pin_number', "; - $sql .= "accountcode = '$accountcode', "; - $sql .= "enabled = '$enabled', "; - $sql .= "description = '$description' "; - $sql .= "where pin_number_uuid = '$pin_number_uuid'"; - $sql .= "and domain_uuid = '$domain_uuid' "; - $db->exec(check_sql($sql)); - unset($sql); - - messages::add($text['message-update']); - header("Location: pin_numbers.php"); - return; - - } //if ($action == "update") - } //if ($_POST["persistformvar"] != "true") -} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) - -//pre-populate the form - if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { - $pin_number_uuid = check_str($_GET["id"]); - $sql = "select * from v_pin_numbers "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= "and pin_number_uuid = '$pin_number_uuid' "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($result as &$row) { - $pin_number = $row["pin_number"]; - $accountcode = $row["accountcode"]; - $enabled = $row["enabled"]; - $description = $row["description"]; - } - unset ($prep_statement); - } - -//show the header - require_once "resources/header.php"; - -//show the content - echo "
\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - - echo "\n"; - echo "\n"; - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " "; - echo "
".$text['title-pin_number']."

\n"; - echo " "; - echo " "; - echo "
\n"; - echo " ".$text['label-pin_number']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-pin_number']."\n"; - echo "
\n"; - echo " ".$text['label-accountcode']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-accountcode']."\n"; - echo "
\n"; - echo " ".$text['label-enabled']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-enabled']."\n"; - echo "
\n"; - echo " ".$text['label-description']."\n"; - echo "\n"; - echo " \n"; - echo "
\n"; - echo $text['description-description']."\n"; - echo "
\n"; - if ($action == "update") { - echo " \n"; - } - echo " \n"; - echo "
"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; - + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('pin_number_add') || permission_exists('pin_number_edit')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $pin_number_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (count($_POST)>0) { + $pin_number = check_str($_POST["pin_number"]); + $accountcode = check_str($_POST["accountcode"]); + $enabled = check_str($_POST["enabled"]); + $description = check_str($_POST["description"]); + } + +if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { + + $msg = ''; + if ($action == "update") { + $pin_number_uuid = check_str($_POST["pin_number_uuid"]); + } + + //check for all required data + if (strlen($pin_number) == 0) { $msg .= $text['message-required']." ".$text['label-pin_number']."
\n"; } + //if (strlen($accountcode) == 0) { $msg .= $text['message-required']." ".$text['label-accountcode']."
\n"; } + if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."
\n"; } + //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //add or update the database + if ($_POST["persistformvar"] != "true") { + if ($action == "add" && permission_exists('pin_number_add')) { + $sql = "insert into v_pin_numbers "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "pin_number_uuid, "; + $sql .= "pin_number, "; + $sql .= "accountcode, "; + $sql .= "enabled, "; + $sql .= "description "; + $sql .= ")"; + $sql .= "values "; + $sql .= "("; + $sql .= "'$domain_uuid', "; + $sql .= "'".uuid()."', "; + $sql .= "'$pin_number', "; + $sql .= "'$accountcode', "; + $sql .= "'$enabled', "; + $sql .= "'$description' "; + $sql .= ")"; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-add']); + header("Location: pin_numbers.php"); + return; + + } //if ($action == "add") + + if ($action == "update" && permission_exists('pin_number_edit')) { + $sql = "update v_pin_numbers set "; + $sql .= "pin_number = '$pin_number', "; + $sql .= "accountcode = '$accountcode', "; + $sql .= "enabled = '$enabled', "; + $sql .= "description = '$description' "; + $sql .= "where pin_number_uuid = '$pin_number_uuid'"; + $sql .= "and domain_uuid = '$domain_uuid' "; + $db->exec(check_sql($sql)); + unset($sql); + + messages::add($text['message-update']); + header("Location: pin_numbers.php"); + return; + + } //if ($action == "update") + } //if ($_POST["persistformvar"] != "true") +} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { + $pin_number_uuid = check_str($_GET["id"]); + $sql = "select * from v_pin_numbers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= "and pin_number_uuid = '$pin_number_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($result as &$row) { + $pin_number = $row["pin_number"]; + $accountcode = $row["accountcode"]; + $enabled = $row["enabled"]; + $description = $row["description"]; + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + +//show the content + echo "
\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " "; + echo "
".$text['title-pin_number']."

\n"; + echo " "; + echo " "; + echo "
\n"; + echo " ".$text['label-pin_number']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-pin_number']."\n"; + echo "
\n"; + echo " ".$text['label-accountcode']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-accountcode']."\n"; + echo "
\n"; + echo " ".$text['label-enabled']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-enabled']."\n"; + echo "
\n"; + echo " ".$text['label-description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-description']."\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + ?> \ No newline at end of file diff --git a/app/pin_numbers/pin_numbers.php b/app/pin_numbers/pin_numbers.php index 56fee3d31e..3359481693 100644 --- a/app/pin_numbers/pin_numbers.php +++ b/app/pin_numbers/pin_numbers.php @@ -1,186 +1,186 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -//includes - require_once "root.php"; - require_once "resources/require.php"; - -//check permissions - require_once "resources/check_auth.php"; - if (permission_exists('pin_number_view')) { - //access granted - } - else { - echo "access denied"; - exit; - } - -//add multi-lingual support - $language = new text; - $text = $language->get(); - -//get variables used to control the order - $order_by = check_str($_GET["order_by"]); - $order = check_str($_GET["order"]); - -//add the search term - $search = check_str($_GET["search"]); - if (strlen($search) > 0) { - $sql_search = "and ("; - $sql_search .= "pin_number like '%".$search."%'"; - $sql_search .= "or accountcode like '%".$search."%'"; - $sql_search .= "or enabled like '%".$search."%'"; - $sql_search .= "or description like '%".$search."%'"; - $sql_search .= ")"; - } -//additional includes - require_once "resources/header.php"; - require_once "resources/paging.php"; - -//prepare to page the results - $sql = "select count(*) as num_rows from v_pin_numbers "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= $sql_search; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $prep_statement = $db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - if ($row['num_rows'] > 0) { - $num_rows = $row['num_rows']; - } - else { - $num_rows = '0'; - } - } - -//prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; - $param = ""; - $page = $_GET['page']; - if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } - list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); - $offset = $rows_per_page * $page; - -//get the list - $sql = "select * from v_pin_numbers "; - $sql .= "where domain_uuid = '$domain_uuid' "; - $sql .= $sql_search; - if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } - $sql .= "limit $rows_per_page offset $offset "; - $prep_statement = $db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement, $sql); - -//alternate the row style - $c = 0; - $row_style["0"] = "row_style0"; - $row_style["1"] = "row_style1"; - -//show the content - echo "\n"; - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
".$text['title-pin_numbers']."
\n"; - echo " \n"; - echo " \n"; - echo "
\n"; - echo " ".$text['title_description-pin_number']."

\n"; - echo "
\n"; - - echo "\n"; - echo "\n"; - echo th_order_by('pin_number', $text['label-pin_number'], $order_by, $order); - echo th_order_by('accountcode', $text['label-accountcode'], $order_by, $order); - echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); - echo th_order_by('description', $text['label-description'], $order_by, $order); - echo "\n"; - echo "\n"; - - if (is_array($result)) { - foreach($result as $row) { - if (permission_exists('pin_number_edit')) { - $tr_link = "href='pin_number_edit.php?id=".$row['pin_number_uuid']."'"; - } - echo "\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "\n"; - if ($c==0) { $c=1; } else { $c=0; } - } //end foreach - unset($sql, $result, $row_count); - } //end if results - - echo "\n"; - echo "\n"; - echo "\n"; - echo "
"; - if (permission_exists('pin_number_add')) { - echo "$v_link_label_add"; - } - else { - echo " \n"; - } - echo "
".$row['pin_number']." ".$row['accountcode']." ".$row['enabled']." ".$row['description']." "; - if (permission_exists('pin_number_edit')) { - echo "$v_link_label_edit"; - } - if (permission_exists('pin_number_delete')) { - echo "$v_link_label_delete"; - } - echo "
\n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo " \n"; - echo "
 $paging_controls"; - if (permission_exists('pin_number_add')) { - echo "$v_link_label_add"; - } - else { - echo " "; - } - echo "
\n"; - echo "
"; - echo "

"; - -//include the footer - require_once "resources/footer.php"; -?> + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permissions + require_once "resources/check_auth.php"; + if (permission_exists('pin_number_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//add multi-lingual support + $language = new text; + $text = $language->get(); + +//get variables used to control the order + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//add the search term + $search = check_str($_GET["search"]); + if (strlen($search) > 0) { + $sql_search = "and ("; + $sql_search .= "pin_number like '%".$search."%'"; + $sql_search .= "or accountcode like '%".$search."%'"; + $sql_search .= "or enabled like '%".$search."%'"; + $sql_search .= "or description like '%".$search."%'"; + $sql_search .= ")"; + } +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//prepare to page the results + $sql = "select count(*) as num_rows from v_pin_numbers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $prep_statement = $db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + if ($row['num_rows'] > 0) { + $num_rows = $row['num_rows']; + } + else { + $num_rows = '0'; + } + } + +//prepare to page the results + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_pin_numbers "; + $sql .= "where domain_uuid = '$domain_uuid' "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//alternate the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//show the content + echo "\n"; + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['title-pin_numbers']."
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['title_description-pin_number']."

\n"; + echo "
\n"; + + echo "\n"; + echo "\n"; + echo th_order_by('pin_number', $text['label-pin_number'], $order_by, $order); + echo th_order_by('accountcode', $text['label-accountcode'], $order_by, $order); + echo th_order_by('enabled', $text['label-enabled'], $order_by, $order); + echo th_order_by('description', $text['label-description'], $order_by, $order); + echo "\n"; + echo "\n"; + + if (is_array($result)) { + foreach($result as $row) { + if (permission_exists('pin_number_edit')) { + $tr_link = "href='pin_number_edit.php?id=".$row['pin_number_uuid']."'"; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "\n"; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
"; + if (permission_exists('pin_number_add')) { + echo "$v_link_label_add"; + } + else { + echo " \n"; + } + echo "
".$row['pin_number']." ".$row['accountcode']." ".$row['enabled']." ".$row['description']." "; + if (permission_exists('pin_number_edit')) { + echo "$v_link_label_edit"; + } + if (permission_exists('pin_number_delete')) { + echo "$v_link_label_delete"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('pin_number_add')) { + echo "$v_link_label_add"; + } + else { + echo " "; + } + echo "
\n"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; +?> diff --git a/app/pin_numbers/root.php b/app/pin_numbers/root.php index 325e6b3867..0045eb7752 100644 --- a/app/pin_numbers/root.php +++ b/app/pin_numbers/root.php @@ -1,90 +1,90 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -// make sure the PATH_SEPARATOR is defined - umask(2); - if (!defined("PATH_SEPARATOR")) { - if (strpos($_ENV["OS"], "Win") !== false) { - define("PATH_SEPARATOR", ";"); - } else { - define("PATH_SEPARATOR", ":"); - } - } - - if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; - - // make sure the document_root is set - $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); - if(PHP_SAPI == 'cli'){ - chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); - $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); - $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); - if (file_exists('/project_root.php')) { - $path = '/'; - } else { - $i = 1; - $path = ''; - while ($i < count($dirs)) { - $path .= '/' . $dirs[$i]; - if (file_exists($path. '/project_root.php')) { - break; - } - $i++; - } - } - $_SERVER["DOCUMENT_ROOT"] = $path; - }else{ - $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); - } - $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); -// try to detect if a project path is being used - if (!defined('PROJECT_PATH')) { - if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { - define('PROJECT_PATH', '/fusionpbx'); - } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { - define('PROJECT_PATH', ''); - } else { - $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); - $i = 1; - $path = $_SERVER["DOCUMENT_ROOT"]; - while ($i < count($dirs)) { - $path .= '/' . $dirs[$i]; - if (file_exists($path. '/project_root.php')) { - break; - } - $i++; - } - if(!file_exists($path. '/project_root.php')){ - die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); - } - $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); - define('PROJECT_PATH', $project_path); - } - $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); - set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); - } - + + Portions created by the Initial Developer are Copyright (C) 2008-2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + if(!file_exists($path. '/project_root.php')){ + die("Failed to locate the Project Root by searching for project_root.php please contact support for assistance"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + ?> \ No newline at end of file diff --git a/app/provision/resources/classes/provision.php b/app/provision/resources/classes/provision.php index 9fa4499c47..58999791e3 100644 --- a/app/provision/resources/classes/provision.php +++ b/app/provision/resources/classes/provision.php @@ -1,1319 +1,1319 @@ - - Copyright (C) 2014-2016 - All Rights Reserved. - - Contributor(s): - Mark J Crane - Luis Daniel Lucio Quiroz -*/ -include "root.php"; - -//define the provision class - class provision { - public $db; - public $domain_uuid; - public $domain_name; - public $template_dir; - public $mac; - - public function __construct() { - //get the database object - global $db; - $this->db = $db; - //set the default template directory - if (PHP_OS == "Linux") { - //set the default template dir - if (strlen($this->template_dir) == 0) { - if (file_exists('/etc/fusionpbx/resources/templates/provision')) { - $this->template_dir = '/etc/fusionpbx/resources/templates/provision'; - } - else { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; - } - } - } elseif (PHP_OS == "FreeBSD") { - //if the FreeBSD port is installed use the following paths by default. - if (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) { - if (strlen($this->template_dir) == 0) { - $this->template_dir = '/usr/local/etc/fusionpbx/resources/templates/provision'; - } - else { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; - } - } - else { - if (strlen($this->template_dir) == 0) { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; - } - else { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; - } - } - } elseif (PHP_OS == "NetBSD") { - //set the default template_dir - if (strlen($this->template_dir) == 0) { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; - } - } elseif (PHP_OS == "OpenBSD") { - //set the default template_dir - if (strlen($this->template_dir) == 0) { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; - } - } else { - //set the default template_dir - if (strlen($this->template_dir) == 0) { - $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; - } - } - - //normalize the mac address - if (isset($this->mac)) { - $this->mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->mac)); - } - } - - public function __destruct() { - foreach ($this as $key => $value) { - unset($this->$key); - } - } - - public function get_domain_uuid() { - return $this->domain_uuid; - } - - //define the function which checks to see if the mac address exists in devices - private function mac_exists($mac) { - //normalize the mac address - $mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $mac)); - //check in the devices table for a specific mac address - $sql = "SELECT count(*) as count FROM v_devices "; - $sql .= "WHERE device_mac_address=:mac "; - $prep_statement = $this->db->prepare(check_sql($sql)); - if ($prep_statement) { - //$prep_statement->bindParam(':domain_uuid', $domain_uuid); - $prep_statement->bindParam(':mac', $mac); - $prep_statement->execute(); - $row = $prep_statement->fetch(); - $count = $row['count']; - if ($row['count'] > 0) { - return true; - } - else { - return false; - } - } - else { - return false; - } - } - - //set the mac address in the correct format for the specific vendor - public function format_mac($mac, $vendor) { - switch (strtolower($vendor)) { - case "algo": - $mac = strtoupper($mac); - break; - case "aastra": - $mac = strtoupper($mac); - break; - case "cisco": - $mac = strtoupper($mac); - break; - case "linksys": - $mac = strtolower($mac); - break; - case "mitel": - $mac = strtoupper($mac); - break; - case "polycom": - $mac = strtolower($mac); - break; - case "snom": - $mac = strtolower($mac); - break; - case "escene": - $mac = strtolower($mac); - break; - case "grandstream": - $mac = strtolower($mac); - break; - default: - $mac = strtolower($mac); - $mac = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2); - } - return $mac; - } - - //define a function to check if a contact exists in the contacts array - private function contact_exists($contacts, $uuid) { - if (is_array($contacts[$uuid])) { - return true; - } - else { - return false; - } - } - - private function contact_append(&$contacts, &$line, $domain_uuid, $device_user_uuid, $is_group){ - $sql = "select c.contact_uuid, c.contact_organization, c.contact_name_given, c.contact_name_family, "; - $sql .= "c.contact_type, c.contact_category, p.phone_label,"; - $sql .= "p.phone_number, p.phone_extension, p.phone_primary "; - $sql .= "from v_contacts as c, v_contact_phones as p "; - $sql .= "where c.contact_uuid = p.contact_uuid "; - $sql .= "and p.phone_type_voice = '1' "; - $sql .= "and c.domain_uuid = '$domain_uuid' "; - if ($is_group) { - $sql .= "and c.contact_uuid in ( "; - $sql .= " select contact_uuid from v_contact_groups "; - $sql .= " where group_uuid in ( "; - $sql .= " select group_uuid from v_group_users "; - $sql .= " where user_uuid = '$device_user_uuid' "; - $sql .= " and domain_uuid = '$domain_uuid' "; - $sql .= " )) "; - } - else { - $sql .= "and c.contact_uuid in ( "; - $sql .= " select contact_uuid from v_contact_users "; - $sql .= " where user_uuid = '$device_user_uuid' "; - $sql .= " and domain_uuid = '$domain_uuid' "; - $sql .= ") "; - } - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($prep_statement, $sql); - - if (is_array($user_contacts)) { - foreach ($user_contacts as &$row) { - $uuid = $row['contact_uuid']; - $phone_label = strtolower($row['phone_label']); - $contact_category = strtolower($row['contact_category']); - - $contact = array(); - $contacts[] = &$contact; - $contact['category'] = $is_group ? 'groups' : 'users'; - $contact['contact_uuid'] = $row['contact_uuid']; - $contact['contact_type'] = $row['contact_type']; - $contact['contact_category'] = $row['contact_category']; - $contact['contact_organization'] = $row['contact_organization']; - $contact['contact_name_given'] = $row['contact_name_given']; - $contact['contact_name_family'] = $row['contact_name_family']; - $contact['numbers'] = array(); - - $numbers = &$contact['numbers']; - - if (($row['phone_primary'] == '1') || (!isset($contact['phone_number']))) { - $contact['phone_label'] = $phone_label; - $contact['phone_number'] = $row['phone_number']; - $contact['phone_extension'] = $row['phone_extension']; - } - - $numbers[] = array( - line_number => $line['line_number'], - phone_label => $phone_label, - phone_number => $row['phone_number'], - phone_extension => $row['phone_extension'], - phone_primary => $row['phone_primary'], - ); - - $contact['phone_number_' . $phone_label] = $row['phone_number']; - unset($contact, $numbers, $uuid, $phone_label); - } - } - } - - private function contact_grandstream(&$contacts, &$line, $domain_uuid, $device_user_uuid){ - // Get username for this. - $sql = "SELECT username FROM v_users WHERE user_uuid = '${device_user_uuid}' AND domain_uuid = '${domain_uuid}' LIMIT 1"; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $my_username = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($prep_statement, $sql); - $my_username = $my_username[0]['username']; - - // Global contact groups available to every phone if ['provision']['global_contact_groups']['text'] is set. - // Easier than assigning these common groups to every user. - // Check provision global_contact_groups and sanitize for sql. - $global_contact_groups['enabled']=false; - if ( preg_match('/[a-zA-Z0-9-_, ]/',$_SESSION['provision']['gs_global_contact_groups']['text'])){ - $global_contact_groups['enabled']=true; - $gp=array(); - $groups=explode(',',$_SESSION['provision']['gs_global_contact_groups']['text']); - foreach ($groups as $group){ - $gp[] = trim($group); - } - $global_contact_groups['sql']="'".implode("','", $gp)."'"; - } - // Get a list of groups the user has access to see. - $sql = "SELECT DISTINCT g.group_uuid, g.group_name, g.group_description "; - $sql .= "FROM v_groups g "; - $sql .= " INNER JOIN v_group_users gu "; - $sql .= " ON gu.group_uuid=g.group_uuid "; - $sql .= " INNER JOIN v_contact_groups cg "; - $sql .= " ON cg.group_uuid=g.group_uuid "; - $sql .= "WHERE gu.user_uuid = '$device_user_uuid' "; - if ( $global_contact_groups['enabled'] ){ - $sql .= "UNION "; - $sql .= "SELECT g.group_uuid, g.group_name, g.group_description "; - $sql .= "FROM v_groups g "; - $sql .= "WHERE g.group_name IN( ".$global_contact_groups['sql'].") "; - } - $sql .= "ORDER BY group_description"; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $user_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($prep_statement, $sql); - $key=0; - foreach ($user_groups as &$row) { - $contacts[] = array("contact_type"=>"group", "group_name"=>$row['group_name'], "group_description"=>$row['group_description'], "id"=>++$key); - $groups[$row['group_uuid']] = $key; - $my_groups[] = '@'.$row['group_name']; // Used to show/hide - } - // Get a list of contacts that this user/phone has access based on assigned users and groups. - $sql = "SELECT c.contact_uuid, c.contact_name_given, c.contact_name_family, c.contact_title, c.contact_category, c.contact_role, c.contact_organization, u.user_uuid "; - $sql .= "FROM v_contacts c "; - $sql .= " LEFT JOIN v_users u "; - $sql .= " ON c.contact_uuid = u.contact_uuid "; - $sql .= "WHERE c.contact_uuid IN ("; // assigned groups - $sql .= " SELECT cg.contact_uuid"; - $sql .= " FROM v_contact_groups cg "; - $sql .= " WHERE cg.group_uuid IN ("; - $sql .= " SELECT gu.group_uuid "; - $sql .= " FROM v_group_users gu "; - $sql .= " WHERE gu.user_uuid = '$device_user_uuid' "; - $sql .= " AND gu.domain_uuid = '$domain_uuid' "; - if ( $global_contact_groups['enabled'] ){ - $sql .= " UNION "; - $sql .= " SELECT g.group_uuid "; - $sql .= " FROM v_groups g "; - $sql .= " WHERE g.group_name IN( ".$global_contact_groups['sql'].") "; - } - $sql .= " )"; - $sql .= " UNION "; // assigned users - $sql .= " SELECT cu.contact_uuid "; - $sql .= " FROM v_contact_users cu "; - $sql .= " WHERE cu.user_uuid = '$device_user_uuid' "; - $sql .= " AND cu.domain_uuid = '$domain_uuid' "; - $sql .= ")"; - $sql .= "ORDER BY contact_name_given, contact_name_family"; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($prep_statement, $sql); - $groupid=0; - foreach ($user_contacts as &$row) { - $last_extention = $row['extension']; - unset($contact); - // Grandsteam phonebook manager: First, Last, Department, Primary, (Work, Home, Mobile, Fax, Pager, Car... with number and account), email(s), Photo, Ringtone, Group(s) - // GXP21xx serries has First, Last, Company, Department, Job, Job TItle, 1Work ,1Home, 1Mobile, Accounts, Groups(1-many) - $contact = array(); - $contact['contact_type'] = "contact"; - $contact['contact_uuid'] = $row['contact_uuid']; - $contact['user_uuid'] = $row['user_uuid']; - $contact['contact_name_given'] = $row['contact_name_given']; //FirstName - $contact['contact_name_family'] = $row['contact_name_family']; // LastName - $contact['contact_title'] = $row['contact_title']; - $contact['contact_category'] = $row['contact_category']; // Department - $contact['contact_role'] = $row['contact_role']; // Job Title - $contact['contact_organization']= $row['contact_organization']; // Company - $contact['contact_work'] = $row['extension']; - //$contact['contact_account_index'] = $line['line_number']; // This was empty so disabled it. - // Look up groups for this contact - $sql = "SELECT g.group_description, g.group_uuid "; - $sql .= "FROM v_groups g "; - $sql .= " INNER JOIN v_contact_groups cg "; - $sql .= " ON cg.group_uuid=g.group_uuid "; - $sql .= "WHERE cg.contact_uuid = '".$row['contact_uuid']."' "; - $sql .= "AND cg.domain_uuid = '$domain_uuid'"; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $user_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($user_groups as $group ){ - if ( ! empty($groups[$group['group_uuid']])){ - $contact['groups'][] = $groups[$group['group_uuid']]; - } - } - if ( empty($contact['groups']) && !empty($groups['Other'])){ - $contact['groups'][] = $groups['Other']; - } - // Look up extention(s) for this contact. - if ( ! empty ($row['user_uuid']) ){ - $sql = "SELECT e.extension, e.description "; - $sql .= "FROM v_extensions e "; - $sql .= " INNER JOIN v_extension_users eu "; - $sql .= " ON e.extension_uuid = eu.extension_uuid "; - $sql .= "WHERE eu.user_uuid = '".$row['user_uuid']."' "; - $sql .= "AND eu.domain_uuid = '$domain_uuid' "; - $sql .= "AND e.enabled = 'true' "; - $sql .= "AND e.directory_visible = 'true' "; # TODO: not right field but it works for our district. - $sql .= "AND e.directory_exten_visible = 'true' "; # TODO: not right field but it works for our district. - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $user_extentions = $prep_statement->fetchAll(PDO::FETCH_NAMED); - foreach ($user_extentions as $ext ){ - if ( preg_match ('/ (Cell|Mobile)/i', $ext['description'])){ - $contact['contact_cell'] = $ext['extension']; - } elseif ( preg_match ("/ Home/i", $ext['description'])){ - $contact['contact_home'] = $ext['extension']; - } else { - $contact['contact_work'] = $ext['extension']; - } - } - } - // Additional phone numbers for this contact. - $sql = "select phone_number, phone_label, phone_description from v_contact_phones "; - $sql .= "where contact_uuid='".$row['contact_uuid']."' "; - $sql .= "and domain_uuid='".$domain_uuid."' "; - $sql .= "and phone_type_voice = '1' "; - $sql .= "and phone_label in ('Home', 'Mobile', 'Work') "; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $user_phones = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset($prep_statement, $sql); - foreach ($user_phones as $phone){ - // Check permission in phone_description field for string :allow:username1:username2:@group1:@group2: - $show = true; - if ( preg_match ('/:allow:/i', $phone['phone_description'] )){ - $show = false; - $allows = explode ( ':', $phone['phone_description'] ); - foreach ( $allows as $allow ){ - if ( in_array($allow, $my_groups) || preg_match('/^'.$my_username.'$/', $allow)){ - $show = true; - break 1; - } - } - } - if ( $show && $phone['phone_label'] == "Home" ) { - $contact['contact_home'] = $phone['phone_number']; - } elseif ( $show && $phone['phone_label'] == "Mobile" ){ - $contact['contact_cell'] = $phone['phone_number']; - } elseif ( $show && $phone['phone_label'] == "Work" ){ - // Work phones are usually just extentions already assigned above. - if (empty($contact['contact_work'])){ - $contact['contact_work'] = $phone['phone_number']; - } - } - } - // Only add to contact list if a phone number exists. - if(!empty($contact['contact_work']) || !empty($contact['contact_home']) || !empty($contact['contact_cell'])){ - $contacts[] = &$contact; - } - } - } - - public function render() { - - //debug - $debug = $_REQUEST['debug']; // array - - //get the variables - $domain_uuid = $this->domain_uuid; - $device_template = $this->device_template; - $template_dir = $this->template_dir; - $mac = $this->mac; - $file = $this->file; - - //set the mac address to lower case to be consistent with the database - $mac = strtolower($mac); - - //get the device template - if (strlen($_REQUEST['template']) > 0) { - $device_template = $_REQUEST['template']; - $search = array('..', '/./'); - $device_template = str_replace($search, "", $device_template); - $device_template = str_replace('//', '/', $device_template); - } - - //remove ../ and slashes in the file name - $search = array('..', '/', '\\', '/./', '//'); - $file = str_replace($search, "", $file); - - //get the domain_name - if (strlen($domain_name) == 0) { - $sql = "SELECT domain_name FROM v_domains "; - $sql .= "WHERE domain_uuid=:domain_uuid "; - $prep_statement = $this->db->prepare(check_sql($sql)); - if ($prep_statement) { - //use the prepared statement - $prep_statement->bindParam(':domain_uuid', $domain_uuid); - $prep_statement->execute(); - $row = $prep_statement->fetch(); - unset($prep_statement); - //set the variables from values in the database - $domain_name = $row["domain_name"]; - } - } - - //build the provision array - $provision = Array(); - if (is_array($_SESSION['provision'])) { - foreach($_SESSION['provision'] as $key=>$val) { - if (strlen($val['var']) > 0) { $value = $val['var']; } - if (strlen($val['text']) > 0) { $value = $val['text']; } - if (strlen($val['boolean']) > 0) { $value = $val['boolean']; } - if (strlen($val['numeric']) > 0) { $value = $val['numeric']; } - if (strlen($value) > 0) { $provision[$key] = $value; } - unset($value); - } - } - - //check to see if the mac_address exists in devices - if (strlen($_REQUEST['user_id']) == 0 || strlen($_REQUEST['userid']) == 0) { - if ($this->mac_exists($mac)) { - //get the device_template - if (strlen($device_template) == 0) { - $sql = "SELECT * FROM v_devices "; - $sql .= "WHERE device_mac_address=:mac "; - if($provision['http_domain_filter'] == "true") { - $sql .= "AND domain_uuid=:domain_uuid "; - } - $prep_statement_2 = $this->db->prepare(check_sql($sql)); - if ($prep_statement_2) { - //use the prepared statement - $prep_statement_2->bindParam(':mac', $mac); - if($provision['http_domain_filter'] == "true") { - $prep_statement_2->bindParam(':domain_uuid', $domain_uuid); - } - $prep_statement_2->execute(); - $row = $prep_statement_2->fetch(); - //checks either device enabled - if($row['device_enabled'] != 'true'){ - if ($_SESSION['provision']['debug']['boolean'] == 'true'){ - echo "
device disabled
"; - } - echo "file not found"; - exit; - } - - //set the variables from values in the database - $device_uuid = $row["device_uuid"]; - $device_label = $row["device_label"]; - if (strlen($row["device_vendor"]) > 0) { - $device_vendor = strtolower($row["device_vendor"]); - } - $device_user_uuid = $row["device_user_uuid"]; - $device_model = $row["device_model"]; - $device_firmware_version = $row["device_firmware_version"]; - $device_enabled = $row["device_enabled"]; - $device_template = $row["device_template"]; - $device_profile_uuid = $row["device_profile_uuid"]; - $device_description = $row["device_description"]; - } - } - - //find a template that was defined on another phone and use that as the default. - if (strlen($device_template) == 0) { - $sql = "SELECT * FROM v_devices "; - $sql .= "WHERE domain_uuid=:domain_uuid "; - $sql .= "AND device_enabled='true' "; - $sql .= "limit 1 "; - $prep_statement_3 = $this->db->prepare(check_sql($sql)); - if ($prep_statement_3) { - $prep_statement_3->bindParam(':domain_uuid', $domain_uuid); - $prep_statement_3->execute(); - $row = $prep_statement_3->fetch(); - $device_label = $row["device_label"]; - $device_vendor = strtolower($row["device_vendor"]); - $device_model = $row["device_model"]; - $device_firmware_version = $row["device_firmware_version"]; - $device_enabled = $row["device_enabled"]; - $device_template = $row["device_template"]; - $device_profile_uuid = $row["device_profile_uuid"]; - $device_description = $row["device_description"]; - } - } - } - else { - //use the user_agent to pre-assign a template for 1-hit provisioning. Enter the a unique string to match in the user agent, and the template it should match. - $template_list=array( - "Linksys/SPA-2102"=>"linksys/spa2102", - "Linksys/SPA-3102"=>"linksys/spa3102", - "Linksys/SPA-9212"=>"linksys/spa921", - "Cisco/SPA301"=>"cisco/spa301", - "Cisco/SPA301D"=>"cisco/spa302d", - "Cisco/SPA303"=>"cisco/spa303", - "Cisco/SPA501G"=>"cisco/spa501g", - "Cisco/SPA502G"=>"cisco/spa502g", - "Cisco/SPA504G"=>"cisco/spa504g", - "Cisco/SPA508G"=>"cisco/spa508g", - "Cisco/SPA509G"=>"cisco/spa509g", - "Cisco/SPA512G"=>"cisco/spa512g", - "Cisco/SPA514G"=>"cisco/spa514g", - "Cisco/SPA525G2"=>"cisco/spa525g2", - "snom300-SIP"=>"snom/300", - "snom320-SIP"=>"snom/320", - "snom360-SIP"=>"snom/360", - "snom370-SIP"=>"snom/370", - "snom820-SIP"=>"snom/820", - "snom-m3-SIP"=>"snom/m3", - "yealink SIP-T20"=>"yealink/t20", - "yealink SIP-T22"=>"yealink/t22", - "yealink SIP-T26"=>"yealink/t26", - "Yealink SIP-T32"=>"yealink/t32", - "HW DP750"=>"grandstream/dp750", - "HW GXP1450"=>"grandstream/gxp1450", - "HW GXP1628"=>"grandstream/gxp16xx", - "HW GXP1610"=>"grandstream/gxp16xx", - "HW GXP1620"=>"grandstream/gxp16xx", - "HW GXP1625"=>"grandstream/gxp16xx", - "HW GXP1628"=>"grandstream/gxp16xx", - "HW GXP1630"=>"grandstream/gxp16xx", - "HW GXP2124"=>"grandstream/gxp2124", - "HW GXP2130"=>"grandstream/gxp2130", - "HW GXP2135"=>"grandstream/gxp2135", - "HW GXP2140"=>"grandstream/gxp2140", - "HW GXP2160"=>"grandstream/gxp2160", - "HW GXP2170"=>"grandstream/gxp2170", - "HW GXV3140"=>"grandstream/gxv3140", - "HW GXV3240"=>"grandstream/gxv3240", - "HW GXV3175"=>"grandstream/gxv3175", - "Vesa VCS754"=>"vtech/vcs754", - "Wget/1.11.3"=>"konftel/kt300ip" - ); - - foreach ($template_list as $key=>$val){ - if(stripos($_SERVER['HTTP_USER_AGENT'],$key)!== false) { - $device_template = $val; - break; - } - } - unset($template_list); - - //mac address does not exist in the table so add it - if ($_SESSION['provision']['auto_insert_enabled']['boolean'] == "true" and strlen($domain_uuid) > 0) { - $device_uuid = uuid(); - $sql = "INSERT INTO v_devices "; - $sql .= "("; - $sql .= "domain_uuid, "; - $sql .= "device_uuid, "; - $sql .= "device_mac_address, "; - $sql .= "device_vendor, "; - $sql .= "device_model, "; - $sql .= "device_enabled, "; - $sql .= "device_template, "; - $sql .= "device_description "; - $sql .= ") "; - $sql .= "VALUES "; - $sql .= "("; - $sql .= "'".$domain_uuid."', "; - $sql .= "'$device_uuid', "; - $sql .= "'$mac', "; - $sql .= "'$device_vendor', "; - $sql .= "'', "; - $sql .= "'true', "; - $sql .= "'$device_template', "; - $sql .= "'auto {$_SERVER['HTTP_USER_AGENT']}' "; - $sql .= ")"; - $this->db->exec(check_sql($sql)); - unset($sql); - } - } - } - - //alternate device_uuid - if (strlen($device_uuid) > 0) { - $sql = "SELECT * FROM v_devices "; - $sql .= "WHERE device_uuid = '".$device_uuid."' "; - $sql .= "AND device_enabled = 'true' "; - if($provision['http_domain_filter'] == "true") { - $sql .= "AND domain_uuid=:domain_uuid "; - } - $prep_statement_3 = $this->db->prepare(check_sql($sql)); - if ($prep_statement_3) { - if($provision['http_domain_filter'] == "true") { - $prep_statement_3->bindParam(':domain_uuid', $domain_uuid); - } - $prep_statement_3->execute(); - $row = $prep_statement_3->fetch(); - $device_uuid_alternate = $row["device_uuid_alternate"]; - if (is_uuid($device_uuid_alternate)) { - //override the original device_uuid - $device_uuid = $device_uuid_alternate; - //get the new devices information - $sql = "SELECT * FROM v_devices "; - $sql .= "WHERE device_uuid = '".$device_uuid."' "; - if($provision['http_domain_filter'] == "true") { - $sql .= "AND domain_uuid=:domain_uuid "; - } - $prep_statement_4 = $this->db->prepare(check_sql($sql)); - if ($prep_statement_4) { - if($provision['http_domain_filter'] == "true") { - $prep_statement_4->bindParam(':domain_uuid', $domain_uuid); - } - $prep_statement_4->execute(); - $row = $prep_statement_4->fetch(); - if($row["device_enabled"] == "true") { - $device_label = $row["device_label"]; - $device_firmware_version = $row["device_firmware_version"]; - $device_user_uuid = $row["device_user_uuid"]; - $device_enabled = $row["device_enabled"]; - //keep the original template - $device_profile_uuid = $row["device_profile_uuid"]; - $device_description = $row["device_description"]; - } - } - unset($prep_statement_4); - } - } - unset($prep_statement_3); - } - - //get the device settings table in the provision category from the profile and update the provision array - if ((strlen($device_uuid) > 0) and (strlen($device_profile_uuid) > 0)) { - $sql = "SELECT * FROM v_device_settings "; - $sql .= "WHERE device_profile_uuid = '".$device_profile_uuid."' "; - $sql .= "AND device_setting_enabled = 'true' "; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); - if (is_array($result)) { - foreach($result as $row) { - $key = $row['device_setting_subcategory']; - $value = $row['device_setting_value']; - $provision[$key] = $value; - } - } - unset ($prep_statement); - } - - //get the device settings table in the provision category and update the provision array - if (strlen($device_uuid) > 0) { - $sql = "SELECT * FROM v_device_settings "; - $sql .= "WHERE device_uuid = '".$device_uuid."' "; - $sql .= "AND device_setting_enabled = 'true' "; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - $result_count = count($result); - if (is_array($result)) { - foreach($result as $row) { - $key = $row['device_setting_subcategory']; - $value = $row['device_setting_value']; - $provision[$key] = $value; - } - } - unset ($prep_statement); - } - - //initialize a template object - $view = new template(); - if (strlen($_SESSION['provision']['template_engine']['text']) > 0) { - $view->engine = $_SESSION['provision']['template_engine']['text']; //raintpl, smarty, twig - } - else { - $view->engine = "smarty"; - } - $view->template_dir = $template_dir ."/".$device_template."/"; - $view->cache_dir = $_SESSION['server']['temp']['dir']; - $view->init(); - - //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number - - //create a mac address with back slashes for backwards compatability - $mac_dash = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2); - - //get the provisioning information from device lines table - if (strlen($device_uuid) > 0) { - //get the device lines array - $sql = "select * from v_device_lines "; - $sql .= "where device_uuid = '".$device_uuid."' "; - $sql .= "and (enabled = 'true' or enabled is null or enabled = '') "; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED); - //assign the keys array - $view->assign("lines", $device_lines); - //set the variables - if (is_array($device_lines)) { - foreach($device_lines as $row) { - //set the variables - $line_number = $row['line_number']; - $register_expires = $row['register_expires']; - $sip_transport = strtolower($row['sip_transport']); - $sip_port = $row['sip_port']; - - //set defaults - if (strlen($register_expires) == 0) { $register_expires = "120"; } - if (strlen($sip_transport) == 0) { $sip_transport = "tcp"; } - if (strlen($sip_port) == 0) { - if ($line_number == "" || $line_number == "1") { - $sip_port = "5060"; - } - else { - $sip_port = "506".($line_number + 1); - } - } - - //set a lines array index is the line number - $lines[$line_number]['register_expires'] = $register_expires; - $lines[$line_number]['sip_transport'] = strtolower($sip_transport); - $lines[$line_number]['sip_port'] = $sip_port; - $lines[$line_number]['server_address'] = $row["server_address"]; - $lines[$line_number]['outbound_proxy'] = $row["outbound_proxy_primary"]; - $lines[$line_number]['outbound_proxy_primary'] = $row["outbound_proxy_primary"]; - $lines[$line_number]['outbound_proxy_secondary'] = $row["outbound_proxy_secondary"]; - $lines[$line_number]['display_name'] = $row["display_name"]; - $lines[$line_number]['auth_id'] = $row["auth_id"]; - $lines[$line_number]['user_id'] = $row["user_id"]; - $lines[$line_number]['password'] = $row["password"]; - - //assign the variables for line one - short name - if ($line_number == "1") { - $view->assign("server_address", $row["server_address"]); - $view->assign("outbound_proxy", $row["outbound_proxy_primary"]); - $view->assign("outbound_proxy_primary", $row["outbound_proxy_primary"]); - $view->assign("outbound_proxy_secondary", $row["outbound_proxy_secondary"]); - $view->assign("display_name", $row["display_name"]); - $view->assign("auth_id", $row["auth_id"]); - $view->assign("user_id", $row["user_id"]); - $view->assign("user_password", $row["password"]); - $view->assign("sip_transport", $sip_transport); - $view->assign("sip_port", $sip_port); - $view->assign("register_expires", $register_expires); - } - - //assign the variables with the line number as part of the name - $view->assign("server_address_".$line_number, $row["server_address"]); - $view->assign("outbound_proxy_".$line_number, $row["outbound_proxy_primary"]); - $view->assign("outbound_proxy_primary_".$line_number, $row["outbound_proxy_primary"]); - $view->assign("outbound_proxy_secondary_".$line_number, $row["outbound_proxy_secondary"]); - $view->assign("display_name_".$line_number, $row["display_name"]); - $view->assign("auth_id_".$line_number, $row["auth_id"]); - $view->assign("user_id_".$line_number, $row["user_id"]); - $view->assign("user_password_".$line_number, $row["password"]); - $view->assign("sip_transport_".$line_number, $sip_transport); - $view->assign("sip_port_".$line_number, $sip_port); - $view->assign("register_expires_".$line_number, $register_expires); - } - } - unset ($prep_statement); - } - - //get the list of contact directly assigned to the user - if (strlen($device_user_uuid) > 0 and strlen($domain_uuid) > 0) { - //get the contacts assigned to the groups and add to the contacts array - if ($_SESSION['provision']['contact_groups']['boolean'] == "true") { - $this->contact_append($contacts, $line, $domain_uuid, $device_user_uuid, true); - } - - //get the contacts assigned to the user and add to the contacts array - if ($_SESSION['provision']['contact_users']['boolean'] == "true") { - $this->contact_append($contacts, $line, $domain_uuid, $device_user_uuid, false); - } - // Grandstream get the contacts assigned to the user and groups and add to the contacts array - if ($_SESSION['provision']['contact_grandstream']['text'] == "true") { - $this->contact_grandstream($contacts, $line, $domain_uuid, $device_user_uuid); - } - } - - //get the extensions and add them to the contacts array - if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0 and $_SESSION['provision']['contact_extensions']['boolean'] == "true") { - //get contacts from the database - $sql = "select extension_uuid as contact_uuid, directory_full_name, "; - $sql .= "effective_caller_id_name, effective_caller_id_number, "; - $sql .= "number_alias, extension "; - $sql .= "from v_extensions "; - $sql .= "where domain_uuid = '".$domain_uuid."' "; - $sql .= "and enabled = 'true' "; - $sql .= "order by number_alias, extension asc "; - $prep_statement = $this->db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED); - if (is_array($extensions)) { - foreach ($extensions as $row) { - //get the contact_uuid - $uuid = $row['contact_uuid']; - //get the names - if (strlen($row['directory_full_name']) > 0) { - $name_array = explode(" ", $row['directory_full_name']); - } else { - $name_array = explode(" ", $row['effective_caller_id_name']); - } - $contact_name_given = array_shift($name_array); - $contact_name_family = trim(implode(' ', $name_array)); - //get the phone_extension - if (is_numeric($row['extension'])) { - $phone_extension = $row['extension']; - } - else { - $phone_extension = $row['number_alias']; - } - //save the contact array values - $contacts[$uuid]['category'] = 'extensions'; - $contacts[$uuid]['contact_uuid'] = $row['contact_uuid']; - $contacts[$uuid]['contact_category'] = 'extensions'; - $contacts[$uuid]['contact_name_given'] = $contact_name_given; - $contacts[$uuid]['contact_name_family'] = $contact_name_family; - $contacts[$uuid]['phone_extension'] = $phone_extension; - //unset the variables - unset($name_array, $contact_name_given, $contact_name_family, $phone_extension); - } - } - } - } - - //assign the contacts array to the template - if (is_array($contacts)) { - $view->assign("contacts", $contacts); - unset($contacts); - } - - //get the provisioning information from device keys - if (strlen($device_uuid) > 0) { - - //get the device keys array - $sql = "SELECT * FROM v_device_keys "; - $sql .= "WHERE ("; - $sql .= "device_uuid = '".$device_uuid."' "; - if (strlen($device_profile_uuid) > 0) { - $sql .= "or device_profile_uuid = '".$device_profile_uuid."' "; - } - $sql .= ") "; - if (strtolower($device_vendor) == 'escene'){ - $sql .= "AND (lower(device_key_vendor) = 'escene' or lower(device_key_vendor) = 'escene programmable' or device_key_vendor is null) "; - } - else { - $sql .= "AND (lower(device_key_vendor) = '".$device_vendor."' or device_key_vendor is null) "; - } - $sql .= "ORDER BY "; - $sql .= "device_key_vendor ASC, "; - $sql .= "CASE device_key_category "; - $sql .= "WHEN 'line' THEN 1 "; - $sql .= "WHEN 'memory' THEN 2 "; - $sql .= "WHEN 'programmable' THEN 3 "; - $sql .= "WHEN 'expansion' THEN 4 "; - $sql .= "ELSE 100 END, "; - if ($GLOBALS['db_type'] == "mysql") { - $sql .= "device_key_id ASC, "; - } - else { - $sql .= "CAST(device_key_id as numeric) ASC, "; - } - $sql .= "CASE WHEN device_uuid IS NULL THEN 0 ELSE 1 END ASC "; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); - - //override profile keys with device keys - if (is_array($keys)) { - foreach($keys as $row) { - //set the variables - $id = $row['device_key_id']; - $category = $row['device_key_category']; - - //build the device keys array - $device_keys[$category][$id] = $row; - if (is_uuid($row['device_profile_uuid'])) { - $device_keys[$category][$id]['device_key_owner'] = "profile"; - } - else { - $device_keys[$category][$id]['device_key_owner'] = "device"; - } - - //kept temporarily for backwards comptability to allow custom templates to be updated - $device_keys[$id] = $row; - if (is_uuid($row['device_profile_uuid'])) { - $device_keys[$id]['device_key_owner'] = "profile"; - } - else { - $device_keys[$id]['device_key_owner'] = "device"; - } - } - } - unset($keys); - } - - //debug information - if ($debug == "array") { - echo "
\n";
-						print_r($device_keys);
-						echo "
\n";
-						exit;
-					}
-
-				//set the variables key and values
-					$x = 1;
-					$variables['domain_name'] = $domain_name;
-					$variables['user_id'] = $lines[$x]['user_id'];
-					$variables['auth_id'] = $lines[$x]['auth_id'];
-					$variables['extension'] = $lines[$x]['extension'];
-					//$variables['password'] = $lines[$x]['password'];
-					$variables['register_expires'] = $lines[$x]['register_expires'];
-					$variables['sip_transport'] = $lines[$x]['sip_transport'];
-					$variables['sip_port'] = $lines[$x]['sip_port'];
-					$variables['server_address'] = $lines[$x]['server_address'];
-					$variables['outbound_proxy'] = $lines[$x]['outbound_proxy_primary'];
-					$variables['outbound_proxy_primary'] = $lines[$x]['outbound_proxy_primary'];
-					$variables['outbound_proxy_secondary'] = $lines[$x]['outbound_proxy_secondary'];
-					$variables['display_name'] = $lines[$x]['display_name'];
-
-				//update the device keys by replacing variables with their values
-					foreach($variables as $name => $value) {
-						if (is_array($device_keys)) {
-							foreach($device_keys as $k => $field) {
-								if (strlen($field['device_key_uuid']) > 0) {
-										$device_keys[$k]['device_key_value'] = str_replace("\${".$name."}", $value, $field['device_key_value']);
-										$device_keys[$k]['device_key_extension'] = str_replace("\${".$name."}", $value, $field['device_key_extension']);
-										$device_keys[$k]['device_key_label'] = str_replace("\${".$name."}", $value, $field['device_key_label']);
-								}
-								else {
-									if (is_array($field)) {
-										foreach($field as $key => $row) {
-											$device_keys[$k][$key]['device_key_value'] = str_replace("\${".$name."}", $value, $row['device_key_value']);
-											$device_keys[$k][$key]['device_key_extension'] = str_replace("\${".$name."}", $value, $row['device_key_extension']);
-											$device_keys[$k][$key]['device_key_label'] = str_replace("\${".$name."}", $value, $row['device_key_label']);
-										}
-									}
-								}
-							}
-						}
-					}
-
-				//assign the keys array
-					$view->assign("keys", $device_keys);
-
-				//set the variables
-					$types = array("line", "memory", "expansion", "programmable");
-					foreach ($types as $type) {
-						if (is_array($device_keys[$type])) {
-							foreach($device_keys[$type] as $row) {
-								//set the variables
-									$device_key_category = $row['device_key_category'];
-									$device_key_id = $row['device_key_id']; //1
-									$device_key_type = $row['device_key_type']; //line
-									$device_key_line = $row['device_key_line'];
-									$device_key_value = $row['device_key_value']; //1
-									$device_key_extension = $row['device_key_extension'];
-									$device_key_label = $row['device_key_label']; //label
-
-								//add general variables
-									$device_key_value = str_replace("\${domain_name}", $domain_name, $device_key_value);
-									$device_key_extension = str_replace("\${domain_name}", $domain_name, $device_key_extension);
-									$device_key_label = str_replace("\${domain_name}", $domain_name, $device_key_label);
-
-								//grandstream modes are different based on the category
-									if ($device_vendor == "grandstream") {
-										if ($device_key_category == "line") {
-											switch ($device_key_type) {
-												case "line": $device_key_type  = "0"; break;
-												case "shared line": $device_key_type  = "1"; break;
-												case "speed dial": $device_key_type  = "10"; break;
-												case "blf": $device_key_type  = "11"; break;
-												case "presence watcher": $device_key_type  = "12"; break;
-												case "eventlist blf": $device_key_type  = "13"; break;
-												case "speed dial active": $device_key_type  = "14"; break;
-												case "dial dtmf": $device_key_type  = "15"; break;
-												case "voicemail": $device_key_type  = "16"; break;
-												case "call return": $device_key_type  = "17"; break;
-												case "transfer": $device_key_type  = "18"; break;
-												case "call park": $device_key_type  = "19"; break;
-												case "intercom": $device_key_type  = "20"; break;
-												case "ldap search": $device_key_type  = "21"; break;
-											}
-										}
-										if ($device_key_category == "memory" || $device_key_category == "expansion") {
-											switch ($device_key_type) {
-												case "speed dial": $device_key_type  = "0"; break;
-												case "blf": $device_key_type  = "1"; break;
-												case "presence watcher": $device_key_type  = "2"; break;
-												case "eventlist blf": $device_key_type  = "3"; break;
-												case "speed dial active": $device_key_type  = "4"; break;
-												case "dial dtmf": $device_key_type  = "5"; break;
-												case "voicemail": $device_key_type  = "6"; break;
-												case "call return": $device_key_type  = "7"; break;
-												case "transfer": $device_key_type  = "8"; break;
-												case "call park": $device_key_type  = "9"; break;
-												case "intercom": $device_key_type  = "10"; break;
-												case "ldap search": $device_key_type  = "11"; break;
-											}
-										}
-									}
-
-								//assign the variables
-									if (strlen($device_key_category) == 0) {
-										$view->assign("key_id_".$device_key_id, $device_key_id);
-										$view->assign("key_type_".$device_key_id, $device_key_type);
-										$view->assign("key_line_".$device_key_id, $device_key_line);
-										$view->assign("key_value_".$device_key_id, $device_key_value);
-										$view->assign("key_extension_".$device_key_id, $device_key_extension);
-										$view->assign("key_label_".$device_key_id, $device_key_label);
-									}
-									else {
-										$view->assign($device_key_category."_key_id_".$device_key_id, $device_key_id);
-										$view->assign($device_key_category."_key_type_".$device_key_id, $device_key_type);
-										$view->assign($device_key_category."_key_line_".$device_key_id, $device_key_line);
-										$view->assign($device_key_category."_key_value_".$device_key_id, $device_key_value);
-										$view->assign($device_key_category."_key_extension_".$device_key_id, $device_key_extension);
-										$view->assign($device_key_category."_key_label_".$device_key_id, $device_key_label);
-									}
-							}
-						}
-					}
-					unset ($prep_statement);
-
-				//set the mac address in the correct format
-					$mac = $this->format_mac($mac, $device_vendor);
-
-				//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
-					$view->assign("mac" , $mac);
-					$view->assign("label", $device_label);
-					$view->assign("device_label", $device_label);
-					$view->assign("firmware_version", $device_firmware_version);
-					$view->assign("domain_name", $domain_name);
-					$view->assign("project_path", PROJECT_PATH);
-					$view->assign("server1_address", $server1_address);
-					$view->assign("proxy1_address", $proxy1_address);
-					$view->assign("user_id",$user_id);
-					$view->assign("password",$password);
-					$view->assign("template",$device_template);
-
-				// personal ldap password
-					global $laddr_salt;
-					if (isset($device_user_uuid)){
-						$sql = "SELECT contact_uuid FROM v_users WHERE user_uuid='".$device_user_uuid."'";
-						$prep_statement = $this->db->prepare(check_sql($sql));
-						$prep_statement->execute();
-						$c_uuid = $prep_statement->fetchAll(PDO::FETCH_NAMED);
-						$view->assign("ldap_username","uid=".$c_uuid[0]['contact_uuid'].",".$_SESSION['provision']['gs_ldap_user_base']['text']);
-						$view->assign("ldap_password",md5($laddr_salt.$device_user_uuid));
-					}
-
-
-				//get the time zone
-					$time_zone_name = $_SESSION['domain']['time_zone']['name'];
-					if (strlen($time_zone_name) > 0) {
-						$time_zone_offset_raw = get_time_zone_offset($time_zone_name)/3600;
-						$time_zone_offset_hours = floor($time_zone_offset_raw);
-						$time_zone_offset_minutes = ($time_zone_offset_raw - $time_zone_offset_hours) * 60;
-						$time_zone_offset_minutes = number_pad($time_zone_offset_minutes, 2);
-						if ($time_zone_offset_raw > 0) {
-							$time_zone_offset_hours = number_pad($time_zone_offset_hours, 2);
-							$time_zone_offset_hours = "+".$time_zone_offset_hours;
-						}
-						else {
-							$time_zone_offset_hours = str_replace("-", "", $time_zone_offset_hours);
-							$time_zone_offset_hours = "-".number_pad($time_zone_offset_hours, 2);
-						}
-						$time_zone_offset = $time_zone_offset_hours.":".$time_zone_offset_minutes;
-						if (!isset($provision["time_zone_offset"])) {
-							$provision["time_zone_offset"] = $time_zone_offset;
-						}
-					}
-
-				//set the daylight savings time
-					if (!isset($provision["yealink_time_zone_start_time"])) {
-						$provision["yealink_time_zone_start_time"] = $provision["daylight_savings_start_month"]."/".$provision["daylight_savings_start_day"]."/".$provision["daylight_savings_start_time"];
-					}
-					if (!isset($provision["yealink_time_zone_end_time"])) {
-						$provision["yealink_time_zone_end_time"] = $provision["daylight_savings_stop_month"]."/".$provision["daylight_savings_stop_day"]."/".$provision["daylight_savings_stop_time"];
-					}
-
-				//replace the dynamic provision variables that are defined in default, domain, and device settings
-					if (is_array($provision)) {
-						foreach($provision as $key=>$val) {
-							$view->assign($key, $val);
-						}
-					}
-
-				//set the template directory
-					if (strlen($provision["template_dir"]) > 0) {
-						$template_dir = $provision["template_dir"];
-					}
-
-				//if the domain name directory exists then only use templates from it
-					if (is_dir($template_dir.'/'.$domain_name)) {
-						$device_template = $domain_name.'/'.$device_template;
-					}
-
-				//if $file is not provided then look for a default file that exists
-					if (strlen($file) == 0) {
-						if (file_exists($template_dir."/".$device_template ."/{\$mac}")) {
-							$file = "{\$mac}";
-						}
-						elseif (file_exists($template_dir."/".$device_template ."/{\$mac}.xml")) {
-							$file = "{\$mac}.xml";
-						}
-						elseif (file_exists($template_dir."/".$device_template ."/{\$mac}.cfg")) {
-							$file = "{\$mac}.cfg";
-						}
-						else {
-							echo "file not found";
-							exit;
-						}
-					}
-					else {
-						//make sure the file exists
-						if (!file_exists($template_dir."/".$device_template ."/".$file)) {
-							echo "file not found ".$template_dir."/".$device_template ."/".$file;
-							if ($_SESSION['provision']['debug']['boolean'] == 'true'){
-								echo ":$template_dir/$device_template/$file
"; - echo "template_dir: $template_dir
"; - echo "device_template: $device_template
"; - echo "file: $file"; - } - exit; - } - } - - //output template to string for header processing - $file_contents = $view->render($file); - - //log file for testing - if ($_SESSION['provision']['debug']['boolean'] == 'true'){ - $tmp_file = "/tmp/provisioning_log.txt"; - $fh = fopen($tmp_file, 'w') or die("can't open file"); - $tmp_string = $mac."\n"; - fwrite($fh, $tmp_string); - fclose($fh); - } - - $this->file = $file; - //returned the rendered template - return $file_contents; - - } //end render function - - function write() { - //build the provision array - $provision = Array(); - if (is_array($_SESSION['provision'])) { - foreach($_SESSION['provision'] as $key=>$val) { - if (strlen($val['var']) > 0) { $value = $val['var']; } - if (strlen($val['text']) > 0) { $value = $val['text']; } - if (strlen($val['boolean']) > 0) { $value = $val['boolean']; } - if (strlen($val['numeric']) > 0) { $value = $val['numeric']; } - if (strlen($value) > 0) { $provision[$key] = $value; } - unset($value); - } - } - - //check either we have destination path to write files - if(strlen($provision["path"]) == 0){ - return; - } - - //get the devices from database - $sql = "select * from v_devices "; - //$sql .= "where domain_uuid = '".$this->domain_uuid."' "; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - unset ($prep_statement); - - //process each device - if (is_array($result)) foreach ($result as &$row) { - //get the values from the database and set as variables - $domain_uuid = $row["domain_uuid"]; - $device_uuid = $row["device_uuid"]; - $device_mac_address = $row["device_mac_address"]; - $device_label = $row["device_label"]; - $device_vendor = strtolower($row["device_vendor"]); - $device_model = $row["device_model"]; - $device_firmware_version = $row["device_firmware_version"]; - $device_enabled = $row["device_enabled"]; - $device_template = $row["device_template"]; - $device_username = $row["device_username"]; - $device_password = $row["device_password"]; - $device_description = $row["device_description"]; - - clearstatcache(); - - //loop through the provision template directory - $dir_array = array(); - if (strlen($device_template) > 0) { - $template_path = path_join($this->template_dir, $device_template); - $dir_list = opendir($template_path); - if ($dir_list) { - $x = 0; - while (false !== ($file = readdir($dir_list))) { - $ignore = $file == "." || $file == ".." || substr($file, -3) == ".db" || - substr($file, -4) == ".svn" || substr($file, -4) == ".git"; - if (!$ignore) { - $dir_array[] = path_join($template_path, $file); - if ($x > 1000) { break; }; - $x++; - } - } - closedir($dir_list); - unset($x, $file); - } - unset($dir_list, $template_path); - } - - //loop through the provision templates - if (is_array($dir_array)) foreach ($dir_array as &$template_path) { - if (is_dir($template_path)) continue; - if (!file_exists($template_path)) continue; - - //template file name - $file_name = basename($template_path); - - //configure device object - $this->domain_uuid = $domain_uuid; - $this->mac = $device_mac_address; - $this->file = $file_name; - - //format the mac address - $mac = $this->format_mac($device_mac_address, $device_vendor); - - //replace {$mac} in the file name - $file_name = str_replace("{\$mac}", $mac, $file_name); - - //render and write configuration to file - $provision_dir_array = explode(";", $provision["path"]); - if (is_array($provision_dir_array)) foreach($provision_dir_array as $directory) { - //destinatino file path - $dest_path = path_join($directory, $file_name); - - if ($device_enabled == 'true'){ - //output template to string for header processing - $file_contents = $this->render(); - - //write the file - mkdir($directory,0777,true); - $fh = fopen($dest_path,"w") or die("Unable to write to $directory for provisioning. Make sure the path exists and permissons are set correctly."); - fwrite($fh, $file_contents); - fclose($fh); - } - else{ // device disabled - //remove only files with `{$mac}` name - if(strpos($template_path, '{$mac}') !== false){ - unlink($dest_path); - } - } - - unset($dest_path); - } - //unset variables - unset($file_name, $provision_dir_array); - } //end for each - - //unset variables - unset($dir_array); - } - } //end write function - - } //end provision class - -?> + + Copyright (C) 2014-2016 + All Rights Reserved. + + Contributor(s): + Mark J Crane + Luis Daniel Lucio Quiroz +*/ +include "root.php"; + +//define the provision class + class provision { + public $db; + public $domain_uuid; + public $domain_name; + public $template_dir; + public $mac; + + public function __construct() { + //get the database object + global $db; + $this->db = $db; + //set the default template directory + if (PHP_OS == "Linux") { + //set the default template dir + if (strlen($this->template_dir) == 0) { + if (file_exists('/etc/fusionpbx/resources/templates/provision')) { + $this->template_dir = '/etc/fusionpbx/resources/templates/provision'; + } + else { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + } + } elseif (PHP_OS == "FreeBSD") { + //if the FreeBSD port is installed use the following paths by default. + if (file_exists('/usr/local/etc/fusionpbx/resources/templates/provision')) { + if (strlen($this->template_dir) == 0) { + $this->template_dir = '/usr/local/etc/fusionpbx/resources/templates/provision'; + } + else { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + } + else { + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + else { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + } + } elseif (PHP_OS == "NetBSD") { + //set the default template_dir + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + } elseif (PHP_OS == "OpenBSD") { + //set the default template_dir + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + } else { + //set the default template_dir + if (strlen($this->template_dir) == 0) { + $this->template_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/templates/provision'; + } + } + + //normalize the mac address + if (isset($this->mac)) { + $this->mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $this->mac)); + } + } + + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + public function get_domain_uuid() { + return $this->domain_uuid; + } + + //define the function which checks to see if the mac address exists in devices + private function mac_exists($mac) { + //normalize the mac address + $mac = strtolower(preg_replace('#[^a-fA-F0-9./]#', '', $mac)); + //check in the devices table for a specific mac address + $sql = "SELECT count(*) as count FROM v_devices "; + $sql .= "WHERE device_mac_address=:mac "; + $prep_statement = $this->db->prepare(check_sql($sql)); + if ($prep_statement) { + //$prep_statement->bindParam(':domain_uuid', $domain_uuid); + $prep_statement->bindParam(':mac', $mac); + $prep_statement->execute(); + $row = $prep_statement->fetch(); + $count = $row['count']; + if ($row['count'] > 0) { + return true; + } + else { + return false; + } + } + else { + return false; + } + } + + //set the mac address in the correct format for the specific vendor + public function format_mac($mac, $vendor) { + switch (strtolower($vendor)) { + case "algo": + $mac = strtoupper($mac); + break; + case "aastra": + $mac = strtoupper($mac); + break; + case "cisco": + $mac = strtoupper($mac); + break; + case "linksys": + $mac = strtolower($mac); + break; + case "mitel": + $mac = strtoupper($mac); + break; + case "polycom": + $mac = strtolower($mac); + break; + case "snom": + $mac = strtolower($mac); + break; + case "escene": + $mac = strtolower($mac); + break; + case "grandstream": + $mac = strtolower($mac); + break; + default: + $mac = strtolower($mac); + $mac = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2); + } + return $mac; + } + + //define a function to check if a contact exists in the contacts array + private function contact_exists($contacts, $uuid) { + if (is_array($contacts[$uuid])) { + return true; + } + else { + return false; + } + } + + private function contact_append(&$contacts, &$line, $domain_uuid, $device_user_uuid, $is_group){ + $sql = "select c.contact_uuid, c.contact_organization, c.contact_name_given, c.contact_name_family, "; + $sql .= "c.contact_type, c.contact_category, p.phone_label,"; + $sql .= "p.phone_number, p.phone_extension, p.phone_primary "; + $sql .= "from v_contacts as c, v_contact_phones as p "; + $sql .= "where c.contact_uuid = p.contact_uuid "; + $sql .= "and p.phone_type_voice = '1' "; + $sql .= "and c.domain_uuid = '$domain_uuid' "; + if ($is_group) { + $sql .= "and c.contact_uuid in ( "; + $sql .= " select contact_uuid from v_contact_groups "; + $sql .= " where group_uuid in ( "; + $sql .= " select group_uuid from v_group_users "; + $sql .= " where user_uuid = '$device_user_uuid' "; + $sql .= " and domain_uuid = '$domain_uuid' "; + $sql .= " )) "; + } + else { + $sql .= "and c.contact_uuid in ( "; + $sql .= " select contact_uuid from v_contact_users "; + $sql .= " where user_uuid = '$device_user_uuid' "; + $sql .= " and domain_uuid = '$domain_uuid' "; + $sql .= ") "; + } + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement, $sql); + + if (is_array($user_contacts)) { + foreach ($user_contacts as &$row) { + $uuid = $row['contact_uuid']; + $phone_label = strtolower($row['phone_label']); + $contact_category = strtolower($row['contact_category']); + + $contact = array(); + $contacts[] = &$contact; + $contact['category'] = $is_group ? 'groups' : 'users'; + $contact['contact_uuid'] = $row['contact_uuid']; + $contact['contact_type'] = $row['contact_type']; + $contact['contact_category'] = $row['contact_category']; + $contact['contact_organization'] = $row['contact_organization']; + $contact['contact_name_given'] = $row['contact_name_given']; + $contact['contact_name_family'] = $row['contact_name_family']; + $contact['numbers'] = array(); + + $numbers = &$contact['numbers']; + + if (($row['phone_primary'] == '1') || (!isset($contact['phone_number']))) { + $contact['phone_label'] = $phone_label; + $contact['phone_number'] = $row['phone_number']; + $contact['phone_extension'] = $row['phone_extension']; + } + + $numbers[] = array( + line_number => $line['line_number'], + phone_label => $phone_label, + phone_number => $row['phone_number'], + phone_extension => $row['phone_extension'], + phone_primary => $row['phone_primary'], + ); + + $contact['phone_number_' . $phone_label] = $row['phone_number']; + unset($contact, $numbers, $uuid, $phone_label); + } + } + } + + private function contact_grandstream(&$contacts, &$line, $domain_uuid, $device_user_uuid){ + // Get username for this. + $sql = "SELECT username FROM v_users WHERE user_uuid = '${device_user_uuid}' AND domain_uuid = '${domain_uuid}' LIMIT 1"; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $my_username = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement, $sql); + $my_username = $my_username[0]['username']; + + // Global contact groups available to every phone if ['provision']['global_contact_groups']['text'] is set. + // Easier than assigning these common groups to every user. + // Check provision global_contact_groups and sanitize for sql. + $global_contact_groups['enabled']=false; + if ( preg_match('/[a-zA-Z0-9-_, ]/',$_SESSION['provision']['gs_global_contact_groups']['text'])){ + $global_contact_groups['enabled']=true; + $gp=array(); + $groups=explode(',',$_SESSION['provision']['gs_global_contact_groups']['text']); + foreach ($groups as $group){ + $gp[] = trim($group); + } + $global_contact_groups['sql']="'".implode("','", $gp)."'"; + } + // Get a list of groups the user has access to see. + $sql = "SELECT DISTINCT g.group_uuid, g.group_name, g.group_description "; + $sql .= "FROM v_groups g "; + $sql .= " INNER JOIN v_group_users gu "; + $sql .= " ON gu.group_uuid=g.group_uuid "; + $sql .= " INNER JOIN v_contact_groups cg "; + $sql .= " ON cg.group_uuid=g.group_uuid "; + $sql .= "WHERE gu.user_uuid = '$device_user_uuid' "; + if ( $global_contact_groups['enabled'] ){ + $sql .= "UNION "; + $sql .= "SELECT g.group_uuid, g.group_name, g.group_description "; + $sql .= "FROM v_groups g "; + $sql .= "WHERE g.group_name IN( ".$global_contact_groups['sql'].") "; + } + $sql .= "ORDER BY group_description"; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $user_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement, $sql); + $key=0; + foreach ($user_groups as &$row) { + $contacts[] = array("contact_type"=>"group", "group_name"=>$row['group_name'], "group_description"=>$row['group_description'], "id"=>++$key); + $groups[$row['group_uuid']] = $key; + $my_groups[] = '@'.$row['group_name']; // Used to show/hide + } + // Get a list of contacts that this user/phone has access based on assigned users and groups. + $sql = "SELECT c.contact_uuid, c.contact_name_given, c.contact_name_family, c.contact_title, c.contact_category, c.contact_role, c.contact_organization, u.user_uuid "; + $sql .= "FROM v_contacts c "; + $sql .= " LEFT JOIN v_users u "; + $sql .= " ON c.contact_uuid = u.contact_uuid "; + $sql .= "WHERE c.contact_uuid IN ("; // assigned groups + $sql .= " SELECT cg.contact_uuid"; + $sql .= " FROM v_contact_groups cg "; + $sql .= " WHERE cg.group_uuid IN ("; + $sql .= " SELECT gu.group_uuid "; + $sql .= " FROM v_group_users gu "; + $sql .= " WHERE gu.user_uuid = '$device_user_uuid' "; + $sql .= " AND gu.domain_uuid = '$domain_uuid' "; + if ( $global_contact_groups['enabled'] ){ + $sql .= " UNION "; + $sql .= " SELECT g.group_uuid "; + $sql .= " FROM v_groups g "; + $sql .= " WHERE g.group_name IN( ".$global_contact_groups['sql'].") "; + } + $sql .= " )"; + $sql .= " UNION "; // assigned users + $sql .= " SELECT cu.contact_uuid "; + $sql .= " FROM v_contact_users cu "; + $sql .= " WHERE cu.user_uuid = '$device_user_uuid' "; + $sql .= " AND cu.domain_uuid = '$domain_uuid' "; + $sql .= ")"; + $sql .= "ORDER BY contact_name_given, contact_name_family"; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $user_contacts = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement, $sql); + $groupid=0; + foreach ($user_contacts as &$row) { + $last_extention = $row['extension']; + unset($contact); + // Grandsteam phonebook manager: First, Last, Department, Primary, (Work, Home, Mobile, Fax, Pager, Car... with number and account), email(s), Photo, Ringtone, Group(s) + // GXP21xx serries has First, Last, Company, Department, Job, Job TItle, 1Work ,1Home, 1Mobile, Accounts, Groups(1-many) + $contact = array(); + $contact['contact_type'] = "contact"; + $contact['contact_uuid'] = $row['contact_uuid']; + $contact['user_uuid'] = $row['user_uuid']; + $contact['contact_name_given'] = $row['contact_name_given']; //FirstName + $contact['contact_name_family'] = $row['contact_name_family']; // LastName + $contact['contact_title'] = $row['contact_title']; + $contact['contact_category'] = $row['contact_category']; // Department + $contact['contact_role'] = $row['contact_role']; // Job Title + $contact['contact_organization']= $row['contact_organization']; // Company + $contact['contact_work'] = $row['extension']; + //$contact['contact_account_index'] = $line['line_number']; // This was empty so disabled it. + // Look up groups for this contact + $sql = "SELECT g.group_description, g.group_uuid "; + $sql .= "FROM v_groups g "; + $sql .= " INNER JOIN v_contact_groups cg "; + $sql .= " ON cg.group_uuid=g.group_uuid "; + $sql .= "WHERE cg.contact_uuid = '".$row['contact_uuid']."' "; + $sql .= "AND cg.domain_uuid = '$domain_uuid'"; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $user_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($user_groups as $group ){ + if ( ! empty($groups[$group['group_uuid']])){ + $contact['groups'][] = $groups[$group['group_uuid']]; + } + } + if ( empty($contact['groups']) && !empty($groups['Other'])){ + $contact['groups'][] = $groups['Other']; + } + // Look up extention(s) for this contact. + if ( ! empty ($row['user_uuid']) ){ + $sql = "SELECT e.extension, e.description "; + $sql .= "FROM v_extensions e "; + $sql .= " INNER JOIN v_extension_users eu "; + $sql .= " ON e.extension_uuid = eu.extension_uuid "; + $sql .= "WHERE eu.user_uuid = '".$row['user_uuid']."' "; + $sql .= "AND eu.domain_uuid = '$domain_uuid' "; + $sql .= "AND e.enabled = 'true' "; + $sql .= "AND e.directory_visible = 'true' "; # TODO: not right field but it works for our district. + $sql .= "AND e.directory_exten_visible = 'true' "; # TODO: not right field but it works for our district. + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $user_extentions = $prep_statement->fetchAll(PDO::FETCH_NAMED); + foreach ($user_extentions as $ext ){ + if ( preg_match ('/ (Cell|Mobile)/i', $ext['description'])){ + $contact['contact_cell'] = $ext['extension']; + } elseif ( preg_match ("/ Home/i", $ext['description'])){ + $contact['contact_home'] = $ext['extension']; + } else { + $contact['contact_work'] = $ext['extension']; + } + } + } + // Additional phone numbers for this contact. + $sql = "select phone_number, phone_label, phone_description from v_contact_phones "; + $sql .= "where contact_uuid='".$row['contact_uuid']."' "; + $sql .= "and domain_uuid='".$domain_uuid."' "; + $sql .= "and phone_type_voice = '1' "; + $sql .= "and phone_label in ('Home', 'Mobile', 'Work') "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $user_phones = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset($prep_statement, $sql); + foreach ($user_phones as $phone){ + // Check permission in phone_description field for string :allow:username1:username2:@group1:@group2: + $show = true; + if ( preg_match ('/:allow:/i', $phone['phone_description'] )){ + $show = false; + $allows = explode ( ':', $phone['phone_description'] ); + foreach ( $allows as $allow ){ + if ( in_array($allow, $my_groups) || preg_match('/^'.$my_username.'$/', $allow)){ + $show = true; + break 1; + } + } + } + if ( $show && $phone['phone_label'] == "Home" ) { + $contact['contact_home'] = $phone['phone_number']; + } elseif ( $show && $phone['phone_label'] == "Mobile" ){ + $contact['contact_cell'] = $phone['phone_number']; + } elseif ( $show && $phone['phone_label'] == "Work" ){ + // Work phones are usually just extentions already assigned above. + if (empty($contact['contact_work'])){ + $contact['contact_work'] = $phone['phone_number']; + } + } + } + // Only add to contact list if a phone number exists. + if(!empty($contact['contact_work']) || !empty($contact['contact_home']) || !empty($contact['contact_cell'])){ + $contacts[] = &$contact; + } + } + } + + public function render() { + + //debug + $debug = $_REQUEST['debug']; // array + + //get the variables + $domain_uuid = $this->domain_uuid; + $device_template = $this->device_template; + $template_dir = $this->template_dir; + $mac = $this->mac; + $file = $this->file; + + //set the mac address to lower case to be consistent with the database + $mac = strtolower($mac); + + //get the device template + if (strlen($_REQUEST['template']) > 0) { + $device_template = $_REQUEST['template']; + $search = array('..', '/./'); + $device_template = str_replace($search, "", $device_template); + $device_template = str_replace('//', '/', $device_template); + } + + //remove ../ and slashes in the file name + $search = array('..', '/', '\\', '/./', '//'); + $file = str_replace($search, "", $file); + + //get the domain_name + if (strlen($domain_name) == 0) { + $sql = "SELECT domain_name FROM v_domains "; + $sql .= "WHERE domain_uuid=:domain_uuid "; + $prep_statement = $this->db->prepare(check_sql($sql)); + if ($prep_statement) { + //use the prepared statement + $prep_statement->bindParam(':domain_uuid', $domain_uuid); + $prep_statement->execute(); + $row = $prep_statement->fetch(); + unset($prep_statement); + //set the variables from values in the database + $domain_name = $row["domain_name"]; + } + } + + //build the provision array + $provision = Array(); + if (is_array($_SESSION['provision'])) { + foreach($_SESSION['provision'] as $key=>$val) { + if (strlen($val['var']) > 0) { $value = $val['var']; } + if (strlen($val['text']) > 0) { $value = $val['text']; } + if (strlen($val['boolean']) > 0) { $value = $val['boolean']; } + if (strlen($val['numeric']) > 0) { $value = $val['numeric']; } + if (strlen($value) > 0) { $provision[$key] = $value; } + unset($value); + } + } + + //check to see if the mac_address exists in devices + if (strlen($_REQUEST['user_id']) == 0 || strlen($_REQUEST['userid']) == 0) { + if ($this->mac_exists($mac)) { + //get the device_template + if (strlen($device_template) == 0) { + $sql = "SELECT * FROM v_devices "; + $sql .= "WHERE device_mac_address=:mac "; + if($provision['http_domain_filter'] == "true") { + $sql .= "AND domain_uuid=:domain_uuid "; + } + $prep_statement_2 = $this->db->prepare(check_sql($sql)); + if ($prep_statement_2) { + //use the prepared statement + $prep_statement_2->bindParam(':mac', $mac); + if($provision['http_domain_filter'] == "true") { + $prep_statement_2->bindParam(':domain_uuid', $domain_uuid); + } + $prep_statement_2->execute(); + $row = $prep_statement_2->fetch(); + //checks either device enabled + if($row['device_enabled'] != 'true'){ + if ($_SESSION['provision']['debug']['boolean'] == 'true'){ + echo "
device disabled
"; + } + echo "file not found"; + exit; + } + + //set the variables from values in the database + $device_uuid = $row["device_uuid"]; + $device_label = $row["device_label"]; + if (strlen($row["device_vendor"]) > 0) { + $device_vendor = strtolower($row["device_vendor"]); + } + $device_user_uuid = $row["device_user_uuid"]; + $device_model = $row["device_model"]; + $device_firmware_version = $row["device_firmware_version"]; + $device_enabled = $row["device_enabled"]; + $device_template = $row["device_template"]; + $device_profile_uuid = $row["device_profile_uuid"]; + $device_description = $row["device_description"]; + } + } + + //find a template that was defined on another phone and use that as the default. + if (strlen($device_template) == 0) { + $sql = "SELECT * FROM v_devices "; + $sql .= "WHERE domain_uuid=:domain_uuid "; + $sql .= "AND device_enabled='true' "; + $sql .= "limit 1 "; + $prep_statement_3 = $this->db->prepare(check_sql($sql)); + if ($prep_statement_3) { + $prep_statement_3->bindParam(':domain_uuid', $domain_uuid); + $prep_statement_3->execute(); + $row = $prep_statement_3->fetch(); + $device_label = $row["device_label"]; + $device_vendor = strtolower($row["device_vendor"]); + $device_model = $row["device_model"]; + $device_firmware_version = $row["device_firmware_version"]; + $device_enabled = $row["device_enabled"]; + $device_template = $row["device_template"]; + $device_profile_uuid = $row["device_profile_uuid"]; + $device_description = $row["device_description"]; + } + } + } + else { + //use the user_agent to pre-assign a template for 1-hit provisioning. Enter the a unique string to match in the user agent, and the template it should match. + $template_list=array( + "Linksys/SPA-2102"=>"linksys/spa2102", + "Linksys/SPA-3102"=>"linksys/spa3102", + "Linksys/SPA-9212"=>"linksys/spa921", + "Cisco/SPA301"=>"cisco/spa301", + "Cisco/SPA301D"=>"cisco/spa302d", + "Cisco/SPA303"=>"cisco/spa303", + "Cisco/SPA501G"=>"cisco/spa501g", + "Cisco/SPA502G"=>"cisco/spa502g", + "Cisco/SPA504G"=>"cisco/spa504g", + "Cisco/SPA508G"=>"cisco/spa508g", + "Cisco/SPA509G"=>"cisco/spa509g", + "Cisco/SPA512G"=>"cisco/spa512g", + "Cisco/SPA514G"=>"cisco/spa514g", + "Cisco/SPA525G2"=>"cisco/spa525g2", + "snom300-SIP"=>"snom/300", + "snom320-SIP"=>"snom/320", + "snom360-SIP"=>"snom/360", + "snom370-SIP"=>"snom/370", + "snom820-SIP"=>"snom/820", + "snom-m3-SIP"=>"snom/m3", + "yealink SIP-T20"=>"yealink/t20", + "yealink SIP-T22"=>"yealink/t22", + "yealink SIP-T26"=>"yealink/t26", + "Yealink SIP-T32"=>"yealink/t32", + "HW DP750"=>"grandstream/dp750", + "HW GXP1450"=>"grandstream/gxp1450", + "HW GXP1628"=>"grandstream/gxp16xx", + "HW GXP1610"=>"grandstream/gxp16xx", + "HW GXP1620"=>"grandstream/gxp16xx", + "HW GXP1625"=>"grandstream/gxp16xx", + "HW GXP1628"=>"grandstream/gxp16xx", + "HW GXP1630"=>"grandstream/gxp16xx", + "HW GXP2124"=>"grandstream/gxp2124", + "HW GXP2130"=>"grandstream/gxp2130", + "HW GXP2135"=>"grandstream/gxp2135", + "HW GXP2140"=>"grandstream/gxp2140", + "HW GXP2160"=>"grandstream/gxp2160", + "HW GXP2170"=>"grandstream/gxp2170", + "HW GXV3140"=>"grandstream/gxv3140", + "HW GXV3240"=>"grandstream/gxv3240", + "HW GXV3175"=>"grandstream/gxv3175", + "Vesa VCS754"=>"vtech/vcs754", + "Wget/1.11.3"=>"konftel/kt300ip" + ); + + foreach ($template_list as $key=>$val){ + if(stripos($_SERVER['HTTP_USER_AGENT'],$key)!== false) { + $device_template = $val; + break; + } + } + unset($template_list); + + //mac address does not exist in the table so add it + if ($_SESSION['provision']['auto_insert_enabled']['boolean'] == "true" and strlen($domain_uuid) > 0) { + $device_uuid = uuid(); + $sql = "INSERT INTO v_devices "; + $sql .= "("; + $sql .= "domain_uuid, "; + $sql .= "device_uuid, "; + $sql .= "device_mac_address, "; + $sql .= "device_vendor, "; + $sql .= "device_model, "; + $sql .= "device_enabled, "; + $sql .= "device_template, "; + $sql .= "device_description "; + $sql .= ") "; + $sql .= "VALUES "; + $sql .= "("; + $sql .= "'".$domain_uuid."', "; + $sql .= "'$device_uuid', "; + $sql .= "'$mac', "; + $sql .= "'$device_vendor', "; + $sql .= "'', "; + $sql .= "'true', "; + $sql .= "'$device_template', "; + $sql .= "'auto {$_SERVER['HTTP_USER_AGENT']}' "; + $sql .= ")"; + $this->db->exec(check_sql($sql)); + unset($sql); + } + } + } + + //alternate device_uuid + if (strlen($device_uuid) > 0) { + $sql = "SELECT * FROM v_devices "; + $sql .= "WHERE device_uuid = '".$device_uuid."' "; + $sql .= "AND device_enabled = 'true' "; + if($provision['http_domain_filter'] == "true") { + $sql .= "AND domain_uuid=:domain_uuid "; + } + $prep_statement_3 = $this->db->prepare(check_sql($sql)); + if ($prep_statement_3) { + if($provision['http_domain_filter'] == "true") { + $prep_statement_3->bindParam(':domain_uuid', $domain_uuid); + } + $prep_statement_3->execute(); + $row = $prep_statement_3->fetch(); + $device_uuid_alternate = $row["device_uuid_alternate"]; + if (is_uuid($device_uuid_alternate)) { + //override the original device_uuid + $device_uuid = $device_uuid_alternate; + //get the new devices information + $sql = "SELECT * FROM v_devices "; + $sql .= "WHERE device_uuid = '".$device_uuid."' "; + if($provision['http_domain_filter'] == "true") { + $sql .= "AND domain_uuid=:domain_uuid "; + } + $prep_statement_4 = $this->db->prepare(check_sql($sql)); + if ($prep_statement_4) { + if($provision['http_domain_filter'] == "true") { + $prep_statement_4->bindParam(':domain_uuid', $domain_uuid); + } + $prep_statement_4->execute(); + $row = $prep_statement_4->fetch(); + if($row["device_enabled"] == "true") { + $device_label = $row["device_label"]; + $device_firmware_version = $row["device_firmware_version"]; + $device_user_uuid = $row["device_user_uuid"]; + $device_enabled = $row["device_enabled"]; + //keep the original template + $device_profile_uuid = $row["device_profile_uuid"]; + $device_description = $row["device_description"]; + } + } + unset($prep_statement_4); + } + } + unset($prep_statement_3); + } + + //get the device settings table in the provision category from the profile and update the provision array + if ((strlen($device_uuid) > 0) and (strlen($device_profile_uuid) > 0)) { + $sql = "SELECT * FROM v_device_settings "; + $sql .= "WHERE device_profile_uuid = '".$device_profile_uuid."' "; + $sql .= "AND device_setting_enabled = 'true' "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + if (is_array($result)) { + foreach($result as $row) { + $key = $row['device_setting_subcategory']; + $value = $row['device_setting_value']; + $provision[$key] = $value; + } + } + unset ($prep_statement); + } + + //get the device settings table in the provision category and update the provision array + if (strlen($device_uuid) > 0) { + $sql = "SELECT * FROM v_device_settings "; + $sql .= "WHERE device_uuid = '".$device_uuid."' "; + $sql .= "AND device_setting_enabled = 'true' "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + $result_count = count($result); + if (is_array($result)) { + foreach($result as $row) { + $key = $row['device_setting_subcategory']; + $value = $row['device_setting_value']; + $provision[$key] = $value; + } + } + unset ($prep_statement); + } + + //initialize a template object + $view = new template(); + if (strlen($_SESSION['provision']['template_engine']['text']) > 0) { + $view->engine = $_SESSION['provision']['template_engine']['text']; //raintpl, smarty, twig + } + else { + $view->engine = "smarty"; + } + $view->template_dir = $template_dir ."/".$device_template."/"; + $view->cache_dir = $_SESSION['server']['temp']['dir']; + $view->init(); + + //replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number + + //create a mac address with back slashes for backwards compatability + $mac_dash = substr($mac, 0,2).'-'.substr($mac, 2,2).'-'.substr($mac, 4,2).'-'.substr($mac, 6,2).'-'.substr($mac, 8,2).'-'.substr($mac, 10,2); + + //get the provisioning information from device lines table + if (strlen($device_uuid) > 0) { + //get the device lines array + $sql = "select * from v_device_lines "; + $sql .= "where device_uuid = '".$device_uuid."' "; + $sql .= "and (enabled = 'true' or enabled is null or enabled = '') "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $device_lines = $prep_statement->fetchAll(PDO::FETCH_NAMED); + //assign the keys array + $view->assign("lines", $device_lines); + //set the variables + if (is_array($device_lines)) { + foreach($device_lines as $row) { + //set the variables + $line_number = $row['line_number']; + $register_expires = $row['register_expires']; + $sip_transport = strtolower($row['sip_transport']); + $sip_port = $row['sip_port']; + + //set defaults + if (strlen($register_expires) == 0) { $register_expires = "120"; } + if (strlen($sip_transport) == 0) { $sip_transport = "tcp"; } + if (strlen($sip_port) == 0) { + if ($line_number == "" || $line_number == "1") { + $sip_port = "5060"; + } + else { + $sip_port = "506".($line_number + 1); + } + } + + //set a lines array index is the line number + $lines[$line_number]['register_expires'] = $register_expires; + $lines[$line_number]['sip_transport'] = strtolower($sip_transport); + $lines[$line_number]['sip_port'] = $sip_port; + $lines[$line_number]['server_address'] = $row["server_address"]; + $lines[$line_number]['outbound_proxy'] = $row["outbound_proxy_primary"]; + $lines[$line_number]['outbound_proxy_primary'] = $row["outbound_proxy_primary"]; + $lines[$line_number]['outbound_proxy_secondary'] = $row["outbound_proxy_secondary"]; + $lines[$line_number]['display_name'] = $row["display_name"]; + $lines[$line_number]['auth_id'] = $row["auth_id"]; + $lines[$line_number]['user_id'] = $row["user_id"]; + $lines[$line_number]['password'] = $row["password"]; + + //assign the variables for line one - short name + if ($line_number == "1") { + $view->assign("server_address", $row["server_address"]); + $view->assign("outbound_proxy", $row["outbound_proxy_primary"]); + $view->assign("outbound_proxy_primary", $row["outbound_proxy_primary"]); + $view->assign("outbound_proxy_secondary", $row["outbound_proxy_secondary"]); + $view->assign("display_name", $row["display_name"]); + $view->assign("auth_id", $row["auth_id"]); + $view->assign("user_id", $row["user_id"]); + $view->assign("user_password", $row["password"]); + $view->assign("sip_transport", $sip_transport); + $view->assign("sip_port", $sip_port); + $view->assign("register_expires", $register_expires); + } + + //assign the variables with the line number as part of the name + $view->assign("server_address_".$line_number, $row["server_address"]); + $view->assign("outbound_proxy_".$line_number, $row["outbound_proxy_primary"]); + $view->assign("outbound_proxy_primary_".$line_number, $row["outbound_proxy_primary"]); + $view->assign("outbound_proxy_secondary_".$line_number, $row["outbound_proxy_secondary"]); + $view->assign("display_name_".$line_number, $row["display_name"]); + $view->assign("auth_id_".$line_number, $row["auth_id"]); + $view->assign("user_id_".$line_number, $row["user_id"]); + $view->assign("user_password_".$line_number, $row["password"]); + $view->assign("sip_transport_".$line_number, $sip_transport); + $view->assign("sip_port_".$line_number, $sip_port); + $view->assign("register_expires_".$line_number, $register_expires); + } + } + unset ($prep_statement); + } + + //get the list of contact directly assigned to the user + if (strlen($device_user_uuid) > 0 and strlen($domain_uuid) > 0) { + //get the contacts assigned to the groups and add to the contacts array + if ($_SESSION['provision']['contact_groups']['boolean'] == "true") { + $this->contact_append($contacts, $line, $domain_uuid, $device_user_uuid, true); + } + + //get the contacts assigned to the user and add to the contacts array + if ($_SESSION['provision']['contact_users']['boolean'] == "true") { + $this->contact_append($contacts, $line, $domain_uuid, $device_user_uuid, false); + } + // Grandstream get the contacts assigned to the user and groups and add to the contacts array + if ($_SESSION['provision']['contact_grandstream']['text'] == "true") { + $this->contact_grandstream($contacts, $line, $domain_uuid, $device_user_uuid); + } + } + + //get the extensions and add them to the contacts array + if (strlen($device_uuid) > 0 and strlen($domain_uuid) > 0 and $_SESSION['provision']['contact_extensions']['boolean'] == "true") { + //get contacts from the database + $sql = "select extension_uuid as contact_uuid, directory_full_name, "; + $sql .= "effective_caller_id_name, effective_caller_id_number, "; + $sql .= "number_alias, extension "; + $sql .= "from v_extensions "; + $sql .= "where domain_uuid = '".$domain_uuid."' "; + $sql .= "and enabled = 'true' "; + $sql .= "order by number_alias, extension asc "; + $prep_statement = $this->db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $extensions = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (is_array($extensions)) { + foreach ($extensions as $row) { + //get the contact_uuid + $uuid = $row['contact_uuid']; + //get the names + if (strlen($row['directory_full_name']) > 0) { + $name_array = explode(" ", $row['directory_full_name']); + } else { + $name_array = explode(" ", $row['effective_caller_id_name']); + } + $contact_name_given = array_shift($name_array); + $contact_name_family = trim(implode(' ', $name_array)); + //get the phone_extension + if (is_numeric($row['extension'])) { + $phone_extension = $row['extension']; + } + else { + $phone_extension = $row['number_alias']; + } + //save the contact array values + $contacts[$uuid]['category'] = 'extensions'; + $contacts[$uuid]['contact_uuid'] = $row['contact_uuid']; + $contacts[$uuid]['contact_category'] = 'extensions'; + $contacts[$uuid]['contact_name_given'] = $contact_name_given; + $contacts[$uuid]['contact_name_family'] = $contact_name_family; + $contacts[$uuid]['phone_extension'] = $phone_extension; + //unset the variables + unset($name_array, $contact_name_given, $contact_name_family, $phone_extension); + } + } + } + } + + //assign the contacts array to the template + if (is_array($contacts)) { + $view->assign("contacts", $contacts); + unset($contacts); + } + + //get the provisioning information from device keys + if (strlen($device_uuid) > 0) { + + //get the device keys array + $sql = "SELECT * FROM v_device_keys "; + $sql .= "WHERE ("; + $sql .= "device_uuid = '".$device_uuid."' "; + if (strlen($device_profile_uuid) > 0) { + $sql .= "or device_profile_uuid = '".$device_profile_uuid."' "; + } + $sql .= ") "; + if (strtolower($device_vendor) == 'escene'){ + $sql .= "AND (lower(device_key_vendor) = 'escene' or lower(device_key_vendor) = 'escene programmable' or device_key_vendor is null) "; + } + else { + $sql .= "AND (lower(device_key_vendor) = '".$device_vendor."' or device_key_vendor is null) "; + } + $sql .= "ORDER BY "; + $sql .= "device_key_vendor ASC, "; + $sql .= "CASE device_key_category "; + $sql .= "WHEN 'line' THEN 1 "; + $sql .= "WHEN 'memory' THEN 2 "; + $sql .= "WHEN 'programmable' THEN 3 "; + $sql .= "WHEN 'expansion' THEN 4 "; + $sql .= "ELSE 100 END, "; + if ($GLOBALS['db_type'] == "mysql") { + $sql .= "device_key_id ASC, "; + } + else { + $sql .= "CAST(device_key_id as numeric) ASC, "; + } + $sql .= "CASE WHEN device_uuid IS NULL THEN 0 ELSE 1 END ASC "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $keys = $prep_statement->fetchAll(PDO::FETCH_NAMED); + + //override profile keys with device keys + if (is_array($keys)) { + foreach($keys as $row) { + //set the variables + $id = $row['device_key_id']; + $category = $row['device_key_category']; + + //build the device keys array + $device_keys[$category][$id] = $row; + if (is_uuid($row['device_profile_uuid'])) { + $device_keys[$category][$id]['device_key_owner'] = "profile"; + } + else { + $device_keys[$category][$id]['device_key_owner'] = "device"; + } + + //kept temporarily for backwards comptability to allow custom templates to be updated + $device_keys[$id] = $row; + if (is_uuid($row['device_profile_uuid'])) { + $device_keys[$id]['device_key_owner'] = "profile"; + } + else { + $device_keys[$id]['device_key_owner'] = "device"; + } + } + } + unset($keys); + } + + //debug information + if ($debug == "array") { + echo "
\n";
+						print_r($device_keys);
+						echo "
\n";
+						exit;
+					}
+
+				//set the variables key and values
+					$x = 1;
+					$variables['domain_name'] = $domain_name;
+					$variables['user_id'] = $lines[$x]['user_id'];
+					$variables['auth_id'] = $lines[$x]['auth_id'];
+					$variables['extension'] = $lines[$x]['extension'];
+					//$variables['password'] = $lines[$x]['password'];
+					$variables['register_expires'] = $lines[$x]['register_expires'];
+					$variables['sip_transport'] = $lines[$x]['sip_transport'];
+					$variables['sip_port'] = $lines[$x]['sip_port'];
+					$variables['server_address'] = $lines[$x]['server_address'];
+					$variables['outbound_proxy'] = $lines[$x]['outbound_proxy_primary'];
+					$variables['outbound_proxy_primary'] = $lines[$x]['outbound_proxy_primary'];
+					$variables['outbound_proxy_secondary'] = $lines[$x]['outbound_proxy_secondary'];
+					$variables['display_name'] = $lines[$x]['display_name'];
+
+				//update the device keys by replacing variables with their values
+					foreach($variables as $name => $value) {
+						if (is_array($device_keys)) {
+							foreach($device_keys as $k => $field) {
+								if (strlen($field['device_key_uuid']) > 0) {
+										$device_keys[$k]['device_key_value'] = str_replace("\${".$name."}", $value, $field['device_key_value']);
+										$device_keys[$k]['device_key_extension'] = str_replace("\${".$name."}", $value, $field['device_key_extension']);
+										$device_keys[$k]['device_key_label'] = str_replace("\${".$name."}", $value, $field['device_key_label']);
+								}
+								else {
+									if (is_array($field)) {
+										foreach($field as $key => $row) {
+											$device_keys[$k][$key]['device_key_value'] = str_replace("\${".$name."}", $value, $row['device_key_value']);
+											$device_keys[$k][$key]['device_key_extension'] = str_replace("\${".$name."}", $value, $row['device_key_extension']);
+											$device_keys[$k][$key]['device_key_label'] = str_replace("\${".$name."}", $value, $row['device_key_label']);
+										}
+									}
+								}
+							}
+						}
+					}
+
+				//assign the keys array
+					$view->assign("keys", $device_keys);
+
+				//set the variables
+					$types = array("line", "memory", "expansion", "programmable");
+					foreach ($types as $type) {
+						if (is_array($device_keys[$type])) {
+							foreach($device_keys[$type] as $row) {
+								//set the variables
+									$device_key_category = $row['device_key_category'];
+									$device_key_id = $row['device_key_id']; //1
+									$device_key_type = $row['device_key_type']; //line
+									$device_key_line = $row['device_key_line'];
+									$device_key_value = $row['device_key_value']; //1
+									$device_key_extension = $row['device_key_extension'];
+									$device_key_label = $row['device_key_label']; //label
+
+								//add general variables
+									$device_key_value = str_replace("\${domain_name}", $domain_name, $device_key_value);
+									$device_key_extension = str_replace("\${domain_name}", $domain_name, $device_key_extension);
+									$device_key_label = str_replace("\${domain_name}", $domain_name, $device_key_label);
+
+								//grandstream modes are different based on the category
+									if ($device_vendor == "grandstream") {
+										if ($device_key_category == "line") {
+											switch ($device_key_type) {
+												case "line": $device_key_type  = "0"; break;
+												case "shared line": $device_key_type  = "1"; break;
+												case "speed dial": $device_key_type  = "10"; break;
+												case "blf": $device_key_type  = "11"; break;
+												case "presence watcher": $device_key_type  = "12"; break;
+												case "eventlist blf": $device_key_type  = "13"; break;
+												case "speed dial active": $device_key_type  = "14"; break;
+												case "dial dtmf": $device_key_type  = "15"; break;
+												case "voicemail": $device_key_type  = "16"; break;
+												case "call return": $device_key_type  = "17"; break;
+												case "transfer": $device_key_type  = "18"; break;
+												case "call park": $device_key_type  = "19"; break;
+												case "intercom": $device_key_type  = "20"; break;
+												case "ldap search": $device_key_type  = "21"; break;
+											}
+										}
+										if ($device_key_category == "memory" || $device_key_category == "expansion") {
+											switch ($device_key_type) {
+												case "speed dial": $device_key_type  = "0"; break;
+												case "blf": $device_key_type  = "1"; break;
+												case "presence watcher": $device_key_type  = "2"; break;
+												case "eventlist blf": $device_key_type  = "3"; break;
+												case "speed dial active": $device_key_type  = "4"; break;
+												case "dial dtmf": $device_key_type  = "5"; break;
+												case "voicemail": $device_key_type  = "6"; break;
+												case "call return": $device_key_type  = "7"; break;
+												case "transfer": $device_key_type  = "8"; break;
+												case "call park": $device_key_type  = "9"; break;
+												case "intercom": $device_key_type  = "10"; break;
+												case "ldap search": $device_key_type  = "11"; break;
+											}
+										}
+									}
+
+								//assign the variables
+									if (strlen($device_key_category) == 0) {
+										$view->assign("key_id_".$device_key_id, $device_key_id);
+										$view->assign("key_type_".$device_key_id, $device_key_type);
+										$view->assign("key_line_".$device_key_id, $device_key_line);
+										$view->assign("key_value_".$device_key_id, $device_key_value);
+										$view->assign("key_extension_".$device_key_id, $device_key_extension);
+										$view->assign("key_label_".$device_key_id, $device_key_label);
+									}
+									else {
+										$view->assign($device_key_category."_key_id_".$device_key_id, $device_key_id);
+										$view->assign($device_key_category."_key_type_".$device_key_id, $device_key_type);
+										$view->assign($device_key_category."_key_line_".$device_key_id, $device_key_line);
+										$view->assign($device_key_category."_key_value_".$device_key_id, $device_key_value);
+										$view->assign($device_key_category."_key_extension_".$device_key_id, $device_key_extension);
+										$view->assign($device_key_category."_key_label_".$device_key_id, $device_key_label);
+									}
+							}
+						}
+					}
+					unset ($prep_statement);
+
+				//set the mac address in the correct format
+					$mac = $this->format_mac($mac, $device_vendor);
+
+				//replace the variables in the template in the future loop through all the line numbers to do a replace for each possible line number
+					$view->assign("mac" , $mac);
+					$view->assign("label", $device_label);
+					$view->assign("device_label", $device_label);
+					$view->assign("firmware_version", $device_firmware_version);
+					$view->assign("domain_name", $domain_name);
+					$view->assign("project_path", PROJECT_PATH);
+					$view->assign("server1_address", $server1_address);
+					$view->assign("proxy1_address", $proxy1_address);
+					$view->assign("user_id",$user_id);
+					$view->assign("password",$password);
+					$view->assign("template",$device_template);
+
+				// personal ldap password
+					global $laddr_salt;
+					if (isset($device_user_uuid)){
+						$sql = "SELECT contact_uuid FROM v_users WHERE user_uuid='".$device_user_uuid."'";
+						$prep_statement = $this->db->prepare(check_sql($sql));
+						$prep_statement->execute();
+						$c_uuid = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+						$view->assign("ldap_username","uid=".$c_uuid[0]['contact_uuid'].",".$_SESSION['provision']['gs_ldap_user_base']['text']);
+						$view->assign("ldap_password",md5($laddr_salt.$device_user_uuid));
+					}
+
+
+				//get the time zone
+					$time_zone_name = $_SESSION['domain']['time_zone']['name'];
+					if (strlen($time_zone_name) > 0) {
+						$time_zone_offset_raw = get_time_zone_offset($time_zone_name)/3600;
+						$time_zone_offset_hours = floor($time_zone_offset_raw);
+						$time_zone_offset_minutes = ($time_zone_offset_raw - $time_zone_offset_hours) * 60;
+						$time_zone_offset_minutes = number_pad($time_zone_offset_minutes, 2);
+						if ($time_zone_offset_raw > 0) {
+							$time_zone_offset_hours = number_pad($time_zone_offset_hours, 2);
+							$time_zone_offset_hours = "+".$time_zone_offset_hours;
+						}
+						else {
+							$time_zone_offset_hours = str_replace("-", "", $time_zone_offset_hours);
+							$time_zone_offset_hours = "-".number_pad($time_zone_offset_hours, 2);
+						}
+						$time_zone_offset = $time_zone_offset_hours.":".$time_zone_offset_minutes;
+						if (!isset($provision["time_zone_offset"])) {
+							$provision["time_zone_offset"] = $time_zone_offset;
+						}
+					}
+
+				//set the daylight savings time
+					if (!isset($provision["yealink_time_zone_start_time"])) {
+						$provision["yealink_time_zone_start_time"] = $provision["daylight_savings_start_month"]."/".$provision["daylight_savings_start_day"]."/".$provision["daylight_savings_start_time"];
+					}
+					if (!isset($provision["yealink_time_zone_end_time"])) {
+						$provision["yealink_time_zone_end_time"] = $provision["daylight_savings_stop_month"]."/".$provision["daylight_savings_stop_day"]."/".$provision["daylight_savings_stop_time"];
+					}
+
+				//replace the dynamic provision variables that are defined in default, domain, and device settings
+					if (is_array($provision)) {
+						foreach($provision as $key=>$val) {
+							$view->assign($key, $val);
+						}
+					}
+
+				//set the template directory
+					if (strlen($provision["template_dir"]) > 0) {
+						$template_dir = $provision["template_dir"];
+					}
+
+				//if the domain name directory exists then only use templates from it
+					if (is_dir($template_dir.'/'.$domain_name)) {
+						$device_template = $domain_name.'/'.$device_template;
+					}
+
+				//if $file is not provided then look for a default file that exists
+					if (strlen($file) == 0) {
+						if (file_exists($template_dir."/".$device_template ."/{\$mac}")) {
+							$file = "{\$mac}";
+						}
+						elseif (file_exists($template_dir."/".$device_template ."/{\$mac}.xml")) {
+							$file = "{\$mac}.xml";
+						}
+						elseif (file_exists($template_dir."/".$device_template ."/{\$mac}.cfg")) {
+							$file = "{\$mac}.cfg";
+						}
+						else {
+							echo "file not found";
+							exit;
+						}
+					}
+					else {
+						//make sure the file exists
+						if (!file_exists($template_dir."/".$device_template ."/".$file)) {
+							echo "file not found ".$template_dir."/".$device_template ."/".$file;
+							if ($_SESSION['provision']['debug']['boolean'] == 'true'){
+								echo ":$template_dir/$device_template/$file
"; + echo "template_dir: $template_dir
"; + echo "device_template: $device_template
"; + echo "file: $file"; + } + exit; + } + } + + //output template to string for header processing + $file_contents = $view->render($file); + + //log file for testing + if ($_SESSION['provision']['debug']['boolean'] == 'true'){ + $tmp_file = "/tmp/provisioning_log.txt"; + $fh = fopen($tmp_file, 'w') or die("can't open file"); + $tmp_string = $mac."\n"; + fwrite($fh, $tmp_string); + fclose($fh); + } + + $this->file = $file; + //returned the rendered template + return $file_contents; + + } //end render function + + function write() { + //build the provision array + $provision = Array(); + if (is_array($_SESSION['provision'])) { + foreach($_SESSION['provision'] as $key=>$val) { + if (strlen($val['var']) > 0) { $value = $val['var']; } + if (strlen($val['text']) > 0) { $value = $val['text']; } + if (strlen($val['boolean']) > 0) { $value = $val['boolean']; } + if (strlen($val['numeric']) > 0) { $value = $val['numeric']; } + if (strlen($value) > 0) { $provision[$key] = $value; } + unset($value); + } + } + + //check either we have destination path to write files + if(strlen($provision["path"]) == 0){ + return; + } + + //get the devices from database + $sql = "select * from v_devices "; + //$sql .= "where domain_uuid = '".$this->domain_uuid."' "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement); + + //process each device + if (is_array($result)) foreach ($result as &$row) { + //get the values from the database and set as variables + $domain_uuid = $row["domain_uuid"]; + $device_uuid = $row["device_uuid"]; + $device_mac_address = $row["device_mac_address"]; + $device_label = $row["device_label"]; + $device_vendor = strtolower($row["device_vendor"]); + $device_model = $row["device_model"]; + $device_firmware_version = $row["device_firmware_version"]; + $device_enabled = $row["device_enabled"]; + $device_template = $row["device_template"]; + $device_username = $row["device_username"]; + $device_password = $row["device_password"]; + $device_description = $row["device_description"]; + + clearstatcache(); + + //loop through the provision template directory + $dir_array = array(); + if (strlen($device_template) > 0) { + $template_path = path_join($this->template_dir, $device_template); + $dir_list = opendir($template_path); + if ($dir_list) { + $x = 0; + while (false !== ($file = readdir($dir_list))) { + $ignore = $file == "." || $file == ".." || substr($file, -3) == ".db" || + substr($file, -4) == ".svn" || substr($file, -4) == ".git"; + if (!$ignore) { + $dir_array[] = path_join($template_path, $file); + if ($x > 1000) { break; }; + $x++; + } + } + closedir($dir_list); + unset($x, $file); + } + unset($dir_list, $template_path); + } + + //loop through the provision templates + if (is_array($dir_array)) foreach ($dir_array as &$template_path) { + if (is_dir($template_path)) continue; + if (!file_exists($template_path)) continue; + + //template file name + $file_name = basename($template_path); + + //configure device object + $this->domain_uuid = $domain_uuid; + $this->mac = $device_mac_address; + $this->file = $file_name; + + //format the mac address + $mac = $this->format_mac($device_mac_address, $device_vendor); + + //replace {$mac} in the file name + $file_name = str_replace("{\$mac}", $mac, $file_name); + + //render and write configuration to file + $provision_dir_array = explode(";", $provision["path"]); + if (is_array($provision_dir_array)) foreach($provision_dir_array as $directory) { + //destinatino file path + $dest_path = path_join($directory, $file_name); + + if ($device_enabled == 'true'){ + //output template to string for header processing + $file_contents = $this->render(); + + //write the file + mkdir($directory,0777,true); + $fh = fopen($dest_path,"w") or die("Unable to write to $directory for provisioning. Make sure the path exists and permissons are set correctly."); + fwrite($fh, $file_contents); + fclose($fh); + } + else{ // device disabled + //remove only files with `{$mac}` name + if(strpos($template_path, '{$mac}') !== false){ + unlink($dest_path); + } + } + + unset($dest_path); + } + //unset variables + unset($file_name, $provision_dir_array); + } //end for each + + //unset variables + unset($dir_array); + } + } //end write function + + } //end provision class + +?> diff --git a/app/scripts/resources/classes/scripts.php b/app/scripts/resources/classes/scripts.php index 3d2cb6fc72..2abf452629 100644 --- a/app/scripts/resources/classes/scripts.php +++ b/app/scripts/resources/classes/scripts.php @@ -1,341 +1,341 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - - -/** - * scripts class provides methods for creating the config.lua and copying switch scripts - * - * @method string correct_path - * @method string copy_files - * @method string write_config - */ -if (!class_exists('scripts')) { - class scripts { - - public $db; - public $db_type; - public $db_name; - public $db_host; - public $db_port; - public $db_path; - public $db_username; - public $db_password; - public $dsn_name; - public $dsn_username; - public $dsn_password; - - /** - * Called when the object is created - */ - public function __construct() { - //connect to the database if not connected - require_once "resources/classes/database.php"; - $database = new database; - $database->connect(); - $this->db = $database->db; - $this->db_type = $database->type; - $this->db_name = $database->db_name; - $this->db_host = $database->host; - $this->db_port = $database->port; - $this->db_path = $database->path; - $this->db_username = $database->username; - $this->db_password = $database->password; - } - - /** - * Called when there are no references to a particular object - * unset the variables used in the class - */ - public function __destruct() { - foreach ($this as $key => $value) { - unset($this->$key); - } - } - - /** - * Corrects the path for specifically for windows - */ - private function correct_path($path) { - global $IS_WINDOWS; - if ($IS_WINDOWS == null) { - if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; } - } - if ($IS_WINDOWS) { - return str_replace('\\', '/', $path); - } - return $path; - } - - /** - * Copy the switch scripts from the web directory to the switch directory - */ - public function copy_files() { - if (is_array($_SESSION['switch']['scripts'])) { - $dst_dir = $_SESSION['switch']['scripts']['dir']; - if (file_exists($dst_dir)) { - //get the source directory - if (file_exists('/usr/share/examples/fusionpbx/scripts')){ - $src_dir = '/usr/share/examples/fusionpbx/scripts'; - } - else { - $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts'; - } - if (is_readable($dst_dir)) { - recursive_copy($src_dir,$dst_dir); - unset($src_dir); - - // Copy the app/*/resource/install/scripts - $app_scripts = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'app/*/resource/install/scripts'); - foreach ($app_scripts as $app_script){ - recursive_copy($app_script, $dst_dir); - } - unset($app_scripts); - }else{ - throw new Exception("Cannot read from '$src_dir' to get the scripts"); - } - chmod($dst_dir, 0775); - unset($dst_dir); - } - } - } - - /** - * Writes the config.lua - */ - public function write_config() { - if (is_array($_SESSION['switch']['scripts'])) { - - //replace the backslash with a forward slash - $this->db_path = str_replace("\\", "/", $this->db_path); - - //get the odbc information - $sql = "select count(*) as num_rows from v_databases "; - $sql .= "where database_driver = 'odbc' "; - $prep_statement = $this->db->prepare($sql); - if ($prep_statement) { - $prep_statement->execute(); - $row = $prep_statement->fetch(PDO::FETCH_ASSOC); - unset($prep_statement); - if ($row['num_rows'] > 0) { - $odbc_num_rows = $row['num_rows']; - - $sql = "select * from v_databases "; - $sql .= "where database_driver = 'odbc' "; - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); - if (is_array($result)) { - foreach ($result as &$row) { - $this->dsn_name = $row["database_name"]; - $this->dsn_username = $row["database_username"]; - $this->dsn_password = $row["database_password"]; - break; //limit to 1 row - } - unset ($prep_statement); - } - } - else { - $odbc_num_rows = '0'; - } - } - - //get the recordings directory - if (is_array($_SESSION['switch']['recordings'])) { - $recordings_dir = $_SESSION['switch']['recordings']['dir']; - } - - //get the http_protocol - if (!isset($_SERVER['HTTP_PROTOCOL'])) { - $_SERVER['HTTP_PROTOCOL'] = 'http'; - if (isset($_SERVER['REQUEST_SCHEME'])) { $_SERVER['HTTP_PROTOCOL'] = $_SERVER['REQUEST_SCHEME']; } - if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } - if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } - } - - //find the location to write the config.lua - if (is_dir("/etc/fusionpbx")){ - $config = "/etc/fusionpbx/config.lua"; - } elseif (is_dir("/usr/local/etc/fusionpbx")){ - $config = "/usr/local/etc/fusionpbx/config.lua"; - } - else { - $config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua"; - } - $fout = fopen($config,"w"); - if(!$fout){ - return; - } - - //make the config.lua - $tmp = "\n"; - $tmp .= "--set the variables\n"; - if (strlen($_SESSION['switch']['conf']['dir']) > 0) { - $tmp .= $this->correct_path(" conf_dir = [[".$_SESSION['switch']['conf']['dir']."]];\n"); - } - if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { - $tmp .= $this->correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n"); - } - if (strlen($_SESSION['switch']['db']['dir']) > 0) { - $tmp .= $this->correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n"); - } - if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { - $tmp .= $this->correct_path(" recordings_dir = [[".$recordings_dir."]];\n"); - } - if (strlen($_SESSION['switch']['storage']['dir']) > 0) { - $tmp .= $this->correct_path(" storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n"); - } - if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) { - $tmp .= $this->correct_path(" voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n"); - } - if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { - $tmp .= $this->correct_path(" scripts_dir = [[".$_SESSION['switch']['scripts']['dir']."]];\n"); - } - $tmp .= $this->correct_path(" php_dir = [[".PHP_BINDIR."]];\n"); - if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") { - $tmp .= " php_bin = \"php.exe\";\n"; - } - elseif (file_exists(PHP_BINDIR."/php5")) { - $tmp .= " php_bin = \"php5\";\n"; - } - else { - $tmp .= " php_bin = \"php\";\n"; - } - $tmp .= $this->correct_path(" document_root = [[".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."]];\n"); - $tmp .= $this->correct_path(" project_path = [[".PROJECT_PATH."]];\n"); - $tmp .= $this->correct_path(" http_protocol = [[".$_SERVER['HTTP_PROTOCOL']."]];\n"); - $tmp .= "\n"; - - $tmp .= "--store settings in memcache\n"; - $tmp .= " settings_in_cache = false;\n"; - $tmp .= "\n"; - - if ((strlen($this->db_type) > 0) || (strlen($this->dsn_name) > 0)) { - $tmp .= "--database information\n"; - $tmp .= " database = {}\n"; - $tmp .= " database.type = \"".$this->db_type."\";\n"; - $tmp .= " database.name = \"".$this->db_name."\";\n"; - $tmp .= $this->correct_path(" database.path = [[".$this->db_path."]];\n"); - - if (strlen($this->dsn_name) > 0) { - $tmp .= " database.system = \"odbc://".$this->dsn_name.":".$this->dsn_username.":".$this->dsn_password."\";\n"; - $tmp .= " database.switch = \"odbc://freeswitch:".$this->dsn_username.":".$this->dsn_password."\";\n"; - } - elseif ($this->db_type == "pgsql") { - if ($this->db_host == "localhost") { $this->db_host = "127.0.0.1"; } - $tmp .= " database.system = \"pgsql://hostaddr=".$this->db_host." port=".$this->db_port." dbname=".$this->db_name." user=".$this->db_username." password=".$this->db_password." options='' application_name='".$this->db_name."'\";\n"; - $tmp .= " database.switch = \"pgsql://hostaddr=".$this->db_host." port=".$this->db_port." dbname=freeswitch user=".$this->db_username." password=".$this->db_password." options='' application_name='freeswitch'\";\n"; - } - elseif ($this->db_type == "sqlite") { - $tmp .= " database.system = \"sqlite://".$this->db_path."/".$this->db_name."\";\n"; - $tmp .= " database.switch = \"sqlite://".$_SESSION['switch']['db']['dir']."\";\n"; - } - elseif ($this->db_type == "mysql") { - $tmp .= " database.system = \"\";\n"; - $tmp .= " database.switch = \"\";\n"; - } - $tmp .= "\n"; - $tmp .= " database.backend = {}\n"; - $tmp .= " database.backend.base64 = 'luasql'\n"; - $tmp .= "\n"; - } - $tmp .= "--set defaults\n"; - $tmp .= " expire = {}\n"; - $tmp .= " expire.default = \"3600\";\n"; - $tmp .= " expire.directory = \"3600\";\n"; - $tmp .= " expire.dialplan = \"3600\";\n"; - $tmp .= " expire.languages = \"3600\";\n"; - $tmp .= " expire.sofia = \"3600\";\n"; - $tmp .= " expire.acl = \"3600\";\n"; - $tmp .= " expire.ivr = \"3600\";\n"; - $tmp .= "\n"; - $tmp .= "--set xml_handler\n"; - $tmp .= " xml_handler = {}\n"; - $tmp .= " xml_handler.fs_path = false;\n"; - $tmp .= " xml_handler.reg_as_number_alias = false;\n"; - $tmp .= " xml_handler.number_as_presence_id = true;\n"; - $tmp .= "\n"; - $tmp .= "--set settings\n"; - $tmp .= " settings = {}\n"; - $tmp .= " settings.recordings = {}\n"; - $tmp .= " settings.voicemail = {}\n"; - $tmp .= " settings.fax = {}\n"; - if (isset($_SESSION['recordings']['storage_type']['text'])) { - $tmp .= " settings.recordings.storage_type = \"".$_SESSION['recordings']['storage_type']['text']."\";\n"; - } - else { - $tmp .= " settings.recordings.storage_type = \"\";\n"; - } - if (isset($_SESSION['voicemail']['storage_type']['text'])) { - $tmp .= " settings.voicemail.storage_type = \"".$_SESSION['voicemail']['storage_type']['text']."\";\n"; - } - else { - $tmp .= " settings.voicemail.storage_type = \"\";\n"; - } - if (isset($_SESSION['fax']['storage_type']['text'])) { - $tmp .= " settings.fax.storage_type = \"".$_SESSION['fax']['storage_type']['text']."\";\n"; - } - else { - $tmp .= " settings.fax.storage_type = \"\";\n"; - } - $tmp .= "\n"; - $tmp .= "--set the debug options\n"; - $tmp .= " debug.params = false;\n"; - $tmp .= " debug.sql = false;\n"; - $tmp .= " debug.xml_request = false;\n"; - $tmp .= " debug.xml_string = false;\n"; - $tmp .= " debug.cache = false;\n"; - $tmp .= "\n"; - $tmp .= "--additional info\n"; - $tmp .= " domain_count = ".count($_SESSION["domains"]).";\n"; - $tmp .= $this->correct_path(" temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n"); - if (isset($_SESSION['domain']['dial_string']['text'])) { - $tmp .= " dial_string = \"".$_SESSION['domain']['dial_string']['text']."\";\n"; - } - $tmp .= "\n"; - $tmp .= "--include local.lua\n"; - $tmp .= " require(\"resources.functions.file_exists\");\n"; - $tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n"; - $tmp .= " dofile(\"/etc/fusionpbx/local.lua\");\n"; - $tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n"; - $tmp .= " dofile(\"/usr/local/etc/fusionpbx/local.lua\");\n"; - $tmp .= " elseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n"; - $tmp .= " require(\"resources.local\");\n"; - $tmp .= " end\n"; - fwrite($fout, $tmp); - unset($tmp); - fclose($fout); - } - } //end config_lua - } //end scripts class -} -/* -//example use - -//update config.lua - $obj = new scripts; - $obj->write_config(); -*/ -?> + + Portions created by the Initial Developer are Copyright (C) 2008-2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + + +/** + * scripts class provides methods for creating the config.lua and copying switch scripts + * + * @method string correct_path + * @method string copy_files + * @method string write_config + */ +if (!class_exists('scripts')) { + class scripts { + + public $db; + public $db_type; + public $db_name; + public $db_host; + public $db_port; + public $db_path; + public $db_username; + public $db_password; + public $dsn_name; + public $dsn_username; + public $dsn_password; + + /** + * Called when the object is created + */ + public function __construct() { + //connect to the database if not connected + require_once "resources/classes/database.php"; + $database = new database; + $database->connect(); + $this->db = $database->db; + $this->db_type = $database->type; + $this->db_name = $database->db_name; + $this->db_host = $database->host; + $this->db_port = $database->port; + $this->db_path = $database->path; + $this->db_username = $database->username; + $this->db_password = $database->password; + } + + /** + * Called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + /** + * Corrects the path for specifically for windows + */ + private function correct_path($path) { + global $IS_WINDOWS; + if ($IS_WINDOWS == null) { + if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; } + } + if ($IS_WINDOWS) { + return str_replace('\\', '/', $path); + } + return $path; + } + + /** + * Copy the switch scripts from the web directory to the switch directory + */ + public function copy_files() { + if (is_array($_SESSION['switch']['scripts'])) { + $dst_dir = $_SESSION['switch']['scripts']['dir']; + if (file_exists($dst_dir)) { + //get the source directory + if (file_exists('/usr/share/examples/fusionpbx/scripts')){ + $src_dir = '/usr/share/examples/fusionpbx/scripts'; + } + else { + $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts'; + } + if (is_readable($dst_dir)) { + recursive_copy($src_dir,$dst_dir); + unset($src_dir); + + // Copy the app/*/resource/install/scripts + $app_scripts = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'app/*/resource/install/scripts'); + foreach ($app_scripts as $app_script){ + recursive_copy($app_script, $dst_dir); + } + unset($app_scripts); + }else{ + throw new Exception("Cannot read from '$src_dir' to get the scripts"); + } + chmod($dst_dir, 0775); + unset($dst_dir); + } + } + } + + /** + * Writes the config.lua + */ + public function write_config() { + if (is_array($_SESSION['switch']['scripts'])) { + + //replace the backslash with a forward slash + $this->db_path = str_replace("\\", "/", $this->db_path); + + //get the odbc information + $sql = "select count(*) as num_rows from v_databases "; + $sql .= "where database_driver = 'odbc' "; + $prep_statement = $this->db->prepare($sql); + if ($prep_statement) { + $prep_statement->execute(); + $row = $prep_statement->fetch(PDO::FETCH_ASSOC); + unset($prep_statement); + if ($row['num_rows'] > 0) { + $odbc_num_rows = $row['num_rows']; + + $sql = "select * from v_databases "; + $sql .= "where database_driver = 'odbc' "; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + if (is_array($result)) { + foreach ($result as &$row) { + $this->dsn_name = $row["database_name"]; + $this->dsn_username = $row["database_username"]; + $this->dsn_password = $row["database_password"]; + break; //limit to 1 row + } + unset ($prep_statement); + } + } + else { + $odbc_num_rows = '0'; + } + } + + //get the recordings directory + if (is_array($_SESSION['switch']['recordings'])) { + $recordings_dir = $_SESSION['switch']['recordings']['dir']; + } + + //get the http_protocol + if (!isset($_SERVER['HTTP_PROTOCOL'])) { + $_SERVER['HTTP_PROTOCOL'] = 'http'; + if (isset($_SERVER['REQUEST_SCHEME'])) { $_SERVER['HTTP_PROTOCOL'] = $_SERVER['REQUEST_SCHEME']; } + if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } + if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } + } + + //find the location to write the config.lua + if (is_dir("/etc/fusionpbx")){ + $config = "/etc/fusionpbx/config.lua"; + } elseif (is_dir("/usr/local/etc/fusionpbx")){ + $config = "/usr/local/etc/fusionpbx/config.lua"; + } + else { + $config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua"; + } + $fout = fopen($config,"w"); + if(!$fout){ + return; + } + + //make the config.lua + $tmp = "\n"; + $tmp .= "--set the variables\n"; + if (strlen($_SESSION['switch']['conf']['dir']) > 0) { + $tmp .= $this->correct_path(" conf_dir = [[".$_SESSION['switch']['conf']['dir']."]];\n"); + } + if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { + $tmp .= $this->correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n"); + } + if (strlen($_SESSION['switch']['db']['dir']) > 0) { + $tmp .= $this->correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n"); + } + if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { + $tmp .= $this->correct_path(" recordings_dir = [[".$recordings_dir."]];\n"); + } + if (strlen($_SESSION['switch']['storage']['dir']) > 0) { + $tmp .= $this->correct_path(" storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n"); + } + if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) { + $tmp .= $this->correct_path(" voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n"); + } + if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { + $tmp .= $this->correct_path(" scripts_dir = [[".$_SESSION['switch']['scripts']['dir']."]];\n"); + } + $tmp .= $this->correct_path(" php_dir = [[".PHP_BINDIR."]];\n"); + if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") { + $tmp .= " php_bin = \"php.exe\";\n"; + } + elseif (file_exists(PHP_BINDIR."/php5")) { + $tmp .= " php_bin = \"php5\";\n"; + } + else { + $tmp .= " php_bin = \"php\";\n"; + } + $tmp .= $this->correct_path(" document_root = [[".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."]];\n"); + $tmp .= $this->correct_path(" project_path = [[".PROJECT_PATH."]];\n"); + $tmp .= $this->correct_path(" http_protocol = [[".$_SERVER['HTTP_PROTOCOL']."]];\n"); + $tmp .= "\n"; + + $tmp .= "--store settings in memcache\n"; + $tmp .= " settings_in_cache = false;\n"; + $tmp .= "\n"; + + if ((strlen($this->db_type) > 0) || (strlen($this->dsn_name) > 0)) { + $tmp .= "--database information\n"; + $tmp .= " database = {}\n"; + $tmp .= " database.type = \"".$this->db_type."\";\n"; + $tmp .= " database.name = \"".$this->db_name."\";\n"; + $tmp .= $this->correct_path(" database.path = [[".$this->db_path."]];\n"); + + if (strlen($this->dsn_name) > 0) { + $tmp .= " database.system = \"odbc://".$this->dsn_name.":".$this->dsn_username.":".$this->dsn_password."\";\n"; + $tmp .= " database.switch = \"odbc://freeswitch:".$this->dsn_username.":".$this->dsn_password."\";\n"; + } + elseif ($this->db_type == "pgsql") { + if ($this->db_host == "localhost") { $this->db_host = "127.0.0.1"; } + $tmp .= " database.system = \"pgsql://hostaddr=".$this->db_host." port=".$this->db_port." dbname=".$this->db_name." user=".$this->db_username." password=".$this->db_password." options='' application_name='".$this->db_name."'\";\n"; + $tmp .= " database.switch = \"pgsql://hostaddr=".$this->db_host." port=".$this->db_port." dbname=freeswitch user=".$this->db_username." password=".$this->db_password." options='' application_name='freeswitch'\";\n"; + } + elseif ($this->db_type == "sqlite") { + $tmp .= " database.system = \"sqlite://".$this->db_path."/".$this->db_name."\";\n"; + $tmp .= " database.switch = \"sqlite://".$_SESSION['switch']['db']['dir']."\";\n"; + } + elseif ($this->db_type == "mysql") { + $tmp .= " database.system = \"\";\n"; + $tmp .= " database.switch = \"\";\n"; + } + $tmp .= "\n"; + $tmp .= " database.backend = {}\n"; + $tmp .= " database.backend.base64 = 'luasql'\n"; + $tmp .= "\n"; + } + $tmp .= "--set defaults\n"; + $tmp .= " expire = {}\n"; + $tmp .= " expire.default = \"3600\";\n"; + $tmp .= " expire.directory = \"3600\";\n"; + $tmp .= " expire.dialplan = \"3600\";\n"; + $tmp .= " expire.languages = \"3600\";\n"; + $tmp .= " expire.sofia = \"3600\";\n"; + $tmp .= " expire.acl = \"3600\";\n"; + $tmp .= " expire.ivr = \"3600\";\n"; + $tmp .= "\n"; + $tmp .= "--set xml_handler\n"; + $tmp .= " xml_handler = {}\n"; + $tmp .= " xml_handler.fs_path = false;\n"; + $tmp .= " xml_handler.reg_as_number_alias = false;\n"; + $tmp .= " xml_handler.number_as_presence_id = true;\n"; + $tmp .= "\n"; + $tmp .= "--set settings\n"; + $tmp .= " settings = {}\n"; + $tmp .= " settings.recordings = {}\n"; + $tmp .= " settings.voicemail = {}\n"; + $tmp .= " settings.fax = {}\n"; + if (isset($_SESSION['recordings']['storage_type']['text'])) { + $tmp .= " settings.recordings.storage_type = \"".$_SESSION['recordings']['storage_type']['text']."\";\n"; + } + else { + $tmp .= " settings.recordings.storage_type = \"\";\n"; + } + if (isset($_SESSION['voicemail']['storage_type']['text'])) { + $tmp .= " settings.voicemail.storage_type = \"".$_SESSION['voicemail']['storage_type']['text']."\";\n"; + } + else { + $tmp .= " settings.voicemail.storage_type = \"\";\n"; + } + if (isset($_SESSION['fax']['storage_type']['text'])) { + $tmp .= " settings.fax.storage_type = \"".$_SESSION['fax']['storage_type']['text']."\";\n"; + } + else { + $tmp .= " settings.fax.storage_type = \"\";\n"; + } + $tmp .= "\n"; + $tmp .= "--set the debug options\n"; + $tmp .= " debug.params = false;\n"; + $tmp .= " debug.sql = false;\n"; + $tmp .= " debug.xml_request = false;\n"; + $tmp .= " debug.xml_string = false;\n"; + $tmp .= " debug.cache = false;\n"; + $tmp .= "\n"; + $tmp .= "--additional info\n"; + $tmp .= " domain_count = ".count($_SESSION["domains"]).";\n"; + $tmp .= $this->correct_path(" temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n"); + if (isset($_SESSION['domain']['dial_string']['text'])) { + $tmp .= " dial_string = \"".$_SESSION['domain']['dial_string']['text']."\";\n"; + } + $tmp .= "\n"; + $tmp .= "--include local.lua\n"; + $tmp .= " require(\"resources.functions.file_exists\");\n"; + $tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n"; + $tmp .= " dofile(\"/etc/fusionpbx/local.lua\");\n"; + $tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n"; + $tmp .= " dofile(\"/usr/local/etc/fusionpbx/local.lua\");\n"; + $tmp .= " elseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n"; + $tmp .= " require(\"resources.local\");\n"; + $tmp .= " end\n"; + fwrite($fout, $tmp); + unset($tmp); + fclose($fout); + } + } //end config_lua + } //end scripts class +} +/* +//example use + +//update config.lua + $obj = new scripts; + $obj->write_config(); +*/ +?> diff --git a/app/xml_cdr/resources/classes/xml_cdr.php b/app/xml_cdr/resources/classes/xml_cdr.php index 845149275e..78fb767347 100644 --- a/app/xml_cdr/resources/classes/xml_cdr.php +++ b/app/xml_cdr/resources/classes/xml_cdr.php @@ -1,915 +1,915 @@ - - Portions created by the Initial Developer are Copyright (C) 2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - - -/** - * xml_cdr class provides methods for adding cdr records to the database - * - * @method boolean add - */ -if (!class_exists('xml_cdr')) { - class xml_cdr { - - //define variables - public $db; - public $array; - public $debug; - public $fields; - - //user summary - public $domain_uuid; - public $quick_select; - public $start_stamp_begin; - public $start_stamp_end; - public $include_internal; - public $extensions; - - /** - * Called when the object is created - */ - public function __construct() { - //connect to the database if not connected - if (!$this->db) { - require_once "resources/classes/database.php"; - $database = new database; - $database->connect(); - $this->db = $database->db; - } - } - - /** - * Called when there are no references to a particular object - * unset the variables used in the class - */ - public function __destruct() { - if (isset($this)) foreach ($this as $key => $value) { - unset($this->$key); - } - } - - - /** - * cdr process logging - */ - public function log($message) { - //save to file system (alternative to a syslog server) - $fp = fopen($_SESSION['server']['temp']['dir'].'/xml_cdr.log', 'a+'); - if (!$fp) { - return; - } - fwrite($fp, $message); - fclose($fp); - } - - /** - * cdr fields in the database schema - */ - public function fields() { - - $this->fields[] = "uuid"; - $this->fields[] = "domain_uuid"; - $this->fields[] = "extension_uuid"; - $this->fields[] = "domain_name"; - $this->fields[] = "accountcode"; - $this->fields[] = "direction"; - $this->fields[] = "default_language"; - $this->fields[] = "context"; - $this->fields[] = "xml"; - $this->fields[] = "json"; - $this->fields[] = "caller_id_name"; - $this->fields[] = "caller_id_number"; - $this->fields[] = "caller_destination"; - $this->fields[] = "destination_number"; - $this->fields[] = "source_number"; - $this->fields[] = "start_epoch"; - $this->fields[] = "start_stamp"; - $this->fields[] = "answer_stamp"; - $this->fields[] = "answer_epoch"; - $this->fields[] = "end_epoch"; - $this->fields[] = "end_stamp"; - $this->fields[] = "duration"; - $this->fields[] = "mduration"; - $this->fields[] = "billsec"; - $this->fields[] = "billmsec"; - $this->fields[] = "bridge_uuid"; - $this->fields[] = "read_codec"; - $this->fields[] = "read_rate"; - $this->fields[] = "write_codec"; - $this->fields[] = "write_rate"; - $this->fields[] = "remote_media_ip"; - $this->fields[] = "network_addr"; - $this->fields[] = "recording_file"; - $this->fields[] = "leg"; - $this->fields[] = "pdd_ms"; - $this->fields[] = "rtp_audio_in_mos"; - $this->fields[] = "last_app"; - $this->fields[] = "last_arg"; - $this->fields[] = "cc_side"; - $this->fields[] = "cc_member_uuid"; - $this->fields[] = "cc_queue_joined_epoch"; - $this->fields[] = "cc_queue"; - $this->fields[] = "cc_member_session_uuid"; - $this->fields[] = "cc_agent"; - $this->fields[] = "cc_agent_type"; - $this->fields[] = "waitsec"; - $this->fields[] = "conference_name"; - $this->fields[] = "conference_uuid"; - $this->fields[] = "conference_member_id"; - $this->fields[] = "digits_dialed"; - $this->fields[] = "pin_number"; - $this->fields[] = "hangup_cause"; - $this->fields[] = "hangup_cause_q850"; - $this->fields[] = "sip_hangup_disposition"; - if (is_array($_SESSION['cdr']['field'])) { - foreach ($_SESSION['cdr']['field'] as $field) { - $this->fields[] = $field; - } - } - } - - /** - * save to the database - */ - public function save() { - - $this->fields(); - $field_count = sizeof($this->fields); - - $sql = "insert into v_xml_cdr ("; - $f = 1; - if (isset($this->fields)) foreach ($this->fields as $field) { - if ($field_count == $f) { - $sql .= "$field "; - } - else { - $sql .= "$field, "; - } - $f++; - } - $sql .= ")\n"; - $sql .= "values \n"; - $row_count = sizeof($this->array); - //$field_count = sizeof($this->fields); - $i = 0; - if (isset($this->array)) foreach ($this->array as $row) { - $sql .= "("; - $f = 1; - if (isset($this->fields)) foreach ($this->fields as $field) { - if (isset($row[$field]) && strlen($row[$field]) > 0) { - $sql .= "'".$row[$field]."'"; - } - else { - $sql .= "null"; - } - if ($field_count != $f) { - $sql .= ","; - } - $f++; - } - $sql .= ")"; - if ($row_count != $i) { - $sql .= ",\n"; - } - $i++; - } - if (substr($sql,-2) == ",\n") { - $sql = substr($sql,0,-2); - } - $this->db->exec(check_sql($sql)); - unset($sql); - } - - /** - * process method converts the xml cdr and adds it to the database - */ - public function xml_array($key, $leg, $xml_string) { - - //fix the xml by escaping the contents of - if(defined('STDIN')) { - $xml_string = preg_replace_callback("/<([^><]+)>(.*?[><].*?)<\/\g1>/", - function ($matches) { - return '<' . $matches[1] . '>' . - str_replace(">", ">", - str_replace("<", "<", $matches[2]) - ) . - ''; - }, - $xml_string - ); - } - - //parse the xml to get the call detail record info - try { - //$this->log($xml_string); - $xml = simplexml_load_string($xml_string); - //$this->log("\nxml load done\n"); - } - catch(Exception $e) { - echo $e->getMessage(); - //$this->log("\nfail loadxml: " . $e->getMessage() . "\n"); - } - - //get the destination number - if ($xml->variables->current_application == "bridge") { - $current_application_data = urldecode($xml->variables->current_application_data); - $bridge_array = explode("/", $current_application_data); - $destination_number = end($bridge_array); - if (strpos($destination_number,'@') !== FALSE) { - $destination_array = explode("@", $destination_number); - $destination_number = $destination_array[0]; - } - } - else { - $destination_number = urldecode($xml->variables->sip_to_user); - } - - //if last_sent_callee_id_number is set use it for the destination_number - if (strlen($xml->variables->last_sent_callee_id_number) > 0) { - $destination_number = urldecode($xml->variables->last_sent_callee_id_number); - } - - //get the caller details - $caller_id_name = urldecode($xml->variables->effective_caller_id_name); - $caller_id_number = urldecode($xml->variables->effective_caller_id_number); - $caller_id_destination = urldecode($xml->variables->caller_destination); - if (strlen($caller_id_number) == 0) foreach ($xml->callflow as $row) { - $caller_id_name = urldecode($row->caller_profile->caller_id_name); - $caller_id_number = urldecode($row->caller_profile->caller_id_number); - } - - //misc - $uuid = check_str(urldecode($xml->variables->uuid)); - $this->array[$key]['uuid'] = $uuid; - $this->array[$key]['destination_number'] = check_str($destination_number); - $this->array[$key]['source_number'] = check_str(urldecode($xml->variables->effective_caller_id_number)); - $this->array[$key]['user_context'] = check_str(urldecode($xml->variables->user_context)); - $this->array[$key]['network_addr'] = check_str(urldecode($xml->variables->sip_network_ip)); - $this->array[$key]['caller_id_name'] = check_str($caller_id_name); - $this->array[$key]['caller_id_number'] = check_str($caller_id_number); - - $this->array[$key]['accountcode'] = check_str(urldecode($xml->variables->accountcode)); - $this->array[$key]['default_language'] = check_str(urldecode($xml->variables->default_language)); - $this->array[$key]['bridge_uuid'] = check_str(urldecode($xml->variables->bridge_uuid)); - //$this->array[$key]['digits_dialed'] = check_str(urldecode($xml->variables->digits_dialed)); - $this->array[$key]['sip_hangup_disposition'] = check_str(urldecode($xml->variables->sip_hangup_disposition)); - $this->array[$key]['pin_number'] = check_str(urldecode($xml->variables->pin_number)); - //time - $this->array[$key]['start_epoch'] = check_str(urldecode($xml->variables->start_epoch)); - $start_stamp = check_str(urldecode($xml->variables->start_stamp)); - $this->array[$key]['start_stamp'] = $start_stamp; - $this->array[$key]['answer_stamp'] = check_str(urldecode($xml->variables->answer_stamp)); - $this->array[$key]['answer_epoch'] = check_str(urldecode($xml->variables->answer_epoch)); - $this->array[$key]['end_epoch'] = check_str(urldecode($xml->variables->end_epoch)); - $this->array[$key]['end_stamp'] = check_str(urldecode($xml->variables->end_stamp)); - $this->array[$key]['duration'] = check_str(urldecode($xml->variables->duration)); - $this->array[$key]['mduration'] = check_str(urldecode($xml->variables->mduration)); - $this->array[$key]['billsec'] = check_str(urldecode($xml->variables->billsec)); - $this->array[$key]['billmsec'] = check_str(urldecode($xml->variables->billmsec)); - //codecs - $this->array[$key]['read_codec'] = check_str(urldecode($xml->variables->read_codec)); - $this->array[$key]['read_rate'] = check_str(urldecode($xml->variables->read_rate)); - $this->array[$key]['write_codec'] = check_str(urldecode($xml->variables->write_codec)); - $this->array[$key]['write_rate'] = check_str(urldecode($xml->variables->write_rate)); - $this->array[$key]['remote_media_ip'] = check_str(urldecode($xml->variables->remote_media_ip)); - $this->array[$key]['hangup_cause'] = check_str(urldecode($xml->variables->hangup_cause)); - $this->array[$key]['hangup_cause_q850'] = check_str(urldecode($xml->variables->hangup_cause_q850)); - //call center - $this->array[$key]['cc_side'] = check_str(urldecode($xml->variables->cc_side)); - $this->array[$key]['cc_member_uuid'] = check_str(urldecode($xml->variables->cc_member_uuid)); - $this->array[$key]['cc_queue_joined_epoch'] = check_str(urldecode($xml->variables->cc_queue_joined_epoch)); - $this->array[$key]['cc_queue'] = check_str(urldecode($xml->variables->cc_queue)); - $this->array[$key]['cc_member_session_uuid'] = check_str(urldecode($xml->variables->cc_member_session_uuid)); - $this->array[$key]['cc_agent'] = check_str(urldecode($xml->variables->cc_agent)); - $this->array[$key]['cc_agent_type'] = check_str(urldecode($xml->variables->cc_agent_type)); - $this->array[$key]['waitsec'] = check_str(urldecode($xml->variables->waitsec)); - //app info - $this->array[$key]['last_app'] = check_str(urldecode($xml->variables->last_app)); - $this->array[$key]['last_arg'] = check_str(urldecode($xml->variables->last_arg)); - //conference - $this->array[$key]['conference_name'] = check_str(urldecode($xml->variables->conference_name)); - $this->array[$key]['conference_uuid'] = check_str(urldecode($xml->variables->conference_uuid)); - $this->array[$key]['conference_member_id'] = check_str(urldecode($xml->variables->conference_member_id)); - //call quality - $rtp_audio_in_mos = check_str(urldecode($xml->variables->rtp_audio_in_mos)); - if (strlen($rtp_audio_in_mos) > 0) { - $this->array[$key]['rtp_audio_in_mos'] = $rtp_audio_in_mos; - } - - //store the call leg - $this->array[$key]['leg'] = $leg; - - //store the call direction - $this->array[$key]['direction'] = check_str(urldecode($xml->variables->call_direction)); - - //store post dial delay, in milliseconds - $this->array[$key]['pdd_ms'] = check_str(urldecode($xml->variables->progress_mediamsec) + urldecode($xml->variables->progressmsec)); - - //get break down the date to year, month and day - $tmp_time = strtotime($start_stamp); - $tmp_year = date("Y", $tmp_time); - $tmp_month = date("M", $tmp_time); - $tmp_day = date("d", $tmp_time); - - //get the domain values from the xml - $domain_name = check_str(urldecode($xml->variables->domain_name)); - $domain_uuid = check_str(urldecode($xml->variables->domain_uuid)); - - //get the domain name - if (strlen($domain_name) == 0) { - $domain_name = check_str(urldecode($xml->variables->sip_req_host)); - } - if (strlen($domain_name) == 0) { - $presence_id = check_str(urldecode($xml->variables->presence_id)); - if (strlen($presence_id) > 0) { - $presence_array = explode($presence_id); - $domain_name = $presence_array[1]; - } - } - - //dynamic cdr fields - if (is_array($_SESSION['cdr']['field'])) { - foreach ($_SESSION['cdr']['field'] as $field) { - $fields = explode(",", $field); - $field_name = end($fields); - $this->fields[] = $field_name; - if (count($fields) == 1) { - $this->array[$key][$field_name] = urldecode($xml->variables->$fields[0]); - } - if (count($fields) == 2) { - $this->array[$key][$field_name] = urldecode($xml->$fields[0]->$fields[1]); - } - if (count($fields) == 3) { - $this->array[$key][$field_name] = urldecode($xml->$fields[0]->$fields[1]->$fields[2]); - } - } - } - - //send the domain name to the cdr log - //$this->log("\ndomain_name is `$domain_name`; domain_uuid is '$domain_uuid'\n"); - - //get the domain_uuid with the domain_name - if (strlen($domain_uuid) == 0) { - $sql = "select domain_uuid from v_domains "; - if (strlen($domain_name) == 0 && $context != 'public' && $context != 'default') { - $sql .= "where domain_name = '".$context."' "; - } - else { - $sql .= "where domain_name = '".$domain_name."' "; - } - $row = $this->db->query($sql)->fetch(); - $domain_uuid = $row['domain_uuid']; - } - - //set values in the database - if (strlen($domain_uuid) > 0) { - $this->array[$key]['domain_uuid'] = $domain_uuid; - } - if (strlen($domain_name) > 0) { - $this->array[$key]['domain_name'] = $domain_name; - } - - //check whether a recording exists - $recording_relative_path = '/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; - if (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.wav')) { - $recording_file = $recording_relative_path.'/'.$uuid.'.wav'; - } - elseif (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.mp3')) { - $recording_file = $recording_relative_path.'/'.$uuid.'.mp3'; - } - if(isset($recording_file) && !empty($recording_file)) { - $this->array[$key]['recording_file'] = $recording_file; - } - - //save to the database in xml format - if ($_SESSION['cdr']['format']['text'] == "xml" && $_SESSION['cdr']['storage']['text'] == "db") { - $this->array[$key]['xml'] = check_str($xml_string); - } - - //save to the database in json format - if ($_SESSION['cdr']['format']['text'] == "json" && $_SESSION['cdr']['storage']['text'] == "db") { - $this->array[$key]['json'] = check_str(json_encode($xml)); - } - - //insert the check_str($extension_uuid) - if (strlen($xml->variables->extension_uuid) > 0) { - $this->array[$key]['extension_uuid'] = check_str(urldecode($xml->variables->extension_uuid)); - } - - //insert the values - if (strlen($uuid) > 0) { - if ($this->debug) { - //$time5_insert = microtime(true); - //echo $sql."
\n"; - } - try { - $error = "false"; - //$this->db->exec(check_sql($sql)); - } - catch(PDOException $e) { - $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/'; - if(!file_exists($tmp_dir)) { - event_socket_mkdir($tmp_dir); - } - if ($_SESSION['cdr']['format']['text'] == "xml") { - $tmp_file = $uuid.'.xml'; - $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); - fwrite($fh, $xml_string); - } - else { - $tmp_file = $uuid.'.json'; - $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); - fwrite($fh, json_encode($xml)); - } - fclose($fh); - if ($this->debug) { - echo $e->getMessage(); - } - $error = "true"; - } - - if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") { - if (strlen($uuid) > 0) { - $tmp_time = strtotime($start_stamp); - $tmp_year = date("Y", $tmp_time); - $tmp_month = date("M", $tmp_time); - $tmp_day = date("d", $tmp_time); - $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; - if(!file_exists($tmp_dir)) { - event_socket_mkdir($tmp_dir); - } - if ($_SESSION['cdr']['format']['text'] == "xml") { - $tmp_file = $uuid.'.xml'; - $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); - fwrite($fh, $xml_string); - } - else { - $tmp_file = $uuid.'.json'; - $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); - fwrite($fh, json_encode($xml)); - } - fclose($fh); - } - } - unset($error); - - //if ($this->debug) { - //GLOBAL $insert_time,$insert_count; - //$insert_time+=microtime(true)-$time5_insert; //add this current query. - //$insert_count++; - //} - } - unset($sql); - } - - /** - * get xml from the filesystem and save it to the database - */ - public function read_files() { - $xml_cdr_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr'; - $dir_handle = opendir($xml_cdr_dir); - $x = 0; - while($file = readdir($dir_handle)) { - if ($file != '.' && $file != '..') { - if ( !is_dir($xml_cdr_dir . '/' . $file) ) { - //get the leg of the call and the file prefix - if (substr($file, 0, 2) == "a_") { - $leg = "a"; - $file_prefix = substr($file, 2, 1); - } - else { - $leg = "b"; - $file_prefix = substr($file, 0, 1); - } - - //set the limit - if (isset($_SERVER["argv"][1]) && is_numeric($_SERVER["argv"][1])) { - $limit = $_SERVER["argv"][1]; - } - else { - $limit = 1; - } - - //filter for specific files based on the file prefix - if (isset($_SERVER["argv"][2])) { - if (strpos($_SERVER["argv"][2], $file_prefix) !== FALSE) { - $import = true; - } - else { - $import = false; - } - } - else { - $import = true; - } - - //import the call detail record - if ($import) { - //get the xml cdr string - $xml_string = file_get_contents($xml_cdr_dir.'/'.$file); - - //parse the xml and insert the data into the db - $this->xml_array($x, $leg, $xml_string); - - //delete the file after it has been imported - unlink($xml_cdr_dir.'/'.$file); - } - - //increment the value - if ($import) { - $x++; - } - - //if limit exceeded exit the loop - if ($limit == $x) { - //echo "limit: $limit count: $x if\n"; - break; - } - } - } - } - $this->save(); - closedir($dir_handle); - } - //$this->read_files(); - - /** - * read the call detail records from the http post - */ - public function post() { - if (isset($_POST["cdr"])) { - //debug method - if ($this->debug){ - print_r($_POST["cdr"]); - } - - //authentication for xml cdr http post - if (!defined('STDIN')) { - if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "true" && strlen($_SESSION["xml_cdr"]["username"]) == 0) { - //get the contents of xml_cdr.conf.xml - $conf_xml_string = file_get_contents($_SESSION['switch']['conf']['dir'].'/autoload_configs/xml_cdr.conf.xml'); - - //parse the xml to get the call detail record info - try { - $conf_xml = simplexml_load_string($conf_xml_string); - } - catch(Exception $e) { - echo $e->getMessage(); - } - if (isset($conf_xml->settings->param)) foreach ($conf_xml->settings->param as $row) { - if ($row->attributes()->name == "cred") { - $auth_array = explode(":", $row->attributes()->value); - //echo "username: ".$auth_array[0]."
\n"; - //echo "password: ".$auth_array[1]."
\n"; - } - if ($row->attributes()->name == "url") { - //check name is equal to url - } - } - } - } - - //if http enabled is set to false then deny access - if (!defined('STDIN')) { - if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "false") { - echo "access denied
\n"; - return; - } - } - - //check for the correct username and password - if (!defined('STDIN')) { - if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "true") { - if ($auth_array[0] == $_SERVER["PHP_AUTH_USER"] && $auth_array[1] == $_SERVER["PHP_AUTH_PW"]) { - //echo "access granted
\n"; - $_SESSION["xml_cdr"]["username"] = $auth_array[0]; - $_SESSION["xml_cdr"]["password"] = $auth_array[1]; - } - else { - echo "access denied
\n"; - return; - } - } - } - - //loop through all attribues - //foreach($xml->settings->param[1]->attributes() as $a => $b) { - // echo $a,'="',$b,"\"
\n"; - //} - - //get the http post variable - $xml_string = trim($_POST["cdr"]); - - //get the leg of the call - if (substr($_REQUEST['uuid'], 0, 2) == "a_") { - $leg = "a"; - } - else { - $leg = "b"; - } - - //log the xml cdr - //xml_cdr_log("process cdr via post\n"); - - //parse the xml and insert the data into the database - $this->xml_array(0, $leg, $xml_string); - $this->save(); - } - } - //$this->post(); - - /** - * user summary returns an array - */ - public function user_summary() { - - //build the date range - if (strlen($this->start_stamp_begin) > 0 || strlen($this->start_stamp_end) > 0) { - unset($this->quick_select); - if (strlen($this->start_stamp_begin) > 0 && strlen($this->start_stamp_end) > 0) { - $sql_date_range .= " and start_stamp between '".$this->start_stamp_begin.":00.000' and '".$this->start_stamp_end.":59.999' \n"; - } - else { - if (strlen($this->start_stamp_begin) > 0) { $sql_date_range .= "AND start_stamp >= '".$this->start_stamp_begin.":00.000' \n"; } - if (strlen($this->start_stamp_end) > 0) { $sql_date_range .= "AND start_stamp <= '".$this->start_stamp_end.":59.999' \n"; } - } - } - else { - switch ($this->quick_select) { - case 1: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 week"))."' \n"; break; //last 7 days - case 2: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 hour"))."' \n"; break; //last hour - case 3: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d')." "."00:00:00.000' \n"; break; //today - case 4: $sql_date_range .= "AND start_stamp between '".date('Y-m-d',strtotime("-1 day"))." "."00:00:00.000' and '".date('Y-m-d',strtotime("-1 day"))." "."23:59:59.999' \n"; break; //yesterday - case 5: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d',strtotime("this week"))." "."00:00:00.000' \n"; break; //this week - case 6: $sql_date_range .= "AND start_stamp >= '".date('Y-m-')."01 "."00:00:00.000' \n"; break; //this month - case 7: $sql_date_range .= "AND start_stamp >= '".date('Y-')."01-01 "."00:00:00.000' \n"; break; //this year - } - } - - //calculate the summary data - $sql = "SELECT \n"; - $sql .= "e.domain_uuid, \n"; - $sql .= "d.domain_name, \n"; - $sql .= "e.extension, \n"; - $sql .= "e.number_alias, \n"; - - $sql .= "COUNT(*) \n"; - $sql .= "FILTER( \n"; - $sql .= " WHERE c.domain_uuid = e.domain_uuid \n"; - $sql .= " AND ((\n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL and ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - $sql .= " AND (\n"; - $sql .= " c.answer_stamp IS NOT NULL \n"; - $sql .= " and \n"; - $sql .= " c.bridge_uuid IS NOT NULL) \n"; - - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; - } - else { - $sql .= "AND direction = 'inbound') \n"; - } - $sql .= "AS answered, \n"; - - $sql .= "COUNT(*) \n"; - $sql .= "FILTER( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR (\n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - $sql .= " AND ( \n"; - $sql .= " c.answer_stamp IS NULL \n"; - $sql .= " AND \n"; - $sql .= " c.bridge_uuid IS NULL) \n"; - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR direction = 'outbound'))"; - } else { - $sql .= " AND direction = 'inbound')"; - } - $sql .= "AS missed, \n"; - - $sql .= "COUNT(*) \n"; - $sql .= "FILTER( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - $sql .= " AND c.hangup_cause = 'NO_ANSWER' \n"; - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR direction = 'local') \n"; - } - else { - $sql .= "AND direction = 'inbound' \n"; - } - $sql .= ") AS no_answer, \n"; - - $sql .= "COUNT(*) \n"; - $sql .= "FILTER( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - $sql .= " AND \n"; - $sql .= " c.hangup_cause = 'USER_BUSY' \n"; - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; - } - else { - $sql .= " AND direction = 'inbound') \n"; - } - $sql .= "AS busy, \n"; - - $sql .= "SUM(c.billsec) \n"; - $sql .= "FILTER ( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR 'direction = 'outbound') \n"; - } - $sql .= " ) / \n"; - $sql .= "COUNT(*) \n"; - $sql .= "FILTER ( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR 'direction = 'outbound') \n"; - } - $sql .= " ) AS aloc, \n"; - - $sql .= "COUNT(*) \n"; - $sql .= "FILTER ( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; - } - else { - $sql .= " AND direction = 'inbound') \n"; - } - $sql .= "AS inbound_calls, \n"; - - $sql .= "SUM(c.billsec) \n"; - $sql .= "FILTER ( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - if ($this->include_internal) { - $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; - } - else { - $sql .= " AND direction = 'inbound') \n"; - } - $sql .= "AS inbound_duration, \n"; - - $sql .= "COUNT(*) \n"; - $sql .= "FILTER ( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - $sql .= " AND \n"; - $sql .= " c.direction = 'outbound') \n"; - $sql .= "AS outbound_calls, \n"; - - $sql .= "SUM(c.billsec) \n"; - $sql .= "FILTER ( \n"; - $sql .= " WHERE (( \n"; - $sql .= " c.caller_id_number = e.extension \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.extension) \n"; - $sql .= " OR ( \n"; - $sql .= " e.number_alias IS NOT NULL \n"; - $sql .= " AND ( \n"; - $sql .= " c.caller_id_number = e.number_alias \n"; - $sql .= " OR \n"; - $sql .= " c.destination_number = e.number_alias))) \n"; - $sql .= " AND ( \n"; - $sql .= " c.direction = 'outbound')) \n"; - $sql .= "AS outbound_duration, \n"; - - $sql .= "e.description \n"; - - $sql .= "FROM v_extensions AS e, v_domains AS d, \n"; - $sql .= "( SELECT \n"; - $sql .= " domain_uuid, \n"; - $sql .= " caller_id_number, \n"; - $sql .= " destination_number, \n"; - $sql .= " answer_stamp, \n"; - $sql .= " bridge_uuid, \n"; - $sql .= " direction, \n"; - $sql .= " start_stamp, \n"; - $sql .= " hangup_cause, \n"; - $sql .= " billsec \n"; - $sql .= " FROM v_xml_cdr \n"; - $sql .= " WHERE domain_uuid = '".$this->domain_uuid."' \n"; - $sql .= $sql_date_range; - $sql .= ") AS c \n"; - - $sql .= "WHERE \n"; - $sql .= "d.domain_uuid = e.domain_uuid \n"; - if (!($_GET['showall'] && permission_exists('xml_cdr_all'))) { - $sql .= "AND e.domain_uuid = '".$this->domain_uuid."' \n"; - } - $sql .= "GROUP BY e.extension, e.domain_uuid, d.domain_uuid, e.number_alias, e.description \n"; - $sql .= "ORDER BY extension ASC \n"; - - $prep_statement = $this->db->prepare(check_sql($sql)); - $prep_statement->execute(); - $summary = $prep_statement->fetchAll(PDO::FETCH_NAMED); - - //return the array - return $summary; - } - - } //end scripts class -} -/* -//example use - $cdr = new xml_cdr; - $cdr->read_files(); -*/ -?> + + Portions created by the Initial Developer are Copyright (C) 2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + + +/** + * xml_cdr class provides methods for adding cdr records to the database + * + * @method boolean add + */ +if (!class_exists('xml_cdr')) { + class xml_cdr { + + //define variables + public $db; + public $array; + public $debug; + public $fields; + + //user summary + public $domain_uuid; + public $quick_select; + public $start_stamp_begin; + public $start_stamp_end; + public $include_internal; + public $extensions; + + /** + * Called when the object is created + */ + public function __construct() { + //connect to the database if not connected + if (!$this->db) { + require_once "resources/classes/database.php"; + $database = new database; + $database->connect(); + $this->db = $database->db; + } + } + + /** + * Called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + if (isset($this)) foreach ($this as $key => $value) { + unset($this->$key); + } + } + + + /** + * cdr process logging + */ + public function log($message) { + //save to file system (alternative to a syslog server) + $fp = fopen($_SESSION['server']['temp']['dir'].'/xml_cdr.log', 'a+'); + if (!$fp) { + return; + } + fwrite($fp, $message); + fclose($fp); + } + + /** + * cdr fields in the database schema + */ + public function fields() { + + $this->fields[] = "uuid"; + $this->fields[] = "domain_uuid"; + $this->fields[] = "extension_uuid"; + $this->fields[] = "domain_name"; + $this->fields[] = "accountcode"; + $this->fields[] = "direction"; + $this->fields[] = "default_language"; + $this->fields[] = "context"; + $this->fields[] = "xml"; + $this->fields[] = "json"; + $this->fields[] = "caller_id_name"; + $this->fields[] = "caller_id_number"; + $this->fields[] = "caller_destination"; + $this->fields[] = "destination_number"; + $this->fields[] = "source_number"; + $this->fields[] = "start_epoch"; + $this->fields[] = "start_stamp"; + $this->fields[] = "answer_stamp"; + $this->fields[] = "answer_epoch"; + $this->fields[] = "end_epoch"; + $this->fields[] = "end_stamp"; + $this->fields[] = "duration"; + $this->fields[] = "mduration"; + $this->fields[] = "billsec"; + $this->fields[] = "billmsec"; + $this->fields[] = "bridge_uuid"; + $this->fields[] = "read_codec"; + $this->fields[] = "read_rate"; + $this->fields[] = "write_codec"; + $this->fields[] = "write_rate"; + $this->fields[] = "remote_media_ip"; + $this->fields[] = "network_addr"; + $this->fields[] = "recording_file"; + $this->fields[] = "leg"; + $this->fields[] = "pdd_ms"; + $this->fields[] = "rtp_audio_in_mos"; + $this->fields[] = "last_app"; + $this->fields[] = "last_arg"; + $this->fields[] = "cc_side"; + $this->fields[] = "cc_member_uuid"; + $this->fields[] = "cc_queue_joined_epoch"; + $this->fields[] = "cc_queue"; + $this->fields[] = "cc_member_session_uuid"; + $this->fields[] = "cc_agent"; + $this->fields[] = "cc_agent_type"; + $this->fields[] = "waitsec"; + $this->fields[] = "conference_name"; + $this->fields[] = "conference_uuid"; + $this->fields[] = "conference_member_id"; + $this->fields[] = "digits_dialed"; + $this->fields[] = "pin_number"; + $this->fields[] = "hangup_cause"; + $this->fields[] = "hangup_cause_q850"; + $this->fields[] = "sip_hangup_disposition"; + if (is_array($_SESSION['cdr']['field'])) { + foreach ($_SESSION['cdr']['field'] as $field) { + $this->fields[] = $field; + } + } + } + + /** + * save to the database + */ + public function save() { + + $this->fields(); + $field_count = sizeof($this->fields); + + $sql = "insert into v_xml_cdr ("; + $f = 1; + if (isset($this->fields)) foreach ($this->fields as $field) { + if ($field_count == $f) { + $sql .= "$field "; + } + else { + $sql .= "$field, "; + } + $f++; + } + $sql .= ")\n"; + $sql .= "values \n"; + $row_count = sizeof($this->array); + //$field_count = sizeof($this->fields); + $i = 0; + if (isset($this->array)) foreach ($this->array as $row) { + $sql .= "("; + $f = 1; + if (isset($this->fields)) foreach ($this->fields as $field) { + if (isset($row[$field]) && strlen($row[$field]) > 0) { + $sql .= "'".$row[$field]."'"; + } + else { + $sql .= "null"; + } + if ($field_count != $f) { + $sql .= ","; + } + $f++; + } + $sql .= ")"; + if ($row_count != $i) { + $sql .= ",\n"; + } + $i++; + } + if (substr($sql,-2) == ",\n") { + $sql = substr($sql,0,-2); + } + $this->db->exec(check_sql($sql)); + unset($sql); + } + + /** + * process method converts the xml cdr and adds it to the database + */ + public function xml_array($key, $leg, $xml_string) { + + //fix the xml by escaping the contents of + if(defined('STDIN')) { + $xml_string = preg_replace_callback("/<([^><]+)>(.*?[><].*?)<\/\g1>/", + function ($matches) { + return '<' . $matches[1] . '>' . + str_replace(">", ">", + str_replace("<", "<", $matches[2]) + ) . + ''; + }, + $xml_string + ); + } + + //parse the xml to get the call detail record info + try { + //$this->log($xml_string); + $xml = simplexml_load_string($xml_string); + //$this->log("\nxml load done\n"); + } + catch(Exception $e) { + echo $e->getMessage(); + //$this->log("\nfail loadxml: " . $e->getMessage() . "\n"); + } + + //get the destination number + if ($xml->variables->current_application == "bridge") { + $current_application_data = urldecode($xml->variables->current_application_data); + $bridge_array = explode("/", $current_application_data); + $destination_number = end($bridge_array); + if (strpos($destination_number,'@') !== FALSE) { + $destination_array = explode("@", $destination_number); + $destination_number = $destination_array[0]; + } + } + else { + $destination_number = urldecode($xml->variables->sip_to_user); + } + + //if last_sent_callee_id_number is set use it for the destination_number + if (strlen($xml->variables->last_sent_callee_id_number) > 0) { + $destination_number = urldecode($xml->variables->last_sent_callee_id_number); + } + + //get the caller details + $caller_id_name = urldecode($xml->variables->effective_caller_id_name); + $caller_id_number = urldecode($xml->variables->effective_caller_id_number); + $caller_id_destination = urldecode($xml->variables->caller_destination); + if (strlen($caller_id_number) == 0) foreach ($xml->callflow as $row) { + $caller_id_name = urldecode($row->caller_profile->caller_id_name); + $caller_id_number = urldecode($row->caller_profile->caller_id_number); + } + + //misc + $uuid = check_str(urldecode($xml->variables->uuid)); + $this->array[$key]['uuid'] = $uuid; + $this->array[$key]['destination_number'] = check_str($destination_number); + $this->array[$key]['source_number'] = check_str(urldecode($xml->variables->effective_caller_id_number)); + $this->array[$key]['user_context'] = check_str(urldecode($xml->variables->user_context)); + $this->array[$key]['network_addr'] = check_str(urldecode($xml->variables->sip_network_ip)); + $this->array[$key]['caller_id_name'] = check_str($caller_id_name); + $this->array[$key]['caller_id_number'] = check_str($caller_id_number); + + $this->array[$key]['accountcode'] = check_str(urldecode($xml->variables->accountcode)); + $this->array[$key]['default_language'] = check_str(urldecode($xml->variables->default_language)); + $this->array[$key]['bridge_uuid'] = check_str(urldecode($xml->variables->bridge_uuid)); + //$this->array[$key]['digits_dialed'] = check_str(urldecode($xml->variables->digits_dialed)); + $this->array[$key]['sip_hangup_disposition'] = check_str(urldecode($xml->variables->sip_hangup_disposition)); + $this->array[$key]['pin_number'] = check_str(urldecode($xml->variables->pin_number)); + //time + $this->array[$key]['start_epoch'] = check_str(urldecode($xml->variables->start_epoch)); + $start_stamp = check_str(urldecode($xml->variables->start_stamp)); + $this->array[$key]['start_stamp'] = $start_stamp; + $this->array[$key]['answer_stamp'] = check_str(urldecode($xml->variables->answer_stamp)); + $this->array[$key]['answer_epoch'] = check_str(urldecode($xml->variables->answer_epoch)); + $this->array[$key]['end_epoch'] = check_str(urldecode($xml->variables->end_epoch)); + $this->array[$key]['end_stamp'] = check_str(urldecode($xml->variables->end_stamp)); + $this->array[$key]['duration'] = check_str(urldecode($xml->variables->duration)); + $this->array[$key]['mduration'] = check_str(urldecode($xml->variables->mduration)); + $this->array[$key]['billsec'] = check_str(urldecode($xml->variables->billsec)); + $this->array[$key]['billmsec'] = check_str(urldecode($xml->variables->billmsec)); + //codecs + $this->array[$key]['read_codec'] = check_str(urldecode($xml->variables->read_codec)); + $this->array[$key]['read_rate'] = check_str(urldecode($xml->variables->read_rate)); + $this->array[$key]['write_codec'] = check_str(urldecode($xml->variables->write_codec)); + $this->array[$key]['write_rate'] = check_str(urldecode($xml->variables->write_rate)); + $this->array[$key]['remote_media_ip'] = check_str(urldecode($xml->variables->remote_media_ip)); + $this->array[$key]['hangup_cause'] = check_str(urldecode($xml->variables->hangup_cause)); + $this->array[$key]['hangup_cause_q850'] = check_str(urldecode($xml->variables->hangup_cause_q850)); + //call center + $this->array[$key]['cc_side'] = check_str(urldecode($xml->variables->cc_side)); + $this->array[$key]['cc_member_uuid'] = check_str(urldecode($xml->variables->cc_member_uuid)); + $this->array[$key]['cc_queue_joined_epoch'] = check_str(urldecode($xml->variables->cc_queue_joined_epoch)); + $this->array[$key]['cc_queue'] = check_str(urldecode($xml->variables->cc_queue)); + $this->array[$key]['cc_member_session_uuid'] = check_str(urldecode($xml->variables->cc_member_session_uuid)); + $this->array[$key]['cc_agent'] = check_str(urldecode($xml->variables->cc_agent)); + $this->array[$key]['cc_agent_type'] = check_str(urldecode($xml->variables->cc_agent_type)); + $this->array[$key]['waitsec'] = check_str(urldecode($xml->variables->waitsec)); + //app info + $this->array[$key]['last_app'] = check_str(urldecode($xml->variables->last_app)); + $this->array[$key]['last_arg'] = check_str(urldecode($xml->variables->last_arg)); + //conference + $this->array[$key]['conference_name'] = check_str(urldecode($xml->variables->conference_name)); + $this->array[$key]['conference_uuid'] = check_str(urldecode($xml->variables->conference_uuid)); + $this->array[$key]['conference_member_id'] = check_str(urldecode($xml->variables->conference_member_id)); + //call quality + $rtp_audio_in_mos = check_str(urldecode($xml->variables->rtp_audio_in_mos)); + if (strlen($rtp_audio_in_mos) > 0) { + $this->array[$key]['rtp_audio_in_mos'] = $rtp_audio_in_mos; + } + + //store the call leg + $this->array[$key]['leg'] = $leg; + + //store the call direction + $this->array[$key]['direction'] = check_str(urldecode($xml->variables->call_direction)); + + //store post dial delay, in milliseconds + $this->array[$key]['pdd_ms'] = check_str(urldecode($xml->variables->progress_mediamsec) + urldecode($xml->variables->progressmsec)); + + //get break down the date to year, month and day + $tmp_time = strtotime($start_stamp); + $tmp_year = date("Y", $tmp_time); + $tmp_month = date("M", $tmp_time); + $tmp_day = date("d", $tmp_time); + + //get the domain values from the xml + $domain_name = check_str(urldecode($xml->variables->domain_name)); + $domain_uuid = check_str(urldecode($xml->variables->domain_uuid)); + + //get the domain name + if (strlen($domain_name) == 0) { + $domain_name = check_str(urldecode($xml->variables->sip_req_host)); + } + if (strlen($domain_name) == 0) { + $presence_id = check_str(urldecode($xml->variables->presence_id)); + if (strlen($presence_id) > 0) { + $presence_array = explode($presence_id); + $domain_name = $presence_array[1]; + } + } + + //dynamic cdr fields + if (is_array($_SESSION['cdr']['field'])) { + foreach ($_SESSION['cdr']['field'] as $field) { + $fields = explode(",", $field); + $field_name = end($fields); + $this->fields[] = $field_name; + if (count($fields) == 1) { + $this->array[$key][$field_name] = urldecode($xml->variables->$fields[0]); + } + if (count($fields) == 2) { + $this->array[$key][$field_name] = urldecode($xml->$fields[0]->$fields[1]); + } + if (count($fields) == 3) { + $this->array[$key][$field_name] = urldecode($xml->$fields[0]->$fields[1]->$fields[2]); + } + } + } + + //send the domain name to the cdr log + //$this->log("\ndomain_name is `$domain_name`; domain_uuid is '$domain_uuid'\n"); + + //get the domain_uuid with the domain_name + if (strlen($domain_uuid) == 0) { + $sql = "select domain_uuid from v_domains "; + if (strlen($domain_name) == 0 && $context != 'public' && $context != 'default') { + $sql .= "where domain_name = '".$context."' "; + } + else { + $sql .= "where domain_name = '".$domain_name."' "; + } + $row = $this->db->query($sql)->fetch(); + $domain_uuid = $row['domain_uuid']; + } + + //set values in the database + if (strlen($domain_uuid) > 0) { + $this->array[$key]['domain_uuid'] = $domain_uuid; + } + if (strlen($domain_name) > 0) { + $this->array[$key]['domain_name'] = $domain_name; + } + + //check whether a recording exists + $recording_relative_path = '/'.$_SESSION['domain_name'].'/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + if (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.wav')) { + $recording_file = $recording_relative_path.'/'.$uuid.'.wav'; + } + elseif (file_exists($_SESSION['switch']['recordings']['dir'].$recording_relative_path.'/'.$uuid.'.mp3')) { + $recording_file = $recording_relative_path.'/'.$uuid.'.mp3'; + } + if(isset($recording_file) && !empty($recording_file)) { + $this->array[$key]['recording_file'] = $recording_file; + } + + //save to the database in xml format + if ($_SESSION['cdr']['format']['text'] == "xml" && $_SESSION['cdr']['storage']['text'] == "db") { + $this->array[$key]['xml'] = check_str($xml_string); + } + + //save to the database in json format + if ($_SESSION['cdr']['format']['text'] == "json" && $_SESSION['cdr']['storage']['text'] == "db") { + $this->array[$key]['json'] = check_str(json_encode($xml)); + } + + //insert the check_str($extension_uuid) + if (strlen($xml->variables->extension_uuid) > 0) { + $this->array[$key]['extension_uuid'] = check_str(urldecode($xml->variables->extension_uuid)); + } + + //insert the values + if (strlen($uuid) > 0) { + if ($this->debug) { + //$time5_insert = microtime(true); + //echo $sql."
\n"; + } + try { + $error = "false"; + //$this->db->exec(check_sql($sql)); + } + catch(PDOException $e) { + $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/failed/'; + if(!file_exists($tmp_dir)) { + event_socket_mkdir($tmp_dir); + } + if ($_SESSION['cdr']['format']['text'] == "xml") { + $tmp_file = $uuid.'.xml'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, $xml_string); + } + else { + $tmp_file = $uuid.'.json'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, json_encode($xml)); + } + fclose($fh); + if ($this->debug) { + echo $e->getMessage(); + } + $error = "true"; + } + + if ($_SESSION['cdr']['storage']['text'] == "dir" && $error != "true") { + if (strlen($uuid) > 0) { + $tmp_time = strtotime($start_stamp); + $tmp_year = date("Y", $tmp_time); + $tmp_month = date("M", $tmp_time); + $tmp_day = date("d", $tmp_time); + $tmp_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr/archive/'.$tmp_year.'/'.$tmp_month.'/'.$tmp_day; + if(!file_exists($tmp_dir)) { + event_socket_mkdir($tmp_dir); + } + if ($_SESSION['cdr']['format']['text'] == "xml") { + $tmp_file = $uuid.'.xml'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, $xml_string); + } + else { + $tmp_file = $uuid.'.json'; + $fh = fopen($tmp_dir.'/'.$tmp_file, 'w'); + fwrite($fh, json_encode($xml)); + } + fclose($fh); + } + } + unset($error); + + //if ($this->debug) { + //GLOBAL $insert_time,$insert_count; + //$insert_time+=microtime(true)-$time5_insert; //add this current query. + //$insert_count++; + //} + } + unset($sql); + } + + /** + * get xml from the filesystem and save it to the database + */ + public function read_files() { + $xml_cdr_dir = $_SESSION['switch']['log']['dir'].'/xml_cdr'; + $dir_handle = opendir($xml_cdr_dir); + $x = 0; + while($file = readdir($dir_handle)) { + if ($file != '.' && $file != '..') { + if ( !is_dir($xml_cdr_dir . '/' . $file) ) { + //get the leg of the call and the file prefix + if (substr($file, 0, 2) == "a_") { + $leg = "a"; + $file_prefix = substr($file, 2, 1); + } + else { + $leg = "b"; + $file_prefix = substr($file, 0, 1); + } + + //set the limit + if (isset($_SERVER["argv"][1]) && is_numeric($_SERVER["argv"][1])) { + $limit = $_SERVER["argv"][1]; + } + else { + $limit = 1; + } + + //filter for specific files based on the file prefix + if (isset($_SERVER["argv"][2])) { + if (strpos($_SERVER["argv"][2], $file_prefix) !== FALSE) { + $import = true; + } + else { + $import = false; + } + } + else { + $import = true; + } + + //import the call detail record + if ($import) { + //get the xml cdr string + $xml_string = file_get_contents($xml_cdr_dir.'/'.$file); + + //parse the xml and insert the data into the db + $this->xml_array($x, $leg, $xml_string); + + //delete the file after it has been imported + unlink($xml_cdr_dir.'/'.$file); + } + + //increment the value + if ($import) { + $x++; + } + + //if limit exceeded exit the loop + if ($limit == $x) { + //echo "limit: $limit count: $x if\n"; + break; + } + } + } + } + $this->save(); + closedir($dir_handle); + } + //$this->read_files(); + + /** + * read the call detail records from the http post + */ + public function post() { + if (isset($_POST["cdr"])) { + //debug method + if ($this->debug){ + print_r($_POST["cdr"]); + } + + //authentication for xml cdr http post + if (!defined('STDIN')) { + if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "true" && strlen($_SESSION["xml_cdr"]["username"]) == 0) { + //get the contents of xml_cdr.conf.xml + $conf_xml_string = file_get_contents($_SESSION['switch']['conf']['dir'].'/autoload_configs/xml_cdr.conf.xml'); + + //parse the xml to get the call detail record info + try { + $conf_xml = simplexml_load_string($conf_xml_string); + } + catch(Exception $e) { + echo $e->getMessage(); + } + if (isset($conf_xml->settings->param)) foreach ($conf_xml->settings->param as $row) { + if ($row->attributes()->name == "cred") { + $auth_array = explode(":", $row->attributes()->value); + //echo "username: ".$auth_array[0]."
\n"; + //echo "password: ".$auth_array[1]."
\n"; + } + if ($row->attributes()->name == "url") { + //check name is equal to url + } + } + } + } + + //if http enabled is set to false then deny access + if (!defined('STDIN')) { + if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "false") { + echo "access denied
\n"; + return; + } + } + + //check for the correct username and password + if (!defined('STDIN')) { + if ($_SESSION["cdr"]["http_enabled"]["boolean"] == "true") { + if ($auth_array[0] == $_SERVER["PHP_AUTH_USER"] && $auth_array[1] == $_SERVER["PHP_AUTH_PW"]) { + //echo "access granted
\n"; + $_SESSION["xml_cdr"]["username"] = $auth_array[0]; + $_SESSION["xml_cdr"]["password"] = $auth_array[1]; + } + else { + echo "access denied
\n"; + return; + } + } + } + + //loop through all attribues + //foreach($xml->settings->param[1]->attributes() as $a => $b) { + // echo $a,'="',$b,"\"
\n"; + //} + + //get the http post variable + $xml_string = trim($_POST["cdr"]); + + //get the leg of the call + if (substr($_REQUEST['uuid'], 0, 2) == "a_") { + $leg = "a"; + } + else { + $leg = "b"; + } + + //log the xml cdr + //xml_cdr_log("process cdr via post\n"); + + //parse the xml and insert the data into the database + $this->xml_array(0, $leg, $xml_string); + $this->save(); + } + } + //$this->post(); + + /** + * user summary returns an array + */ + public function user_summary() { + + //build the date range + if (strlen($this->start_stamp_begin) > 0 || strlen($this->start_stamp_end) > 0) { + unset($this->quick_select); + if (strlen($this->start_stamp_begin) > 0 && strlen($this->start_stamp_end) > 0) { + $sql_date_range .= " and start_stamp between '".$this->start_stamp_begin.":00.000' and '".$this->start_stamp_end.":59.999' \n"; + } + else { + if (strlen($this->start_stamp_begin) > 0) { $sql_date_range .= "AND start_stamp >= '".$this->start_stamp_begin.":00.000' \n"; } + if (strlen($this->start_stamp_end) > 0) { $sql_date_range .= "AND start_stamp <= '".$this->start_stamp_end.":59.999' \n"; } + } + } + else { + switch ($this->quick_select) { + case 1: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 week"))."' \n"; break; //last 7 days + case 2: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d H:i:s.000', strtotime("-1 hour"))."' \n"; break; //last hour + case 3: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d')." "."00:00:00.000' \n"; break; //today + case 4: $sql_date_range .= "AND start_stamp between '".date('Y-m-d',strtotime("-1 day"))." "."00:00:00.000' and '".date('Y-m-d',strtotime("-1 day"))." "."23:59:59.999' \n"; break; //yesterday + case 5: $sql_date_range .= "AND start_stamp >= '".date('Y-m-d',strtotime("this week"))." "."00:00:00.000' \n"; break; //this week + case 6: $sql_date_range .= "AND start_stamp >= '".date('Y-m-')."01 "."00:00:00.000' \n"; break; //this month + case 7: $sql_date_range .= "AND start_stamp >= '".date('Y-')."01-01 "."00:00:00.000' \n"; break; //this year + } + } + + //calculate the summary data + $sql = "SELECT \n"; + $sql .= "e.domain_uuid, \n"; + $sql .= "d.domain_name, \n"; + $sql .= "e.extension, \n"; + $sql .= "e.number_alias, \n"; + + $sql .= "COUNT(*) \n"; + $sql .= "FILTER( \n"; + $sql .= " WHERE c.domain_uuid = e.domain_uuid \n"; + $sql .= " AND ((\n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL and ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + $sql .= " AND (\n"; + $sql .= " c.answer_stamp IS NOT NULL \n"; + $sql .= " and \n"; + $sql .= " c.bridge_uuid IS NOT NULL) \n"; + + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; + } + else { + $sql .= "AND direction = 'inbound') \n"; + } + $sql .= "AS answered, \n"; + + $sql .= "COUNT(*) \n"; + $sql .= "FILTER( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR (\n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + $sql .= " AND ( \n"; + $sql .= " c.answer_stamp IS NULL \n"; + $sql .= " AND \n"; + $sql .= " c.bridge_uuid IS NULL) \n"; + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR direction = 'outbound'))"; + } else { + $sql .= " AND direction = 'inbound')"; + } + $sql .= "AS missed, \n"; + + $sql .= "COUNT(*) \n"; + $sql .= "FILTER( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + $sql .= " AND c.hangup_cause = 'NO_ANSWER' \n"; + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR direction = 'local') \n"; + } + else { + $sql .= "AND direction = 'inbound' \n"; + } + $sql .= ") AS no_answer, \n"; + + $sql .= "COUNT(*) \n"; + $sql .= "FILTER( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + $sql .= " AND \n"; + $sql .= " c.hangup_cause = 'USER_BUSY' \n"; + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; + } + else { + $sql .= " AND direction = 'inbound') \n"; + } + $sql .= "AS busy, \n"; + + $sql .= "SUM(c.billsec) \n"; + $sql .= "FILTER ( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR 'direction = 'outbound') \n"; + } + $sql .= " ) / \n"; + $sql .= "COUNT(*) \n"; + $sql .= "FILTER ( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR 'direction = 'outbound') \n"; + } + $sql .= " ) AS aloc, \n"; + + $sql .= "COUNT(*) \n"; + $sql .= "FILTER ( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; + } + else { + $sql .= " AND direction = 'inbound') \n"; + } + $sql .= "AS inbound_calls, \n"; + + $sql .= "SUM(c.billsec) \n"; + $sql .= "FILTER ( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + if ($this->include_internal) { + $sql .= " AND (direction = 'inbound' OR direction = 'local')) \n"; + } + else { + $sql .= " AND direction = 'inbound') \n"; + } + $sql .= "AS inbound_duration, \n"; + + $sql .= "COUNT(*) \n"; + $sql .= "FILTER ( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + $sql .= " AND \n"; + $sql .= " c.direction = 'outbound') \n"; + $sql .= "AS outbound_calls, \n"; + + $sql .= "SUM(c.billsec) \n"; + $sql .= "FILTER ( \n"; + $sql .= " WHERE (( \n"; + $sql .= " c.caller_id_number = e.extension \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.extension) \n"; + $sql .= " OR ( \n"; + $sql .= " e.number_alias IS NOT NULL \n"; + $sql .= " AND ( \n"; + $sql .= " c.caller_id_number = e.number_alias \n"; + $sql .= " OR \n"; + $sql .= " c.destination_number = e.number_alias))) \n"; + $sql .= " AND ( \n"; + $sql .= " c.direction = 'outbound')) \n"; + $sql .= "AS outbound_duration, \n"; + + $sql .= "e.description \n"; + + $sql .= "FROM v_extensions AS e, v_domains AS d, \n"; + $sql .= "( SELECT \n"; + $sql .= " domain_uuid, \n"; + $sql .= " caller_id_number, \n"; + $sql .= " destination_number, \n"; + $sql .= " answer_stamp, \n"; + $sql .= " bridge_uuid, \n"; + $sql .= " direction, \n"; + $sql .= " start_stamp, \n"; + $sql .= " hangup_cause, \n"; + $sql .= " billsec \n"; + $sql .= " FROM v_xml_cdr \n"; + $sql .= " WHERE domain_uuid = '".$this->domain_uuid."' \n"; + $sql .= $sql_date_range; + $sql .= ") AS c \n"; + + $sql .= "WHERE \n"; + $sql .= "d.domain_uuid = e.domain_uuid \n"; + if (!($_GET['showall'] && permission_exists('xml_cdr_all'))) { + $sql .= "AND e.domain_uuid = '".$this->domain_uuid."' \n"; + } + $sql .= "GROUP BY e.extension, e.domain_uuid, d.domain_uuid, e.number_alias, e.description \n"; + $sql .= "ORDER BY extension ASC \n"; + + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $summary = $prep_statement->fetchAll(PDO::FETCH_NAMED); + + //return the array + return $summary; + } + + } //end scripts class +} +/* +//example use + $cdr = new xml_cdr; + $cdr->read_files(); +*/ +?> diff --git a/resources/fonts/web_font_loader.php b/resources/fonts/web_font_loader.php index 500c7ac620..6a5967e305 100644 --- a/resources/fonts/web_font_loader.php +++ b/resources/fonts/web_font_loader.php @@ -1,110 +1,110 @@ - 0) { - foreach ($_SESSION['theme'] as $subcategory => $type) { - if (substr_count($subcategory, '_font') > 0) { - $font_string = $type['text']; - if ($font_string != '') { - if (substr_count($font_string, ',') > 0) { - $tmp_array = explode(',', $font_string); - } - else { - $tmp_array[] = $font_string; - } - foreach ($tmp_array as $font_name) { - $font_name = trim($font_name, "'"); - $font_name = trim($font_name, '"'); - $font_name = trim($font_name); - $fonts[] = $font_name; - } - } - } - unset($tmp_array); - } - } - - //optimize fonts array - if (is_array($fonts) && sizeof($fonts) > 0) { - $fonts = array_unique($fonts); - $common_fonts = 'serif,sans-serif,arial,arial black,arial narrow,calibri,'. - 'candara,apple gothic,geneva,tahoma,microsoft sans serif,'. - 'lucidia,lucidia console,monaco,lucidia sans unicode,'. - 'lucidiagrande,consolas,menlo,trebuchet,trebuchet ms,'. - 'helvetica,times,times new roman,courier,courier new,'. - 'impact,comic sans,comic sans ms,georgia,palatino,'. - 'palatino linotype,verdana,franklin gothic,'. - 'franklin gothic medium,gill sans,gill sans mt,'. - 'brush script,corbel,segoe,segoe ui,optima,'; - $common_fonts = explode(',', $common_fonts); - foreach ($fonts as $index => $font) { - if (in_array(strtolower($font), $common_fonts)) { - unset($fonts[$index]); - } - } - } - - //load fonts - if (is_array($fonts) && sizeof($fonts) > 0) { - if ($_SESSION['theme']['font_retrieval']['text'] == 'asynchronous') { - ?> - WebFontConfig = { - google: { - families: [''] - } - }; - (function(d) { - var wf = d.createElement('script'), s = d.scripts[0]; - wf.src = '//ajax.googleapis.com/ajax/libs/webfont//webfont.js'; - s.parentNode.insertBefore(wf, s); - })(document); - - WebFont.load({ - google: { - families: [''] - } - }); - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + 0) { + foreach ($_SESSION['theme'] as $subcategory => $type) { + if (substr_count($subcategory, '_font') > 0) { + $font_string = $type['text']; + if ($font_string != '') { + if (substr_count($font_string, ',') > 0) { + $tmp_array = explode(',', $font_string); + } + else { + $tmp_array[] = $font_string; + } + foreach ($tmp_array as $font_name) { + $font_name = trim($font_name, "'"); + $font_name = trim($font_name, '"'); + $font_name = trim($font_name); + $fonts[] = $font_name; + } + } + } + unset($tmp_array); + } + } + + //optimize fonts array + if (is_array($fonts) && sizeof($fonts) > 0) { + $fonts = array_unique($fonts); + $common_fonts = 'serif,sans-serif,arial,arial black,arial narrow,calibri,'. + 'candara,apple gothic,geneva,tahoma,microsoft sans serif,'. + 'lucidia,lucidia console,monaco,lucidia sans unicode,'. + 'lucidiagrande,consolas,menlo,trebuchet,trebuchet ms,'. + 'helvetica,times,times new roman,courier,courier new,'. + 'impact,comic sans,comic sans ms,georgia,palatino,'. + 'palatino linotype,verdana,franklin gothic,'. + 'franklin gothic medium,gill sans,gill sans mt,'. + 'brush script,corbel,segoe,segoe ui,optima,'; + $common_fonts = explode(',', $common_fonts); + foreach ($fonts as $index => $font) { + if (in_array(strtolower($font), $common_fonts)) { + unset($fonts[$index]); + } + } + } + + //load fonts + if (is_array($fonts) && sizeof($fonts) > 0) { + if ($_SESSION['theme']['font_retrieval']['text'] == 'asynchronous') { + ?> + WebFontConfig = { + google: { + families: [''] + } + }; + (function(d) { + var wf = d.createElement('script'), s = d.scripts[0]; + wf.src = '//ajax.googleapis.com/ajax/libs/webfont//webfont.js'; + s.parentNode.insertBefore(wf, s); + })(document); + + WebFont.load({ + google: { + families: [''] + } + }); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/themes/default/app_defaults.php b/themes/default/app_defaults.php index be641408b0..5d2d61762b 100644 --- a/themes/default/app_defaults.php +++ b/themes/default/app_defaults.php @@ -1,59 +1,59 @@ - - Portions created by the Initial Developer are Copyright (C) 2008-2016 - the Initial Developer. All Rights Reserved. - - Contributor(s): - Mark J Crane -*/ - -if ($domains_processed == 1) { - - //get the background images - $relative_path = PROJECT_PATH.'/themes/default/images/backgrounds'; - $backgrounds = opendir($_SERVER["DOCUMENT_ROOT"].'/'.$relative_path); - unset($array); - $x = 0; - while (false !== ($file = readdir($backgrounds))) { - if ($file != "." AND $file != "..") { - $ext = pathinfo($file, PATHINFO_EXTENSION); - if ($ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "gif") { - $array[$x]['default_setting_category'] = 'theme'; - $array[$x]['default_setting_subcategory'] = 'background_image'; - $array[$x]['default_setting_name'] = 'array'; - $array[$x]['default_setting_value'] = $relative_path.'/'.$file; - $array[$x]['default_setting_enabled'] = 'false'; - $array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.'; - $x++; - $array[$x]['default_setting_category'] = 'theme'; - $array[$x]['default_setting_subcategory'] = 'login_background_image'; - $array[$x]['default_setting_name'] = 'array'; - $array[$x]['default_setting_value'] = $relative_path.'/'.$file; - $array[$x]['default_setting_enabled'] = 'false'; - $array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.'; - $x++; - } - if ($x > 300) { break; }; - } - } - -} - -?> + + Portions created by the Initial Developer are Copyright (C) 2008-2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +if ($domains_processed == 1) { + + //get the background images + $relative_path = PROJECT_PATH.'/themes/default/images/backgrounds'; + $backgrounds = opendir($_SERVER["DOCUMENT_ROOT"].'/'.$relative_path); + unset($array); + $x = 0; + while (false !== ($file = readdir($backgrounds))) { + if ($file != "." AND $file != "..") { + $ext = pathinfo($file, PATHINFO_EXTENSION); + if ($ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "gif") { + $array[$x]['default_setting_category'] = 'theme'; + $array[$x]['default_setting_subcategory'] = 'background_image'; + $array[$x]['default_setting_name'] = 'array'; + $array[$x]['default_setting_value'] = $relative_path.'/'.$file; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.'; + $x++; + $array[$x]['default_setting_category'] = 'theme'; + $array[$x]['default_setting_subcategory'] = 'login_background_image'; + $array[$x]['default_setting_name'] = 'array'; + $array[$x]['default_setting_value'] = $relative_path.'/'.$file; + $array[$x]['default_setting_enabled'] = 'false'; + $array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.'; + $x++; + } + if ($x > 300) { break; }; + } + } + +} + +?> diff --git a/themes/default/css.php b/themes/default/css.php index 85fdc30da7..ab2b4a7305 100644 --- a/themes/default/css.php +++ b/themes/default/css.php @@ -1,1837 +1,1837 @@ - 0) { - foreach ($_SESSION['theme'] as $subcategory => $type) { - if (substr_count($subcategory, '_font') > 0) { - $font_string = $type['text']; - if ($font_string != '') { - if (substr_count($font_string, ',') > 0) { - $tmp_array = explode(',', $font_string); - } - else { - $tmp_array[] = $font_string; - } - foreach ($tmp_array as $font_name) { - $font_name = trim($font_name, "'"); - $font_name = trim($font_name, '"'); - $font_name = trim($font_name); - $fonts[] = $font_name; - } - if (sizeof($fonts) == 1 && strtolower($fonts[0]) != 'arial') { $fonts[] = 'Arial'; } //fall back font - $_SESSION['theme'][$subcategory]['text'] = "'".implode("','", $fonts)."'"; - } - } - unset($fonts, $tmp_array); - } - } - -//determine which background image/color settings to use (login or standard) - $background_images_enabled = false; - if ($default_login) { - //try using login background images/colors - if (isset($_SESSION['theme']) && $_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) { - $background_images_enabled = true; - $background_images = $_SESSION['theme']['login_background_image']; - } - else if ($_SESSION['theme']['login_background_color'][0] != '' || $_SESSION['theme']['login_background_color'][1] != '') { - $background_colors[0] = $_SESSION['theme']['login_background_color'][0]; - $background_colors[1] = $_SESSION['theme']['login_background_color'][1]; - } - else { - //otherwise, use standard background images/colors - if ($_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) { - $background_images_enabled = true; - $background_images = $_SESSION['theme']['background_image']; - } - else { - $background_colors[0] = $_SESSION['theme']['background_color'][0]; - $background_colors[1] = $_SESSION['theme']['background_color'][1]; - } - } - } - else { - //use standard background images/colors - if (isset($_SESSION['theme']) && isset($_SESSION['theme']['background_image_enabled']) && $_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) { - $background_images_enabled = true; - $background_images = $_SESSION['theme']['background_image']; - } - else { - $background_colors[0] = $_SESSION['theme']['background_color'][0]; - $background_colors[1] = $_SESSION['theme']['background_color'][1]; - } - } - -//check for background image - if ($background_images_enabled) { - // background image is enabled - $image_extensions = array('jpg','jpeg','png','gif'); - - if (count($background_images) > 0) { - - if ((!isset($_SESSION['background_image'])) or strlen($_SESSION['background_image']) == 0) { - $_SESSION['background_image'] = $background_images[array_rand($background_images)]; - $background_image = $_SESSION['background_image']; - } - - // background image(s) specified, check if source is file or folder - if (in_array(strtolower(pathinfo($background_image, PATHINFO_EXTENSION)), $image_extensions)) { - $image_source = 'file'; - } - else { - $image_source = 'folder'; - } - - // is source (file/folder) local or remote - if (substr($background_image, 0, 4) == 'http') { - $source_path = $background_image; - } - else if (substr($background_image, 0, 1) == '/') { // - // use project path as root - $source_path = PROJECT_PATH.$background_image; - } - else { - // use theme images/backgrounds folder as root - $source_path = PROJECT_PATH.'/themes/default/images/backgrounds/'.$background_image; - } - - } - else { - // not set, so use default backgrounds folder and images - $image_source = 'folder'; - $source_path = PROJECT_PATH.'/themes/default/images/backgrounds'; - } - - if ($image_source == 'folder') { - if (file_exists($_SERVER["DOCUMENT_ROOT"].$source_path)) { - // retrieve a random background image - $dir_list = opendir($_SERVER["DOCUMENT_ROOT"].$source_path); - $v_background_array = array(); - $x = 0; - while (false !== ($file = readdir($dir_list))) { - if ($file != "." AND $file != ".."){ - $new_path = $dir.'/'.$file; - $level = explode('/',$new_path); - if (in_array(strtolower(pathinfo($new_path, PATHINFO_EXTENSION)), $image_extensions)) { - $v_background_array[] = $new_path; - } - if ($x > 100) { break; }; - $x++; - } - } - if ($_SESSION['background_image'] == '' && sizeof($v_background_array) > 0) { - $_SESSION['background_image'] = PROJECT_PATH.$source_path.$v_background_array[array_rand($v_background_array, 1)]; - } - } - else { - $_SESSION['background_image'] = ''; - } - - } - else if ($image_source == 'file') { - $_SESSION['background_image'] = $source_path; - } - } - -// check for background color - else if ( - $background_colors[0] != '' || - $background_colors[1] != '' - ) { // background color 1 or 2 is enabled - - if ($background_colors[0] != '' && $background_colors[1] == '') { // use color 1 - $background_color = "background: ".$background_colors[0].";"; - } - else if ($background_colors[0] == '' && $background_colors[1] != '') { // use color 2 - $background_color = "background: ".$background_colors[1].";"; - } - else if ($background_colors[0] != '' && $background_colors[1] != '') { // vertical gradient - $background_color = "background: ".$background_colors[0].";\n"; - $background_color .= "background: -ms-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; - $background_color .= "background: -moz-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; - $background_color .= "background: -o-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; - $background_color .= "background: -webkit-gradient(linear, left top, left bottom, color-stop(0, ".$background_colors[0]."), color-stop(1, ".$background_colors[1]."));\n"; - $background_color .= "background: -webkit-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; - $background_color .= "background: linear-gradient(to bottom, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; - } - } - else { // default: white - $background_color = "background: #ffffff;\n"; - } -?> - - html { - height: 100%; - width: 100%; - } - - body { - z-index: 1; - position: absolute; - margin: 0; - padding: 0; - overflow: auto; - -ms-overflow-style: scrollbar; /* stops ie10+ from displaying auto-hiding scroll bar on top of the body content (the domain selector, specifically) */ - top: 0; - right: 0; - bottom: 0; - left: 0; - text-align: center; - - background-repeat: no-repeat; - background-attachment: fixed; - webkit-background-size:cover; - -moz-background-size:cover; - -o-background-size:cover; - background-size:cover; - } - - pre { - white-space: pre-wrap; - } - - div#footer { - display: inline-block; - width: 100%; - background: ; - text-align: center; - vertical-align: middle; - margin-bottom: 60px; - padding: 8px; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - } - - div#footer_login { - position: absolute; - left: 0; - right: 0; - bottom: 0; - width: 100%; - background: ; - text-align: center; - vertical-align: middle; - padding: 8px; - } - - .footer { - font-size: 11px; - font-family: arial; - line-height: 14px; - color: ; - white-space: nowrap; - } - - .footer > a:hover { - color: ; - } - -/* MENU: BEGIN ******************************************************************/ - - /* main menu container */ - .navbar { - - background-image: url(""); - background-position: 0px 0px; - background-repeat: repeat-x; - - background: ; - - -webkit-box-shadow: ; - -moz-box-shadow: ; - box-shadow: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - } - - /* main menu logo */ - .navbar-logo { - border: none; - height: 27px; - width: auto; - margin: 11px 0 0 7px; - padding-right: 13px; - cursor: pointer; - float: left; - display: inline; - } - - /* menu brand text */ - .navbar-header > div > a.navbar-brand { - color: ; - white-space: nowrap; - } - - .navbar-header > div > a.navbar-brand:hover { - color: ; - } - - /* main menu item */ - .navbar .navbar-nav > li > a, - .navbar .navbar-nav > li.current-menu-item > a { - font-family: ; - font-size: ; - color: ; - padding-right: 10px; - padding-left: 10px; - } - - .navbar .navbar-nav > li:hover > a, - .navbar .navbar-nav > li:focus > a, - .navbar .navbar-nav > li:active > a { - color: ; - background: - } - - .navbar .navbar-nav > li > a > span.glyphicon { - margin: 1px 2px 0 0; - } - - @media(min-width: 768px) { - .dropdown:hover .dropdown-menu { - display: block; - } - } - - /* sub menu container */ - .navbar-nav > li > .dropdown-menu { - margin-top: 0; - padding-top: 0; - padding-bottom: 10px; - - background: ; - -webkit-box-shadow: ; - -moz-box-shadow: ; - box-shadow: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - } - - /* sub menu item */ - .dropdown-menu > li > a { - font-family: ; - color: ; - font-size: ; - margin: 0; - padding: 3px 15px; - } - - .dropdown-menu > li > a:hover, - .dropdown-menu > li > a:focus, - .dropdown-menu > li > a:active { - color: ; - background: ; - outline: none; - } - - .dropdown-menu > li > a > span.glyphicon { - display: inline-block; - font-size: 8pt; - margin: 0 0 8px 8px; - opacity: 0.30; - text-align: top; - } - - /* domain name/selector */ - a.domain_selector_domain { - display: inline-block; - white-space: nowrap; - font-size: 9.5pt; - color: ; - padding: 16px 0 14px 0; - } - - a.domain_selector_domain:hover, - a.domain_selector_domain:focus, - a.domain_selector_domain:active { - color: ; - text-decoration: none; - } - - /* logout icon */ - a.logout_icon { - display: inline-block; - color: ; - font-size: 11pt; - padding: 16px 10px 13px 10px; - margin-left: 10px; - } - - a.logout_icon:hover, - a.logout_icon:focus, - a.logout_icon:active { - color: ; - text-decoration: none; - } - - /* xs menu toggle button */ - .navbar-inverse .navbar-toggle { - background: transparent; - border: none; - padding: 16px 7px 17px 20px; - margin: 0 8px; - } - - .navbar-inverse .navbar-toggle:hover, - .navbar-inverse .navbar-toggle:focus, - .navbar-inverse .navbar-toggle:active { - background: transparent; - } - - .navbar-inverse .navbar-toggle .icon-bar { - background: ; - } - - .navbar-inverse .navbar-toggle:hover > .icon-bar { - background: ; - } - -/* BUTTONS ********************************************************************/ - - /* buttons */ - input.btn, - input.button { - height: ; - padding: ; - border: solid ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - - background: ; - background-image: -ms-linear-gradient(top, 0%, 100%); - background-image: -moz-linear-gradient(top, 0%, 100%); - background-image: -o-linear-gradient(top, 0%, 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); - background-image: -webkit-linear-gradient(top, 0%, 100%); - background-image: linear-gradient(to bottom, 0%, 100%); - - font-family: ; - text-align: center; - text-transform: uppercase; - color: ; - font-weight: ; - font-size: ; - vertical-align: middle; - } - - input.btn:hover, - input.btn:active, - input.btn:focus, - input.button:hover, - input.button:active, - input.button:focus { - cursor: pointer; - border-color: ; - - background: ; - background-image: -ms-linear-gradient(top, 0%, 100%); - background-image: -moz-linear-gradient(top, 0%, 100%); - background-image: -o-linear-gradient(top, 0%, 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); - background-image: -webkit-linear-gradient(top, 0%, 100%); - background-image: linear-gradient(to bottom, 0%, 100%); - - color: ; - } - - /* default bootstrap buttons - not currently used */ - button.btn-default { - font-family: Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif; - padding: 4px 8px; - color: #fff; - font-weight: bold; - font-size: 8pt; - border: 1px solid #26242a; - background: #3e3e3e; - background-image: -moz-linear-gradient(top, #000 0%, #3e3e3e 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.0, #000), color-stop(1, #3e3e3e)); - -moz-border-radius: 3px; - -webkit-border-radius: 3px; - -khtml-border-radius: 3px; - border-radius: 3px; - text-align: center; - text-transform: uppercase; - text-shadow: 0px 0px 1px rgba(0,0,0,0.9); - opacity: 0.9; - -moz-opacity: 0.9; - } - - button.btn-default:hover, - button.btn-default:active, - button.btn-default:focus { - cursor: pointer; - color: #ffffff; - border: 1px solid #26242a; - box-shadow: 0 0 5px #cddaf0; - -webkit-box-shadow: 0 0 5px #cddaf0; - -moz-box-shadow: 0 0 5px #cddaf0; - opacity: 1.0; - -moz-opacity: 1.0; - } - - /* control icons (must be defined after the default bootstrap buttons) */ - button.list_control_icon, - button.list_control_icon_disabled { - width: 24px; - height: 24px; - padding: 2px; - margin: 1px; - border: solid ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - - background: ; - background-image: -ms-linear-gradient(top, 0%, 100%); - background-image: -moz-linear-gradient(top, 0%, 100%); - background-image: -o-linear-gradient(top, 0%, 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); - background-image: -webkit-linear-gradient(top, 0%, 100%); - background-image: linear-gradient(to bottom, 0%, 100%); - - color: ; - font-size: 10.5pt; - text-align: center; - -moz-opacity: 0.3; - opacity: 0.3; - } - - button.list_control_icon:hover, - button.list_control_icon:active, - button.list_control_icon:focus { - cursor: pointer; - border-color: ; - - background: ; - background-image: -ms-linear-gradient(top, 0%, 100%); - background-image: -moz-linear-gradient(top, 0%, 100%); - background-image: -o-linear-gradient(top, 0%, 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); - background-image: -webkit-linear-gradient(top, 0%, 100%); - background-image: linear-gradient(to bottom, 0%, 100%); - - color: ; - -moz-opacity: 1.0; - opacity: 1.0; - } - -/* ICONS *********************************************************************/ - - span.icon_glyphicon_body { - width: 16px; - height: 16px; - color: ; - border: 0; - } - - span.icon_glyphicon_body:hover { - color: ; - } - -/* DOMAIN SELECTOR ***********************************************************/ - - #domains_container { - z-index: 99990; - position: absolute; - right: 0; - top: 0; - bottom: 0; - width: 360px; - overflow: hidden; - display: none; - } - - #domains_block { - position: absolute; - right: -300px; - top: 0; - bottom: 0; - width: 340px; - padding: 20px 20px 100px 20px; - font-family: arial, san-serif; - font-size: 10pt; - overflow: hidden; - background-color: #fff; - -webkit-box-shadow: ; - -moz-box-shadow: ; - box-shadow: ; - } - - #domains_header { - position: relative; - width: 300px; - height: 55px; - margin-bottom: 20px; - text-align: left; - } - - #domains_list { - position: relative; - overflow: auto; - width: 300px; - height: 100%; - padding: 1px; - background-color: #fff; - border: 1px solid #a4aebf; - } - - div.domains_list_item { - text-align: left; - border-bottom: 1px solid #c5d1e5; - padding: 5px 8px 8px 8px; - overflow: hidden; - white-space: nowrap; - cursor: pointer; - } - - div.domains_list_item span.domain_list_item_description { - color: #999; - font-size: 11px; - } - - div.domains_list_item:hover a, - div.domains_list_item:hover span { - color: #5082ca; - } - -/* DOMAIN SELECTOR: END ********************************************************/ - - #default_login { - position: fixed; - top: 50%; - left: 50%; - -moz-transform: translate(-50%, -50%); - -webkit-transform: translate(-50%, -50%); - -khtml-transform: translate(-50%, -50%); - transform: translate(-50%, -50%); - padding: ; - - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - - - - -webkit-box-shadow: ; - -moz-box-shadow: ; - box-shadow: ; - } - - #login_logo { - width: 250px; - height: auto; - } - - a.login_link { - color: ; - font-size: ; - font-family: ; - text-decoration: none; - } - - a.login_link:hover { - color: ; - cursor: pointer; - text-decoration: underline; - } - - - - #main_content { - display: inline-block; - width: 100%; - 0 || !$default_login) - && - (isset($background_images) || $background_colors[0] != '' || $background_colors[1] != '') - ) { ?> - background: ; - background-attachment: fixed; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - -webkit-box-shadow: ; - -moz-box-shadow: ; - box-shadow: ; - padding: 20px; - padding: 5px 10px 10px 10px; - text-align: left; - color: ; - font-size: ; - font-family: ; - } - - /* default body padding */ - .container-fluid { - width: 90%; - } - - /* maximize viewport usage on xs displays */ - @media(min-width: 0px) and (max-width: 767px) { - .container-fluid { - width: 100%; - } - - #main_content { - padding: 8px; - } - } - -/* GENERAL ELEMENTS *****************************************************************/ - - img { - border: none; - } - - .title, b { - color: ; - font-size: ; - font-family: ; - font-weight: bold - } - - a { - color: ; - text-decoration: none; - } - - a:hover { - color: ; - text-decoration: underline; - } - - form { - margin: 0; - } - - /* style placeholder text (for browsers that support the attribute) - note: can't stack, each must be seperate */ - - ::-webkit-input-placeholder { color: } /* chrome/opera/safari */ - ::-moz-placeholder { color: } /* ff 19+ */ - :-moz-placeholder { color: } /* ff 18- */ - :-ms-input-placeholder { color: } /* ie 10+ */ - ::placeholder { color: } /* official standard */ - - select.txt, - textarea.txt, - input[type=text].txt, - input[type=number].txt, - input[type=password].txt, - label.txt, - select.formfld, - textarea.formfld, - input[type=text].formfld, - input[type=number].formfld, - input[type=password].formfld, - label.formfld { - font-family: ; - font-size: ; - color: ; - text-align: left; - height: 28px; - padding: 4px 6px; - margin: 1px; - border-width: ; - border-style: solid; - border-color: ; - background: ; - 0) { - echo '-webkit-box-shadow: '.implode(', ', $shadows).";\n"; - echo '-moz-box-shadow: '.implode(', ', $shadows).";\n"; - echo 'box-shadow: '.implode(', ', $shadows).";\n"; - } - unset($shadows); - ?> - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - vertical-align: middle; - } - - textarea.txt, - input[type=text].txt, - input[type=number].txt, - input[type=password].txt, - textarea.formfld, - input[type=text].formfld, - input[type=number].formfld, - input[type=password].formfld { - transition: width 0.25s; - -moz-transition: width 0.25s; - -webkit-transition: width 0.25s; - max-width: 500px; - } - - select.txt, - select.formfld { - padding: 4px 2px; - } - - textarea.txt:hover, - input[type=text].txt:hover, - input[type=number].txt:hover, - input[type=password].txt:hover, - label.txt:hover, - textarea.formfld:hover, - input[type=text].formfld:hover, - input[type=number].formfld:hover, - input[type=password].formfld:hover, - label.formfld:hover { - border-color: ; - } - - textarea.txt:focus, - input[type=text].txt:focus, - input[type=number].txt:focus, - input[type=password].txt:focus, - label.txt:focus, - textarea.formfld:focus, - input[type=text].formfld:focus, - input[type=number].formfld:focus, - input[type=password].formfld:focus, - label.formfld:focus { - border-color: ; - /* first clear */ - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - - - -webkit-box-shadow: ; - -moz-box-shadow: ; - box-shadow: ; - - } - - input.login { - font-family: ; - font-size: ; - color: ; - border-width: ; - border-color: ; - background: ; - /* first clear */ - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - 0) { - echo '-webkit-box-shadow: '.implode(', ', $shadows).";\n"; - echo '-moz-box-shadow: '.implode(', ', $shadows).";\n"; - echo 'box-shadow: '.implode(', ', $shadows).";\n"; - } - unset($shadows); - ?> - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - } - - input.login:hover { - border-color: ; - } - - input.login:focus { - border-color: ; - /* first clear */ - -webkit-box-shadow: none; - -moz-box-shadow: none; - box-shadow: none; - - - -webkit-box-shadow: ; - -moz-box-shadow: ; - box-shadow: ; - - } - - /* style placeholder text (for browsers that support the attribute) - note: can't stack, each must be seperate */ - - input.login::-webkit-input-placeholder { color: } /* chrome/opera/safari */ - input.login::-moz-placeholder { color: } /* ff 19+ */ - input.login:-moz-placeholder { color: } /* ff 18- */ - input.login:-ms-input-placeholder { color: } /* ie 10+ */ - input.login::placeholder { color: } /* official standard */ - - input[type=password].formfld_highlight_bad, - input[type=password].formfld_highlight_bad:hover, - input[type=password].formfld_highlight_bad:active, - input[type=password].formfld_highlight_bad:focus { - border-color: #aa2525; - -webkit-box-shadow: 0 0 3px #aa2525 inset; - -moz-box-shadow: 0 0 3px #aa2525 inset; - box-shadow: 0 0 3px #aa2525 inset; - } - - input[type=password].formfld_highlight_good, - input[type=password].formfld_highlight_good:hover, - input[type=password].formfld_highlight_good:active, - input[type=password].formfld_highlight_good:focus { - border-color: #2fb22f; - -webkit-box-shadow: 0 0 3px #2fb22f inset; - -moz-box-shadow: 0 0 3px #2fb22f inset; - box-shadow: 0 0 3px #2fb22f inset; - } - - /* removes spinners (increment/decrement controls) inside input fields */ - input[type=number] { -moz-appearance: textfield; } - ::-webkit-inner-spin-button { -webkit-appearance: none; } - ::-webkit-outer-spin-button { -webkit-appearance: none; } - - /* disables text input clear 'x' in IE 10+, slows down autosizeInput jquery script */ - input[type=text]::-ms-clear { - display: none; - } - - input.fileinput { - padding: 1px; - display: inline; - } - - textarea { - min-height: 75px; - } - - label { - font-weight: normal; - vertical-align: middle; - } - - label input[type=checkbox], - label input[type=radio] { - vertical-align: -2px; - margin: 0; - padding: 0; - } - - span.playback_progress_bar { - background-color: #b90004; - width: 17px; - height: 4px; - margin-bottom: 3px; - display: block; - -moz-border-radius: 0 0 6px 6px; - -webkit-border-radius: 0 0 6px 6px; - -khtml-border-radius: 0 0 6px 6px; - border-radius: 0 0 6px 6px; - -webkit-box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); - -moz-box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); - box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); - } - - td.playback_progress_bar_background { - padding: 0; - border-bottom: none; - background-image: -ms-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); - background-image: -moz-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); - background-image: -o-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(0,0,0,0.15)), color-stop(1, transparent)); - background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); - background-image: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, transparent 100%); - overflow: hidden; - } - - div.pwstrength_progress { - display: none; - } - - div.pwstrength_progress > div.progress { - max-width: 200px; - height: 6px; - margin: 1px 0 0 1px; - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - } - - div.pwstrength_progress_password_reset > div.progress { - margin: 0 auto 4px auto; - width: 200px; - max-width: 200px; - background: ; - border-width: ; - border-color: ; - } - -/* TABLES *****************************************************************/ - - table { - border-collapse: separate; - border-spacing: 0; - } - - th { - padding: 4px 7px 4px 0; - padding: 4px 7px; - text-align: left; - color: ; - font-size: ; - font-family: ; - background: ; - border-bottom: 1px solid ; - } - - th a, th a:visited, th a:active { - color: ; - text-decoration: none; - } - - th a:hover { - color: ; - text-decoration: underline; - } - - td { - color: ; - font-size: ; - font-family: ; - } - - table.tr_hover tr { - cursor: default; - } - - table.tr_hover tr:hover td, - table.tr_hover tr:hover td a { - color: ; - cursor: pointer; - } - - table.tr_hover tr.tr_link_void:hover td { - color: ; - cursor: default; - } - - table.tr_hover tr td.tr_link_void { - cursor: default; - } - - td.list_control_icons { - width: 52px; - padding: none; - padding-left: 2px; - text-align: right; - vertical-align: top; - white-space: nowrap; - } - - td.list_control_icon { - width: 26px; - padding: none; - padding-left: 2px; - text-align: right; - vertical-align: top; - white-space: nowrap; - } - - /* form: label/field format */ - .vncell { /* form_label */ - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - border-right: 3px solid ; - border-bottom: 1px solid ; - padding: ; - text-align: right; - color: ; - font-family: ; - font-size: ; - vertical-align: top; - } - - .vncellreq { /* form_label_required */ - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - border-right: 3px solid ; - border-bottom: 1px solid ; - padding: ; - text-align: right; - color: ; - font-family: ; - font-size: ; - font-weight: ; - vertical-align: top; - } - - .vtable { /* form_field */ - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - border-bottom: 1px solid ; - padding: ; - text-align: left; - vertical-align: middle; - color: ; - font-family: ; - font-size: ; - } - - /* form: heading/row format */ - .vncellcol { /* form_heading */ - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - border-bottom: 3px solid ; - padding: ; - text-align: left; - color: ; - font-family: ; - font-size: ; - } - - .vncellcolreq { /* form_heading_required */ - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - border-bottom: 3px solid ; - padding: ; - text-align: left; - color: ; - font-family: ; - font-size: ; - font-weight: ; - } - - .vtablerow { /* form_row */ - - height: px; - background: ; - - -moz-border-radius: ; - -webkit-border-radius: ; - -khtml-border-radius: ; - border-radius: ; - - border-bottom: 1px solid ; - padding: ; - text-align: left; - vertical-align: middle; - color: ; - font-family: ; - font-size: ; - } - - .row_style0 { - border-bottom: 1px solid ; - background: ; - color: ; - font-family: ; - font-size: ; - text-align: left; - padding: 4px 7px; - } - - .row_style1 { - border-bottom: 1px solid ; - background: ; - color: ; - font-family: ; - font-size: ; - text-align: left; - padding: 4px 7px; - } - - .row_style_slim { - padding-top: 0; - padding-bottom: 0; - white-space: nowrap; - } - - .row_stylebg { - border-bottom: 1px solid ; - background: ; - color: ; - font-family: ; - font-size: ; - text-align: left; - padding: 4px 7px; - } - -/* RESPONSE MESSAGES *******************************************************/ - - #message_container { - z-index: 99998; - position: absolute; - top: -80px; - left: 0; - right: 0; - filter: alpha(opacity=0); - opacity: 0; - -moz-opacity:0; - -khtml-opacity: 0; - padding: 15px 0; - } - - #message_text { - z-index: 99999; - position: absolute; - top: -80px; - left: 0; - right: 0; - filter: alpha(opacity=0); - opacity: 0; - -moz-opacity:0; - -khtml-opacity: 0; - margin: 0 auto; - vertical-align: middle; - padding: 15px 0; - text-align: center; - font-family: arial, san-serif; - font-size: 10pt; - } - - .message_container_mood_default { - background: ; - } - - .message_container_mood_negative { - background: ; - } - - .message_container_mood_alert { - background: ; - } - - .message_text_mood_default { - color: ; - } - - .message_text_mood_negative { - color: ; - } - - .message_text_mood_alert { - color: ; - } - -/* MESSAGES STACK *******************************************************/ - - #messages_container { - z-index: 99998; - position: absolute; - top: 0; - left: 0; - right: 0; - padding: 0; - } - - .message_text { - z-index: 99999; - margin: 0 auto; - padding: 0.5em 0; - text-align: center; - font-family: arial, san-serif; - font-size: 10pt; - display: block; - border-bottom: solid 1px; - } - - .message_mood_default { - color: ; - background: ; - border-bottom-color: ; - } - - .message_mood_negative { - color: ; - background: ; - border-bottom-color: ; - } - - .message_mood_alert { - color: ; - background: ; - border-bottom-color: ; - } - -/* OPERATOR PANEL ****************************************************************/ - - div.op_ext { - float: left; - width: 235px; - margin: 0px 8px 8px 0px; - padding: 0px; - border-style: solid; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; - -webkit-box-shadow: 0 0 3px #e5e9f0; - -moz-box-shadow: 0 0 3px #e5e9f0; - box-shadow: 0 0 3px #e5e9f0; - border-width: 1px 3px; - border-color: #b9c5d8 #c5d1e5; - background-color: #e5eaf5; - cursor: default; - } - - div.op_state_active { - background-color: #baf4bb; - border-width: 1px 3px; - border-color: #77d779; - } - - div.op_state_ringing { - background-color: #a8dbf0; - border-width: 1px 3px; - border-color: #41b9eb; - } - - table.op_ext { - width: 100%; - height: 60px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; - background-color: #e5eaf5; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; - } - - td.op_ext_icon { - vertical-align: middle; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; - } - - img.op_ext_icon { - cursor: move; - width: 39px; - height: 42px; - border: none; - } - - td.op_ext_info { - text-align: left; - vertical-align: top; - font-family: arial; - font-size: 10px; - overflow: auto; - width: 100%; - padding: 3px 5px 3px 7px; - -moz-border-radius: 5px; - -webkit-border-radius: 5px; - border-radius: 5px; - background-color: #f0f2f6; - } - - td.op_state_ringing { - background-color: #d1f1ff; - } - - td.op_state_active { - background-color: #e1ffe2; - } - - table.op_state_ringing { - background-color: #a8dbf0; - } - - table.op_state_active { - background-color: #baf4bb; - } - - .op_user_info { - font-family: arial; - font-size: 10px; - display: inline-block; - } - - .op_user_info strong { - color: #3164AD; - } - - .op_caller_info { - display: block; - margin-top: 4px; - font-family: arial; - font-size: 10px; - } - - .op_call_info { - display: inline-block; - padding: 0px; - font-family: arial; - font-size: 10px; - } - - #op_btn_status_available { - background-image: -moz-linear-gradient(top, #8ec989 0%, #2d9c38 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #8ec989), color-stop(1, #2d9c38)); - background-color: #2d9c38; - border: 1px solid #006200; - } - - #op_btn_status_available_on_demand { - background-image: -moz-linear-gradient(top, #abd0aa 0%, #629d62 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #abd0aa), color-stop(1, #629d62)); - background-color: #629d62; - border: 1px solid #619c61; - } - - #op_btn_status_on_break { - background-image: -moz-linear-gradient(top, #ddc38b 0%, #be8e2c 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ddc38b), color-stop(1, #be8e2c)); - background-color: #be8e2c; - border: 1px solid #7d1b00; - } - - #op_btn_status_do_not_disturb { - background-image: -moz-linear-gradient(top, #cc8984 0%, #960d10 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cc8984), color-stop(1, #960d10)); - background-color: #960d10; - border: 1px solid #5b0000; - } - - #op_btn_status_logged_out { - background-image: -moz-linear-gradient(top, #cacac9 0%, #8d8d8b 100%); - background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cacac9), color-stop(1, #8d8d8b)); - background-color: #8d8d8b; - border: 1px solid #5d5f5a; - } - -/* DASHBOARD **********************************************************************/ - - /* login message */ - div.login_message { - border: 1px solid #bae0ba; - background-color: #eeffee; - -webkit-border-radius: 3px; - -moz-border-radius: 3px; - border-radius: 3px; - padding: 20px; - margin-bottom: 15px; - } - - /* hud boxes */ - div.hud_box { - height: auto; - vertical-align: top; - text-align: center; - - background: ; - background-image: -ms-linear-gradient(left, 0%, 30%, 70%, 100%); - background-image: -moz-linear-gradient(left, 0%, 30%, 70%, 100%); - background-image: -o-linear-gradient(left, 0%, 30%, 70%, 100%); - background-image: -webkit-gradient(linear, left, right, color-stop(0, ), color-stop(0.30, ), color-stop(0.70, ), color-stop(1, )); - background-image: -webkit-linear-gradient(left, 0%, 30%, 70%, 100%); - background-image: linear-gradient(to right, 0%, 30%, 70%, 100%); - - - -webkit-border-radius: ; - -moz-border-radius: ; - border-radius: ; - - border: 1px solid ; - overflow: hidden; - margin: -1px; - } - - div.hud_box:hover { - border: 1px solid ; - } - - span.hud_title { - display: block; - width: 100%; - font-family: ; - text-shadow: 0px 1px 2px ; - letter-spacing: -0.02em; - color: ; - font-size: ; - - line-height: 0) ? str_replace($font_size_number, $line_height_number, $font_size) : '26.25pt'; ?>; - text-align: center; - background: ; - border-bottom: 1px solid ; - overflow: hidden; - } - - span.hud_title:hover { - color: ; - text-shadow: 0px 1px 2px ; - background: ; - cursor: pointer; - } - - span.hud_stat { - display: block; - clear: both; - text-align: center; - text-shadow: 0px 2px 2px ; - width: 100%; - color: ; - font-family: ; - font-size: ; - - line-height: 0) ? str_replace($font_size_number, $line_height_number, $font_size) : '77pt'; ?>; - font-weight: normal; - background: ; - border-top: 1px solid ; - overflow: hidden; - } - - span.hud_stat:hover { - color: ; - text-shadow: 0px 2px 2px ; - background: ; - cursor: pointer; - } - - span.hud_stat_title { - display: block; - clear: both; - width: 100%; - height: 30px; - cursor: default; - text-align: center; - text-shadow: 0px 1px 1px ; - color: ; - font-size: ; - padding-top: 4px; - white-space: nowrap; - letter-spacing: -0.02em; - font-weight: normal; - font-family: ; - background: ; - border-bottom: 1px solid ; - margin: 0; - overflow: hidden; - } - - span.hud_stat:hover + span.hud_stat_title { - color: ; - text-shadow: 0px 1px 1px ; - background: ; - } - - div.hud_details { - -moz-box-shadow: inset 0 7px 7px -7px , inset 0 -8px 12px -10px ; - -webkit-box-shadow: inset 0 7px 7px -7px , inset 0 -8px 12px -10px ; - box-shadow: inset 0 7px 7px -7px , inset 0 -8px 12px -10px ; - padding-top: 3px; - padding-bottom: 15px; - } - - @media(min-width: 0px) and (max-width: 1199px) { - div.hud_details { - display: none; - height: auto; - } - } - - @media(min-width: 1200px) { - div.hud_details { - height: 350px; - display: block; - } - } - - th.hud_heading { - text-align: left; - font-size: ; - font-family: - color: ; - } - - td.hud_text { - font-size: ; - color: ; - text-align: left; - vertical-align: middle; - } - - span.hud_expander { - display: block; - clear: both; - background: ; - padding: 4px 0; - text-align: center; - width: 100%; - height: 25px; - font-size: 13px; - line-height: 5px; - color: ; - border-top: 1px solid ; - } - - span.hud_expander:hover { - color: ; - background: ; - cursor: pointer; - } - -/* PLUGINS ********************************************************************/ - - /* bootstrap colorpicker */ - .colorpicker-2x .colorpicker-saturation { - width: 200px; - height: 200px; - } - - .colorpicker-2x .colorpicker-hue, - .colorpicker-2x .colorpicker-alpha { - width: 30px; - height: 200px; - } - - .colorpicker-2x .colorpicker-color, - .colorpicker-2x .colorpicker-color div{ - height: 30px; - } - - /* jquery ui autocomplete styles */ - .ui-widget { - margin: 0px; - padding: 0px; - } - - .ui-autocomplete { - cursor: default; - position: absolute; - max-height: 200px; - overflow-y: auto; - overflow-x: hidden; - white-space: nowrap; - width: auto; - border: 1px solid #c0c0c0; - } - - .ui-menu, .ui-menu .ui-menu-item { - width: 350px; - } - - .ui-menu .ui-menu-item a { - text-decoration: none; - cursor: pointer; - border-color: #fff; - background-image: none; - background-color: #fff; - white-space: nowrap; - font-family: arial; - font-size: 12px; - color: #444; - } - - .ui-menu .ui-menu-item a:hover { - color: #5082ca; - border: 1px solid white; - background-image: none; - background-color: #fff; - } + 0) { + foreach ($_SESSION['theme'] as $subcategory => $type) { + if (substr_count($subcategory, '_font') > 0) { + $font_string = $type['text']; + if ($font_string != '') { + if (substr_count($font_string, ',') > 0) { + $tmp_array = explode(',', $font_string); + } + else { + $tmp_array[] = $font_string; + } + foreach ($tmp_array as $font_name) { + $font_name = trim($font_name, "'"); + $font_name = trim($font_name, '"'); + $font_name = trim($font_name); + $fonts[] = $font_name; + } + if (sizeof($fonts) == 1 && strtolower($fonts[0]) != 'arial') { $fonts[] = 'Arial'; } //fall back font + $_SESSION['theme'][$subcategory]['text'] = "'".implode("','", $fonts)."'"; + } + } + unset($fonts, $tmp_array); + } + } + +//determine which background image/color settings to use (login or standard) + $background_images_enabled = false; + if ($default_login) { + //try using login background images/colors + if (isset($_SESSION['theme']) && $_SESSION['theme']['login_background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['login_background_image'])) { + $background_images_enabled = true; + $background_images = $_SESSION['theme']['login_background_image']; + } + else if ($_SESSION['theme']['login_background_color'][0] != '' || $_SESSION['theme']['login_background_color'][1] != '') { + $background_colors[0] = $_SESSION['theme']['login_background_color'][0]; + $background_colors[1] = $_SESSION['theme']['login_background_color'][1]; + } + else { + //otherwise, use standard background images/colors + if ($_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) { + $background_images_enabled = true; + $background_images = $_SESSION['theme']['background_image']; + } + else { + $background_colors[0] = $_SESSION['theme']['background_color'][0]; + $background_colors[1] = $_SESSION['theme']['background_color'][1]; + } + } + } + else { + //use standard background images/colors + if (isset($_SESSION['theme']) && isset($_SESSION['theme']['background_image_enabled']) && $_SESSION['theme']['background_image_enabled']['boolean'] == 'true' && is_array($_SESSION['theme']['background_image'])) { + $background_images_enabled = true; + $background_images = $_SESSION['theme']['background_image']; + } + else { + $background_colors[0] = $_SESSION['theme']['background_color'][0]; + $background_colors[1] = $_SESSION['theme']['background_color'][1]; + } + } + +//check for background image + if ($background_images_enabled) { + // background image is enabled + $image_extensions = array('jpg','jpeg','png','gif'); + + if (count($background_images) > 0) { + + if ((!isset($_SESSION['background_image'])) or strlen($_SESSION['background_image']) == 0) { + $_SESSION['background_image'] = $background_images[array_rand($background_images)]; + $background_image = $_SESSION['background_image']; + } + + // background image(s) specified, check if source is file or folder + if (in_array(strtolower(pathinfo($background_image, PATHINFO_EXTENSION)), $image_extensions)) { + $image_source = 'file'; + } + else { + $image_source = 'folder'; + } + + // is source (file/folder) local or remote + if (substr($background_image, 0, 4) == 'http') { + $source_path = $background_image; + } + else if (substr($background_image, 0, 1) == '/') { // + // use project path as root + $source_path = PROJECT_PATH.$background_image; + } + else { + // use theme images/backgrounds folder as root + $source_path = PROJECT_PATH.'/themes/default/images/backgrounds/'.$background_image; + } + + } + else { + // not set, so use default backgrounds folder and images + $image_source = 'folder'; + $source_path = PROJECT_PATH.'/themes/default/images/backgrounds'; + } + + if ($image_source == 'folder') { + if (file_exists($_SERVER["DOCUMENT_ROOT"].$source_path)) { + // retrieve a random background image + $dir_list = opendir($_SERVER["DOCUMENT_ROOT"].$source_path); + $v_background_array = array(); + $x = 0; + while (false !== ($file = readdir($dir_list))) { + if ($file != "." AND $file != ".."){ + $new_path = $dir.'/'.$file; + $level = explode('/',$new_path); + if (in_array(strtolower(pathinfo($new_path, PATHINFO_EXTENSION)), $image_extensions)) { + $v_background_array[] = $new_path; + } + if ($x > 100) { break; }; + $x++; + } + } + if ($_SESSION['background_image'] == '' && sizeof($v_background_array) > 0) { + $_SESSION['background_image'] = PROJECT_PATH.$source_path.$v_background_array[array_rand($v_background_array, 1)]; + } + } + else { + $_SESSION['background_image'] = ''; + } + + } + else if ($image_source == 'file') { + $_SESSION['background_image'] = $source_path; + } + } + +// check for background color + else if ( + $background_colors[0] != '' || + $background_colors[1] != '' + ) { // background color 1 or 2 is enabled + + if ($background_colors[0] != '' && $background_colors[1] == '') { // use color 1 + $background_color = "background: ".$background_colors[0].";"; + } + else if ($background_colors[0] == '' && $background_colors[1] != '') { // use color 2 + $background_color = "background: ".$background_colors[1].";"; + } + else if ($background_colors[0] != '' && $background_colors[1] != '') { // vertical gradient + $background_color = "background: ".$background_colors[0].";\n"; + $background_color .= "background: -ms-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; + $background_color .= "background: -moz-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; + $background_color .= "background: -o-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; + $background_color .= "background: -webkit-gradient(linear, left top, left bottom, color-stop(0, ".$background_colors[0]."), color-stop(1, ".$background_colors[1]."));\n"; + $background_color .= "background: -webkit-linear-gradient(top, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; + $background_color .= "background: linear-gradient(to bottom, ".$background_colors[0]." 0%, ".$background_colors[1]." 100%);\n"; + } + } + else { // default: white + $background_color = "background: #ffffff;\n"; + } +?> + + html { + height: 100%; + width: 100%; + } + + body { + z-index: 1; + position: absolute; + margin: 0; + padding: 0; + overflow: auto; + -ms-overflow-style: scrollbar; /* stops ie10+ from displaying auto-hiding scroll bar on top of the body content (the domain selector, specifically) */ + top: 0; + right: 0; + bottom: 0; + left: 0; + text-align: center; + + background-repeat: no-repeat; + background-attachment: fixed; + webkit-background-size:cover; + -moz-background-size:cover; + -o-background-size:cover; + background-size:cover; + } + + pre { + white-space: pre-wrap; + } + + div#footer { + display: inline-block; + width: 100%; + background: ; + text-align: center; + vertical-align: middle; + margin-bottom: 60px; + padding: 8px; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + } + + div#footer_login { + position: absolute; + left: 0; + right: 0; + bottom: 0; + width: 100%; + background: ; + text-align: center; + vertical-align: middle; + padding: 8px; + } + + .footer { + font-size: 11px; + font-family: arial; + line-height: 14px; + color: ; + white-space: nowrap; + } + + .footer > a:hover { + color: ; + } + +/* MENU: BEGIN ******************************************************************/ + + /* main menu container */ + .navbar { + + background-image: url(""); + background-position: 0px 0px; + background-repeat: repeat-x; + + background: ; + + -webkit-box-shadow: ; + -moz-box-shadow: ; + box-shadow: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + } + + /* main menu logo */ + .navbar-logo { + border: none; + height: 27px; + width: auto; + margin: 11px 0 0 7px; + padding-right: 13px; + cursor: pointer; + float: left; + display: inline; + } + + /* menu brand text */ + .navbar-header > div > a.navbar-brand { + color: ; + white-space: nowrap; + } + + .navbar-header > div > a.navbar-brand:hover { + color: ; + } + + /* main menu item */ + .navbar .navbar-nav > li > a, + .navbar .navbar-nav > li.current-menu-item > a { + font-family: ; + font-size: ; + color: ; + padding-right: 10px; + padding-left: 10px; + } + + .navbar .navbar-nav > li:hover > a, + .navbar .navbar-nav > li:focus > a, + .navbar .navbar-nav > li:active > a { + color: ; + background: + } + + .navbar .navbar-nav > li > a > span.glyphicon { + margin: 1px 2px 0 0; + } + + @media(min-width: 768px) { + .dropdown:hover .dropdown-menu { + display: block; + } + } + + /* sub menu container */ + .navbar-nav > li > .dropdown-menu { + margin-top: 0; + padding-top: 0; + padding-bottom: 10px; + + background: ; + -webkit-box-shadow: ; + -moz-box-shadow: ; + box-shadow: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + } + + /* sub menu item */ + .dropdown-menu > li > a { + font-family: ; + color: ; + font-size: ; + margin: 0; + padding: 3px 15px; + } + + .dropdown-menu > li > a:hover, + .dropdown-menu > li > a:focus, + .dropdown-menu > li > a:active { + color: ; + background: ; + outline: none; + } + + .dropdown-menu > li > a > span.glyphicon { + display: inline-block; + font-size: 8pt; + margin: 0 0 8px 8px; + opacity: 0.30; + text-align: top; + } + + /* domain name/selector */ + a.domain_selector_domain { + display: inline-block; + white-space: nowrap; + font-size: 9.5pt; + color: ; + padding: 16px 0 14px 0; + } + + a.domain_selector_domain:hover, + a.domain_selector_domain:focus, + a.domain_selector_domain:active { + color: ; + text-decoration: none; + } + + /* logout icon */ + a.logout_icon { + display: inline-block; + color: ; + font-size: 11pt; + padding: 16px 10px 13px 10px; + margin-left: 10px; + } + + a.logout_icon:hover, + a.logout_icon:focus, + a.logout_icon:active { + color: ; + text-decoration: none; + } + + /* xs menu toggle button */ + .navbar-inverse .navbar-toggle { + background: transparent; + border: none; + padding: 16px 7px 17px 20px; + margin: 0 8px; + } + + .navbar-inverse .navbar-toggle:hover, + .navbar-inverse .navbar-toggle:focus, + .navbar-inverse .navbar-toggle:active { + background: transparent; + } + + .navbar-inverse .navbar-toggle .icon-bar { + background: ; + } + + .navbar-inverse .navbar-toggle:hover > .icon-bar { + background: ; + } + +/* BUTTONS ********************************************************************/ + + /* buttons */ + input.btn, + input.button { + height: ; + padding: ; + border: solid ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + + background: ; + background-image: -ms-linear-gradient(top, 0%, 100%); + background-image: -moz-linear-gradient(top, 0%, 100%); + background-image: -o-linear-gradient(top, 0%, 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); + background-image: -webkit-linear-gradient(top, 0%, 100%); + background-image: linear-gradient(to bottom, 0%, 100%); + + font-family: ; + text-align: center; + text-transform: uppercase; + color: ; + font-weight: ; + font-size: ; + vertical-align: middle; + } + + input.btn:hover, + input.btn:active, + input.btn:focus, + input.button:hover, + input.button:active, + input.button:focus { + cursor: pointer; + border-color: ; + + background: ; + background-image: -ms-linear-gradient(top, 0%, 100%); + background-image: -moz-linear-gradient(top, 0%, 100%); + background-image: -o-linear-gradient(top, 0%, 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); + background-image: -webkit-linear-gradient(top, 0%, 100%); + background-image: linear-gradient(to bottom, 0%, 100%); + + color: ; + } + + /* default bootstrap buttons - not currently used */ + button.btn-default { + font-family: Candara, Calibri, Segoe, "Segoe UI", Optima, Arial, sans-serif; + padding: 4px 8px; + color: #fff; + font-weight: bold; + font-size: 8pt; + border: 1px solid #26242a; + background: #3e3e3e; + background-image: -moz-linear-gradient(top, #000 0%, #3e3e3e 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0.0, #000), color-stop(1, #3e3e3e)); + -moz-border-radius: 3px; + -webkit-border-radius: 3px; + -khtml-border-radius: 3px; + border-radius: 3px; + text-align: center; + text-transform: uppercase; + text-shadow: 0px 0px 1px rgba(0,0,0,0.9); + opacity: 0.9; + -moz-opacity: 0.9; + } + + button.btn-default:hover, + button.btn-default:active, + button.btn-default:focus { + cursor: pointer; + color: #ffffff; + border: 1px solid #26242a; + box-shadow: 0 0 5px #cddaf0; + -webkit-box-shadow: 0 0 5px #cddaf0; + -moz-box-shadow: 0 0 5px #cddaf0; + opacity: 1.0; + -moz-opacity: 1.0; + } + + /* control icons (must be defined after the default bootstrap buttons) */ + button.list_control_icon, + button.list_control_icon_disabled { + width: 24px; + height: 24px; + padding: 2px; + margin: 1px; + border: solid ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + + background: ; + background-image: -ms-linear-gradient(top, 0%, 100%); + background-image: -moz-linear-gradient(top, 0%, 100%); + background-image: -o-linear-gradient(top, 0%, 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); + background-image: -webkit-linear-gradient(top, 0%, 100%); + background-image: linear-gradient(to bottom, 0%, 100%); + + color: ; + font-size: 10.5pt; + text-align: center; + -moz-opacity: 0.3; + opacity: 0.3; + } + + button.list_control_icon:hover, + button.list_control_icon:active, + button.list_control_icon:focus { + cursor: pointer; + border-color: ; + + background: ; + background-image: -ms-linear-gradient(top, 0%, 100%); + background-image: -moz-linear-gradient(top, 0%, 100%); + background-image: -o-linear-gradient(top, 0%, 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, ), color-stop(1, )); + background-image: -webkit-linear-gradient(top, 0%, 100%); + background-image: linear-gradient(to bottom, 0%, 100%); + + color: ; + -moz-opacity: 1.0; + opacity: 1.0; + } + +/* ICONS *********************************************************************/ + + span.icon_glyphicon_body { + width: 16px; + height: 16px; + color: ; + border: 0; + } + + span.icon_glyphicon_body:hover { + color: ; + } + +/* DOMAIN SELECTOR ***********************************************************/ + + #domains_container { + z-index: 99990; + position: absolute; + right: 0; + top: 0; + bottom: 0; + width: 360px; + overflow: hidden; + display: none; + } + + #domains_block { + position: absolute; + right: -300px; + top: 0; + bottom: 0; + width: 340px; + padding: 20px 20px 100px 20px; + font-family: arial, san-serif; + font-size: 10pt; + overflow: hidden; + background-color: #fff; + -webkit-box-shadow: ; + -moz-box-shadow: ; + box-shadow: ; + } + + #domains_header { + position: relative; + width: 300px; + height: 55px; + margin-bottom: 20px; + text-align: left; + } + + #domains_list { + position: relative; + overflow: auto; + width: 300px; + height: 100%; + padding: 1px; + background-color: #fff; + border: 1px solid #a4aebf; + } + + div.domains_list_item { + text-align: left; + border-bottom: 1px solid #c5d1e5; + padding: 5px 8px 8px 8px; + overflow: hidden; + white-space: nowrap; + cursor: pointer; + } + + div.domains_list_item span.domain_list_item_description { + color: #999; + font-size: 11px; + } + + div.domains_list_item:hover a, + div.domains_list_item:hover span { + color: #5082ca; + } + +/* DOMAIN SELECTOR: END ********************************************************/ + + #default_login { + position: fixed; + top: 50%; + left: 50%; + -moz-transform: translate(-50%, -50%); + -webkit-transform: translate(-50%, -50%); + -khtml-transform: translate(-50%, -50%); + transform: translate(-50%, -50%); + padding: ; + + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + + + + -webkit-box-shadow: ; + -moz-box-shadow: ; + box-shadow: ; + } + + #login_logo { + width: 250px; + height: auto; + } + + a.login_link { + color: ; + font-size: ; + font-family: ; + text-decoration: none; + } + + a.login_link:hover { + color: ; + cursor: pointer; + text-decoration: underline; + } + + + + #main_content { + display: inline-block; + width: 100%; + 0 || !$default_login) + && + (isset($background_images) || $background_colors[0] != '' || $background_colors[1] != '') + ) { ?> + background: ; + background-attachment: fixed; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + -webkit-box-shadow: ; + -moz-box-shadow: ; + box-shadow: ; + padding: 20px; + padding: 5px 10px 10px 10px; + text-align: left; + color: ; + font-size: ; + font-family: ; + } + + /* default body padding */ + .container-fluid { + width: 90%; + } + + /* maximize viewport usage on xs displays */ + @media(min-width: 0px) and (max-width: 767px) { + .container-fluid { + width: 100%; + } + + #main_content { + padding: 8px; + } + } + +/* GENERAL ELEMENTS *****************************************************************/ + + img { + border: none; + } + + .title, b { + color: ; + font-size: ; + font-family: ; + font-weight: bold + } + + a { + color: ; + text-decoration: none; + } + + a:hover { + color: ; + text-decoration: underline; + } + + form { + margin: 0; + } + + /* style placeholder text (for browsers that support the attribute) - note: can't stack, each must be seperate */ + + ::-webkit-input-placeholder { color: } /* chrome/opera/safari */ + ::-moz-placeholder { color: } /* ff 19+ */ + :-moz-placeholder { color: } /* ff 18- */ + :-ms-input-placeholder { color: } /* ie 10+ */ + ::placeholder { color: } /* official standard */ + + select.txt, + textarea.txt, + input[type=text].txt, + input[type=number].txt, + input[type=password].txt, + label.txt, + select.formfld, + textarea.formfld, + input[type=text].formfld, + input[type=number].formfld, + input[type=password].formfld, + label.formfld { + font-family: ; + font-size: ; + color: ; + text-align: left; + height: 28px; + padding: 4px 6px; + margin: 1px; + border-width: ; + border-style: solid; + border-color: ; + background: ; + 0) { + echo '-webkit-box-shadow: '.implode(', ', $shadows).";\n"; + echo '-moz-box-shadow: '.implode(', ', $shadows).";\n"; + echo 'box-shadow: '.implode(', ', $shadows).";\n"; + } + unset($shadows); + ?> + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + vertical-align: middle; + } + + textarea.txt, + input[type=text].txt, + input[type=number].txt, + input[type=password].txt, + textarea.formfld, + input[type=text].formfld, + input[type=number].formfld, + input[type=password].formfld { + transition: width 0.25s; + -moz-transition: width 0.25s; + -webkit-transition: width 0.25s; + max-width: 500px; + } + + select.txt, + select.formfld { + padding: 4px 2px; + } + + textarea.txt:hover, + input[type=text].txt:hover, + input[type=number].txt:hover, + input[type=password].txt:hover, + label.txt:hover, + textarea.formfld:hover, + input[type=text].formfld:hover, + input[type=number].formfld:hover, + input[type=password].formfld:hover, + label.formfld:hover { + border-color: ; + } + + textarea.txt:focus, + input[type=text].txt:focus, + input[type=number].txt:focus, + input[type=password].txt:focus, + label.txt:focus, + textarea.formfld:focus, + input[type=text].formfld:focus, + input[type=number].formfld:focus, + input[type=password].formfld:focus, + label.formfld:focus { + border-color: ; + /* first clear */ + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + + + -webkit-box-shadow: ; + -moz-box-shadow: ; + box-shadow: ; + + } + + input.login { + font-family: ; + font-size: ; + color: ; + border-width: ; + border-color: ; + background: ; + /* first clear */ + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + 0) { + echo '-webkit-box-shadow: '.implode(', ', $shadows).";\n"; + echo '-moz-box-shadow: '.implode(', ', $shadows).";\n"; + echo 'box-shadow: '.implode(', ', $shadows).";\n"; + } + unset($shadows); + ?> + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + } + + input.login:hover { + border-color: ; + } + + input.login:focus { + border-color: ; + /* first clear */ + -webkit-box-shadow: none; + -moz-box-shadow: none; + box-shadow: none; + + + -webkit-box-shadow: ; + -moz-box-shadow: ; + box-shadow: ; + + } + + /* style placeholder text (for browsers that support the attribute) - note: can't stack, each must be seperate */ + + input.login::-webkit-input-placeholder { color: } /* chrome/opera/safari */ + input.login::-moz-placeholder { color: } /* ff 19+ */ + input.login:-moz-placeholder { color: } /* ff 18- */ + input.login:-ms-input-placeholder { color: } /* ie 10+ */ + input.login::placeholder { color: } /* official standard */ + + input[type=password].formfld_highlight_bad, + input[type=password].formfld_highlight_bad:hover, + input[type=password].formfld_highlight_bad:active, + input[type=password].formfld_highlight_bad:focus { + border-color: #aa2525; + -webkit-box-shadow: 0 0 3px #aa2525 inset; + -moz-box-shadow: 0 0 3px #aa2525 inset; + box-shadow: 0 0 3px #aa2525 inset; + } + + input[type=password].formfld_highlight_good, + input[type=password].formfld_highlight_good:hover, + input[type=password].formfld_highlight_good:active, + input[type=password].formfld_highlight_good:focus { + border-color: #2fb22f; + -webkit-box-shadow: 0 0 3px #2fb22f inset; + -moz-box-shadow: 0 0 3px #2fb22f inset; + box-shadow: 0 0 3px #2fb22f inset; + } + + /* removes spinners (increment/decrement controls) inside input fields */ + input[type=number] { -moz-appearance: textfield; } + ::-webkit-inner-spin-button { -webkit-appearance: none; } + ::-webkit-outer-spin-button { -webkit-appearance: none; } + + /* disables text input clear 'x' in IE 10+, slows down autosizeInput jquery script */ + input[type=text]::-ms-clear { + display: none; + } + + input.fileinput { + padding: 1px; + display: inline; + } + + textarea { + min-height: 75px; + } + + label { + font-weight: normal; + vertical-align: middle; + } + + label input[type=checkbox], + label input[type=radio] { + vertical-align: -2px; + margin: 0; + padding: 0; + } + + span.playback_progress_bar { + background-color: #b90004; + width: 17px; + height: 4px; + margin-bottom: 3px; + display: block; + -moz-border-radius: 0 0 6px 6px; + -webkit-border-radius: 0 0 6px 6px; + -khtml-border-radius: 0 0 6px 6px; + border-radius: 0 0 6px 6px; + -webkit-box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); + -moz-box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); + box-shadow: 0 0 3px 0px rgba(255,0,0,0.9); + } + + td.playback_progress_bar_background { + padding: 0; + border-bottom: none; + background-image: -ms-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: -moz-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: -o-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, rgba(0,0,0,0.15)), color-stop(1, transparent)); + background-image: -webkit-linear-gradient(top, rgba(0,0,0,0.15) 0%, transparent 100%); + background-image: linear-gradient(to bottom, rgba(0,0,0,0.15) 0%, transparent 100%); + overflow: hidden; + } + + div.pwstrength_progress { + display: none; + } + + div.pwstrength_progress > div.progress { + max-width: 200px; + height: 6px; + margin: 1px 0 0 1px; + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + } + + div.pwstrength_progress_password_reset > div.progress { + margin: 0 auto 4px auto; + width: 200px; + max-width: 200px; + background: ; + border-width: ; + border-color: ; + } + +/* TABLES *****************************************************************/ + + table { + border-collapse: separate; + border-spacing: 0; + } + + th { + padding: 4px 7px 4px 0; + padding: 4px 7px; + text-align: left; + color: ; + font-size: ; + font-family: ; + background: ; + border-bottom: 1px solid ; + } + + th a, th a:visited, th a:active { + color: ; + text-decoration: none; + } + + th a:hover { + color: ; + text-decoration: underline; + } + + td { + color: ; + font-size: ; + font-family: ; + } + + table.tr_hover tr { + cursor: default; + } + + table.tr_hover tr:hover td, + table.tr_hover tr:hover td a { + color: ; + cursor: pointer; + } + + table.tr_hover tr.tr_link_void:hover td { + color: ; + cursor: default; + } + + table.tr_hover tr td.tr_link_void { + cursor: default; + } + + td.list_control_icons { + width: 52px; + padding: none; + padding-left: 2px; + text-align: right; + vertical-align: top; + white-space: nowrap; + } + + td.list_control_icon { + width: 26px; + padding: none; + padding-left: 2px; + text-align: right; + vertical-align: top; + white-space: nowrap; + } + + /* form: label/field format */ + .vncell { /* form_label */ + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + border-right: 3px solid ; + border-bottom: 1px solid ; + padding: ; + text-align: right; + color: ; + font-family: ; + font-size: ; + vertical-align: top; + } + + .vncellreq { /* form_label_required */ + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + border-right: 3px solid ; + border-bottom: 1px solid ; + padding: ; + text-align: right; + color: ; + font-family: ; + font-size: ; + font-weight: ; + vertical-align: top; + } + + .vtable { /* form_field */ + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + border-bottom: 1px solid ; + padding: ; + text-align: left; + vertical-align: middle; + color: ; + font-family: ; + font-size: ; + } + + /* form: heading/row format */ + .vncellcol { /* form_heading */ + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + border-bottom: 3px solid ; + padding: ; + text-align: left; + color: ; + font-family: ; + font-size: ; + } + + .vncellcolreq { /* form_heading_required */ + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + border-bottom: 3px solid ; + padding: ; + text-align: left; + color: ; + font-family: ; + font-size: ; + font-weight: ; + } + + .vtablerow { /* form_row */ + + height: px; + background: ; + + -moz-border-radius: ; + -webkit-border-radius: ; + -khtml-border-radius: ; + border-radius: ; + + border-bottom: 1px solid ; + padding: ; + text-align: left; + vertical-align: middle; + color: ; + font-family: ; + font-size: ; + } + + .row_style0 { + border-bottom: 1px solid ; + background: ; + color: ; + font-family: ; + font-size: ; + text-align: left; + padding: 4px 7px; + } + + .row_style1 { + border-bottom: 1px solid ; + background: ; + color: ; + font-family: ; + font-size: ; + text-align: left; + padding: 4px 7px; + } + + .row_style_slim { + padding-top: 0; + padding-bottom: 0; + white-space: nowrap; + } + + .row_stylebg { + border-bottom: 1px solid ; + background: ; + color: ; + font-family: ; + font-size: ; + text-align: left; + padding: 4px 7px; + } + +/* RESPONSE MESSAGES *******************************************************/ + + #message_container { + z-index: 99998; + position: absolute; + top: -80px; + left: 0; + right: 0; + filter: alpha(opacity=0); + opacity: 0; + -moz-opacity:0; + -khtml-opacity: 0; + padding: 15px 0; + } + + #message_text { + z-index: 99999; + position: absolute; + top: -80px; + left: 0; + right: 0; + filter: alpha(opacity=0); + opacity: 0; + -moz-opacity:0; + -khtml-opacity: 0; + margin: 0 auto; + vertical-align: middle; + padding: 15px 0; + text-align: center; + font-family: arial, san-serif; + font-size: 10pt; + } + + .message_container_mood_default { + background: ; + } + + .message_container_mood_negative { + background: ; + } + + .message_container_mood_alert { + background: ; + } + + .message_text_mood_default { + color: ; + } + + .message_text_mood_negative { + color: ; + } + + .message_text_mood_alert { + color: ; + } + +/* MESSAGES STACK *******************************************************/ + + #messages_container { + z-index: 99998; + position: absolute; + top: 0; + left: 0; + right: 0; + padding: 0; + } + + .message_text { + z-index: 99999; + margin: 0 auto; + padding: 0.5em 0; + text-align: center; + font-family: arial, san-serif; + font-size: 10pt; + display: block; + border-bottom: solid 1px; + } + + .message_mood_default { + color: ; + background: ; + border-bottom-color: ; + } + + .message_mood_negative { + color: ; + background: ; + border-bottom-color: ; + } + + .message_mood_alert { + color: ; + background: ; + border-bottom-color: ; + } + +/* OPERATOR PANEL ****************************************************************/ + + div.op_ext { + float: left; + width: 235px; + margin: 0px 8px 8px 0px; + padding: 0px; + border-style: solid; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + -webkit-box-shadow: 0 0 3px #e5e9f0; + -moz-box-shadow: 0 0 3px #e5e9f0; + box-shadow: 0 0 3px #e5e9f0; + border-width: 1px 3px; + border-color: #b9c5d8 #c5d1e5; + background-color: #e5eaf5; + cursor: default; + } + + div.op_state_active { + background-color: #baf4bb; + border-width: 1px 3px; + border-color: #77d779; + } + + div.op_state_ringing { + background-color: #a8dbf0; + border-width: 1px 3px; + border-color: #41b9eb; + } + + table.op_ext { + width: 100%; + height: 60px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + background-color: #e5eaf5; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + } + + td.op_ext_icon { + vertical-align: middle; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + } + + img.op_ext_icon { + cursor: move; + width: 39px; + height: 42px; + border: none; + } + + td.op_ext_info { + text-align: left; + vertical-align: top; + font-family: arial; + font-size: 10px; + overflow: auto; + width: 100%; + padding: 3px 5px 3px 7px; + -moz-border-radius: 5px; + -webkit-border-radius: 5px; + border-radius: 5px; + background-color: #f0f2f6; + } + + td.op_state_ringing { + background-color: #d1f1ff; + } + + td.op_state_active { + background-color: #e1ffe2; + } + + table.op_state_ringing { + background-color: #a8dbf0; + } + + table.op_state_active { + background-color: #baf4bb; + } + + .op_user_info { + font-family: arial; + font-size: 10px; + display: inline-block; + } + + .op_user_info strong { + color: #3164AD; + } + + .op_caller_info { + display: block; + margin-top: 4px; + font-family: arial; + font-size: 10px; + } + + .op_call_info { + display: inline-block; + padding: 0px; + font-family: arial; + font-size: 10px; + } + + #op_btn_status_available { + background-image: -moz-linear-gradient(top, #8ec989 0%, #2d9c38 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #8ec989), color-stop(1, #2d9c38)); + background-color: #2d9c38; + border: 1px solid #006200; + } + + #op_btn_status_available_on_demand { + background-image: -moz-linear-gradient(top, #abd0aa 0%, #629d62 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #abd0aa), color-stop(1, #629d62)); + background-color: #629d62; + border: 1px solid #619c61; + } + + #op_btn_status_on_break { + background-image: -moz-linear-gradient(top, #ddc38b 0%, #be8e2c 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #ddc38b), color-stop(1, #be8e2c)); + background-color: #be8e2c; + border: 1px solid #7d1b00; + } + + #op_btn_status_do_not_disturb { + background-image: -moz-linear-gradient(top, #cc8984 0%, #960d10 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cc8984), color-stop(1, #960d10)); + background-color: #960d10; + border: 1px solid #5b0000; + } + + #op_btn_status_logged_out { + background-image: -moz-linear-gradient(top, #cacac9 0%, #8d8d8b 100%); + background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #cacac9), color-stop(1, #8d8d8b)); + background-color: #8d8d8b; + border: 1px solid #5d5f5a; + } + +/* DASHBOARD **********************************************************************/ + + /* login message */ + div.login_message { + border: 1px solid #bae0ba; + background-color: #eeffee; + -webkit-border-radius: 3px; + -moz-border-radius: 3px; + border-radius: 3px; + padding: 20px; + margin-bottom: 15px; + } + + /* hud boxes */ + div.hud_box { + height: auto; + vertical-align: top; + text-align: center; + + background: ; + background-image: -ms-linear-gradient(left, 0%, 30%, 70%, 100%); + background-image: -moz-linear-gradient(left, 0%, 30%, 70%, 100%); + background-image: -o-linear-gradient(left, 0%, 30%, 70%, 100%); + background-image: -webkit-gradient(linear, left, right, color-stop(0, ), color-stop(0.30, ), color-stop(0.70, ), color-stop(1, )); + background-image: -webkit-linear-gradient(left, 0%, 30%, 70%, 100%); + background-image: linear-gradient(to right, 0%, 30%, 70%, 100%); + + + -webkit-border-radius: ; + -moz-border-radius: ; + border-radius: ; + + border: 1px solid ; + overflow: hidden; + margin: -1px; + } + + div.hud_box:hover { + border: 1px solid ; + } + + span.hud_title { + display: block; + width: 100%; + font-family: ; + text-shadow: 0px 1px 2px ; + letter-spacing: -0.02em; + color: ; + font-size: ; + + line-height: 0) ? str_replace($font_size_number, $line_height_number, $font_size) : '26.25pt'; ?>; + text-align: center; + background: ; + border-bottom: 1px solid ; + overflow: hidden; + } + + span.hud_title:hover { + color: ; + text-shadow: 0px 1px 2px ; + background: ; + cursor: pointer; + } + + span.hud_stat { + display: block; + clear: both; + text-align: center; + text-shadow: 0px 2px 2px ; + width: 100%; + color: ; + font-family: ; + font-size: ; + + line-height: 0) ? str_replace($font_size_number, $line_height_number, $font_size) : '77pt'; ?>; + font-weight: normal; + background: ; + border-top: 1px solid ; + overflow: hidden; + } + + span.hud_stat:hover { + color: ; + text-shadow: 0px 2px 2px ; + background: ; + cursor: pointer; + } + + span.hud_stat_title { + display: block; + clear: both; + width: 100%; + height: 30px; + cursor: default; + text-align: center; + text-shadow: 0px 1px 1px ; + color: ; + font-size: ; + padding-top: 4px; + white-space: nowrap; + letter-spacing: -0.02em; + font-weight: normal; + font-family: ; + background: ; + border-bottom: 1px solid ; + margin: 0; + overflow: hidden; + } + + span.hud_stat:hover + span.hud_stat_title { + color: ; + text-shadow: 0px 1px 1px ; + background: ; + } + + div.hud_details { + -moz-box-shadow: inset 0 7px 7px -7px , inset 0 -8px 12px -10px ; + -webkit-box-shadow: inset 0 7px 7px -7px , inset 0 -8px 12px -10px ; + box-shadow: inset 0 7px 7px -7px , inset 0 -8px 12px -10px ; + padding-top: 3px; + padding-bottom: 15px; + } + + @media(min-width: 0px) and (max-width: 1199px) { + div.hud_details { + display: none; + height: auto; + } + } + + @media(min-width: 1200px) { + div.hud_details { + height: 350px; + display: block; + } + } + + th.hud_heading { + text-align: left; + font-size: ; + font-family: + color: ; + } + + td.hud_text { + font-size: ; + color: ; + text-align: left; + vertical-align: middle; + } + + span.hud_expander { + display: block; + clear: both; + background: ; + padding: 4px 0; + text-align: center; + width: 100%; + height: 25px; + font-size: 13px; + line-height: 5px; + color: ; + border-top: 1px solid ; + } + + span.hud_expander:hover { + color: ; + background: ; + cursor: pointer; + } + +/* PLUGINS ********************************************************************/ + + /* bootstrap colorpicker */ + .colorpicker-2x .colorpicker-saturation { + width: 200px; + height: 200px; + } + + .colorpicker-2x .colorpicker-hue, + .colorpicker-2x .colorpicker-alpha { + width: 30px; + height: 200px; + } + + .colorpicker-2x .colorpicker-color, + .colorpicker-2x .colorpicker-color div{ + height: 30px; + } + + /* jquery ui autocomplete styles */ + .ui-widget { + margin: 0px; + padding: 0px; + } + + .ui-autocomplete { + cursor: default; + position: absolute; + max-height: 200px; + overflow-y: auto; + overflow-x: hidden; + white-space: nowrap; + width: auto; + border: 1px solid #c0c0c0; + } + + .ui-menu, .ui-menu .ui-menu-item { + width: 350px; + } + + .ui-menu .ui-menu-item a { + text-decoration: none; + cursor: pointer; + border-color: #fff; + background-image: none; + background-color: #fff; + white-space: nowrap; + font-family: arial; + font-size: 12px; + color: #444; + } + + .ui-menu .ui-menu-item a:hover { + color: #5082ca; + border: 1px solid white; + background-image: none; + background-color: #fff; + }