root/modules/branches/2.9/recordings/page.recordings.php

Revision 10347, 23.8 kB (checked in by p_lindheimer, 3 years ago)

Merged revisions 10305-10346 via svnmerge from
http://svn.freepbx.org/modules/branches/2.8

........

r10308 | p_lindheimer | 2010-09-23 11:37:02 -0700 (Thu, 23 Sep 2010) | 1 line


Module Publish Script: recordings 3.3.10.1

........

r10325 | mickecarlsson | 2010-09-27 11:00:45 -0700 (Mon, 27 Sep 2010) | 1 line


Re #4555, updated russian language for language module. Thank you ded.

........

r10326 | mickecarlsson | 2010-09-27 11:02:38 -0700 (Mon, 27 Sep 2010) | 1 line


Close #4555, updated russian language for fax module. Thank you ded.

........

r10338 | p_lindheimer | 2010-10-04 11:04:54 -0700 (Mon, 04 Oct 2010) | 1 line


fixes #4568 better validation

........

r10345 | p_lindheimer | 2010-10-04 11:21:35 -0700 (Mon, 04 Oct 2010) | 1 line


update module.xml re #4568

........

r10346 | p_lindheimer | 2010-10-04 11:30:31 -0700 (Mon, 04 Oct 2010) | 1 line


revert most of r10345 checked-in in error (still work in progress)

........

  • Property svn:mime-type set to text/html
  • Property svn:eol-style set to native
  • Property svn:eol-type set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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 // check ctype_digit() to avoid very obscure vulnerability that can be made if certain proxy's are used
