diff --git a/app/call_recordings/app_config.php b/app/call_recordings/app_config.php new file mode 100644 index 0000000000..a7034f6c3b --- /dev/null +++ b/app/call_recordings/app_config.php @@ -0,0 +1,87 @@ + \ No newline at end of file diff --git a/app/call_recordings/app_languages.php b/app/call_recordings/app_languages.php new file mode 100644 index 0000000000..869ac6b7df --- /dev/null +++ b/app/call_recordings/app_languages.php @@ -0,0 +1,344 @@ + \ No newline at end of file diff --git a/app/call_recordings/app_menu.php b/app/call_recordings/app_menu.php new file mode 100644 index 0000000000..233f50e261 --- /dev/null +++ b/app/call_recordings/app_menu.php @@ -0,0 +1,19 @@ + \ No newline at end of file diff --git a/app/call_recordings/call_recording_delete.php b/app/call_recordings/call_recording_delete.php new file mode 100644 index 0000000000..f3b31ca9b9 --- /dev/null +++ b/app/call_recordings/call_recording_delete.php @@ -0,0 +1,42 @@ +get(); + +//get the id + if (count($_GET)>0) { + $id = check_str($_GET["id"]); + } + +//delete the data + if (strlen($id)>0) { + $sql = "delete from v_call_recordings "; + $sql .= "where call_recording_uuid = '$id' "; + $sql .= "and domain_uuid = '$domain_uuid' "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + unset($sql); + } + +//delete message + messages::add($text['message-delete']); + +//redirect the user + header('Location: call_recordings.php'); + +?> \ No newline at end of file diff --git a/app/call_recordings/call_recording_edit.php b/app/call_recordings/call_recording_edit.php new file mode 100644 index 0000000000..9dadb2a4b3 --- /dev/null +++ b/app/call_recordings/call_recording_edit.php @@ -0,0 +1,240 @@ +get(); + +//action add or update + if (isset($_REQUEST["id"])) { + $action = "update"; + $call_recording_uuid = check_str($_REQUEST["id"]); + } + else { + $action = "add"; + } + +//get http post variables and set them to php variables + if (is_array($_POST)) { + $call_recording_name = check_str($_POST["call_recording_name"]); + $call_recording_path = check_str($_POST["call_recording_path"]); + $call_recording_length = check_str($_POST["call_recording_length"]); + $call_recording_date = check_str($_POST["call_recording_date"]); + $call_direction = check_str($_POST["call_direction"]); + $call_recording_description = check_str($_POST["call_recording_description"]); + $call_recording_base64 = check_str($_POST["call_recording_base64"]); + } + +//process the user data and save it to the database + if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) { + + //get the uuid from the POST + if ($action == "update") { + $call_recording_uuid = check_str($_POST["call_recording_uuid"]); + } + + //check for all required data + $msg = ''; + if (strlen($call_recording_name) == 0) { $msg .= $text['message-required']." ".$text['label-call_recording_name']."
\n"; } + //if (strlen($call_recording_path) == 0) { $msg .= $text['message-required']." ".$text['label-call_recording_path']."
\n"; } + if (strlen($call_recording_length) == 0) { $msg .= $text['message-required']." ".$text['label-call_recording_length']."
\n"; } + if (strlen($call_recording_date) == 0) { $msg .= $text['message-required']." ".$text['label-call_recording_date']."
\n"; } + if (strlen($call_direction) == 0) { $msg .= $text['message-required']." ".$text['label-call_direction']."
\n"; } + //if (strlen($call_recording_description) == 0) { $msg .= $text['message-required']." ".$text['label-call_recording_description']."
\n"; } + //if (strlen($call_recording_base64) == 0) { $msg .= $text['message-required']." ".$text['label-call_recording_base64']."
\n"; } + if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) { + require_once "resources/header.php"; + require_once "resources/persist_form_var.php"; + echo "
\n"; + echo "
\n"; + echo $msg."
"; + echo "
\n"; + persistformvar($_POST); + echo "
\n"; + require_once "resources/footer.php"; + return; + } + + //set the domain_uuid + $_POST["domain_uuid"] = $_SESSION["domain_uuid"]; + + //add the call_recording_uuid + if (strlen($_POST["call_recording_uuid"]) == 0) { + $call_recording_uuid = uuid(); + $_POST["call_recording_uuid"] = $call_recording_uuid; + } + + //prepare the array + $array['call_recordings'][0] = $_POST; + + //save to the data + $database = new database; + $database->app_name = 'call_recordings'; + $database->app_uuid = null; + if (strlen($call_recording_uuid) > 0) { + $database->uuid($call_recording_uuid); + } + $database->save($array); + $message = $database->message; + + //debug info + //echo "
";
+			//print_r($message);
+			//echo "
"; + //exit; + + //redirect the user + if (isset($action)) { + if ($action == "add") { + $_SESSION["message"] = $text['message-add']; + } + if ($action == "update") { + $_SESSION["message"] = $text['message-update']; + } + header('Location: call_recording_edit.php?id='.$call_recording_uuid); + return; + } + } //(is_array($_POST) && strlen($_POST["persistformvar"]) == 0) + +//pre-populate the form + if (is_array($_GET) && $_POST["persistformvar"] != "true") { + $call_recording_uuid = check_str($_GET["id"]); + $sql = "select * from v_call_recordings "; + $sql .= "where call_recording_uuid = '$call_recording_uuid' "; + //$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) { + $call_recording_name = $row["call_recording_name"]; + $call_recording_path = $row["call_recording_path"]; + $call_recording_length = $row["call_recording_length"]; + $call_recording_date = $row["call_recording_date"]; + $call_direction = $row["call_direction"]; + $call_recording_description = $row["call_recording_description"]; + $call_recording_base64 = $row["call_recording_base64"]; + } + unset ($prep_statement); + } + +//show the header + require_once "resources/header.php"; + +//add the calendar + echo "\n"; + +//show the content + echo "
\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo "\n"; + echo "\n"; + echo "\n"; + echo "\n"; + + echo " \n"; + echo " \n"; + echo " "; + echo "
".$text['title-call_recording']."

