Voicemail Greetings: Better base64 support in gui (playback, download, etc) and lua scripts, some lua mods to allow re-recording without having to enter greeting # again, fixed choose greeting function, new greeting recordings now only save when told to (uses a temp file prior to), fix sorting on greetings list, app_defaults to move greetings from file system to base64 in db (and vice versa).

Recordings: Fix sorting and paging.

IVRs: Code cleanup.

(... and some other stuff I can't remember at this hour.)
This commit is contained in:
Nate Jones
2015-04-25 12:26:31 +00:00
parent aa51218465
commit 33248f605f
17 changed files with 876 additions and 749 deletions

View File

@@ -235,7 +235,7 @@ else {
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
if (permission_exists('dialplan_delete') && $result_count > 0) {
echo "<th style='text-align: center;' style='text-align: center; padding: 3px 0px 0px 0px;' width='1'><input type='checkbox' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
echo "<th style='text-align: center;' style='text-align: center; padding: 3px 0px 0px 0px;' width='1'><input type='checkbox' style='margin: 0px 0px 0px 2px;' onchange=\"(this.checked) ? check('all') : check('none');\"></th>";
}
echo th_order_by('dialplan_name', $text['label-name'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null));
echo th_order_by('dialplan_number', $text['label-number'], $order_by, $order, $app_uuid, null, (($search != '') ? "search=".$search : null));

View File

@@ -54,119 +54,109 @@ else {
}
//show the content
echo "<table width='100%' cellpadding='0' cellspacing='0' border='0'>\n";
echo "<b>".$text['header-ivr_menus']."</b>\n";
echo "<br /><br />\n";
echo $text['description-ivr_menus']."\n";
echo "<br /><br />\n";
//get the count
require_once "resources/classes/database.php";
require_once "resources/classes/ivr_menu.php";
$ivr = new ivr_menu;
$ivr->domain_uuid = $_SESSION["domain_uuid"];
$ivr->table = "v_ivr_menus";
$where[0]['name'] = 'domain_uuid';
$where[0]['value'] = $_SESSION["domain_uuid"];
$where[0]['operator'] = '=';
$ivr->where = $where;
$num_rows = $ivr->count();
//use total ivr menu count from the database
$total_ivr_menus = $num_rows;
//prepare to page the results
$rows_per_page = 150;
$param = "";
if (!isset($_GET['page'])) { $_GET['page'] = 0; }
$_GET['page'] = check_str($_GET['page']);
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $_GET['page'];
//get the list from the db
if (isset($order_by)) {
if (count($order_by) > 0) {
$ivr->order_by = $order_by;
}
}
$result = $ivr->find();
$result_count = count($result);
unset ($prep_statement, $sql);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td width='50%' nowrap='nowrap' align='left'><b>".$text['header-ivr_menus']."</b></td>\n";
echo "</tr>\n";
echo "<tr>\n";
echo "<td align='left'>".$text['description-ivr_menus']."</td>\n";
echo th_order_by('ivr_menu_name', $text['label-name'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_extension', $text['label-extension'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_direct_dial', $text['label-direct_dial'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_enabled', $text['label-enabled'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_description', $text['label-description'], $order_by[0]['name'], $order_by[0]['order']);
echo "<td class='list_control_icons'>";
if (permission_exists('ivr_menu_add')) {
if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
echo "<a href='ivr_menu_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
echo "</td>\n";
echo "</tr>\n";
if ($result_count > 0) {
foreach($result as $row) {
$ivr_menu_name = str_replace("-", " ", $row['ivr_menu_name']);
$tr_link = (permission_exists('ivr_menu_edit')) ? "href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."'" : null;
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('ivr_menu_edit')) {
echo "<a href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."'>".$ivr_menu_name."</a>";
}
else {
echo $ivr_menu_name;
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['ivr_menu_extension']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".ucwords($row['ivr_menu_direct_dial'])."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".ucwords($row['ivr_menu_enabled'])."</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['ivr_menu_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('ivr_menu_edit')) {
echo "<a href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('ivr_menu_delete')) {
echo "<a href='ivr_menu_delete.php?id=".$row['ivr_menu_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
} //end if results
if (permission_exists('ivr_menu_add')) {
if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
echo "<tr>\n";
echo " <td colspan='5' align='left'>&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
echo "<a href='ivr_menu_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
echo " </td>\n";
echo "</tr>\n";
}
}
echo "</table>\n";
echo "<br>\n";
echo "<br>";
//get the count
require_once "resources/classes/database.php";
require_once "resources/classes/ivr_menu.php";
$ivr = new ivr_menu;
$ivr->domain_uuid = $_SESSION["domain_uuid"];
$ivr->table = "v_ivr_menus";
$where[0]['name'] = 'domain_uuid';
$where[0]['value'] = $_SESSION["domain_uuid"];
$where[0]['operator'] = '=';
$ivr->where = $where;
$num_rows = $ivr->count();
//use total ivr menu count from the database
$total_ivr_menus = $num_rows;
//prepare to page the results
$rows_per_page = 150;
$param = "";
if (!isset($_GET['page'])) { $_GET['page'] = 0; }
$_GET['page'] = check_str($_GET['page']);
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $_GET['page'];
//get the list from the db
if (isset($order_by)) {
if (count($order_by) > 0) {
$ivr->order_by = $order_by;
}
}
$result = $ivr->find();
$result_count = count($result);
unset ($prep_statement, $sql);
$c = 0;
$row_style["0"] = "row_style0";
$row_style["1"] = "row_style1";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('ivr_menu_name', $text['label-name'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_extension', $text['label-extension'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_direct_dial', $text['label-direct_dial'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_enabled', $text['label-enabled'], $order_by[0]['name'], $order_by[0]['order']);
echo th_order_by('ivr_menu_description', $text['label-description'], $order_by[0]['name'], $order_by[0]['order']);
echo "<td class='list_control_icons'>";
if (permission_exists('ivr_menu_add')) {
if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
echo "<a href='ivr_menu_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
echo "</td>\n";
echo "</tr>\n";
if ($result_count > 0) {
foreach($result as $row) {
$ivr_menu_name = str_replace("-", " ", $row['ivr_menu_name']);
$tr_link = (permission_exists('ivr_menu_edit')) ? "href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."'" : null;
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
if (permission_exists('ivr_menu_edit')) {
echo "<a href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."'>".$ivr_menu_name."</a>";
}
else {
echo $ivr_menu_name;
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['ivr_menu_extension']."&nbsp;</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".ucwords($row['ivr_menu_direct_dial'])."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".ucwords($row['ivr_menu_enabled'])."</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['ivr_menu_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('ivr_menu_edit')) {
echo "<a href='ivr_menu_edit.php?id=".$row['ivr_menu_uuid']."' alt='".$text['button-edit']."'>$v_link_label_edit</a>";
}
if (permission_exists('ivr_menu_delete')) {
echo "<a href='ivr_menu_delete.php?id=".$row['ivr_menu_uuid']."' alt='".$text['button-delete']."' onclick=\"return confirm('".$text['confirm-delete']."')\">$v_link_label_delete</a>";
}
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
} //end foreach
unset($sql, $result, $row_count);
} //end if results
echo "<tr>\n";
echo "<td colspan='6' align='left'>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('ivr_menu_add')) {
if ($_SESSION['limit']['ivr_menus']['numeric'] == '' || ($_SESSION['limit']['ivr_menus']['numeric'] != '' && $total_ivr_menus < $_SESSION['limit']['ivr_menus']['numeric'])) {
echo "<a href='ivr_menu_edit.php' alt='".$text['button-add']."'>".$v_link_label_add."</a>";
}
}
echo " </td>\n";
echo " </tr>\n";
echo " </table>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<br><br>";
//show the footer

View File

@@ -140,12 +140,12 @@ $text['header']['fr-fr'] = "Télécharger Enregistrement";
$text['header']['pt-br'] = "Carregadr gravações";
$text['header']['pl'] = "Wyślij nagranie";
$text['description-recording']['en-us'] = "Recording Name. example: recording_x";
$text['description-recording']['es-cl'] = "Nombre de la grabación. ejemplo: grabacion_x";
$text['description-recording']['pt-pt'] = "Nome da gravação. exemplo: recording_x";
$text['description-recording']['fr-fr'] = "Nom de l'enregistrement. exemple: enregistrement_x";
$text['description-recording']['pt-br'] = "Nome da gravação: exemplo: recording_x";
$text['description-recording']['pl'] = "Nazwa nagrania, przykład: nagranie_x";
$text['description-recording']['en-us'] = "A name for the recording (not parsed).";
$text['description-recording']['es-cl'] = "Nombre de la grabación.";
$text['description-recording']['pt-pt'] = "Nome da gravação.";
$text['description-recording']['fr-fr'] = "Nom de l'enregistrement (non parsé).";
$text['description-recording']['pt-br'] = "Nome da gravação:";
$text['description-recording']['pl'] = "Nazwa nagrania.";
$text['description-file']['en-us'] = "Name of the file. example.wav";
$text['description-file']['es-cl'] = "Nombre del archivo. ejemplo.wav";
@@ -161,12 +161,12 @@ $text['description-description']['fr-fr'] = "Vous pouvez entrer ici une descript
$text['description-description']['pt-br'] = "Insira a descrição, caso desejar";
$text['description-description']['pl'] = "Tutaj możesz wpisać opis w celach informacyjnych.";
$text['description']['en-us'] = "To make a recording dial *732 or you can make a 16bit 8khz/16khz Mono WAV file then copy it to the following directory then refresh the page to play it back. Click on the \'Filename\' to download it or the \'Recording Name\' to play the audio.";
$text['description']['es-cl'] = "Para realizar una grabación marque *732 o puede crear un archivo en formato WAV a 16 bit 8khz/16khz Mono y luego copiarlo en el siguiente directorio y refrezcar la página para reproducirlo. Click en el 'Nombre de archivo' para descargarlo o el 'Nombre de grabación' para reproducirlo.";
$text['description']['pt-pt'] = "Para fazer uma gravação marque *732 ou crie um ficheiro WAV de 16bit 8khz/16khz e copie-o para a seguinte directoria e actualize a página para o ouvir. Clique em \'Filename\' para descarregá-lo ou em \'Recording Name\' para ouvir o áudio.";
$text['description']['en-us'] = "Dial *732 to create a recording, or (for best results) upload a 16bit 8khz/16khz mono WAV file.";
$text['description']['es-cl'] = "Para realizar una grabación marque *732 o puede crear un archivo en formato WAV a 16 bit 8khz/16khz Mono y luego copiarlo en el siguiente directorio y refrezcar la página para reproducirlo.";
$text['description']['pt-pt'] = "Para fazer uma gravação marque *732 ou crie um ficheiro WAV de 16bit 8khz/16khz e copie-o para a seguinte directoria e actualize a página para o ouvir.";
$text['description']['fr-fr'] = "Pour créer un guide vocal, composer le *732 ou créer un fichier audio WAV 16bit 8khz/16khz Mono et ensuite le copier dans le répertoire qui suit. Rafraîchir ensuite cette page pour le voir apparaitre.";
$text['description']['pt-br'] = "Editar informações da conta.";
$text['description']['pl'] = "Aby stworzyć nagranie wybierz *732 z klawiatury telefonu lub stwórz plik audio w formacie WAV o następujących parametrach: 16bit 8khz/16khz Mono, a następnie skopiuj go do odpowiedniego katalogu i odśwież, aby go odsłuchać. Kliknij na \Filename\, aby pobrać plik lub na \Recording Name\, aby odsłuchać.";
$text['description']['pl'] = "Aby stworzyć nagranie wybierz *732 z klawiatury telefonu lub stwórz plik audio w formacie WAV o następujących parametrach: 16bit 8khz/16khz Mono, a następnie skopiuj go do odpowiedniego katalogu i odśwież, aby go odsłuchać.";
$text['confirm-delete']['en-us'] = "Do you really want to delete this?";
$text['confirm-delete']['es-cl'] = "¿Realmente desea eliminar esto?";

View File

@@ -39,42 +39,32 @@ else {
$language = new text;
$text = $language->get();
//set the action as an add or an update
//get recording id
if (isset($_REQUEST["id"])) {
$action = "update";
$recording_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
//get the form value and set to php variables
if (count($_POST)>0) {
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_uuid = check_str($_POST["recording_uuid"]);
$recording_description = check_str($_POST["recording_description"]);
//clean the recording filename and name
$recording_filename = str_replace(" ", "_", $recording_filename);
$recording_filename = str_replace("'", "", $recording_filename);
$recording_name = str_replace(" ", "_", $recording_name);
$recording_name = str_replace("'", "", $recording_name);
}
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
if ($action == "update") {
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get recording uuid to edit
$recording_uuid = check_str($_POST["recording_uuid"]);
}
//check for all required data
//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
$msg = '';
if (strlen($recording_filename) == 0) { $msg .= $text['label-edit-file']."<br>\n"; }
if (strlen($recording_name) == 0) { $msg .= $text['label-edit-recording']."<br>\n"; }
//if (strlen($recording_uuid) == 0) { $msg .= "Please provide: recording_uuid<br>\n"; }
//if (strlen($recording_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
@@ -88,72 +78,29 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
return;
}
//add or update the database
//update the database
if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('recording_add')) {
$recording_uuid = uuid();
$sql = "insert into v_recordings ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "recording_uuid, ";
$sql .= "recording_filename, ";
$sql .= "recording_name, ";
$sql .= "recording_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$recording_uuid', ";
$sql .= "'$recording_filename', ";
$sql .= "'$recording_name', ";
$sql .= "'$recording_description' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-add'];
header("Location: recordings.php");
return;
} //if ($action == "add")
if ($action == "update" && permission_exists('recording_edit')) {
//get the original filename
$sql = "select * from v_recordings ";
$sql .= "where recording_uuid = '$recording_uuid' ";
$sql .= "and domain_uuid = '$domain_uuid' ";
//echo "sql: ".$sql."<br />\n";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$recording_filename_orig = $row["recording_filename"];
break; //limit to 1 row
}
unset ($prep_statement);
if (permission_exists('recording_edit')) {
//if file name is not the same then rename the file
if ($recording_filename != $recording_filename_orig) {
//echo "orig: ".$_SESSION['switch']['recordings']['dir'].'/'.$recording_filename_orig."<br />\n";
//echo "new: ".$_SESSION['switch']['recordings']['dir'].'/'.$recording_filename."<br />\n";
rename($_SESSION['switch']['recordings']['dir'].'/'.$recording_filename_orig, $_SESSION['switch']['recordings']['dir'].'/'.$recording_filename);
if ($recording_filename != $recording_filename_original) {
rename($_SESSION['switch']['recordings']['dir'].'/'.$recording_filename_original, $_SESSION['switch']['recordings']['dir'].'/'.$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_uuid = '$recording_uuid', ";
$sql .= "recording_description = '$recording_description' ";
$sql .= "where domain_uuid = '$domain_uuid'";
$sql .= "and recording_uuid = '$recording_uuid'";
$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);
$_SESSION["message"] = $text['message-update'];
header("Location: recordings.php");
return;
} //if ($action == "update")
} //if (permission_exists('recording_edit')) {
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
@@ -161,16 +108,14 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
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' ";
$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) {
$domain_uuid = $row["domain_uuid"];
$recording_filename = $row["recording_filename"];
$recording_name = $row["recording_name"];
//$recording_uuid = $row["recording_uuid"];
$recording_description = $row["recording_description"];
break; //limit to 1 row
}
@@ -178,30 +123,31 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
//show the header
$document['title'] = $text['title-edit'];
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<table border='0' cellpadding='0' cellspacing='0' align='right'>\n";
echo "<tr>\n";
if ($action == "add") {
echo "<td align='left' width='30%' nowrap><b>".$text['title-add']."</b></td>\n";
}
if ($action == "update") {
echo "<td align='left' width='30%' nowrap><b>".$text['title-edit']."</b></td>\n";
}
echo "<td width='70%' align='right'>";
echo "<td nowrap='nowrap'>";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='recordings.php'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<b>".$text['title-edit']."</b>\n";
echo "<br /><br />\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-recording_name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='recording_name' maxlength='255' value=\"$recording_name\">\n";
echo "<br />\n";
echo $text['description-recording']."\n";
@@ -214,6 +160,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='recording_filename' maxlength='255' value=\"$recording_filename\">\n";
echo " <input type='hidden' name='recording_filename_original' value=\"$recording_filename\">\n";
echo "<br />\n";
echo $text['message-file']."\n";
echo "</td>\n";
@@ -231,9 +178,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
if ($action == "update") {
echo " <input type='hidden' name='recording_uuid' value='$recording_uuid'>\n";
}
echo " <input type='hidden' name='recording_uuid' value='".$recording_uuid."'>\n";
echo " <br>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
@@ -242,7 +187,6 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "<br><br>";
echo "</form>";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -39,6 +39,12 @@ require_once "resources/check_auth.php";
$order_by = $_GET["order_by"];
$order = $_GET["order"];
//define order by default
if ($order_by == '') {
$order_by = "recording_name";
$order = "asc";
}
//download the recordings
if ($_GET['a'] == "download" && (permission_exists('recording_play') || permission_exists('recording_download'))) {
session_cache_limiter('public');
@@ -99,13 +105,12 @@ require_once "resources/check_auth.php";
//upload the recording
if (permission_exists('recording_upload')) {
if ($_POST['submit'] == "Upload" && $_POST['type'] == 'rec') {
if (is_uploaded_file($_FILES['ulfile']['tmp_name'])) {
move_uploaded_file($_FILES['ulfile']['tmp_name'], $_SESSION['switch']['recordings']['dir'].'/'.$_FILES['ulfile']['name']);
unset($_POST['txtCommand']);
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'].'/'.$recording_filename);
$_SESSION['message'] = $text['message-uploaded'].": ".htmlentities($_FILES['ulfile']['name']);
}
$_SESSION['message'] = $text['message-uploaded'].": ".htmlentities($recording_filename);
header("Location: recordings.php");
exit;
}
@@ -150,7 +155,7 @@ require_once "resources/check_auth.php";
if (!in_array($file, $array_recordings)) {
//file not found, add it to the database
$a_file = explode("\.", $file);
$a_file = explode('.', $file);
$recording_uuid = uuid();
$sql = "insert into v_recordings ";
$sql .= "(";
@@ -214,29 +219,23 @@ require_once "resources/check_auth.php";
require_once "resources/header.php";
//begin the content
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left'>\n";
echo " <b>".$text['title']."</b>";
echo " <br /><br />\n";
echo " ".stripslashes($text['description'])."\n";
echo " <br /><br />\n";
echo " </td>\n";
echo " </tr>\n";
echo "</table>";
echo "<br /><br />\n";
if (permission_exists('recording_upload')) {
echo "<b>".$text['header']."</b>";
echo "<br><br>";
echo "<form action='' method='post' enctype='multipart/form-data' name='frmUpload'>\n";
echo "<input name='type' type='hidden' value='rec'>\n";
echo "".$text['label-upload']."\n";
echo "<input name='ulfile' type='file' class='formfld fileinput' style='width: 260px;' id='ulfile'>\n";
echo "<input name='submit' type='submit' class='btn' id='upload' value=\"".$text['button-upload']."\">\n";
echo "</form>";
echo "<br><br>\n";
echo "<table cellpadding='0' cellspacing='0' border='0' align='right'>\n";
echo " <tr>\n";
echo " <td nowrap='nowrap'>\n";
echo " <form action='' method='post' enctype='multipart/form-data' name='frmUpload'>\n";
echo " <input name='type' type='hidden' value='rec'>\n";
echo " <input name='ulfile' type='file' class='formfld fileinput' style='width: 260px;' id='ulfile'>\n";
echo " <input name='submit' type='submit' class='btn' id='upload' value=\"".$text['button-upload']."\">\n";
echo " </form>";
echo " </td>\n";
echo " </tr>\n";
echo "</table>";
}
echo "<b>".$text['title']."</b>";
echo "<br /><br />\n";
echo $text['description']."\n";
echo "<br /><br />\n";
$sql = "select * from v_recordings ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
@@ -248,7 +247,7 @@ require_once "resources/check_auth.php";
unset ($prep_statement, $result, $sql);
$rows_per_page = 100;
$param = "";
$param = "&order_by=".$order_by."&order=".$order;
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
@@ -256,7 +255,7 @@ require_once "resources/check_auth.php";
$sql = "select * from v_recordings ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "order by ".((strlen($order_by) > 0) ? $order_by." ".$order : "recording_name asc")." ";
$sql .= "order by ".$order_by." ".$order." ";
$sql .= "limit ".$rows_per_page." offset ".$offset." ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
@@ -272,57 +271,54 @@ require_once "resources/check_auth.php";
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo th_order_by('recording_name', $text['label-recording_name'], $order_by, $order);
echo th_order_by('recording_filename', $text['label-file_name'], $order_by, $order);
echo "<th class='listhdr' nowrap>".$text['label-tools']."</th>\n";
if ($_SESSION['recordings']['storage_type']['text'] != 'base64') {
echo th_order_by('recording_filename', $text['label-file_name'], $order_by, $order);
echo "<th class='listhdr' style='text-align: center;' nowrap>".$text['label-file-size']."</th>\n";
}
echo "<th class='listhdr' nowrap>".$text['label-tools']."</th>\n";
echo th_order_by('recording_description', $text['label-description'], $order_by, $order);
echo "<td class='list_control_icons'>&nbsp;</td>\n";
echo "</tr>\n";
//calculate colspan for progress bar
$colspan = 5; //max
if ($_SESSION['recordings']['storage_type']['text'] == 'base64') { $colspan = $colspan - 2; }
if (!(permission_exists('recording_edit') || permission_exists('recording_delete'))) { $colspan = $colspan - 1; }
if ($result_count > 0) {
foreach($result as $row) {
if ($_SESSION['recordings']['storage_type']['text'] != 'base64') {
$tmp_filesize = filesize($_SESSION['switch']['recordings']['dir'].'/'.$row['recording_filename']);
$tmp_filesize = byte_convert($tmp_filesize);
}
//playback progress bar
echo "<tr id='recording_progress_bar_".$row['recording_uuid']."' style='display: none;'><td colspan='5'><span class='playback_progress_bar' id='recording_progress_".$row['recording_uuid']."'></span></td></tr>\n";
if (permission_exists('recording_play')) {
echo "<tr id='recording_progress_bar_".$row['recording_uuid']."' style='display: none;'><td colspan='".$colspan."'><span class='playback_progress_bar' id='recording_progress_".$row['recording_uuid']."'></span></td></tr>\n";
}
$tr_link = (permission_exists('recording_edit')) ? "href='recording_edit.php?id=".$row['recording_uuid']."'" : null;
echo "<tr ".$tr_link.">\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
echo $row['recording_name'];
echo "</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>";
echo " \n";
echo $row['recording_filename'];
echo " </a>";
echo " </td>\n";
if (strlen($row['recording_filename']) > 0) {
echo " <td valign='top' class='".$row_style["2"]." ".((!$c) ? "row_style_hor_mir_grad" : null)." tr_link_void'>";
$recording_file_path = $row['recording_filename'];
$recording_file_name = strtolower(pathinfo($recording_file_path, PATHINFO_BASENAME));
$recording_file_ext = pathinfo($recording_file_name, PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".$row['recording_uuid']."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$row['recording_uuid']."')\" onended=\"recording_reset('".$row['recording_uuid']."');\" src=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&id=".$row['recording_uuid']."\" type='".$recording_type."'></audio>";
echo "<span id='recording_button_".$row['recording_uuid']."' onclick=\"recording_play('".$row['recording_uuid']."')\" title='".$text['label-play']." / ".$text['label-pause']."'>".$v_link_label_play."</span>";
echo "<a href=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&t=bin&id=".$row['recording_uuid']."\" title='".$text['label-download']."'>".$v_link_label_download."</a>";
}
else {
echo " <td valign='top' class='".$row_style[$c]."'>";
echo "&nbsp;";
}
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['recording_name']."</td>\n";
if ($_SESSION['recordings']['storage_type']['text'] != 'base64') {
echo " <td valign='top' class='".$row_style[$c]."'>".$row['recording_filename']."</td>\n";
$tmp_filesize = filesize($_SESSION['switch']['recordings']['dir'].'/'.$row['recording_filename']);
$tmp_filesize = byte_convert($tmp_filesize);
echo " <td class='".$row_style[$c]."' style='text-align: center;'>".$tmp_filesize."</td>\n";
}
if (permission_exists('recording_play') || permission_exists('recording_download')) {
echo " <td valign='top' class='".$row_style["2"]." ".((!$c) ? "row_style_hor_mir_grad" : null)." tr_link_void'>";
if (permission_exists('recording_play')) {
$recording_file_path = $row['recording_filename'];
$recording_file_name = strtolower(pathinfo($recording_file_path, PATHINFO_BASENAME));
$recording_file_ext = pathinfo($recording_file_name, PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".$row['recording_uuid']."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$row['recording_uuid']."')\" onended=\"recording_reset('".$row['recording_uuid']."');\" src=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&id=".$row['recording_uuid']."\" type='".$recording_type."'></audio>";
echo "<span id='recording_button_".$row['recording_uuid']."' onclick=\"recording_play('".$row['recording_uuid']."')\" title='".$text['label-play']." / ".$text['label-pause']."'>".$v_link_label_play."</span>";
}
if (permission_exists('recording_download')) {
echo "<a href=\"".PROJECT_PATH."/app/recordings/recordings.php?a=download&type=rec&t=bin&id=".$row['recording_uuid']."\" title='".$text['label-download']."'>".$v_link_label_download."</a>";
}
echo " </td>\n";
}
echo " <td valign='top' class='row_stylebg' width='30%'>".$row['recording_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>";
if (permission_exists('recording_edit')) {
@@ -334,20 +330,14 @@ require_once "resources/check_auth.php";
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
$c = ($c) ? 0 : 1;
} //end foreach
unset($sql, $result, $row_count);
} //end if results
echo "</table>\n";
echo "<br />\n";
echo "<table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td class='list_control_icons'>";
echo " </td>\n";
echo " </tr>\n";
echo "</table>\n";
echo "<div align='center'>".$paging_controls."</div>\n";
echo "<br><br>\n";
//include the footer

View File

@@ -103,6 +103,10 @@
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "greeting_filename";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";
$z++;
$apps[$x]['db'][$y]['fields'][$z]['name'] = "greeting_description";
$apps[$x]['db'][$y]['fields'][$z]['type'] = "text";
$apps[$x]['db'][$y]['fields'][$z]['description']['en-us'] = "";

View File

@@ -0,0 +1,123 @@
<?php
/*
FusionPBX
Version: MPL 1.1
The contents of this file are subject to the Mozilla Public License Version
1.1 (the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at
http://www.mozilla.org/MPL/
Software distributed under the License is distributed on an "AS IS" basis,
WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
for the specific language governing rights and limitations under the
License.
The Original Code is FusionPBX
The Initial Developer of the Original Code is
Mark J Crane <markjcrane@fusionpbx.com>
Portions created by the Initial Developer are Copyright (C) 2008-2012
the Initial Developer. All Rights Reserved.
Contributor(s):
Mark J Crane <markjcrane@fusionpbx.com>
*/
if ($domains_processed == 1) {
//if greeting filename field empty, copy greeting name field value
$sql = "update v_voicemail_greetings ";
$sql .= "set greeting_filename = greeting_name ";
$sql .= "where greeting_filename is null ";
$sql .= "or greeting_filename = '' ";
$db->exec(check_sql($sql));
unset($sql);
//populate greeting id number if empty
$sql = "select voicemail_greeting_uuid, greeting_filename ";
$sql .= "from v_voicemail_greetings ";
$sql .= "where greeting_id is null ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$voicemail_greeting_uuid = $row['voicemail_greeting_uuid'];
$greeting_id = preg_replace('{\D}', '', $row['greeting_filename']);
$sqlu = "update v_voicemail_greetings ";
$sqlu .= "set greeting_id = ".$greeting_id." ";
$sqlu .= "where voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$db->exec(check_sql($sqlu));
unset($sqlu, $voicemail_greeting_uuid, $greeting_id);
}
unset ($sql, $prep_statement);
//if base64, populate from existing greeting files, then remove
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
//get greetings without base64 in db
$sql = "select voicemail_greeting_uuid, domain_uuid, voicemail_id, greeting_filename ";
$sql .= "from v_voicemail_greetings where greeting_base64 is null or greeting_base64 = '' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) > 0) {
foreach ($result as &$row) {
$voicemail_greeting_uuid = $row['voicemail_greeting_uuid'];
$greeting_domain_uuid = $row['domain_uuid'];
$voicemail_id = $row['voicemail_id'];
$greeting_filename = $row['greeting_filename'];
//set greeting directory
$greeting_directory = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$greeting_domain_uuid]['domain_name'].'/'.$voicemail_id;
//encode greeting file (if exists)
if (file_exists($greeting_directory.'/'.$greeting_filename)) {
$greeting_base64 = base64_encode(file_get_contents($greeting_directory.'/'.$greeting_filename));
//update greeting record with base64
$sql = "update v_voicemail_greetings set ";
$sql .= "greeting_base64 = '".$greeting_base64."' ";
$sql .= "where domain_uuid = '".$greeting_domain_uuid."' ";
$sql .= "and voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
//remove local greeting file
@unlink($greeting_directory.'/'.$greeting_filename);
}
}
}
unset($sql, $prep_statement, $result, $row);
}
//if not base64, decode to local files, remove base64 data from db
else if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') {
//get greetings with base64 in db
$sql = "select voicemail_greeting_uuid, domain_uuid, voicemail_id, greeting_filename, greeting_base64 ";
$sql .= "from v_voicemail_greetings where greeting_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) {
foreach ($result as &$row) {
$voicemail_greeting_uuid = $row['voicemail_greeting_uuid'];
$greeting_domain_uuid = $row['domain_uuid'];
$voicemail_id = $row['voicemail_id'];
$greeting_filename = $row['greeting_filename'];
$greeting_base64 = $row['greeting_base64'];
//set greeting directory
$greeting_directory = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$greeting_domain_uuid]['domain_name'].'/'.$voicemail_id;
//remove local file, if any
if (file_exists($greeting_directory.'/'.$greeting_filename)) {
@unlink($greeting_directory.'/'.$greeting_filename);
}
//decode base64, save to local file
$greeting_decoded = base64_decode($greeting_base64);
file_put_contents($greeting_directory.'/'.$greeting_filename, $greeting_decoded);
$sql = "update v_voicemail_greetings ";
$sql .= "set greeting_base64 = null ";
$sql .= "where domain_uuid = '".$greeting_domain_uuid."' ";
$sql .= "and voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
}
unset($sql, $prep_statement, $result, $row);
}
}
?>

View File

@@ -11,12 +11,24 @@ $text['table-size']['pt-pt'] = "Tamanho";
$text['table-size']['fr-fr'] = "Taille";
$text['table-size']['pt-br'] = "Tamanho";
$text['table-number']['en-us'] = "#";
$text['table-number']['es-cl'] = "Número";
$text['table-number']['pt-pt'] = "Número";
$text['table-number']['fr-fr'] = "Nombre";
$text['table-number']['pt-br'] = "Número";
$text['table-name']['en-us'] = "Name";
$text['table-name']['es-cl'] = "Nombre";
$text['table-name']['pt-pt'] = "Nome";
$text['table-name']['fr-fr'] = "Nom";
$text['table-name']['pt-br'] = "Nome";
$text['table-filename']['en-us'] = "File Name";
$text['table-filename']['es-cl'] = "Nombre Del Archivo";
$text['table-filename']['pt-pt'] = "Nome Do Arquivo";
$text['table-filename']['fr-fr'] = "Nom de fichier";
$text['table-filename']['pt-br'] = "Nome Do Arquivo";
$text['table-download']['en-us'] = "Download";
$text['table-download']['es-cl'] = "Descargar";
$text['table-download']['pt-pt'] = "Descarregar";
@@ -47,6 +59,12 @@ $text['message-update']['pt-pt'] = "Actualização Efectuada";
$text['message-update']['fr-fr'] = "Mis à jour";
$text['message-update']['pt-br'] = "Atualização Efetuada";
$text['message-greeting_selected']['en-us'] = "Greeting Selected";
$text['message-greeting_selected']['es-cl'] = "Saludo Seleccionado";
$text['message-greeting_selected']['pt-pt'] = "Saudação Selecionada";
$text['message-greeting_selected']['fr-fr'] = "Message d'accueil Sélectionné";
$text['message-greeting_selected']['pt-br'] = "Saudação Selecionada";
$text['message-delete']['en-us'] = "Delete Complete";
$text['message-delete']['es-cl'] = "Eliminación Completada";
$text['message-delete']['pt-pt'] = "Remoção Efectuada";
@@ -83,6 +101,18 @@ $text['label-name']['pt-pt'] = "Nome da Saudação";
$text['label-name']['fr-fr'] = "Nom de salutation";
$text['label-name']['pt-br'] = "Nome";
$text['label-greeting']['en-us'] = "Greeting";
$text['label-greeting']['es-cl'] = "Saludo";
$text['label-greeting']['pt-pt'] = "Saudação";
$text['label-greeting']['fr-fr'] = "Salutation";
$text['label-greeting']['pt-br'] = "Saudação";
$text['label-filename']['en-us'] = "File Name";
$text['label-filename']['es-cl'] = "Nombre Del Archivo";
$text['label-filename']['pt-pt'] = "Nome Do Arquivo";
$text['label-filename']['fr-fr'] = "Nom de fichier";
$text['label-filename']['pt-br'] = "Nome Do Arquivo";
$text['label-edit']['en-us'] = "Edit Greeting";
$text['label-edit']['es-cl'] = "Edición de Saludo";
$text['label-edit']['pt-pt'] = "Editar Saudação";
@@ -107,10 +137,10 @@ $text['label-add']['pt-pt'] = "Adicionar Saudação";
$text['label-add']['fr-fr'] = "Ajouter salutation";
$text['label-add']['pt-br'] = "Adicionar Greeting";
$text['description-name']['en-us'] = "Greeting Name. example: greeting_x";
$text['description-name']['es-cl'] = "Nombre de Bienvenida. Ejemplo: bienvenida_x";
$text['description-name']['pt-pt'] = "Nome da Saudação. exemplo: saudação_x";
$text['description-name']['fr-fr'] = "Nome da Salutation. exemple: accueil_x";
$text['description-name']['en-us'] = "A name for the greeting (not parsed).";
$text['description-name']['es-cl'] = "Nombre de Bienvenida.";
$text['description-name']['pt-pt'] = "Nome da Saudação.";
$text['description-name']['fr-fr'] = "Nome da Salutation (non parsé).";
$text['description-name']['pt-br'] = "Insira o nome do menu";
$text['description-info']['en-us'] = "You may enter a description here for your reference (not parsed).";
@@ -125,12 +155,18 @@ $text['description']['pt-pt'] = "Escolha e active uma mensagem de saudação a a
$text['description']['fr-fr'] = "Choisir le message de salutation à jouer pour l'extension:";
$text['description']['pt-br'] = "Editar informações da conta.";
$text['confirm-name']['en-us'] = "Please provide: Greeting Name (play)";
$text['confirm-name']['es-cl'] = "Por favor indique: Nombre de Bienvenida (reproducir)";
$text['confirm-name']['pt-pt'] = "Por favor indique: Nome da saudação (tocar)";
$text['confirm-name']['fr-fr'] = "Merci d'indiquer: Nom de salutation (jouer)";
$text['confirm-name']['en-us'] = "Please provide: Greeting Name";
$text['confirm-name']['es-cl'] = "Por favor indique: Nombre de Bienvenida";
$text['confirm-name']['pt-pt'] = "Por favor indique: Nome da saudação";
$text['confirm-name']['fr-fr'] = "Merci d'indiquer: Nom de salutation";
$text['confirm-name']['pt-br'] = "Por favor indique: Nome";
$text['confirm-filename']['en-us'] = "Please provide: Greeting Filename";
$text['confirm-filename']['es-cl'] = "Por favor indique: Nombre Del Archivo";
$text['confirm-filename']['pt-pt'] = "Por favor indique: Nome Do Arquivo";
$text['confirm-filename']['fr-fr'] = "Merci d'indiquer: Nom De Fichier";
$text['confirm-filename']['pt-br'] = "Por favor indique: Nome Do Arquivo";
$text['button-upload']['en-us'] = "Upload";
$text['button-upload']['es-cl'] = "Subir";
$text['button-upload']['pt-pt'] = "Carregar";

View File

@@ -38,31 +38,31 @@ else {
$language = new text;
$text = $language->get();
if (count($_GET)>0) {
$id = check_str($_GET["id"]);
if (count($_GET) > 0) {
$voicemail_greeting_uuid = check_str($_GET["id"]);
$voicemail_id = check_str($_GET["voicemail_id"]);
}
if (strlen($id)>0) {
if (strlen($voicemail_greeting_uuid) > 0) {
//get the greeting filename
$sql = "select * from v_voicemail_greetings ";
$sql .= "where voicemail_greeting_uuid = '$id' ";
$sql .= "and domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
$sql = "select greeting_filename from v_voicemail_greetings ";
$sql .= "where voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$sql .= "and domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_id = '".$voicemail_id."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$greeting_name = $row["greeting_name"];
$greeting_filename = $row["greeting_filename"];
break; //limit to 1 row
}
unset ($prep_statement);
//delete recording from the database
$sql = "delete from v_voicemail_greetings ";
$sql .= "where voicemail_greeting_uuid = '$id' ";
$sql .= "and domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
$sql .= "where voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$sql .= "and domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_id = '".$voicemail_id."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($sql);
@@ -71,7 +71,9 @@ if (strlen($id)>0) {
$v_greeting_dir = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id;
//delete the recording file
unlink($v_greeting_dir."/".$greeting_name);
if (file_exists($v_greeting_dir."/".$greeting_filename)) {
@unlink($v_greeting_dir."/".$greeting_filename);
}
}
//redirect the user

View File

@@ -26,7 +26,7 @@
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('voicemail_greeting_add') || permission_exists('voicemail_greeting_edit')) {
if (permission_exists('voicemail_greeting_edit')) {
//access granted
}
else {
@@ -38,14 +38,10 @@ else {
$language = new text;
$text = $language->get();
//set the action as an add or an update
//get greeting id
if (isset($_REQUEST["id"])) {
$action = "update";
$voicemail_greeting_uuid = check_str($_REQUEST["id"]);
}
else {
$action = "add";
}
//get the form value and set to php variables
$voicemail_id = check_str($_REQUEST["voicemail_id"]);
@@ -53,22 +49,17 @@ else {
$greeting_name = check_str($_POST["greeting_name"]);
$greeting_description = check_str($_POST["greeting_description"]);
//clean the filename and recording name
$greeting_name = str_replace(" ", "_", $greeting_name);
//clean the name
$greeting_name = str_replace("'", "", $greeting_name);
}
if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$msg = '';
if ($action == "update") {
if (count($_POST) > 0 && strlen($_POST["persistformvar"]) == 0) {
//get greeting uuid to edit
$voicemail_greeting_uuid = check_str($_POST["voicemail_greeting_uuid"]);
}
//check for all required data
//if (strlen($domain_uuid) == 0) { $msg .= "Please provide: domain_uuid<br>\n"; }
$msg = '';
if (strlen($greeting_name) == 0) { $msg .= "".$text['confirm-name']."<br>\n"; }
//if (strlen($greeting_description) == 0) { $msg .= "Please provide: Description<br>\n"; }
if (strlen($msg) > 0 && strlen($_POST["persistformvar"]) == 0) {
require_once "resources/header.php";
require_once "resources/persist_form_var.php";
@@ -82,59 +73,15 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
return;
}
//add or update the database
//update the database
if ($_POST["persistformvar"] != "true") {
if ($action == "add" && permission_exists('voicemail_greeting_add')) {
$voicemail_greeting_uuid = uuid();
$sql = "insert into v_voicemail_greetings ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "voicemail_greeting_uuid, ";
$sql .= "greeting_name, ";
$sql .= "greeting_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$voicemail_greeting_uuid', ";
$sql .= "'$greeting_name', ";
$sql .= "'$greeting_description' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
$_SESSION["message"] = $text['message-add'];
header("Location: voicemail_greetings.php?id=".$voicemail_id);
return;
} //if ($action == "add")
if ($action == "update" && permission_exists('voicemail_greeting_edit')) {
//get the original filename
$sql = "select * from v_voicemail_greetings ";
$sql .= "where voicemail_greeting_uuid = '$voicemail_greeting_uuid' ";
$sql .= "and voicemail_greeting_uuid = '$domain_uuid' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
foreach ($result as &$row) {
$greeting_name_orig = $row["greeting_name"];
break; //limit to 1 row
}
unset ($prep_statement);
//if file name is not the same then rename the file
if ($greeting_name != $greeting_name_orig) {
//echo "orig: ".$voicemail_greetings_dir.'/'.$filename_orig."<br />\n";
//echo "new: ".$voicemail_greetings_dir.'/'.$greeting_name."<br />\n";
rename($voicemail_greetings_dir.'/'.$greeting_name_orig, $voicemail_greetings_dir.'/'.$greeting_name);
}
if (permission_exists('voicemail_greeting_edit')) {
//update the database with the new data
$sql = "update v_voicemail_greetings set ";
$sql .= "greeting_name = '$greeting_name', ";
$sql .= "greeting_description = '$greeting_description' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_greeting_uuid = '$voicemail_greeting_uuid' ";
$sql .= "greeting_name = '".$greeting_name."', ";
$sql .= "greeting_description = '".$greeting_description."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
@@ -142,7 +89,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
$_SESSION["message"] = $text['message-update'];
header("Location: voicemail_greetings.php?id=".$voicemail_id);
return;
} //if ($action == "update")
} //if (permission_exists('voicemail_greeting_edit')) {
} //if ($_POST["persistformvar"] != "true")
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
@@ -150,8 +97,8 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
if (count($_GET) > 0 && $_POST["persistformvar"] != "true") {
$voicemail_greeting_uuid = check_str($_GET["id"]);
$sql = "select * from v_voicemail_greetings ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_greeting_uuid = '$voicemail_greeting_uuid' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
@@ -164,30 +111,30 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
}
//show the header
$document['title'] = $text['label-edit'];
require_once "resources/header.php";
//show the content
echo "<form method='post' name='frm' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<table cellpadding='0' cellspacing='0' border='0' align='right'>\n";
echo "<tr>\n";
if ($action == "add") {
echo "<td align='left' width='30%' nowrap><b>".$text['label-add']."</b></td>\n";
}
if ($action == "update") {
echo "<td align='left' width='30%' nowrap><b>".$text['label-edit']."</b></td>\n";
}
echo "<td width='70%' align='right'>\n";
echo "<td nowrap='nowrap'>\n";
echo " <input type='button' class='btn' name='' alt='".$text['button-back']."' onclick=\"window.location='voicemail_greetings.php?id=".$voicemail_id."'\" value='".$text['button-back']."'>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo "</td>\n";
echo "</tr>\n";
echo "</table>\n";
echo "<b>".$text['label-edit']."</b>\n";
echo "<br><br>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<td class='vncellreq' valign='top' align='left' nowrap>\n";
echo "<td width='30%' class='vncellreq' valign='top' align='left' nowrap>\n";
echo " ".$text['label-name']."\n";
echo "</td>\n";
echo "<td class='vtable' align='left'>\n";
echo "<td width='70%' class='vtable' align='left'>\n";
echo " <input class='formfld' type='text' name='greeting_name' maxlength='255' value=\"$greeting_name\">\n";
echo "<br />\n";
echo "".$text['description-name']."\n";
@@ -206,16 +153,15 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
echo "</tr>\n";
echo " <tr>\n";
echo " <td colspan='2' align='right'>\n";
if ($action == "update") {
echo " <input type='hidden' name='voicemail_greeting_uuid' value='$voicemail_greeting_uuid'>\n";
}
echo " <input type='hidden' name='voicemail_id' value='$voicemail_id'>\n";
echo " <input type='hidden' name='voicemail_greeting_uuid' value='".$voicemail_greeting_uuid."'>\n";
echo " <input type='hidden' name='voicemail_id' value='".$voicemail_id."'>\n";
echo " <br>";
echo " <input type='submit' name='submit' class='btn' value='".$text['button-save']."'>\n";
echo " </td>\n";
echo " </tr>";
echo "</table>";
echo "<br><br>";
echo "</form>";
//include the footer

View File

@@ -26,21 +26,11 @@
include "root.php";
require_once "resources/require.php";
require_once "resources/check_auth.php";
if (permission_exists('voicemail_greeting_view')) {
//access granted
}
else {
echo "access denied";
exit;
}
//add multi-lingual support
$language = new text;
$text = $language->get();
//additional includes
require_once "resources/paging.php";
//set the max php execution time
ini_set(max_execution_time,7200);
@@ -49,7 +39,21 @@ else {
$order_by = check_str($_GET["order_by"]);
$order = check_str($_GET["order"]);
//used to search the array to determin if an extension is assigned to the user
//define order by default
if ($order_by == '') {
$order_by = "greeting_name";
$order = "asc";
}
//deny access if the user extension is not assigned
if (!(if_group("superadmin") || if_group("admin"))) {
if (!is_extension_assigned($voicemail_id)) {
echo "access denied";
return;
}
}
//used (above) to search the array to determine if an extension is assigned to the user
function is_extension_assigned($number) {
$result = false;
foreach ($_SESSION['user']['extension'] as $row) {
@@ -60,48 +64,131 @@ else {
return $result;
}
//allow admins, superadmins and users that are assigned to the extension to view the page
if (if_group("superadmin") || if_group("admin")) {
//get currently selected greeting
$sql = "select greeting_id from v_voicemails ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_id = '".$voicemail_id."' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$selected_greeting_id = $row['greeting_id'];
}
unset($prep_statement, $row);
//define greeting directory
$v_greeting_dir = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id;
//download the greeting
if ($_GET['a'] == "download" && (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download'))) {
session_cache_limiter('public');
if ($_GET['type'] = "rec") {
$voicemail_greeting_uuid = check_str($_GET['uuid']);
//get voicemail greeting details from db
$sql = "select greeting_filename, greeting_base64, greeting_id from v_voicemail_greetings ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_greeting_uuid = '".$voicemail_greeting_uuid."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_ASSOC);
if (count($result) > 0) {
foreach($result as &$row) {
$greeting_filename = $row['greeting_filename'];
$greeting_id = $row['greeting_id'];
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
$greeting_decoded = base64_decode($row['greeting_base64']);
file_put_contents($v_greeting_dir.'/'.$greeting_filename, $greeting_decoded);
}
break;
}
}
unset ($sql, $prep_statement, $result, $greeting_decoded);
if (file_exists($v_greeting_dir.'/'.$greeting_filename)) {
$fd = fopen($v_greeting_dir.'/'.$greeting_filename, "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($greeting_filename, -3);
if ($file_ext == "wav") {
header("Content-Type: audio/x-wav");
}
if ($file_ext == "mp3") {
header("Content-Type: audio/mpeg");
}
}
header('Content-Disposition: attachment; filename="'.$greeting_filename.'"');
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($v_greeting_dir.'/'.$greeting_filename));
ob_clean();
fpassthru($fd);
}
//if base64, remove temp greeting file (if not currently selected greeting)
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64' && $row['greeting_base64'] != '') {
if ($greeting_id != $selected_greeting_id) {
@unlink($v_greeting_dir.'/'.$greeting_filename);
}
}
}
exit;
}
//upload the greeting
if (permission_exists('voicemail_greeting_upload')) {
if ($_POST['submit'] == $text['button-upload'] && $_POST['type'] == 'rec' && is_uploaded_file($_FILES['file']['tmp_name'])) {
//find the next available
for ($i = 1; $i < 10; $i++) {
$file_name = 'greeting_'.$i.'.wav';
//check the database
$sql = "select voicemail_greeting_uuid from v_voicemail_greetings ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_id = '".$voicemail_id."' ";
$sql .= "and greeting_filename = '".$file_name."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
if (count($result) == 0 && !file_exists($v_greeting_dir.'/'.$file_name)) {
//move the uploaded greeting
mkdir($v_greeting_dir, 0777, true);
move_uploaded_file($_FILES['file']['tmp_name'], $v_greeting_dir.'/'.$file_name);
//set newly uploaded greeting as active greeting for voicemail box
$sql = "update v_voicemails ";
$sql .= "set greeting_id = '".$i."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_id = '".$voicemail_id."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement);
$_SESSION["message"] = $text['message-uploaded'].": ".$_FILES['file']['name'];
break;
}
else {
continue;
}
unset ($prep_statement);
}
//set the file name to be inserted as the greeting description
$greeting_description = base64_encode($_FILES['file']['name']);
header("Location: voicemail_greetings.php?id=".$voicemail_id."&order_by=".$order_by."&order=".$order."&gd=".$greeting_description);
exit;
}
}
//check the permission
if (permission_exists('voicemail_greeting_view')) {
//access granted
}
else {
//deny access if the user extension is not assigned
if (!is_extension_assigned($voicemail_id)) {
echo "access denied";
return;
}
}
//set the greeting directory
$v_greeting_dir = $_SESSION['switch']['storage']['dir'].'/voicemail/default/'.$_SESSION['domains'][$domain_uuid]['domain_name'].'/'.$voicemail_id;
//upload the recording
if (($_POST['submit'] == $text['button-upload']) && is_uploaded_file($_FILES['file']['tmp_name']) && permission_exists('voicemail_greeting_upload')) {
if ($_POST['type'] == 'rec') {
//find the next available
for($i = 1; $i < 10; $i++){
$file_name = 'greeting_'.$i.'.wav';
if (!file_exists($v_greeting_dir.'/'.$file_name)) {
$greeting_id = $i;
$_REQUEST['greeting'] = $file_name;
break;
}
}
//move the uploaded greeting
if ($_REQUEST['greeting']) {
mkdir($v_greeting_dir, 0777, true);
move_uploaded_file($_FILES['file']['tmp_name'], $v_greeting_dir.'/'.$_REQUEST['greeting']);
$_SESSION["message"] = $text['message-uploaded'].": ".$_REQUEST['greeting'];
}
//set the greeting_id
$sql = "update v_voicemails ";
$sql .= "set greeting_id = '$greeting_id' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement);
}
echo "access denied";
exit;
}
//set the greeting
@@ -111,112 +198,116 @@ else {
//set the greeting_id
$sql = "update v_voicemails ";
$sql .= "set greeting_id = '$greeting_id' ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
$sql .= "set greeting_id = '".$greeting_id."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_id = '".$voicemail_id."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
unset($prep_statement);
}
//download the voicemail greeting
if ($_GET['a'] == "download") { // && permission_exists('voicemail_greeting_download')) {
session_cache_limiter('public');
if ($_GET['type'] = "rec") {
if (file_exists($v_greeting_dir.'/'.base64_decode($_GET['filename']))) {
$fd = fopen($v_greeting_dir.'/'.base64_decode($_GET['filename']), "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");
header('Content-Disposition: attachment; filename="'.base64_decode($_GET['filename']).'"');
}
else {
$file_ext = substr(base64_decode($_GET['filename']), -3);
if ($file_ext == "wav") {
header("Content-Type: audio/x-wav");
}
if ($file_ext == "mp3") {
header("Content-Type: audio/mp3");
}
}
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($v_greeting_dir.'/'.base64_decode($_GET['filename'])));
fpassthru($fd);
}
}
$_SESSION["message"] = $text['message-greeting_selected'];
header("Location: voicemail_greetings.php?id=".$voicemail_id."&order_by=".$order_by."&order=".$order);
exit;
}
//build a list of voicemail greetings
$config_voicemail_greeting_list = '|';
$i = 0;
$sql = "select * from v_voicemail_greetings ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
//get existing greetings
$sql = "select voicemail_greeting_uuid, greeting_filename, greeting_base64 from v_voicemail_greetings ";
$sql .= "where domain_uuid = '".$domain_uuid."' and voicemail_id = '".$voicemail_id."' ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
$config_greeting_list = "|";
foreach ($result as &$row) {
$config_greeting_list .= $row['greeting_name']."|";
$array_greetings[$row['voicemail_greeting_uuid']] = $row['greeting_filename'];
$array_base64_exists[$row['voicemail_greeting_uuid']] = ($row['greeting_base64'] != '') ? true : false;
//if not base64, convert back to local files and remove base64 from db
if ($_SESSION['voicemail']['storage_type']['text'] != 'base64' && $row['greeting_base64'] != '') {
if (file_exists($v_greeting_dir.'/'.$row['greeting_filename'])) {
@unlink($v_greeting_dir.'/'.$row['greeting_filename']);
}
$greeting_decoded = base64_decode($row['greeting_base64']);
file_put_contents($v_greeting_dir.'/'.$row['greeting_filename'], $greeting_decoded);
$sql = "update v_voicemail_greetings ";
$sql .= "set greeting_base64 = null ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_greeting_uuid = '".$row['voicemail_greeting_uuid']."' ";
$db->exec(check_sql($sql));
unset($sql);
}
}
unset ($prep_statement);
//add recordings to the database
//add greetings to the database
if (is_dir($v_greeting_dir.'/')) {
if ($dh = opendir($v_greeting_dir.'/')) {
while (($file = readdir($dh)) !== false) {
if (filetype($v_greeting_dir."/".$file) == "file") {
if (strpos($config_greeting_list, "|".$file) === false) {
if (substr($file, 0, 8) == "greeting") {
//file not found add it to the database
$a_file = explode("\.", $file);
$voicemail_greeting_uuid = uuid();
$sql = "insert into v_voicemail_greetings ";
$sql .= "(";
$sql .= "domain_uuid, ";
$sql .= "voicemail_greeting_uuid, ";
$sql .= "voicemail_id, ";
$sql .= "greeting_name, ";
$sql .= "greeting_description ";
$sql .= ")";
$sql .= "values ";
$sql .= "(";
$sql .= "'$domain_uuid', ";
$sql .= "'$voicemail_greeting_uuid', ";
$sql .= "'$voicemail_id', ";
$sql .= "'".$a_file[0]."', ";
$sql .= "'' ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
if (filetype($v_greeting_dir."/".$file) == "file" && substr($file, 0, 8) == "greeting" && substr($file, 10, 4) != ".tmp") {
$greeting_number = preg_replace('{\D}', '', $file);
if (!in_array($file, $array_greetings)) {
//file not found, add to database
$greeting_name = $text['label-greeting'].' '.$greeting_number;
$greeting_description = base64_decode($_GET['gd']);
$voicemail_greeting_uuid = uuid();
$sql = "insert into v_voicemail_greetings ";
$sql .= "( ";
$sql .= "voicemail_greeting_uuid, ";
$sql .= "domain_uuid, ";
$sql .= "voicemail_id, ";
$sql .= "greeting_name, ";
$sql .= "greeting_filename, ";
$sql .= "greeting_description, ";
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
$sql .= "greeting_base64, ";
}
$sql .= "greeting_id ";
$sql .= ") ";
$sql .= "values ";
$sql .= "(";
$sql .= "'".$voicemail_greeting_uuid."', ";
$sql .= "'".$domain_uuid."', ";
$sql .= "'".$voicemail_id."', ";
$sql .= "'".$greeting_name."', ";
$sql .= "'".$file."', ";
$sql .= "'".$greeting_description."', ";
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
$greeting_base64 = base64_encode(file_get_contents($v_greeting_dir.'/'.$file));
$sql .= "'".$greeting_base64."', ";
}
$sql .= $greeting_number." ";
$sql .= ")";
$db->exec(check_sql($sql));
unset($sql);
}
else {
//echo "The $file was found.<br/>";
//file found, check if base64 present
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') {
$found_greeting_uuid = array_search($file, $array_greetings);
if (!$array_base64_exists[$found_greeting_uuid]) {
$greeting_base64 = base64_encode(file_get_contents($v_greeting_dir.'/'.$file));
$sql = "update v_voicemail_greetings set ";
$sql .= "greeting_base64 = '".$greeting_base64."' ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_greeting_uuid = '".$found_greeting_uuid."' ";
$db->exec(check_sql($sql));
unset($sql);
}
}
}
//if base64, remove local file (unless currently selected greeting)
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64' && file_exists($v_greeting_dir.'/'.$file)) {
if ($greeting_number != $selected_greeting_id) {
@unlink($v_greeting_dir.'/'.$file);
}
}
}
}
} //while
closedir($dh);
}
}
} //if
} //if
//get the number of rows in v_extensions
$sql = "select greeting_id from v_voicemails ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
$prep_statement = $db->prepare(check_sql($sql));
if ($prep_statement) {
$prep_statement->execute();
$row = $prep_statement->fetch(PDO::FETCH_ASSOC);
$greeting_id = $row['greeting_id'];
}
unset($prep_statement, $result);
//include the header
$document['title'] = $text['title'];
require_once "resources/header.php";
//begin the content
@@ -227,60 +318,31 @@ else {
echo "}\n";
echo "</script>";
echo "<form action=\"\" method=\"POST\" enctype=\"multipart/form-data\" name=\"frm\" onSubmit=\"\">\n";
echo "<table width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">\n";
echo "<form name='frm' method='POST' enctype='multipart/form-data' action=''>\n";
echo "<table width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td align='left' nowrap valign='top'>\n";
echo " <span class='title'>".$text['title']."</span>\n";
echo " <br><br>\n";
echo " ".$text['description']." <strong>".$voicemail_id."</strong>\n";
echo " </td>";
if (permission_exists('voicemail_greeting_upload')) {
echo " <td align='right' nowrap valign='top'>\n";
echo " <div valign='middle'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='".PROJECT_PATH."/app/voicemails/voicemails.php';\" value='".$text['button-back']."'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
echo " <input name=\"file\" type=\"file\" class=\"formfld fileinput\" id=\"file\">\n";
echo " <input name=\"type\" type=\"hidden\" value=\"rec\">\n";
echo " <input name=\"submit\" type=\"submit\" class=\"btn\" id=\"upload\" value=\"".$text['button-upload']."\">\n";
echo " </td>\n";
echo " <td align='right' nowrap valign='top'>\n";
echo " <input type='button' class='btn' name='' alt='back' onclick=\"window.location='".PROJECT_PATH."/app/voicemails/voicemails.php';\" value='".$text['button-back']."'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;\n";
echo " <input name='file' type='file' class='formfld fileinput' id='file'>\n";
echo " <input name='type' type='hidden' value='rec'>\n";
echo " <input name='submit' type='submit' class='btn' id='upload' value=\"".$text['button-upload']."\">\n";
echo " </td>\n";
}
echo " </tr>";
echo "</table>\n";
echo "<br />\n";
//get the number of rows in v_voicemail_greetings
$sql = "select count(*) as num_rows from v_voicemail_greetings ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
$prep_statement = $db->prepare(check_sql($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';
}
}
unset($prep_statement, $result);
//prepare to page the results
$rows_per_page = 100;
$param = "";
$page = $_GET['page'];
if (strlen($page) == 0) { $page = 0; $_GET['page'] = 0; }
list($paging_controls, $rows_per_page, $var_3) = paging($num_rows, $param, $rows_per_page);
$offset = $rows_per_page * $page;
//get the greetings list
$sql = "select * from v_voicemail_greetings ";
$sql .= "where domain_uuid = '$domain_uuid' ";
$sql .= "and voicemail_id = '$voicemail_id' ";
if (strlen($order_by)> 0) { $sql .= "order by $order_by $order "; }
$sql .= " limit $rows_per_page offset $offset ";
$sql .= "where domain_uuid = '".$domain_uuid."' ";
$sql .= "and voicemail_id = '".$voicemail_id."' ";
$sql .= "order by ".$order_by." ".$order." ";
$prep_statement = $db->prepare(check_sql($sql));
$prep_statement->execute();
$result = $prep_statement->fetchAll(PDO::FETCH_NAMED);
@@ -294,62 +356,66 @@ else {
echo "<table class='tr_hover' width='100%' border='0' cellpadding='0' cellspacing='0'>\n";
echo "<tr>\n";
echo "<th>".$text['table-choose']."</th>\n";
echo th_order_by('greeting_name', $text['table-name'], $order_by, $order);
if (permission_exists('voicemail_greeting_download')) {
echo "<th width='2'>&nbsp;</th>\n";
echo th_order_by('greeting_id', $text['table-number'], $order_by, $order, '', "width='20'", "id=".$voicemail_id);
echo th_order_by('greeting_name', $text['table-name'], $order_by, $order, '', '', "id=".$voicemail_id);
if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') {
echo th_order_by('greeting_filename', $text['table-filename'], $order_by, $order, '', '', "id=".$voicemail_id);
echo "<th class='listhdr' style='text-align: right;' nowrap='nowrap'>".$text['table-size']."</th>\n";
}
if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) {
echo "<th>".$text['label-tools']."</th>\n";
}
echo "<th class=\"listhdr\" style='text-align: right;' nowrap=\"nowrap\">".$text['table-size']."</th>\n";
echo th_order_by('greeting_description', $text['table-description'], $order_by, $order);
echo th_order_by('greeting_description', $text['table-description'], $order_by, $order, '', '', "id=".$voicemail_id);
echo "<td align='right' width='21'>\n";
//if (permission_exists('voicemail_greeting_add')) {
// echo " <a href='voicemail_greeting_edit.php?&voicemail_id=".$voicemail_id."' alt='add'>$v_link_label_add</a>\n";
//}
echo "</td>\n";
echo "</tr>\n";
//calculate colspan for progress bar
$colspan = 7; //max
if ($_SESSION['voicemail']['storage_type']['text'] == 'base64') { $colspan = $colspan - 2; }
if (!(permission_exists('voicemail_greeting_edit') || permission_exists('voicemail_greeting_delete'))) { $colspan = $colspan - 1; }
if ($result_count > 0) {
foreach($result as $row) {
$tmp_filesize = filesize($v_greeting_dir.'/'.$row['greeting_name']);
$tmp_filesize = byte_convert($tmp_filesize);
//playback progress bar
echo "<tr id='recording_progress_bar_".$row['voicemail_greeting_uuid']."' style='display: none;'><td colspan='5'><span class='playback_progress_bar' id='recording_progress_".$row['voicemail_greeting_uuid']."'></span></td></tr>\n";
if (permission_exists('voicemail_greeting_play')) {
echo "<tr id='recording_progress_bar_".$row['voicemail_greeting_uuid']."' style='display: none;'><td colspan='".$colspan."'><span class='playback_progress_bar' id='recording_progress_".$row['voicemail_greeting_uuid']."'></span></td></tr>\n";
}
$tr_link = (permission_exists('voicemail_greeting_edit')) ? "href='voicemail_greeting_edit.php?id=".$row['voicemail_greeting_uuid']."&voicemail_id=".$voicemail_id."'" : null;
echo "<tr ".$tr_link.">\n";
echo " <td class='".$row_style[$c]." tr_link_void' width='30px;' valign='top'>\n";
if (preg_replace('{\D}', '', $row['greeting_name']) == $greeting_id) {
echo " <input type=\"radio\" onclick=\"window.location='".PROJECT_PATH."/app/voicemail_greetings/voicemail_greetings.php?id=$voicemail_id&greeting_id=".preg_replace('{\D}', '', $row['greeting_name'])."&action=set';\" name=\"greeting_id\" value=\"".preg_replace('{\D}', '', $row['greeting_name'])."\" checked=\"checked\">\n";
}
else {
echo " <input type=\"radio\" onclick=\"window.location='".PROJECT_PATH."/app/voicemail_greetings/voicemail_greetings.php?id=$voicemail_id&greeting_id=".preg_replace('{\D}', '', $row['greeting_name'])."&action=set';\" name=\"greeting_id\" value=\"".preg_replace('{\D}', '', $row['greeting_name'])."\" >\n";
}
echo " <td class='".$row_style[$c]." tr_link_void' width='30px;' valign='top'>";
$selected = ($row['greeting_id'] == $selected_greeting_id) ? true : false;
echo "<input type='radio' onclick=\"window.location='".PROJECT_PATH."/app/voicemail_greetings/voicemail_greetings.php?id=".$voicemail_id."&greeting_id=".$row['greeting_id']."&action=set&order_by=".$order_by."&order=".$order."';\" name='greeting_id' value='".$row['greeting_id']."' ".(($selected) ? "checked='checked'" : null).">\n";
echo " </td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['greeting_id']."</td>\n";
echo " <td valign='top' class='".$row_style[$c]."'>".$row['greeting_name']."</td>\n";
if (permission_exists('voicemail_greeting_download')) {
if (strlen($row['greeting_name']) > 0) {
echo " <td valign='top' class='".$row_style["2"]." ".((!$c) ? "row_style_hor_mir_grad" : null)." tr_link_void'>";
$recording_file_path = $row['greeting_name'];
$recording_file_name = strtolower(pathinfo($recording_file_path, PATHINFO_BASENAME));
$recording_file_ext = pathinfo($recording_file_name, PATHINFO_EXTENSION);
switch ($recording_file_ext) {
case "wav" : $recording_type = "audio/wav"; break;
case "mp3" : $recording_type = "audio/mpeg"; break;
case "ogg" : $recording_type = "audio/ogg"; break;
if ($_SESSION['voicemail']['storage_type']['text'] != 'base64') {
echo " <td valign='top' class='".$row_style[$c]."'>".$row['greeting_filename']."</td>\n";
$tmp_filesize = filesize($v_greeting_dir.'/'.$row['greeting_filename']);
$tmp_filesize = byte_convert($tmp_filesize);
echo " <td class='".$row_style[$c]."' style='text-align: right;' nowrap>".$tmp_filesize."</td>\n";
}
if (permission_exists('voicemail_greeting_play') || permission_exists('voicemail_greeting_download')) {
echo " <td valign='top' class='".$row_style["2"]." ".((!$c) ? "row_style_hor_mir_grad" : null)." tr_link_void'>";
if (permission_exists('voicemail_greeting_play')) {
$greeting_file_path = $row['greeting_filename'];
$greeting_file_name = strtolower(pathinfo($greeting_file_path, PATHINFO_BASENAME));
$greeting_file_ext = pathinfo($greeting_file_name, PATHINFO_EXTENSION);
switch ($greeting_file_ext) {
case "wav" : $greeting_type = "audio/wav"; break;
case "mp3" : $greeting_type = "audio/mpeg"; break;
case "ogg" : $greeting_type = "audio/ogg"; break;
}
echo "<audio id='recording_audio_".$row['voicemail_greeting_uuid']."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$row['voicemail_greeting_uuid']."')\" onended=\"recording_reset('".$row['voicemail_greeting_uuid']."');\" src=\"voicemail_greetings.php?id=".$voicemail_id."&a=download&type=rec&filename=".base64_encode($recording_file_path)."\" type='".$recording_type."'></audio>";
echo "<audio id='recording_audio_".$row['voicemail_greeting_uuid']."' style='display: none;' preload='none' ontimeupdate=\"update_progress('".$row['voicemail_greeting_uuid']."')\" onended=\"recording_reset('".$row['voicemail_greeting_uuid']."');\" src=\"voicemail_greetings.php?id=".$voicemail_id."&a=download&type=rec&uuid=".$row['voicemail_greeting_uuid']."\" type='".$greeting_type."'></audio>";
echo "<span id='recording_button_".$row['voicemail_greeting_uuid']."' onclick=\"recording_play('".$row['voicemail_greeting_uuid']."')\" title='".$text['label-play']." / ".$text['label-pause']."'>".$v_link_label_play."</span>";
echo "<a href=\"voicemail_greetings.php?id=".$voicemail_id."&a=download&type=rec&t=bin&filename=".base64_encode($recording_file_path)."\" title='".$text['label-download']."'>".$v_link_label_download."</a>";
}
else {
echo " <td valign='top' class='".$row_style[$c]."'>";
echo "&nbsp;";
if (permission_exists('voicemail_greeting_download')) {
echo "<a href=\"voicemail_greetings.php?a=download&type=rec&t=bin&id=".$voicemail_id."&uuid=".$row['voicemail_greeting_uuid']."\" title='".$text['label-download']."'>".$v_link_label_download."</a>";
}
echo " </td>\n";
}
echo " <td class='".$row_style[$c]."' style='text-align: right;' nowrap>".$tmp_filesize."</td>\n";
echo " <td valign='top' class='row_stylebg'>".$row['greeting_description']."&nbsp;</td>\n";
echo " <td width='30%' valign='top' class='row_stylebg'>".$row['greeting_description']."&nbsp;</td>\n";
echo " <td class='list_control_icons'>\n";
if (permission_exists('voicemail_greeting_edit')) {
echo "<a href='voicemail_greeting_edit.php?id=".$row['voicemail_greeting_uuid']."&voicemail_id=".$voicemail_id."' alt='edit'>$v_link_label_edit</a>";
@@ -360,25 +426,18 @@ else {
echo " </td>\n";
echo "</tr>\n";
if ($c==0) { $c=1; } else { $c=0; }
$c = ($c) ? 0 : 1;
} //end foreach
unset($sql, $result, $row_count);
} //end if results
echo "</table>\n";
echo " <table width='100%' cellpadding='0' cellspacing='0'>\n";
echo " <tr>\n";
echo " <td width='33.3%' nowrap>&nbsp;</td>\n";
echo " <td width='33.3%' align='center' nowrap>$paging_controls</td>\n";
echo " <td width='33.3%' align='right'>&nbsp;</td>\n";
echo " </tr>\n";
echo " </table>\n";
echo " <br><br>";
echo "<br />\n";
echo "<input type='hidden' name='id' value='$voicemail_id'>\n";
echo "</form>";
echo "<br><br>";
//include the footer
require_once "resources/footer.php";
?>

View File

@@ -87,29 +87,27 @@
--get the greeting from the database
if (storage_type == "base64") then
if (string.len(ivr_menu_greet_long) > 1) then
sql = [[SELECT * FROM v_voicemail_greetings
WHERE domain_uuid = ']] .. domain_uuid ..[['
AND voicemail_id = ']].. voicemail_id.. [['
AND greeting_id = ']].. greeting_id.. [[' ]];
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
end
status = dbh:query(sql, function(row)
--add functions
dofile(scripts_dir.."/resources/functions/base64.lua");
--set the voicemail message path
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
--save the greeting to the file system
if (string.len(row["greeting_base64"]) > 32) then
local file = io.open(greeting_location, "w");
file:write(base64.decode(row["greeting_base64"]));
file:close();
end
end);
sql = [[SELECT * FROM v_voicemail_greetings
WHERE domain_uuid = ']] .. domain_uuid ..[['
AND voicemail_id = ']].. voicemail_id.. [['
AND greeting_id = ']].. greeting_id.. [[' ]];
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
end
status = dbh:query(sql, function(row)
--add functions
dofile(scripts_dir.."/resources/functions/base64.lua");
--set the voicemail message path
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
--save the greeting to the file system
if (string.len(row["greeting_base64"]) > 32) then
local file = io.open(greeting_location, "w");
file:write(base64.decode(row["greeting_base64"]));
file:close();
end
end);
elseif (storage_type == "http_cache") then
greeting_location = storage_path.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
end

View File

@@ -43,33 +43,35 @@
--get the greeting from the database
if (storage_type == "base64") then
sql = [[SELECT * FROM v_voicemail_greetings
WHERE domain_uuid = ']] .. domain_uuid ..[['
AND voicemail_id = ']].. voicemail_id.. [['
AND greeting_id = ']].. greeting_id.. [[' ]];
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
end
status = dbh:query(sql, function(row)
--add functions
dofile(scripts_dir.."/resources/functions/base64.lua");
sql = [[SELECT * FROM v_voicemail_greetings
WHERE domain_uuid = ']] .. domain_uuid ..[['
AND voicemail_id = ']].. voicemail_id.. [['
AND greeting_id = ']].. greeting_id.. [[' ]];
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
end
status = dbh:query(sql, function(row)
--add functions
dofile(scripts_dir.."/resources/functions/base64.lua");
--set the voicemail message path
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
--set the voicemail message path
greeting_location = voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav"; --vm_message_ext;
--save the greeting to the file system
--if not found, save greeting to local file system
--if (not file_exists(greeting_location)) then
if (string.len(row["greeting_base64"]) > 32) then
local file = io.open(greeting_location, "w");
file:write(base64.decode(row["greeting_base64"]));
file:close();
end
--end
--play the greeting
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
--play the greeting
session:streamFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
--delete the greeting
os.remove(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
end);
--delete the greeting (retain local for better responsiveness)
--os.remove(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
end);
elseif (storage_type == "http_cache") then
session:streamFile(storage_path.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
else

View File

@@ -24,16 +24,18 @@
-- POSSIBILITY OF SUCH DAMAGE.
--define a function to record the greeting
function record_greeting()
function record_greeting(greeting_id)
--flush dtmf digits from the input buffer
session:flushDigits();
--Choose a greeting between 1 and 9
if (session:ready()) then
dtmf_digits = '';
greeting_id = macro(session, "choose_greeting_choose", 1, 5000, '');
freeswitch.consoleLog("notice", "[voicemail] greeting_id: " .. greeting_id .. "\n");
--choose a greeting between 1 and 9
if (greeting_id == nil) then
if (session:ready()) then
dtmf_digits = '';
greeting_id = macro(session, "choose_greeting_choose", 1, 5000, '');
freeswitch.consoleLog("notice", "[voicemail] greeting_id: " .. greeting_id .. "\n");
end
end
--validate the greeting_id
@@ -53,7 +55,11 @@
end
--store the voicemail greeting
if (storage_type == "base64") then
if (storage_type == "http_cache") then
freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. " ".. storage_path .."\n");
storage_path = storage_path:gsub("${domain_name}", domain_name);
session:execute("record", storage_path .."/"..recording_name);
else
--prepare to record the greeting
if (session:ready()) then
max_len_seconds = 30;
@@ -61,97 +67,11 @@
silence_seconds = 5;
mkdir(voicemail_dir.."/"..voicemail_id);
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav", max_len_seconds, silence_threshold, silence_seconds);
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", max_len_seconds, silence_threshold, silence_seconds);
--session:execute("record", voicemail_dir.."/"..uuid.." 180 200");
end
--include the base64 function
dofile(scripts_dir.."/resources/functions/base64.lua");
--show the storage type
--freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. "\n");
--base64 encode the file
local f = io.open(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav", "rb");
local file_content = f:read("*all");
f:close();
greeting_base64 = base64.encode(file_content);
--delete the previous recording
sql = "delete from v_voicemail_greetings ";
sql = sql .. "where domain_uuid = '".. domain_uuid .. "' ";
sql = sql .. "and voicemail_id = '".. voicemail_id .."'";
sql = sql .. "and greeting_id = '".. greeting_id .."'";
dbh:query(sql);
--get a new uuid
voicemail_greeting_uuid = api:execute("create_uuid");
--save the message to the voicemail messages
local array = {}
table.insert(array, "INSERT INTO v_voicemail_greetings ");
table.insert(array, "(");
table.insert(array, "voicemail_greeting_uuid, ");
table.insert(array, "domain_uuid, ");
table.insert(array, "voicemail_id, ");
table.insert(array, "greeting_id, ");
if (storage_type == "base64") then
table.insert(array, "greeting_base64, ");
end
table.insert(array, "greeting_name ");
table.insert(array, ") ");
table.insert(array, "VALUES ");
table.insert(array, "( ");
table.insert(array, "'"..voicemail_greeting_uuid.."', ");
table.insert(array, "'"..domain_uuid.."', ");
table.insert(array, "'"..voicemail_id.."', ");
table.insert(array, "'"..greeting_id.."', ");
if (storage_type == "base64") then
table.insert(array, "'"..greeting_base64.."', ");
end
table.insert(array, "'greeting_"..greeting_id..".wav' ");
table.insert(array, ") ");
sql = table.concat(array, "\n");
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
end
if (storage_type == "base64") then
array = explode("://", database["system"]);
local luasql = require "luasql.postgres";
local env = assert (luasql.postgres());
local db = env:connect(array[2]);
res, serr = db:execute(sql);
db:close();
env:close();
else
dbh:query(sql);
end
elseif (storage_type == "http_cache") then
freeswitch.consoleLog("notice", "[voicemail] ".. storage_type .. " ".. storage_path .."\n");
storage_path = storage_path:gsub("${domain_name}", domain_name);
session:execute("record", storage_path .."/"..recording_name);
else
--prepare to record the greeting
if (session:ready()) then
max_len_seconds = 30;
silence_threshold = 30;
silence_seconds = 5;
mkdir(voicemail_dir.."/"..voicemail_id);
-- syntax is session:recordFile(file_name, max_len_secs, silence_threshold, silence_secs)
result = session:recordFile(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav", max_len_seconds, silence_threshold, silence_seconds);
--session:execute("record", voicemail_dir.."/"..uuid.." 180 200");
end
end
--use the new greeting
local array = {}
table.insert(array, "update v_voicemails ");
table.insert(array, "set greeting_id = '".. greeting_id .."' ");
table.insert(array, "where domain_uuid = '".. domain_uuid .."' ");
table.insert(array, "and voicemail_id = '".. voicemail_id .."' ");
sql = table.concat(array, "\n");
dbh:query(sql);
--play the greeting
--if (session:ready()) then
-- if (file_exists(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav")) then
@@ -162,11 +82,7 @@
--option to play, save, and re-record the greeting
if (session:ready()) then
timeouts = 0;
record_menu("greeting", voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
if (storage_type == "base64") then
--delete the greeting
os.remove(voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".wav");
end
record_menu("greeting", voicemail_dir.."/"..voicemail_id.."/greeting_"..greeting_id..".tmp.wav", greeting_id);
end
else
--invalid greeting_id
@@ -186,4 +102,12 @@
end
end
end
--clean up any tmp greeting files
for gid = 1, 9, 1 do
if (file_exists(voicemail_dir.."/"..voicemail_id.."/greeting_"..gid..".tmp.wav")) then
os.remove(voicemail_dir.."/"..voicemail_id.."/greeting_"..gid..".tmp.wav");
end
end
end

View File

@@ -24,7 +24,7 @@
-- POSSIBILITY OF SUCH DAMAGE.
--record message menu
function record_menu(type, file)
function record_menu(type, tmp_file, greeting_id)
if (session:ready()) then
--clear the dtmf digits variable
dtmf_digits = '';
@@ -52,10 +52,10 @@
if (session:ready()) then
if (dtmf_digits == "1") then
--listen to the recording
session:streamFile(file);
session:streamFile(tmp_file);
--session:streamFile(voicemail_dir.."/"..voicemail_id.."/msg_"..uuid.."."..vm_message_ext);
--record menu 1 listen to the recording, 2 save the recording, 3 re-record
record_menu(type, file);
--record menu (1=listen, 2=save, 3=re-record)
record_menu(type, tmp_file, greeting_id);
elseif (dtmf_digits == "2") then
--save the message
dtmf_digits = '';
@@ -67,6 +67,93 @@
session:hangup();
end
if (type == "greeting") then
--remove old greeting file, and rename tmp file
local real_file = string.gsub(tmp_file, ".tmp", "");
if (file_exists(real_file)) then
os.remove(real_file);
end
if (file_exists(tmp_file)) then
os.rename(tmp_file, real_file);
end
if (storage_type == "base64") then
--delete the greeting (retain local for better responsiveness)
--os.remove(real_file);
end
--if base64, encode file
if (storage_type == "base64") then
--include the base64 function
dofile(scripts_dir.."/resources/functions/base64.lua");
--base64 encode the file
local f = io.open(real_file, "rb");
local file_content = f:read("*all");
f:close();
greeting_base64 = base64.encode(file_content);
end
--delete the previous recording
sql = "delete from v_voicemail_greetings ";
sql = sql .. "where domain_uuid = '".. domain_uuid .. "' ";
sql = sql .. "and voicemail_id = '".. voicemail_id .."' ";
sql = sql .. "and greeting_id = '".. greeting_id .."' ";
--freeswitch.consoleLog("notice", "[SQL] DELETING: " .. greeting_id .. "\n");
dbh:query(sql);
--get a new uuid
voicemail_greeting_uuid = api:execute("create_uuid");
--save the message to the voicemail messages
local array = {}
table.insert(array, "INSERT INTO v_voicemail_greetings ");
table.insert(array, "(");
table.insert(array, "voicemail_greeting_uuid, ");
table.insert(array, "domain_uuid, ");
table.insert(array, "voicemail_id, ");
table.insert(array, "greeting_id, ");
if (storage_type == "base64") then
table.insert(array, "greeting_base64, ");
end
table.insert(array, "greeting_name, ");
table.insert(array, "greeting_filename ");
table.insert(array, ") ");
table.insert(array, "VALUES ");
table.insert(array, "( ");
table.insert(array, "'"..voicemail_greeting_uuid.."', ");
table.insert(array, "'"..domain_uuid.."', ");
table.insert(array, "'"..voicemail_id.."', ");
table.insert(array, "'"..greeting_id.."', ");
if (storage_type == "base64") then
table.insert(array, "'"..greeting_base64.."', ");
end
table.insert(array, "'Greeting "..greeting_id.."', ");
table.insert(array, "'greeting_"..greeting_id..".wav' ");
table.insert(array, ") ");
sql = table.concat(array, "\n");
--freeswitch.consoleLog("notice", "[SQL] INSERTING: " .. greeting_id .. "\n");
if (debug["sql"]) then
freeswitch.consoleLog("notice", "[voicemail] SQL: " .. sql .. "\n");
end
if (storage_type == "base64") then
array = explode("://", database["system"]);
local luasql = require "luasql.postgres";
local env = assert (luasql.postgres());
local db = env:connect(array[2]);
res, serr = db:execute(sql);
db:close();
env:close();
else
dbh:query(sql);
end
--use the new greeting
local array = {}
table.insert(array, "update v_voicemails ");
table.insert(array, "set greeting_id = '".. greeting_id .."' ");
table.insert(array, "where domain_uuid = '".. domain_uuid .."' ");
table.insert(array, "and voicemail_id = '".. voicemail_id .."' ");
sql = table.concat(array, "\n");
dbh:query(sql);
advanced();
end
if (type == "name") then
@@ -80,12 +167,22 @@
record_message();
end
if (type == "greeting") then
record_greeting();
--remove temporary greeting file, if any
if (file_exists(tmp_file)) then
os.remove(tmp_file);
end
record_greeting(greeting_id);
end
if (type == "name") then
record_name();
end
elseif (dtmf_digits == "*") then
if (type == "greeting") then
--remove temporary greeting file, if any
if (file_exists(tmp_file)) then
os.remove(tmp_file);
end
end
--hangup
if (session:ready()) then
dtmf_digits = '';
@@ -96,13 +193,19 @@
if (session:ready()) then
timeouts = timeouts + 1;
if (timeouts < max_timeouts) then
record_menu(type, file);
record_menu(type, tmp_file, greeting_id);
else
if (type == "message") then
dtmf_digits = '';
macro(session, "message_saved", 1, 100, '');
macro(session, "goodbye", 1, 1000, '');
session:hangup();
end
if (type == "greeting") then
--remove temporary greeting file, if any
if (file_exists(tmp_file)) then
os.remove(tmp_file);
end
advanced();
end
if (type == "name") then

View File

@@ -185,7 +185,13 @@
message_waiting(id, domain_uuid);
--clear the variable
db_voicemail_uuid = '';
elseif (storage_type == "base64") then
--delete voicemail recording file
if (file_exists(file)) then
os.remove(file);
end
end
end
end

View File

@@ -154,7 +154,7 @@
--delete the previous recording
sql = "delete from v_recordings ";
sql = sql .. "where domain_uuid = '".. domain_uuid .. "' ";
sql = sql .. "and recording_name = '".. recording_name .."'";
sql = sql .. "and recording_filename = '".. recording_name .."'";
dbh:query(sql);
--get a new uuid