20060318. // //This program is free software; you can redistribute it and/or //modify it under the terms of the GNU General Public License //as published by the Free Software Foundation; either version 2 //of the License, or (at your option) any later version. // //This program is distributed in the hope that it will be useful, //but WITHOUT ANY WARRANTY; without even the implied warranty of //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //GNU General Public License for more details. $action = isset($_REQUEST['action'])?$_REQUEST['action']:''; // Lite weight popup code here, don't need everything else below // switch ($action) { case 'popup': case 'audio': include_once("$action.php"); exit; break; default: break; } $id = isset($_REQUEST['id'])?$_REQUEST['id']:''; $notes = isset($_REQUEST['notes'])?$_REQUEST['notes']:''; $rname = isset($_REQUEST['rname'])?$_REQUEST['rname']:''; $usersnum = isset($_REQUEST['usersnum'])?$_REQUEST['usersnum']:''; $sysrec = isset($_REQUEST['sysrec'])?$_REQUEST['sysrec']:''; $suffix = isset($_REQUEST['suffix']) && trim($_REQUEST['suffix'] != "") ? $_REQUEST['suffix'] : 'wav'; $fcode = isset($_REQUEST['fcode']) && $_REQUEST['fcode'] != '' ? 1 : 0; $fcode_pass = isset($_REQUEST['fcode_pass'])?$_REQUEST['fcode_pass']:''; $fcbase = '*29'; $default_pos = 0; $astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; $astsnd .= "/sounds/"; // check ctype_digit() to avoid very obscure vulnerability that can be made if certain proxy's are used // with the PBX system if (empty($usersnum) || !ctype_digit($usersnum)) { $dest = "unnumbered-"; } else { $dest = "{$usersnum}-"; } // get feature codes for diplay purposes $fcc = new featurecode('recordings', 'record_save'); $fc_save = $fcc->getCodeActive(); unset($fcc); $fcc = new featurecode('recordings', 'record_check'); $fc_check = $fcc->getCodeActive(); unset($fcc); $fc_save = ($fc_save != '' ? $fc_save : _('** MISSING FEATURE CODE **')); $fc_check = ($fc_check != '' ? $fc_check : _('** MISSING FEATURE CODE **')); switch ($action) { case "system": recording_sidebar(-1, null); recording_sysfiles(); break; case "newsysrec": $sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1); if (recordings_add($sysrecs[$sysrec], $sysrecs[$sysrec])) { $id = recordings_get_id($sysrecs[$sysrec]); } else { $id = 0; } recording_sidebar($id, null); recording_editpage($id, null); break; case "recorded": // Clean up the filename, take out any nasty characters $filename = escapeshellcmd(strtr($rname, '/ ', '__')); if (!file_exists($astsnd."custom")) { if (!mkdir($astsnd."custom", 0775)) { echo '
'._("Failed to create").' '.$astsnd.'custom'.'
'; } } else { // can't rename a file from one partition to another, must use mv or cp // rename($recordings_save_path."{$dest}ivrrecording.wav",$recordings_astsnd_path."custom/{$filename}.wav"); if (!file_exists($recordings_save_path."{$dest}ivrrecording.$suffix")) { echo "
"._("[ERROR] The Recorded File Does Not exists:")."
"; echo $recordings_save_path."{$dest}ivrrecording.$suffix

