Function: Moved recur_sounds_dir() to functions.php, removed from ivr_menu_edit.php and conference_center_edit.php.

This commit is contained in:
Nate Jones 2014-08-25 18:01:26 +00:00
parent f8f9cc9cbe
commit b4e61290f1
3 changed files with 80 additions and 121 deletions

View File

@ -277,54 +277,7 @@ if (count($_POST)>0 && strlen($_POST["persistformvar"]) == 0) {
} //(count($_POST)>0 && strlen($_POST["persistformvar"]) == 0)
//function to show the list of sound files
function recur_sounds_dir($dir) {
global $dir_array;
global $dir_path;
$dir_list = opendir($dir);
while ($file = readdir ($dir_list)) {
if ($file != '.' && $file != '..') {
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (substr($newpath, -4) == ".svn") {
//ignore .svn dir and subdir
}
else {
if (is_dir($newpath)) { //directories
recur_sounds_dir($newpath);
}
else { //files
if (strlen($newpath) > 0) {
//make the path relative
$relative_path = substr($newpath, strlen($dir_path), strlen($newpath));
//remove the 8000-48000 khz from the path
$relative_path = str_replace("/8000/", "/", $relative_path);
$relative_path = str_replace("/16000/", "/", $relative_path);
$relative_path = str_replace("/32000/", "/", $relative_path);
$relative_path = str_replace("/48000/", "/", $relative_path);
//remove the default_language, default_dialect, and default_voice (en/us/callie) from the path
$file_array = explode( "/", $relative_path );
$x = 1;
$relative_path = '';
foreach( $file_array as $tmp) {
if ($x == 5) { $relative_path .= $tmp; }
if ($x > 5) { $relative_path .= '/'.$tmp; }
$x++;
}
//add the file if it does not exist in the array
if (isset($dir_array[$relative_path])) {
//already exists
}
else {
//add the new path
if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; }
}
}
}
}
}
}
closedir($dir_list);
}
// moved to functions.php
//pre-populate the form
if (count($_GET)>0 && $_POST["persistformvar"] != "true") {

View File

@ -46,54 +46,7 @@ else {
$log->log("debug", check_str($_POST["ivr_menu_uuid"]));
//function to show the list of sound files
function recur_sounds_dir($dir) {
global $dir_array;
global $dir_path;
$dir_list = opendir($dir);
while ($file = readdir ($dir_list)) {
if ($file != '.' && $file != '..') {
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (substr($newpath, -4) == ".svn") {
//ignore .svn dir and subdir
}
else {
if (is_dir($newpath)) { //directories
recur_sounds_dir($newpath);
}
else { //files
if (strlen($newpath) > 0) {
//make the path relative
$relative_path = substr($newpath, strlen($dir_path), strlen($newpath));
//remove the 8000-48000 khz from the path
$relative_path = str_replace("/8000/", "/", $relative_path);
$relative_path = str_replace("/16000/", "/", $relative_path);
$relative_path = str_replace("/32000/", "/", $relative_path);
$relative_path = str_replace("/48000/", "/", $relative_path);
//remove the default_language, default_dialect, and default_voice (en/us/callie) from the path
$file_array = explode( "/", $relative_path );
$x = 1;
$relative_path = '';
foreach( $file_array as $tmp) {
if ($x == 5) { $relative_path .= $tmp; }
if ($x > 5) { $relative_path .= '/'.$tmp; }
$x++;
}
//add the file if it does not exist in the array
if (isset($dir_array[$relative_path])) {
//already exists
}
else {
//add the new path
if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; }
}
}
}
}
}
}
closedir($dir_list);
}
// moved to functions.php
//action add or update
if (strlen($_REQUEST["id"]) > 0) {

View File

@ -988,33 +988,86 @@ function number_pad($number,$n) {
}
// validate email address syntax
if(!function_exists('validate_email')) {
function valid_email($email) {
$regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/';
if ($email != "" && preg_match($regex, $email) == 0) {
return false; // email address does not have valid syntax
}
else {
return true; // email address has valid syntax
}
}
}
// ellipsisnicely truncate long text
if(!function_exists('ellipsis')) {
function ellipsis($string, $max_characters, $preserve_word = true) {
if ($max_characters+$x >= strlen($string)) { return $string; }
if ($preserve_word) {
for ($x = 0; $x < strlen($string); $x++) {
if ($string{$max_characters+$x} == " ") {
return substr($string,0,$max_characters+$x)." ...";
}
else { continue; }
if(!function_exists('validate_email')) {
function valid_email($email) {
$regex = '/^[A-z0-9][\w.-]*@[A-z0-9][\w\-\.]+\.[A-z0-9]{2,6}$/';
if ($email != "" && preg_match($regex, $email) == 0) {
return false; // email address does not have valid syntax
}
else {
return true; // email address has valid syntax
}
}
else {
return substr($string,0,$max_characters)." ...";
}
// ellipsis nicely truncate long text
if(!function_exists('ellipsis')) {
function ellipsis($string, $max_characters, $preserve_word = true) {
if ($max_characters+$x >= strlen($string)) { return $string; }
if ($preserve_word) {
for ($x = 0; $x < strlen($string); $x++) {
if ($string{$max_characters+$x} == " ") {
return substr($string,0,$max_characters+$x)." ...";
}
else { continue; }
}
}
else {
return substr($string,0,$max_characters)." ...";
}
}
}
}
//function to show the list of sound files
if (!function_exists('recur_sounds_dir')) {
function recur_sounds_dir($dir) {
global $dir_array;
global $dir_path;
$dir_list = opendir($dir);
while ($file = readdir ($dir_list)) {
if ($file != '.' && $file != '..') {
$newpath = $dir.'/'.$file;
$level = explode('/',$newpath);
if (substr($newpath, -4) == ".svn") {
//ignore .svn dir and subdir
}
else {
if (is_dir($newpath)) { //directories
recur_sounds_dir($newpath);
}
else { //files
if (strlen($newpath) > 0) {
//make the path relative
$relative_path = substr($newpath, strlen($dir_path), strlen($newpath));
//remove the 8000-48000 khz from the path
$relative_path = str_replace("/8000/", "/", $relative_path);
$relative_path = str_replace("/16000/", "/", $relative_path);
$relative_path = str_replace("/32000/", "/", $relative_path);
$relative_path = str_replace("/48000/", "/", $relative_path);
//remove the default_language, default_dialect, and default_voice (en/us/callie) from the path
$file_array = explode( "/", $relative_path );
$x = 1;
$relative_path = '';
foreach( $file_array as $tmp) {
if ($x == 5) { $relative_path .= $tmp; }
if ($x > 5) { $relative_path .= '/'.$tmp; }
$x++;
}
//add the file if it does not exist in the array
if (isset($dir_array[$relative_path])) {
//already exists
}
else {
//add the new path
if (strlen($relative_path) > 0) { $dir_array[$relative_path] = '0'; }
}
}
}
}
}
}
closedir($dir_list);
}
}
?>