find . -name "*.php" | xargs dos2unix
This commit is contained in:
Mafoo 2017-06-13 06:09:36 +01:00 committed by FusionPBX
parent 6c97a1ae3d
commit 7bdea2c30c
32 changed files with 9072 additions and 9072 deletions

View File

@ -1,32 +1,32 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016 Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//proccess this only one time //proccess this only one time
if ($domains_processed == 1) { if ($domains_processed == 1) {
} }
?> ?>

View File

@ -1,31 +1,31 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016 Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//process this only one time //process this only one time
if ($domains_processed == 1) { if ($domains_processed == 1) {
} }
?> ?>

View File

@ -1,131 +1,131 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
if ($domains_processed == 1) { if ($domains_processed == 1) {
//add the conference controls list to the database //add the conference controls list to the database
$sql = "select count(*) as num_rows from v_conference_controls; "; $sql = "select count(*) as num_rows from v_conference_controls; ";
$prep_statement = $db->prepare($sql); $prep_statement = $db->prepare($sql);
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] == 0) { if ($row['num_rows'] == 0) {
//set the directory //set the directory
$xml_dir = $_SESSION["switch"]["conf"]["dir"].'/autoload_configs'; $xml_dir = $_SESSION["switch"]["conf"]["dir"].'/autoload_configs';
$xml_file = $xml_dir."/conference.conf"; $xml_file = $xml_dir."/conference.conf";
$xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/resources/templates/conf/autoload_configs/conference.conf'; $xml_file_alt = $_SERVER["DOCUMENT_ROOT"].'/'.PROJECT_PATH.'/resources/templates/conf/autoload_configs/conference.conf';
//rename the file //rename the file
if (file_exists($xml_dir.'/conference.conf.xml.noload')) { if (file_exists($xml_dir.'/conference.conf.xml.noload')) {
rename($xml_dir.'/conference.conf.xml.noload', $xml_dir.'/conference.conf'); rename($xml_dir.'/conference.conf.xml.noload', $xml_dir.'/conference.conf');
} }
//load the xml and save it into an array //load the xml and save it into an array
if (file_exists($xml_file)) { if (file_exists($xml_file)) {
$xml_string = file_get_contents($xml_file); $xml_string = file_get_contents($xml_file);
} }
elseif (file_exists($xml_file_alt)) { elseif (file_exists($xml_file_alt)) {
$xml_string = file_get_contents($xml_file_alt); $xml_string = file_get_contents($xml_file_alt);
} }
$xml_object = simplexml_load_string($xml_string); $xml_object = simplexml_load_string($xml_string);
$json = json_encode($xml_object); $json = json_encode($xml_object);
$conf_array = json_decode($json, true); $conf_array = json_decode($json, true);
//process the array //process the array
foreach ($conf_array['caller-controls']['group'] as $row) { foreach ($conf_array['caller-controls']['group'] as $row) {
//get the data from the array //get the data from the array
$control_name = $row['@attributes']['name']; $control_name = $row['@attributes']['name'];
//echo $profile_name."<br />\n"; //echo $profile_name."<br />\n";
//insert the data into the database //insert the data into the database
$conference_control_uuid = uuid(); $conference_control_uuid = uuid();
$sql = "insert into v_conference_controls "; $sql = "insert into v_conference_controls ";
$sql .= "("; $sql .= "(";
//$sql .= "domain_uuid, "; //$sql .= "domain_uuid, ";
$sql .= "conference_control_uuid, "; $sql .= "conference_control_uuid, ";
$sql .= "control_name, "; $sql .= "control_name, ";
$sql .= "control_enabled "; $sql .= "control_enabled ";
$sql .= ") "; $sql .= ") ";
$sql .= "values "; $sql .= "values ";
$sql .= "( "; $sql .= "( ";
//$sql .= "'".$domain_uuid."', "; //$sql .= "'".$domain_uuid."', ";
$sql .= "'".$conference_control_uuid."', "; $sql .= "'".$conference_control_uuid."', ";
$sql .= "'".check_str($control_name)."', "; $sql .= "'".check_str($control_name)."', ";
$sql .= "'true' "; $sql .= "'true' ";
$sql .= ");"; $sql .= ");";
//echo $sql."\n"; //echo $sql."\n";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
//insert the profile params //insert the profile params
foreach ($row['control'] as $p) { foreach ($row['control'] as $p) {
//get the name //get the name
//print_r($p); //print_r($p);
$control_action = $p['@attributes']['action']; $control_action = $p['@attributes']['action'];
$control_digits = $p['@attributes']['digits']; $control_digits = $p['@attributes']['digits'];
$control_data = $p['@attributes']['data']; $control_data = $p['@attributes']['data'];
$control_enabled = 'true'; $control_enabled = 'true';
//add the coference profile params //add the coference profile params
$conference_control_detail_uuid = uuid(); $conference_control_detail_uuid = uuid();
$sql = "insert into v_conference_control_details "; $sql = "insert into v_conference_control_details ";
$sql .= "("; $sql .= "(";
$sql .= "conference_control_uuid, "; $sql .= "conference_control_uuid, ";
$sql .= "conference_control_detail_uuid, "; $sql .= "conference_control_detail_uuid, ";
$sql .= "control_digits, "; $sql .= "control_digits, ";
$sql .= "control_action, "; $sql .= "control_action, ";
if (strlen($control_data) > 0) { if (strlen($control_data) > 0) {
$sql .= "control_data, "; $sql .= "control_data, ";
} }
$sql .= "control_enabled "; $sql .= "control_enabled ";
$sql .= ") "; $sql .= ") ";
$sql .= "values "; $sql .= "values ";
$sql .= "( "; $sql .= "( ";
$sql .= "'".$conference_control_uuid."', "; $sql .= "'".$conference_control_uuid."', ";
$sql .= "'".$conference_control_detail_uuid."', "; $sql .= "'".$conference_control_detail_uuid."', ";
$sql .= "'".$control_digits."', "; $sql .= "'".$control_digits."', ";
$sql .= "'".$control_action."', "; $sql .= "'".$control_action."', ";
if (strlen($control_data) > 0) { if (strlen($control_data) > 0) {
$sql .= "'".$control_data."', "; $sql .= "'".$control_data."', ";
} }
$sql .= "'".$control_enabled."' "; $sql .= "'".$control_enabled."' ";
$sql .= ");"; $sql .= ");";
//echo $sql."\n"; //echo $sql."\n";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
} }
} }
} //if num_rows } //if num_rows
} //if prep_statement } //if prep_statement
} }
?> ?>

View File