"; echo "make sure you uploaded or recorded a file with the entered extension
"; } else { exec("cp " . $recordings_save_path . "{$dest}ivrrecording.$suffix " . $astsnd."custom/{$filename}.$suffix 2>&1", $outarray, $ret); if (!$ret) { $isok = recordings_add($rname, "custom/{$filename}.$suffix"); } else { echo "
"._("[ERROR] SAVING RECORDING:")."
"; foreach ($outarray as $line) { echo "$line
"; } echo _("Make sure you have entered a proper name"); echo "
"; } exec("rm " . $recordings_save_path . "{$dest}ivrrecording.$suffix ", $outarray, $ret); if ($ret) { echo "
"._("[ERROR] REMOVING TEMPORARY RECORDING:")."
"; foreach ($outarray as $line) { echo "$line
"; } echo _("Make sure Asterisk is not running as root "); echo "
"; } } recording_sidebar(null, $usersnum); recording_addpage($usersnum); if ($isok) echo '
'._("System Recording").' "'.$rname.'" '._("Saved").'!
'; } break; case "edit": $arr = recordings_get($id); $filename=$arr['filename']; // Check all possibilities of uploaded file types. $valid = Array("au","g723","g723sf","g729","gsm","h263","ilbc","mp3","ogg","pcm","alaw","ulaw","al","ul","mu","sln","raw","vox","WAV","wav","wav49"); $fileexists = false; if (strpos($filename, '&') === false) { foreach ($valid as $xtn) { $checkfile = $recordings_astsnd_path.$filename.".".$xtn; if (file_exists($checkfile)) { $suffix = substr(strrchr($filename, "."), 1); copy($checkfile, $recordings_save_path."{$dest}ivrrecording.".$suffix); $fileexists = true; } } if ($fileexists === false) { echo '
'._("Unable to locate").' '.$recordings_astsnd_path.$filename.' '._("with a a valid suffix").'
'; } } recording_sidebar($id, $usersnum); recording_editpage($id, $usersnum); break; case "edited": recordings_update($id, $rname, $notes, $_REQUEST, $fcode, $fcode_pass); recording_sidebar($id, $usersnum); recording_editpage($id, $usersnum); echo '
'._("System Recording").' "'.$rname.'" '._("Updated").'!
'; needreload(); break; case "delete"; recordings_del($id); needreload(); default: recording_sidebar($id, $usersnum); recording_addpage($usersnum); break; } function recording_addpage($usersnum) { global $fc_save; global $fc_check; global $recordings_save_path; ?>

"._("dial")." ".$fc_save." "; echo _("Start speaking at the tone. Hangup when finished.").""; echo _("and speak the message you wish to record.")."\n"; } else { ?>

" tabindex="">

must be PCM Encoded, 16 Bits, at 8000Hz")?>:
" onclick="document.upload.submit(upload);alert('');" tabindex=""/>
"._("Successfully uploaded")." ".$_FILES['ivrfile']['name'].""; $rname = rtrim(basename($_FILES['ivrfile']['name'], $suffix), '.'); } ?>

"._("dial")." ".$fc_check." "._("to listen to your recording.")?>

"._("Step 2: Name").""; } ?>
:
\n"; ?> " tabindex="">

Error reading Recording ID $id - Aborting

"; return; }?>  '.$link['description'].''; echo "
".$label.""; } } else { $delURL = "config.php?display=recordings&action=delete&usersnum=".urlencode($num)."&id=$id"; $tlabel = _("Remove Recording"); $label = ' '.$tlabel.''; echo "".$label.""; echo " ("; echo _("Note, does not delete file from computer"); echo ")"; } ?>
getCode(); unset($fcc); if ($rec_code == '') { $rec_code = $fcbase.$id; } } else { $rec_code = $fcbase.$id; } ?>

 
: OnClick="resetDefaultSound();"; return true;'>
:

:
" tabindex="">
\n"; } function recordings_popup_jscript() { ?>

">

definition around it. $astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; $astsnd .= "/sounds/"; $sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1); $html_txt .= "\n"; $html_txt .= ""; $audio=$astpath; include_once("crypt.php"); $crypt = new Crypt(); $REC_CRYPT_PASSWORD = (isset($amp_conf['AMPPLAYKEY']) && trim($amp_conf['AMPPLAYKEY']) != "")?trim($amp_conf['AMPPLAYKEY']):'moufdsuu3nma0'; $audio = urlencode($crypt->encrypt($audio,$REC_CRYPT_PASSWORD)); $recurl=$_SERVER['PHP_SELF']."?display=recordings&action=popup&recordingpath=$audio&recording="; $html_txt .= ""; $html_txt .= ""; $html_txt .= ""; if ($count==0) { $html_txt .= "\n"; } else { $html_txt .= ""; $html_txt .= ""; $html_txt .= "\n"; } if ($count > $max) { $html_txt .= "\n"; } else { $html_txt .= ""; $html_txt .= "\n"; $html_txt .= ""; $html_txt .= "\n"; } $html_txt .= "\n"; $html_txt .= ""; $html_txt .= ""; $html_txt .= "\n"; $html_txt .= "\n"; return $html_txt; } ?>