\n"; + echo " "; + echo " "; + echo "
\n"; + echo " ".$text['label-call_recording_name']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-call_recording_name']."\n"; + echo "
\n"; + echo " ".$text['label-call_recording_path']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-call_recording_path']."\n"; + echo "
\n"; + echo " ".$text['label-call_recording_length']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-call_recording_length']."\n"; + echo "
\n"; + echo " ".$text['label-call_recording_date']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-call_recording_date']."\n"; + echo "
\n"; + echo " ".$text['label-call_direction']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-call_direction']."\n"; + echo "
\n"; + echo " ".$text['label-call_recording_description']."\n"; + echo "\n"; + echo " \n"; + echo "
\n"; + echo $text['description-call_recording_description']."\n"; + echo "
\n"; + if ($action == "update") { + echo " \n"; + } + echo " \n"; + echo "
"; + echo "
"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/app/call_recordings/call_recordings.php b/app/call_recordings/call_recordings.php new file mode 100644 index 0000000000..470a7b078e --- /dev/null +++ b/app/call_recordings/call_recordings.php @@ -0,0 +1,263 @@ +get(); + +//get variables used to control the order + $order_by = check_str($_GET["order_by"]); + $order = check_str($_GET["order"]); + +//add the search term + $search = strtolower(check_str($_GET["search"])); + if (strlen($search) > 0) { + $sql_search = "and ("; + $sql_search .= "lower(call_recording_name) like '%".$search."%' "; + $sql_search .= "or lower(call_recording_path) like '%".$search."%' "; + $sql_search .= "or lower(call_direction) like '%".$search."%' "; + $sql_search .= "or lower(call_recording_description) like '%".$search."%' "; + $sql_search .= ") "; + } + +//delete the recordings + if (permission_exists('call_recording_delete')) { + if (is_array($_POST["call_recordings"])) { + //set the array + $call_recordings = $_POST["call_recordings"]; + //debug info + //echo "
\n";
+				//print_r($call_recordings);
+				//echo "
\n"; + //get the action + foreach($call_recordings as $row) { + if ($row['action'] == 'delete') { + $action = 'delete'; + break; + } + } + //delete the checked rows + if ($action == 'delete') { + foreach($call_recordings as $row) { + if ($row['checked'] == 'true') { + $sql = "delete from v_call_recordings "; + $sql .= "where call_recording_uuid = '".$row['call_recording_uuid']."'; "; + //echo $sql."\n"; + $db->query($sql); + unset($sql); + } + } + } + //delete message + messages::add($text['message-delete']); + } + } + +//additional includes + require_once "resources/header.php"; + require_once "resources/paging.php"; + +//prepare to page the results + $sql = "select count(call_recording_uuid) as num_rows from v_call_recordings "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $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'; + } + } + +//prepare to page the results + $rows_per_page = ($_SESSION['domain']['paging']['numeric'] != '') ? $_SESSION['domain']['paging']['numeric'] : 50; + $param = ""; + $page = $_GET['page']; + if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; } + list($paging_controls, $rows_per_page, $var3) = paging($num_rows, $param, $rows_per_page); + $offset = $rows_per_page * $page; + +//get the list + $sql = "select * from v_call_recordings "; + $sql .= "where domain_uuid = '".$_SESSION["domain_uuid"]."' "; + $sql .= $sql_search; + if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; } + $sql .= "limit $rows_per_page offset $offset "; + $prep_statement = $db->prepare(check_sql($sql)); + $prep_statement->execute(); + $result = $prep_statement->fetchAll(PDO::FETCH_NAMED); + unset ($prep_statement, $sql); + +//alternate the row style + $c = 0; + $row_style["0"] = "row_style0"; + $row_style["1"] = "row_style1"; + +//define the checkbox_toggle function + echo "\n"; + +//show the content + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
".$text['title-call_recordings']."
\n"; + echo " \n"; + echo " \n"; + echo "
\n"; + echo " ".$text['title_description-call_recording']."