@ -1,49 +1,49 @@
<?php <?php
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('conference_control_delete')) { if (permission_exists('conference_control_delete')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the id //get the id
if (count($_GET) > 0) { if (count($_GET) > 0) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
} }
//delete the data //delete the data
if (strlen($id) > 0) { if (strlen($id) > 0) {
//delete conference_control_detail //delete conference_control_detail
$sql = "delete from v_conference_control_details "; $sql = "delete from v_conference_control_details ";
$sql .= "where conference_control_uuid = '$id' "; $sql .= "where conference_control_uuid = '$id' ";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
unset($sql); unset($sql);
//delete conference_control //delete conference_control
$sql = "delete from v_conference_controls "; $sql = "delete from v_conference_controls ";
$sql .= "where conference_control_uuid = '$id' "; $sql .= "where conference_control_uuid = '$id' ";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
unset($sql); unset($sql);
} }
//redirect the user //redirect the user
messages::add($text['message-delete']); messages::add($text['message-delete']);
header('Location: conference_controls.php'); header('Location: conference_controls.php');
?> ?>

View File

@ -1,42 +1,42 @@
<?php <?php
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('conference_control_detail_delete')) { if (permission_exists('conference_control_detail_delete')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the id //get the id
if (count($_GET) > 0) { if (count($_GET) > 0) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
$conference_control_uuid = check_str($_GET["conference_control_uuid"]); $conference_control_uuid = check_str($_GET["conference_control_uuid"]);
} }
//delete the data //delete the data
if (strlen($id) > 0) { if (strlen($id) > 0) {
//delete conference_control_detail //delete conference_control_detail
$sql = "delete from v_conference_control_details "; $sql = "delete from v_conference_control_details ";
$sql .= "where conference_control_detail_uuid = '$id' "; $sql .= "where conference_control_detail_uuid = '$id' ";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
unset($sql); unset($sql);
} }
//redirect the user //redirect the user
messages::add($text['message-delete']); messages::add($text['message-delete']);
header('Location: conference_control_detail_edit.php?id='.$conference_control_uuid); header('Location: conference_control_detail_edit.php?id='.$conference_control_uuid);
?> ?>

View File

@ -1,226 +1,226 @@
<?php <?php
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('conference_control_detail_add') || permission_exists('conference_control_detail_edit')) { if (permission_exists('conference_control_detail_add') || permission_exists('conference_control_detail_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (isset($_REQUEST["id"])) {
$action = "update"; $action = "update";
$conference_control_detail_uuid = check_str($_REQUEST["id"]); $conference_control_detail_uuid = check_str($_REQUEST["id"]);
} }
else { else {
$action = "add"; $action = "add";
} }
//set the parent uuid //set the parent uuid
if (strlen($_GET["conference_control_uuid"]) > 0) { if (strlen($_GET["conference_control_uuid"]) > 0) {
$conference_control_uuid = check_str($_GET["conference_control_uuid"]); $conference_control_uuid = check_str($_GET["conference_control_uuid"]);
} }
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (count($_POST)>0) { if (count($_POST)>0) {
$control_digits = check_str($_POST["control_digits"]); $control_digits = check_str($_POST["control_digits"]);
$control_action = check_str($_POST["control_action"]); $control_action = check_str($_POST["control_action"]);
$control_data = check_str($_POST["control_data"]); $control_data = check_str($_POST["control_data"]);
$control_enabled = check_str($_POST["control_enabled"]); $control_enabled = check_str($_POST["control_enabled"]);
} }
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//get the uuid //get the uuid
if ($action == "update") { if ($action == "update") {
$conference_control_detail_uuid = check_str($_POST["conference_control_detail_uuid"]); $conference_control_detail_uuid = check_str($_POST["conference_control_detail_uuid"]);
} }
//check for all required data //check for all required data
$msg = ''; $msg = '';
//if (strlen($control_digits) == 0) { $msg .= $text['message-required']." ".$text['label-control_digits']."<br>\n"; } //if (strlen($control_digits) == 0) { $msg .= $text['message-required']." ".$text['label-control_digits']."<br>\n"; }
if (strlen($control_action) == 0) { $msg .= $text['message-required']." ".$text['label-control_action']."<br>\n"; } if (strlen($control_action) == 0) { $msg .= $text['message-required']." ".$text['label-control_action']."<br>\n"; }
//if (strlen($control_data) == 0) { $msg .= $text['message-required']." ".$text['label-control_data']."<br>\n"; } //if (strlen($control_data) == 0) { $msg .= $text['message-required']." ".$text['label-control_data']."<br>\n"; }
if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."<br>\n"; } if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add or update the database //add or update the database
if ($_POST["persistformvar"] != "true") { if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('conference_control_detail_add')) { if ($action == "add" && permission_exists('conference_control_detail_add')) {
$sql = "insert into v_conference_control_details "; $sql = "insert into v_conference_control_details ";
$sql .= "("; $sql .= "(";
//$sql .= "domain_uuid, "; //$sql .= "domain_uuid, ";
$sql .= "conference_control_detail_uuid, "; $sql .= "conference_control_detail_uuid, ";
$sql .= "conference_control_uuid, "; $sql .= "conference_control_uuid, ";
$sql .= "control_digits, "; $sql .= "control_digits, ";
$sql .= "control_action, "; $sql .= "control_action, ";
$sql .= "control_data, "; $sql .= "control_data, ";
$sql .= "control_enabled "; $sql .= "control_enabled ";
$sql .= ")"; $sql .= ")";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
//$sql .= "'$domain_uuid', "; //$sql .= "'$domain_uuid', ";
$sql .= "'".uuid()."', "; $sql .= "'".uuid()."', ";
$sql .= "'$conference_control_uuid', "; $sql .= "'$conference_control_uuid', ";
$sql .= "'$control_digits', "; $sql .= "'$control_digits', ";
$sql .= "'$control_action', "; $sql .= "'$control_action', ";
$sql .= "'$control_data', "; $sql .= "'$control_data', ";
$sql .= "'$control_enabled' "; $sql .= "'$control_enabled' ";
$sql .= ")"; $sql .= ")";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-add']); messages::add($text['message-add']);
header('Location: conference_control_edit.php?id='.$conference_control_uuid); header('Location: conference_control_edit.php?id='.$conference_control_uuid);
return; return;
} //if ($action == "add") } //if ($action == "add")
if ($action == "update" && permission_exists('conference_control_detail_edit')) { if ($action == "update" && permission_exists('conference_control_detail_edit')) {
$sql = "update v_conference_control_details set "; $sql = "update v_conference_control_details set ";
$sql .= "conference_control_uuid = '$conference_control_uuid', "; $sql .= "conference_control_uuid = '$conference_control_uuid', ";
$sql .= "control_digits = '$control_digits', "; $sql .= "control_digits = '$control_digits', ";
$sql .= "control_action = '$control_action', "; $sql .= "control_action = '$control_action', ";
$sql .= "control_data = '$control_data', "; $sql .= "control_data = '$control_data', ";
$sql .= "control_enabled = '$control_enabled' "; $sql .= "control_enabled = '$control_enabled' ";
$sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid'"; $sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid'";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' ";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-update']); messages::add($text['message-update']);
header('Location: conference_control_edit.php?id='.$conference_control_uuid); header('Location: conference_control_edit.php?id='.$conference_control_uuid);
return; return;
} //if ($action == "update") } //if ($action == "update")
} //if ($_POST["persistformvar"] != "true") } //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$conference_control_detail_uuid = check_str($_GET["id"]); $conference_control_detail_uuid = check_str($_GET["id"]);
$sql = "select * from v_conference_control_details "; $sql = "select * from v_conference_control_details ";
$sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid' "; $sql .= "where conference_control_detail_uuid = '$conference_control_detail_uuid' ";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { foreach ($result as &$row) {
$control_digits = $row["control_digits"]; $control_digits = $row["control_digits"];
$control_action = $row["control_action"]; $control_action = $row["control_action"];
$control_data = $row["control_data"]; $control_data = $row["control_data"];
$control_enabled = $row["control_enabled"]; $control_enabled = $row["control_enabled"];
} }
unset ($prep_statement); unset ($prep_statement);
} }
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_control_detail']."</b><br><br></td>\n"; echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_control_detail']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n"; echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='conference_control_edit.php?id=$conference_control_uuid'\" value='".$text['button-back']."'>"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='conference_control_edit.php?id=$conference_control_uuid'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_digits']."\n"; echo " ".$text['label-control_digits']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_digits' maxlength='255' value='$control_digits'>\n"; echo " <input class='formfld' type='text' name='control_digits' maxlength='255' value='$control_digits'>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-control_digits']."\n"; echo $text['description-control_digits']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_action']."\n"; echo " ".$text['label-control_action']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_action' maxlength='255' value=\"$control_action\">\n"; echo " <input class='formfld' type='text' name='control_action' maxlength='255' value=\"$control_action\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-control_action']."\n"; echo $text['description-control_action']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_data']."\n"; echo " ".$text['label-control_data']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_data' maxlength='255' value=\"$control_data\">\n"; echo " <input class='formfld' type='text' name='control_data' maxlength='255' value=\"$control_data\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-control_data']."\n"; echo $text['description-control_data']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_enabled']."\n"; echo " ".$text['label-control_enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='control_enabled'>\n"; echo " <select class='formfld' name='control_enabled'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if ($control_enabled == "true") { if ($control_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n"; echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
} }
else { else {
echo " <option value='true'>".$text['label-true']."</option>\n"; echo " <option value='true'>".$text['label-true']."</option>\n";
} }
if ($control_enabled == "false") { if ($control_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n"; echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
} }
else { else {
echo " <option value='false'>".$text['label-false']."</option>\n"; echo " <option value='false'>".$text['label-false']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-control_enabled']."\n"; echo $text['description-control_enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='conference_control_uuid' value='$conference_control_uuid'>\n"; echo " <input type='hidden' name='conference_control_uuid' value='$conference_control_uuid'>\n";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='conference_control_detail_uuid' value='$conference_control_detail_uuid'>\n"; echo " <input type='hidden' name='conference_control_detail_uuid' value='$conference_control_detail_uuid'>\n";
} }
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";
echo "</form>"; echo "</form>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,160 +1,160 @@
<?php <?php
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('conference_control_detail_view')) { if (permission_exists('conference_control_detail_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get variables used to control the order //get variables used to control the order
$order_by = check_str($_GET["order_by"]); $order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]); $order = check_str($_GET["order"]);
//add the search term //add the search term
$search = check_str($_GET["search"]); $search = check_str($_GET["search"]);
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql_search = "and ("; $sql_search = "and (";
$sql_search .= "control_digits like '%".$search."%'"; $sql_search .= "control_digits like '%".$search."%'";
$sql_search .= "or control_action like '%".$search."%'"; $sql_search .= "or control_action like '%".$search."%'";
$sql_search .= "or control_data like '%".$search."%'"; $sql_search .= "or control_data like '%".$search."%'";
$sql_search .= "or control_enabled like '%".$search."%'"; $sql_search .= "or control_enabled like '%".$search."%'";
$sql_search .= ")"; $sql_search .= ")";
} }
//additional includes //additional includes
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
//prepare to page the results //prepare to page the results
$sql = "select count(*) as num_rows "; $sql = "select count(*) as num_rows ";
$sql .= "from v_conference_control_details "; $sql .= "from v_conference_control_details ";
$sql .= "where conference_control_uuid = '$conference_control_uuid' "; $sql .= "where conference_control_uuid = '$conference_control_uuid' ";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($sql); $prep_statement = $db->prepare($sql);
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) { if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows']; $num_rows = $row['num_rows'];
} }
else { else {
$num_rows = '0'; $num_rows = '0';
} }
} }
//prepare to page the results //prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = ""; $param = "";
$page = $_GET['page']; $page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the list //get the list
$sql = "select * from v_conference_control_details "; $sql = "select * from v_conference_control_details ";
$sql .= "where conference_control_uuid = '$conference_control_uuid' "; $sql .= "where conference_control_uuid = '$conference_control_uuid' ";
//$sql .= "and domain_uuid = '$domain_uuid' "; //$sql .= "and domain_uuid = '$domain_uuid' ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by) > 0) { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset "; $sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql); unset ($prep_statement, $sql);
//alternate the row style //alternate the row style
$c = 0; $c = 0;
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
$row_style["1"] = "row_style1"; $row_style["1"] = "row_style1";
//show the content //show the content
echo "<table width='100%' border='0'>\n"; echo "<table width='100%' border='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-conference_control_details']."</b></td>\n"; echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-conference_control_details']."</b></td>\n";
//echo " <form method='get' action=''>\n"; //echo " <form method='get' action=''>\n";
//echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n"; //echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
//echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n"; //echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n";
//echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n"; //echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
//echo " </td>\n"; //echo " </td>\n";
//echo " </form>\n"; //echo " </form>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo th_order_by('control_digits', $text['label-control_digits'], $order_by, $order); 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_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_data', $text['label-control_data'], $order_by, $order);
echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order); echo th_order_by('control_enabled', $text['label-control_enabled'], $order_by, $order);
echo "<td class='list_control_icons'>"; echo "<td class='list_control_icons'>";
if (permission_exists('conference_control_detail_add')) { if (permission_exists('conference_control_detail_add')) {
echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;\n"; echo "&nbsp;\n";
} }
echo "</td>\n"; echo "</td>\n";
echo "<tr>\n"; echo "<tr>\n";
if (is_array($result)) { if (is_array($result)) {
foreach($result as $row) { foreach($result as $row) {
if (permission_exists('conference_control_detail_edit')) { 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']."'"; $tr_link = "href='conference_control_detail_edit.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."'";
} }
echo "<tr ".$tr_link.">\n"; echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_digits']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_digits']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_action']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_action']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_data']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_data']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_enabled']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_enabled']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_detail_edit')) { if (permission_exists('conference_control_detail_edit')) {
echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>"; echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
} }
if (permission_exists('conference_control_detail_delete')) { if (permission_exists('conference_control_detail_delete')) {
echo "<a href='conference_control_detail_delete.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>"; echo "<a href='conference_control_detail_delete.php?conference_control_uuid=".$row['conference_control_uuid']."&id=".$row['conference_control_detail_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
} }
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($sql, $result, $row_count);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='5' align='left'>\n"; echo "<td colspan='5' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n"; echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n"; echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n"; echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_detail_add')) { if (permission_exists('conference_control_detail_add')) {
echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='conference_control_detail_edit.php?conference_control_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;"; echo "&nbsp;";
} }
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,191 +1,191 @@
<?php <?php
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('conference_control_add') || permission_exists('conference_control_edit')) { if (permission_exists('conference_control_add') || permission_exists('conference_control_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (isset($_REQUEST["id"])) {
$action = "update"; $action = "update";
$conference_control_uuid = check_str($_REQUEST["id"]); $conference_control_uuid = check_str($_REQUEST["id"]);
} }
else { else {
$action = "add"; $action = "add";
} }
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (is_array($_POST)) { if (is_array($_POST)) {
$control_name = check_str($_POST["control_name"]); $control_name = check_str($_POST["control_name"]);
$control_enabled = check_str($_POST["control_enabled"]); $control_enabled = check_str($_POST["control_enabled"]);
$control_description = check_str($_POST["control_description"]); $control_description = check_str($_POST["control_description"]);
} }
//process the user data and save it to the database //process the user data and save it to the database
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get the uuid from the POST //get the uuid from the POST
if ($action == "update") { if ($action == "update") {
$conference_control_uuid = check_str($_POST["conference_control_uuid"]); $conference_control_uuid = check_str($_POST["conference_control_uuid"]);
} }
//check for all required data //check for all required data
$msg = ''; $msg = '';
if (strlen($control_name) == 0) { $msg .= $text['message-required']." ".$text['label-control_name']."<br>\n"; } if (strlen($control_name) == 0) { $msg .= $text['message-required']." ".$text['label-control_name']."<br>\n"; }
if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."<br>\n"; } if (strlen($control_enabled) == 0) { $msg .= $text['message-required']." ".$text['label-control_enabled']."<br>\n"; }
//if (strlen($control_description) == 0) { $msg .= $text['message-required']." ".$text['label-control_description']."<br>\n"; } //if (strlen($control_description) == 0) { $msg .= $text['message-required']." ".$text['label-control_description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add the conference_control_uuid //add the conference_control_uuid
if (strlen($_POST["conference_control_uuid"]) == 0) { if (strlen($_POST["conference_control_uuid"]) == 0) {
$conference_control_uuid = uuid(); $conference_control_uuid = uuid();
$_POST["conference_control_uuid"] = $conference_control_uuid; $_POST["conference_control_uuid"] = $conference_control_uuid;
} }
//prepare the array //prepare the array
$array['conference_controls'][] = $_POST; $array['conference_controls'][] = $_POST;
//save to the data //save to the data
$database = new database; $database = new database;
$database->app_name = 'conference_controls'; $database->app_name = 'conference_controls';
$database->app_uuid = null; $database->app_uuid = null;
if (strlen($conference_control_uuid) > 0) { if (strlen($conference_control_uuid) > 0) {
$database->uuid($conference_control_uuid); $database->uuid($conference_control_uuid);
} }
$database->save($array); $database->save($array);
$message = $database->message; $message = $database->message;
//redirect the user //redirect the user
if (isset($action)) { if (isset($action)) {
if ($action == "add") { if ($action == "add") {
messages::add($text['message-add']); messages::add($text['message-add']);
} }
if ($action == "update") { if ($action == "update") {
messages::add($text['message-update']); messages::add($text['message-update']);
} }
header("Location: conference_controls.php"); header("Location: conference_controls.php");
return; return;
} }
} //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form //pre-populate the form
if (is_array($_GET) && $_POST["persistformvar"] != "true") { if (is_array($_GET) && $_POST["persistformvar"] != "true") {
$conference_control_uuid = check_str($_GET["id"]); $conference_control_uuid = check_str($_GET["id"]);
$sql = "select * from v_conference_controls "; $sql = "select * from v_conference_controls ";
//$sql .= "where domain_uuid = '$domain_uuid' "; //$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "where conference_control_uuid = '$conference_control_uuid' "; $sql .= "where conference_control_uuid = '$conference_control_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { foreach ($result as &$row) {
$control_name = $row["control_name"]; $control_name = $row["control_name"];
$control_enabled = $row["control_enabled"]; $control_enabled = $row["control_enabled"];
$control_description = $row["control_description"]; $control_description = $row["control_description"];
} }
unset ($prep_statement); unset ($prep_statement);
} }
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_control']."</b><br><br></td>\n"; echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-conference_control']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n"; echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='conference_controls.php'\" value='".$text['button-back']."'>"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='conference_controls.php'\" value='".$text['button-back']."'>";
echo " <input type='submit' class='btn' value='".$text['button-save']."'>"; echo " <input type='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_name']."\n"; echo " ".$text['label-control_name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_name' maxlength='255' value=\"$control_name\">\n"; echo " <input class='formfld' type='text' name='control_name' maxlength='255' value=\"$control_name\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-control_name']."\n"; echo $text['description-control_name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_enabled']."\n"; echo " ".$text['label-control_enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='control_enabled'>\n"; echo " <select class='formfld' name='control_enabled'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if ($control_enabled == "true") { if ($control_enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n"; echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
} }
else { else {
echo " <option value='true'>".$text['label-true']."</option>\n"; echo " <option value='true'>".$text['label-true']."</option>\n";
} }
if ($control_enabled == "false") { if ($control_enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n"; echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
} }
else { else {
echo " <option value='false'>".$text['label-false']."</option>\n"; echo " <option value='false'>".$text['label-false']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-control_enabled']."\n"; echo $text['description-control_enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-control_description']."\n"; echo " ".$text['label-control_description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='control_description' maxlength='255' value=\"$control_description\">\n"; echo " <input class='formfld' type='text' name='control_description' maxlength='255' value=\"$control_description\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-control_description']."\n"; echo $text['description-control_description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='conference_control_uuid' value='$conference_control_uuid'>\n"; echo " <input type='hidden' name='conference_control_uuid' value='$conference_control_uuid'>\n";
} }
echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n"; echo " <input type='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";
echo "</form>"; echo "</form>";
echo "<br /><br />"; echo "<br /><br />";
if ($action == "update") { if ($action == "update") {
require "conference_control_details.php"; require "conference_control_details.php";
} }
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,159 +1,159 @@
<?php <?php
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('conference_control_view')) { if (permission_exists('conference_control_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get variables used to control the order //get variables used to control the order
$order_by = check_str($_GET["order_by"]); $order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]); $order = check_str($_GET["order"]);
//add the search term //add the search term
$search = strtolower(check_str($_GET["search"])); $search = strtolower(check_str($_GET["search"]));
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql_search = "where ("; $sql_search = "where (";
$sql_search .= "lower(control_name) like '%".$search."%' "; $sql_search .= "lower(control_name) like '%".$search."%' ";
$sql_search .= "or lower(control_description) like '%".$search."%' "; $sql_search .= "or lower(control_description) like '%".$search."%' ";
$sql_search .= ") "; $sql_search .= ") ";
} }
//additional includes //additional includes
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
//prepare to page the results //prepare to page the results
$sql = "select count(conference_control_uuid) as num_rows "; $sql = "select count(conference_control_uuid) as num_rows ";
$sql .= "from v_conference_controls"; $sql .= "from v_conference_controls";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($sql); $prep_statement = $db->prepare($sql);
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) { if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows']; $num_rows = $row['num_rows'];
} }
else { else {
$num_rows = '0'; $num_rows = '0';
} }
} }
//prepare to page the results //prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = ""; $param = "";
$page = $_GET['page']; $page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the list //get the list
$sql = "select * from v_conference_controls "; $sql = "select * from v_conference_controls ";
//$sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; //$sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset "; $sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql); unset ($prep_statement, $sql);
//alternate the row style //alternate the row style
$c = 0; $c = 0;
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
$row_style["1"] = "row_style1"; $row_style["1"] = "row_style1";
//show the content //show the content
echo "<table width='100%' border='0'>\n"; echo "<table width='100%' border='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-conference_controls']."</b></td>\n"; echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-conference_controls']."</b></td>\n";
echo " <form method='get' action=''>\n"; echo " <form method='get' action=''>\n";
echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n"; echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n"; echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n"; echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </form>\n"; echo " </form>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align='left' colspan='2'>\n"; echo " <td align='left' colspan='2'>\n";
echo " ".$text['title_description-conference_control']."<br /><br />\n"; echo " ".$text['title_description-conference_control']."<br /><br />\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo th_order_by('control_name', $text['label-control_name'], $order_by, $order); 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_enabled', $text['label-control_enabled'], $order_by, $order);
echo th_order_by('control_description', $text['label-control_description'], $order_by, $order); echo th_order_by('control_description', $text['label-control_description'], $order_by, $order);
echo "<td class='list_control_icons'>"; echo "<td class='list_control_icons'>";
if (permission_exists('conference_control_add')) { if (permission_exists('conference_control_add')) {
echo "<a href='conference_control_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='conference_control_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;\n"; echo "&nbsp;\n";
} }
echo "</td>\n"; echo "</td>\n";
echo "<tr>\n"; echo "<tr>\n";
if (is_array($result)) { if (is_array($result)) {
foreach($result as $row) { foreach($result as $row) {
if (permission_exists('conference_control_edit')) { if (permission_exists('conference_control_edit')) {
$tr_link = "href='conference_control_edit.php?id=".$row['conference_control_uuid']."'"; $tr_link = "href='conference_control_edit.php?id=".$row['conference_control_uuid']."'";
} }
echo "<tr ".$tr_link.">\n"; echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_name']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_name']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_enabled']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['control_enabled']."&nbsp;</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['control_description']."&nbsp;</td>\n"; echo " <td valign='top' class='row_stylebg'>".$row['control_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_edit')) { if (permission_exists('conference_control_edit')) {
echo "<a href='conference_control_edit.php?id=".$row['conference_control_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>"; echo "<a href='conference_control_edit.php?id=".$row['conference_control_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
} }
if (permission_exists('conference_control_delete')) { if (permission_exists('conference_control_delete')) {
echo "<a href='conference_control_delete.php?id=".$row['conference_control_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>"; echo "<a href='conference_control_delete.php?id=".$row['conference_control_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
} }
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($sql, $result, $row_count);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='4' align='left'>\n"; echo "<td colspan='4' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n"; echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n"; echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n"; echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('conference_control_add')) { if (permission_exists('conference_control_add')) {
echo "<a href='conference_control_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='conference_control_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;"; echo "&nbsp;";
} }
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,122 +1,122 @@
<?php <?php
//application details //application details
$apps[$x]['name'] = "Database Transactions"; $apps[$x]['name'] = "Database Transactions";
$apps[$x]['uuid'] = "de47783c-1caa-4b3e-9b51-ad6c9e69215c"; $apps[$x]['uuid'] = "de47783c-1caa-4b3e-9b51-ad6c9e69215c";
$apps[$x]['category'] = ""; $apps[$x]['category'] = "";
$apps[$x]['subcategory'] = ""; $apps[$x]['subcategory'] = "";
$apps[$x]['version'] = "1.0"; $apps[$x]['version'] = "1.0";
$apps[$x]['license'] = "Mozilla Public License 1.1"; $apps[$x]['license'] = "Mozilla Public License 1.1";
$apps[$x]['url'] = "http://www.fusionpbx.com"; $apps[$x]['url'] = "http://www.fusionpbx.com";
$apps[$x]['description']['en-us'] = "Track database transactions"; $apps[$x]['description']['en-us'] = "Track database transactions";
$apps[$x]['description']['ar-eg'] = ""; $apps[$x]['description']['ar-eg'] = "";
$apps[$x]['description']['de-at'] = ""; $apps[$x]['description']['de-at'] = "";
$apps[$x]['description']['de-ch'] = ""; $apps[$x]['description']['de-ch'] = "";
$apps[$x]['description']['de-de'] = ""; $apps[$x]['description']['de-de'] = "";
$apps[$x]['description']['es-cl'] = ""; $apps[$x]['description']['es-cl'] = "";
$apps[$x]['description']['es-mx'] = ""; $apps[$x]['description']['es-mx'] = "";
$apps[$x]['description']['fr-ca'] = ""; $apps[$x]['description']['fr-ca'] = "";
$apps[$x]['description']['fr-fr'] = ""; $apps[$x]['description']['fr-fr'] = "";
$apps[$x]['description']['he-il'] = ""; $apps[$x]['description']['he-il'] = "";
$apps[$x]['description']['it-it'] = ""; $apps[$x]['description']['it-it'] = "";
$apps[$x]['description']['nl-nl'] = ""; $apps[$x]['description']['nl-nl'] = "";
$apps[$x]['description']['pl-pl'] = ""; $apps[$x]['description']['pl-pl'] = "";
$apps[$x]['description']['pt-br'] = ""; $apps[$x]['description']['pt-br'] = "";
$apps[$x]['description']['pt-pt'] = ""; $apps[$x]['description']['pt-pt'] = "";
$apps[$x]['description']['ro-ro'] = ""; $apps[$x]['description']['ro-ro'] = "";
$apps[$x]['description']['ru-ru'] = ""; $apps[$x]['description']['ru-ru'] = "";
$apps[$x]['description']['sv-se'] = ""; $apps[$x]['description']['sv-se'] = "";
$apps[$x]['description']['uk-ua'] = ""; $apps[$x]['description']['uk-ua'] = "";
//permission details //permission details
$y=0; $y=0;
$apps[$x]['permissions'][$y]['name'] = "database_transaction_view"; $apps[$x]['permissions'][$y]['name'] = "database_transaction_view";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//$apps[$x]['permissions'][$y]['groups'][] = "user"; //$apps[$x]['permissions'][$y]['groups'][] = "user";
//$apps[$x]['permissions'][$y]['groups'][] = "admin"; //$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++; $y++;
$apps[$x]['permissions'][$y]['name'] = "database_transaction_add"; $apps[$x]['permissions'][$y]['name'] = "database_transaction_add";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//$apps[$x]['permissions'][$y]['groups'][] = "admin"; //$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++; $y++;
$apps[$x]['permissions'][$y]['name'] = "database_transaction_edit"; $apps[$x]['permissions'][$y]['name'] = "database_transaction_edit";
$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; $apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//$apps[$x]['permissions'][$y]['groups'][] = "admin"; //$apps[$x]['permissions'][$y]['groups'][] = "admin";
//$apps[$x]['permissions'][$y]['groups'][] = "user"; //$apps[$x]['permissions'][$y]['groups'][] = "user";
$y++; $y++;
$apps[$x]['permissions'][$y]['name'] = "database_transaction_delete"; $apps[$x]['permissions'][$y]['name'] = "database_transaction_delete";
//$apps[$x]['permissions'][$y]['groups'][] = "superadmin"; //$apps[$x]['permissions'][$y]['groups'][] = "superadmin";
//$apps[$x]['permissions'][$y]['groups'][] = "admin"; //$apps[$x]['permissions'][$y]['groups'][] = "admin";
$y++; $y++;
//schema details //schema details
$y=0; $y=0;
$apps[$x]['db'][$y]['table']['name'] = "v_database_transactions"; $apps[$x]['db'][$y]['table']['name'] = "v_database_transactions";
$apps[$x]['db'][$y]['table']['parent'] = ""; $apps[$x]['db'][$y]['table']['parent'] = "";
$z=0; $z=0;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "domain_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign"; $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "foreign";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains"; $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['table'] = "v_domains";
$apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid"; $apps[$x]['db'][$y]['fields'][$z]['key']['reference']['field'] = "domain_uuid";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "database_transaction_uuid"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "database_transaction_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary"; $apps[$x]['db'][$y]['fields'][$z]['key']['type'] = "primary";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "user_uuid"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "user_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "User transaction."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "User transaction.";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "app_name"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "app_name";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Application name."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Application name.";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "app_uuid"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "app_uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "uuid";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "char(36)";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Application ID"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Application ID";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_code"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_code";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Transaction code."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Transaction code.";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_address"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_address";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "IP address of the user."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "IP address of the user.";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_type"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_type";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Type: insert, update, delete, select"; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Type: insert, update, delete, select";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_date"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_date";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "timestamp"; $apps[$x]['db'][$y]['fields'][$z]['type'] = "timestamp";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Transaction date."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Transaction date.";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_old"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_old";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "longtext"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "longtext";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Before the transaction."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Before the transaction.";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_new"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_new";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "longtext"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "longtext";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "After the transaction."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "After the transaction.";
$z++; $z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_result"; $apps[$x]['db'][$y]['fields'][$z]['name'] = "transaction_result";
$apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['pgsql'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text"; $apps[$x]['db'][$y]['fields'][$z]['type']['sqlite'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "longtext"; $apps[$x]['db'][$y]['fields'][$z]['type']['mysql'] = "longtext";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Result of the transaction."; $apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "Result of the transaction.";
?> ?>

View File

@ -1,21 +1,21 @@
<?php <?php
$apps[$x]['menu'][0]['title']['en-us'] = 'Transactions'; $apps[$x]['menu'][0]['title']['en-us'] = 'Transactions';
$apps[$x]['menu'][0]['title']['es-cl'] = ''; $apps[$x]['menu'][0]['title']['es-cl'] = '';
$apps[$x]['menu'][0]['title']['fr-fr'] = ''; $apps[$x]['menu'][0]['title']['fr-fr'] = '';
$apps[$x]['menu'][0]['title']['fr-ca'] = ''; $apps[$x]['menu'][0]['title']['fr-ca'] = '';
$apps[$x]['menu'][0]['title']['pl'] = ''; $apps[$x]['menu'][0]['title']['pl'] = '';
$apps[$x]['menu'][0]['title']['ru-ru'] = 'Изменения в БД'; $apps[$x]['menu'][0]['title']['ru-ru'] = 'Изменения в БД';
$apps[$x]['menu'][0]['title']['sv-se'] = ''; $apps[$x]['menu'][0]['title']['sv-se'] = '';
$apps[$x]['menu'][0]['title']['uk'] = ''; $apps[$x]['menu'][0]['title']['uk'] = '';
$apps[$x]['menu'][0]['title']['de-de'] = 'Datenbank Transaktionen'; $apps[$x]['menu'][0]['title']['de-de'] = 'Datenbank Transaktionen';
$apps[$x]['menu'][0]['title']['de-at'] = 'Datenbank Transaktionen'; $apps[$x]['menu'][0]['title']['de-at'] = 'Datenbank Transaktionen';
$apps[$x]['menu'][0]['uuid'] = 'ffc57bea-df1d-4099-b7e5-835d68f09006'; $apps[$x]['menu'][0]['uuid'] = 'ffc57bea-df1d-4099-b7e5-835d68f09006';
$apps[$x]['menu'][0]['parent_uuid'] = '594d99c5-6128-9c88-ca35-4b33392cec0f'; $apps[$x]['menu'][0]['parent_uuid'] = '594d99c5-6128-9c88-ca35-4b33392cec0f';
$apps[$x]['menu'][0]['category'] = 'internal'; $apps[$x]['menu'][0]['category'] = 'internal';
$apps[$x]['menu'][0]['path'] = '/app/database_transactions/database_transactions.php'; $apps[$x]['menu'][0]['path'] = '/app/database_transactions/database_transactions.php';
$apps[$x]['menu'][0]['groups'][] = 'superadmin'; $apps[$x]['menu'][0]['groups'][] = 'superadmin';
//$apps[$x]['menu'][0]['groups'][] = 'admin'; //$apps[$x]['menu'][0]['groups'][] = 'admin';
//$apps[$x]['menu'][0]['groups'][] = 'user'; //$apps[$x]['menu'][0]['groups'][] = 'user';
?> ?>

View File

@ -1,64 +1,64 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('database_transaction_delete')) { if (permission_exists('database_transaction_delete')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the id //get the id
if (count($_GET)>0) { if (count($_GET)>0) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
} }
//delete database_transaction //delete database_transaction
if (strlen($id)>0) { if (strlen($id)>0) {
$sql = "delete from v_database_transactions "; $sql = "delete from v_database_transactions ";
$sql .= "where database_transaction_uuid = '$id' "; $sql .= "where database_transaction_uuid = '$id' ";
$sql .= "and domain_uuid = '$domain_uuid' "; $sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
unset($sql); unset($sql);
} }
//redirect the user //redirect the user
messages::add($text['message-delete']); messages::add($text['message-delete']);
header('Location: database_transactions.php'); header('Location: database_transactions.php');
?> ?>

View File

@ -1,475 +1,475 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 - 2017 Portions created by the Initial Developer are Copyright (C) 2016 - 2017
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('database_transaction_add') || permission_exists('database_transaction_edit')) { if (permission_exists('database_transaction_add') || permission_exists('database_transaction_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (isset($_REQUEST["id"])) {
//$action = "update"; //$action = "update";
$database_transaction_uuid = check_str($_REQUEST["id"]); $database_transaction_uuid = check_str($_REQUEST["id"]);
} }
//else { //else {
// $action = "add"; // $action = "add";
//} //}
//get http post variables and set them to php variables //get http post variables and set them to php variables
/* /*
if (count($_POST) > 0) { if (count($_POST) > 0) {
$user_uuid = check_str($_POST["user_uuid"]); $user_uuid = check_str($_POST["user_uuid"]);
$app_uuid = check_str($_POST["app_uuid"]); $app_uuid = check_str($_POST["app_uuid"]);
$transaction_code = check_str($_POST["transaction_code"]); $transaction_code = check_str($_POST["transaction_code"]);
$transaction_address = check_str($_POST["transaction_address"]); $transaction_address = check_str($_POST["transaction_address"]);
$transaction_type = check_str($_POST["transaction_type"]); $transaction_type = check_str($_POST["transaction_type"]);
$transaction_date = check_str($_POST["transaction_date"]); $transaction_date = check_str($_POST["transaction_date"]);
$transaction_old = check_str($_POST["transaction_old"]); $transaction_old = check_str($_POST["transaction_old"]);
$transaction_new = check_str($_POST["transaction_new"]); $transaction_new = check_str($_POST["transaction_new"]);
$transaction_result = check_str($_POST["transaction_result"]); $transaction_result = check_str($_POST["transaction_result"]);
} }
*/ */
//process the data //process the data
/* /*
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
$msg = ''; $msg = '';
if ($action == "update") { if ($action == "update") {
$database_transaction_uuid = check_str($_POST["database_transaction_uuid"]); $database_transaction_uuid = check_str($_POST["database_transaction_uuid"]);
} }
//check for all required data //check for all required data
if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; } if (strlen($domain_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-domain_uuid']."<br>\n"; }
if (strlen($user_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-user_uuid']."<br>\n"; } if (strlen($user_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-user_uuid']."<br>\n"; }
if (strlen($app_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-app_uuid']."<br>\n"; } if (strlen($app_uuid) == 0) { $msg .= $text['message-required']." ".$text['label-app_uuid']."<br>\n"; }
if (strlen($transaction_code) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_code']."<br>\n"; } if (strlen($transaction_code) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_code']."<br>\n"; }
if (strlen($transaction_address) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_address']."<br>\n"; } if (strlen($transaction_address) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_address']."<br>\n"; }
if (strlen($transaction_type) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_type']."<br>\n"; } if (strlen($transaction_type) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_type']."<br>\n"; }
if (strlen($transaction_date) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_date']."<br>\n"; } if (strlen($transaction_date) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_date']."<br>\n"; }
if (strlen($transaction_old) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_old']."<br>\n"; } if (strlen($transaction_old) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_old']."<br>\n"; }
if (strlen($transaction_new) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_new']."<br>\n"; } if (strlen($transaction_new) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_new']."<br>\n"; }
if (strlen($transaction_result) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_result']."<br>\n"; } if (strlen($transaction_result) == 0) { $msg .= $text['message-required']." ".$text['label-transaction_result']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add or update the database //add or update the database
if ($_POST["persistformvar"] != "true") { if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('database_transaction_add')) { if ($action == "add" && permission_exists('database_transaction_add')) {
$sql = "insert into v_database_transactions "; $sql = "insert into v_database_transactions ";
$sql .= "("; $sql .= "(";
$sql .= "domain_uuid, "; $sql .= "domain_uuid, ";
$sql .= "database_transaction_uuid, "; $sql .= "database_transaction_uuid, ";
$sql .= "domain_uuid, "; $sql .= "domain_uuid, ";
$sql .= "user_uuid, "; $sql .= "user_uuid, ";
$sql .= "app_uuid, "; $sql .= "app_uuid, ";
$sql .= "transaction_code, "; $sql .= "transaction_code, ";
$sql .= "transaction_address, "; $sql .= "transaction_address, ";
$sql .= "transaction_type, "; $sql .= "transaction_type, ";
$sql .= "transaction_date, "; $sql .= "transaction_date, ";
$sql .= "transaction_old, "; $sql .= "transaction_old, ";
$sql .= "transaction_new, "; $sql .= "transaction_new, ";
$sql .= "transaction_result "; $sql .= "transaction_result ";
$sql .= ")"; $sql .= ")";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
$sql .= "'$domain_uuid', "; $sql .= "'$domain_uuid', ";
$sql .= "'".uuid()."', "; $sql .= "'".uuid()."', ";
$sql .= "'$domain_uuid', "; $sql .= "'$domain_uuid', ";
$sql .= "'$user_uuid', "; $sql .= "'$user_uuid', ";
$sql .= "'$app_uuid', "; $sql .= "'$app_uuid', ";
$sql .= "'$transaction_code', "; $sql .= "'$transaction_code', ";
$sql .= "'$transaction_address', "; $sql .= "'$transaction_address', ";
$sql .= "'$transaction_type', "; $sql .= "'$transaction_type', ";
$sql .= "now(), "; $sql .= "now(), ";
$sql .= "'$transaction_old', "; $sql .= "'$transaction_old', ";
$sql .= "'$transaction_new', "; $sql .= "'$transaction_new', ";
$sql .= "'$transaction_result' "; $sql .= "'$transaction_result' ";
$sql .= ")"; $sql .= ")";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-add']); messages::add($text['message-add']);
header("Location: database_transactions.php"); header("Location: database_transactions.php");
return; return;
} //if ($action == "add") } //if ($action == "add")
if ($action == "update" && permission_exists('database_transaction_edit')) { if ($action == "update" && permission_exists('database_transaction_edit')) {
$sql = "update v_database_transactions set "; $sql = "update v_database_transactions set ";
$sql .= "domain_uuid = '$domain_uuid', "; $sql .= "domain_uuid = '$domain_uuid', ";
$sql .= "user_uuid = '$user_uuid', "; $sql .= "user_uuid = '$user_uuid', ";
$sql .= "app_uuid = '$app_uuid', "; $sql .= "app_uuid = '$app_uuid', ";
$sql .= "transaction_code = '$transaction_code', "; $sql .= "transaction_code = '$transaction_code', ";
$sql .= "transaction_address = '$transaction_address', "; $sql .= "transaction_address = '$transaction_address', ";
$sql .= "transaction_type = '$transaction_type', "; $sql .= "transaction_type = '$transaction_type', ";
$sql .= "transaction_date = now(), "; $sql .= "transaction_date = now(), ";
$sql .= "transaction_old = '$transaction_old', "; $sql .= "transaction_old = '$transaction_old', ";
$sql .= "transaction_new = '$transaction_new', "; $sql .= "transaction_new = '$transaction_new', ";
$sql .= "transaction_result = '$transaction_result' "; $sql .= "transaction_result = '$transaction_result' ";
$sql .= "where database_transaction_uuid = '$database_transaction_uuid'"; $sql .= "where database_transaction_uuid = '$database_transaction_uuid'";
$sql .= "and domain_uuid = '$domain_uuid' "; $sql .= "and domain_uuid = '$domain_uuid' ";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-update']); messages::add($text['message-update']);
header("Location: database_transactions.php"); header("Location: database_transactions.php");
return; return;
} //if ($action == "update") } //if ($action == "update")
} //if ($_POST["persistformvar"] != "true") } //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
*/ */
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$database_transaction_uuid = check_str($_GET["id"]); $database_transaction_uuid = check_str($_GET["id"]);
$sql = "select "; $sql = "select ";
$sql .= "t.database_transaction_uuid, d.domain_name, u.username, t.user_uuid, t.app_name, t.app_uuid, "; $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_code, t.transaction_address, t.transaction_type, t.transaction_date, ";
$sql .= "t.transaction_old, t.transaction_new, t.transaction_result "; $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 .= "from v_database_transactions as t, v_domains as d, v_users as u ";
$sql .= "where t.domain_uuid = '$domain_uuid' "; $sql .= "where t.domain_uuid = '$domain_uuid' ";
$sql .= "and t.database_transaction_uuid = '$database_transaction_uuid' "; $sql .= "and t.database_transaction_uuid = '$database_transaction_uuid' ";
$sql .= "and t.user_uuid = u.user_uuid "; $sql .= "and t.user_uuid = u.user_uuid ";
$sql .= "and t.domain_uuid = d.domain_uuid "; $sql .= "and t.domain_uuid = d.domain_uuid ";
//$sql = "select *, u.username from v_database_transactions as t, v_users as u "; //$sql = "select *, u.username from v_database_transactions as t, v_users as u ";
//$sql .= "where domain_uuid = '$domain_uuid' "; //$sql .= "where domain_uuid = '$domain_uuid' ";
//$sql .= "t.user_uuid = u.user_uuid "; //$sql .= "t.user_uuid = u.user_uuid ";
//$sql .= "and database_transaction_uuid = '$database_transaction_uuid' "; //$sql .= "and database_transaction_uuid = '$database_transaction_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { foreach ($result as &$row) {
$user_uuid = $row["user_uuid"]; $user_uuid = $row["user_uuid"];
$app_name = $row["app_name"]; $app_name = $row["app_name"];
$app_uuid = $row["app_uuid"]; $app_uuid = $row["app_uuid"];
$domain_name = $row["domain_name"]; $domain_name = $row["domain_name"];
$username = $row["username"]; $username = $row["username"];
$transaction_code = $row["transaction_code"]; $transaction_code = $row["transaction_code"];
$transaction_address = $row["transaction_address"]; $transaction_address = $row["transaction_address"];
//$transaction_type = $row["transaction_type"]; //$transaction_type = $row["transaction_type"];
$transaction_date = $row["transaction_date"]; $transaction_date = $row["transaction_date"];
$transaction_old = $row["transaction_old"]; $transaction_old = $row["transaction_old"];
$transaction_new = $row["transaction_new"]; $transaction_new = $row["transaction_new"];
$transaction_result = $row["transaction_result"]; $transaction_result = $row["transaction_result"];
} }
unset ($prep_statement); unset ($prep_statement);
} }
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
//echo "<form name='frm' id='frm' method='post' action=''>\n"; //echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align='left' width='20%' nowrap='nowrap' valign='top'><b>".$text['title-database_transaction']."</b><br><br></td>\n"; echo " <td align='left' width='20%' nowrap='nowrap' valign='top'><b>".$text['title-database_transaction']."</b><br><br></td>\n";
echo " <td width='80%' align='right' valign='top'>\n"; echo " <td width='80%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='database_transactions.php'\" value='".$text['button-back']."'>"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='database_transactions.php'\" value='".$text['button-back']."'>";
//echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>"; //echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "<table width='350px' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='350px' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<td valign='top'>\n"; echo "<td valign='top'>\n";
echo " <table>\n"; echo " <table>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <th valign='top' align='left' nowrap='nowrap'>\n"; echo " <th valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-app_name']."\n"; echo " ".$text['label-app_name']."\n";
echo " </th>\n"; echo " </th>\n";
echo " <td class='vtable' align='left'>\n"; echo " <td class='vtable' align='left'>\n";
echo " ".$app_name."\n"; echo " ".$app_name."\n";
//echo " <input class='formfld' type='text' name='app_name' maxlength='255' value='$app_name'>\n"; //echo " <input class='formfld' type='text' name='app_name' maxlength='255' value='$app_name'>\n";
//echo " <br />\n"; //echo " <br />\n";
//echo " ".$text['description-app_uuid']."\n"; //echo " ".$text['description-app_uuid']."\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
/*echo " <tr>\n"; /*echo " <tr>\n";
echo " <th width='10%' valign='top' align='left' nowrap='nowrap'>\n"; echo " <th width='10%' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-domain']."\n"; echo " ".$text['label-domain']."\n";
echo " </th>\n"; echo " </th>\n";
echo " <td width='90%' aclass='vtable' align='left'>\n"; echo " <td width='90%' aclass='vtable' align='left'>\n";
echo " ".$domain_name; echo " ".$domain_name;
//echo " <input class='formfld' type='text' name='domain_name' maxlength='255' value='$domain_name'>\n"; //echo " <input class='formfld' type='text' name='domain_name' maxlength='255' value='$domain_name'>\n";
//echo " <br />\n"; //echo " <br />\n";
//echo " ".$text['description-domain']."\n"; //echo " ".$text['description-domain']."\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
*/ */
echo " <tr>\n"; echo " <tr>\n";
echo " <th valign='top' align='left' nowrap='nowrap'>\n"; echo " <th valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-user_uuid']."\n"; echo " ".$text['label-user_uuid']."\n";
echo " </th>\n"; echo " </th>\n";
echo " <td class='vtable' align='left'>\n"; echo " <td class='vtable' align='left'>\n";
echo " ".$username."\n"; echo " ".$username."\n";
//echo " <input class='formfld' type='text' name='username' maxlength='255' value='$username'>\n"; //echo " <input class='formfld' type='text' name='username' maxlength='255' value='$username'>\n";
//echo " <br />\n"; //echo " <br />\n";
//echo " ".$text['description-user_uuid']."\n"; //echo " ".$text['description-user_uuid']."\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
echo "<td valign='top'>\n"; echo "<td valign='top'>\n";
echo " <table>\n"; echo " <table>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <th valign='top' align='left' nowrap='nowrap'>\n"; echo " <th valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-transaction_code']."\n"; echo " ".$text['label-transaction_code']."\n";
echo " </th>\n"; echo " </th>\n";
echo " <td class='vtable' align='left'>\n"; echo " <td class='vtable' align='left'>\n";
echo " $transaction_code\n"; echo " $transaction_code\n";
//echo " <input class='formfld' type='text' name='transaction_code' maxlength='255' value='$transaction_code'>\n"; //echo " <input class='formfld' type='text' name='transaction_code' maxlength='255' value='$transaction_code'>\n";
//echo " <br />\n"; //echo " <br />\n";
//echo " ".$text['description-transaction_code']."\n"; //echo " ".$text['description-transaction_code']."\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <th valign='top' align='left' nowrap='nowrap'>\n"; echo " <th valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-transaction_address']."\n"; echo " ".$text['label-transaction_address']."\n";
echo " </th>\n"; echo " </th>\n";
echo " <td class='vtable' align='left'>\n"; echo " <td class='vtable' align='left'>\n";
echo " $transaction_address\n"; echo " $transaction_address\n";
//echo " <input class='formfld' type='text' name='transaction_address' maxlength='255' value=\"$transaction_address\">\n"; //echo " <input class='formfld' type='text' name='transaction_address' maxlength='255' value=\"$transaction_address\">\n";
//echo " <br />\n"; //echo " <br />\n";
//echo " ".$text['description-transaction_address']."\n"; //echo " ".$text['description-transaction_address']."\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>\n"; echo "</table>\n";
//echo "<tr>\n"; //echo "<tr>\n";
//echo "<th valign='top' align='left' nowrap='nowrap'>\n"; //echo "<th valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-transaction_type']."\n"; //echo " ".$text['label-transaction_type']."\n";
//echo "</th>\n"; //echo "</th>\n";
//echo "<td class='vtable' align='left'>\n"; //echo "<td class='vtable' align='left'>\n";
//echo " <input class='formfld' type='text' name='transaction_type' maxlength='255' value=\"$transaction_type\">\n"; //echo " <input class='formfld' type='text' name='transaction_type' maxlength='255' value=\"$transaction_type\">\n";
//echo "<br />\n"; //echo "<br />\n";
//echo $text['description-transaction_type']."\n"; //echo $text['description-transaction_type']."\n";
//echo "</td>\n"; //echo "</td>\n";
//echo "</tr>\n"; //echo "</tr>\n";
if ($_REQUEST["debug"] == "true") { if ($_REQUEST["debug"] == "true") {
echo "<table width='350px' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='350px' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<th valign='top' align='left' nowrap='nowrap'>\n"; echo "<th valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-transaction_old']."\n"; echo " ".$text['label-transaction_old']."\n";
echo "</th>\n"; echo "</th>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
//echo " <input class='formfld' type='text' name='transaction_old' maxlength='255' value=\"$transaction_old\">\n"; //echo " <input class='formfld' type='text' name='transaction_old' maxlength='255' value=\"$transaction_old\">\n";
echo " <textarea name='transaction_old' style='width: 265px; height: 80px;'>$transaction_old</textarea>\n"; echo " <textarea name='transaction_old' style='width: 265px; height: 80px;'>$transaction_old</textarea>\n";
//echo "<br />\n"; //echo "<br />\n";
//echo $text['description-transaction_old']."\n"; //echo $text['description-transaction_old']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<th valign='top' align='left' nowrap='nowrap'>\n"; echo "<th valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-transaction_new']."\n"; echo " ".$text['label-transaction_new']."\n";
echo "</th>\n"; echo "</th>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
//echo " <input class='formfld' type='text' name='transaction_new' maxlength='255' value=\"$transaction_new\">\n"; //echo " <input class='formfld' type='text' name='transaction_new' maxlength='255' value=\"$transaction_new\">\n";
echo " <textarea name='transaction_new' style='width: 265px; height: 80px;'>$transaction_new</textarea>\n"; echo " <textarea name='transaction_new' style='width: 265px; height: 80px;'>$transaction_new</textarea>\n";
//echo "<br />\n"; //echo "<br />\n";
//echo $text['description-transaction_new']."\n"; //echo $text['description-transaction_new']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<th valign='top' align='left' nowrap='nowrap'>\n"; echo "<th valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-transaction_result']."\n"; echo " ".$text['label-transaction_result']."\n";
echo "</th>\n"; echo "</th>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
//echo " <input class='formfld' type='text' name='transaction_result' maxlength='255' value=\"$transaction_result\">\n"; //echo " <input class='formfld' type='text' name='transaction_result' maxlength='255' value=\"$transaction_result\">\n";
echo " <textarea name='transaction_result' style='width: 265px; height: 80px;'>$transaction_result</textarea>\n"; echo " <textarea name='transaction_result' style='width: 265px; height: 80px;'>$transaction_result</textarea>\n";
//echo "<br />\n"; //echo "<br />\n";
//echo $text['description-transaction_result']."\n"; //echo $text['description-transaction_result']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
} }
//echo " <tr>\n"; //echo " <tr>\n";
//echo " <td colspan='2' align='right'>\n"; //echo " <td colspan='2' align='right'>\n";
//if ($action == "update") { //if ($action == "update") {
// echo " <input type='hidden' name='database_transaction_uuid' value='$database_transaction_uuid'>\n"; // echo " <input type='hidden' name='database_transaction_uuid' value='$database_transaction_uuid'>\n";
//} //}
//echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n"; //echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
//echo " </td>\n"; //echo " </td>\n";
//echo " </tr>"; //echo " </tr>";
//echo "</table>"; //echo "</table>";
//echo "</form>"; //echo "</form>";
//echo "<br /><br />"; //echo "<br /><br />";
//define the array _difference function //define the array _difference function
//this adds old and new values to the array //this adds old and new values to the array
function array_difference($array1, $array2) { function array_difference($array1, $array2) {
$difference = array(); $difference = array();
if (is_array($array1)) { if (is_array($array1)) {
foreach($array1 as $key => $value) { foreach($array1 as $key => $value) {
if(is_array($array2[$key])) { if(is_array($array2[$key])) {
$difference[$key] = array_difference($array1[$key], $array2[$key]); $difference[$key] = array_difference($array1[$key], $array2[$key]);
} }
else { else {
$difference[$key]['old'] = $value; $difference[$key]['old'] = $value;
} }
} }
} }
if (is_array($array2)) { if (is_array($array2)) {
foreach($array2 as $key => $value) { foreach($array2 as $key => $value) {
if(is_array($value)) { if(is_array($value)) {
$difference[$key] = array_difference($array1[$key], $array2[$key]); $difference[$key] = array_difference($array1[$key], $array2[$key]);
} }
else { else {
$difference[$key]['new'] = $value; $difference[$key]['new'] = $value;
} }
} }
} }
return $difference; return $difference;
} }
//show the content from the difference array as a list //show the content from the difference array as a list
function show_difference($array) { function show_difference($array) {
//loop through the array //loop through the array
foreach($array as $key => $value) { foreach($array as $key => $value) {
if(is_array($value) && !isset($value['old']) && !isset($value['new'])) { if(is_array($value) && !isset($value['old']) && !isset($value['new'])) {
if (!is_numeric($key)) { if (!is_numeric($key)) {
//get the table name //get the table name
$_SESSION['name'] = $key; $_SESSION['name'] = $key;
} }
else { else {
//get the row id //get the row id
$_SESSION['row'] = $key; $_SESSION['row'] = $key;
} }
$array = show_difference($value); $array = show_difference($value);
} }
else { else {
//set the variables //set the variables
$old = $value['old']; $old = $value['old'];
$new = $value['new']; $new = $value['new'];
if (is_null($old)) { $old = ''; } if (is_null($old)) { $old = ''; }
if (is_null($new)) { $new = ''; } if (is_null($new)) { $new = ''; }
//determine if the value has changed //determine if the value has changed
if (strval($old) == strval($new) && isset($old)) { if (strval($old) == strval($new) && isset($old)) {
$color = "#000000"; $color = "#000000";
} }
else { else {
$color = "#ff0000"; $color = "#ff0000";
} }
//set the table header //set the table header
if ($_SESSION['previous_name'] != $_SESSION['name'] || $_SESSION['previous_row'] != $_SESSION['row']) { if ($_SESSION['previous_name'] != $_SESSION['name'] || $_SESSION['previous_row'] != $_SESSION['row']) {
echo str_replace("<th>name</th>","<th>".$_SESSION['name']."</th>",$_SESSION['table_header']); echo str_replace("<th>name</th>","<th>".$_SESSION['name']."</th>",$_SESSION['table_header']);
//echo $_SESSION['table_header']; //echo $_SESSION['table_header'];
} }
$_SESSION['previous_name'] = $_SESSION['name']; $_SESSION['previous_name'] = $_SESSION['name'];
$_SESSION['previous_row'] = $_SESSION['row']; $_SESSION['previous_row'] = $_SESSION['row'];
//show the results //show the results
echo "<tr style='color: $color;'>\n"; echo "<tr style='color: $color;'>\n";
//echo " <td class=\"vtable\" style='color: $color;'>".$_SESSION['name']."</td>\n"; //echo " <td class=\"vtable\" style='color: $color;'>".$_SESSION['name']."</td>\n";
//echo " <td class=\"vtable\" style='color: $color; text-align: center;'>".$_SESSION['row']."</td>\n"; //echo " <td class=\"vtable\" style='color: $color; text-align: center;'>".$_SESSION['row']."</td>\n";
echo " <td class=\"vtable\" style='color: $color;'>$key</td>\n"; echo " <td class=\"vtable\" style='color: $color;'>$key</td>\n";
echo " <td class=\"vtable\" style='color: $color;'>".$old."</td>\n"; echo " <td class=\"vtable\" style='color: $color;'>".$old."</td>\n";
echo " <td class=\"vtable\" style='color: $color;'>".$new."</td>"; echo " <td class=\"vtable\" style='color: $color;'>".$new."</td>";
echo "</tr>\n"; echo "</tr>\n";
//echo "</table>\n"; //echo "</table>\n";
} }
} }
} }
//decode the json to arrays //decode the json to arrays
$before = json_decode($transaction_old, true); $before = json_decode($transaction_old, true);
$after = json_decode($transaction_new, true); $after = json_decode($transaction_new, true);
//unset the sessions //unset the sessions
unset($_SESSION['previous_name']); unset($_SESSION['previous_name']);
unset($_SESSION['previous_row']); unset($_SESSION['previous_row']);
//show the add or update //show the add or update
if (count($before) > 0 && count($after) > 0) { if (count($before) > 0 && count($after) > 0) {
//create the table header //create the table header
$array = array_difference($before, $after, 1); $array = array_difference($before, $after, 1);
$table_header = "<tr><td colspan='5'>&nbsp;</td></tr>\n"; $table_header = "<tr><td colspan='5'>&nbsp;</td></tr>\n";
$table_header .= "<tr>\n"; $table_header .= "<tr>\n";
//$table_header .= " <th>Table</th>\n"; //$table_header .= " <th>Table</th>\n";
//$table_header .= " <th>Row</th>\n"; //$table_header .= " <th>Row</th>\n";
$table_header .= " <th>name</th>\n"; $table_header .= " <th>name</th>\n";
$table_header .= " <th>old</th>\n"; $table_header .= " <th>old</th>\n";
$table_header .= " <th>new</th>\n"; $table_header .= " <th>new</th>\n";
$table_header .= "</tr>\n"; $table_header .= "</tr>\n";
$_SESSION['table_header'] = $table_header; $_SESSION['table_header'] = $table_header;
//show the difference //show the difference
echo "<table border='0' cellpadding='3'>\n"; echo "<table border='0' cellpadding='3'>\n";
show_difference($array); show_difference($array);
echo "</table>\n"; echo "</table>\n";
} }
//show the delete //show the delete
if (count($before) > 0 && count($after) == 0) { if (count($before) > 0 && count($after) == 0) {
echo "<h3>Record Deleted</h3><br />\n"; echo "<h3>Record Deleted</h3><br />\n";
echo " <pre>\n"; echo " <pre>\n";
print_r($before); print_r($before);
echo " </pre>\n"; echo " </pre>\n";
} }
//add a few lines at the end //add a few lines at the end
echo "<br />\n"; echo "<br />\n";
echo "<br />\n"; echo "<br />\n";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,90 +1,90 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012 Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
// make sure the PATH_SEPARATOR is defined // make sure the PATH_SEPARATOR is defined
umask(2); umask(2);
if (!defined("PATH_SEPARATOR")) { if (!defined("PATH_SEPARATOR")) {
if (strpos($_ENV["OS"], "Win") !== false) { if (strpos($_ENV["OS"], "Win") !== false) {
define("PATH_SEPARATOR", ";"); define("PATH_SEPARATOR", ";");
} else { } else {
define("PATH_SEPARATOR", ":"); define("PATH_SEPARATOR", ":");
} }
} }
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
// make sure the document_root is set // make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
if(PHP_SAPI == 'cli'){ if(PHP_SAPI == 'cli'){
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
if (file_exists('/project_root.php')) { if (file_exists('/project_root.php')) {
$path = '/'; $path = '/';
} else { } else {
$i = 1; $i = 1;
$path = ''; $path = '';
while ($i < count($dirs)) { while ($i < count($dirs)) {
$path .= '/' . $dirs[$i]; $path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) { if (file_exists($path. '/project_root.php')) {
break; break;
} }
$i++; $i++;
} }
} }
$_SERVER["DOCUMENT_ROOT"] = $path; $_SERVER["DOCUMENT_ROOT"] = $path;
}else{ }else{
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
} }
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
// try to detect if a project path is being used // try to detect if a project path is being used
if (!defined('PROJECT_PATH')) { if (!defined('PROJECT_PATH')) {
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
define('PROJECT_PATH', '/fusionpbx'); define('PROJECT_PATH', '/fusionpbx');
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
define('PROJECT_PATH', ''); define('PROJECT_PATH', '');
} else { } else {
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
$i = 1; $i = 1;
$path = $_SERVER["DOCUMENT_ROOT"]; $path = $_SERVER["DOCUMENT_ROOT"];
while ($i < count($dirs)) { while ($i < count($dirs)) {
$path .= '/' . $dirs[$i]; $path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) { if (file_exists($path. '/project_root.php')) {
break; break;
} }
$i++; $i++;
} }
if(!file_exists($path. '/project_root.php')){ 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"); 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); $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
define('PROJECT_PATH', $project_path); define('PROJECT_PATH', $project_path);
} }
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
} }
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -1,64 +1,64 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('device_vendor_delete')) { if (permission_exists('device_vendor_delete')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the id //get the id
if (count($_GET)>0) { if (count($_GET)>0) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
} }
//delete the data //delete the data
if (strlen($id)>0) { if (strlen($id)>0) {
//delete device_vendor //delete device_vendor
$sql = "delete from v_device_vendors "; $sql = "delete from v_device_vendors ";
$sql .= "where device_vendor_uuid = '$id' "; $sql .= "where device_vendor_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
unset($sql); unset($sql);
} }
//redirect the user //redirect the user
messages::add($text['message-delete']); messages::add($text['message-delete']);
header('Location: device_vendors.php'); header('Location: device_vendors.php');
?> ?>

View File

@ -1,223 +1,223 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('device_vendor_add') || permission_exists('device_vendor_edit')) { if (permission_exists('device_vendor_add') || permission_exists('device_vendor_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (isset($_REQUEST["id"])) {
$action = "update"; $action = "update";
$device_vendor_uuid = check_str($_REQUEST["id"]); $device_vendor_uuid = check_str($_REQUEST["id"]);
} }
else { else {
$action = "add"; $action = "add";
} }
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (count($_POST)>0) { if (count($_POST)>0) {
$name = check_str($_POST["name"]); $name = check_str($_POST["name"]);
$enabled = check_str($_POST["enabled"]); $enabled = check_str($_POST["enabled"]);
$description = check_str($_POST["description"]); $description = check_str($_POST["description"]);
} }
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = ''; $msg = '';
if ($action == "update") { if ($action == "update") {
$device_vendor_uuid = check_str($_POST["device_vendor_uuid"]); $device_vendor_uuid = check_str($_POST["device_vendor_uuid"]);
} }
//check for all required data //check for all required data
if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."<br>\n"; } if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."<br>\n"; }
if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; } if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
//if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; } //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add or update the database //add or update the database
if ($_POST["persistformvar"] != "true") { if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('device_vendor_add')) { if ($action == "add" && permission_exists('device_vendor_add')) {
$sql = "insert into v_device_vendors "; $sql = "insert into v_device_vendors ";
$sql .= "("; $sql .= "(";
$sql .= "device_vendor_uuid, "; $sql .= "device_vendor_uuid, ";
$sql .= "name, "; $sql .= "name, ";
$sql .= "enabled, "; $sql .= "enabled, ";
$sql .= "description "; $sql .= "description ";
$sql .= ")"; $sql .= ")";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
$sql .= "'".uuid()."', "; $sql .= "'".uuid()."', ";
$sql .= "'$name', "; $sql .= "'$name', ";
$sql .= "'$enabled', "; $sql .= "'$enabled', ";
$sql .= "'$description' "; $sql .= "'$description' ";
$sql .= ")"; $sql .= ")";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-add']); messages::add($text['message-add']);
header("Location: device_vendors.php"); header("Location: device_vendors.php");
return; return;
} //if ($action == "add") } //if ($action == "add")
if ($action == "update" && permission_exists('device_vendor_edit')) { if ($action == "update" && permission_exists('device_vendor_edit')) {
$sql = "update v_device_vendors set "; $sql = "update v_device_vendors set ";
$sql .= "name = '$name', "; $sql .= "name = '$name', ";
$sql .= "enabled = '$enabled', "; $sql .= "enabled = '$enabled', ";
$sql .= "description = '$description' "; $sql .= "description = '$description' ";
$sql .= "where device_vendor_uuid = '$device_vendor_uuid'"; $sql .= "where device_vendor_uuid = '$device_vendor_uuid'";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-update']); messages::add($text['message-update']);
header("Location: device_vendors.php"); header("Location: device_vendors.php");
return; return;
} //if ($action == "update") } //if ($action == "update")
} //if ($_POST["persistformvar"] != "true") } //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$device_vendor_uuid = check_str($_GET["id"]); $device_vendor_uuid = check_str($_GET["id"]);
$sql = "select * from v_device_vendors "; $sql = "select * from v_device_vendors ";
$sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; $sql .= "where device_vendor_uuid = '$device_vendor_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { foreach ($result as &$row) {
$name = $row["name"]; $name = $row["name"];
$enabled = $row["enabled"]; $enabled = $row["enabled"];
$description = $row["description"]; $description = $row["description"];
} }
unset ($prep_statement); unset ($prep_statement);
} }
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-device_vendor']."</b><br><br></td>\n"; echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-device_vendor']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n"; echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='device_vendors.php'\" value='".$text['button-back']."'>"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='device_vendors.php'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n"; echo " ".$text['label-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"$name\">\n"; echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"$name\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-name']."\n"; echo $text['description-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-enabled']."\n"; echo " ".$text['label-enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='enabled'>\n"; echo " <select class='formfld' name='enabled'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if ($enabled == "false") { if ($enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n"; echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
} }
else { else {
echo " <option value='false'>".$text['label-false']."</option>\n"; echo " <option value='false'>".$text['label-false']."</option>\n";
} }
if ($enabled == "true") { if ($enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n"; echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
} }
else { else {
echo " <option value='true'>".$text['label-true']."</option>\n"; echo " <option value='true'>".$text['label-true']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-enabled']."\n"; echo $text['description-enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-description']."\n"; echo " ".$text['label-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='description' maxlength='255' value=\"$description\">\n"; echo " <input class='formfld' type='text' name='description' maxlength='255' value=\"$description\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-description']."\n"; echo $text['description-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='device_vendor_uuid' value='$device_vendor_uuid'>\n"; echo " <input type='hidden' name='device_vendor_uuid' value='$device_vendor_uuid'>\n";
} }
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";
echo "</form>"; echo "</form>";
echo "<br /><br />"; echo "<br /><br />";
if ($action == "update") { if ($action == "update") {
require "device_vendor_functions.php"; require "device_vendor_functions.php";
} }
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,65 +1,65 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('device_vendor_function_delete')) { if (permission_exists('device_vendor_function_delete')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the id //get the id
if (count($_GET)>0) { if (count($_GET)>0) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
$device_vendor_uuid = check_str($_GET["device_vendor_uuid"]); $device_vendor_uuid = check_str($_GET["device_vendor_uuid"]);
} }
//delete the data //delete the data
if (strlen($id)>0) { if (strlen($id)>0) {
//delete device_vendor_function //delete device_vendor_function
$sql = "delete from v_device_vendor_functions "; $sql = "delete from v_device_vendor_functions ";
$sql .= "where device_vendor_function_uuid = '$id' "; $sql .= "where device_vendor_function_uuid = '$id' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
unset($sql); unset($sql);
} }
//redirect the user //redirect the user
messages::add($text['message-delete']); messages::add($text['message-delete']);
header('Location: device_vendor_function_edit.php?id='.$device_vendor_uuid); header('Location: device_vendor_function_edit.php?id='.$device_vendor_uuid);
?> ?>

View File

@ -1,393 +1,393 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//delete the group from the menu item //delete the group from the menu item
if ($_REQUEST["a"] == "delete" && permission_exists("device_vendor_function_delete") && $_REQUEST["id"] != '') { if ($_REQUEST["a"] == "delete" && permission_exists("device_vendor_function_delete") && $_REQUEST["id"] != '') {
//get the id //get the id
$device_vendor_function_group_uuid = check_str($_REQUEST["id"]); $device_vendor_function_group_uuid = check_str($_REQUEST["id"]);
$device_vendor_function_uuid = check_str($_REQUEST["device_vendor_function_uuid"]); $device_vendor_function_uuid = check_str($_REQUEST["device_vendor_function_uuid"]);
$device_vendor_uuid = check_str($_REQUEST["device_vendor_uuid"]); $device_vendor_uuid = check_str($_REQUEST["device_vendor_uuid"]);
//delete the group from the users //delete the group from the users
$sql = "delete from v_device_vendor_function_groups "; $sql = "delete from v_device_vendor_function_groups ";
$sql .= "where device_vendor_function_group_uuid = '".$device_vendor_function_group_uuid."' "; $sql .= "where device_vendor_function_group_uuid = '".$device_vendor_function_group_uuid."' ";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
//redirect the browser //redirect the browser
messages::add($text['message-delete']); messages::add($text['message-delete']);
header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid); header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid);
return; return;
} }
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit')) { if (permission_exists('device_vendor_function_add') || permission_exists('device_vendor_function_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (isset($_REQUEST["id"])) {
$action = "update"; $action = "update";
$device_vendor_function_uuid = check_str($_REQUEST["id"]); $device_vendor_function_uuid = check_str($_REQUEST["id"]);
} }
else { else {
$action = "add"; $action = "add";
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//set the parent uuid //set the parent uuid
if (strlen($_GET["device_vendor_uuid"]) > 0) { if (strlen($_GET["device_vendor_uuid"]) > 0) {
$device_vendor_uuid = check_str($_GET["device_vendor_uuid"]); $device_vendor_uuid = check_str($_GET["device_vendor_uuid"]);
} }
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (count($_POST)>0) { if (count($_POST)>0) {
//$label = check_str($_POST["label"]); //$label = check_str($_POST["label"]);
$name = check_str($_POST["name"]); $name = check_str($_POST["name"]);
$value = check_str($_POST["value"]); $value = check_str($_POST["value"]);
$enabled = check_str($_POST["enabled"]); $enabled = check_str($_POST["enabled"]);
$description = check_str($_POST["description"]); $description = check_str($_POST["description"]);
} }
//process the http variables //process the http variables
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get the uuid //get the uuid
if ($action == "update") { if ($action == "update") {
$device_vendor_function_uuid = check_str($_POST["device_vendor_function_uuid"]); $device_vendor_function_uuid = check_str($_POST["device_vendor_function_uuid"]);
} }
//check for all required data //check for all required data
$msg = ''; $msg = '';
//if (strlen($label) == 0) { $msg .= $text['message-required']." ".$text['label-label']."<br>\n"; } //if (strlen($label) == 0) { $msg .= $text['message-required']." ".$text['label-label']."<br>\n"; }
if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."<br>\n"; } if (strlen($name) == 0) { $msg .= $text['message-required']." ".$text['label-name']."<br>\n"; }
if (strlen($value) == 0) { $msg .= $text['message-required']." ".$text['label-value']."<br>\n"; } if (strlen($value) == 0) { $msg .= $text['message-required']." ".$text['label-value']."<br>\n"; }
if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; } if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
//if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; } //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add or update the database //add or update the database
if ($_POST["persistformvar"] != "true") { if ($_POST["persistformvar"] != "true") {
//add vendor functions //add vendor functions
if ($action == "add" && permission_exists('device_vendor_function_add')) { if ($action == "add" && permission_exists('device_vendor_function_add')) {
$device_vendor_function_uuid = uuid(); $device_vendor_function_uuid = uuid();
$sql = "insert into v_device_vendor_functions "; $sql = "insert into v_device_vendor_functions ";
$sql .= "("; $sql .= "(";
$sql .= "device_vendor_function_uuid, "; $sql .= "device_vendor_function_uuid, ";
$sql .= "device_vendor_uuid, "; $sql .= "device_vendor_uuid, ";
//$sql .= "label, "; //$sql .= "label, ";
$sql .= "name, "; $sql .= "name, ";
$sql .= "value, "; $sql .= "value, ";
$sql .= "enabled, "; $sql .= "enabled, ";
$sql .= "description "; $sql .= "description ";
$sql .= ")"; $sql .= ")";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
$sql .= "'".$device_vendor_function_uuid."', "; $sql .= "'".$device_vendor_function_uuid."', ";
$sql .= "'$device_vendor_uuid', "; $sql .= "'$device_vendor_uuid', ";
//$sql .= "'$label', "; //$sql .= "'$label', ";
$sql .= "'$name', "; $sql .= "'$name', ";
$sql .= "'$value', "; $sql .= "'$value', ";
$sql .= "'$enabled', "; $sql .= "'$enabled', ";
$sql .= "'$description' "; $sql .= "'$description' ";
$sql .= ")"; $sql .= ")";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
} //if ($action == "add") } //if ($action == "add")
//update vendor functions //update vendor functions
if ($action == "update" && permission_exists('device_vendor_function_edit')) { if ($action == "update" && permission_exists('device_vendor_function_edit')) {
$sql = "update v_device_vendor_functions set "; $sql = "update v_device_vendor_functions set ";
$sql .= "device_vendor_uuid = '$device_vendor_uuid', "; $sql .= "device_vendor_uuid = '$device_vendor_uuid', ";
//$sql .= "label = '$label', "; //$sql .= "label = '$label', ";
$sql .= "name = '$name', "; $sql .= "name = '$name', ";
$sql .= "value = '$value', "; $sql .= "value = '$value', ";
$sql .= "enabled = '$enabled', "; $sql .= "enabled = '$enabled', ";
$sql .= "description = '$description' "; $sql .= "description = '$description' ";
$sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid'"; $sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid'";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
} //if ($action == "update") } //if ($action == "update")
//add a group to the menu //add a group to the menu
if (permission_exists('device_vendor_function_add') && $_REQUEST["group_uuid_name"] != '') { if (permission_exists('device_vendor_function_add') && $_REQUEST["group_uuid_name"] != '') {
//get the group uuid and group_name //get the group uuid and group_name
$group_data = explode('|', check_str($_REQUEST["group_uuid_name"])); $group_data = explode('|', check_str($_REQUEST["group_uuid_name"]));
$group_uuid = $group_data[0]; $group_uuid = $group_data[0];
$group_name = $group_data[1]; $group_name = $group_data[1];
//add the group to the menu //add the group to the menu
if (strlen($device_vendor_function_uuid) > 0) { if (strlen($device_vendor_function_uuid) > 0) {
$device_vendor_function_group_uuid = uuid(); $device_vendor_function_group_uuid = uuid();
$sql = "insert into v_device_vendor_function_groups "; $sql = "insert into v_device_vendor_function_groups ";
$sql .= "("; $sql .= "(";
$sql .= "device_vendor_function_group_uuid, "; $sql .= "device_vendor_function_group_uuid, ";
$sql .= "device_vendor_function_uuid, "; $sql .= "device_vendor_function_uuid, ";
$sql .= "device_vendor_uuid, "; $sql .= "device_vendor_uuid, ";
$sql .= "group_name, "; $sql .= "group_name, ";
$sql .= "group_uuid "; $sql .= "group_uuid ";
$sql .= ")"; $sql .= ")";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
$sql .= "'".$device_vendor_function_group_uuid."', "; $sql .= "'".$device_vendor_function_group_uuid."', ";
$sql .= "'".$device_vendor_function_uuid."', "; $sql .= "'".$device_vendor_function_uuid."', ";
$sql .= "'".$device_vendor_uuid."', "; $sql .= "'".$device_vendor_uuid."', ";
$sql .= "'".$group_name."', "; $sql .= "'".$group_name."', ";
$sql .= "'".$group_uuid."' "; $sql .= "'".$group_uuid."' ";
$sql .= ")"; $sql .= ")";
$db->exec($sql); $db->exec($sql);
} }
} }
//redirect the user //redirect the user
$_SESSION["message"] = $text['message-'.$action]; $_SESSION["message"] = $text['message-'.$action];
header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid); header("Location: device_vendor_function_edit.php?id=".$device_vendor_function_uuid ."&device_vendor_uuid=".$device_vendor_uuid);
return; return;
} //if ($_POST["persistformvar"] != "true") } //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$device_vendor_function_uuid = check_str($_GET["id"]); $device_vendor_function_uuid = check_str($_GET["id"]);
$sql = "select * from v_device_vendor_functions "; $sql = "select * from v_device_vendor_functions ";
$sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid' "; $sql .= "where device_vendor_function_uuid = '$device_vendor_function_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$device_vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); $device_vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($device_vendor_functions as &$row) { foreach ($device_vendor_functions as &$row) {
//$label = $row["label"]; //$label = $row["label"];
$name = $row["name"]; $name = $row["name"];
$value = $row["value"]; $value = $row["value"];
$enabled = $row["enabled"]; $enabled = $row["enabled"];
$description = $row["description"]; $description = $row["description"];
} }
unset ($prep_statement); unset ($prep_statement);
} }
//group groups assigned //group groups assigned
$sql = "select "; $sql = "select ";
$sql .= " fg.*, g.domain_uuid as group_domain_uuid "; $sql .= " fg.*, g.domain_uuid as group_domain_uuid ";
$sql .= "from "; $sql .= "from ";
$sql .= " v_device_vendor_function_groups as fg, "; $sql .= " v_device_vendor_function_groups as fg, ";
$sql .= " v_groups as g "; $sql .= " v_groups as g ";
$sql .= "where "; $sql .= "where ";
$sql .= " fg.group_uuid = g.group_uuid "; $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_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 .= " 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 .= "order by ";
$sql .= " g.domain_uuid desc, "; $sql .= " g.domain_uuid desc, ";
$sql .= " g.group_name asc "; $sql .= " g.group_name asc ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid); $prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid);
$prep_statement->bindParam(':device_vendor_function_uuid', $device_vendor_function_uuid); $prep_statement->bindParam(':device_vendor_function_uuid', $device_vendor_function_uuid);
$prep_statement->execute(); $prep_statement->execute();
$function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); $function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($sql, $prep_statement); unset($sql, $prep_statement);
//set the assigned_groups array //set the assigned_groups array
if (is_array($menu_item_groups)) { if (is_array($menu_item_groups)) {
foreach($menu_item_groups as $field) { foreach($menu_item_groups as $field) {
if (strlen($field['group_name']) > 0) { if (strlen($field['group_name']) > 0) {
$assigned_groups[] = $field['group_uuid']; $assigned_groups[] = $field['group_uuid'];
} }
} }
} }
//get the groups //get the groups
$sql = "select * from v_groups "; $sql = "select * from v_groups ";
if (sizeof($assigned_groups) > 0) { if (sizeof($assigned_groups) > 0) {
$sql .= "where group_uuid not in ('".implode("','",$assigned_groups)."') "; $sql .= "where group_uuid not in ('".implode("','",$assigned_groups)."') ";
} }
$sql .= "order by domain_uuid desc, group_name asc "; $sql .= "order by domain_uuid desc, group_name asc ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); $groups = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($sql, $prep_statement); unset($sql, $prep_statement);
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-device_vendor_function']."</b><br><br></td>\n"; echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-device_vendor_function']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n"; echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='device_vendor_edit.php?id=$device_vendor_uuid'\" value='".$text['button-back']."'>"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='device_vendor_edit.php?id=$device_vendor_uuid'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
//echo "<tr>\n"; //echo "<tr>\n";
//echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; //echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
//echo " ".$text['label-label']."\n"; //echo " ".$text['label-label']."\n";
//echo "</td>\n"; //echo "</td>\n";
//echo "<td class='vtable' align='left'>\n"; //echo "<td class='vtable' align='left'>\n";
//echo " <input class='formfld' type='text' name='label' maxlength='255' value=\"$label\">\n"; //echo " <input class='formfld' type='text' name='label' maxlength='255' value=\"$label\">\n";
//echo "<br />\n"; //echo "<br />\n";
//echo $text['description-label']."\n"; //echo $text['description-label']."\n";
//echo "</td>\n"; //echo "</td>\n";
//echo "</tr>\n"; //echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-name']."\n"; echo " ".$text['label-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"$name\">\n"; echo " <input class='formfld' type='text' name='name' maxlength='255' value=\"$name\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-name']."\n"; echo $text['description-name']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-value']."\n"; echo " ".$text['label-value']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='value' maxlength='255' value=\"$value\">\n"; echo " <input class='formfld' type='text' name='value' maxlength='255' value=\"$value\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-value']."\n"; echo $text['description-value']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
//echo "<pre>\n"; //echo "<pre>\n";
//print_r($function_groups); //print_r($function_groups);
//echo "</pre>\n"; //echo "</pre>\n";
echo " <tr>"; echo " <tr>";
echo " <td class='vncell' valign='top'>".$text['label-groups']."</td>"; echo " <td class='vncell' valign='top'>".$text['label-groups']."</td>";
echo " <td class='vtable'>"; echo " <td class='vtable'>";
if (is_array($function_groups)) { if (is_array($function_groups)) {
echo "<table cellpadding='0' cellspacing='0' border='0'>\n"; echo "<table cellpadding='0' cellspacing='0' border='0'>\n";
foreach($function_groups as $field) { foreach($function_groups as $field) {
if (strlen($field['group_name']) > 0) { if (strlen($field['group_name']) > 0) {
echo "<tr>\n"; echo "<tr>\n";
echo " <td class='vtable' style='white-space: nowrap; padding-right: 30px;' nowrap='nowrap'>"; echo " <td class='vtable' style='white-space: nowrap; padding-right: 30px;' nowrap='nowrap'>";
echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null); echo $field['group_name'].(($field['group_domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['group_domain_uuid']]['domain_name'] : null);
echo " </td>\n"; echo " </td>\n";
if (permission_exists('group_member_delete') || if_group("superadmin")) { if (permission_exists('group_member_delete') || if_group("superadmin")) {
echo " <td class='list_control_icons' style='width: 25px;'>"; echo " <td class='list_control_icons' style='width: 25px;'>";
echo "<a href='device_vendor_function_edit.php?id=".$field['device_vendor_function_group_uuid']."&group_uuid=".$field['group_uuid']."&device_vendor_function_uuid=".$device_vendor_function_uuid."&device_vendor_uuid=".$device_vendor_uuid."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>"; echo "<a href='device_vendor_function_edit.php?id=".$field['device_vendor_function_group_uuid']."&group_uuid=".$field['group_uuid']."&device_vendor_function_uuid=".$device_vendor_function_uuid."&device_vendor_uuid=".$device_vendor_uuid."&a=delete' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a>";
echo " </td>"; echo " </td>";
} }
echo "</tr>\n"; echo "</tr>\n";
} }
} }
echo "</table>\n"; echo "</table>\n";
} }
if (is_array($groups)) { if (is_array($groups)) {
echo "<br />\n"; echo "<br />\n";
echo "<select name='group_uuid_name' class='formfld' style='width: auto; margin-right: 3px;'>\n"; echo "<select name='group_uuid_name' class='formfld' style='width: auto; margin-right: 3px;'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
foreach($groups as $field) { foreach($groups as $field) {
if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins if ($field['group_name'] == "superadmin" && !if_group("superadmin")) { continue; } //only show the superadmin group to other superadmins
if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins if ($field['group_name'] == "admin" && (!if_group("superadmin") && !if_group("admin") )) { continue; } //only show the admin group to other admins
if (!in_array($field["group_uuid"], $assigned_groups)) { if (!in_array($field["group_uuid"], $assigned_groups)) {
echo " <option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n"; echo " <option value='".$field['group_uuid']."|".$field['group_name']."'>".$field['group_name'].(($field['domain_uuid'] != '') ? "@".$_SESSION['domains'][$field['domain_uuid']]['domain_name'] : null)."</option>\n";
} }
} }
echo "</select>"; echo "</select>";
echo "<input type='submit' class='btn' name='submit' value=\"".$text['button-add']."\">\n"; echo "<input type='submit' class='btn' name='submit' value=\"".$text['button-add']."\">\n";
} }
echo " </td>"; echo " </td>";
echo " </tr>"; echo " </tr>";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-enabled']."\n"; echo " ".$text['label-enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='enabled'>\n"; echo " <select class='formfld' name='enabled'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if ($enabled == "true") { if ($enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n"; echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
} }
else { else {
echo " <option value='true'>".$text['label-true']."</option>\n"; echo " <option value='true'>".$text['label-true']."</option>\n";
} }
if ($enabled == "false") { if ($enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n"; echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
} }
else { else {
echo " <option value='false'>".$text['label-false']."</option>\n"; echo " <option value='false'>".$text['label-false']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-enabled']."\n"; echo $text['description-enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-description']."\n"; echo " ".$text['label-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='description' maxlength='255' value=\"$description\">\n"; echo " <input class='formfld' type='text' name='description' maxlength='255' value=\"$description\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-description']."\n"; echo $text['description-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
echo " <input type='hidden' name='device_vendor_uuid' value='$device_vendor_uuid'>\n"; echo " <input type='hidden' name='device_vendor_uuid' value='$device_vendor_uuid'>\n";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='device_vendor_function_uuid' value='$device_vendor_function_uuid'>\n"; echo " <input type='hidden' name='device_vendor_function_uuid' value='$device_vendor_function_uuid'>\n";
} }
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";
echo "</form>"; echo "</form>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,218 +1,218 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016-2017 Portions created by the Initial Developer are Copyright (C) 2016-2017
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('device_vendor_function_view')) { if (permission_exists('device_vendor_function_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get variables used to control the order //get variables used to control the order
$order_by = check_str($_GET["order_by"]); $order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]); $order = check_str($_GET["order"]);
//add the search term //add the search term
$search = check_str($_GET["search"]); $search = check_str($_GET["search"]);
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql_search = "and ("; $sql_search = "and (";
$sql_search .= "label like '%".$search."%'"; $sql_search .= "label like '%".$search."%'";
$sql_search .= "or name like '%".$search."%'"; $sql_search .= "or name like '%".$search."%'";
$sql_search .= "or value like '%".$search."%'"; $sql_search .= "or value like '%".$search."%'";
$sql_search .= "or enabled like '%".$search."%'"; $sql_search .= "or enabled like '%".$search."%'";
$sql_search .= "or description like '%".$search."%'"; $sql_search .= "or description like '%".$search."%'";
$sql_search .= ")"; $sql_search .= ")";
} }
//additional includes //additional includes
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
//prepare to page the results //prepare to page the results
$sql = "select count(*) as num_rows from v_device_vendor_functions "; $sql = "select count(*) as num_rows from v_device_vendor_functions ";
$sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; $sql .= "where device_vendor_uuid = '$device_vendor_uuid' ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; } if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($sql); $prep_statement = $db->prepare($sql);
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) { if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows']; $num_rows = $row['num_rows'];
} }
else { else {
$num_rows = '0'; $num_rows = '0';
} }
} }
//prepare to page the results //prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = ""; $param = "";
$page = $_GET['page']; $page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the list //get the list
$sql = "select * from v_device_vendor_functions "; $sql = "select * from v_device_vendor_functions ";
$sql .= "where device_vendor_uuid = '$device_vendor_uuid' "; $sql .= "where device_vendor_uuid = '$device_vendor_uuid' ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; } if (strlen($order_by) == 0) { $sql .= "order by name asc "; } else { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset "; $sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED); $vendor_functions = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql); unset ($prep_statement, $sql);
//alternate the row style //alternate the row style
$c = 0; $c = 0;
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
$row_style["1"] = "row_style1"; $row_style["1"] = "row_style1";
//show the content //show the content
echo "<table width='100%' border='0'>\n"; echo "<table width='100%' border='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-device_vendor_functions']."</b></td>\n"; echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-device_vendor_functions']."</b></td>\n";
//echo " <form method='get' action=''>\n"; //echo " <form method='get' action=''>\n";
//echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n"; //echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
//echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n"; //echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n";
//echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n"; //echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
//echo " </td>\n"; //echo " </td>\n";
//echo " </form>\n"; //echo " </form>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<th>".$text['label-label']."</th>\n"; echo "<th>".$text['label-label']."</th>\n";
echo th_order_by('name', $text['label-name'], $order_by, $order); echo th_order_by('name', $text['label-name'], $order_by, $order);
echo th_order_by('value', $text['label-value'], $order_by, $order); echo th_order_by('value', $text['label-value'], $order_by, $order);
echo "<th>".$text['label-groups']."</th>\n"; echo "<th>".$text['label-groups']."</th>\n";
echo th_order_by('enabled', $text['label-enabled'], $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 th_order_by('description', $text['label-description'], $order_by, $order);
echo "<td class='list_control_icons'>"; echo "<td class='list_control_icons'>";
if (permission_exists('device_vendor_function_add')) { if (permission_exists('device_vendor_function_add')) {
echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;\n"; echo "&nbsp;\n";
} }
echo "</td>\n"; echo "</td>\n";
echo "<tr>\n"; echo "<tr>\n";
if (is_array($vendor_functions)) { if (is_array($vendor_functions)) {
foreach($vendor_functions as $row) { foreach($vendor_functions as $row) {
//get the groups that have been assigned to the vendor functions //get the groups that have been assigned to the vendor functions
$sql = "select "; $sql = "select ";
$sql .= " fg.*, g.domain_uuid as group_domain_uuid "; $sql .= " fg.*, g.domain_uuid as group_domain_uuid ";
$sql .= "from "; $sql .= "from ";
$sql .= " v_device_vendor_function_groups as fg, "; $sql .= " v_device_vendor_function_groups as fg, ";
$sql .= " v_groups as g "; $sql .= " v_groups as g ";
$sql .= "where "; $sql .= "where ";
$sql .= " fg.group_uuid = g.group_uuid "; $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_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 .= " and fg.device_vendor_function_uuid = '".$row['device_vendor_function_uuid']."' "; //$sql .= " and fg.device_vendor_function_uuid = '".$row['device_vendor_function_uuid']."' ";
$sql .= "order by "; $sql .= "order by ";
$sql .= " g.domain_uuid desc, "; $sql .= " g.domain_uuid desc, ";
$sql .= " g.group_name asc "; $sql .= " g.group_name asc ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid); $prep_statement->bindParam(':device_vendor_uuid', $device_vendor_uuid);
$prep_statement->bindParam(':device_vendor_function_uuid', $row['device_vendor_function_uuid']); $prep_statement->bindParam(':device_vendor_function_uuid', $row['device_vendor_function_uuid']);
$prep_statement->execute(); $prep_statement->execute();
$vendor_function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED); $vendor_function_groups = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset($sql, $prep_statement); unset($sql, $prep_statement);
unset($group_list); unset($group_list);
foreach ($vendor_function_groups as &$sub_row) { 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[] = $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) : ''; $group_list = isset($group_list) ? implode(', ', $group_list) : '';
unset ($vendor_function_groups); unset ($vendor_function_groups);
//build the edit link //build the edit link
if (permission_exists('device_vendor_function_edit')) { 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']."'"; $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 //show the row of data
echo "<tr ".$tr_link.">\n"; echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-'.$row['name']]."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$text['label-'.$row['name']]."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['name']." &nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['name']." &nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['value']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['value']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$group_list."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$group_list."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['enabled']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['enabled']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['description']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('device_vendor_function_edit')) { if (permission_exists('device_vendor_function_edit')) {
echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>"; echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
} }
if (permission_exists('device_vendor_function_delete')) { if (permission_exists('device_vendor_function_delete')) {
echo "<a href='device_vendor_function_delete.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>"; echo "<a href='device_vendor_function_delete.php?device_vendor_uuid=".$row['device_vendor_uuid']."&id=".$row['device_vendor_function_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
} }
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
//toggle the value of the c variable //toggle the value of the c variable
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($sql, $result, $row_count);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='7' align='left'>\n"; echo "<td colspan='7' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n"; echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n"; echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n"; echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('device_vendor_function_add')) { if (permission_exists('device_vendor_function_add')) {
echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='device_vendor_function_edit.php?device_vendor_uuid=".$_GET['id']."' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;"; echo "&nbsp;";
} }
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,185 +1,185 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('device_vendor_view')) { if (permission_exists('device_vendor_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get variables used to control the order //get variables used to control the order
$order_by = check_str($_GET["order_by"]); $order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]); $order = check_str($_GET["order"]);
//add the search term //add the search term
$search = check_str($_GET["search"]); $search = check_str($_GET["search"]);
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql_search = "where ("; $sql_search = "where (";
$sql_search .= "name like '%".$search."%'"; $sql_search .= "name like '%".$search."%'";
$sql_search .= "or enabled like '%".$search."%'"; $sql_search .= "or enabled like '%".$search."%'";
$sql_search .= "or description like '%".$search."%'"; $sql_search .= "or description like '%".$search."%'";
$sql_search .= ")"; $sql_search .= ")";
} }
//additional includes //additional includes
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
//prepare to page the results //prepare to page the results
$sql = "select count(*) as num_rows from v_device_vendors "; $sql = "select count(*) as num_rows from v_device_vendors ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($sql); $prep_statement = $db->prepare($sql);
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) { if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows']; $num_rows = $row['num_rows'];
} }
else { else {
$num_rows = '0'; $num_rows = '0';
} }
} }
//prepare to page the results //prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = ""; $param = "";
$page = $_GET['page']; $page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the list //get the list
$sql = "select * from v_device_vendors "; $sql = "select * from v_device_vendors ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset "; $sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql); unset ($prep_statement, $sql);
//alternate the row style //alternate the row style
$c = 0; $c = 0;
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
$row_style["1"] = "row_style1"; $row_style["1"] = "row_style1";
//show the content //show the content
echo "<table width='100%' border='0'>\n"; echo "<table width='100%' border='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-device_vendors']."</b></td>\n"; echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-device_vendors']."</b></td>\n";
echo " <form method='get' action=''>\n"; echo " <form method='get' action=''>\n";
echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n"; echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
if (permission_exists('device_vendor_restore')) { if (permission_exists('device_vendor_restore')) {
echo " <input type='button' class='btn' alt='".$text['button-restore']."' onclick=\"document.location='device_vendor_restore.php'\" value='".$text['button-restore']."'>"; echo " <input type='button' class='btn' alt='".$text['button-restore']."' onclick=\"document.location='device_vendor_restore.php'\" value='".$text['button-restore']."'>";
} }
echo " <input type='button' class='btn' alt='".$text['button-back']."' onclick=\"document.location='devices.php'\" value='".$text['button-back']."'>"; echo " <input type='button' class='btn' alt='".$text['button-back']."' onclick=\"document.location='devices.php'\" value='".$text['button-back']."'>";
echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n"; echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n"; echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </form>\n"; echo " </form>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align='left' colspan='2'>\n"; echo " <td align='left' colspan='2'>\n";
echo " ".$text['title_description-device_vendor']."<br /><br />\n"; echo " ".$text['title_description-device_vendor']."<br /><br />\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo th_order_by('name', $text['label-name'], $order_by, $order); 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('enabled', $text['label-enabled'], $order_by, $order);
echo th_order_by('description', $text['label-description'], $order_by, $order); echo th_order_by('description', $text['label-description'], $order_by, $order);
echo "<td class='list_control_icons'>"; echo "<td class='list_control_icons'>";
if (permission_exists('device_vendor_add')) { if (permission_exists('device_vendor_add')) {
echo "<a href='device_vendor_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='device_vendor_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;\n"; echo "&nbsp;\n";
} }
echo "</td>\n"; echo "</td>\n";
echo "<tr>\n"; echo "<tr>\n";
if (is_array($result)) { if (is_array($result)) {
foreach($result as $row) { foreach($result as $row) {
if (permission_exists('device_vendor_edit')) { if (permission_exists('device_vendor_edit')) {
$tr_link = "href='device_vendor_edit.php?id=".$row['device_vendor_uuid']."'"; $tr_link = "href='device_vendor_edit.php?id=".$row['device_vendor_uuid']."'";
} }
echo "<tr ".$tr_link.">\n"; echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['name']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['name']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['enabled']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['enabled']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['description']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('device_vendor_edit')) { if (permission_exists('device_vendor_edit')) {
echo "<a href='device_vendor_edit.php?id=".$row['device_vendor_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>"; echo "<a href='device_vendor_edit.php?id=".$row['device_vendor_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
} }
if (permission_exists('device_vendor_delete')) { if (permission_exists('device_vendor_delete')) {
echo "<a href='device_vendor_delete.php?id=".$row['device_vendor_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>"; echo "<a href='device_vendor_delete.php?id=".$row['device_vendor_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
} }
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($sql, $result, $row_count);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='4' align='left'>\n"; echo "<td colspan='4' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n"; echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n"; echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n"; echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('device_vendor_add')) { if (permission_exists('device_vendor_add')) {
echo "<a href='device_vendor_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='device_vendor_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;"; echo "&nbsp;";
} }
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,249 +1,249 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012 Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
James Rose <james.o.rose@gmail.com> James Rose <james.o.rose@gmail.com>
*/ */
include "root.php"; include "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
require_once "resources/functions/object_to_array.php"; require_once "resources/functions/object_to_array.php";
require_once "resources/functions/parse_message.php"; require_once "resources/functions/parse_message.php";
if (permission_exists('fax_inbox_view')) { if (permission_exists('fax_inbox_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get fax server uuid, set connection parameters //get fax server uuid, set connection parameters
if (strlen($_GET['id']) > 0) { if (strlen($_GET['id']) > 0) {
$fax_uuid = check_str($_GET["id"]); $fax_uuid = check_str($_GET["id"]);
if (if_group("superadmin") || if_group("admin")) { if (if_group("superadmin") || if_group("admin")) {
//show all fax extensions //show all fax extensions
$sql = "select * from v_fax "; $sql = "select * from v_fax ";
$sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and fax_uuid = '$fax_uuid' "; $sql .= "and fax_uuid = '$fax_uuid' ";
} }
else { else {
//show only assigned fax extensions //show only assigned fax extensions
$sql = "select * from v_fax as f, v_fax_users as u "; $sql = "select * from v_fax as f, v_fax_users as u ";
$sql .= "where f.fax_uuid = u.fax_uuid "; $sql .= "where f.fax_uuid = u.fax_uuid ";
$sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' "; $sql .= "and f.domain_uuid = '".$_SESSION['domain_uuid']."' ";
$sql .= "and f.fax_uuid = '$fax_uuid' "; $sql .= "and f.fax_uuid = '$fax_uuid' ";
$sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' "; $sql .= "and u.user_uuid = '".$_SESSION['user_uuid']."' ";
} }
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) == 0) { if (count($result) == 0) {
if (!if_group("superadmin") && !if_group("admin")) { if (!if_group("superadmin") && !if_group("admin")) {
echo "access denied"; echo "access denied";
exit; exit;
} }
} }
foreach ($result as &$row) { foreach ($result as &$row) {
$fax_name = $row["fax_name"]; $fax_name = $row["fax_name"];
$fax_extension = $row["fax_extension"]; $fax_extension = $row["fax_extension"];
$fax_email_connection_type = $row["fax_email_connection_type"]; $fax_email_connection_type = $row["fax_email_connection_type"];
$fax_email_connection_host = $row["fax_email_connection_host"]; $fax_email_connection_host = $row["fax_email_connection_host"];
$fax_email_connection_port = $row["fax_email_connection_port"]; $fax_email_connection_port = $row["fax_email_connection_port"];
$fax_email_connection_security = $row["fax_email_connection_security"]; $fax_email_connection_security = $row["fax_email_connection_security"];
$fax_email_connection_validate = $row["fax_email_connection_validate"]; $fax_email_connection_validate = $row["fax_email_connection_validate"];
$fax_email_connection_username = $row["fax_email_connection_username"]; $fax_email_connection_username = $row["fax_email_connection_username"];
$fax_email_connection_password = $row["fax_email_connection_password"]; $fax_email_connection_password = $row["fax_email_connection_password"];
$fax_email_connection_mailbox = $row["fax_email_connection_mailbox"]; $fax_email_connection_mailbox = $row["fax_email_connection_mailbox"];
$fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"]; $fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"];
break; break;
} }
unset ($prep_statement); unset ($prep_statement);
// make connection // make connection
$fax_email_connection = "{".$fax_email_connection_host.":".$fax_email_connection_port."/".$fax_email_connection_type; $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_security != '') ? "/".$fax_email_connection_security : "/notls";
$fax_email_connection .= "/".(($fax_email_connection_validate == 'false') ? "no" : null)."validate-cert"; $fax_email_connection .= "/".(($fax_email_connection_validate == 'false') ? "no" : null)."validate-cert";
$fax_email_connection .= "}".$fax_email_connection_mailbox; $fax_email_connection .= "}".$fax_email_connection_mailbox;
if (!$connection = imap_open($fax_email_connection, $fax_email_connection_username, $fax_email_connection_password)) { 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'); messages::add($text['message-cannot_connect']."(".imap_last_error().")", 'neative');
header("Location: fax.php"); header("Location: fax.php");
exit; exit;
} }
} }
else { else {
header("Location: fax.php"); header("Location: fax.php");
exit; exit;
} }
//message action //message action
if ($_GET['email_id'] != '') { if ($_GET['email_id'] != '') {
$email_id = check_str($_GET['email_id']); $email_id = check_str($_GET['email_id']);
//download attachment //download attachment
if (isset($_GET['download'])) { if (isset($_GET['download'])) {
$message = parse_message($connection, $email_id, FT_UID); $message = parse_message($connection, $email_id, FT_UID);
$attachment = $message['attachments'][0]; $attachment = $message['attachments'][0];
if ($attachment) { if ($attachment) {
$file_type = pathinfo($attachment['name'], PATHINFO_EXTENSION); $file_type = pathinfo($attachment['name'], PATHINFO_EXTENSION);
switch ($file_type) { switch ($file_type) {
case "pdf" : header("Content-Type: application/pdf"); break; case "pdf" : header("Content-Type: application/pdf"); break;
case "tif" : header("Contet-Type: image/tiff"); break; case "tif" : header("Contet-Type: image/tiff"); break;
} }
header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1 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("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // date in the past
header("Content-Length: ".$attachment['size']); header("Content-Length: ".$attachment['size']);
$browser = $_SERVER["HTTP_USER_AGENT"]; $browser = $_SERVER["HTTP_USER_AGENT"];
if (preg_match("/MSIE 5.5/", $browser) || preg_match("/MSIE 6.0/", $browser)) { if (preg_match("/MSIE 5.5/", $browser) || preg_match("/MSIE 6.0/", $browser)) {
header("Content-Disposition: filename=\"".$attachment['name']."\""); header("Content-Disposition: filename=\"".$attachment['name']."\"");
} }
else { else {
header("Content-Disposition: attachment; filename=\"".$attachment['name']."\""); header("Content-Disposition: attachment; filename=\"".$attachment['name']."\"");
} }
header("Content-Transfer-Encoding: binary"); header("Content-Transfer-Encoding: binary");
echo $attachment['data']; echo $attachment['data'];
exit; exit;
} }
else{ else{
//redirect user //redirect user
messages::add($text['message-download_failed'], 'negative'); messages::add($text['message-download_failed'], 'negative');
header("Location: ?id=".$fax_uuid); header("Location: ?id=".$fax_uuid);
exit; exit;
} }
} }
//delete email //delete email
if (isset($_GET['delete']) && permission_exists('fax_inbox_delete')) { if (isset($_GET['delete']) && permission_exists('fax_inbox_delete')) {
$message = parse_message($connection, $email_id, FT_UID); $message = parse_message($connection, $email_id, FT_UID);
$attachment = $message['attachments'][0]; $attachment = $message['attachments'][0];
if (imap_delete($connection, $email_id, FT_UID)) { if (imap_delete($connection, $email_id, FT_UID)) {
if (imap_expunge($connection)) { if (imap_expunge($connection)) {
//clean up local inbox copy //clean up local inbox copy
$fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name']; $fax_dir = $_SESSION['switch']['storage']['dir'].'/fax/'.$_SESSION['domain_name'];
@unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment['name']); @unlink($fax_dir.'/'.$fax_extension.'/inbox/'.$attachment['name']);
//redirect user //redirect user
messages::add($text['message-delete']); messages::add($text['message-delete']);
header("Location: ?id=".$fax_uuid); header("Location: ?id=".$fax_uuid);
exit; exit;
} }
} }
else { else {
//redirect user //redirect user
messages::add($text['message-delete_failed'], 'negative'); messages::add($text['message-delete_failed'], 'negative');
header("Location: ?id=".$fax_uuid); header("Location: ?id=".$fax_uuid);
exit; exit;
} }
} }
else { else {
//redirect user //redirect user
messages::add($text['message-delete_failed'], 'negative'); messages::add($text['message-delete_failed'], 'negative');
header("Location: ?id=".$fax_uuid); header("Location: ?id=".$fax_uuid);
exit; exit;
} }
} }
//get emails //get emails
$emails = imap_search($connection, "SUBJECT \"".$fax_email_inbound_subject_tag."\"", SE_UID); $emails = imap_search($connection, "SUBJECT \"".$fax_email_inbound_subject_tag."\"", SE_UID);
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
$row_style["1"] = "row_style1"; $row_style["1"] = "row_style1";
//show the inbox //show the inbox
$c = 0; $c = 0;
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align='left' valign='top'>\n"; echo " <td align='left' valign='top'>\n";
echo " <b>".$text['header-inbox'].": <span style='color: #000;'>".$fax_name." (".$fax_extension.")</span></b>\n"; echo " <b>".$text['header-inbox'].": <span style='color: #000;'>".$fax_name." (".$fax_extension.")</span></b>\n";
echo " </td>\n"; echo " </td>\n";
echo " <td width='70%' align='right' valign='top'>\n"; echo " <td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' alt='".$text['button-back']."' onclick=\"window.location='fax.php';\" value='".$text['button-back']."'>\n"; echo " <input type='button' class='btn' alt='".$text['button-back']."' onclick=\"window.location='fax.php';\" value='".$text['button-back']."'>\n";
echo " <input type='button' class='btn' alt='".$text['button-refresh']."' onclick=\"document.location.reload();\" value='".$text['button-refresh']."'>\n"; echo " <input type='button' class='btn' alt='".$text['button-refresh']."' onclick=\"document.location.reload();\" value='".$text['button-refresh']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "<br><br>\n"; echo "<br><br>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <th>".$text['label-fax_caller_id_name']."</th>\n"; echo " <th>".$text['label-fax_caller_id_name']."</th>\n";
echo " <th>".$text['label-fax_caller_id_number']."</th>\n"; echo " <th>".$text['label-fax_caller_id_number']."</th>\n";
echo " <th>".$text['table-file']."</th>\n"; echo " <th>".$text['table-file']."</th>\n";
echo " <th>".$text['label-email_size']."</th>\n"; echo " <th>".$text['label-email_size']."</th>\n";
echo " <th>".$text['label-email_received']."</th>\n"; echo " <th>".$text['label-email_received']."</th>\n";
if (permission_exists('fax_inbox_delete')) { if (permission_exists('fax_inbox_delete')) {
echo " <td style='width: 25px;' class='list_control_icons'>&nbsp;</td>\n"; echo " <td style='width: 25px;' class='list_control_icons'>&nbsp;</td>\n";
} }
echo " </tr>"; echo " </tr>";
if ($emails) { if ($emails) {
rsort($emails); // most recent on top rsort($emails); // most recent on top
foreach ($emails as $email_id) { foreach ($emails as $email_id) {
$metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID)); $metadata = object_to_array(imap_fetch_overview($connection, $email_id, FT_UID));
$message = parse_message($connection, $email_id, FT_UID); $message = parse_message($connection, $email_id, FT_UID);
$attachment = $message['attachments'][0]; $attachment = $message['attachments'][0];
$file_name = $attachment['name']; $file_name = $attachment['name'];
$caller_id_name = substr($file_name, 0, strpos($file_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; $caller_id_number = (is_numeric($caller_id_name)) ? format_phone((int) $caller_id_name) : null;
echo " <tr ".(($metadata[0]['seen'] == 0) ? "style='font-weight: bold;'" : null).">\n"; echo " <tr ".(($metadata[0]['seen'] == 0) ? "style='font-weight: bold;'" : null).">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$caller_id_name."</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$caller_id_name."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$caller_id_number."</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$caller_id_number."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'><a href='?id=".$fax_uuid."&email_id=".$email_id."&download'>".$file_name."</a></td>\n"; echo " <td valign='top' class='".$row_style[$c]."'><a href='?id=".$fax_uuid."&email_id=".$email_id."&download'>".$file_name."</a></td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".byte_convert($attachment['size'])."</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".byte_convert($attachment['size'])."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$metadata[0]['date']."</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$metadata[0]['date']."</td>\n";
if (permission_exists('fax_inbox_delete')) { if (permission_exists('fax_inbox_delete')) {
echo " <td style='width: 25px;' class='list_control_icons'><a href='?id=".$fax_uuid."&email_id=".$email_id."&delete' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a></td>\n"; echo " <td style='width: 25px;' class='list_control_icons'><a href='?id=".$fax_uuid."&email_id=".$email_id."&delete' onclick=\"return confirm('".$text['confirm-delete']."')\">".$v_link_label_delete."</a></td>\n";
} }
echo " </tr>\n"; echo " </tr>\n";
$c = ($c) ? 0 : 1; $c = ($c) ? 0 : 1;
} }
} }
else { else {
echo "<tr valign='top'>\n"; echo "<tr valign='top'>\n";
echo " <td colspan='4' style='text-align: center;'><br><br>".$text['message-no_faxes_found']."<br><br></td>\n"; echo " <td colspan='4' style='text-align: center;'><br><br>".$text['message-no_faxes_found']."<br><br></td>\n";
echo "</tr>\n"; echo "</tr>\n";
} }
echo "</table>"; echo "</table>";
echo "<br><br>"; echo "<br><br>";
/* close the connection */ /* close the connection */
imap_close($connection); imap_close($connection);
//show the footer //show the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,65 +1,65 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('pin_number_delete')) { if (permission_exists('pin_number_delete')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get the id //get the id
if (count($_GET)>0) { if (count($_GET)>0) {
$id = check_str($_GET["id"]); $id = check_str($_GET["id"]);
} }
//delete the data //delete the data
if (strlen($id)>0) { if (strlen($id)>0) {
//delete pin_number //delete pin_number
$sql = "delete from v_pin_numbers "; $sql = "delete from v_pin_numbers ";
$sql .= "where pin_number_uuid = '$id' "; $sql .= "where pin_number_uuid = '$id' ";
$sql .= "and domain_uuid = '$domain_uuid' "; $sql .= "and domain_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
unset($sql); unset($sql);
} }
//redirect the user //redirect the user
messages::add($text['message-delete']); messages::add($text['message-delete']);
header('Location: pin_numbers.php'); header('Location: pin_numbers.php');
?> ?>

View File

@ -1,240 +1,240 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('pin_number_add') || permission_exists('pin_number_edit')) { if (permission_exists('pin_number_add') || permission_exists('pin_number_edit')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//action add or update //action add or update
if (isset($_REQUEST["id"])) { if (isset($_REQUEST["id"])) {
$action = "update"; $action = "update";
$pin_number_uuid = check_str($_REQUEST["id"]); $pin_number_uuid = check_str($_REQUEST["id"]);
} }
else { else {
$action = "add"; $action = "add";
} }
//get http post variables and set them to php variables //get http post variables and set them to php variables
if (count($_POST)>0) { if (count($_POST)>0) {
$pin_number = check_str($_POST["pin_number"]); $pin_number = check_str($_POST["pin_number"]);
$accountcode = check_str($_POST["accountcode"]); $accountcode = check_str($_POST["accountcode"]);
$enabled = check_str($_POST["enabled"]); $enabled = check_str($_POST["enabled"]);
$description = check_str($_POST["description"]); $description = check_str($_POST["description"]);
} }
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) { if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = ''; $msg = '';
if ($action == "update") { if ($action == "update") {
$pin_number_uuid = check_str($_POST["pin_number_uuid"]); $pin_number_uuid = check_str($_POST["pin_number_uuid"]);
} }
//check for all required data //check for all required data
if (strlen($pin_number) == 0) { $msg .= $text['message-required']." ".$text['label-pin_number']."<br>\n"; } if (strlen($pin_number) == 0) { $msg .= $text['message-required']." ".$text['label-pin_number']."<br>\n"; }
//if (strlen($accountcode) == 0) { $msg .= $text['message-required']." ".$text['label-accountcode']."<br>\n"; } //if (strlen($accountcode) == 0) { $msg .= $text['message-required']." ".$text['label-accountcode']."<br>\n"; }
if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; } if (strlen($enabled) == 0) { $msg .= $text['message-required']." ".$text['label-enabled']."<br>\n"; }
//if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; } //if (strlen($description) == 0) { $msg .= $text['message-required']." ".$text['label-description']."<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/persist_form_var.php"; require_once "resources/persist_form_var.php";
echo "<div align='center'>\n"; echo "<div align='center'>\n";
echo "<table><tr><td>\n"; echo "<table><tr><td>\n";
echo $msg."<br />"; echo $msg."<br />";
echo "</td></tr></table>\n"; echo "</td></tr></table>\n";
persistformvar($_POST); persistformvar($_POST);
echo "</div>\n"; echo "</div>\n";
require_once "resources/footer.php"; require_once "resources/footer.php";
return; return;
} }
//add or update the database //add or update the database
if ($_POST["persistformvar"] != "true") { if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('pin_number_add')) { if ($action == "add" && permission_exists('pin_number_add')) {
$sql = "insert into v_pin_numbers "; $sql = "insert into v_pin_numbers ";
$sql .= "("; $sql .= "(";
$sql .= "domain_uuid, "; $sql .= "domain_uuid, ";
$sql .= "pin_number_uuid, "; $sql .= "pin_number_uuid, ";
$sql .= "pin_number, "; $sql .= "pin_number, ";
$sql .= "accountcode, "; $sql .= "accountcode, ";
$sql .= "enabled, "; $sql .= "enabled, ";
$sql .= "description "; $sql .= "description ";
$sql .= ")"; $sql .= ")";
$sql .= "values "; $sql .= "values ";
$sql .= "("; $sql .= "(";
$sql .= "'$domain_uuid', "; $sql .= "'$domain_uuid', ";
$sql .= "'".uuid()."', "; $sql .= "'".uuid()."', ";
$sql .= "'$pin_number', "; $sql .= "'$pin_number', ";
$sql .= "'$accountcode', "; $sql .= "'$accountcode', ";
$sql .= "'$enabled', "; $sql .= "'$enabled', ";
$sql .= "'$description' "; $sql .= "'$description' ";
$sql .= ")"; $sql .= ")";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-add']); messages::add($text['message-add']);
header("Location: pin_numbers.php"); header("Location: pin_numbers.php");
return; return;
} //if ($action == "add") } //if ($action == "add")
if ($action == "update" && permission_exists('pin_number_edit')) { if ($action == "update" && permission_exists('pin_number_edit')) {
$sql = "update v_pin_numbers set "; $sql = "update v_pin_numbers set ";
$sql .= "pin_number = '$pin_number', "; $sql .= "pin_number = '$pin_number', ";
$sql .= "accountcode = '$accountcode', "; $sql .= "accountcode = '$accountcode', ";
$sql .= "enabled = '$enabled', "; $sql .= "enabled = '$enabled', ";
$sql .= "description = '$description' "; $sql .= "description = '$description' ";
$sql .= "where pin_number_uuid = '$pin_number_uuid'"; $sql .= "where pin_number_uuid = '$pin_number_uuid'";
$sql .= "and domain_uuid = '$domain_uuid' "; $sql .= "and domain_uuid = '$domain_uuid' ";
$db->exec(check_sql($sql)); $db->exec(check_sql($sql));
unset($sql); unset($sql);
messages::add($text['message-update']); messages::add($text['message-update']);
header("Location: pin_numbers.php"); header("Location: pin_numbers.php");
return; return;
} //if ($action == "update") } //if ($action == "update")
} //if ($_POST["persistformvar"] != "true") } //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) } //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//pre-populate the form //pre-populate the form
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") { if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$pin_number_uuid = check_str($_GET["id"]); $pin_number_uuid = check_str($_GET["id"]);
$sql = "select * from v_pin_numbers "; $sql = "select * from v_pin_numbers ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and pin_number_uuid = '$pin_number_uuid' "; $sql .= "and pin_number_uuid = '$pin_number_uuid' ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) { foreach ($result as &$row) {
$pin_number = $row["pin_number"]; $pin_number = $row["pin_number"];
$accountcode = $row["accountcode"]; $accountcode = $row["accountcode"];
$enabled = $row["enabled"]; $enabled = $row["enabled"];
$description = $row["description"]; $description = $row["description"];
} }
unset ($prep_statement); unset ($prep_statement);
} }
//show the header //show the header
require_once "resources/header.php"; require_once "resources/header.php";
//show the content //show the content
echo "<form name='frm' id='frm' method='post' action=''>\n"; echo "<form name='frm' id='frm' method='post' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-pin_number']."</b><br><br></td>\n"; echo "<td align='left' width='30%' nowrap='nowrap' valign='top'><b>".$text['title-pin_number']."</b><br><br></td>\n";
echo "<td width='70%' align='right' valign='top'>\n"; echo "<td width='70%' align='right' valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='pin_numbers.php'\" value='".$text['button-back']."'>"; echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='pin_numbers.php'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-pin_number']."\n"; echo " ".$text['label-pin_number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='pin_number' maxlength='255' value=\"$pin_number\">\n"; echo " <input class='formfld' type='text' name='pin_number' maxlength='255' value=\"$pin_number\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-pin_number']."\n"; echo $text['description-pin_number']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-accountcode']."\n"; echo " ".$text['label-accountcode']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='accountcode' maxlength='255' value=\"$accountcode\">\n"; echo " <input class='formfld' type='text' name='accountcode' maxlength='255' value=\"$accountcode\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-accountcode']."\n"; echo $text['description-accountcode']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncellreq' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-enabled']."\n"; echo " ".$text['label-enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <select class='formfld' name='enabled'>\n"; echo " <select class='formfld' name='enabled'>\n";
echo " <option value=''></option>\n"; echo " <option value=''></option>\n";
if ($enabled == "true") { if ($enabled == "true") {
echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n"; echo " <option value='true' selected='selected'>".$text['label-true']."</option>\n";
} }
else { else {
echo " <option value='true'>".$text['label-true']."</option>\n"; echo " <option value='true'>".$text['label-true']."</option>\n";
} }
if ($enabled == "false") { if ($enabled == "false") {
echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n"; echo " <option value='false' selected='selected'>".$text['label-false']."</option>\n";
} }
else { else {
echo " <option value='false'>".$text['label-false']."</option>\n"; echo " <option value='false'>".$text['label-false']."</option>\n";
} }
echo " </select>\n"; echo " </select>\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-enabled']."\n"; echo $text['description-enabled']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "<tr>\n"; echo "<tr>\n";
echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n"; echo "<td class='vncell' valign='top' align='left' nowrap='nowrap'>\n";
echo " ".$text['label-description']."\n"; echo " ".$text['label-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "<td class='vtable' align='left'>\n"; echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='description' maxlength='255' value=\"$description\">\n"; echo " <input class='formfld' type='text' name='description' maxlength='255' value=\"$description\">\n";
echo "<br />\n"; echo "<br />\n";
echo $text['description-description']."\n"; echo $text['description-description']."\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td colspan='2' align='right'>\n"; echo " <td colspan='2' align='right'>\n";
if ($action == "update") { if ($action == "update") {
echo " <input type='hidden' name='pin_number_uuid' value='$pin_number_uuid'>\n"; echo " <input type='hidden' name='pin_number_uuid' value='$pin_number_uuid'>\n";
} }
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n"; echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>"; echo " </tr>";
echo "</table>"; echo "</table>";
echo "</form>"; echo "</form>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,186 +1,186 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2016 Portions created by the Initial Developer are Copyright (C) 2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
//includes //includes
require_once "root.php"; require_once "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
//check permissions //check permissions
require_once "resources/check_auth.php"; require_once "resources/check_auth.php";
if (permission_exists('pin_number_view')) { if (permission_exists('pin_number_view')) {
//access granted //access granted
} }
else { else {
echo "access denied"; echo "access denied";
exit; exit;
} }
//add multi-lingual support //add multi-lingual support
$language = new text; $language = new text;
$text = $language->get(); $text = $language->get();
//get variables used to control the order //get variables used to control the order
$order_by = check_str($_GET["order_by"]); $order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]); $order = check_str($_GET["order"]);
//add the search term //add the search term
$search = check_str($_GET["search"]); $search = check_str($_GET["search"]);
if (strlen($search) > 0) { if (strlen($search) > 0) {
$sql_search = "and ("; $sql_search = "and (";
$sql_search .= "pin_number like '%".$search."%'"; $sql_search .= "pin_number like '%".$search."%'";
$sql_search .= "or accountcode like '%".$search."%'"; $sql_search .= "or accountcode like '%".$search."%'";
$sql_search .= "or enabled like '%".$search."%'"; $sql_search .= "or enabled like '%".$search."%'";
$sql_search .= "or description like '%".$search."%'"; $sql_search .= "or description like '%".$search."%'";
$sql_search .= ")"; $sql_search .= ")";
} }
//additional includes //additional includes
require_once "resources/header.php"; require_once "resources/header.php";
require_once "resources/paging.php"; require_once "resources/paging.php";
//prepare to page the results //prepare to page the results
$sql = "select count(*) as num_rows from v_pin_numbers "; $sql = "select count(*) as num_rows from v_pin_numbers ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$prep_statement = $db->prepare($sql); $prep_statement = $db->prepare($sql);
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
if ($row['num_rows'] > 0) { if ($row['num_rows'] > 0) {
$num_rows = $row['num_rows']; $num_rows = $row['num_rows'];
} }
else { else {
$num_rows = '0'; $num_rows = '0';
} }
} }
//prepare to page the results //prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
$param = ""; $param = "";
$page = $_GET['page']; $page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page; $offset = $rows_per_page * $page;
//get the list //get the list
$sql = "select * from v_pin_numbers "; $sql = "select * from v_pin_numbers ";
$sql .= "where domain_uuid = '$domain_uuid' "; $sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= $sql_search; $sql .= $sql_search;
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= "limit $rows_per_page offset $offset "; $sql .= "limit $rows_per_page offset $offset ";
$prep_statement = $db->prepare(check_sql($sql)); $prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
unset ($prep_statement, $sql); unset ($prep_statement, $sql);
//alternate the row style //alternate the row style
$c = 0; $c = 0;
$row_style["0"] = "row_style0"; $row_style["0"] = "row_style0";
$row_style["1"] = "row_style1"; $row_style["1"] = "row_style1";
//show the content //show the content
echo "<input type='button' class='btn' style='margin-right: 15px;' value='".$text['button-export']."' onclick=\"window.location.href='pin_download.php'\">\n"; echo "<input type='button' class='btn' style='margin-right: 15px;' value='".$text['button-export']."' onclick=\"window.location.href='pin_download.php'\">\n";
echo "<table width='100%' border='0'>\n"; echo "<table width='100%' border='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-pin_numbers']."</b></td>\n"; echo " <td width='50%' align='left' nowrap='nowrap'><b>".$text['title-pin_numbers']."</b></td>\n";
echo " <form method='get' action=''>\n"; echo " <form method='get' action=''>\n";
echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n"; echo " <td width='50%' style='vertical-align: top; text-align: right; white-space: nowrap;'>\n";
echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n"; echo " <input type='text' class='txt' style='width: 150px' name='search' id='search' value='".$search."'>\n";
echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n"; echo " <input type='submit' class='btn' name='submit' value='".$text['button-search']."'>\n";
echo " </td>\n"; echo " </td>\n";
echo " </form>\n"; echo " </form>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td align='left' colspan='2'>\n"; echo " <td align='left' colspan='2'>\n";
echo " ".$text['title_description-pin_number']."<br /><br />\n"; echo " ".$text['title_description-pin_number']."<br /><br />\n";
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo "</table>\n"; echo "</table>\n";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n"; echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n"; echo "<tr>\n";
echo th_order_by('pin_number', $text['label-pin_number'], $order_by, $order); 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('accountcode', $text['label-accountcode'], $order_by, $order);
echo th_order_by('enabled', $text['label-enabled'], $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 th_order_by('description', $text['label-description'], $order_by, $order);
echo "<td class='list_control_icons'>"; echo "<td class='list_control_icons'>";
if (permission_exists('pin_number_add')) { if (permission_exists('pin_number_add')) {
echo "<a href='pin_number_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='pin_number_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;\n"; echo "&nbsp;\n";
} }
echo "</td>\n"; echo "</td>\n";
echo "<tr>\n"; echo "<tr>\n";
if (is_array($result)) { if (is_array($result)) {
foreach($result as $row) { foreach($result as $row) {
if (permission_exists('pin_number_edit')) { if (permission_exists('pin_number_edit')) {
$tr_link = "href='pin_number_edit.php?id=".$row['pin_number_uuid']."'"; $tr_link = "href='pin_number_edit.php?id=".$row['pin_number_uuid']."'";
} }
echo "<tr ".$tr_link.">\n"; echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['pin_number']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['pin_number']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['accountcode']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['accountcode']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['enabled']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['enabled']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['description']."&nbsp;</td>\n"; echo " <td valign='top' class='".$row_style[$c]."'>".$row['description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('pin_number_edit')) { if (permission_exists('pin_number_edit')) {
echo "<a href='pin_number_edit.php?id=".$row['pin_number_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>"; echo "<a href='pin_number_edit.php?id=".$row['pin_number_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
} }
if (permission_exists('pin_number_delete')) { if (permission_exists('pin_number_delete')) {
echo "<a href='pin_number_delete.php?id=".$row['pin_number_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>"; echo "<a href='pin_number_delete.php?id=".$row['pin_number_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
} }
echo " </td>\n"; echo " </td>\n";
echo "</tr>\n"; echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; } if ($c==0) { $c=1; } else { $c=0; }
} //end foreach } //end foreach
unset($sql, $result, $row_count); unset($sql, $result, $row_count);
} //end if results } //end if results
echo "<tr>\n"; echo "<tr>\n";
echo "<td colspan='5' align='left'>\n"; echo "<td colspan='5' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n"; echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n"; echo " <tr>\n";
echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n"; echo " <td width='33.3%' nowrap='nowrap'>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n"; echo " <td width='33.3%' align='center' nowrap='nowrap'>$paging_controls</td>\n";
echo " <td class='list_control_icons'>"; echo " <td class='list_control_icons'>";
if (permission_exists('pin_number_add')) { if (permission_exists('pin_number_add')) {
echo "<a href='pin_number_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>"; echo "<a href='pin_number_edit.php' alt='".$text['button-add']."'>$v_link_label_add</a>";
} }
else { else {
echo "&nbsp;"; echo "&nbsp;";
} }
echo " </td>\n"; echo " </td>\n";
echo " </tr>\n"; echo " </tr>\n";
echo " </table>\n"; echo " </table>\n";
echo "</td>\n"; echo "</td>\n";
echo "</tr>\n"; echo "</tr>\n";
echo "</table>"; echo "</table>";
echo "<br /><br />"; echo "<br /><br />";
//include the footer //include the footer
require_once "resources/footer.php"; require_once "resources/footer.php";
?> ?>

View File

@ -1,90 +1,90 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016 Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
// make sure the PATH_SEPARATOR is defined // make sure the PATH_SEPARATOR is defined
umask(2); umask(2);
if (!defined("PATH_SEPARATOR")) { if (!defined("PATH_SEPARATOR")) {
if (strpos($_ENV["OS"], "Win") !== false) { if (strpos($_ENV["OS"], "Win") !== false) {
define("PATH_SEPARATOR", ";"); define("PATH_SEPARATOR", ";");
} else { } else {
define("PATH_SEPARATOR", ":"); define("PATH_SEPARATOR", ":");
} }
} }
if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html';
// make sure the document_root is set // make sure the document_root is set
$_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]);
if(PHP_SAPI == 'cli'){ if(PHP_SAPI == 'cli'){
chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME));
$script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]);
$dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME));
if (file_exists('/project_root.php')) { if (file_exists('/project_root.php')) {
$path = '/'; $path = '/';
} else { } else {
$i = 1; $i = 1;
$path = ''; $path = '';
while ($i < count($dirs)) { while ($i < count($dirs)) {
$path .= '/' . $dirs[$i]; $path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) { if (file_exists($path. '/project_root.php')) {
break; break;
} }
$i++; $i++;
} }
} }
$_SERVER["DOCUMENT_ROOT"] = $path; $_SERVER["DOCUMENT_ROOT"] = $path;
}else{ }else{
$_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]);
} }
$_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]);
// try to detect if a project path is being used // try to detect if a project path is being used
if (!defined('PROJECT_PATH')) { if (!defined('PROJECT_PATH')) {
if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) {
define('PROJECT_PATH', '/fusionpbx'); define('PROJECT_PATH', '/fusionpbx');
} elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) {
define('PROJECT_PATH', ''); define('PROJECT_PATH', '');
} else { } else {
$dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME)));
$i = 1; $i = 1;
$path = $_SERVER["DOCUMENT_ROOT"]; $path = $_SERVER["DOCUMENT_ROOT"];
while ($i < count($dirs)) { while ($i < count($dirs)) {
$path .= '/' . $dirs[$i]; $path .= '/' . $dirs[$i];
if (file_exists($path. '/project_root.php')) { if (file_exists($path. '/project_root.php')) {
break; break;
} }
$i++; $i++;
} }
if(!file_exists($path. '/project_root.php')){ 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"); 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); $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path);
define('PROJECT_PATH', $project_path); define('PROJECT_PATH', $project_path);
} }
$_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH);
set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]);
} }
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -1,341 +1,341 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016 Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
/** /**
* scripts class provides methods for creating the config.lua and copying switch scripts * scripts class provides methods for creating the config.lua and copying switch scripts
* *
* @method string correct_path * @method string correct_path
* @method string copy_files * @method string copy_files
* @method string write_config * @method string write_config
*/ */
if (!class_exists('scripts')) { if (!class_exists('scripts')) {
class scripts { class scripts {
public $db; public $db;
public $db_type; public $db_type;
public $db_name; public $db_name;
public $db_host; public $db_host;
public $db_port; public $db_port;
public $db_path; public $db_path;
public $db_username; public $db_username;
public $db_password; public $db_password;
public $dsn_name; public $dsn_name;
public $dsn_username; public $dsn_username;
public $dsn_password; public $dsn_password;
/** /**
* Called when the object is created * Called when the object is created
*/ */
public function __construct() { public function __construct() {
//connect to the database if not connected //connect to the database if not connected
require_once "resources/classes/database.php"; require_once "resources/classes/database.php";
$database = new database; $database = new database;
$database->connect(); $database->connect();
$this->db = $database->db; $this->db = $database->db;
$this->db_type = $database->type; $this->db_type = $database->type;
$this->db_name = $database->db_name; $this->db_name = $database->db_name;
$this->db_host = $database->host; $this->db_host = $database->host;
$this->db_port = $database->port; $this->db_port = $database->port;
$this->db_path = $database->path; $this->db_path = $database->path;
$this->db_username = $database->username; $this->db_username = $database->username;
$this->db_password = $database->password; $this->db_password = $database->password;
} }
/** /**
* Called when there are no references to a particular object * Called when there are no references to a particular object
* unset the variables used in the class * unset the variables used in the class
*/ */
public function __destruct() { public function __destruct() {
foreach ($this as $key => $value) { foreach ($this as $key => $value) {
unset($this->$key); unset($this->$key);
} }
} }
/** /**
* Corrects the path for specifically for windows * Corrects the path for specifically for windows
*/ */
private function correct_path($path) { private function correct_path($path) {
global $IS_WINDOWS; global $IS_WINDOWS;
if ($IS_WINDOWS == null) { if ($IS_WINDOWS == null) {
if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; } if (stristr(PHP_OS, 'WIN')) { $IS_WINDOWS = true; } else { $IS_WINDOWS = false; }
} }
if ($IS_WINDOWS) { if ($IS_WINDOWS) {
return str_replace('\\', '/', $path); return str_replace('\\', '/', $path);
} }
return $path; return $path;
} }
/** /**
* Copy the switch scripts from the web directory to the switch directory * Copy the switch scripts from the web directory to the switch directory
*/ */
public function copy_files() { public function copy_files() {
if (is_array($_SESSION['switch']['scripts'])) { if (is_array($_SESSION['switch']['scripts'])) {
$dst_dir = $_SESSION['switch']['scripts']['dir']; $dst_dir = $_SESSION['switch']['scripts']['dir'];
if (file_exists($dst_dir)) { if (file_exists($dst_dir)) {
//get the source directory //get the source directory
if (file_exists('/usr/share/examples/fusionpbx/scripts')){ if (file_exists('/usr/share/examples/fusionpbx/scripts')){
$src_dir = '/usr/share/examples/fusionpbx/scripts'; $src_dir = '/usr/share/examples/fusionpbx/scripts';
} }
else { else {
$src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts'; $src_dir = $_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'/resources/install/scripts';
} }
if (is_readable($dst_dir)) { if (is_readable($dst_dir)) {
recursive_copy($src_dir,$dst_dir); recursive_copy($src_dir,$dst_dir);
unset($src_dir); unset($src_dir);
// Copy the app/*/resource/install/scripts // Copy the app/*/resource/install/scripts
$app_scripts = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'app/*/resource/install/scripts'); $app_scripts = glob($_SERVER["DOCUMENT_ROOT"].PROJECT_PATH.'app/*/resource/install/scripts');
foreach ($app_scripts as $app_script){ foreach ($app_scripts as $app_script){
recursive_copy($app_script, $dst_dir); recursive_copy($app_script, $dst_dir);
} }
unset($app_scripts); unset($app_scripts);
}else{ }else{
throw new Exception("Cannot read from '$src_dir' to get the scripts"); throw new Exception("Cannot read from '$src_dir' to get the scripts");
} }
chmod($dst_dir, 0775); chmod($dst_dir, 0775);
unset($dst_dir); unset($dst_dir);
} }
} }
} }
/** /**
* Writes the config.lua * Writes the config.lua
*/ */
public function write_config() { public function write_config() {
if (is_array($_SESSION['switch']['scripts'])) { if (is_array($_SESSION['switch']['scripts'])) {
//replace the backslash with a forward slash //replace the backslash with a forward slash
$this->db_path = str_replace("\\", "/", $this->db_path); $this->db_path = str_replace("\\", "/", $this->db_path);
//get the odbc information //get the odbc information
$sql = "select count(*) as num_rows from v_databases "; $sql = "select count(*) as num_rows from v_databases ";
$sql .= "where database_driver = 'odbc' "; $sql .= "where database_driver = 'odbc' ";
$prep_statement = $this->db->prepare($sql); $prep_statement = $this->db->prepare($sql);
if ($prep_statement) { if ($prep_statement) {
$prep_statement->execute(); $prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC); $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
unset($prep_statement); unset($prep_statement);
if ($row['num_rows'] > 0) { if ($row['num_rows'] > 0) {
$odbc_num_rows = $row['num_rows']; $odbc_num_rows = $row['num_rows'];
$sql = "select * from v_databases "; $sql = "select * from v_databases ";
$sql .= "where database_driver = 'odbc' "; $sql .= "where database_driver = 'odbc' ";
$prep_statement = $this->db->prepare(check_sql($sql)); $prep_statement = $this->db->prepare(check_sql($sql));
$prep_statement->execute(); $prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED); $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (is_array($result)) { if (is_array($result)) {
foreach ($result as &$row) { foreach ($result as &$row) {
$this->dsn_name = $row["database_name"]; $this->dsn_name = $row["database_name"];
$this->dsn_username = $row["database_username"]; $this->dsn_username = $row["database_username"];
$this->dsn_password = $row["database_password"]; $this->dsn_password = $row["database_password"];
break; //limit to 1 row break; //limit to 1 row
} }
unset ($prep_statement); unset ($prep_statement);
} }
} }
else { else {
$odbc_num_rows = '0'; $odbc_num_rows = '0';
} }
} }
//get the recordings directory //get the recordings directory
if (is_array($_SESSION['switch']['recordings'])) { if (is_array($_SESSION['switch']['recordings'])) {
$recordings_dir = $_SESSION['switch']['recordings']['dir']; $recordings_dir = $_SESSION['switch']['recordings']['dir'];
} }
//get the http_protocol //get the http_protocol
if (!isset($_SERVER['HTTP_PROTOCOL'])) { if (!isset($_SERVER['HTTP_PROTOCOL'])) {
$_SERVER['HTTP_PROTOCOL'] = 'http'; $_SERVER['HTTP_PROTOCOL'] = 'http';
if (isset($_SERVER['REQUEST_SCHEME'])) { $_SERVER['HTTP_PROTOCOL'] = $_SERVER['REQUEST_SCHEME']; } if (isset($_SERVER['REQUEST_SCHEME'])) { $_SERVER['HTTP_PROTOCOL'] = $_SERVER['REQUEST_SCHEME']; }
if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } if ($_SERVER['HTTPS'] == 'on') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; } if ($_SERVER['SERVER_PORT'] == '443') { $_SERVER['HTTP_PROTOCOL'] = 'https'; }
} }
//find the location to write the config.lua //find the location to write the config.lua
if (is_dir("/etc/fusionpbx")){ if (is_dir("/etc/fusionpbx")){
$config = "/etc/fusionpbx/config.lua"; $config = "/etc/fusionpbx/config.lua";
} elseif (is_dir("/usr/local/etc/fusionpbx")){ } elseif (is_dir("/usr/local/etc/fusionpbx")){
$config = "/usr/local/etc/fusionpbx/config.lua"; $config = "/usr/local/etc/fusionpbx/config.lua";
} }
else { else {
$config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua"; $config = $_SESSION['switch']['scripts']['dir']."/resources/config.lua";
} }
$fout = fopen($config,"w"); $fout = fopen($config,"w");
if(!$fout){ if(!$fout){
return; return;
} }
//make the config.lua //make the config.lua
$tmp = "\n"; $tmp = "\n";
$tmp .= "--set the variables\n"; $tmp .= "--set the variables\n";
if (strlen($_SESSION['switch']['conf']['dir']) > 0) { if (strlen($_SESSION['switch']['conf']['dir']) > 0) {
$tmp .= $this->correct_path(" conf_dir = [[".$_SESSION['switch']['conf']['dir']."]];\n"); $tmp .= $this->correct_path(" conf_dir = [[".$_SESSION['switch']['conf']['dir']."]];\n");
} }
if (strlen($_SESSION['switch']['sounds']['dir']) > 0) { if (strlen($_SESSION['switch']['sounds']['dir']) > 0) {
$tmp .= $this->correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n"); $tmp .= $this->correct_path(" sounds_dir = [[".$_SESSION['switch']['sounds']['dir']."]];\n");
} }
if (strlen($_SESSION['switch']['db']['dir']) > 0) { if (strlen($_SESSION['switch']['db']['dir']) > 0) {
$tmp .= $this->correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n"); $tmp .= $this->correct_path(" database_dir = [[".$_SESSION['switch']['db']['dir']."]];\n");
} }
if (strlen($_SESSION['switch']['recordings']['dir']) > 0) { if (strlen($_SESSION['switch']['recordings']['dir']) > 0) {
$tmp .= $this->correct_path(" recordings_dir = [[".$recordings_dir."]];\n"); $tmp .= $this->correct_path(" recordings_dir = [[".$recordings_dir."]];\n");
} }
if (strlen($_SESSION['switch']['storage']['dir']) > 0) { if (strlen($_SESSION['switch']['storage']['dir']) > 0) {
$tmp .= $this->correct_path(" storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n"); $tmp .= $this->correct_path(" storage_dir = [[".$_SESSION['switch']['storage']['dir']."]];\n");
} }
if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) { if (strlen($_SESSION['switch']['voicemail']['dir']) > 0) {
$tmp .= $this->correct_path(" voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n"); $tmp .= $this->correct_path(" voicemail_dir = [[".$_SESSION['switch']['voicemail']['dir']."]];\n");
} }
if (strlen($_SESSION['switch']['scripts']['dir']) > 0) { if (strlen($_SESSION['switch']['scripts']['dir']) > 0) {
$tmp .= $this->correct_path(" scripts_dir = [[".$_SESSION['switch']['scripts']['dir']."]];\n"); $tmp .= $this->correct_path(" scripts_dir = [[".$_SESSION['switch']['scripts']['dir']."]];\n");
} }
$tmp .= $this->correct_path(" php_dir = [[".PHP_BINDIR."]];\n"); $tmp .= $this->correct_path(" php_dir = [[".PHP_BINDIR."]];\n");
if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") { if (substr(strtoupper(PHP_OS), 0, 3) == "WIN") {
$tmp .= " php_bin = \"php.exe\";\n"; $tmp .= " php_bin = \"php.exe\";\n";
} }
elseif (file_exists(PHP_BINDIR."/php5")) { elseif (file_exists(PHP_BINDIR."/php5")) {
$tmp .= " php_bin = \"php5\";\n"; $tmp .= " php_bin = \"php5\";\n";
} }
else { else {
$tmp .= " php_bin = \"php\";\n"; $tmp .= " php_bin = \"php\";\n";
} }
$tmp .= $this->correct_path(" document_root = [[".$_SERVER["DOCUMENT_ROOT"].PROJECT_PATH."]];\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(" project_path = [[".PROJECT_PATH."]];\n");
$tmp .= $this->correct_path(" http_protocol = [[".$_SERVER['HTTP_PROTOCOL']."]];\n"); $tmp .= $this->correct_path(" http_protocol = [[".$_SERVER['HTTP_PROTOCOL']."]];\n");
$tmp .= "\n"; $tmp .= "\n";
$tmp .= "--store settings in memcache\n"; $tmp .= "--store settings in memcache\n";
$tmp .= " settings_in_cache = false;\n"; $tmp .= " settings_in_cache = false;\n";
$tmp .= "\n"; $tmp .= "\n";
if ((strlen($this->db_type) > 0) || (strlen($this->dsn_name) > 0)) { if ((strlen($this->db_type) > 0) || (strlen($this->dsn_name) > 0)) {
$tmp .= "--database information\n"; $tmp .= "--database information\n";
$tmp .= " database = {}\n"; $tmp .= " database = {}\n";
$tmp .= " database.type = \"".$this->db_type."\";\n"; $tmp .= " database.type = \"".$this->db_type."\";\n";
$tmp .= " database.name = \"".$this->db_name."\";\n"; $tmp .= " database.name = \"".$this->db_name."\";\n";
$tmp .= $this->correct_path(" database.path = [[".$this->db_path."]];\n"); $tmp .= $this->correct_path(" database.path = [[".$this->db_path."]];\n");
if (strlen($this->dsn_name) > 0) { if (strlen($this->dsn_name) > 0) {
$tmp .= " database.system = \"odbc://".$this->dsn_name.":".$this->dsn_username.":".$this->dsn_password."\";\n"; $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"; $tmp .= " database.switch = \"odbc://freeswitch:".$this->dsn_username.":".$this->dsn_password."\";\n";
} }
elseif ($this->db_type == "pgsql") { elseif ($this->db_type == "pgsql") {
if ($this->db_host == "localhost") { $this->db_host = "127.0.0.1"; } 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.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"; $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") { elseif ($this->db_type == "sqlite") {
$tmp .= " database.system = \"sqlite://".$this->db_path."/".$this->db_name."\";\n"; $tmp .= " database.system = \"sqlite://".$this->db_path."/".$this->db_name."\";\n";
$tmp .= " database.switch = \"sqlite://".$_SESSION['switch']['db']['dir']."\";\n"; $tmp .= " database.switch = \"sqlite://".$_SESSION['switch']['db']['dir']."\";\n";
} }
elseif ($this->db_type == "mysql") { elseif ($this->db_type == "mysql") {
$tmp .= " database.system = \"\";\n"; $tmp .= " database.system = \"\";\n";
$tmp .= " database.switch = \"\";\n"; $tmp .= " database.switch = \"\";\n";
} }
$tmp .= "\n"; $tmp .= "\n";
$tmp .= " database.backend = {}\n"; $tmp .= " database.backend = {}\n";
$tmp .= " database.backend.base64 = 'luasql'\n"; $tmp .= " database.backend.base64 = 'luasql'\n";
$tmp .= "\n"; $tmp .= "\n";
} }
$tmp .= "--set defaults\n"; $tmp .= "--set defaults\n";
$tmp .= " expire = {}\n"; $tmp .= " expire = {}\n";
$tmp .= " expire.default = \"3600\";\n"; $tmp .= " expire.default = \"3600\";\n";
$tmp .= " expire.directory = \"3600\";\n"; $tmp .= " expire.directory = \"3600\";\n";
$tmp .= " expire.dialplan = \"3600\";\n"; $tmp .= " expire.dialplan = \"3600\";\n";
$tmp .= " expire.languages = \"3600\";\n"; $tmp .= " expire.languages = \"3600\";\n";
$tmp .= " expire.sofia = \"3600\";\n"; $tmp .= " expire.sofia = \"3600\";\n";
$tmp .= " expire.acl = \"3600\";\n"; $tmp .= " expire.acl = \"3600\";\n";
$tmp .= " expire.ivr = \"3600\";\n"; $tmp .= " expire.ivr = \"3600\";\n";
$tmp .= "\n"; $tmp .= "\n";
$tmp .= "--set xml_handler\n"; $tmp .= "--set xml_handler\n";
$tmp .= " xml_handler = {}\n"; $tmp .= " xml_handler = {}\n";
$tmp .= " xml_handler.fs_path = false;\n"; $tmp .= " xml_handler.fs_path = false;\n";
$tmp .= " xml_handler.reg_as_number_alias = false;\n"; $tmp .= " xml_handler.reg_as_number_alias = false;\n";
$tmp .= " xml_handler.number_as_presence_id = true;\n"; $tmp .= " xml_handler.number_as_presence_id = true;\n";
$tmp .= "\n"; $tmp .= "\n";
$tmp .= "--set settings\n"; $tmp .= "--set settings\n";
$tmp .= " settings = {}\n"; $tmp .= " settings = {}\n";
$tmp .= " settings.recordings = {}\n"; $tmp .= " settings.recordings = {}\n";
$tmp .= " settings.voicemail = {}\n"; $tmp .= " settings.voicemail = {}\n";
$tmp .= " settings.fax = {}\n"; $tmp .= " settings.fax = {}\n";
if (isset($_SESSION['recordings']['storage_type']['text'])) { if (isset($_SESSION['recordings']['storage_type']['text'])) {
$tmp .= " settings.recordings.storage_type = \"".$_SESSION['recordings']['storage_type']['text']."\";\n"; $tmp .= " settings.recordings.storage_type = \"".$_SESSION['recordings']['storage_type']['text']."\";\n";
} }
else { else {
$tmp .= " settings.recordings.storage_type = \"\";\n"; $tmp .= " settings.recordings.storage_type = \"\";\n";
} }
if (isset($_SESSION['voicemail']['storage_type']['text'])) { if (isset($_SESSION['voicemail']['storage_type']['text'])) {
$tmp .= " settings.voicemail.storage_type = \"".$_SESSION['voicemail']['storage_type']['text']."\";\n"; $tmp .= " settings.voicemail.storage_type = \"".$_SESSION['voicemail']['storage_type']['text']."\";\n";
} }
else { else {
$tmp .= " settings.voicemail.storage_type = \"\";\n"; $tmp .= " settings.voicemail.storage_type = \"\";\n";
} }
if (isset($_SESSION['fax']['storage_type']['text'])) { if (isset($_SESSION['fax']['storage_type']['text'])) {
$tmp .= " settings.fax.storage_type = \"".$_SESSION['fax']['storage_type']['text']."\";\n"; $tmp .= " settings.fax.storage_type = \"".$_SESSION['fax']['storage_type']['text']."\";\n";
} }
else { else {
$tmp .= " settings.fax.storage_type = \"\";\n"; $tmp .= " settings.fax.storage_type = \"\";\n";
} }
$tmp .= "\n"; $tmp .= "\n";
$tmp .= "--set the debug options\n"; $tmp .= "--set the debug options\n";
$tmp .= " debug.params = false;\n"; $tmp .= " debug.params = false;\n";
$tmp .= " debug.sql = false;\n"; $tmp .= " debug.sql = false;\n";
$tmp .= " debug.xml_request = false;\n"; $tmp .= " debug.xml_request = false;\n";
$tmp .= " debug.xml_string = false;\n"; $tmp .= " debug.xml_string = false;\n";
$tmp .= " debug.cache = false;\n"; $tmp .= " debug.cache = false;\n";
$tmp .= "\n"; $tmp .= "\n";
$tmp .= "--additional info\n"; $tmp .= "--additional info\n";
$tmp .= " domain_count = ".count($_SESSION["domains"]).";\n"; $tmp .= " domain_count = ".count($_SESSION["domains"]).";\n";
$tmp .= $this->correct_path(" temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n"); $tmp .= $this->correct_path(" temp_dir = [[".$_SESSION['server']['temp']['dir']."]];\n");
if (isset($_SESSION['domain']['dial_string']['text'])) { if (isset($_SESSION['domain']['dial_string']['text'])) {
$tmp .= " dial_string = \"".$_SESSION['domain']['dial_string']['text']."\";\n"; $tmp .= " dial_string = \"".$_SESSION['domain']['dial_string']['text']."\";\n";
} }
$tmp .= "\n"; $tmp .= "\n";
$tmp .= "--include local.lua\n"; $tmp .= "--include local.lua\n";
$tmp .= " require(\"resources.functions.file_exists\");\n"; $tmp .= " require(\"resources.functions.file_exists\");\n";
$tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n"; $tmp .= " if (file_exists(\"/etc/fusionpbx/local.lua\")) then\n";
$tmp .= " dofile(\"/etc/fusionpbx/local.lua\");\n"; $tmp .= " dofile(\"/etc/fusionpbx/local.lua\");\n";
$tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n"; $tmp .= " elseif (file_exists(\"/usr/local/etc/fusionpbx/local.lua\")) then\n";
$tmp .= " dofile(\"/usr/local/etc/fusionpbx/local.lua\");\n"; $tmp .= " dofile(\"/usr/local/etc/fusionpbx/local.lua\");\n";
$tmp .= " elseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n"; $tmp .= " elseif (file_exists(scripts_dir..\"/resources/local.lua\")) then\n";
$tmp .= " require(\"resources.local\");\n"; $tmp .= " require(\"resources.local\");\n";
$tmp .= " end\n"; $tmp .= " end\n";
fwrite($fout, $tmp); fwrite($fout, $tmp);
unset($tmp); unset($tmp);
fclose($fout); fclose($fout);
} }
} //end config_lua } //end config_lua
} //end scripts class } //end scripts class
} }
/* /*
//example use //example use
//update config.lua //update config.lua
$obj = new scripts; $obj = new scripts;
$obj->write_config(); $obj->write_config();
*/ */
?> ?>

