| 1 |
<?php |
|---|
| 2 |
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); } |
|---|
| 3 |
|
|---|
| 4 |
// Source and Destination Dirctories for recording |
|---|
| 5 |
global $recordings_astsnd_path; // PHP5 needs extra convincing of a global |
|---|
| 6 |
global $amp_conf; |
|---|
| 7 |
$recordings_save_path = $amp_conf['ASTSPOOLDIR']."/tmp/"; |
|---|
| 8 |
$recordings_astsnd_path = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; |
|---|
| 9 |
$recordings_astsnd_path .= "/sounds/"; |
|---|
| 10 |
|
|---|
| 11 |
function recordings_get_config($engine) { |
|---|
| 12 |
global $ext; // is this the best way to pass this? |
|---|
| 13 |
global $recordings_save_path; |
|---|
| 14 |
global $version; |
|---|
| 15 |
|
|---|
| 16 |
$ast_ge_14 = version_compare($version, '1.4', 'ge'); |
|---|
| 17 |
$ast_ge_16 = version_compare($version, '1.6', 'ge'); |
|---|
| 18 |
|
|---|
| 19 |
$modulename = "recordings"; |
|---|
| 20 |
$appcontext = "app-recordings"; |
|---|
| 21 |
|
|---|
| 22 |
switch($engine) { |
|---|
| 23 |
case "asterisk": |
|---|
| 24 |
// FeatureCodes for save / check |
|---|
| 25 |
$fcc = new featurecode($modulename, 'record_save'); |
|---|
| 26 |
$fc_save = $fcc->getCodeActive(); |
|---|
| 27 |
unset($fcc); |
|---|
| 28 |
|
|---|
| 29 |
$fcc = new featurecode($modulename, 'record_check'); |
|---|
| 30 |
$fc_check = $fcc->getCodeActive(); |
|---|
| 31 |
unset($fcc); |
|---|
| 32 |
|
|---|
| 33 |
if ($fc_save != '' || $fc_check != '') { |
|---|
| 34 |
$ext->addInclude('from-internal-additional', 'app-recordings'); // Add the include from from-internal |
|---|
| 35 |
|
|---|
| 36 |
if ($fc_save != '') { |
|---|
| 37 |
$ext->add($appcontext, $fc_save, '', new ext_macro('user-callerid')); |
|---|
| 38 |
$ext->add($appcontext, $fc_save, '', new ext_wait('2')); |
|---|
| 39 |
$ext->add($appcontext, $fc_save, '', new ext_macro('systemrecording', 'dorecord')); |
|---|
| 40 |
} |
|---|
| 41 |
|
|---|
| 42 |
if ($fc_check != '') { |
|---|
| 43 |
$ext->add($appcontext, $fc_check, '', new ext_macro('user-callerid')); |
|---|
| 44 |
$ext->add($appcontext, $fc_check, '', new ext_wait('2')); |
|---|
| 45 |
$ext->add($appcontext, $fc_check, '', new ext_macro('systemrecording', 'docheck')); |
|---|
| 46 |
} |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
// Now generate the Feature Codes to edit recordings |
|---|
| 50 |
// |
|---|
| 51 |
$recordings = recordings_list(); |
|---|
| 52 |
foreach ($recordings as $item) { |
|---|
| 53 |
|
|---|
| 54 |
// Get the feature code, and do a sanity check if it is not suppose to be active and delete it |
|---|
| 55 |
// |
|---|
| 56 |
if ($item['fcode'] != 0) { |
|---|
| 57 |
$fcc = new featurecode($modulename, 'edit-recording-'.$item['id']); |
|---|
| 58 |
$fcode = $fcc->getCodeActive(); |
|---|
| 59 |
unset($fcc); |
|---|
| 60 |
} else { |
|---|
| 61 |
$fcc = new featurecode('recordings', 'edit-recording-'.$item['id']); |
|---|
| 62 |
$fcc->delete(); |
|---|
| 63 |
unset($fcc); |
|---|
| 64 |
continue; // loop back to foreach |
|---|
| 65 |
} |
|---|
| 66 |
|
|---|
| 67 |
if ($fcode != '') { |
|---|
| 68 |
// Do a sanity check, there should be no compound files |
|---|
| 69 |
// |
|---|
| 70 |
if (strpos($item['filename'], '&') === false && trim($item['filename']) != '') { |
|---|
| 71 |
$fcode_pass = (trim($item['fcode_pass']) != '') ? ','.$item['fcode_pass'] : ''; |
|---|
| 72 |
$ext->add($appcontext, $fcode, '', new ext_macro('user-callerid')); |
|---|
| 73 |
$ext->add($appcontext, $fcode, '', new ext_wait('2')); |
|---|
| 74 |
$ext->add($appcontext, $fcode, '', new ext_macro('systemrecording', 'docheck,'.$item['filename'].$fcode_pass)); |
|---|
| 75 |
//$ext->add($appcontext, $fcode, '', new ext_macro('hangup')); |
|---|
| 76 |
} |
|---|
| 77 |
} |
|---|
| 78 |
} |
|---|
| 79 |
|
|---|
| 80 |
// moved from modules/core to modules/recordings |
|---|
| 81 |
// since it really belongs here and not there |
|---|
| 82 |
// also provides direct access to $recordings_save_path |
|---|
| 83 |
// which removes a hard-coded value in the macro |
|---|
| 84 |
|
|---|
| 85 |
$context = 'macro-systemrecording'; |
|---|
| 86 |
|
|---|
| 87 |
$ext->add($context, 's', '', new ext_setvar('RECFILE','${IF($["${ARG2}" = ""]?'.$recordings_save_path.'${AMPUSER}-ivrrecording:${ARG2})}')); |
|---|
| 88 |
$ext->add($context, 's', '', new ext_execif('$["${ARG3}" != ""]','Authenticate','${ARG3}')); |
|---|
| 89 |
$ext->add($context, 's', '', new ext_goto(1, '${ARG1}')); |
|---|
| 90 |
|
|---|
| 91 |
$exten = 'dorecord'; |
|---|
| 92 |
|
|---|
| 93 |
// Delete all versions of the current sound file (does not consider languages though |
|---|
| 94 |
// otherwise you might have some versions that are not re-recorded |
|---|
| 95 |
// |
|---|
| 96 |
// If we get here from *77 then we don't have ARG2, so just skip the remove, otherwise we have two paths |
|---|
| 97 |
$ext->add($context, $exten, '', new ext_gotoif('$["${ARG2}" = ""]','skipremove')); |
|---|
| 98 |
$ext->add($context, $exten, '', new ext_system('rm ${ASTVARLIBDIR}/sounds/${RECFILE}.*')); |
|---|
| 99 |
if ($ast_ge_16) { |
|---|
| 100 |
// Added in Asterisk 1.6: "If the user hangs up during a recording, all data is lost". |
|---|
| 101 |
// Third option - k: Keep recorded file upon hangup. |
|---|
| 102 |
$ext->add($context, $exten, 'skipremove', new ext_record('${RECFILE}.wav,,,k')); |
|---|
| 103 |
} else { |
|---|
| 104 |
$ext->add($context, $exten, 'skipremove', new ext_record('${RECFILE}.wav')); |
|---|
| 105 |
} |
|---|
| 106 |
$ext->add($context, $exten, '', new ext_wait(1)); |
|---|
| 107 |
$ext->add($context, $exten, '', new ext_goto(1, 'confmenu')); |
|---|
| 108 |
|
|---|
| 109 |
$exten = 'docheck'; |
|---|
| 110 |
|
|---|
| 111 |
$ext->add($context, $exten, '', new ext_playback('beep')); |
|---|
| 112 |
if ($ast_ge_14) { |
|---|
| 113 |
$ext->add($context, $exten, 'dc_start', new ext_background('${RECFILE},m,${CHANNEL(language)},macro-systemrecording')); |
|---|
| 114 |
} else { |
|---|
| 115 |
$ext->add($context, $exten, 'dc_start', new ext_background('${RECFILE},m,${LANGUAGE},macro-systemrecording')); |
|---|
| 116 |
} |
|---|
| 117 |
$ext->add($context, $exten, '', new ext_wait(1)); |
|---|
| 118 |
$ext->add($context, $exten, '', new ext_goto(1, 'confmenu')); |
|---|
| 119 |
|
|---|
| 120 |
$exten = 'confmenu'; |
|---|
| 121 |
if ($ast_ge_14) { |
|---|
| 122 |
$ext->add($context, $exten, '', new ext_background('to-listen-to-it&press-1&to-rerecord-it&press-star&astcc-followed-by-pound,m,${CHANNEL(language)},macro-systemrecording')); |
|---|
| 123 |
} else { |
|---|
| 124 |
$ext->add($context, $exten, '', new ext_background('to-listen-to-it&press-1&to-rerecord-it&press-star&astcc-followed-by-pound,m,${LANGUAGE},macro-systemrecording')); |
|---|
| 125 |
} |
|---|
| 126 |
$ext->add($context, $exten, '', new ext_read('RECRESULT', '', 1, '', '', 4)); |
|---|
| 127 |
$ext->add($context, $exten, '', new ext_gotoif('$["x${RECRESULT}"="x*"]', 'dorecord,1')); |
|---|
| 128 |
$ext->add($context, $exten, '', new ext_gotoif('$["x${RECRESULT}"="x1"]', 'docheck,2')); |
|---|
| 129 |
$ext->add($context, $exten, '', new ext_goto(1)); |
|---|
| 130 |
|
|---|
| 131 |
$ext->add($context, '1', '', new ext_goto('dc_start', 'docheck')); |
|---|
| 132 |
$ext->add($context, '*', '', new ext_goto(1, 'dorecord')); |
|---|
| 133 |
|
|---|
| 134 |
$ext->add($context, 't', '', new ext_playback('goodbye')); |
|---|
| 135 |
$ext->add($context, 't', '', new ext_hangup()); |
|---|
| 136 |
|
|---|
| 137 |
$ext->add($context, 'i', '', new ext_playback('pm-invalid-option')); |
|---|
| 138 |
$ext->add($context, 'i', '', new ext_goto(1, 'confmenu')); |
|---|
| 139 |
|
|---|
| 140 |
$ext->add($context, 'h', '', new ext_hangup()); |
|---|
| 141 |
|
|---|
| 142 |
break; |
|---|
| 143 |
} |
|---|
| 144 |
} |
|---|
| 145 |
|
|---|
| 146 |
function recordings_get_or_create_id($fn, $module) { |
|---|
| 147 |
$id = recordings_get_id($fn); |
|---|
| 148 |
if ($id != null) { |
|---|
| 149 |
return $id; |
|---|
| 150 |
} else { |
|---|
| 151 |
// Create the id, name it the file name or if multi-part ... |
|---|
| 152 |
// |
|---|
| 153 |
$dname = explode('&',$displayname); |
|---|
| 154 |
$displayname = 'auto-created: '; |
|---|
| 155 |
$displayname .= count($dname) == 1 ? $fn : $dname[0]."&..."; |
|---|
| 156 |
$description = sprintf(_("Missing Sound file auto-created from migration of %s module"),$module); |
|---|
| 157 |
recordings_add($displayname, $fn, $description=''); |
|---|
| 158 |
|
|---|
| 159 |
// get the id we just created |
|---|
| 160 |
// |
|---|
| 161 |
$id = recordings_get_id($fn); |
|---|
| 162 |
|
|---|
| 163 |
// Notify of issue |
|---|
| 164 |
// |
|---|
| 165 |
$nt =& notifications::create($db); |
|---|
| 166 |
$text = sprintf(_("Non-Existent Recording in module %s"),$module); |
|---|
| 167 |
$extext = sprintf(_("The %s referenced a recording file listed below that does not exists. An entry has been generated, named %s, with the referenced file(s) but you should confirm that it really works and the real files exist. The file(s) referenced: %s "),$module, $displayname, $fn); |
|---|
| 168 |
$nt->add_error('recordings', 'NEWREC-'.$id, $text, $extext, '', true, true); |
|---|
| 169 |
unset($nt); |
|---|
| 170 |
|
|---|
| 171 |
// return the id just created |
|---|
| 172 |
return $id; |
|---|
| 173 |
} |
|---|
| 174 |
} |
|---|
| 175 |
|
|---|
| 176 |
function recordings_get_id($fn) { |
|---|
| 177 |
global $db; |
|---|
| 178 |
|
|---|
| 179 |
$sql = "SELECT id FROM recordings WHERE filename='$fn'"; |
|---|
| 180 |
$results = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| 181 |
if (isset($results['id'])) { |
|---|
| 182 |
return $results['id']; |
|---|
| 183 |
} else { |
|---|
| 184 |
return null; |
|---|
| 185 |
} |
|---|
| 186 |
} |
|---|
| 187 |
|
|---|
| 188 |
function recordings_get_file($id) { |
|---|
| 189 |
$res = recordings_get($id); |
|---|
| 190 |
return $res['filename']; |
|---|
| 191 |
} |
|---|
| 192 |
|
|---|
| 193 |
|
|---|
| 194 |
function recordings_list($compound=true) { |
|---|
| 195 |
|
|---|
| 196 |
static $initialized=false; |
|---|
| 197 |
static $full_list; |
|---|
| 198 |
static $filter_list=array(); |
|---|
| 199 |
|
|---|
| 200 |
if ($initialized) { |
|---|
| 201 |
return ($compound ? $full_list : $filter_list); |
|---|
| 202 |
} |
|---|
| 203 |
$initialized=true; |
|---|
| 204 |
|
|---|
| 205 |
$sql = "SELECT * FROM recordings where displayname <> '__invalid' ORDER BY displayname"; |
|---|
| 206 |
$full_list = sql($sql,'getAll',DB_FETCHMODE_ASSOC); |
|---|
| 207 |
|
|---|
| 208 |
// Make array backward compatible, put first 4 columns as numeric |
|---|
| 209 |
$count = 0; |
|---|
| 210 |
foreach($full_list as $item) { |
|---|
| 211 |
$full_list[$count][0] = $item['id']; |
|---|
| 212 |
$full_list[$count][1] = $item['displayname']; |
|---|
| 213 |
$full_list[$count][2] = $item['filename']; |
|---|
| 214 |
$full_list[$count][3] = $item['description']; |
|---|
| 215 |
if (strstr($item['filename'],'&') === false) { |
|---|
| 216 |
$filter_list[] = $full_list[$count]; |
|---|
| 217 |
} |
|---|
| 218 |
$count++; |
|---|
| 219 |
} |
|---|
| 220 |
return ($compound ? $full_list : $filter_list); |
|---|
| 221 |
} |
|---|
| 222 |
|
|---|
| 223 |
function recordings_get($id) { |
|---|
| 224 |
global $db; |
|---|
| 225 |
$sql = "SELECT * FROM recordings where id='$id'"; |
|---|
| 226 |
$results = $db->getRow($sql, DB_FETCHMODE_ASSOC); |
|---|
| 227 |
if(DB::IsError($results)) { |
|---|
| 228 |
$results = null; |
|---|
| 229 |
} |
|---|
| 230 |
return $results; |
|---|
| 231 |
} |
|---|
| 232 |
|
|---|
| 233 |
function recordings_add($displayname, $filename, $description='') { |
|---|
| 234 |
global $db; |
|---|
| 235 |
global $recordings_astsnd_path; |
|---|
| 236 |
|
|---|
| 237 |
// Check to make sure we can actually read the file if it has an extension (if it doesn't, |
|---|
| 238 |
// it was put here by system recordings, so we know it's there. |
|---|
| 239 |
if (preg_match("/\.(au|g723|g723sf|g726-\d\d|g729|gsm|h263|ilbc|mp3|ogg|pcm|[au]law|[au]l|mu|sln|raw|vox|WAV|wav|wav49)$/", $filename)) { |
|---|
| 240 |
if (!is_readable($recordings_astsnd_path.$filename)) { |
|---|
| 241 |
print "<p>Unable to add ".$recordings_astsnd_path.$filename." - Can not read file!</p>"; |
|---|
| 242 |
return false; |
|---|
| 243 |
} |
|---|
| 244 |
$fname = preg_replace("/\.(au|g723|g723sf|g726-\d\d|g729|gsm|h263|ilbc|mp3|ogg|pcm|[au]law|[au]l|mu|sln|raw|vox|WAV|wav|wav49)$/", "", $filename); |
|---|
| 245 |
|
|---|
| 246 |
} else { |
|---|
| 247 |
$fname = $filename; |
|---|
| 248 |
} |
|---|
| 249 |
$description = ($description != '') ? $db->escapeSimple($description) : _("No long description available"); |
|---|
| 250 |
$displayname = $db->escapeSimple($displayname); |
|---|
| 251 |
sql("INSERT INTO recordings (displayname, filename, description) VALUES ( '$displayname', '$fname', '$description')"); |
|---|
| 252 |
|
|---|
| 253 |
return true; |
|---|
| 254 |
|
|---|
| 255 |
} |
|---|
| 256 |
|
|---|
| 257 |
function recordings_update($id, $rname, $descr, $_REQUEST, $fcode=0, $fcode_pass='') { |
|---|
| 258 |
global $db; |
|---|
| 259 |
|
|---|
| 260 |
// Update the descriptive fields |
|---|
| 261 |
$fcode_pass = preg_replace("/[^0-9*]/" ,"", trim($fcode_pass)); |
|---|
| 262 |
$results = sql("UPDATE recordings SET displayname = '".$db->escapeSimple($rname)."', description = '".$db->escapeSimple($descr)."', fcode='$fcode', fcode_pass='".$fcode_pass."' WHERE id = '$id'"); |
|---|
| 263 |
|
|---|
| 264 |
// Build the file list from _REQUEST |
|---|
| 265 |
$astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; |
|---|
| 266 |
$astsnd .= "/sounds/"; |
|---|
| 267 |
$recordings = Array(); |
|---|
| 268 |
|
|---|
| 269 |
// Set the file names from the submitted page, sysrec[N] |
|---|
| 270 |
// We don't set if feature code was selected, we use what was already there |
|---|
| 271 |
// because the fields will have been disabled and won't be accessible in the |
|---|
| 272 |
// $_REQUEST array anyhow |
|---|
| 273 |
// |
|---|
| 274 |
if ($fcode != 1) { |
|---|
| 275 |
// delete the feature code if it existed |
|---|
| 276 |
// |
|---|
| 277 |
$fcc = new featurecode('recordings', 'edit-recording-'.$id); |
|---|
| 278 |
$fcc->delete(); |
|---|
| 279 |
unset($fcc); |
|---|
| 280 |
foreach ($_REQUEST as $key => $val) { |
|---|
| 281 |
$res = strpos($key, 'sysrec'); |
|---|
| 282 |
if ($res !== false) { |
|---|
| 283 |
// strip out any relative paths, since this is coming from a URL |
|---|
| 284 |
str_replace('..','',$val); |
|---|
| 285 |
|
|---|
| 286 |
$recordings[substr($key,6)]=$val; |
|---|
| 287 |
} |
|---|
| 288 |
} |
|---|
| 289 |
|
|---|
| 290 |
// Stick the filename in the database |
|---|
| 291 |
recordings_set_file($id, implode('&', $recordings)); |
|---|
| 292 |
} else { |
|---|
| 293 |
// Add the feature code if it is needed |
|---|
| 294 |
// |
|---|
| 295 |
$fcc = new featurecode('recordings', 'edit-recording-'.$id); |
|---|
| 296 |
$fcc->setDescription("Edit Recording: $rname"); |
|---|
| 297 |
$fcc->setDefault('*29'.$id); |
|---|
| 298 |
$fcc->setProvideDest(); |
|---|
| 299 |
$fcc->update(); |
|---|
| 300 |
unset($fcc); |
|---|
| 301 |
} |
|---|
| 302 |
|
|---|
| 303 |
// In _REQUEST there are also various actions (possibly) |
|---|
| 304 |
// up[N] - Move file id N up one place |
|---|
| 305 |
// down[N] - Move fid N down one place |
|---|
| 306 |
// del[N] - Delete fid N |
|---|
| 307 |
|
|---|
| 308 |
foreach ($_REQUEST as $key => $val) { |
|---|
| 309 |
if (strpos($key,"_") == 0) { |
|---|
| 310 |
$up = strpos($key, "up"); |
|---|
| 311 |
|
|---|
| 312 |
$down = strpos($key, "down"); |
|---|
| 313 |
$del = strpos($key, "del"); |
|---|
| 314 |
} |
|---|
| 315 |
if ( $up !== false ) { |
|---|
| 316 |
$up = substr($key, 2); |
|---|
| 317 |
recordings_move_file_up($id, $up); |
|---|
| 318 |
} |
|---|
| 319 |
if ($del !== false ) { |
|---|
| 320 |
$del = substr($key,3); |
|---|
| 321 |
recordings_delete_file($id, $del); |
|---|
| 322 |
} |
|---|
| 323 |
if ($down !== false ) { |
|---|
| 324 |
$down = substr($key,4); |
|---|
| 325 |
recordings_move_file_down($id, $down); |
|---|
| 326 |
} |
|---|
| 327 |
} |
|---|
| 328 |
} |
|---|
| 329 |
|
|---|
| 330 |
function recordings_move_file_up($id, $src) { |
|---|
| 331 |
$files = recordings_get_file($id); |
|---|
| 332 |
if ($src === 0 || $src < 0) { return false; } // Should never happen, up shouldn't appear whten fid=0 |
|---|
| 333 |
$tmparr = explode('&', $files); |
|---|
| 334 |
$tmp = $tmparr[$src-1]; |
|---|
| 335 |
$tmparr[$src-1] = $tmparr[$src]; |
|---|
| 336 |
$tmparr[$src] = $tmp; |
|---|
| 337 |
recordings_set_file($id, implode('&', $tmparr)); |
|---|
| 338 |
} |
|---|
| 339 |
function recordings_move_file_down($id, $src) { |
|---|
| 340 |
$files = recordings_get_file($id); |
|---|
| 341 |
$tmparr = explode('&', $files); |
|---|
| 342 |
$tmp = $tmparr[$src+1]; |
|---|
| 343 |
$tmparr[$src+1] = $tmparr[$src]; |
|---|
| 344 |
$tmparr[$src] = $tmp; |
|---|
| 345 |
recordings_set_file($id, implode('&', $tmparr)); |
|---|
| 346 |
} |
|---|
| 347 |
function recordings_delete_file($id, $src) { |
|---|
| 348 |
$files = recordings_get_file($id); |
|---|
| 349 |
$tmparr = explode('&', $files); |
|---|
| 350 |
$tmp = Array(); |
|---|
| 351 |
$counter = 0; |
|---|
| 352 |
foreach ($tmparr as $file) { |
|---|
| 353 |
if ($counter != $src) { $tmp[] = $file; } |
|---|
| 354 |
$counter++; |
|---|
| 355 |
} |
|---|
| 356 |
recordings_set_file($id, implode('&', $tmp)); |
|---|
| 357 |
} |
|---|
| 358 |
|
|---|
| 359 |
|
|---|
| 360 |
function recordings_del($id) { |
|---|
| 361 |
$results = sql("DELETE FROM recordings WHERE id = \"$id\""); |
|---|
| 362 |
|
|---|
| 363 |
// delete the feature code if it existed |
|---|
| 364 |
$fcc = new featurecode('recordings', 'edit-recording-'.$id); |
|---|
| 365 |
$fcc->delete(); |
|---|
| 366 |
unset($fcc); |
|---|
| 367 |
} |
|---|
| 368 |
|
|---|
| 369 |
function recordings_set_file($id, $filename) { |
|---|
| 370 |
global $db; |
|---|
| 371 |
// Strip off any dangling &'s on the end: |
|---|
| 372 |
$filename = rtrim($filename, '&'); |
|---|
| 373 |
$results = sql("UPDATE recordings SET filename = '".$db->escapeSimple($filename)."' WHERE id = '$id'"); |
|---|
| 374 |
} |
|---|
| 375 |
|
|---|
| 376 |
|
|---|
| 377 |
|
|---|
| 378 |
function recordings_readdir($snddir) { |
|---|
| 379 |
$files = recordings_getdir($snddir); |
|---|
| 380 |
$ptr = 0; |
|---|
| 381 |
foreach ($files as $fnam) { |
|---|
| 382 |
$files[$ptr] = substr($fnam, strlen($snddir)+1); |
|---|
| 383 |
$ptr++; |
|---|
| 384 |
} |
|---|
| 385 |
// Strip off every possible file extension |
|---|
| 386 |
$flist = preg_replace("/\.(au|g723|g723sf|g726-\d\d|g729|gsm|h263|ilbc|mp3|ogg|pcm|[au]law|[au]l|mu|sln|raw|vox|WAV|wav|wav49)$/", "", $files); |
|---|
| 387 |
sort($flist); |
|---|
| 388 |
return array_unique($flist); |
|---|
| 389 |
} |
|---|
| 390 |
|
|---|
| 391 |
function recordings_getdir($snddir) { |
|---|
| 392 |
$dir = opendir($snddir); |
|---|
| 393 |
$files = Array(); |
|---|
| 394 |
while ($fn = readdir($dir)) { |
|---|
| 395 |
if ($fn == '.' || $fn == '..') { continue; } |
|---|
| 396 |
if (is_dir($snddir.'/'.$fn)) { |
|---|
| 397 |
$files = array_merge(recordings_getdir($snddir.'/'.$fn), $files); |
|---|
| 398 |
continue; |
|---|
| 399 |
} |
|---|
| 400 |
$files[] = $snddir.'/'.$fn; |
|---|
| 401 |
} |
|---|
| 402 |
return $files; |
|---|
| 403 |
} |
|---|
| 404 |
|
|---|
| 405 |
function recordings_list_usage($id) { |
|---|
| 406 |
global $active_modules; |
|---|
| 407 |
$full_usage_arr = array(); |
|---|
| 408 |
|
|---|
| 409 |
foreach(array_keys($active_modules) as $mod) { |
|---|
| 410 |
$function = $mod."_recordings_usage"; |
|---|
| 411 |
if (function_exists($function)) { |
|---|
| 412 |
modgettext::push_textdomain($mod); |
|---|
| 413 |
$recordings_usage = $function($id); |
|---|
| 414 |
modgettext::pop_textdomain(); |
|---|
| 415 |
if (!empty($recordings_usage)) { |
|---|
| 416 |
$full_usage_arr = array_merge($full_usage_arr, $recordings_usage); |
|---|
| 417 |
} |
|---|
| 418 |
} |
|---|
| 419 |
} |
|---|
| 420 |
return $full_usage_arr; |
|---|
| 421 |
} |
|---|
| 422 |
|
|---|
| 423 |
?> |
|---|