root/modules/branches/2.4/customappsreg/page.customextens.php

Revision 10521, 6.1 kB (checked in by p_lindheimer, 2 years ago)

Merged revisions 10520 via svnmerge from
http://www.freepbx.org/v2/svn/modules/branches/2.5

................

r10520 | p_lindheimer | 2010-11-02 12:18:43 -0700 (Tue, 02 Nov 2010) | 30 lines


Merged revisions 10519 via svnmerge from
http://www.freepbx.org/v2/svn/modules/branches/2.6


................

r10519 | p_lindheimer | 2010-11-02 12:16:31 -0700 (Tue, 02 Nov 2010) | 23 lines


Merged revisions 10518 via svnmerge from
http://www.freepbx.org/v2/svn/modules/branches/2.7


................

r10518 | p_lindheimer | 2010-11-02 12:14:32 -0700 (Tue, 02 Nov 2010) | 16 lines


Merged revisions 10517 via svnmerge from
http://svn.freepbx.org/modules/branches/2.8


................

r10517 | p_lindheimer | 2010-11-02 12:12:08 -0700 (Tue, 02 Nov 2010) | 9 lines


Merged revisions 10516 via svnmerge from
http://svn.freepbx.org/modules/branches/2.9


........

r10516 | p_lindheimer | 2010-11-02 12:10:23 -0700 (Tue, 02 Nov 2010) | 1 line


fixes #4618 xss security issue and some other precations unreported

........

................

................

................

................