File diff suppressed because it is too large Load Diff

View File

@ -1,110 +1,110 @@
<?php <?php
include "root.php"; include "root.php";
require_once "resources/require.php"; require_once "resources/require.php";
$font_loader_version = ($_GET['v'] != '') ? $_GET['v'] : 1; $font_loader_version = ($_GET['v'] != '') ? $_GET['v'] : 1;
header("Content-type: text/javascript; charset: UTF-8"); header("Content-type: text/javascript; charset: UTF-8");
//web font loader //web font loader
if ($_SESSION['theme']['font_loader']['text'] == 'true') { if ($_SESSION['theme']['font_loader']['text'] == 'true') {
//parse font names //parse font names
if (is_array($_SESSION['theme']) && sizeof($_SESSION['theme']) > 0) { if (is_array($_SESSION['theme']) && sizeof($_SESSION['theme']) > 0) {
foreach ($_SESSION['theme'] as $subcategory => $type) { foreach ($_SESSION['theme'] as $subcategory => $type) {
if (substr_count($subcategory, '_font') > 0) { if (substr_count($subcategory, '_font') > 0) {
$font_string = $type['text']; $font_string = $type['text'];
if ($font_string != '') { if ($font_string != '') {
if (substr_count($font_string, ',') > 0) { if (substr_count($font_string, ',') > 0) {
$tmp_array = explode(',', $font_string); $tmp_array = explode(',', $font_string);
} }
else { else {
$tmp_array[] = $font_string; $tmp_array[] = $font_string;
} }
foreach ($tmp_array as $font_name) { foreach ($tmp_array as $font_name) {
$font_name = trim($font_name, "'"); $font_name = trim($font_name, "'");
$font_name = trim($font_name, '"'); $font_name = trim($font_name, '"');
$font_name = trim($font_name); $font_name = trim($font_name);
$fonts[] = $font_name; $fonts[] = $font_name;
} }
} }
} }
unset($tmp_array); unset($tmp_array);
} }
} }
//optimize fonts array //optimize fonts array
if (is_array($fonts) && sizeof($fonts) > 0) { if (is_array($fonts) && sizeof($fonts) > 0) {
$fonts = array_unique($fonts); $fonts = array_unique($fonts);
$common_fonts = 'serif,sans-serif,arial,arial black,arial narrow,calibri,'. $common_fonts = 'serif,sans-serif,arial,arial black,arial narrow,calibri,'.
'candara,apple gothic,geneva,tahoma,microsoft sans serif,'. 'candara,apple gothic,geneva,tahoma,microsoft sans serif,'.
'lucidia,lucidia console,monaco,lucidia sans unicode,'. 'lucidia,lucidia console,monaco,lucidia sans unicode,'.
'lucidiagrande,consolas,menlo,trebuchet,trebuchet ms,'. 'lucidiagrande,consolas,menlo,trebuchet,trebuchet ms,'.
'helvetica,times,times new roman,courier,courier new,'. 'helvetica,times,times new roman,courier,courier new,'.
'impact,comic sans,comic sans ms,georgia,palatino,'. 'impact,comic sans,comic sans ms,georgia,palatino,'.
'palatino linotype,verdana,franklin gothic,'. 'palatino linotype,verdana,franklin gothic,'.
'franklin gothic medium,gill sans,gill sans mt,'. 'franklin gothic medium,gill sans,gill sans mt,'.
'brush script,corbel,segoe,segoe ui,optima,'; 'brush script,corbel,segoe,segoe ui,optima,';
$common_fonts = explode(',', $common_fonts); $common_fonts = explode(',', $common_fonts);
foreach ($fonts as $index => $font) { foreach ($fonts as $index => $font) {
if (in_array(strtolower($font), $common_fonts)) { if (in_array(strtolower($font), $common_fonts)) {
unset($fonts[$index]); unset($fonts[$index]);
} }
} }
} }
//load fonts //load fonts
if (is_array($fonts) && sizeof($fonts) > 0) { if (is_array($fonts) && sizeof($fonts) > 0) {
if ($_SESSION['theme']['font_retrieval']['text'] == 'asynchronous') { if ($_SESSION['theme']['font_retrieval']['text'] == 'asynchronous') {
?> ?>
WebFontConfig = { WebFontConfig = {
google: { google: {
families: ['<?php echo implode("','", $fonts); ?>'] families: ['<?php echo implode("','", $fonts); ?>']
} }
}; };
(function(d) { (function(d) {
var wf = d.createElement('script'), s = d.scripts[0]; var wf = d.createElement('script'), s = d.scripts[0];
wf.src = '//ajax.googleapis.com/ajax/libs/webfont/<?php echo $font_loader_version; ?>/webfont.js'; wf.src = '//ajax.googleapis.com/ajax/libs/webfont/<?php echo $font_loader_version; ?>/webfont.js';
s.parentNode.insertBefore(wf, s); s.parentNode.insertBefore(wf, s);
})(document); })(document);
<?php <?php
} }
else { //synchronous else { //synchronous
?> ?>
WebFont.load({ WebFont.load({
google: { google: {
families: ['<?php echo implode("','", $fonts); ?>'] families: ['<?php echo implode("','", $fonts); ?>']
} }
}); });
<?php <?php
} }
} }
} }
?> ?>

