diff --git a/app/recordings/app_defaults.php b/app/recordings/app_defaults.php
index ab440e6889..800f387a41 100644
--- a/app/recordings/app_defaults.php
+++ b/app/recordings/app_defaults.php
@@ -36,11 +36,12 @@
if (is_array($_SESSION['recordings']['storage_type']) && $_SESSION['recordings']['storage_type']['text'] == 'base64') {
//get recordings without base64 in db
$sql = "select recording_uuid, domain_uuid, recording_filename ";
- $sql .= "from v_recordings where recording_base64 is null or recording_base64 = '' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (is_array($result)) {
+ $sql .= "from v_recordings ";
+ $sql .= "where recording_base64 is null ";
+ $sql .= "or recording_base64 = '' ";
+ $database = new database;
+ $result = $database->select($sql, null, 'all');
+ if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as &$row) {
$recording_uuid = $row['recording_uuid'];
$recording_domain_uuid = $row['domain_uuid'];
@@ -49,30 +50,38 @@
$recording_directory = $_SESSION['switch']['recordings']['dir'].'/'.$domain_name;
//encode recording file (if exists)
if (file_exists($recording_directory.'/'.$recording_filename)) {
- $recording_base64 = base64_encode(file_get_contents($recording_directory.'/'.$recording_filename));
+ //build array
+ $recording_base64 = base64_encode(file_get_contents($recording_directory.'/'.$recording_filename));
+ $array['recordings'][0]['recording_uuid'] = $recording_uuid;
+ $array['recordings'][0]['domain_uuid'] = $recording_domain_uuid;
+ $array['recordings'][0]['recording_base64'] = $recording_base64;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('recording_edit', 'temp');
//update recording record with base64
- $sql = "update v_recordings set ";
- $sql .= "recording_base64 = '".$recording_base64."' ";
- $sql .= "where domain_uuid = '".$recording_domain_uuid."' ";
- $sql .= "and recording_uuid = '".$recording_uuid."' ";
- $db->exec(check_sql($sql));
- unset($sql);
+ $database = new database;
+ $database->app_name = 'recordings';
+ $database->app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('recording_edit', 'temp');
//remove local recording file
@unlink($recording_directory.'/'.$recording_filename);
}
}
}
- unset($sql, $prep_statement, $result, $row);
+ unset($sql, $result, $row);
}
//if not base64, decode to local files, remove base64 data from db
else if (is_array($_SESSION['recordings']['storage_type']) && $_SESSION['recordings']['storage_type']['text'] != 'base64') {
//get recordings with base64 in db
$sql = "select recording_uuid, domain_uuid, recording_filename, recording_base64 ";
- $sql .= "from v_recordings where recording_base64 is not null ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- if (count($result) > 0) {
+ $sql .= "from v_recordings ";
+ $sql .= "where recording_base64 is not null ";
+ $database = new database;
+ $result = $database->select($sql, null, 'all');
+ if (is_array($result) && @sizeof($result) != 0) {
foreach ($result as &$row) {
$recording_uuid = $row['recording_uuid'];
$recording_domain_uuid = $row['domain_uuid'];
@@ -87,15 +96,24 @@
//decode base64, save to local file
$recording_decoded = base64_decode($recording_base64);
file_put_contents($recording_directory.'/'.$recording_filename, $recording_decoded);
- $sql = "update v_recordings ";
- $sql .= "set recording_base64 = null ";
- $sql .= "where domain_uuid = '".$recording_domain_uuid."' ";
- $sql .= "and recording_uuid = '".$recording_uuid."' ";
- $db->exec(check_sql($sql));
- unset($sql);
+ //build array
+ $array['recordings'][0]['recording_uuid'] = $recording_uuid;
+ $array['recordings'][0]['domain_uuid'] = $recording_domain_uuid;
+ $array['recordings'][0]['recording_base64'] = null;
+ //grant temporary permissions
+ $p = new permissions;
+ $p->add('recording_edit', 'temp');
+ //update recording record
+ $database = new database;
+ $database->app_name = 'recordings';
+ $database->app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
+ $database->save($array);
+ unset($array);
+ //revoke temporary permissions
+ $p->delete('recording_edit', 'temp');
}
}
- unset($sql, $prep_statement, $result, $row);
+ unset($sql, $result, $row);
}
}
diff --git a/app/recordings/recording_delete.php b/app/recordings/recording_delete.php
index a4c91e28fc..ad85a809a6 100644
--- a/app/recordings/recording_delete.php
+++ b/app/recordings/recording_delete.php
@@ -39,40 +39,41 @@ else {
$text = $language->get();
//get the id
- if (count($_GET) > 0) {
- $id = $_GET["id"];
- }
+ $recording_uuid = $_GET["id"];
-if (strlen($id)>0) {
+if (is_uuid($recording_uuid)) {
//get filename
- $sql = "select * from v_recordings ";
- $sql .= "where recording_uuid = '$id' ";
- $sql .= "and domain_uuid = '$domain_uuid' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- foreach ($result as &$row) {
- $filename = $row["recording_filename"];
- break; //limit to 1 row
- }
- unset ($prep_statement);
+ $sql = "select recording_filename from v_recordings ";
+ $sql .= "where recording_uuid = :recording_uuid ";
+ $sql .= "and domain_uuid = :domain_uuid ";
+ $parameters['recording_uuid'] = $recording_uuid;
+ $parameters['domain_uuid'] = $domain_uuid;
+ $database = new database;
+ $filename = $database->select($sql, $parameters, 'column');
+ unset($prep_statement);
+
+ //build array
+ $array['recordings'][0]['recording_uuid'] = $recording_uuid;
+ $array['recordings'][0]['domain_uuid'] = $domain_uuid;
//delete recording from the database
- $sql = "delete from v_recordings ";
- $sql .= "where recording_uuid = '$id' ";
- $sql .= "and domain_uuid = '$domain_uuid' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- unset($sql);
+ $database = new database;
+ $database->app_name = 'recordings';
+ $database->app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
+ $database->delete($array);
+ unset($array);
//delete the recording
if (file_exists($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$filename)) {
@unlink($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$filename);
}
+
+ //set message
+ message::add($text['message-delete']);
}
//redirect the user
- message::add($text['message-delete']);
header("Location: recordings.php");
- return;
+ exit;
+
?>
\ No newline at end of file
diff --git a/app/recordings/recording_edit.php b/app/recordings/recording_edit.php
index c639ade871..5703619218 100644
--- a/app/recordings/recording_edit.php
+++ b/app/recordings/recording_edit.php
@@ -40,16 +40,16 @@ else {
$text = $language->get();
//get recording id
- if (isset($_REQUEST["id"])) {
- $recording_uuid = check_str($_REQUEST["id"]);
+ if (is_uuid($_REQUEST["id"])) {
+ $recording_uuid = $_REQUEST["id"];
}
//get the form value and set to php variables
if (count($_POST) > 0) {
- $recording_filename = check_str($_POST["recording_filename"]);
- $recording_filename_original = check_str($_POST["recording_filename_original"]);
- $recording_name = check_str($_POST["recording_name"]);
- $recording_description = check_str($_POST["recording_description"]);
+ $recording_filename = $_POST["recording_filename"];
+ $recording_filename_original = $_POST["recording_filename_original"];
+ $recording_name = $_POST["recording_name"];
+ $recording_description = $_POST["recording_description"];
//clean the recording filename and name
$recording_filename = str_replace(" ", "_", $recording_filename);
@@ -59,7 +59,7 @@ else {
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get recording uuid to edit
- $recording_uuid = check_str($_POST["recording_uuid"]);
+ $recording_uuid = $_POST["recording_uuid"];
//check for all required data
$msg = '';
@@ -86,40 +86,46 @@ if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
rename($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename_original, $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename);
}
- //update the database with the new data
- $sql = "update v_recordings set ";
- $sql .= "domain_uuid = '".$domain_uuid."', ";
- $sql .= "recording_filename = '".$recording_filename."', ";
- $sql .= "recording_name = '".$recording_name."', ";
- $sql .= "recording_description = '".$recording_description."' ";
- $sql .= "where domain_uuid = '".$domain_uuid."'";
- $sql .= "and recording_uuid = '".$recording_uuid."'";
- $db->exec(check_sql($sql));
- unset($sql);
+ //build array
+ $array['recordings'][0]['domain_uuid'] = $domain_uuid;
+ $array['recordings'][0]['recording_filename'] = $recording_filename;
+ $array['recordings'][0]['recording_name'] = $recording_name;
+ $array['recordings'][0]['recording_description'] = $recording_description;
+ $array['recordings'][0]['domain_uuid'] = $domain_uuid;
+ $array['recordings'][0]['recording_uuid'] = $recording_uuid;
- message::add($text['message-update']);
- header("Location: recordings.php");
- return;
- } //if (permission_exists('recording_edit')) {
- } //if ($_POST["persistformvar"] != "true")
-} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
+ //execute update
+ $database = new database;
+ $database->app_name = 'recordings';
+ $database->app_uuid = '83913217-c7a2-9e90-925d-a866eb40b60e';
+ $database->save($array);
+ unset($array);
+ // set message
+ message::add($text['message-update']);
+
+ //redirect
+ header("Location: recordings.php");
+ exit;
+ }
+ }
+}
//pre-populate the form
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {
$recording_uuid = $_GET["id"];
$sql = "select * from v_recordings ";
- $sql .= "where domain_uuid = '".$domain_uuid."' ";
- $sql .= "and recording_uuid = '".$recording_uuid."' ";
- $prep_statement = $db->prepare(check_sql($sql));
- $prep_statement->execute();
- $result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
- foreach ($result as &$row) {
+ $sql .= "where domain_uuid = :domain_uuid ";
+ $sql .= "and recording_uuid = :recording_uuid ";
+ $parameters['domain_uuid'] = $domain_uuid;
+ $parameters['recording_uuid'] = $recording_uuid;
+ $database = new database;
+ $row = $database->select($sql, $parameters, 'row');
+ if (is_array($row) && @sizeof($row) != 0) {
$recording_filename = $row["recording_filename"];
$recording_name = $row["recording_name"];
$recording_description = $row["recording_description"];
- break; //limit to 1 row
}
- unset ($prep_statement);
+ unset($sql, $parameters, $row);
}
//show the header
diff --git a/app/recordings/recording_play.php b/app/recordings/recording_play.php
index 74fdf107e8..0117dbf265 100644
--- a/app/recordings/recording_play.php
+++ b/app/recordings/recording_play.php
@@ -65,16 +65,16 @@
if ($file_ext == "wav") {
//HTML5 method
if ($browser_name == "Google Chrome" || $browser_name == "Mozilla Firefox") {
- echo "";
+ echo "";
}
else {
- echo "";
- echo "