\n"; + echo "
\n"; + + //echo "\n"; + echo "\n"; + + echo "
\n"; + echo "\n"; + echo "\n"; + echo " \n"; + echo th_order_by('call_recording_name', $text['label-call_recording_name'], $order_by, $order); + echo "\n"; + //echo th_order_by('call_recording_path', $text['label-play'], $order_by, $order); + echo th_order_by('call_recording_length', $text['label-call_recording_length'], $order_by, $order); + echo th_order_by('call_recording_date', $text['label-call_recording_date'], $order_by, $order); + echo th_order_by('call_direction', $text['label-call_direction'], $order_by, $order); + echo th_order_by('call_recording_description', $text['label-call_recording_description'], $order_by, $order); + //echo th_order_by('call_recording_base64', $text['label-call_recording_base64'], $order_by, $order); + echo " \n"; + echo "\n"; + + if (is_array($result)) { + $x = 0; + foreach($result as $row) { + //if (permission_exists('recording_play') && $recording_file_path != '') { + // echo "\n"; + //} + if (permission_exists('call_recording_edit')) { + $tr_link = "href='call_recording_edit.php?id=".$row['call_recording_uuid']."'"; + } + echo "\n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + //echo " \n"; + echo " \n"; + echo "\n"; + $x++; + if ($c==0) { $c=1; } else { $c=0; } + } //end foreach + unset($sql, $result, $row_count); + } //end if results + + echo "\n"; + echo "\n"; + echo "\n"; + echo "
\n"; + echo " \n"; + echo " ".$text['label-recording'].""; + if (permission_exists('call_recording_add')) { + echo " $v_link_label_add"; + } + else { + echo " \n"; + } + echo "
".$row['call_recording_name']." \n"; + //echo " ".$text['label-download']." ".$v_link_label_download."\n"; + //echo " ".$row['call_recording_length']." ".$row['call_recording_date']." ".$row['call_direction']." ".$row['call_recording_description']." ".$row['call_recording_base64']." "; + if (permission_exists('xml_cdr_details')) { + echo " $v_link_label_view"; + } + if (permission_exists('call_recording_edit')) { + echo "\n"; + } + echo "
\n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo " \n"; + echo "
 $paging_controls"; + if (permission_exists('call_recording_add')) { + echo "$v_link_label_add"; + } + else { + echo " "; + } + echo "
