root/modules/branches/2.10/iaxsettings/page.iaxsettings.php

Revision 14124, 24.9 kB (checked in by GameGamer43, 1 year ago)

closes #5867 - fix invalid link

Line 
1 <?php /* $Id:$ */
2 if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
3
4 // Original Release by Philippe Lindheimer
5 // Copyright Philippe Lindheimer (2009)
6 // Copyright Bandwidth.com (2009)
7 /*
8     This program is free software: you can redistribute it and/or modify
9     it under the terms of the GNU Affero General Public License as
10     published by the Free Software Foundation, either version 3 of the
11     License, or (at your option) any later version.
12
13     This program is distributed in the hope that it will be useful,
14     but WITHOUT ANY WARRANTY; without even the implied warranty of
15     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16     GNU Affero General Public License for more details.
17
18     You should have received a copy of the GNU Affero General Public License
19     along with this program.  If not, see <http://www.gnu.org/licenses/>.
20 */
21
22   /* Determines how many columns per row for the codecs and formats the table */
23   $cols_per_row   = 4;
24   $width          = (100.0 / $cols_per_row);
25   $tabindex       = 0;
26   $dispnum        = "iaxsettings";
27   $error_displays = array();
28   $action                            = isset($_POST['action'])?$_POST['action']:'';
29     $post_codec = isset($_POST['codec']) ? $_POST['codec'] : array();
30     $post_vcodec = isset($_POST['vcodec']) ? $_POST['vcodec'] : array();
31     
32   $codecs = array(
33     'ulaw'     => '',
34     'alaw'     => '',
35     'slin'     => '',
36     'g726'     => '',
37     'gsm'      => '',
38     'g729'     => '',
39     'ilbc'     => '',
40     'g723'     => '',
41     'g726aal2' => '',
42     'adpcm'    => '',
43     'lpc10'    => '',
44     'speex'    => '',
45     'g722'     => '',
46     'siren7'   => '',
47     'siren14'  => '',
48     );
49
50   // With the new sorting, the vars should come to us in the sorted order so just use that
51   //
52   $pri = 1;
53   foreach (array_keys($post_codec) as $codec) {
54     $codecs[$codec] = $pri++;
55   }
56   $iax_settings['codecs']            = $codecs;
57
58   $video_codecs = array(
59     'h261'  => '',
60     'h263'  => '',
61     'h263p' => '',
62     'h264'  => '',
63     );
64
65   // With the new sorting, the vars should come to us in the sorted order so just use that
66   //
67   $pri = 1;
68   foreach (array_keys($post_vcodec) as $vcodec) {
69     $video_codecs[$vcodec] = $pri++;
70   }
71   $iax_settings['codecpriority']     = isset($_POST['codecpriority']) ? $_POST['codecpriority'] : 'host';
72   $iax_settings['bandwidth']         = isset($_POST['bandwidth']) ? $_POST['bandwidth'] : 'unset';
73   $iax_settings['video_codecs']      = $video_codecs;
74   $iax_settings['videosupport']      = isset($_POST['videosupport']) ? $_POST['videosupport'] : 'no';
75
76   $iax_settings['maxregexpire']      = isset($_POST['maxregexpire']) ? htmlspecialchars($_POST['maxregexpire']) : '3600';
77   $iax_settings['minregexpire']      = isset($_POST['minregexpire']) ? htmlspecialchars($_POST['minregexpire']) : '60';
78
79   $iax_settings['jitterbuffer']      = isset($_POST['jitterbuffer']) ? $_POST['jitterbuffer'] : 'no';
80   $iax_settings['forcejitterbuffer'] = isset($_POST['forcejitterbuffer']) ? $_POST['forcejitterbuffer'] : 'no';
81   $iax_settings['maxjitterbuffer']   = isset($_POST['maxjitterbuffer']) ? htmlspecialchars($_POST['maxjitterbuffer']) : '200';
82   $iax_settings['resyncthreshold']   = isset($_POST['resyncthreshold']) ? htmlspecialchars($_POST['resyncthreshold']) : '1000';
83   $iax_settings['maxjitterinterps']  = isset($_POST['maxjitterinterps']) ? htmlspecialchars($_POST['maxjitterinterps']) : '10';
84
85   $iax_settings['iax_language']      = isset($_POST['iax_language']) ? htmlspecialchars($_POST['iax_language']) : '';
86   $iax_settings['bindaddr']          = isset($_POST['bindaddr']) ? htmlspecialchars($_POST['bindaddr']) : '';
87   $iax_settings['bindport']          = isset($_POST['bindport']) ? htmlspecialchars($_POST['bindport']) : '';
88   $iax_settings['delayreject']       = isset($_POST['delayreject']) ? htmlspecialchars($_POST['delayreject']) : 'yes';
89
90   $p_idx = 0;
91   $n_idx = 0;
92   while (isset($_POST["iax_custom_key_$p_idx"])) {
93     if ($_POST["iax_custom_key_$p_idx"] != '') {
94       $iax_settings["iax_custom_key_$n_idx"] = htmlspecialchars($_POST["iax_custom_key_$p_idx"]);
95       $iax_settings["iax_custom_val_$n_idx"] = htmlspecialchars($_POST["iax_custom_val_$p_idx"]);
96       $n_idx++;
97     }
98     $p_idx++;
99   }
100   function cmp($a, $b) {
101     if ($a == $b) {
102       return 0;
103     }
104     if ($a == '') {
105       return 1;
106     } elseif ($b == '') {
107       return -1;
108     } else {
109       return ($a > $b) ? 1 : -1;
110     }
111   }
112
113 switch ($action) {
114   case "edit"//just delete and re-add
115     if (($errors = iaxsettings_edit($iax_settings)) !== true) {
116       $error_displays = process_errors($errors);
117     } else {
118       needreload();
119       //redirect_standard();
120     }
121   break;
122   default:
123     /* only get them if first time load, if they pressed submit, use values from POST */
124     $iax_settings = iaxsettings_get();
125 }
126 $error_displays = array_merge($error_displays,iaxsettings_check_custom_files());
127
128 ?>
129   <h2><?php echo _("Edit Settings"); ?></h2>
130
131 <?php
132
133   /* We massaged these above or they came from iaxsettings_get() if this is not
134    * from and edit. So extract them after sorting out the codec sub arrays.
135      */
136   $codecs = $iax_settings['codecs'];
137   unset($iax_settings['codecs']);
138   uasort($codecs, 'cmp');
139
140   $video_codecs = $iax_settings['video_codecs'];
141   unset($iax_settings['video_codecs']);
142   uasort($video_codecs, 'cmp');
143
144   /* EXTRACT THE VARIABLE HERE - MAKE SURE THEY ARE ALL MASSAGED ABOVE */
145     //
146   extract($iax_settings);
147
148 ?>
149   <form autocomplete="off" name="editIax" action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
150   <input type="hidden" name="action" value="edit">
151   <table width="690px">
152
153 <?php
154   /* if there were erros on the submit then create error box */
155   if (!empty($error_displays)) {
156 ?>
157   <tr>
158     <td colspan="2">
159       <div class="iax-errors">
160         <p><?php echo _("ERRORS") ?></p>
161         <ul>
162 <?php
163     foreach ($error_displays as $div_disp) {
164       echo "<li>".$div_disp['div']."</li>";
165     }
166 ?>
167         </ul>
168       </div>
169     </td>
170   </tr>
171 <?php
172   }
173 ?>
174   <tr>
175     <td colspan="2"><h5><?php echo _("Audio Codecs")?><hr></h5></td>
176   </tr>
177   <tr>
178     <td valign='top'><a href="#" class="info"><?php echo _("Codecs")?><span><?php echo _("Check the desired codecs, all others will be disabled unless explicitly enabled in a device or trunks configuration. Drag to re-order.")?></span></a></td>
179     <td>
180 <?php
181   $seq = 1;
182 echo '<ul class="sortable">';
183   foreach ($codecs as $codec => $codec_state) {
184     $tabindex++;
185     $codec_trans = _($codec);
186     $codec_checked = $codec_state ? 'checked' : '';
187     echo '<li><a href="#">'
188         . '<img src="assets/'.$dispnum.'/images/arrow_up_down.png" height="16" width="16" border="0" alt="move" style="float:none; margin-left:-6px; margin-bottom:-3px;cursor:move" /> '
189         . '<input type="checkbox" '
190         . ($codec_checked ? 'value="'. $seq++ . '" ' : '')
191         . 'name="codec[' . $codec . ']" '
192         . 'id="'. $codec . '" '
193         . 'class="audio-codecs" tabindex="' . $tabindex. '" '
194         . $codec_checked
195         . ' />'
196         . '<label for="'. $codec . '"> '
197         . '<small>' . $codec_trans . '</small>'
198         . ' </label></a></li>';
199   }
200 echo '</ul>';
201 ?>
202
203     </td>
204   </tr>
205
206   <tr>
207     <td>
208       <a href="#" class="info"><?php echo _("Codec Priority")?><span><?php echo _("Asterisk: codecpriority. Controls the codec negotiation of an inbound IAX call. This option is inherited to all user entities.  It can also be defined in each user entity separately which will override the setting here. The valid values are:<br />host - Consider the host's preferred order ahead of the caller's.<br />caller - Consider the callers preferred order ahead of the host's.<br /> disabled - Disable the consideration of codec preference altogether. (this is the original behavior before preferences were added)<br />reqonly  - Same as disabled, only do not consider capabilities if the requested format is not available the call will only be accepted if the requested format is available.")?></span></a>
209     </td>
210     <td>
211       <table width="100%">
212         <tr>
213           <td>
214                 <span class="radioset">
215             <input id="codecpriority-host" type="radio" name="codecpriority" value="host" tabindex="<?php echo ++$tabindex;?>"<?php echo $codecpriority=="host"?"checked=\"host\"":""?>/>
216             <label for="codecpriority-host">host</label>
217             <input id="codecpriority-caller" type="radio" name="codecpriority" value="caller" tabindex="<?php echo ++$tabindex;?>"<?php echo $codecpriority=="caller"?"checked=\"caller\"":""?>/>
218             <label for="codecpriority-caller">caller</label>
219             <input id="codecpriority-disabled" type="radio" name="codecpriority" value="disabled" tabindex="<?php echo ++$tabindex;?>"<?php echo $codecpriority=="disabled"?"checked=\"disabled\"":""?>/>
220             <label for="codecpriority-disabled">disabled</label>
221             <input id="codecpriority-regonly" type="radio" name="codecpriority" value="regonly" tabindex="<?php echo ++$tabindex;?>"<?php echo $codecpriority=="regonly"?"checked=\"regonly\"":""?>/>
222             <label for="codecpriority-regonly">regonly</label>
223                 </span>
224           </td>
225         </tr>
226       </table>
227     </td>
228   </tr>
229
230   <tr>
231     <td>
232       <a href="#" class="info"><?php echo _("Bandwidth")?><span><?php echo _("Asterisk: bandwidth. Specify bandwidth of low, medium, or high to control which codecs are used in general.")?></span></a>
233     </td>
234     <td>
235       <table width="100%">
236         <tr>
237           <td>
238             <span class="radioset">
239             <input id="bandwidth-low" type="radio" name="bandwidth" value="low" tabindex="<?php echo ++$tabindex;?>"<?php echo $bandwidth=="low"?"checked=\"low\"":""?>/>
240             <label for="bandwidth-low"><?php echo _("low") ?></label>
241             <input id="bandwidth-medium" type="radio" name="bandwidth" value="medium" tabindex="<?php echo ++$tabindex;?>"<?php echo $bandwidth=="medium"?"checked=\"medium\"":""?>/>
242             <label for="bandwidth-medium"><?php echo _("medium") ?></label>
243             <input id="bandwidth-high" type="radio" name="bandwidth" value="high" tabindex="<?php echo ++$tabindex;?>"<?php echo $bandwidth=="high"?"checked=\"high\"":""?>/>
244             <label for="bandwidth-high"><?php echo _("high") ?></label>
245             <input id="bandwidth-unset" type="radio" name="bandwidth" value="unset" tabindex="<?php echo ++$tabindex;?>"<?php echo $bandwidth=="unset"?"checked=\"unset\"":""?>/>
246             <label for="bandwidth-unset"><?php echo _("unset") ?></label>
247             </span>
248           </td>
249         </tr>
250       </table>
251     </td>
252   </tr>
253
254   <tr>
255     <td colspan="2"><h5><?php echo _("Video Codecs")?><hr></h5></td>
256   </tr>
257
258   <tr>
259     <td>
260       <a href="#" class="info"><?php echo _("Video Support")?><span><?php echo _("Check to enable and then choose allowed codecs.")._(" If you clear each codec and then add them one at a time, submitting with each addition, they will be added in order which will effect the codec priority.")?></span></a>
261     </td>
262     <td>
263       <table width="100%">
264         <tr>
265           <td>
266             <span class="radioset">
267             <input id="videosupport-yes" type="radio" name="videosupport" value="yes" tabindex="<?php echo ++$tabindex;?>"<?php echo $videosupport=="yes"?"checked=\"yes\"":""?>/>
268             <label for="videosupport-yes"><?php echo _("Enabled") ?></label>
269             <input id="videosupport-no" type="radio" name="videosupport" value="no" tabindex="<?php echo ++$tabindex;?>"<?php echo $videosupport=="no"?"checked=\"no\"":""?>/>
270             <label for="videosupport-no"><?php echo _("Disabled") ?></label>
271             </span>
272           </td>
273         </tr>
274       </table>
275     </td>
276   </tr>
277   <tr class="video-codecs">
278     <td></td>
279     <td>
280       <table width="100%">
281         <tr>
282 <?php
283 echo '<ul  class="sortable video-codecs">';
284    foreach ($video_codecs as $codec => $codec_state) {
285     $tabindex++;
286     $codec_trans = _($codec);
287     $codec_checked = $codec_state ? 'checked' : '';
288     echo '<li><a href="#">'
289         . '<img src="assets/'.$dispnum.'/images/arrow_up_down.png" height="16" width="16" border="0" alt="move" style="float:none; margin-left:-6px; margin-bottom:-3px;cursor:move" /> '
290         . '<input type="checkbox" '
291         . ($codec_checked ? 'value="'. $seq++ . '" ' : '')
292         . 'name="vcodec[' . $codec . ']" '
293         . 'id="'. $codec . '" '
294         . 'class="audio-codecs" tabindex="' . $tabindex. '" '
295         . $codec_checked
296         . ' />'
297         . '<label for="'. $codec . '"> '
298         . '<small>' . $codec_trans . '</small>'
299         . ' </label></a></li>';
300       }
301 echo '</ul>';
302
303 ?>
304         </tr>
305       </table>
306     </td>
307   </tr>
308
309   <tr>
310     <td colspan="2"><h5><?php echo _("Registration Settings") ?><hr></h5></td>
311   </tr>
312
313   <tr>
314     <td>
315       <a href="#" class="info"><?php echo _("Registration Times")?><span><?php echo _("Asterisk: minregexpire, maxregexpire. Minimum and maximum length of time that IAX peers can request as a registration expiration interval (in seconds).")?></span></a>
316     </td>
317     <td>
318       <input type="text" size="2" id="minregexpire" name="minregexpire" class="validate-int" value="<?php echo $minregexpire ?>" tabindex="<?php echo ++$tabindex;?>"><small>&nbsp;(minregexpire)</small>&nbsp;
319       <input type="text" size="3" id="maxregexpire" name="maxregexpire" class="validate-int" value="<?php echo $maxregexpire ?>" tabindex="<?php echo ++$tabindex;?>"><small>&nbsp;(maxregexpire)</small>&nbsp;
320     </td>
321   </tr>
322
323   <tr>
324     <td colspan="2"><h5><?php echo _("Jitter Buffer Settings") ?><hr></h5></td>
325   </tr>
326
327   <tr>
328     <td>
329        <a href="#" class="info"><?php echo _("Jitter Buffer")?><span><?php echo _("Asterisk: jitterbuffer. You can adjust several parameters relating to the jitter buffer. The jitter buffer's function is to compensate for varying network delay. The jitter buffer works for INCOMING audio - the outbound audio will be dejittered by the jitter buffer at the other end.")?></span></a>
330     </td>
331     <td>
332       <table width="100%">
333         <tr>
334           <td>
335             <span class="radioset">
336             <input id="jitterbuffer-yes" type="radio" name="jitterbuffer" value="yes" tabindex="<?php echo ++$tabindex;?>"<?php echo $jitterbuffer=="yes"?"checked=\"yes\"":""?>/>
337             <label for="jitterbuffer-yes"><?php echo _("Enabled") ?></label>
338             <input id="jitterbuffer-no" type="radio" name="jitterbuffer" value="no" tabindex="<?php echo ++$tabindex;?>"<?php echo $jitterbuffer=="no"?"checked=\"no\"":""?>/>
339             <label for="jitterbuffer-no"><?php echo _("Disabled") ?></label>
340             </span>
341           </td>
342         </tr>
343       </table>
344     </td>
345   </tr>
346
347   <tr class="jitter-buffer">
348     <td>
349       <a href="#" class="info"><?php echo _("Force Jitter Buffer")?><span><?php echo _("Asterisk: forcejitterbuffer. Forces the use of a jitterbuffer on the receive side of an IAX channel. Normally the jitter buffer will not be used if receiving a jittery channel but sending it off to another channel such as a SIP channel to an endpoint, since there is typically a jitter buffer at the far end. This will force the use of the jitter buffer before sending the stream on. This is not typically desired as it adds additional latency into the stream.")?></span></a>
350     </td>
351     <td>
352       <table width="100%">
353         <tr>
354           <td>
355             <span class="radioset">
356             <input id="forcejitterbuffer-yes" type="radio" name="forcejitterbuffer" class="jitter-buffer" value="yes" tabindex="<?php echo ++$tabindex;?>"<?php echo $forcejitterbuffer=="yes"?"checked=\"yes\"":""?>/>
357             <label for="forcejitterbuffer-yes"><?php echo _("Yes") ?></label>
358             <input id="forcejitterbuffer-no" type="radio" name="forcejitterbuffer" class="jitter-buffer" value="no" tabindex="<?php echo ++$tabindex;?>"<?php echo $forcejitterbuffer=="no"?"checked=\"no\"":""?>/>
359             <label for="forcejitterbuffer-no"><?php echo _("No") ?></label>
360             <span>
361           </td>
362         </tr>
363       </table>
364     </td>
365   </tr>
366
367   <tr class="jitter-buffer">
368     <td>
369       <a href="#" class="info"><?php echo _("Jitter Buffer Size")?><span><?php echo _("Asterisk: maxjitterbuffer. Max length of the jitterbuffer in milliseconds.<br /> Asterisk: resyncthreshold. When the jitterbuffer notices a significant change in delay that continues over a few frames, it will resync, assuming that the change in delay was caused by a timestamping mix-up. The threshold for noticing a change in delay is measured as twice the measured jitter plus this resync threshold. Resyncing can be disabled by setting this parameter to -1.")?></span></a>
370     </td>
371     <td>
372       <input type="text" size="4" id="maxjitterbuffer" name="maxjitterbuffer" class="jitter-buffer validate-int" value="<?php echo $maxjitterbuffer ?>" tabindex="<?php echo ++$tabindex;?>"><small>&nbsp;(maxjitterbuffer)</small>&nbsp;
373       <input type="text" size="4" id="resyncthreshold" name="resyncthreshold" class="jitter-buffer validate-int" value="<?php echo $resyncthreshold ?>" tabindex="<?php echo ++$tabindex;?>"><small>&nbsp;(resyncthreshold)</small>&nbsp;
374     </td>
375   </tr>
376
377   <tr class="jitter-buffer">
378     <td>
379       <a href="#" class="info"><?php echo _("Max Interpolations")?><span><?php echo _("Asterisk: maxjitterinterps. The maximum number of interpolation frames the jitterbuffer should return in a row. Since some clients do not send CNG/DTX frames to indicate silence, the jitterbuffer will assume silence has begun after returning this many interpolations. This prevents interpolating throughout a long silence.")?></span></a>
380     </td>
381     <td>
382       <input type="text" size="4" id="maxjitterinterps" name="maxjitterinterps" class="jitter-buffer validate-int" value="<?php echo $maxjitterinterps ?>" tabindex="<?php echo ++$tabindex;?>">
383     </td>
384   </tr>
385
386   <tr>
387     <td colspan="2"><h5><?php echo _("Advanced General Settings") ?><hr></h5></td>
388   </tr>
389
390   <tr>
391     <td>
392       <a href="#" class="info"><?php echo _("Language")?><span><?php echo _("Default Language for a channel, Asterisk: language")?></span></a>
393     </td>
394     <td>
395       <input type="text" id="iax_language" name="iax_language" class="validate-alphanumeric" value="<?php echo $iax_language ?>" tabindex="<?php echo ++$tabindex;?>">
396     </td>
397   </tr>
398
399   <tr>
400     <td>
401       <a href="#" class="info"><?php echo _("Bind Address")?><span><?php echo _("Asterisk: bindaddr. The IP address to bind to and listen for calls on the Bind Port. If set to 0.0.0.0 Asterisk will listen on all addresses. To bind to multiple IP addresses or ports, use the Other 'IAX Settings' fields where you can put settings such as:<br /> bindaddr=192.168.10.100:4555.<br />  It is recommended to leave this blank.")?></span></a>
402     </td>
403     <td>
404       <input type="text" id="bindaddr" name="bindaddr" class="validate-ip" value="<?php echo $bindaddr ?>" tabindex="<?php echo ++$tabindex;?>">
405     </td>
406   </tr>
407
408   <tr>
409     <td>
410       <a href="#" class="info"><?php echo _("Bind Port")?><span><?php echo _("Asterisk: bindport. Local incoming UDP Port that Asterisk will bind to and listen for IAX messages. The IAX standard is 4569 and in most cases this is what you want. It is recommended to leave this blank.")?></span></a>
411     </td>
412     <td>
413       <input type="text" id="bindport" name="bindport" class="validate-ip-port" value="<?php echo $bindport ?>" tabindex="<?php echo ++$tabindex;?>">
414     </td>
415   </tr>
416
417   <tr>
418     <td>
419       <a href="#" class="info"><?php echo _("Delay Auth Rejects")?><span><?php echo _("Asterisk: delayreject. For increased security against brute force password attacks enable this which will delay the sending of authentication reject for REGREQ or AUTHREP if there is a password.")?></span></a>
420     </td>
421     <td>
422       <table width="100%">
423         <tr>
424           <td>
425             <span class="radioset">
426             <input id="delayreject-yes" type="radio" name="delayreject" value="yes" tabindex="<?php echo ++$tabindex;?>"<?php echo $delayreject=="yes"?"checked=\"yes\"":""?>/>
427             <label for="delayreject-yes"><?php echo _("Enable") ?></label>
428             <input id="delayreject-no" type="radio" name="delayreject" value="no" tabindex="<?php echo ++$tabindex;?>"<?php echo $delayreject=="no"?"checked=\"no\"":""?>/>
429             <label for="delayreject-no"><?php echo _("Disable") ?></label>
430             </span>
431           </td>
432         </tr>
433       </table>
434     </td>
435   </tr>
436
437   <tr><td colspan="2"><br /></td></tr>
438
439   <tr>
440     <td>
441       <a href="#" class="info"><?php echo _("Other IAX Settings")?><span><?php echo _("You may set any other IAX settings not present here that are allowed to be configured in the General section of iax.conf. There will be no error checking against these settings so check them carefully. They should be entered as:<br /> [setting] = [value]<br /> in the boxes below. Click the Add Field box to add additional fields. Blank boxes will be deleted when submitted.")?></span></a>
442     </td>
443     <td>
444       <input type="text" id="iax_custom_key_0" name="iax_custom_key_0" class="iax-custom" value="<?php echo $iax_custom_key_0 ?>" tabindex="<?php echo ++$tabindex;?>"> =
445       <input type="text" id="iax_custom_val_0" name="iax_custom_val_0" value="<?php echo $iax_custom_val_0 ?>" tabindex="<?php echo ++$tabindex;?>">
446     </td>
447   </tr>
448
449 <?php
450   $idx = 1;
451   $var_iax_custom_key = "iax_custom_key_$idx";
452   $var_iax_custom_val = "iax_custom_val_$idx";
453   while (isset($$var_iax_custom_key)) {
454     if ($$var_iax_custom_key != '') {
455       $tabindex++;
456       echo <<< END
457   <tr>
458     <td>
459     </td>
460     <td>
461       <input type="text" id="iax_custom_key_$idx" name="iax_custom_key_$idx" class="iax-custom" value="{$$var_iax_custom_key}" tabindex="$tabindex"> =
462 END;
463       $tabindex++;
464       echo <<< END
465       <input type="text" id="iax_custom_val_$idx" name="iax_custom_val_$idx" value="{$$var_iax_custom_val}" tabindex="$tabindex">
466     </td>
467   </tr>
468 END;
469     }
470     $idx++;
471     $var_iax_custom_key = "iax_custom_key_$idx";
472     $var_iax_custom_val = "iax_custom_val_$idx";
473   }
474   $tabindex += 60; // make room for dynamic insertion of new fields
475 ?>
476   <tr id="iax-custom-buttons">
477     <td></td>
478     <td><br \>
479       <input type="button" id="iax-custom-add"  value="<?php echo _("Add Field")?>" />
480     </td>
481   </tr>
482
483   <tr>
484     <td colspan="2"><br><h6><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>" tabindex="<?php echo ++$tabindex;?>"></h6></td>
485   </tr>
486 </table>
487 <script language="javascript">
488 <!--
489 $(document).ready(function(){
490
491   /* Add a Custom Var / Val textbox */
492   $("#iax-custom-add").click(function(){
493     addCustomField("","");
494   });
495
496   /* Initialize Video Support settings and show/hide */
497   if (document.getElementById("videosupport-no").checked) {
498     $(".video-codecs").hide();
499   }
500   $("#videosupport-yes").click(function(){
501     $(".video-codecs").show();
502   });
503   $("#videosupport-no").click(function(){
504     $(".video-codecs").hide();
505   });
506
507   /* Initialize Jitter Buffer settings and show/hide */
508   if (document.getElementById("jitterbuffer-no").checked) {
509     $(".jitter-buffer").hide();
510   }
511   $("#jitterbuffer-yes").click(function(){
512     $(".jitter-buffer").show();
513   });
514   $("#jitterbuffer-no").click(function(){
515     $(".jitter-buffer").hide();
516   });
517 <?php
518   /* this will insert the addClass jquery calls to all id's in error */
519   if (!empty($error_displays)) {
520     foreach ($error_displays as $js_disp) {
521       echo "  ".$js_disp['js'];
522     }
523   }
524 ?>
525 });
526
527 var theForm = document.editIax;
528
529 /* Insert a iax_setting/iax_value pair of text boxes */
530 function addCustomField(key, val) {
531   var idx = $(".iax-custom").size();
532   var idxp = idx - 1;
533   var tabindex = parseInt($("#iax_custom_val_"+idxp).attr('tabindex')) + 1;
534   var tabindexp = tabindex + 1;
535
536   $("#iax-custom-buttons").before('\
537   <tr>\
538     <td>\
539     </td>\
540     <td>\
541       <input type="text" id="iax_custom_key_'+idx+'" name="iax_custom_key_'+idx+'" class="iax-custom" value="'+key+'" tabindex="'+tabindex+'"> =\
542       <input type="text" id="iax_custom_val_'+idx+'" name="iax_custom_val_'+idx+'" value="'+val+'" tabindex="'+tabindexp+'">\
543     </td>\
544   </tr>\
545   ');
546 }
547 //-->
548 </script>
549 </form>
550 <?php       
551
552 /********** UTILITY FUNCTIONS **********/
553
554 function process_errors($errors) {
555   foreach($errors as $error) {
556     $error_display[] = array(
557       'js' => "$('#".$error['id']."').addClass('validation-error');\n",
558       'div' => $error['message'],
559     );
560   }
561   return $error_display;
562 }
563
564 function iaxsettings_check_custom_files() {
565   global $amp_conf;
566   $errors = array();
567
568   $custom_files[] = $amp_conf['ASTETCDIR']."/iax.conf";
569   $custom_files[] = $amp_conf['ASTETCDIR']."/iax_general_custom.conf";
570   $custom_files[] = $amp_conf['ASTETCDIR']."/iax_custom.conf";
571
572   foreach ($custom_files as $file) {
573     if (file_exists($file)) {
574       $iax_conf = @parse_ini_file($file,true);
575       $main = true; // 1 is iax.conf, after that don't care
576       foreach ($iax_conf as $section => $item) {
577         // If setting is an array, then it is a subsection
578         //
579         if (!is_array($item)) {
580           $msg sprintf(_("Settings in %s may override these. Those settings should be removed."),"<b>$file</b>");
581           $errors[] = array( 'js' => '', 'div' => $msg);
582           break;
583         } elseif ($main && is_array($item) && strtolower($section) == 'general' && !empty($item)) {
584           $msg sprintf(_("File %s should not have any settings in it. Those settings should be removed."),"<b>$file</b>");
585           $errors[] = array( 'js' => '', 'div' => $msg);
586           break;
587         }
588         $main = false;
589       }
590     }
591   }
592   return $errors;
593 }
594
595
596 ?>
597
Note: See TracBrowser for help on using the browser.