\n";
echo "| \n";
diff --git a/app/fax/fax_active.php b/app/fax/fax_active.php
index 0b176e0e72..077722c7d6 100644
--- a/app/fax/fax_active.php
+++ b/app/fax/fax_active.php
@@ -39,26 +39,19 @@ else {
$text = $language->get();
//get the HTTP values and set as variables
- $show = trim($_REQUEST["show"]);
- if ($show != "all") { $show = ''; }
-
-//
- $fax_uuid = false;
- if(isset($_REQUEST['id'])) {
- $fax_uuid = check_str($_REQUEST["id"]);
- }
+ $show = $_REQUEST["show"];
+ $fax_uuid = $_REQUEST["id"];
//load gateways into a session variable
$sql = "select gateway_uuid, domain_uuid, gateway from v_gateways where enabled = 'true'";
- $prep_statement = $db->prepare($sql);
- if ($prep_statement) {
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
+ $database = new database;
+ $result = $database->select($sql, null, 'all');
+ if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as $row) {
$_SESSION['gateways'][$row['gateway_uuid']] = $row['gateway'];
}
}
- unset($sql, $prep_statement, $result, $row);
+ unset($sql, $result, $row);
//show the header
$document['title'] = $text['title'];
@@ -75,8 +68,8 @@ else {
if ($show == 'all') {
echo "source_url = source_url + '&show=all';";
}
- if ($fax_uuid) {
- echo "source_url = source_url + '&id=" . $fax_uuid . "';";
+ if (is_uuid($fax_uuid)) {
+ echo "source_url = source_url + '&id=".$fax_uuid."';";
}
if (isset($_REQUEST["debug"])) {
echo "source_url = source_url + '&debug';";
diff --git a/app/fax/fax_active_exec.php b/app/fax/fax_active_exec.php
index 24b38ac2d0..71038aa7b3 100644
--- a/app/fax/fax_active_exec.php
+++ b/app/fax/fax_active_exec.php
@@ -38,37 +38,28 @@ else {
}
//authorized referrer
- if(stristr($_SERVER["HTTP_REFERER"], '/fax_active.php') === false) {
- echo " access denied";
- exit;
- }
-
-//http get variables set to php variables
- if (count($_GET)>0) {
- $cmd = trim(check_str($_GET['cmd']));
- $fax_uuid = trim(check_str($_GET['id']));
- }
-
-//authorized commands
- if ($cmd == 'delete') {
- //authorized;
- } else {
- //not found. this command is not authorized
+ if (stristr($_SERVER["HTTP_REFERER"], '/fax_active.php') === false) {
echo "access denied";
exit;
}
-//Command
- if ($cmd == 'delete') {
- if($fax_uuid){
- $sql = <<exec($sql);
- // if($result === false){
- // var_dump($db->errorInfo());
- // }
- }
+//http get variables set to php variables
+ $cmd = trim($_GET['cmd']);
+ $fax_uuid = trim($_GET['id']);
+
+//command
+ if ($cmd == 'delete' && is_uuid($fax_uuid)) {
+ $array['fax_tasks'][0]['fax_task_uuid'] = $fax_uuid;
+
+ $p = new permissions;
+ $p->add('fax_task_delete', 'temp');
+
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->delete($array);
+ unset($array);
+
+ $p->delete('fax_task_delete', 'temp');
}
?>
\ No newline at end of file
diff --git a/app/fax/fax_active_inc.php b/app/fax/fax_active_inc.php
index 54b708397d..62bcbf4b01 100644
--- a/app/fax/fax_active_inc.php
+++ b/app/fax/fax_active_inc.php
@@ -34,91 +34,65 @@ else {
exit;
}
-if ((!permission_exists('fax_active_all')) && ($show == 'all')) {
+if (!permission_exists('fax_active_all') && $show == 'all') {
echo "access denied";
exit;
}
-$fax_uuid = false;
-if(isset($_REQUEST['id'])) {
- $fax_uuid = check_str($_REQUEST["id"]);
-}
-
//add multi-lingual support
$language = new text;
$text = $language->get();
-//get the HTTP values and set as variables
- $show = trim($_REQUEST["show"]);
- if ($show != "all") { $show = ''; }
+//get submitted values
+ $fax_uuid = $_REQUEST["id"];
+ $show = $_REQUEST["show"];
//include theme config for button images
include_once("themes/".$_SESSION['domain']['template']['name']."/config.php");
-$where = 'where (1 = 1)';
-
-if($show !== 'all'){
- $where .= 'and (t3.domain_name = \'' . check_str($_SESSION['domain_name']) . '\')';
-}
-else if($fax_uuid){
- if(!permission_exists('fax_active_all')){
- $where .= 'and (t3.domain_name = \'' . check_str($_SESSION['domain_name']) . '\')';
+//construct query
+ $sql = "select ";
+ $sql .= "t1.fax_task_uuid as uuid, ";
+ $sql .= "t1.fax_uuid as fax_uuid, ";
+ $sql .= "t3.domain_name, ";
+ $sql .= "t3.domain_uuid, ";
+ $sql .= "t1.task_next_time as next_time, ";
+ $sql .= "t1.task_interrupted as interrupted, ";
+ $sql .= "t1.task_status as status, ";
+ $sql .= "t1.task_uri as uri, ";
+ $sql .= "t1.task_dial_string as dial_string, ";
+ $sql .= "t1.task_dtmf as dtmf, ";
+ $sql .= "t1.task_fax_file as fax_file, ";
+ $sql .= "t1.task_wav_file as wav_file, ";
+ $sql .= "t1.task_reply_address as reply_address, ";
+ $sql .= "t1.task_no_answer_counter as no_answer_counter, ";
+ $sql .= "t1.task_no_answer_retry_counter as no_answer_retry_counter, ";
+ $sql .= "t1.task_retry_counter as retry_counter, ";
+ $sql .= "t2.fax_send_greeting as greeting, ";
+ $sql .= "t2.fax_name as fax_server_name ";
+ $sql .= "from v_fax_tasks t1 ";
+ $sql .= "inner join v_fax t2 on t2.fax_uuid = t1.fax_uuid ";
+ $sql .= "inner join v_domains t3 on t2.domain_uuid = t3.domain_uuid ";
+ $sql .= "where true ";
+ if ($show !== 'all'){
+ $sql .= "and t3.domain_name = :domain_name ";
+ $parameters['domain_name'] = $_SESSION['domain_name'];
}
- $where .= 'and (t1.fax_uuid =\'' . check_str($fax_uuid) . '\')';
-}
-
- $sql = <<prepare(check_sql($sql));
- if ($prep_statement) {
- if($prep_statement->execute()) {
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
+ else if (is_uuid($fax_uuid)) {
+ if (!permission_exists('fax_active_all')) {
+ $sql .= "and t3.domain_name = :domain_name ";
+ $parameters['domain_name'] = $_SESSION['domain_name'];
}
+ $sql .= "and t1.fax_uuid = :fax_uuid ";
+ $parameters['fax_uuid'] = $fax_uuid;
}
- unset($prep_statement, $sql, $where);
+ $sql .= "order by domain_name, fax_server_name, next_time ";
+ $database = new database;
+ $result = $database->select($sql, $parameters, 'all');
+ $message = $database->message;
+ unset($sql, $parameters);
-//if the connnection is available then run it and return the results
- if ($result === false) {
- var_dump($db->errorInfo());
- $msg = " ".$text['message-fail']."
";
- echo "\n";
- echo " \n";
- echo "\n";
- echo "| ".$text['label-message']." | \n";
- echo " \n";
- echo "\n";
- echo "| $msg | \n";
- echo " \n";
- echo " \n";
- echo " \n";
- }
- else {
+ if (is_array($result) && @sizeof($result) != 0) {
//define js function call var
$onhover_pause_refresh = " onmouseover='refresh_stop();' onmouseout='refresh_start();'";
@@ -158,12 +132,12 @@ HERE;
//show headers
echo "\n";
echo "\n";
- echo "| " . $text['fax-active_title_fax_server'] . " | \n";
- echo "" . $text['fax-active_title_enabled'] . " | \n";
- echo "" . $text['fax-active_title_status'] . " | \n";
- echo "" . $text['fax-active_title_next_time'] . " | \n";
- echo "" . $text['fax-active_title_files'] . " | \n";
- echo "" . $text['fax-active_title_uri'] . " | \n";
+ echo "".$text['fax-active_title_fax_server']." | \n";
+ echo "".$text['fax-active_title_enabled']." | \n";
+ echo "".$text['fax-active_title_status']." | \n";
+ echo "".$text['fax-active_title_next_time']." | \n";
+ echo "".$text['fax-active_title_files']." | \n";
+ echo "".$text['fax-active_title_uri']." | \n";
echo " | \n";
echo " \n";
@@ -175,8 +149,8 @@ HERE;
$task_status = $text['fax-active_status_wait'];
$task_next_time = $row['next_time'];
- if($row['status'] > 0){
- if($row['status'] <= 3){
+ if ($row['status'] > 0) {
+ if ($row['status'] <= 3) {
$task_status = $text['fax-active_status_execute'];
}
else if($row['status'] == 10){
@@ -189,17 +163,18 @@ HERE;
$fax_server = $row['fax_server_name'];
if ($show == 'all') {
- $fax_server .= '@' . $domain_name;
+ $fax_server .= '@'.$domain_name;
}
$task_files = '';
- if(!empty($row['fax_file'])){
- $task_files .= ' ' . basename($row['fax_file']);
+ if (!empty($row['fax_file'])) {
+ $task_files .= ' '.basename($row['fax_file']);
}
- if(!empty($row['wav_file'])){
- $task_files .= ' ' . basename($row['wav_file']);
- } else if(!empty($row['greeting'])){
- $task_files .= ' ' . basename($row['greeting']);
+ if (!empty($row['wav_file'])) {
+ $task_files .= ' '.basename($row['wav_file']);
+ }
+ else if (!empty($row['greeting'])) {
+ $task_files .= ' '.basename($row['greeting']);
}
//replace gateway uuid with name
@@ -210,12 +185,12 @@ HERE;
}
echo "\n";
- echo "| " . $fax_server . " | \n";
- echo "" . $task_enabled . " | \n";
- echo "" . $task_status . " | \n";
- echo "" . $task_next_time . " | \n";
- echo "" . $task_files . " | \n";
- echo "" . $fax_uri . " | \n";
+ echo "".$fax_server." | \n";
+ echo "".$task_enabled." | \n";
+ echo "".$task_status." | \n";
+ echo "".$task_next_time." | \n";
+ echo "".$task_files." | \n";
+ echo "".$fax_uri." | \n";
echo "".$v_link_label_delete." | \n";
echo " \n";
diff --git a/app/fax/fax_copy.php b/app/fax/fax_copy.php
index 0e3e70684f..8587217796 100644
--- a/app/fax/fax_copy.php
+++ b/app/fax/fax_copy.php
@@ -40,107 +40,87 @@ else {
$text = $language->get();
//set the http get/post variable(s) to a php variable
- if (isset($_REQUEST["id"])) {
- $fax_uuid = check_str($_REQUEST["id"]);
+ $fax_uuid = $_REQUEST["id"];
+
+ if (is_uuid($fax_uuid)) {
+
+ //get the data
+ $sql = "select * from v_fax ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $row = $database->select($sql, $parameters, 'row');
+ if (is_array($row) && @sizeof($row) != 0) {
+ $fax_extension = $row["fax_extension"];
+ $fax_name = $row["fax_name"];
+ $fax_email = $row["fax_email"];
+ $fax_email_connection_type = $row["fax_email_connection_type"];
+ $fax_email_connection_host = $row["fax_email_connection_host"];
+ $fax_email_connection_port = $row["fax_email_connection_port"];
+ $fax_email_connection_security = $row["fax_email_connection_security"];
+ $fax_email_connection_validate = $row["fax_email_connection_validate"];
+ $fax_email_connection_username = $row["fax_email_connection_username"];
+ $fax_email_connection_password = $row["fax_email_connection_password"];
+ $fax_email_connection_mailbox = $row["fax_email_connection_mailbox"];
+ $fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"];
+ $fax_email_outbound_subject_tag = $row["fax_email_outbound_subject_tag"];
+ $fax_email_outbound_authorized_senders = $row["fax_email_outbound_authorized_senders"];
+ $fax_pin_number = $row["fax_pin_number"];
+ $fax_caller_id_name = $row["fax_caller_id_name"];
+ $fax_caller_id_number = $row["fax_caller_id_number"];
+ $fax_forward_number = $row["fax_forward_number"];
+ $fax_description = $row["fax_description"].' ('.$text['label-copy'].')';
+ }
+ unset($sql, $parameters, $row);
+
+ //build array
+ $fax_uuid = uuid();
+ $dialplan_uuid = uuid();
+ $array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
+ $array['fax'][0]['fax_uuid'] = $fax_uuid;
+ $array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
+ $array['fax'][0]['fax_extension'] = $fax_extension;
+ $array['fax'][0]['fax_name'] = $fax_name;
+ $array['fax'][0]['fax_email'] = $fax_email;
+ $array['fax'][0]['fax_email_connection_type'] = $fax_email_connection_type;
+ $array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host;
+ $array['fax'][0]['fax_email_connection_port'] = $fax_email_connection_port;
+ $array['fax'][0]['fax_email_connection_security'] = $fax_email_connection_security;
+ $array['fax'][0]['fax_email_connection_validate'] = $fax_email_connection_validate;
+ $array['fax'][0]['fax_email_connection_username'] = $fax_email_connection_username;
+ $array['fax'][0]['fax_email_connection_password'] = $fax_email_connection_password;
+ $array['fax'][0]['fax_email_connection_mailbox'] = $fax_email_connection_mailbox;
+ $array['fax'][0]['fax_email_inbound_subject_tag'] = $fax_email_inbound_subject_tag;
+ $array['fax'][0]['fax_email_outbound_subject_tag'] = $fax_email_outbound_subject_tag;
+ $array['fax'][0]['fax_email_outbound_authorized_senders'] = $fax_email_outbound_authorized_senders;
+ $array['fax'][0]['fax_pin_number'] = $fax_pin_number;
+ $array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name;
+ $array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number;
+ if (strlen($fax_forward_number) > 0) {
+ $array['fax'][0]['fax_forward_number'] = $fax_forward_number;
+ }
+ $array['fax'][0]['fax_description'] = $fax_description;
+
+ //execute insert
+ $p = new permissions;
+ $p->add('fax_add', 'temp');
+
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->save($array);
+ unset($array);
+
+ $p->delete('fax_add', 'temp');
+
+ //set message
+ message::add($text['confirm-copy']);
}
-//get the data
- $sql = "select * from v_fax ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and fax_uuid = '$fax_uuid' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (count($result) == 0) {
- echo "access denied";
- exit;
- }
- foreach ($result as &$row) {
- $fax_extension = $row["fax_extension"];
- $fax_name = $row["fax_name"];
- $fax_email = $row["fax_email"];
- $fax_email_connection_type = $row["fax_email_connection_type"];
- $fax_email_connection_host = $row["fax_email_connection_host"];
- $fax_email_connection_port = $row["fax_email_connection_port"];
- $fax_email_connection_security = $row["fax_email_connection_security"];
- $fax_email_connection_validate = $row["fax_email_connection_validate"];
- $fax_email_connection_username = $row["fax_email_connection_username"];
- $fax_email_connection_password = $row["fax_email_connection_password"];
- $fax_email_connection_mailbox = $row["fax_email_connection_mailbox"];
- $fax_email_inbound_subject_tag = $row["fax_email_inbound_subject_tag"];
- $fax_email_outbound_subject_tag = $row["fax_email_outbound_subject_tag"];
- $fax_email_outbound_authorized_senders = $row["fax_email_outbound_authorized_senders"];
- $fax_pin_number = $row["fax_pin_number"];
- $fax_caller_id_name = $row["fax_caller_id_name"];
- $fax_caller_id_number = $row["fax_caller_id_number"];
- $fax_forward_number = $row["fax_forward_number"];
- $fax_description = 'copy: '.$row["fax_description"];
- }
- unset ($prep_statement);
-
-//copy the fax extension
- $fax_uuid = uuid();
- $dialplan_uuid = uuid();
- $sql = "insert into v_fax ";
- $sql .= "(";
- $sql .= "domain_uuid, ";
- $sql .= "fax_uuid, ";
- $sql .= "dialplan_uuid, ";
- $sql .= "fax_extension, ";
- $sql .= "fax_name, ";
- $sql .= "fax_email, ";
- $sql .= "fax_email_connection_type, ";
- $sql .= "fax_email_connection_host, ";
- $sql .= "fax_email_connection_port, ";
- $sql .= "fax_email_connection_security, ";
- $sql .= "fax_email_connection_validate, ";
- $sql .= "fax_email_connection_username, ";
- $sql .= "fax_email_connection_password, ";
- $sql .= "fax_email_connection_mailbox, ";
- $sql .= "fax_email_inbound_subject_tag, ";
- $sql .= "fax_email_outbound_subject_tag, ";
- $sql .= "fax_email_outbound_authorized_senders, ";
- $sql .= "fax_pin_number, ";
- $sql .= "fax_caller_id_name, ";
- $sql .= "fax_caller_id_number, ";
- if (strlen($fax_forward_number) > 0) {
- $sql .= "fax_forward_number, ";
- }
- $sql .= "fax_description ";
- $sql .= ")";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".$_SESSION['domain_uuid']."', ";
- $sql .= "'$fax_uuid', ";
- $sql .= "'$dialplan_uuid', ";
- $sql .= "'$fax_extension', ";
- $sql .= "'$fax_name', ";
- $sql .= "'$fax_email', ";
- $sql .= "'$fax_email_connection_type', ";
- $sql .= "'$fax_email_connection_host', ";
- $sql .= "'$fax_email_connection_port', ";
- $sql .= "'$fax_email_connection_security', ";
- $sql .= "'$fax_email_connection_validate', ";
- $sql .= "'$fax_email_connection_username', ";
- $sql .= "'$fax_email_connection_password', ";
- $sql .= "'$fax_email_connection_mailbox', ";
- $sql .= "'$fax_email_inbound_subject_tag', ";
- $sql .= "'$fax_email_outbound_subject_tag', ";
- $sql .= "'$fax_email_outbound_authorized_senders', ";
- $sql .= "'$fax_pin_number', ";
- $sql .= "'$fax_caller_id_name', ";
- $sql .= "'$fax_caller_id_number', ";
- if (strlen($fax_forward_number) > 0) {
- $sql .= "'$fax_forward_number', ";
- }
- $sql .= "'$fax_description' ";
- $sql .= ")";
- $db->exec(check_sql($sql));
- unset($sql);
-
-//redirect the user
- message::add($text['confirm-copy']);
+//redirect
header("Location: fax.php");
- return;
+ exit;
?>
\ No newline at end of file
diff --git a/app/fax/fax_delete.php b/app/fax/fax_delete.php
index b4273a95ed..8e4f945f09 100644
--- a/app/fax/fax_delete.php
+++ b/app/fax/fax_delete.php
@@ -39,45 +39,52 @@ else {
$text = $language->get();
//get the http get value and set it as a php variable
- if (count($_GET)>0) {
- $fax_uuid = check_str($_GET["id"]);
- }
+ $fax_uuid = $_GET["id"];
//delete the fax extension
- if (strlen($fax_uuid) > 0) {
+ if (is_uuid($fax_uuid)) {
//get the dialplan uuid
- $sql = "select * from v_fax ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and fax_uuid = '$fax_uuid' ";
- $prep_statement = $db->prepare($sql);
- $prep_statement->execute();
- while($row = $prep_statement->fetch(PDO::FETCH_ASSOC)) {
- $dialplan_uuid = $row['dialplan_uuid'];
- }
+ $sql = "select dialplan_uuid from v_fax ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $dialplan_uuid = $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
//delete the fax entry
- $sql = "delete from v_fax ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and fax_uuid = '$fax_uuid' ";
- $db->query($sql);
- unset($sql);
+ $array['fax'][0]['fax_uuid'] = $fax_uuid;
+ $array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
- //delete the dialplan entry
- $sql = "delete from v_dialplans ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and dialplan_uuid = '$dialplan_uuid' ";
- //echo $sql." \n";
- $db->query($sql);
- unset($sql);
+ if (is_uuid($dialplan_uuid)) {
+ //delete the dialplan entry
+ $array['dialplans'][0]['dialplan_uuid'] = $dialplan_uuid;
+ $array['dialplans'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
- //delete the dialplan details
- $sql = "delete from v_dialplan_details ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and dialplan_uuid = '$dialplan_uuid' ";
- //echo $sql." \n";
- $db->query($sql);
- unset($sql);
+ //delete the dialplan details
+ $array['dialplan_details'][0]['dialplan_uuid'] = $dialplan_uuid;
+ $array['dialplan_details'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
+ }
+
+ //grant temp permissions
+ $p = new permissions;
+ $p->add('fax_delete', 'temp');
+ $p->add('dialplan_delete', 'temp');
+ $p->add('dialplan_detail_delete', 'temp');
+
+ //execute delete
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->delete($array);
+ unset($array);
+
+ //revoke temp permissions
+ $p->delete('fax_delete', 'temp');
+ $p->delete('dialplan_delete', 'temp');
+ $p->delete('dialplan_detail_delete', 'temp');
//syncrhonize configuration
save_dialplan_xml();
@@ -88,10 +95,12 @@ else {
//clear the cache
$cache = new cache;
$cache->delete("dialplan:".$_SESSION["context"]);
+
+ //set message
+ message::add($text['message-delete']);
}
//redirect the user
- message::add($text['message-delete']);
header("Location: fax.php");
return;
diff --git a/app/fax/fax_edit.php b/app/fax/fax_edit.php
index 0d5b6a73f7..08c8a7ce8b 100644
--- a/app/fax/fax_edit.php
+++ b/app/fax/fax_edit.php
@@ -44,7 +44,7 @@
//get the fax_extension and save it as a variable
if (strlen($_REQUEST["fax_extension"]) > 0) {
- $fax_extension = check_str($_REQUEST["fax_extension"]);
+ $fax_extension = $_REQUEST["fax_extension"];
}
//set the fax directory
@@ -76,10 +76,10 @@
}
//set the action as an add or an update
- if (isset($_REQUEST["id"])) {
+ if (is_uuid($_REQUEST["id"])) {
$action = "update";
- $fax_uuid = check_str($_REQUEST["id"]);
- $dialplan_uuid = check_str($_REQUEST["dialplan_uuid"]);
+ $fax_uuid = $_REQUEST["id"];
+ $dialplan_uuid = $_REQUEST["dialplan_uuid"];
}
else {
$action = "add";
@@ -88,26 +88,26 @@
//get the http post values and set them as php variables
if (count($_POST) > 0) {
//set the variables
- $fax_name = check_str($_POST["fax_name"]);
- $fax_extension = check_str($_POST["fax_extension"]);
- $fax_accountcode = check_str($_POST["accountcode"]);
- $fax_destination_number = check_str($_POST["fax_destination_number"]);
- $fax_prefix = check_str($_POST["fax_prefix"]);
- $fax_email = check_str(implode(',',array_filter($_POST["fax_email"])));
- $fax_email_connection_type = check_str($_POST["fax_email_connection_type"]);
- $fax_email_connection_host = check_str($_POST["fax_email_connection_host"]);
- $fax_email_connection_port = check_str($_POST["fax_email_connection_port"]);
- $fax_email_connection_security = check_str($_POST["fax_email_connection_security"]);
- $fax_email_connection_validate = check_str($_POST["fax_email_connection_validate"]);
- $fax_email_connection_username = check_str($_POST["fax_email_connection_username"]);
- $fax_email_connection_password = check_str($_POST["fax_email_connection_password"]);
- $fax_email_connection_mailbox = check_str($_POST["fax_email_connection_mailbox"]);
- $fax_email_inbound_subject_tag = check_str($_POST["fax_email_inbound_subject_tag"]);
- $fax_email_outbound_subject_tag = check_str($_POST["fax_email_outbound_subject_tag"]);
+ $fax_name = $_POST["fax_name"];
+ $fax_extension = $_POST["fax_extension"];
+ $fax_accountcode = $_POST["accountcode"];
+ $fax_destination_number = $_POST["fax_destination_number"];
+ $fax_prefix = $_POST["fax_prefix"];
+ $fax_email = implode(',',array_filter($_POST["fax_email"]));
+ $fax_email_connection_type = $_POST["fax_email_connection_type"];
+ $fax_email_connection_host = $_POST["fax_email_connection_host"];
+ $fax_email_connection_port = $_POST["fax_email_connection_port"];
+ $fax_email_connection_security = $_POST["fax_email_connection_security"];
+ $fax_email_connection_validate = $_POST["fax_email_connection_validate"];
+ $fax_email_connection_username = $_POST["fax_email_connection_username"];
+ $fax_email_connection_password = $_POST["fax_email_connection_password"];
+ $fax_email_connection_mailbox = $_POST["fax_email_connection_mailbox"];
+ $fax_email_inbound_subject_tag = $_POST["fax_email_inbound_subject_tag"];
+ $fax_email_outbound_subject_tag = $_POST["fax_email_outbound_subject_tag"];
$fax_email_outbound_authorized_senders = $_POST["fax_email_outbound_authorized_senders"];
- $fax_caller_id_name = check_str($_POST["fax_caller_id_name"]);
- $fax_caller_id_number = check_str($_POST["fax_caller_id_number"]);
- $fax_forward_number = check_str($_POST["fax_forward_number"]);
+ $fax_caller_id_name = $_POST["fax_caller_id_name"];
+ $fax_caller_id_number = $_POST["fax_caller_id_number"];
+ $fax_forward_number = $_POST["fax_forward_number"];
if (strlen($fax_destination_number) == 0) {
$fax_destination_number = $fax_extension;
}
@@ -118,13 +118,14 @@
}
if (strripos($fax_forward_number, '$1') === false) {
$forward_prefix = ''; //not found
- } else {
+ }
+ else {
$forward_prefix = $forward_prefix.$fax_forward_number.'#'; //found
}
- $fax_local = check_str($_POST["fax_local"]); //! @todo check in database
- $fax_description = check_str($_POST["fax_description"]);
- $fax_send_greeting = check_str($_POST["fax_send_greeting"]);
- $fax_send_channels = check_str($_POST["fax_send_channels"]);
+ $fax_local = $_POST["fax_local"]; //! @todo check in database
+ $fax_description = $_POST["fax_description"];
+ $fax_send_greeting = $_POST["fax_send_greeting"];
+ $fax_send_channels = $_POST["fax_send_channels"];
//restrict size of user data
$fax_name = substr($fax_name, 0, 30);
@@ -139,15 +140,24 @@
//delete the user from the fax users
if ($_GET["a"] == "delete" && permission_exists("fax_extension_delete")) {
//set the variables
- $user_uuid = check_str($_REQUEST["user_uuid"]);
- $fax_uuid = check_str($_REQUEST["id"]);
+ $user_uuid = $_REQUEST["user_uuid"];
+ $fax_uuid = $_REQUEST["id"];
//delete the group from the users
- $sql = "delete from v_fax_users ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and fax_uuid = '".$fax_uuid."' ";
- $sql .= "and user_uuid = '".$user_uuid."' ";
- $db->exec(check_sql($sql));
+ $array['fax_users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
+ $array['fax_users'][0]['fax_uuid'] = $fax_uuid;
+ $array['fax_users'][0]['user_uuid'] = $user_uuid;
+
+ $p = new permissions;
+ $p->add('fax_user_delete', 'temp');
+
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->delete($array);
+ unset($array);
+
+ $p->delete('fax_user_delete', 'temp');
//redirect the browser
message::add($text['message-delete']);
@@ -156,26 +166,26 @@
}
//add the user to the fax users
- if (strlen($_REQUEST["user_uuid"]) > 0 && strlen($_REQUEST["id"]) > 0 && $_GET["a"] != "delete") {
+ if (is_uuid($_REQUEST["user_uuid"]) && is_uuid($_REQUEST["id"]) && $_GET["a"] != "delete") {
//set the variables
- $user_uuid = check_str($_REQUEST["user_uuid"]);
- $fax_uuid = check_str($_REQUEST["id"]);
+ $user_uuid = $_REQUEST["user_uuid"];
+ $fax_uuid = $_REQUEST["id"];
//assign the user to the fax extension
- $sql_insert = "insert into v_fax_users ";
- $sql_insert .= "(";
- $sql_insert .= "fax_user_uuid, ";
- $sql_insert .= "domain_uuid, ";
- $sql_insert .= "fax_uuid, ";
- $sql_insert .= "user_uuid ";
- $sql_insert .= ")";
- $sql_insert .= "values ";
- $sql_insert .= "(";
- $sql_insert .= "'".uuid()."', ";
- $sql_insert .= "'".$_SESSION['domain_uuid']."', ";
- $sql_insert .= "'".$fax_uuid."', ";
- $sql_insert .= "'".$user_uuid."' ";
- $sql_insert .= ")";
- $db->exec($sql_insert);
+ $array['fax_users'][0]['fax_user_uuid'] = uuid();
+ $array['fax_users'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
+ $array['fax_users'][0]['fax_uuid'] = $fax_uuid;
+ $array['fax_users'][0]['user_uuid'] = $user_uuid;
+
+ $p = new permissions;
+ $p->add('fax_user_add', 'temp');
+
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->save($array);
+ unset($array);
+
+ $p->delete('fax_user_add', 'temp');
//redirect the browser
message::add($text['confirm-add']);
@@ -190,7 +200,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
if ($action == "update" && permission_exists('fax_extension_edit')) {
- $fax_uuid = check_str($_POST["fax_uuid"]);
+ $fax_uuid = $_POST["fax_uuid"];
}
//check for all required data
@@ -233,7 +243,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
//prep authorized senders
if (sizeof($fax_email_outbound_authorized_senders) > 0) {
foreach ($fax_email_outbound_authorized_senders as $sender_num => $sender) {
- $sender = check_str($sender);
if ($sender == '' || !valid_email($sender)) { unset($fax_email_outbound_authorized_senders[$sender_num]); }
}
$fax_email_outbound_authorized_senders = implode(',', $fax_email_outbound_authorized_senders);
@@ -244,143 +253,84 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$fax_uuid = uuid();
$dialplan_uuid = uuid();
- //add the fax extension to the database
- $sql = "insert into v_fax ";
- $sql .= "(";
- $sql .= "domain_uuid, ";
- $sql .= "fax_uuid, ";
- $sql .= "dialplan_uuid, ";
- $sql .= "fax_extension, ";
- $sql .= "accountcode, ";
- $sql .= "fax_destination_number, ";
- $sql .= "fax_prefix, ";
- $sql .= "fax_name, ";
- $sql .= "fax_email, ";
- if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
- $sql .= "fax_email_connection_type, ";
- $sql .= "fax_email_connection_host, ";
- $sql .= "fax_email_connection_port, ";
- $sql .= "fax_email_connection_security, ";
- $sql .= "fax_email_connection_validate, ";
- $sql .= "fax_email_connection_username, ";
- $sql .= "fax_email_connection_password, ";
- $sql .= "fax_email_connection_mailbox, ";
- $sql .= "fax_email_inbound_subject_tag, ";
- $sql .= "fax_email_outbound_subject_tag, ";
- $sql .= "fax_email_outbound_authorized_senders, ";
- }
- $sql .= "fax_caller_id_name, ";
- $sql .= "fax_caller_id_number, ";
- if (strlen($fax_forward_number) > 0) {
- $sql .= "fax_forward_number, ";
- }
- if (permission_exists('fax_send_greeting')) {
- $sql .= "fax_send_greeting,";
- }
- $sql .= "fax_send_channels,";
- $sql .= "fax_description ";
- $sql .= ")";
- $sql .= "values ";
- $sql .= "(";
- $sql .= "'".$_SESSION['domain_uuid']."', ";
- $sql .= "'$fax_uuid', ";
- $sql .= "'$dialplan_uuid', ";
- $sql .= "'$fax_extension', ";
- $sql .= "'$fax_accountcode', ";
- $sql .= "'$fax_destination_number', ";
- $sql .= "'$fax_prefix', ";
- $sql .= "'$fax_name', ";
- $sql .= "'$fax_email', ";
- if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
- $sql .= "'$fax_email_connection_type', ";
- $sql .= "'$fax_email_connection_host', ";
- $sql .= "'$fax_email_connection_port', ";
- $sql .= "'$fax_email_connection_security', ";
- $sql .= "'$fax_email_connection_validate', ";
- $sql .= "'$fax_email_connection_username', ";
- $sql .= "'$fax_email_connection_password', ";
- $sql .= "'$fax_email_connection_mailbox', ";
- $sql .= "'$fax_email_inbound_subject_tag', ";
- $sql .= "'$fax_email_outbound_subject_tag', ";
- $sql .= "'$fax_email_outbound_authorized_senders', ";
- }
- $sql .= "'$fax_caller_id_name', ";
- $sql .= "'$fax_caller_id_number', ";
- if (strlen($fax_forward_number) > 0) {
- $sql .= "'$fax_forward_number', ";
- }
- if (permission_exists('fax_send_greeting')) {
- $sql .= (strlen($fax_send_greeting)==0?'NULL':"'$fax_send_greeting'") . ",";
- }
- $sql .= (strlen($fax_send_channels)==0?'NULL':"'$fax_send_channels'") . ",";
+ //begin insert array
+ $array['fax'][0]['fax_uuid'] = $fax_uuid;
+ $array['fax'][0]['dialplan_uuid'] = $dialplan_uuid;
- $sql .= "'$fax_description' ";
- $sql .= ")";
- $db->exec(check_sql($sql));
- unset($sql);
+ //assign temp permission
+ $p = new permissions;
+ $p->add('fax_add', 'temp');
//set the dialplan action
$dialplan_type = "add";
}
if ($action == "update" && permission_exists('fax_extension_edit')) {
- //update the fax extension in the database
- $dialplan_type = "";
- $sql = "update v_fax set ";
- $sql .= "fax_extension = '$fax_extension', ";
- $sql .= "accountcode = '$fax_accountcode', ";
- $sql .= "fax_destination_number = '$fax_destination_number', ";
- $sql .= "fax_prefix = '$fax_prefix', ";
- $sql .= "fax_name = '$fax_name', ";
- $sql .= "fax_email = '$fax_email', ";
+ //begin update array
+ $array['fax'][0]['fax_uuid'] = $fax_uuid;
+
+ //assign temp permission
+ $p = new permissions;
+ $p->add('fax_edit', 'temp');
+ }
+
+ if (is_array($array) && @sizeof($array) != 0) {
+ //add common columns to array
+ $array['fax'][0]['domain_uuid'] = $_SESSION['domain_uuid'];
+ $array['fax'][0]['fax_extension'] = $fax_extension;
+ $array['fax'][0]['accountcode'] = $fax_accountcode;
+ $array['fax'][0]['fax_destination_number'] = $fax_destination_number;
+ $array['fax'][0]['fax_prefix'] = $fax_prefix;
+ $array['fax'][0]['fax_name'] = $fax_name;
+ $array['fax'][0]['fax_email'] = $fax_email;
if (permission_exists('fax_extension_advanced') && function_exists("imap_open") && file_exists("fax_files_remote.php")) {
- $sql .= "fax_email_connection_type = '$fax_email_connection_type', ";
- $sql .= "fax_email_connection_host = '$fax_email_connection_host', ";
- $sql .= "fax_email_connection_port = '$fax_email_connection_port', ";
- $sql .= "fax_email_connection_security = '$fax_email_connection_security', ";
- $sql .= "fax_email_connection_validate = '$fax_email_connection_validate', ";
- $sql .= "fax_email_connection_username = '$fax_email_connection_username', ";
- $sql .= "fax_email_connection_password = '$fax_email_connection_password', ";
- $sql .= "fax_email_connection_mailbox = '$fax_email_connection_mailbox', ";
- $sql .= "fax_email_inbound_subject_tag = '$fax_email_inbound_subject_tag', ";
- $sql .= "fax_email_outbound_subject_tag = '$fax_email_outbound_subject_tag', ";
- $sql .= "fax_email_outbound_authorized_senders = '$fax_email_outbound_authorized_senders', ";
+ $array['fax'][0]['fax_email_connection_type'] = $fax_email_connection_type;
+ $array['fax'][0]['fax_email_connection_host'] = $fax_email_connection_host;
+ $array['fax'][0]['fax_email_connection_port'] = $fax_email_connection_port;
+ $array['fax'][0]['fax_email_connection_security'] = $fax_email_connection_security;
+ $array['fax'][0]['fax_email_connection_validate'] = $fax_email_connection_validate;
+ $array['fax'][0]['fax_email_connection_username'] = $fax_email_connection_username;
+ $array['fax'][0]['fax_email_connection_password'] = $fax_email_connection_password;
+ $array['fax'][0]['fax_email_connection_mailbox'] = $fax_email_connection_mailbox;
+ $array['fax'][0]['fax_email_inbound_subject_tag'] = $fax_email_inbound_subject_tag;
+ $array['fax'][0]['fax_email_outbound_subject_tag'] = $fax_email_outbound_subject_tag;
+ $array['fax'][0]['fax_email_outbound_authorized_senders'] = $fax_email_outbound_authorized_senders;
}
- $sql .= "fax_caller_id_name = '$fax_caller_id_name', ";
- $sql .= "fax_caller_id_number = '$fax_caller_id_number', ";
- if (strlen($fax_forward_number) > 0) {
- $sql .= "fax_forward_number = '$fax_forward_number', ";
+ $array['fax'][0]['fax_caller_id_name'] = $fax_caller_id_name;
+ $array['fax'][0]['fax_caller_id_number'] = $fax_caller_id_number;
+ if ($action == "add" && strlen($fax_forward_number) > 0) {
+ $array['fax'][0]['fax_forward_number'] = $fax_forward_number;
}
- else {
- $sql .= "fax_forward_number = null, ";
+ if ($action == "update") {
+ $array['fax'][0]['fax_forward_number'] = strlen($fax_forward_number) > 0 ? $fax_forward_number : null;
}
if (permission_exists('fax_send_greeting')) {
- $tmp = strlen($fax_send_greeting)==0?'NULL':"'$fax_send_greeting'";
- $sql .= "fax_send_greeting = $tmp,";
+ $array['fax'][0]['fax_send_greeting'] = strlen($fax_send_greeting) != 0 ? $fax_send_greeting : null;
}
- $tmp = strlen($fax_send_channels)==0?'NULL':"'$fax_send_channels'";
- $sql .= "fax_send_channels = $tmp,";
+ $array['fax'][0]['fax_send_channels'] = strlen($fax_send_channels) != 0 ? $fax_send_channels : null;
+ $array['fax'][0]['fax_description'] = $fax_description;
- $sql .= "fax_description = '$fax_description' ";
+ //execute
+ $database = new database;
+ $database->app_name = 'fax';
+ $database->app_uuid = '24108154-4ac3-1db6-1551-4731703a4440';
+ $database->save($array);
+ unset($array);
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and fax_uuid = '$fax_uuid' ";
-
- $db->exec(check_sql($sql));
- unset($sql);
+ //revoke temp permissions
+ $p->delete('fax_add', 'temp');
+ $p->delete('fax_edit', 'temp');
}
//get the dialplan_uuid
- $sql = "select * from v_fax ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and fax_uuid = '$fax_uuid' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- foreach ($result as &$row) {
- $dialplan_uuid = $row["dialplan_uuid"];
- }
- unset ($prep_statement);
+ $sql = "select dialplan_uuid from v_fax ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $dialplan_uuid = $database->select($sql, $parameters, 'column');
+ unset($sql, $parameters);
//dialplan add or update
$c = new fax;
@@ -405,23 +355,20 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
header("Location: fax.php");
return;
- } //if ($_POST["persistformvar"] != "true")
-} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+ }
+}
//pre-populate the form
- if (strlen($_GET['id']) > 0 && $_POST["persistformvar"] != "true") {
- $fax_uuid = check_str($_GET["id"]);
+ if (is_uuid($_GET['id']) && $_POST["persistformvar"] != "true") {
+ $fax_uuid = $_GET["id"];
$sql = "select * from v_fax ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and fax_uuid = '".$fax_uuid."' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (count($result) == 0) {
- echo "access denied";
- exit;
- }
- foreach ($result as &$row) {
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $row = $database->select($sql, $parameters, 'row');
+ if (is_array($row) && @sizeof($row) != 0) {
$dialplan_uuid = $row["dialplan_uuid"];
$fax_extension = $row["fax_extension"];
$fax_accountcode = $row["accountcode"];
@@ -447,7 +394,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$fax_send_greeting = $row["fax_send_greeting"];
$fax_send_channels = $row["fax_send_channels"];
}
- unset ($prep_statement);
+ unset($sql, $parameters, $row);
}
else{
$fax_send_channels = 10;
@@ -457,7 +404,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$fax_name = str_replace("-", " ", $fax_name);
//set the dialplan_uuid
- if (strlen($dialplan_uuid) == 0) {
+ if (!is_uuid($dialplan_uuid)) {
$dialplan_uuid = uuid();
}
@@ -636,13 +583,13 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$sql = "select * from v_fax_users as e, v_users as u ";
$sql .= "where e.user_uuid = u.user_uuid ";
- $sql .= "and e.domain_uuid = '".$_SESSION['domain_uuid']."' ";
- $sql .= "and e.fax_uuid = '".$fax_uuid."' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
- $result_count = count($result);
- if ($result_count > 0) {
+ $sql .= "and e.domain_uuid = :domain_uuid ";
+ $sql .= "and e.fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $result = $database->select($sql, $parameters, 'all');
+ if (is_array($result) && @sizeof($result) != 0) {
echo " \n";
foreach($result as $field) {
echo " \n";
@@ -654,25 +601,33 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$assigned_user_uuids[] = $field['user_uuid'];
}
echo " \n";
- echo " \n";
+ echo " \n";
}
+ unset($sql, $parameters, $result, $field);
$sql = "select * from v_users ";
- $sql .= "where domain_uuid = '".$_SESSION['domain_uuid']."' ";
- if (isset($assigned_user_id)) foreach($assigned_user_uuids as $assigned_user_uuid) {
- $sql .= "and user_uuid <> '".$assigned_user_uuid."' ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ if (is_array($assigned_user_uuids) && @sizeof($assigned_user_uuids) != 0) {
+ foreach($assigned_user_uuids as $index => $assigned_user_uuid) {
+ if (is_uuid($assigned_user_uuid)) {
+ $sql .= "and user_uuid <> :user_uuid_".$index;
+ $parameters['user_uuid_'.$index] = $assigned_user_uuid;
+ }
+ }
+ unset($assigned_user_uuids, $index, $assigned_user_uuid);
}
- unset($assigned_user_uuids);
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- echo " \n";
//prepare to page the results
- $sql = "select count(*) as num_rows from v_fax_logs ";
- $sql .= "where domain_uuid = '$domain_uuid' ";
- $sql .= "and fax_uuid = '$fax_uuid' ";
- $prep_statement = $db->prepare($sql);
- if ($prep_statement) {
- $prep_statement->execute();
- $row = $prep_statement->fetch(PDO::FETCH_ASSOC);
- if ($row['num_rows'] > 0) {
- $num_rows = $row['num_rows'];
- }
- else {
- $num_rows = '0';
- }
- }
+ $sql = "select count(*) from v_fax_logs ";
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and fax_uuid = :fax_uuid ";
+ $parameters['domain_uuid'] = $domain_uuid;
+ $parameters['fax_uuid'] = $fax_uuid;
+ $database = new database;
+ $num_rows = $database->select($sql, $parameters, 'column');
//prepare to page the results
$rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50;
@@ -97,16 +88,12 @@
$offset = $rows_per_page * $page;
//get the list
- $sql = "select * from v_fax_logs ";
- $sql .= "where domain_uuid = '$domain_uuid' ";
- $sql .= "and fax_uuid = '$fax_uuid' ";
- $sql .= (strlen($order_by) > 0) ? "order by ".$order_by." ".$order." " : "order by fax_epoch desc ";
- $sql .= "limit $rows_per_page offset $offset ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $fax_logs = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- $result_count = count($result);
- unset ($prep_statement, $sql);
+ $sql = str_replace('count(*)', '*', $sql);
+ $sql .= order_by($order_by, $order, 'fax_epoch', 'desc');
+ $sql .= limit_offset($rows_per_page, $offset);
+ $database = new database;
+ $fax_logs = $database->select($sql, $parameters, 'all');
+ unset($sql, $parameters, $num_rows);
//set the row style
$c = 0;
@@ -139,7 +126,7 @@
echo " | \n";
echo "
\n";
- if (is_array($fax_logs)) {
+ if (is_array($fax_logs) && @sizeof($fax_logs) != 0) {
foreach($fax_logs as $row) {
//$fax_date = date("j M Y", $row['fax_date'].' 00:00:00');
$fax_date = ($_SESSION['domain']['time_format']['text'] == '12h') ? date("j M Y g:i:sa", $row['fax_epoch']) : date("j M Y H:i:s", $row['fax_epoch']);
@@ -172,9 +159,9 @@
echo "\n";
echo "\n";
if ($c==0) { $c=1; } else { $c=0; }
- } //end foreach
- unset($sql, $fax_logs);
- } //end if results
+ }
+ }
+ unset($fax_logs, $row);
echo "