View File

@ -1,59 +1,59 @@
<?php <?php
/* /*
FusionPBX FusionPBX
Version: MPL 1.1 Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with 1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/ http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis, Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the for the specific language governing rights and limitations under the
License. License.
The Original Code is FusionPBX The Original Code is FusionPBX
The Initial Developer of the Original Code is The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2016 Portions created by the Initial Developer are Copyright (C) 2008-2016
the Initial Developer. All Rights Reserved. the Initial Developer. All Rights Reserved.
Contributor(s): Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com> Mark J Crane <markjcrane@fusionpbx.com>
*/ */
if ($domains_processed == 1) { if ($domains_processed == 1) {
//get the background images //get the background images
$relative_path = PROJECT_PATH.'/themes/default/images/backgrounds'; $relative_path = PROJECT_PATH.'/themes/default/images/backgrounds';
$backgrounds = opendir($_SERVER["DOCUMENT_ROOT"].'/'.$relative_path); $backgrounds = opendir($_SERVER["DOCUMENT_ROOT"].'/'.$relative_path);
unset($array); unset($array);
$x = 0; $x = 0;
while (false !== ($file = readdir($backgrounds))) { while (false !== ($file = readdir($backgrounds))) {
if ($file != "." AND $file != "..") { if ($file != "." AND $file != "..") {
$ext = pathinfo($file, PATHINFO_EXTENSION); $ext = pathinfo($file, PATHINFO_EXTENSION);
if ($ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "gif") { if ($ext == "png" || $ext == "jpg" || $ext == "jpeg" || $ext == "gif") {
$array[$x]['default_setting_category'] = 'theme'; $array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'background_image'; $array[$x]['default_setting_subcategory'] = 'background_image';
$array[$x]['default_setting_name'] = 'array'; $array[$x]['default_setting_name'] = 'array';
$array[$x]['default_setting_value'] = $relative_path.'/'.$file; $array[$x]['default_setting_value'] = $relative_path.'/'.$file;
$array[$x]['default_setting_enabled'] = 'false'; $array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.'; $array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.';
$x++; $x++;
$array[$x]['default_setting_category'] = 'theme'; $array[$x]['default_setting_category'] = 'theme';
$array[$x]['default_setting_subcategory'] = 'login_background_image'; $array[$x]['default_setting_subcategory'] = 'login_background_image';
$array[$x]['default_setting_name'] = 'array'; $array[$x]['default_setting_name'] = 'array';
$array[$x]['default_setting_value'] = $relative_path.'/'.$file; $array[$x]['default_setting_value'] = $relative_path.'/'.$file;
$array[$x]['default_setting_enabled'] = 'false'; $array[$x]['default_setting_enabled'] = 'false';
$array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.'; $array[$x]['default_setting_description'] = 'Set a relative path or URL within a selected compatible template.';
$x++; $x++;
} }
if ($x > 300) { break; }; if ($x > 300) { break; };
} }
} }
} }
?> ?>

File diff suppressed because it is too large Load Diff