Line 
1 <?php 
2 /** Custom Extensions Display for FreePBX 2.4
3  * Copyright 2006 Philippe Lindheimer - Astrogen LLC
4  * This program is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU General Public License
6  * as published by the Free Software Foundation; either version 2
7  * of the License, or (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15 $display = 'customextens';
16
17 $type   = isset($_REQUEST['type']) ? $_REQUEST['type'] : 'tool';
18 $action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
19 if (isset($_REQUEST['delete'])) $action = 'delete';
20
21 $custom_exten = preg_replace("/[^0-9*#]/" ,"", trim($custom_exten));
22
23 $old_custom_exten = isset($_REQUEST['old_custom_exten']) ? preg_replace("/[^0-9*#]/" ,"",$_REQUEST['old_custom_exten']) :  '';
24 $custom_exten     = isset($_REQUEST['extdisplay']) ? preg_replace("/[^0-9*#]/" ,"",$_REQUEST['extdisplay']) :  '';
25 $description     = isset($_REQUEST['description']) ? htmlentities($_REQUEST['description']) :  '';
26 $notes           = isset($_REQUEST['notes']) ? htmlentities($_REQUEST['notes']) :  '';
27
28 switch ($action) {
29   case 'add':
30     $conflict_url = array();
31     $usage_arr = framework_check_extension_usage($custom_exten);
32     if (!empty($usage_arr)) {
33       $conflict_url = framework_display_extension_usage_alert($usage_arr);
34       $custom_exten='';
35     } else {
36       if (customappsreg_customextens_add($custom_exten, $description, $notes)) {
37         needreload();
38         redirect_standard();
39       } else {
40         $custom_exten='';
41       }
42     }
43   break;
44   case 'edit':
45     $conflict_url = array();
46     if ($old_custom_exten != $custom_exten) {
47       $usage_arr = framework_check_extension_usage($custom_exten);
48       if (!empty($usage_arr)) {
49         $conflict_url = framework_display_extension_usage_alert($usage_arr);
50       }
51     }
52     if (empty($conflict_url)) {
53       if (customappsreg_customextens_edit($old_custom_exten, $custom_exten, $description, $notes)) {
54         needreload();
55         redirect_standard('extdisplay');
56       }
57     }
58   break;
59   case 'delete':
60     customappsreg_customextens_delete($custom_exten);
61     needreload();
62     redirect_standard();
63   break;
64 }
65
66 ?> 
67 </div>
68
69 <div class="rnav"><ul>
70 <?php 
71
72 echo '<li><a href="config.php?display='.$display.'&amp;type='.$type.'">'._('Add Custom Extension').'</a></li>';
73
74 foreach (customappsreg_customextens_list() as $row) {
75   $descr = $row['description'] != '' ? $row['description'] : '('.$row['custom_exten'].')';
76   echo '<li><a href="config.php?display='.$display.'&amp;type='.$type.'&amp;extdisplay='.$row['custom_exten'].'" class="">'.$descr.'</a></li>';
77 }
78
79 ?>
80 </ul></div>
81
82 <div class="content">
83
84 <?php
85
86 if ($custom_exten != '') {
87   // load
88   $row = customappsreg_customextens_get($custom_exten);
89  
90   $description = $row['description'];
91   $notes       = $row['notes'];
92
93   $disp_description = $row['description'] != '' ? '('.$row['custom_exten'].') '.$row['description'] : '('.$row['custom_exten'].')';
94   echo "<h2>"._("Edit: ")."$disp_description"."</h2>";
95 } else {
96   echo "<h2>"._("Add Custom Extension")."</h2>";
97 }
98
99 $helptext = _("Custom Extensions provides you with a facility to register any custom extenions or feature codes that you have created in a custom file and FreePBX doesn't otherwise know about them. This allows the Extension Registry to be aware of your own extensions so that it can detect conflicts or report back information about your custom extensions to other modules that may make use of the information. You should not put extensions that you create in the Misc Apps Module as those are not custom.");
100 echo $helptext;
101
102 if (!empty($conflict_url)) {
103   echo "<h5>"._("Conflicting Extensions")."</h5>";
104   echo implode('<br .>',$conflict_url);
105 }
106 ?>
107
108 <form name="editCustomExten" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkCustomExten(editCustomExten);">
109   <input type="hidden" name="extdisplay" value="<?php echo $custom_exten; ?>">
110   <input type="hidden" name="old_custom_exten" value="<?php echo $custom_exten; ?>">
111   <input type="hidden" name="action" value="<?php echo ($custom_exten != '' ? 'edit' : 'add'); ?>">
112   <table>
113   <tr><td colspan="2"><h5><?php  echo ($custom_exten ? _("Edit Custom Extension") : _("Add Custom Extension")) ?><hr></h5></td></tr>
114   <tr>
115     <td><a href="#" class="info"><?php echo _("Custom Extension")?>:<span><?php echo _("This is the Extension or Feature Code you are using in your dialplan that you want the FreePBX Extension Registry to be aware of.")?></span></a></td>
116     <td><input size="10" type="text" name="extdisplay" id="extdisplay" value="<?php  echo $custom_exten; ?>"></td>
117   </tr>
118
119   <tr>
120     <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("Brief description that will be published in the Extension Registry about this extension")?></span></a></td>
121     <td><input size="30" type="text" name="description" value="<?php  echo $description; ?>"></td>
122   </tr>
123   <tr>
124     <td valign="top"><a href="#" class="info"><?php echo _("Notes")?>:<span><?php echo _("More detailed notes about this extension to help document it. This field is not used elsewhere.")?></span></a></td>
125     <td><textarea name="notes" cols="23" rows="6"><?php echo $notes; ?></textarea></td>
126   </tr>
127
128   <tr>
129     <td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>">
130     <?php if ($custom_exten != '') { echo '&nbsp;<input name="delete" type="submit" value="'._("Delete").'">'; } ?>
131     </td>   
132   </tr>
133   </table>
134   </form>
135       
136 <script language="javascript">
137 <!--
138
139 function checkCustomExten(theForm) {
140
141   var msgInvalidCustomExten = "<?php echo _('Invalid Extension, must not be blank'); ?>";
142   var msgInvalidDescription = "<?php echo _('Invalid description specified, must not be blank'); ?>";
143
144   // form validation
145   defaultEmptyOK = false;
146
147   if (isEmpty(theForm.extdisplay.value)) {
148     return warnInvalid(theForm.extdisplay, msgInvalidCustomExten);
149   }
150   if (isEmpty(theForm.description.value)) {
151     return warnInvalid(theForm.description, msgInvalidDescription);
152   }
153
154   return true;
155 }
156 //-->
157 </script>
Note: See TracBrowser for help on using the browser.