\n"; + echo "
"; + echo "
\n"; + echo "

"; + +//include the footer + require_once "resources/footer.php"; + +?> \ No newline at end of file diff --git a/app/call_recordings/download.php b/app/call_recordings/download.php new file mode 100644 index 0000000000..590fd84ac6 --- /dev/null +++ b/app/call_recordings/download.php @@ -0,0 +1,45 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2016 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +//includes + require_once "root.php"; + require_once "resources/require.php"; + +//check permisions + require_once "resources/check_auth.php"; + if (permission_exists('call_recording_view')) { + //access granted + } + else { + echo "access denied"; + exit; + } + +//download + $obj = new call_recordings; + $obj->download(); + +?> \ No newline at end of file diff --git a/app/call_recordings/resources/classes/call_recordings.php b/app/call_recordings/resources/classes/call_recordings.php new file mode 100644 index 0000000000..fac920cbf4 --- /dev/null +++ b/app/call_recordings/resources/classes/call_recordings.php @@ -0,0 +1,123 @@ +db) { + require_once "resources/classes/database.php"; + $database = new database; + $database->connect(); + $this->db = $database->db; + } + } + + /** + * Called when there are no references to a particular object + * unset the variables used in the class + */ + public function __destruct() { + foreach ($this as $key => $value) { + unset($this->$key); + } + } + + /** + * download the recordings + */ + public function download() { + +// if (permission_exists('call_recording_play') || permission_exists('call_recording_download')) { + + //cache limiter + session_cache_limiter('public'); + + //get call recording from database + $call_recording_uuid = check_str($_GET['id']); + if ($call_recording_uuid != '') { + $sql = "select call_recording_name, call_recording_path, call_recording_base64 from v_call_recordings "; + $sql .= "where call_recording_uuid = '".$call_recording_uuid."' "; + //$sql .= "and domain_uuid = '".$domain_uuid."' \n"; + $prep_statement = $this->db->prepare(check_sql($sql)); + $prep_statement->execute(); + $call_recordings = $prep_statement->fetchAll(PDO::FETCH_ASSOC); + if (is_array($call_recordings)) { + foreach($call_recordings as &$row) { + $call_recording_name = $row['call_recording_name']; + $call_recording_path = $row['call_recording_path']; + if ($_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') { + file_put_contents($path.'/'.$call_recording_name, base64_decode($row['call_recording_base64'])); + } + break; + } + } + unset ($sql, $prep_statement, $call_recordings); + } + + //set the path for the directory + $default_path = $_SESSION['switch']['call_recordings']['dir']."/".$_SESSION['domain_name']; + + //build full path + $full_recording_path = $call_recording_path . '/' . $call_recording_name; + + //download the file + if (file_exists($full_recording_path)) { + //content-range + //if (isset($_SERVER['HTTP_RANGE'])) { + // range_download($full_recording_path); + //} + ob_clean(); + $fd = fopen($full_recording_path, "rb"); + if ($_GET['t'] == "bin") { + header("Content-Type: application/force-download"); + header("Content-Type: application/octet-stream"); + header("Content-Type: application/download"); + header("Content-Description: File Transfer"); + } + else { + $file_ext = substr($call_recording_name, -3); + if ($file_ext == "wav") { + header("Content-Type: audio/x-wav"); + } + if ($file_ext == "mp3") { + header("Content-Type: audio/mpeg"); + } + } + //exit; + //echo "file_ext: ".$file_ext."
\n"; + //echo "type: ".$_GET['t']."
\n"; + //exit; + header('Content-Disposition: attachment; filename="'.$call_recording_name.'"'); + 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("Content-Length: " . filesize($full_recording_path)); + ob_clean(); + fpassthru($fd); + } + + //if base64, remove temp recording file + if ($_SESSION['call_recordings']['storage_type']['text'] == 'base64' && $row['call_recording_base64'] != '') { + @unlink($full_recording_path); + } +// } + } //end download method + } //end the class +} + +/* +$obj = new call_recordings; +$obj->download('all'); +*/ + +?> \ No newline at end of file diff --git a/app/call_recordings/root.php b/app/call_recordings/root.php new file mode 100644 index 0000000000..6fdf32f37b --- /dev/null +++ b/app/call_recordings/root.php @@ -0,0 +1,90 @@ + + Portions created by the Initial Developer are Copyright (C) 2008-2012 + the Initial Developer. All Rights Reserved. + + Contributor(s): + Mark J Crane +*/ + +// make sure the PATH_SEPARATOR is defined + umask(2); + if (!defined("PATH_SEPARATOR")) { + if (strpos($_ENV["OS"], "Win") !== false) { + define("PATH_SEPARATOR", ";"); + } else { + define("PATH_SEPARATOR", ":"); + } + } + + if (!isset($output_format)) $output_format = (PHP_SAPI == 'cli') ? 'text' : 'html'; + + // make sure the document_root is set + $_SERVER["SCRIPT_FILENAME"] = str_replace("\\", '/', $_SERVER["SCRIPT_FILENAME"]); + if(PHP_SAPI == 'cli'){ + chdir(pathinfo(realpath($_SERVER["PHP_SELF"]), PATHINFO_DIRNAME)); + $script_full_path = str_replace("\\", '/', getcwd() . '/' . $_SERVER["SCRIPT_FILENAME"]); + $dirs = explode('/', pathinfo($script_full_path, PATHINFO_DIRNAME)); + if (file_exists('/project_root.php')) { + $path = '/'; + } else { + $i = 1; + $path = ''; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + } + $_SERVER["DOCUMENT_ROOT"] = $path; + }else{ + $_SERVER["DOCUMENT_ROOT"] = str_replace($_SERVER["PHP_SELF"], "", $_SERVER["SCRIPT_FILENAME"]); + } + $_SERVER["DOCUMENT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"]); +// try to detect if a project path is being used + if (!defined('PROJECT_PATH')) { + if (is_dir($_SERVER["DOCUMENT_ROOT"]. '/fusionpbx')) { + define('PROJECT_PATH', '/fusionpbx'); + } elseif (file_exists($_SERVER["DOCUMENT_ROOT"]. '/project_root.php')) { + define('PROJECT_PATH', ''); + } else { + $dirs = explode('/', str_replace('\\', '/', pathinfo($_SERVER["PHP_SELF"], PATHINFO_DIRNAME))); + $i = 1; + $path = $_SERVER["DOCUMENT_ROOT"]; + while ($i < count($dirs)) { + $path .= '/' . $dirs[$i]; + if (file_exists($path. '/project_root.php')) { + break; + } + $i++; + } + 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"); + } + $project_path = str_replace($_SERVER["DOCUMENT_ROOT"], "", $path); + define('PROJECT_PATH', $project_path); + } + $_SERVER["PROJECT_ROOT"] = realpath($_SERVER["DOCUMENT_ROOT"] . PROJECT_PATH); + set_include_path(get_include_path() . PATH_SEPARATOR . $_SERVER["PROJECT_ROOT"]); + } + +?> \ No newline at end of file