47 // with the PBX system
48 if (empty($usersnum) || !ctype_digit($usersnum)) {
49   $dest = "unnumbered-";
50 } else {
51   $dest = "{$usersnum}-";
52 }
53
54 // get feature codes for diplay purposes
55 $fcc = new featurecode('recordings', 'record_save');
56 $fc_save = $fcc->getCodeActive();
57 unset($fcc);
58 $fcc = new featurecode('recordings', 'record_check');
59 $fc_check = $fcc->getCodeActive();
60 unset($fcc);
61 $fc_save = ($fc_save != '' ? $fc_save : _('** MISSING FEATURE CODE **'));
62 $fc_check = ($fc_check != '' ? $fc_check : _('** MISSING FEATURE CODE **'));
63
64 switch ($action) {
65  
66   case "system":
67     recording_sidebar(-1, null);
68     recording_sysfiles();
69     break;
70   case "newsysrec":
71     $sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1);
72     if (recordings_add($sysrecs[$sysrec], $sysrecs[$sysrec])) {
73       $id = recordings_get_id($sysrecs[$sysrec]);
74     } else {
75       $id = 0;
76     }
77     recording_sidebar($id, null);
78     recording_editpage($id, null);
79     break;
80   case "recorded":
81     // Clean up the filename, take out any nasty characters
82     $filename = escapeshellcmd(strtr($rname, '/ ', '__'));
83     if (!file_exists($astsnd."custom")) {
84       if (!mkdir($astsnd."custom", 0775)) {
85         echo '<div class="content"><h5>'._("Failed to create").' '.$astsnd.'custom'.'</h5>';     
86       }   
87     } else {
88       // can't rename a file from one partition to another, must use mv or cp
89       // rename($recordings_save_path."{$dest}ivrrecording.wav",$recordings_astsnd_path."custom/{$filename}.wav");
90       if (!file_exists($recordings_save_path."{$dest}ivrrecording.$suffix")) {
91         echo "<hr><h5>"._("[ERROR] The Recorded File Does Not exists:")."</h5>";
92         echo $recordings_save_path."{$dest}ivrrecording.$suffix<br><br>";
93         echo "make sure you uploaded or recorded a file with the entered extension<hr>";
94       } else {
95         exec("cp " . $recordings_save_path . "{$dest}ivrrecording.$suffix " . $astsnd."custom/{$filename}.$suffix 2>&1", $outarray, $ret);
96         if (!$ret) {
97           $isok = recordings_add($rname, "custom/{$filename}.$suffix");
98         } else {
99           echo "<hr><h5>"._("[ERROR] SAVING RECORDING:")."</h5>";
100           foreach ($outarray as $line) {
101             echo "$line<br>";
102           }
103           echo _("Make sure you have entered a proper name");
104           echo "<hr>";
105         }
106         exec("rm " . $recordings_save_path . "{$dest}ivrrecording.$suffix ", $outarray, $ret);
107         if ($ret) {
108           echo "<hr><h5>"._("[ERROR] REMOVING TEMPORARY RECORDING:")."</h5>";
109           foreach ($outarray as $line) {
110             echo "$line<br>";
111           }
112           echo _("Make sure Asterisk is not running as root ");
113           echo "<hr>";
114         }
115       }
116
117       recording_sidebar(null, $usersnum);
118       recording_addpage($usersnum);
119       if ($isok)
120         echo '<div class="content"><h5>'._("System Recording").' "'.$rname.'" '._("Saved").'!</h5>';
121     }
122     break;
123     
124   case "edit":
125     $arr = recordings_get($id);
126     $filename=$arr['filename'];
127     // Check all possibilities of uploaded file types.
128     $valid = Array("au","g723","g723sf","g729","gsm","h263","ilbc","mp3","ogg","pcm","alaw","ulaw","al","ul","mu","sln","raw","vox","WAV","wav","wav49");
129     $fileexists = false;
130     if (strpos($filename, '&') === false) {
131       foreach ($valid as $xtn) {
132         $checkfile = $recordings_astsnd_path.$filename.".".$xtn;
133         if (file_exists($checkfile)) {
134           $suffix = substr(strrchr($filename, "."), 1);
135           copy($checkfile, $recordings_save_path."{$dest}ivrrecording.".$suffix);
136           $fileexists = true;
137         }
138       }
139       if ($fileexists === false) {
140         echo '<div class="content"><h5>'._("Unable to locate").' '.$recordings_astsnd_path.$filename.' '._("with a a valid suffix").'</h5>';
141       }
142     }
143     
144     recording_sidebar($id, $usersnum); 
145     recording_editpage($id, $usersnum);
146     break;
147     
148   case "edited":
149     recordings_update($id, $rname, $notes, $_REQUEST, $fcode, $fcode_pass);
150     recording_sidebar($id, $usersnum);
151     recording_editpage($id, $usersnum);
152     echo '<div class="content"><h5>'._("System Recording").' "'.$rname.'" '._("Updated").'!</h5></div>';
153     needreload();
154     break;
155     
156   case "delete";
157     recordings_del($id);
158     needreload();
159     
160   default:
161     recording_sidebar($id, $usersnum);
162     recording_addpage($usersnum);
163     break;
164     
165 }
166  
167 function recording_addpage($usersnum) {
168   global $fc_save;
169   global $fc_check;
170   global $recordings_save_path;
171  
172   ?>
173   <div class="content">
174   <h2><?php echo _("System Recordings")?></h2>
175   <h3><?php echo _("Add Recording") ?></h3>
176   <h5><?php echo _("Step 1: Record or upload")?></h5>
177   <?php if (!empty($usersnum)) {
178     echo '<p>';
179     echo _("Using your phone,")."<a href=\"#\" class=\"info\">"._("dial")."&nbsp;".$fc_save." <span>";
180     echo _("Start speaking at the tone. Hangup when finished.")."</span></a>";
181     echo _("and speak the message you wish to record.")."\n";
182     echo '</p>';
183   } else { ?>
184     <form name="xtnprompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
185     <input type="hidden" name="display" value="recordings">
186     <?php
187     echo _("If you wish to make and verify recordings from your phone, please enter your extension number here:"); ?>
188     <input type="text" size="6" name="usersnum" tabindex="<?php echo ++$tabindex;?>"> <input name="Submit" type="submit" value="<?php echo _("Go"); ?>" tabindex="<?php echo ++$tabindex;?>">
189     </form>
190   <?php } ?>
191   <p></p>
192   <form enctype="multipart/form-data" name="upload" action="<?php echo $_SERVER['PHP_SELF'] ?>" method="POST">
193     <?php echo _("Alternatively, upload a recording in any supported asterisk format. Note that if you're using .wav, (eg, recorded with Microsoft Recorder) the file <b>must</b> be PCM Encoded, 16 Bits, at 8000Hz")?>:<br>
194     <input type="hidden" name="display" value="recordings">
195     <input type="hidden" name="action" value="recordings_start">
196                 <input type="hidden" name="usersnum" value="<?php echo $usersnum ?>">
197     <input type="file" name="ivrfile" tabindex="<?php echo ++$tabindex;?>"/>
198     <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;?>"/>
199   </form>
200   <?php
201   if (isset($_FILES['ivrfile']['tmp_name']) && is_uploaded_file($_FILES['ivrfile']['tmp_name'])) {
202     if (empty($usersnum) || !ctype_digit($usersnum)) {
203       $dest = "unnumbered-";
204     } else {
205       $dest = "{$usersnum}-";
206     }
207     $suffix = preg_replace('/[^0-9a-zA-Z]/','',substr(strrchr($_FILES['ivrfile']['name'], "."), 1));
208     $destfilename = $recordings_save_path.$dest."ivrrecording.".$suffix;
209     move_uploaded_file($_FILES['ivrfile']['tmp_name'], $destfilename);
210     system("chgrp asterisk ".$destfilename);
211     system("chmod g+rw ".$destfilename);
212     echo "<h6>"._("Successfully uploaded")." ".$_FILES['ivrfile']['name']."</h6>";
213     $rname = rtrim(basename($_FILES['ivrfile']['name'], $suffix), '.');
214   } ?>
215   <form name="prompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return rec_onsubmit();">
216   <input type="hidden" name="action" value="recorded">
217   <input type="hidden" name="display" value="recordings">
218   <input type="hidden" name="usersnum" value="<?php echo $usersnum ?>">
219   <?php
220   if (!empty($usersnum)) { ?>
221     <h5><?php echo _("Step 2: Verify")?></h5>
222     <p> <?php echo _("After recording or uploading,")."&nbsp;<em>"._("dial")."&nbsp;".$fc_check."</em> "._("to listen to your recording.")?> </p>
223     <p> <?php echo _("If you wish to re-record your message, dial")."&nbsp;".$fc_save; ?></p>
224     <h5><?php echo _("Step 3: Name")?> </h5> <?php
225   } else {
226     echo "<h5>"._("Step 2: Name")."</h5>";
227   } ?>
228   <table style="text-align:right;">
229     <tr valign="top">
230       <td valign="top"><?php echo _("Name this Recording")?>: </td>
231       <td style="text-align:left"><input type="text" name="rname" value="<?php echo $rname; ?>" tabindex="<?php echo ++$tabindex;?>"></td>
232     </tr>
233   </table>
234  
235   <h6><?php
236   echo _("Click \"SAVE\" when you are satisfied with your recording");
237   echo "<input type=\"hidden\" name=\"suffix\" value=\"$suffix\">\n"; ?>
238   <input name="Submit" type="submit" value="<?php echo _("Save")?>" tabindex="<?php echo ++$tabindex;?>"></h6>
239   <?php recordings_form_jscript(); ?>
240   </form>
241   </div>
242 <?php
243 }
244
245 function recording_editpage($id, $num) {
246   global $fcbase;
247   global $default_pos;
248   global $fcode;
249   global $fcode_pass;
250   global $recordings_astsnd_path;
251 ?>
252   <div class="content">
253   <h2><?php echo _("System Recordings")?></h2>
254   <h3><?php echo _("Edit Recording") ?></h3>
255   <?php
256   $this_recording = recordings_get($id);
257   if (!$this_recording) {
258     echo "<tr><td colspan=2><h2>Error reading Recording ID $id - Aborting</h2></td></tr></table>";
259     return;
260   }?>
261   <?php
262   $usage_list = recordings_list_usage($id);
263   if (count($usage_list)) {
264 ?>
265     <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>
266 <?php
267     $count = 0;
268     foreach ($usage_list as $link) {
269       $label = '<span><img width="16" height="16" border="0" title="'.$link['description'].'" alt="" src="images/application_link.png"/>&nbsp;'.$link['description'].'</span>';
270       echo "<br /><a href=".$link['url_query'].">".$label."</a>";
271     }
272   } else {
273     $delURL = "config.php?display=recordings&amp;action=delete&amp;usersnum=".urlencode($num)."&amp;id=$id";
274     $tlabel = _("Remove Recording");
275     $label = '<span><img width="16" height="16" border="0" title="'.$tlabel.'" alt="" src="images/sound_delete.png"/>&nbsp;'.$tlabel.'</span>';
276     echo "<a href=".$delURL.">".$label."</a>";
277     echo "<i style='font-size: x-small'>&nbsp;(";
278     echo _("Note, does not delete file from computer");
279     echo ")</i>";
280   }
281   ?>
282   <form name="prompt"  action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return rec_onsubmit();">
283   <input type="hidden" name="action" value="edited">
284   <input type="hidden" name="display" value="recordings">
285   <input type="hidden" name="usersnum" value="<?php echo $num ?>">
286   <input type="hidden" name="id" value="<?php echo $id ?>">
287   <table>
288   <tr><td colspan=2><hr></td></tr>
289   <tr>
290     <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>
291     <td><input type="text" name="rname" value="<?php echo $this_recording['displayname'] ?>" tabindex="<?php echo ++$tabindex;?>"></td>
292   </tr>
293   <tr>
294         <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>
295         <td>&nbsp;<textarea name="notes" rows="3" cols="40" tabindex="<?php echo ++$tabindex;?>"><?php echo $this_recording['description'] ?></textarea></td>
296   </tr>
297
298 <?php
299   // This was being called twice: $rec = recordings_get($id);
300   $rec = $this_recording;
301   $fn = $rec['filename'];
302   $files = explode('&', $fn);
303   $counter = 0;
304   $arraymax = count($files)-1;
305   $sndfile_html = "";
306   $jq_autofill = "";
307   foreach ($files as $item) {
308     $sndfile_html .=  recordings_display_sndfile($item, $counter, $arraymax, $recordings_astsnd_path, $rec['fcode']);
309     $counter++;
310
311     // create the jquery autofill statements in advance of the next iteration or the blank one at the end
312     // on mouseover to the <td> element (since select doesn't have mouseover event), we clone the populated
313     // select options and put them into this one which is created just with the selected tag. Then set the
314     // selected value based on what is in the hidden tag. (we skip the hidden tag but for now ...)
315     //
316     $jq_autofill .= '
317     $("#sysrec'.$counter.'").parent().one("mouseover", function(){
318       $selectload = $("#selectload'.$counter.'").show(80,function(){
319         $("#sysrec'.$counter.'").empty().append($optlist.clone()).val($("#sysrecval'.$counter.'").val());
320         $(this).hide();
321       });
322     });
323     ';
324   }
325   $sndfile_html .=  recordings_display_sndfile('', $counter, $arraymax, $recordings_astsnd_path, $rec['fcode']);
326   if ($arraymax == 0 && isset($files[0]) && substr($files[0],0,7) == 'custom/') {
327     if ($rec['fcode']) {
328       $fcc = new featurecode("recordings", 'edit-recording-'.$id);
329       $rec_code = $fcc->getCode();
330       unset($fcc);
331       if ($rec_code == '') {
332         $rec_code = $fcbase.$id;
333       }
334     } else {
335         $rec_code = $fcbase.$id;
336     }
337 ?>
338   <tr>
339     <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>:
340     </td>
341     <td>
342   <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"),$rec_code)?>
343     </td>
344   </tr>
345   <tr>
346     <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>
347     <td><input type="text" name="fcode_pass" id="fcode_pass" value="<?php echo $rec['fcode_pass'] ?>" tabindex="<?php echo ++$tabindex;?>"></td>
348   </tr>
349 <?php
350   } else {
351 ?>
352   <tr>
353     <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>:
354     </td>
355   </tr>
356 <?php
357   }
358 ?>
359
360   <tr><td colspan="2"><hr /></td></tr>
361   </table>
362   <?php echo _("Files");?>:<br />
363   <table>
364   <?php
365   // globals seem to busted in PHP5 define here for now
366   $recordings_astsnd_path = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk';
367   $recordings_astsnd_path .= "/sounds/";
368
369   // recordings_display_sndfile functions need to be run above so we have $default_pos set
370   //
371   echo $sndfile_html;
372   ?>
373   </table>
374   <input name="Submit" type="submit" value="<?php echo _("Save")?>" tabindex="<?php echo ++$tabindex;?>"></h6>
375   <?php recordings_popup_jscript(); ?> 
376   <?php recordings_form_jscript(); ?>
377   <script language="javascript">
378   <!-- Begin
379   var sysrec0_idx;
380   function initPage() {
381     sysrec0_idx = document.getElementById("sysrec0").selectedIndex;
382     alert('Got here with sysrec0_idx as:'.sysrec0_idx);
383   }
384   function resetDefaultSound() {
385     if (document.getElementById('fcode').checked) {
386       document.getElementById('sysrec0').selectedIndex=<?php echo $default_pos ?>;
387       document.getElementById('sysrec1').selectedIndex=0;
388
389       document.getElementById('sysrec0').disabled=true;
390       document.getElementById('sysrec1').disabled=true;
391       document.getElementById('play1').style.visibility='hidden';
392       document.getElementById('down0').style.visibility='hidden';
393       document.getElementById('up1').style.visibility='hidden';
394       document.getElementById('del0').style.visibility='hidden';
395       document.getElementById('del1').style.visibility='hidden';
396     } else {
397       document.getElementById('sysrec0').disabled=false;
398       document.getElementById('sysrec1').disabled=false;
399       document.getElementById('play1').style.visibility='visible';
400       document.getElementById('down0').style.visibility='visible';
401       document.getElementById('up1').style.visibility='visible';
402       document.getElementById('del0').style.visibility='visible';
403       document.getElementById('del1').style.visibility='visible';
404     }
405   }
406
407   $(document).ready(function(){
408     var $reclist = $("#sysrec0");
409     var $optlist = $("#sysrec0 option");
410     //$(".slclass").css({ visibility: "visible" }).hide();
411     $(".slclass").css("visibility", "visible").hide();
412     $(".autofill").width($reclist.width());
413     <?php echo $jq_autofill; ?>
414   });
415
416
417   // End -->
418   </script>
419   </form>
420   </div>
421 <?php
422 }
423
424 function recording_sidebar($id, $num) {
425 ?>
426         <div class="rnav"><ul>
427         <li><a id="<?php echo empty($id)?'current':'nul' ?>" href="config.php?display=recordings&amp;usersnum=<?php echo urlencode($num) ?>"><?php echo _("Add Recording")?></a></li>
428         <li><a id="<?php echo ($id===-1)?'current':'nul' ?>" href="config.php?display=recordings&amp;action=system"><?php echo _("Built-in Recordings")?></a></li>
429 <?php
430     $wrapat = 18;
431         $tresults = recordings_list();
432         if (isset($tresults)){
433                 foreach ($tresults as $tresult) {
434                         echo "<li>";
435                         echo "<a id=\"".($id==$tresult[0] ? 'current':'nul')."\" href=\"config.php?display=recordings&amp;";
436                         echo "action=edit&amp;";
437                         echo "usersnum=".urlencode($num)."&amp;";
438 //                        echo "filename=".urlencode($tresult[2])."&amp;";
439                         echo "id={$tresult[0]}\">";
440                         $dispname = $tresult[1];
441                         while (strlen($dispname) > (1+$wrapat)) {
442                           $part = substr($dispname, 0, $wrapat);
443                           echo htmlspecialchars($part);
444                           $dispname = substr($dispname, $wrapat);
445                           if ($dispname != '')
446                             echo "<br>";
447                         }
448                         echo htmlspecialchars($dispname);
449                         echo "</a>";
450                         echo "</li>\n";
451                 }
452         }
453         echo "</ul></div>\n";
454 }
455
456 function recordings_popup_jscript() {
457 ?>
458         <script language="javascript">
459   <!-- Begin
460   function popUp(URL,optionId) {
461     var selIndex=optionId.selectedIndex
462     var file=encodeURIComponent(optionId.options[selIndex].value)
463
464     /*alert(selIndex);*/
465     if (file != "")
466       popup = window.open(URL+file, 'play', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=1,width=320,height=110');
467   }
468   // End -->
469   </script>
470 <?php
471 }
472
473 function recordings_form_jscript() {
474 ?>
475   <script language="javascript">
476   <!--
477
478   var theForm = document.prompt;
479  
480   function rec_onsubmit() {
481     var msgInvalidFilename = "<?php echo _("Please enter a valid Name for this System Recording"); ?>";
482    
483     defaultEmptyOK = false;
484     if (!isFilename(theForm.rname.value))
485       return warnInvalid(theForm.rname, msgInvalidFilename);
486      
487     return true;
488   }
489
490   //-->
491   </script>
492
493 <?php
494 }
495
496 function recording_sysfiles() {
497   $astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk';
498   $astsnd .= "/sounds/";
499   $sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1);
500 ?>
501   <div class="content">
502   <h2><?php echo _("System Recordings")?></h2>
503   <h3><?php echo _("Built-in Recordings") ?></h3>
504   <h5><?php echo _("Select System Recording:")?></h5>
505   <form name="xtnprompt" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
506   <input type="hidden" name="action" value="newsysrec">
507   <input type="hidden" name="display" value="recordings">
508   <select name="sysrec">
509 <?php
510   foreach ($sysrecs as $srcount => $sr) {
511     // echo '<option value="'.$vmc.'"'.($vmc == $ivr_details['dircontext'] ? ' SELECTED' : '').'>'.$vmc."</option>\n";
512     echo "<option value=\"$srcount\">$sr</option>\n";
513     }
514   ?>
515   </select>
516   <input name="Submit" type="submit" value="<?php echo _("Go"); ?>">
517   <p />
518   </div>
519 <?php
520 }
521
522 function recordings_display_sndfile($item, $count, $max, $astpath, $fcode) {
523   global $default_pos;
524   global $amp_conf;
525
526   $disabled_state = $fcode == 0 ? "" : "disabled='true' ";
527   $hidden_state = $fcode == 0 ? "" : "style='visibility:hidden' ";
528
529   $html_text = "";
530   // Note that when using this, it needs a <table> definition around it.
531
532   if ($count == 0) {
533     $astsnd = isset($asterisk_conf['astvarlibdir'])?$asterisk_conf['astvarlibdir']:'/var/lib/asterisk';
534     $astsnd .= "/sounds/";
535     $sysrecs = recordings_readdir($astsnd, strlen($astsnd)+1);
536     $html_txt .=  "<tr><td><select $disabled_state id='sysrec$count' name='sysrec$count' class='autofill'>\n";
537     $html_txt .=  '<option value=""'.($item == '' ? ' SELECTED' : '')."></option>\n";
538     $index=0;
539     foreach ($sysrecs as $sr) {
540       // value= not needed since text and value are same
541       //
542       $html_txt .=  '<option '.($sr == $item ? ' SELECTED' : '').">$sr</option>\n";
543       if ($sr == $item) {
544         $default_pos = $index+1;
545       }
546       $index++;
547     }
548     $html_txt .=  "</select></td>\n";
549   } else {
550     $html_txt .=  "<tr><td>";
551     $html_txt .=  "<input type='hidden' id='sysrecval$count' value='$item' />";
552     $html_txt .=  "<select $disabled_state id='sysrec$count' name='sysrec$count' class='autofill'>\n";
553     $html_txt .=  "<option  SELECTED>$item</option>\n";
554     $html_txt .=  "</select></td>\n";
555   }
556
557   $html_txt .=  "<td>";
558   $audio=$astpath;
559
560   include_once("crypt.php");
561   $crypt = new Crypt();
562   $REC_CRYPT_PASSWORD = (isset($amp_conf['AMPPLAYKEY']) && trim($amp_conf['AMPPLAYKEY']) != "")?trim($amp_conf['AMPPLAYKEY']):'moufdsuu3nma0';
563   $audio = urlencode($crypt->encrypt($audio,$REC_CRYPT_PASSWORD));
564   $recurl=$_SERVER['PHP_SELF']."?display=recordings&action=popup&recordingpath=$audio&recording=";
565
566   $html_txt .=  "<a href='#' ".(($count)?$hidden_state:'')." type='submit' id='play$count' onClick=\"javascript:popUp('$recurl',document.prompt.sysrec$count); return false;\" input='foo'>";
567   $html_txt .=  "<img border='0' width='20'  height='20' src='images/play.png' title='"._("Click here to play this recording")."' />";
568   $html_txt .=  "</img></td>";
569
570   if ($count==0) {
571      $html_txt .=  "<td></td>\n";
572   } else {
573     $html_txt .=  "<td><img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />";
574     $html_txt .=  "<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")."'>";
575     $html_txt .=  "</td>\n";
576   } if ($count > $max) {
577     $html_txt .=  "<td></td>\n";
578   } else {
579     $html_txt .=  "<td><img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />";
580     $html_txt .=  "<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";
581     $html_txt .=  "<img border='0' width='3' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />";
582     $html_txt .=  "</td>\n";
583   }
584   $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";
585   $html_txt .=  "<img border='0' width='9' height='11' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/blank.gif' />";
586   $html_txt .=  "</td><td id='selectload$count' class='slclass' style='visibility:hidden' width='16'><img border='0' style='float: none; margin-left: 0px; margin-bottom: 0px;' src='images/rec_hourglass.png'></td>\n";
587
588   $html_txt .=  "</tr>\n";
589   return $html_txt;
590 }
591
592 ?>
Note: See TracBrowser for help on using the browser.