| 1 |
<?php |
|---|
| 2 |
/* $Id$ */ |
|---|
| 3 |
//Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca) |
|---|
| 4 |
// |
|---|
| 5 |
//Re-written by Rob Thomas <xrobau@gmail.com> 20060318. |
|---|
| 6 |
// |
|---|
| 7 |
//This program is free software; you can redistribute it and/or |
|---|
| 8 |
//modify it under the terms of the GNU General Public License |
|---|
| 9 |
//as published by the Free Software Foundation; either version 2 |
|---|
| 10 |
//of the License, or (at your option) any later version. |
|---|
| 11 |
// |
|---|
| 12 |
//This program is distributed in the hope that it will be useful, |
|---|
| 13 |
//but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 14 |
//MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 15 |
//GNU General Public License for more details. |
|---|
| 16 |
|
|---|
| 17 |
$action = isset($_REQUEST['action'])?$_REQUEST['action']:''; |
|---|
| 18 |
|
|---|
| 19 |
// Lite weight popup code here, don't need everything else below |
|---|
| 20 |
// |
|---|
| 21 |
switch ($action) { |
|---|
| 22 |
case 'popup': |
|---|
| 23 |
case 'audio': |
|---|
| 24 |
include_once("$action.php"); |
|---|
| 25 |
exit; |
|---|
| 26 |
break; |
|---|
| 27 |
default: |
|---|
| 28 |
break; |
|---|
| 29 |
} |
|---|
| 30 |
$id = isset($_REQUEST['id'])?$_REQUEST['id']:''; |
|---|
| 31 |
$notes = isset($_REQUEST['notes'])?$_REQUEST['notes']:''; |
|---|
| 32 |
$rname = isset($_REQUEST['rname'])?$_REQUEST['rname']:''; |
|---|
| 33 |
$usersnum = isset($_REQUEST['usersnum'])?$_REQUEST['usersnum']:''; |
|---|
| 34 |
$sysrec = isset($_REQUEST['sysrec'])?$_REQUEST['sysrec']:''; |
|---|
| 35 |
$suffix = isset($_REQUEST['suffix']) && trim($_REQUEST['suffix'] != "") ? $_REQUEST['suffix'] : 'wav'; |
|---|
| 36 |
|
|---|
| 37 |
$fcode = isset($_REQUEST['fcode']) && $_REQUEST['fcode'] != '' ? 1 : 0; |
|---|
| 38 |
$fcode_pass = isset($_REQUEST['fcode_pass'])?$_REQUEST['fcode_pass']:''; |
|---|
| 39 |
|
|---|
| 40 |
$fcbase = '*29'; |
|---|
| 41 |
$default_pos = 0; |
|---|
| 42 |
|
|---|
| 43 |
$astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; |
|---|
| 44 |
$astsnd .= "/sounds/"; |
|---|
| 45 |
|
|---|
| 46 |
if (empty($usersnum)) { |
|---|
| 47 |
$dest = "unnumbered-"; |
|---|
| 48 |
} else { |
|---|
| 49 |
$dest = "{$usersnum}-"; |
|---|
| 50 |
} |
|---|
| 51 |
|
|---|
| 52 |
// get feature codes for diplay purposes |
|---|
| 53 |
$fcc = new featurecode('recordings', 'record_save'); |
|---|
| 54 |
$fc_save = $fcc->getCodeActive(); |
|---|
| 55 |
unset($fcc); |
|---|
| 56 |
$fcc = new featurecode('recordings', 'record_check'); |
|---|
| 57 |
$fc_check = $fcc->getCodeActive(); |
|---|
| 58 |
unset($fcc); |
|---|
| 59 |
$fc_save = ($fc_save != '' ? $fc_save : _('** MISSING FEATURE CODE **')); |
|---|
| 60 |
$fc_check = ($fc_check != '' ? $fc_check : _('** MISSING FEATURE CODE **')); |
|---|
| 61 |
|
|---|
| 62 |
switch ($action) { |
|---|
| 63 |
|
|---|
| 64 |
case "system": |
|---|
| 65 |
recording_sidebar(-1, null); |
|---|
| 66 |
recording_sysfiles(); |
|---|
| 67 |
break; |
|---|
| 68 |
case "newsysrec": |
|---|
| 69 |
$sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1); |
|---|
| 70 |
if (recordings_add($sysrecs[$sysrec], $sysrecs[$sysrec])) { |
|---|
| 71 |
$id = recordings_get_id($sysrecs[$sysrec]); |
|---|
| 72 |
} else { |
|---|
| 73 |
$id = 0; |
|---|
| 74 |
} |
|---|
| 75 |
recording_sidebar($id, null); |
|---|
| 76 |
recording_editpage($id, null); |
|---|
| 77 |
break; |
|---|
| 78 |
case "recorded": |
|---|
| 79 |
// Clean up the filename, take out any nasty characters |
|---|
| 80 |
$filename = escapeshellcmd(strtr($rname, '/ ', '__')); |
|---|
| 81 |
if (!file_exists($astsnd."custom")) { |
|---|
| 82 |
if (!mkdir($astsnd."custom", 0775)) { |
|---|
| 83 |
echo '<div class="content"><h5>'._("Failed to create").' '.$astsnd.'custom'.'</h5>'; |
|---|
| 84 |
} |
|---|
| 85 |
} else { |
|---|
| 86 |
// can't rename a file from one partition to another, must use mv or cp |
|---|
| 87 |
// rename($recordings_save_path."{$dest}ivrrecording.wav",$recordings_astsnd_path."custom/{$filename}.wav"); |
|---|
| 88 |
if (!file_exists($recordings_save_path."{$dest}ivrrecording.$suffix")) { |
|---|
| 89 |
echo "<hr><h5>"._("[ERROR] The Recorded File Does Not exists:")."</h5>"; |
|---|
| 90 |
echo $recordings_save_path."{$dest}ivrrecording.$suffix<br><br>"; |
|---|
| 91 |
echo "make sure you uploaded or recorded a file with the entered extension<hr>"; |
|---|
| 92 |
} else { |
|---|
| 93 |
exec("cp " . $recordings_save_path . "{$dest}ivrrecording.$suffix " . $astsnd."custom/{$filename}.$suffix 2>&1", $outarray, $ret); |
|---|
| 94 |
if (!$ret) { |
|---|
| 95 |
$isok = recordings_add($rname, "custom/{$filename}.$suffix"); |
|---|
| 96 |
} else { |
|---|
| 97 |
echo "<hr><h5>"._("[ERROR] SAVING RECORDING:")."</h5>"; |
|---|
| 98 |
foreach ($outarray as $line) { |
|---|
| 99 |
echo "$line<br>"; |
|---|
| 100 |
} |
|---|
| 101 |
echo _("Make sure you have entered a proper name"); |
|---|
| 102 |
echo "<hr>"; |
|---|
| 103 |
} |
|---|
| 104 |
exec("rm " . $recordings_save_path . "{$dest}ivrrecording.$suffix ", $outarray, $ret); |
|---|
| 105 |
if ($ret) { |
|---|
| 106 |
echo "<hr><h5>"._("[ERROR] REMOVING TEMPORARY RECORDING:")."</h5>"; |
|---|
| 107 |
foreach ($outarray as $line) { |
|---|
| 108 |
echo "$line<br>"; |
|---|
| 109 |
} |
|---|
| 110 |
echo _("Make sure Asterisk is not running as root "); |
|---|
| 111 |
echo "<hr>"; |
|---|
| 112 |
} |
|---|
| 113 |
} |
|---|
| 114 |
|
|---|
| 115 |
recording_sidebar(null, $usersnum); |
|---|
| 116 |
recording_addpage($usersnum); |
|---|
| 117 |
if ($isok) |
|---|
| 118 |
echo '<div class="content"><h5>'._("System Recording").' "'.$rname.'" '._("Saved").'!</h5>'; |
|---|
| 119 |
} |
|---|
| 120 |
break; |
|---|
| 121 |
|
|---|
| 122 |
case "edit": |
|---|
| 123 |
$arr = recordings_get($id); |
|---|
| 124 |
$filename=$arr['filename']; |
|---|
| 125 |
// Check all possibilities of uploaded file types. |
|---|
| 126 |
$valid = Array("au","g723","g723sf","g729","gsm","h263","ilbc","mp3","ogg","pcm","alaw","ulaw","al","ul","mu","sln","raw","vox","WAV","wav","wav49"); |
|---|
| 127 |
$fileexists = false; |
|---|
| 128 |
if (strpos($filename, '&') === false) { |
|---|
| 129 |
foreach ($valid as $xtn) { |
|---|
| 130 |
$checkfile = $recordings_astsnd_path.$filename.".".$xtn; |
|---|
| 131 |
if (file_exists($checkfile)) { |
|---|
| 132 |
$suffix = substr(strrchr($filename, "."), 1); |
|---|
| 133 |
copy($checkfile, $recordings_save_path."{$dest}ivrrecording.".$suffix); |
|---|
| 134 |
$fileexists = true; |
|---|
| 135 |
} |
|---|
| 136 |
} |
|---|
| 137 |
if ($fileexists === false) { |
|---|
| 138 |
echo '<div class="content"><h5>'._("Unable to locate").' '.$recordings_astsnd_path.$filename.' '._("with a a valid suffix").'</h5>'; |
|---|
| 139 |
} |
|---|
| 140 |
} |
|---|
| 141 |
|
|---|
| 142 |
recording_sidebar($id, $usersnum); |
|---|
| 143 |
recording_editpage($id, $usersnum); |
|---|
| 144 |
break; |
|---|
| 145 |
|
|---|
| 146 |
case "edited": |
|---|
| 147 |
recordings_update($id, $rname, $notes, $_REQUEST, $fcode, $fcode_pass); |
|---|
| 148 |
recording_sidebar($id, $usersnum); |
|---|
| 149 |
recording_editpage($id, $usersnum); |
|---|
| 150 |
echo '<div class="content"><h5>'._("System Recording").' "'.$rname.'" '._("Updated").'!</h5></div>'; |
|---|
| 151 |
needreload(); |
|---|
| 152 |
break; |
|---|
| 153 |
|
|---|
| 154 |
case "delete"; |
|---|
| 155 |
recordings_del($id); |
|---|
| 156 |
needreload(); |
|---|
| 157 |
|
|---|
| 158 |
default: |
|---|
| 159 |
recording_sidebar($id, $usersnum); |
|---|
| 160 |
recording_addpage($usersnum); |
|---|
| 161 |
break; |
|---|
| 162 |
|
|---|
| 163 |
} |
|---|
| 164 |
|
|---|
| 165 |
function recording_addpage($usersnum) { |
|---|
| 166 |
global $fc_save; |
|---|
| 167 |
global $fc_check; |
|---|
| 168 |
global $recordings_save_path; |
|---|
| 169 |
|
|---|
| 170 |
?> |
|---|
| 171 |
<div class="content"> |
|---|
| 172 |
<h2><?php echo _("System Recordings")?></h2> |
|---|
| 173 |
<h3><?php echo _("Add Recording") ?></h3> |
|---|
| 174 |
<h5><?php echo _("Step 1: Record or upload")?></h5> |
|---|
| 175 |
<p> <?php if (!empty($usersnum)) { |
|---|
| 176 |
echo _("Using your phone,")."<a href=\"#\" class=\"info\">"._("dial")." ".$fc_save." <span>"; |
|---|
| 177 |
echo _("Start speaking at the tone. Hangup when finished.")."</span></a>"; |
|---|
| 178 |
echo _("and speak the message you wish to record.")."\n"; |
|---|
| 179 |
} else { ?> |
|---|
| 180 |
<form name="xtnprompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> |
|---|
| 181 |
<input type="hidden" name="display" value="recordings"> |
|---|
| 182 |
<?php |
|---|
| 183 |
echo _("If you wish to make and verify recordings from your phone, please enter your extension number here:"); ?> |
|---|
| 184 |
<input type="text" size="6" name="usersnum" tabindex="<?php echo ++$tabindex;?>"> <input name="Submit" type="submit" value="<?php echo _("Go"); ?>" tabindex="<?php echo ++$tabindex;?>"> |
|---|
| 185 |
</form> |
|---|
| 186 |
<?php } ?> |
|---|
| 187 |
</p> |
|---|
| 188 |
<p> |
|---|
| 189 |
<form enctype="multipart/form-data" name="upload" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST"/> |
|---|
| 190 |
<?php echo _("Alternatively, upload a recording in")?> <?php echo _("any supported asterisk format.")?> <?php echo _("Note that if you're using .wav, (eg, recorded with Microsoft Recorder) the file <b>must</b> be PCM Encoded, 16 Bits, at 8000Hz")?></span></a>:<br> |
|---|
| 191 |
<input type="hidden" name="display" value="recordings"> |
|---|
| 192 |
<input type="hidden" name="action" value="recordings_start"> |
|---|
| 193 |
<input type="hidden" name="usersnum" value="<?php echo $usersnum ?>"> |
|---|
| 194 |
<input type="file" name="ivrfile" tabindex="<?php echo ++$tabindex;?>"/> |
|---|
| 195 |
<input type="button" value="<?php echo _("Upload")?>" onclick="document.upload.submit(upload);alert('<?php echo addslashes(_("Please wait until the page reloads."))?>');" tabindex="<?php echo ++$tabindex;?>"/> |
|---|
| 196 |
</form> |
|---|
| 197 |
<?php |
|---|
| 198 |
if (isset($_FILES['ivrfile']['tmp_name']) && is_uploaded_file($_FILES['ivrfile']['tmp_name'])) { |
|---|
| 199 |
if (empty($usersnum)) { |
|---|
| 200 |
$dest = "unnumbered-"; |
|---|
| 201 |
} else { |
|---|
| 202 |
$dest = "{$usersnum}-"; |
|---|
| 203 |
} |
|---|
| 204 |
$suffix = substr(strrchr($_FILES['ivrfile']['name'], "."), 1); |
|---|
| 205 |
$destfilename = $recordings_save_path.$dest."ivrrecording.".$suffix; |
|---|
| 206 |
move_uploaded_file($_FILES['ivrfile']['tmp_name'], $destfilename); |
|---|
| 207 |
system("chgrp asterisk ".$destfilename); |
|---|
| 208 |
system("chmod g+rw ".$destfilename); |
|---|
| 209 |
echo "<h6>"._("Successfully uploaded")." ".$_FILES['ivrfile']['name']."</h6>"; |
|---|
| 210 |
$rname = rtrim(basename($_FILES['ivrfile']['name'], $suffix), '.'); |
|---|
| 211 |
} ?> |
|---|
| 212 |
</p> |
|---|
| 213 |
<form name="prompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return rec_onsubmit();"> |
|---|
| 214 |
<input type="hidden" name="action" value="recorded"> |
|---|
| 215 |
<input type="hidden" name="display" value="recordings"> |
|---|
| 216 |
<input type="hidden" name="usersnum" value="<?php echo $usersnum ?>"> |
|---|
| 217 |
<?php |
|---|
| 218 |
if (!empty($usersnum)) { ?> |
|---|
| 219 |
<h5><?php echo _("Step 2: Verify")?></h5> |
|---|
| 220 |
<p> <?php echo _("After recording or uploading,")." <em>"._("dial")." ".$fc_check."</em> "._("to listen to your recording.")?> </p> |
|---|
| 221 |
<p> <?php echo _("If you wish to re-record your message, dial")." ".$fc_save; ?></p> |
|---|
| 222 |
<h5><?php echo _("Step 3: Name")?> </h5> <?php |
|---|
| 223 |
} else { |
|---|
| 224 |
echo "<h5>"._("Step 2: Name")."</h5>"; |
|---|
| 225 |
} ?> |
|---|
| 226 |
<table style="text-align:right;"> |
|---|
| 227 |
<tr valign="top"> |
|---|
| 228 |
<td valign="top"><?php echo _("Name this Recording")?>: </td> |
|---|
| 229 |
<td style="text-align:left"><input type="text" name="rname" value="<?php echo $rname; ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 230 |
</tr> |
|---|
| 231 |
</table> |
|---|
| 232 |
|
|---|
| 233 |
<h6><?php |
|---|
| 234 |
echo _("Click \"SAVE\" when you are satisfied with your recording"); |
|---|
| 235 |
echo "<input type=\"hidden\" name=\"suffix\" value=\"$suffix\">\n"; ?> |
|---|
| 236 |
<input name="Submit" type="submit" value="<?php echo _("Save")?>" tabindex="<?php echo ++$tabindex;?>"></h6> |
|---|
| 237 |
<?php recordings_form_jscript(); ?> |
|---|
| 238 |
</form> |
|---|
| 239 |
</div> |
|---|
| 240 |
<?php |
|---|
| 241 |
} |
|---|
| 242 |
|
|---|
| 243 |
function recording_editpage($id, $num) { |
|---|
| 244 |
global $fcbase; |
|---|
| 245 |
global $default_pos; |
|---|
| 246 |
global $fcode; |
|---|
| 247 |
global $fcode_pass; |
|---|
| 248 |
global $recordings_astsnd_path; |
|---|
| 249 |
?> |
|---|
| 250 |
<div class="content"> |
|---|
| 251 |
<h2><?php echo _("System Recordings")?></h2> |
|---|
| 252 |
<h3><?php echo _("Edit Recording") ?></h3> |
|---|
| 253 |
<?php |
|---|
| 254 |
$this_recording = recordings_get($id); |
|---|
| 255 |
if (!$this_recording) { |
|---|
| 256 |
echo "<tr><td colspan=2><h2>Error reading Recording ID $id - Aborting</h2></td></tr></table>"; |
|---|
| 257 |
return; |
|---|
| 258 |
}?> |
|---|
| 259 |
<?php |
|---|
| 260 |
$usage_list = recordings_list_usage($id); |
|---|
| 261 |
if (count($usage_list)) { |
|---|
| 262 |
?> |
|---|
| 263 |
<a href="#" class="info"><?php echo _("Usage List");?><span><?php echo _("This recording is being used in the following instances. You can not remove this recording while being used. To re-record, you can enable and use the feature code below if allowed.");?></span></a> |
|---|
| 264 |
<?php |
|---|
| 265 |
$count = 0; |
|---|
| 266 |
foreach ($usage_list as $link) { |
|---|
| 267 |
$label = '<span><img width="16" height="16" border="0" title="'.$link['description'].'" alt="" src="images/application_link.png"/> '.$link['description'].'</span>'; |
|---|
| 268 |
echo "<br /><a href=".$link['url_query'].">".$label."</a>"; |
|---|
| 269 |
} |
|---|
| 270 |
} else { |
|---|
| 271 |
$delURL = "config.php?display=recordings&action=delete&usersnum=".urlencode($num)."&id=$id"; |
|---|
| 272 |
$tlabel = _("Remove Recording"); |
|---|
| 273 |
$label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/sound_delete.png"/> '.$tlabel.'</span>'; |
|---|
| 274 |
echo "<a href=".$delURL.">".$label."</a>"; |
|---|
| 275 |
echo "<i style='font-size: x-small'> ("; |
|---|
| 276 |
echo _("Note, does not delete file from computer"); |
|---|
| 277 |
echo ")</i>"; |
|---|
| 278 |
} |
|---|
| 279 |
?> |
|---|
| 280 |
<form name="prompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return rec_onsubmit();"> |
|---|
| 281 |
<input type="hidden" name="action" value="edited"> |
|---|
| 282 |
<input type="hidden" name="display" value="recordings"> |
|---|
| 283 |
<input type="hidden" name="usersnum" value="<?php echo $num ?>"> |
|---|
| 284 |
<input type="hidden" name="id" value="<?php echo $id ?>"> |
|---|
| 285 |
<table> |
|---|
| 286 |
<tr><td colspan=2><hr></td></tr> |
|---|
| 287 |
<tr> |
|---|
| 288 |
<td><a href="#" class="info"><?php echo _("Change Name");?><span><?php echo _("This changes the short name, visible on the right, of this recording");?></span></a></td> |
|---|
| 289 |
<td><input type="text" name="rname" value="<?php echo $this_recording['displayname'] ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 290 |
</tr> |
|---|
| 291 |
<tr> |
|---|
| 292 |
<td><a href="#" class="info"><?php echo _("Descriptive Name");?><span><?php echo _("This is displayed, as a hint, when selecting this recording in Queues, Digital Receptionist, etc");?></span></a></td> |
|---|
| 293 |
<td> <textarea name="notes" rows="3" cols="40" tabindex="<?php echo ++$tabindex;?>"><?php echo $this_recording['description'] ?></textarea></td> |
|---|
| 294 |
</tr> |
|---|
| 295 |
|
|---|
| 296 |
<?php |
|---|
| 297 |
// This was being called twice: $rec = recordings_get($id); |
|---|
| 298 |
$rec = $this_recording; |
|---|
| 299 |
$fn = $rec['filename']; |
|---|
| 300 |
$files = explode('&', $fn); |
|---|
| 301 |
$counter = 0; |
|---|
| 302 |
$arraymax = count($files)-1; |
|---|
| 303 |
$sndfile_html = ""; |
|---|
| 304 |
foreach ($files as $item) { |
|---|
| 305 |
$sndfile_html .= recordings_display_sndfile($item, $counter, $arraymax, $recordings_astsnd_path, $rec['fcode']); |
|---|
| 306 |
$counter++; |
|---|
| 307 |
} |
|---|
| 308 |
$sndfile_html .= recordings_display_sndfile('', $counter, $arraymax, $recordings_astsnd_path, $rec['fcode']); |
|---|
| 309 |
if ($arraymax == 0 && isset($files[0]) && substr($files[0],0,7) == 'custom/') { |
|---|
| 310 |
?> |
|---|
| 311 |
<tr> |
|---|
| 312 |
<td><a class="info" href="#"><?php echo _("Link to Feature Code")?><span><?php echo _("Check this box to create an options feature code that will allow this recording to be changed directly.")?></span></a>: |
|---|
| 313 |
</td> |
|---|
| 314 |
<td> |
|---|
| 315 |
<input type='checkbox' tabindex="<?php echo ++$tabindex;?>"name='fcode' id="fcode" <?php if ($rec['fcode']=="1") { echo 'CHECKED'; }?> OnClick="resetDefaultSound();"; return true;'><?php echo sprintf(_("Optional Feature Code %s"),$fcbase.$id)?> |
|---|
| 316 |
</td> |
|---|
| 317 |
</tr> |
|---|
| 318 |
<tr> |
|---|
| 319 |
<td><a href="#" class="info"><?php echo _("Feature Code Password");?><span><?php echo _("Optional password to protect access to this feature code which allows a user to re-record it.");?></span></a></td> |
|---|
| 320 |
<td><input type="text" name="fcode_pass" id="fcode_pass" value="<?php echo $rec['fcode_pass'] ?>" tabindex="<?php echo ++$tabindex;?>"></td> |
|---|
| 321 |
</tr> |
|---|
| 322 |
<?php |
|---|
| 323 |
} else { |
|---|
| 324 |
?> |
|---|
| 325 |
<tr> |
|---|
| 326 |
<td colspan="2"><a class="info" href="#"><?php echo _("Direct Access Feature Code Not Available")?><span><?php echo _("Direct Access Feature Codes for recordings are not available for built in system recordings or compound recordings made of multiple individual ones.")?></span></a>: |
|---|
| 327 |
</td> |
|---|
| 328 |
</tr> |
|---|
| 329 |
<?php |
|---|
| 330 |
} |
|---|
| 331 |
?> |
|---|
| 332 |
|
|---|
| 333 |
<tr><td colspan="2"><hr /></td></tr> |
|---|
| 334 |
</table> |
|---|
| 335 |
<?php echo _("Files");?>:<br /> |
|---|
| 336 |
<table> |
|---|
| 337 |
<?php |
|---|
| 338 |
// globals seem to busted in PHP5 define here for now |
|---|
| 339 |
$recordings_astsnd_path = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; |
|---|
| 340 |
$recordings_astsnd_path .= "/sounds/"; |
|---|
| 341 |
|
|---|
| 342 |
// recordings_display_sndfile functions need to be run above so we have $default_pos set |
|---|
| 343 |
// |
|---|
| 344 |
echo $sndfile_html; |
|---|
| 345 |
?> |
|---|
| 346 |
</table> |
|---|
| 347 |
<input name="Submit" type="submit" value="<?php echo _("Save")?>" tabindex="<?php echo ++$tabindex;?>"></h6> |
|---|
| 348 |
<?php recordings_popup_jscript(); ?> |
|---|
| 349 |
<?php recordings_form_jscript(); ?> |
|---|
| 350 |
<script language="javascript"> |
|---|
| 351 |
<!-- Begin |
|---|
| 352 |
var sysrec0_idx; |
|---|
| 353 |
function initPage() { |
|---|
| 354 |
sysrec0_idx = document.getElementById("sysrec0").selectedIndex; |
|---|
| 355 |
alert('Got here with sysrec0_idx as:'.sysrec0_idx); |
|---|
| 356 |
} |
|---|
| 357 |
function resetDefaultSound() { |
|---|
| 358 |
if (document.getElementById('fcode').checked) { |
|---|
| 359 |
document.getElementById('sysrec0').selectedIndex=<?php echo $default_pos ?>; |
|---|
| 360 |
document.getElementById('sysrec1').selectedIndex=0; |
|---|
| 361 |
|
|---|
| 362 |
document.getElementById('sysrec0').disabled=true; |
|---|
| 363 |
document.getElementById('sysrec1').disabled=true; |
|---|
| 364 |
document.getElementById('play1').style.visibility='hidden'; |
|---|
| 365 |
document.getElementById('down0').style.visibility='hidden'; |
|---|
| 366 |
document.getElementById('up1').style.visibility='hidden'; |
|---|
| 367 |
document.getElementById('del0').style.visibility='hidden'; |
|---|
| 368 |
document.getElementById('del1').style.visibility='hidden'; |
|---|
| 369 |
} else { |
|---|
| 370 |
document.getElementById('sysrec0').disabled=false; |
|---|
| 371 |
document.getElementById('sysrec1').disabled=false; |
|---|
| 372 |
document.getElementById('play1').style.visibility='visible'; |
|---|
| 373 |
document.getElementById('down0').style.visibility='visible'; |
|---|
| 374 |
document.getElementById('up1').style.visibility='visible'; |
|---|
| 375 |
document.getElementById('del0').style.visibility='visible'; |
|---|
| 376 |
document.getElementById('del1').style.visibility='visible'; |
|---|
| 377 |
} |
|---|
| 378 |
} |
|---|
| 379 |
// End --> |
|---|
| 380 |
</script> |
|---|
| 381 |
</form> |
|---|
| 382 |
</div> |
|---|
| 383 |
<?php |
|---|
| 384 |
} |
|---|
| 385 |
|
|---|
| 386 |
function recording_sidebar($id, $num) { |
|---|
| 387 |
?> |
|---|
| 388 |
<div class="rnav"><ul> |
|---|
| 389 |
<li><a id="<?php echo empty($id)?'current':'nul' ?>" href="config.php?display=recordings&usersnum=<?php echo urlencode($num) ?>"><?php echo _("Add Recording")?></a></li> |
|---|
| 390 |
<li><a id="<?php echo ($id===-1)?'current':'nul' ?>" href="config.php?display=recordings&action=system"><?php echo _("Built-in Recordings")?></a></li> |
|---|
| 391 |
<?php |
|---|
| 392 |
$wrapat = 18; |
|---|
| 393 |
$tresults = recordings_list(); |
|---|
| 394 |
if (isset($tresults)){ |
|---|
| 395 |
foreach ($tresults as $tresult) { |
|---|
| 396 |
echo "<li>"; |
|---|
| 397 |
echo "<a id=\"".($id==$tresult[0] ? 'current':'nul')."\" href=\"config.php?display=recordings&"; |
|---|
| 398 |
echo "action=edit&"; |
|---|
| 399 |
echo "usersnum=".urlencode($num)."&"; |
|---|
| 400 |
// echo "filename=".urlencode($tresult[2])."&"; |
|---|
| 401 |
echo "id={$tresult[0]}\">"; |
|---|
| 402 |
$dispname = $tresult[1]; |
|---|
| 403 |
while (strlen($dispname) > (1+$wrapat)) { |
|---|
| 404 |
$part = substr($dispname, 0, $wrapat); |
|---|
| 405 |
echo htmlspecialchars($part); |
|---|
| 406 |
$dispname = substr($dispname, $wrapat); |
|---|
| 407 |
if ($dispname != '') |
|---|
| 408 |
echo "<br>"; |
|---|
| 409 |
} |
|---|
| 410 |
echo htmlspecialchars($dispname); |
|---|
| 411 |
echo "</a>"; |
|---|
| 412 |
echo "</li>\n"; |
|---|
| 413 |
} |
|---|
| 414 |
} |
|---|
| 415 |
echo "</ul></div>\n"; |
|---|
| 416 |
} |
|---|
| 417 |
|
|---|
| 418 |
function recordings_popup_jscript() { |
|---|
| 419 |
?> |
|---|
| 420 |
<script language="javascript"> |
|---|
| 421 |
<!-- Begin |
|---|
| 422 |
function popUp(URL,optionId) { |
|---|
| 423 |
var selIndex=optionId.selectedIndex |
|---|
| 424 |
var file=encodeURIComponent(optionId.options[selIndex].value) |
|---|
| 425 |
|
|---|
| 426 |
/*alert(selIndex);*/ |
|---|
| 427 |
if (file != "") |
|---|
| 428 |
popup = window.open(URL+file, 'play', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=320,height=110'); |
|---|
| 429 |
} |
|---|
| 430 |
// End --> |
|---|
| 431 |
</script> |
|---|
| 432 |
<?php |
|---|
| 433 |
} |
|---|
| 434 |
|
|---|
| 435 |
function recordings_form_jscript() { |
|---|
| 436 |
?> |
|---|
| 437 |
<script language="javascript"> |
|---|
| 438 |
<!-- |
|---|
| 439 |
|
|---|
| 440 |
var theForm = document.prompt; |
|---|
| 441 |
|
|---|
| 442 |
function rec_onsubmit() { |
|---|
| 443 |
var msgInvalidFilename = "<?php echo _("Please enter a valid Name for this System Recording"); ?>"; |
|---|
| 444 |
|
|---|
| 445 |
defaultEmptyOK = false; |
|---|
| 446 |
if (!isFilename(theForm.rname.value)) |
|---|
| 447 |
return warnInvalid(theForm.rname, msgInvalidFilename); |
|---|
| 448 |
|
|---|
| 449 |
return true; |
|---|
| 450 |
} |
|---|
| 451 |
|
|---|
| 452 |
//--> |
|---|
| 453 |
</script> |
|---|
| 454 |
|
|---|
| 455 |
<?php |
|---|
| 456 |
} |
|---|
| 457 |
|
|---|
| 458 |
function recording_sysfiles() { |
|---|
| 459 |
$astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; |
|---|
| 460 |
$astsnd .= "/sounds/"; |
|---|
| 461 |
$sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1); |
|---|
| 462 |
?> |
|---|
| 463 |
<div class="content"> |
|---|
| 464 |
<h2><?php echo _("System Recordings")?></h2> |
|---|
| 465 |
<h3><?php echo _("Built-in Recordings") ?></h3> |
|---|
| 466 |
<h5><?php echo _("Select System Recording:")?></h5> |
|---|
| 467 |
<form name="xtnprompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post"> |
|---|
| 468 |
<input type="hidden" name="action" value="newsysrec"> |
|---|
| 469 |
<input type="hidden" name="display" value="recordings"> |
|---|
| 470 |
<select name="sysrec"> |
|---|
| 471 |
<?php |
|---|
| 472 |
foreach ($sysrecs as $srcount => $sr) { |
|---|
| 473 |
// echo '<option value="'.$vmc.'"'.($vmc == $ivr_details['dircontext'] ? ' SELECTED' : '').'>'.$vmc."</option>\n"; |
|---|
| 474 |
echo "<option value=\"$srcount\">$sr</option>\n"; |
|---|
| 475 |
} |
|---|
| 476 |
?> |
|---|
| 477 |
</select> |
|---|
| 478 |
<input name="Submit" type="submit" value="<?php echo _("Go"); ?>"> |
|---|
| 479 |
<p /> |
|---|
| 480 |
</div> |
|---|
| 481 |
<?php |
|---|
| 482 |
} |
|---|
| 483 |
|
|---|
| 484 |
function recordings_display_sndfile($item, $count, $max, $astpath, $fcode) { |
|---|
| 485 |
global $default_pos; |
|---|
| 486 |
global $amp_conf; |
|---|
| 487 |
|
|---|
| 488 |
$disabled_state = $fcode == 0 ? "" : "disabled='true' "; |
|---|
| 489 |
$hidden_state = $fcode == 0 ? "" : "style='visibility:hidden' "; |
|---|
| 490 |
|
|---|
| 491 |
$html_text = ""; |
|---|
| 492 |
// Note that when using this, it needs a <table> definition around it. |
|---|
| 493 |
$astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk'; |
|---|
| 494 |
$astsnd .= "/sounds/"; |
|---|
| 495 |
$sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1); |
|---|
| 496 |
$html_txt .= "<tr><td><select $disabled_state id='sysrec$count' name='sysrec$count'>\n"; |
|---|
| 497 |
$html_txt .= '<option value=""'.($item == '' ? ' SELECTED' : '')."></option>\n"; |
|---|
| 498 |
$index=0; |
|---|
| 499 |
foreach ($sysrecs as $sr) { |
|---|
| 500 |
$html_txt .= '<option value="'.$sr.'"'.($sr == $item ? ' SELECTED' : '').">$sr</option>\n"; |
|---|
| 501 |
if ($sr == $item) { |
|---|
| 502 |
$default_pos = $index+1; |
|---|
| 503 |
} |
|---|
| 504 |
$index++; |
|---|
| 505 |
} |
|---|
| 506 |
$html_txt .= "</select></td>\n"; |
|---|
| 507 |
|
|---|
| 508 |
$html_txt .= "<td>"; |
|---|
| 509 |
$audio=$astpath; |
|---|
| 510 |
|
|---|
| 511 |
include_once("crypt.php"); |
|---|
| 512 |
$crypt = new Crypt(); |
|---|
| 513 |
$REC_CRYPT_PASSWORD = (isset($amp_conf['AMPPLAYKEY']) && trim($amp_conf['AMPPLAYKEY']) != "")?trim($amp_conf['AMPPLAYKEY']):'moufdsuu3nma0'; |
|---|
| 514 |
$audio = urlencode($crypt->encrypt($audio,$REC_CRYPT_PASSWORD)); |
|---|
| 515 |
$recurl=$_SERVER['PHP_SELF']."?display=recordings&action=popup&recordingpath=$audio&recording="; |
|---|
| 516 |
|
|---|
| 517 |
$html_txt .= "<a href='#' ".(($count)?$hidden_state:'')." type='submit' id='play$count' onClick=\"javascript:popUp('$recurl',document.prompt.sysrec$count); return false;\" input='foo'>"; |
|---|
| 518 |
$html_txt .= "<img border='0' width='20' height='20' src='images/play.png' title='"._("Click here to play this recording")."' />"; |
|---|
| 519 |
$html_txt .= "</img></td>"; |
|---|
| 520 |
|
|---|
| 521 |
if ($count==0) { |
|---|
| 522 |
$html_txt .= "<td></td>\n"; |
|---|
| 523 |
} else { |
|---|
| 524 |
$html_txt .= "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; |
|---|
| 525 |
$html_txt .= "<td><input $hidden_state name='up$count' id='up$count' width=10 height=20 border=5 title='"._("Move Up")."' type='image' src='images/scrollup.gif' value='"._("Move Up")."'>"; |
|---|
| 526 |
$html_txt .= "</td>\n"; |
|---|
| 527 |
} if ($count > $max) { |
|---|
| 528 |
$html_txt .= "<td></td>\n"; |
|---|
| 529 |
} else { |
|---|
| 530 |
$html_txt .= "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; |
|---|
| 531 |
$html_txt .= "<td><input $hidden_state name='down$count' id='down$count' width=10 height=20 border=0 title='"._("Move Down")."' type='image' src='images/scrolldown.gif' value='"._("Move Down")."'>\n"; |
|---|
| 532 |
$html_txt .= "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; |
|---|
| 533 |
$html_txt .= "</td>\n"; |
|---|
| 534 |
} |
|---|
| 535 |
$html_txt .= "<td><input $hidden_state name='del$count' id='del$count' type='image' border=0 title='"._("Delete")."' src='images/trash.png' value='"._("Delete")."'>\n"; |
|---|
| 536 |
$html_txt .= "<img border='0' width='9' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; |
|---|
| 537 |
$html_txt .= "<img border='0' width='9' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />"; |
|---|
| 538 |
$html_txt .= "</td>\n"; |
|---|
| 539 |
|
|---|
| 540 |
$html_txt .= "</tr>\n"; |
|---|
| 541 |
return $html_txt; |
|---|
| 542 |
} |
|---|
| 543 |
|
|---|
| 544 |
?> |
|---|