From 95a12e2fcd917ffe855b3d70d07ce3f8d1f3c92a Mon Sep 17 00:00:00 2001 From: FusionPBX Date: Thu, 22 Sep 2016 19:26:40 -0600 Subject: [PATCH] Update recordings.php When uploading a recording ensure that the domain name directory exists so the file can be uploaded to it. --- app/recordings/recordings.php | 33 +++++++++++++++++++++++---------- 1 file changed, 23 insertions(+), 10 deletions(-) diff --git a/app/recordings/recordings.php b/app/recordings/recordings.php index 9379c3844b..84043e88f2 100644 --- a/app/recordings/recordings.php +++ b/app/recordings/recordings.php @@ -17,16 +17,18 @@ The Initial Developer of the Original Code is Mark J Crane - Portions created by the Initial Developer are Copyright (C) 2008-2012 + Portions created by the Initial Developer are Copyright (C) 2008-2016 the Initial Developer. All Rights Reserved. Contributor(s): Mark J Crane James Rose */ -include "root.php"; -require_once "resources/require.php"; -require_once "resources/check_auth.php"; + +//includes + include "root.php"; + require_once "resources/require.php"; + require_once "resources/check_auth.php"; //add multi-lingual support $language = new text; @@ -49,7 +51,8 @@ require_once "resources/check_auth.php"; if ($_GET['a'] == "download" && (permission_exists('recording_play') || permission_exists('recording_download'))) { session_cache_limiter('public'); if ($_GET['type'] = "rec") { - $path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']; + //set the path for the directory + $path = $_SESSION['switch']['recordings']['dir']."/".$_SESSION['domain_name']; //if from recordings, get recording details from db $recording_uuid = check_str($_GET['id']); //recordings @@ -125,11 +128,21 @@ require_once "resources/check_auth.php"; //upload the recording if (permission_exists('recording_upload')) { if ($_POST['submit'] == $text['button-upload'] && $_POST['type'] == 'rec' && is_uploaded_file($_FILES['ulfile']['tmp_name'])) { - $recording_filename = str_replace(" ", "_", $_FILES['ulfile']['name']); - $recording_filename = str_replace("'", "", $recording_filename); - move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename); - $_SESSION['message'] = $text['message-uploaded'].": ".htmlentities($recording_filename); + //remove special characters + $recording_filename = str_replace(" ", "_", $_FILES['ulfile']['name']); + $recording_filename = str_replace("'", "", $recording_filename); + + //make sure the destination directory exists + if (!is_dir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'])) { + event_socket_mkdir($_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name']); + } + + //move the uploaded files + move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$_SESSION['domain_name'].'/'.$recording_filename); + + //set the message + $_SESSION['message'] = $text['message-uploaded'].": ".htmlentities($recording_filename); //set the file name to be inserted as the recording description $recording_description = base64_encode($_FILES['ulfile']['name']); @@ -479,4 +492,4 @@ function range_download($file) { fclose($fp); } -?> \ No newline at end of file +?>