diff --git a/app/recordings/recordings.php b/app/recordings/recordings.php index 3e73034d64..cc7b5d65ff 100644 --- a/app/recordings/recordings.php +++ b/app/recordings/recordings.php @@ -40,9 +40,33 @@ //initialize the database connection $database = database::new(); -//add the settings object - $settings = new settings(["domain_uuid" => $_SESSION['domain_uuid'], "user_uuid" => $_SESSION['user_uuid']]); - $speech_enabled = $settings->get('speech', 'enabled'); +//get the session settings + $domain_uuid = $_SESSION['domain_uuid']; + $domain_name = $_SESSION['domain_name']; + $user_uuid = $_SESSION['user_uuid']; + $domains = $_SESSION['domains']; + +//initialize the settings object + $settings = new settings(["domain_uuid" => $domain_uuid, "user_uuid" => $user_uuid]); + +//get the settings + $time_zone = $settings->get('domain', 'time_zone', date_default_timezone_get()); + $speech_enabled = $settings->get('speech', 'enabled', false); + $recording_storage_type = $settings->get('recordings','storage_type'); + $recording_password = $settings->get('recordings','recording_password'); + $domain_paging = $settings->get('domain','paging'); + $domain_paging = $settings->get('domain','paging', ); + $theme_button_icon_edit = $settings->get('theme','button_icon_edit'); + $theme_button_icon_add = $settings->get('theme','button_icon_add'); + $theme_button_icon_upload = $settings->get('theme','button_icon_upload'); + $theme_button_icon_cancel = $settings->get('theme','button_icon_cancel'); + $theme_button_icon_delete = $settings->get('theme','button_icon_delete'); + $theme_button_icon_all = $settings->get('theme','button_icon_all'); + $theme_button_icon_search = $settings->get('theme','button_icon_search'); + $theme_list_row_edit_button = $settings->get('theme','list_row_edit_button'); + $theme_button_icon_download = $settings->get('theme','button_icon_download'); + $theme_button_icon_play = $settings->get('theme','button_icon_play'); + $theme_button_icon_reset = $settings->get('theme','button_icon_reset'); //set additional variables $action = $_REQUEST["action"] ?? ''; @@ -53,7 +77,7 @@ if ($action == "download" && (permission_exists('recording_play') || permission_exists('recording_download'))) { if ($_GET['type'] == "rec") { //set the path for the directory - $path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']; + $path = $switch_recordings."/".$domain_name; //if from recordings, get recording details from db $recording_uuid = $_GET['id']; //recordings @@ -67,7 +91,7 @@ $row = $database->select($sql, $parameters, 'row'); if (is_array($row) && @sizeof($row) != 0) { $recording_filename = $row['recording_filename']; - if (!empty($_SESSION['recordings']['storage_type']['text']) && $_SESSION['recordings']['storage_type']['text'] == 'base64' && !empty($row['recording_base64'])) { + if ($recording_storage_type == 'base64') { $recording_decoded = base64_decode($row['recording_base64']); file_put_contents($path.'/'.$recording_filename, $recording_decoded); } @@ -130,12 +154,12 @@ $recording_filename = str_replace("'", "", $recording_filename); //make sure the destination directory exists - if (!is_dir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'])) { - mkdir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'], 0770, false); + if (!is_dir($switch_recordings.'/'.$domain_name)) { + mkdir($switch_recordings.'/'.$domain_name, 0770, false); } //move the uploaded files - $result = move_uploaded_file($_FILES['file']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename); + $result = move_uploaded_file($_FILES['file']['tmp_name'], $switch_recordings.'/'.$domain_name.'/'.$recording_filename); //clear the destinations session array if (isset($_SESSION['destinations']['array'])) { @@ -171,10 +195,10 @@ $array_recordings[$row['recording_uuid']] = $row['recording_filename']; $array_base64_exists[$row['recording_uuid']] = ($row['recording_base64'] != '') ? true : false; //if not base64, convert back to local files and remove base64 from db - if (!empty($_SESSION['recordings']['storage_type']['text']) && $_SESSION['recordings']['storage_type']['text'] != 'base64' && $row['recording_base64'] != '') { - if (!file_exists($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$row['recording_filename'])) { + if ($recording_storage_type != 'base64' && $row['recording_base64'] != '') { + if (!file_exists($switch_recordings.'/'.$domain_name.'/'.$row['recording_filename'])) { $recording_decoded = base64_decode($row['recording_base64']); - file_put_contents($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$row['recording_filename'], $recording_decoded); + file_put_contents($switch_recordings.'/'.$domain_name.'/'.$row['recording_filename'], $recording_decoded); //build array $array['recordings'][0]['recording_uuid'] = $row['recording_uuid']; $array['recordings'][0]['domain_uuid'] = $domain_uuid; @@ -196,10 +220,10 @@ unset($sql, $parameters, $result, $row); //add recordings to the database - if (is_dir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/')) { - if ($dh = opendir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/')) { + if (is_dir($switch_recordings.'/'.$domain_name.'/')) { + if ($dh = opendir($switch_recordings.'/'.$domain_name.'/')) { while (($recording_filename = readdir($dh)) !== false) { - if (filetype($_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']."/".$recording_filename) == "file") { + if (filetype($switch_recordings."/".$domain_name."/".$recording_filename) == "file") { if (!is_array($array_recordings) || !in_array($recording_filename, $array_recordings)) { //file not found in db, add it @@ -212,8 +236,8 @@ $array['recordings'][0]['recording_filename'] = $recording_filename; $array['recordings'][0]['recording_name'] = $recording_name; $array['recordings'][0]['recording_description'] = $recording_description; - if ($_SESSION['recordings']['storage_type']['text'] == 'base64') { - $recording_base64 = base64_encode(file_get_contents($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename)); + if ($recording_storage_type == 'base64') { + $recording_base64 = base64_encode(file_get_contents($switch_recordings.'/'.$domain_name.'/'.$recording_filename)); $array['recordings'][0]['recording_base64'] = $recording_base64; } //set temporary permissions @@ -229,10 +253,10 @@ } else { //file found in db, check if base64 present - if (!empty($_SESSION['recordings']['storage_type']['text']) && $_SESSION['recordings']['storage_type']['text'] == 'base64') { + if ($recording_storage_type == 'base64') { $found_recording_uuid = array_search($recording_filename, $array_recordings); if (!$array_base64_exists[$found_recording_uuid]) { - $recording_base64 = base64_encode(file_get_contents($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename)); + $recording_base64 = base64_encode(file_get_contents($switch_recordings.'/'.$domain_name.'/'.$recording_filename)); //build array $array['recordings'][0]['domain_uuid'] = $domain_uuid; $array['recordings'][0]['recording_uuid'] = $found_recording_uuid; @@ -296,7 +320,7 @@ $sql .= "where true "; if ($show != "all" || !permission_exists('conference_center_all')) { $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $domain_uuid; } if (!empty($search)) { $sql .= "and ("; @@ -309,7 +333,7 @@ $num_rows = $database->select($sql, $parameters ?? null, 'column'); //prepare to page the results - $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $rows_per_page = ($domain_paging != '') ? $domain_paging : 50; $param = "&search=".urlencode($search); if ($show == "all" && permission_exists('recording_all')) { $param .= "&show=all"; @@ -321,7 +345,7 @@ $offset = $rows_per_page * $page; //get the file size - if (!empty($_SESSION['recordings']['storage_type']['text']) && $_SESSION['recordings']['storage_type']['text'] == 'base64') { + if ($recording_storage_type == 'base64') { switch ($db_type) { case 'pgsql': $sql_file_size = "length(decode(recording_base64,'base64')) as recording_size, "; break; case 'mysql': $sql_file_size = "length(from_base64(recording_base64)) as recording_size, "; break; @@ -331,12 +355,14 @@ //get the recordings from the database $sql = "select recording_uuid, domain_uuid, "; if (!empty($sql_file_size)) { $sql .= $sql_file_size; } + $sql .= "to_char(timezone(:time_zone, update_date), 'DD Mon YYYY') as date_formatted, \n"; + $sql .= "to_char(timezone(:time_zone, update_date), '".$sql_time_format."') as time_formatted, \n"; $sql .= "recording_name, recording_filename, recording_description "; $sql .= "from v_recordings "; $sql .= "where true "; if ($show != "all" || !permission_exists('conference_center_all')) { $sql .= "and (domain_uuid = :domain_uuid or domain_uuid is null) "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $domain_uuid; } if (!empty($search)) { $sql .= "and ("; @@ -348,13 +374,14 @@ } $sql .= order_by($order_by, $order, 'recording_name', 'asc'); $sql .= limit_offset($rows_per_page, $offset); + $parameters['time_zone'] = $time_zone; $recordings = $database->select($sql, $parameters ?? null, 'all'); unset($sql, $parameters); //get current recordings password if (permission_exists('recording_password')) { - if (isset($_SESSION['recordings']['recording_password']['numeric'])) { - $recording_password = $_SESSION['recordings']['recording_password']['numeric']; + if (!empty($recording_password)) { + $recording_password = $recording_password; } else { $sql = " @@ -373,7 +400,7 @@ dd.dialplan_detail_type = 'set' and dd.dialplan_detail_data like 'pin_number=%' and dd.dialplan_detail_enabled = 'true' "; - $parameters['domain_uuid'] = $_SESSION['domain_uuid']; + $parameters['domain_uuid'] = $domain_uuid; $recording_password = $database->select($sql, $parameters, 'column'); unset($sql, $parameters); } @@ -402,7 +429,7 @@ echo "