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

Revision 10521, 7.3 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 Destinations 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 = 'customdests';
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 $old_custom_dest = isset($_REQUEST['old_custom_dest']) ? $_REQUEST['old_custom_dest'] :  '';
22 $custom_dest     = isset($_REQUEST['extdisplay']) ? $_REQUEST['extdisplay'] :  '';
23 $description     = isset($_REQUEST['description']) ? htmlentities($_REQUEST['description']) :  '';
24 $notes           = isset($_REQUEST['notes']) ? htmlentities($_REQUEST['notes']) :  '';
25
26 switch ($action) {
27   case 'add':
28     if (customappsreg_customdests_add($custom_dest, $description, $notes)) {
29       needreload();
30       redirect_standard();
31     } else {
32       $custom_dest='';
33     }
34   break;
35   case 'edit':
36     if (customappsreg_customdests_edit($old_custom_dest, $custom_dest, $description, $notes)) {
37       needreload();
38       redirect_standard('extdisplay');
39     }
40   break;
41   case 'delete':
42     customappsreg_customdests_delete($custom_dest);
43     needreload();
44     redirect_standard();
45   break;
46 }
47
48 ?> 
49 </div>
50
51 <div class="rnav"><ul>
52 <?php 
53
54 echo '<li><a href="config.php?display='.$display.'&amp;type='.$type.'">'._('Add Custom Destination').'</a></li>';
55
56 foreach (customappsreg_customdests_list() as $row) {
57   $descr = $row['description'] != '' ? $row['description'] : '('.$row['custom_dest'].')';
58   echo '<li><a href="config.php?display='.$display.'&amp;type='.$type.'&amp;extdisplay='.$row['custom_dest'].'" class="">'.$descr.'</a></li>';
59 }
60
61 ?>
62 </ul></div>
63
64 <div class="content">
65
66 <?php
67
68 if ($custom_dest != '') {
69   // load
70   $usage_list = framework_display_destination_usage(customappsreg_customdests_getdest($custom_dest));
71
72   $row = customappsreg_customdests_get($custom_dest);
73  
74   $description = $row['description'];
75   $notes       = $row['notes'];
76
77   $disp_description = $row['description'] != '' ? $row['description'] : '('.$row['custom_dest'].')';
78   echo "<h2>"._("Edit: ")."$disp_description"."</h2>";
79 } else {
80   echo "<h2>"._("Add Custom Destination")."</h2>";
81 }
82
83 $helptext = _("Custom Destinations allows you to register your custom destinations that point to custom dialplans and will also 'publish' these destinations as available destinations to other modules. This is an advanced feature and should only be used by knowledgable users. If you are getting warnings or errors in the noticication panel about CUSTOM destinations that are correct, you should include them here. The 'Unknown Destinations' chooser will allow you to choose and insert any such destinations that the registry is not aware of into the Custom Destination field.");
84 echo $helptext;
85 ?>
86
87 <form name="editCustomDest" action="<?php  $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return checkCustomDest(editCustomDest);">
88   <input type="hidden" name="extdisplay" value="<?php echo $custom_dest; ?>">
89   <input type="hidden" name="old_custom_dest" value="<?php echo $custom_dest; ?>">
90   <input type="hidden" name="action" value="<?php echo ($custom_dest != '' ? 'edit' : 'add'); ?>">
91   <table>
92   <tr><td colspan="2"><h5><?php  echo ($custom_dest ? _("Edit Custom Destination") : _("Add Custom Destination")) ?><hr></h5></td></tr>
93   <tr>
94     <td><a href="#" class="info"><?php echo _("Custom Destination")?>:
95       <span>
96         <?php
97         echo _("This is the Custom Destination to be published. It should be formatted exactly as you would put it in a goto statement, with context, exten, priority all included. An example might look like:<br />mycustom-app,s,1");
98         if (!empty($usage_list)) {
99           echo "<br />"._("READONLY WARNING: Because this destination is being used by other module objects it can not be edited. You must remove those dependencies in order to edit this destination, or create a new destination to use");
100         }
101         ?>
102       </span></a></td>
103   <?php
104   if (!empty($usage_list)) {
105   ?>
106     <td><b><?php echo htmlentities($custom_dest); ?></b></td>
107   <?php
108   } else {
109   ?>
110     <td><input size="30" type="text" name="extdisplay" id="extdisplay" value="<?php  echo $custom_dest; ?>"></td>
111   <?php
112   }
113   ?>
114   </tr>
115
116   <?php
117   if (empty($usage_list)) {
118   ?>
119   <tr>
120     <td>
121     <a href=# class="info"><?php echo _("Destination Quick Pick")?>
122       <span>
123         <?php echo _("Choose un-identified destinations on your system to add to the Custom Destinaion Registry. This will insert the chosen entry into the Custom Destination box above.")?>
124       </span>
125     </a>
126     </td>
127     <td>
128       <select onChange="insertDest();" id="insdest">
129         <option value=""><?php echo _("(pick destination)")?></option>
130   <?php
131         $results = customappsreg_customdests_getunknown();
132         foreach ($results as $thisdest) {
133           echo "<option value='$thisdest'>$thisdest</option>\n";
134         }
135   ?>
136       </select>
137     </td>
138   </tr>
139   <?php
140   }
141   ?>
142
143   <tr>
144     <td><a href="#" class="info"><?php echo _("Description")?>:<span><?php echo _("Brief Description that will be published to modules when showing destinations. Example: My Weather App")?></span></a></td>
145     <td><input size="30" type="text" name="description" value="<?php  echo $description; ?>"></td>
146   </tr>
147   <tr>
148     <td valign="top"><a href="#" class="info"><?php echo _("Notes")?>:<span><?php echo _("More detailed notes about this destination to help document it. This field is not used elsewhere.")?></span></a></td>
149     <td><textarea name="notes" cols="23" rows="6"><?php echo $notes; ?></textarea></td>
150   </tr>
151
152   <tr>
153     <td colspan="2"><br><input name="Submit" type="submit" value="<?php echo _("Submit Changes")?>">
154     <?php if ($custom_dest != '') { echo '&nbsp;<input name="delete" type="submit" value="'._("Delete").'">'; } ?>
155     </td>   
156
157     <?php
158     if ($custom_dest != '') {
159       if (!empty($usage_list)) {
160       ?>
161         <tr><td colspan="2">
162         <a href="#" class="info"><?php echo $usage_list['text']?>:<span><?php echo $usage_list['tooltip']?></span></a>
163         </td></tr>
164       <?php
165       }
166     }
167     ?>
168   </tr>
169   </table>
170   </form>
171       
172 <script language="javascript">
173 <!--
174
175 function insertDest() {
176
177   dest = document.getElementById('insdest').value;
178   customDest=document.getElementById('extdisplay');
179
180   if (dest != '') {
181     customDest.value = dest;
182   }
183
184   // reset element
185   document.getElementById('insdest').value = '';
186 }
187
188 function checkCustomDest(theForm) {
189
190   var msgInvalidCustomDest = "<?php echo _('Invalid Destination, must not be blank, must be formatted as: context,exten,pri'); ?>";
191   var msgInvalidDescription = "<?php echo _('Invalid description specified, must not be blank'); ?>";
192
193   // Make sure the custom dest is in the form "context,exten,pri"
194   var re = /[^,]+,[^,]+,[^,]+/;
195
196   // form validation
197   defaultEmptyOK = false;
198
199   if (isEmpty(theForm.extdisplay.value) || !re.test(theForm.extdisplay.value)) {
200     return warnInvalid(theForm.extdisplay, msgInvalidCustomDest);
201   }
202   if (isEmpty(theForm.description.value)) {
203     return warnInvalid(theForm.description, msgInvalidDescription);
204   }
205
206   return true;
207 }
208 //-->
209 </script>
Note: See TracBrowser for help on using the browser.