Changeset 7588
- Timestamp:
- 04/27/09 02:58:06 (4 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
contributed_modules/modules/routepermissions/functions.inc.php
r7583 r7588 65 65 $currentcomponent->setoptlistopts('rpyn', 'sort', false); 66 66 67 // Add the 'proces ' function67 // Add the 'process' function 68 68 $currentcomponent->addguifunc('rp_configpageload'); 69 69 } … … 82 82 foreach ($routes as $route) { 83 83 $currentcomponent->addguielem($section, new gui_radio("rp_$route", $currentcomponent->getoptlist('rpyn'), rp_get_perm($extdisplay,$route), $route, "" , null)); 84 $currentcomponent->addguielem($section, new gui_textbox("rp-redir_$route", rp_get_redir($extdisplay, $route), "'".$route."' "._('Redirect Prefix'), _("Add this prefex and try again if denied. READ THE INSTRUCTIONS on the Outbound Permissions page"), "", "", true, 0, null)); 84 85 } 85 86 } … … 95 96 $rps[substr($r, 3)]=$val; 96 97 } 98 if (!strncmp($_REQUEST[$r], "rp-redir_", 9)) { 99 $redir[substr($r, 9)]=$val; 100 } 97 101 } 98 102 //if submitting form, update database … … 102 106 rp_purge_ext($extdisplay); 103 107 rp_set_perm($extdisplay, $rps); 108 print "Fucker\n"; 109 rp_set_redir($extdispay, $redir); 104 110 break; 105 111 case "del": … … 125 131 } 126 132 133 function rp_get_redir($ext, $route) { 134 global $db; 135 $Sext = mysql_real_escape_string($ext); 136 $Sroute = mysql_real_escape_string($route); 137 $sql = "SELECT faildest FROM routepermissions WHERE routename='$Sroute' AND exten='$Sext'"; 138 $res = $db->getRow($sql); 139 if (PEAR::isError($res)) { die($res->getMessage()); } 140 if (isset($res[0])) { 141 return $res[0]; 142 } else { 143 return ""; 144 } 145 } 146 127 147 function rp_set_perm($ext, $rps) { 128 148 global $db; … … 136 156 } 137 157 } 158 159 function rp_set_redir($ext, $rps) { 160 global $db; 161 $Sext = mysql_real_escape_string($ext); 162 foreach($rps as $r=>$p) { 163 $val = explode("=", $p); 164 $Sr =mysql_real_escape_string($r); 165 $Sval =mysql_real_escape_string($val[1]); 166 $sql = "UPDATE routepermissions SET faildest='$Sval' where exten='$Sext' and routename='$Sr')"; 167 sql($sql); 168 } 169 } 170 138 171 139 172 function rp_purge_ext($ext) { contributed_modules/modules/routepermissions/page.routepermissions.php
r7585 r7588 1 1 <?php 2 /* $Id $ */2 /* $Id:$ */ 3 3 4 4 // Original Release by Rob Thomas (xrobau@gmail.com) … … 15 15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16 16 // GNU General Public License for more details. 17 18 19 20 17 21 18 … … 42 39 // Figure out which button has been pushed. 43 40 foreach ($_REQUEST as $r=>$val) { 44 if (!strncmp($r, "on_", 3)) {41 if (!strncmp($r, "on_", 3)) { 45 42 $route=substr($r,3); 46 43 print "<h4>Route $route set to ALLOW for supplied range</h4>\n"; 47 44 rp_allow($route, $_REQUEST["range_$route"]); 48 }49 if (!strncmp($r, "off_", 3)) {45 } 46 if (!strncmp($r, "off_", 3)) { 50 47 $route=substr($r,4); 51 48 print "<h4>Route $route set to DENY for supplied range</h4>\n"; 52 49 rp_deny($route, $_REQUEST["range_$route"]); 53 }50 } 54 51 if ($r == 'update_dest') { 55 52 $dest = $_REQUEST[$_REQUEST['gotofaildest'].'faildest']; … … 65 62 <tr><td colspan=2><span id="instructions"> 66 63 <p><h3>Instructions</h3></p> 67 <p>This module allows you to block access to certain routes from specified extensions. You can do bulk changes on this page, 68 and you can individually change access to routes on the extension's page.</p> 69 <p>Note that Asterisk is incapable of having two identical routes and trying to force calls to use the other route if 70 one of them is banned by this module. <b>It will not work.</b> You must have unique outbound routes for the proper selection 71 to work</p> 64 <p>This module allows you to block access to certain routes from specified extensions. You can do 65 bulk changes on this page, and you can individually change access to routes on the extension's page.</p> 66 <p>Note that Asterisk is incapable of having two identical routes and trying to force calls to use 67 the other route if one of them is banned by this module. <b>It will not work.</b> You must have 68 unique outbound routes for the proper selection to work</p> 69 <p>If you wish to emulate this functionality, you can use the 'Redirect' function. Any number you type 70 in the 'Redirect' range will be PREPENDED to the number dialled, and the call will then be sent through 71 the dialplan again. For example:</p> 72 <p><ul> 73 <li>Route 1: Zap/1 matches 0|.</li> 74 <li>Route 2: Sip/Foo matches 1|.</li> 75 </ul></p> 76 <p>If you wanted to stop exten 100 from using Zap/1 at all, and send all his calls through Sip/Foo, 77 you would need to DENY 100 access to Route1, and create a NEW route, Route3:</p> 78 <p><ul><li>Route 3: Sip/Foo matches 9990|.</li></ul></p> 79 <p>In the 'Redirect' field, type '999'. When exten 100 dials 0123456, they match Route 1. Route 1 FAILS, 80 and then system invisibly changes the number dialled to be 9990123456 (note the '0' he dialled 81 originally is preserved, and you then strip 9990 from the front in Route 3), which matches Route 3 82 and the call is then sent via Sip/Foo</p> 83 <p>Redirect rules are only checked if the route is DENIED</p> 72 84 <?php 73 85 echo "<p><h3>"._("Bulk Changes"); echo "</h3></p> "; … … 75 87 echo _("You can enter any normal range - comma or hyphen seperated. For example '123,125,200-300' will select extensions 123, 125 and any extensions between 200 and 300."); 76 88 echo "</p>\n "; 77 echo "<p>"._("Note that there is NO UNDO and changes take effect IMMED ATELY. Be cautious.")."</p>";89 echo "<p>"._("Note that there is NO UNDO and changes take effect IMMEDIATELY. Be cautious.")."</p>"; 78 90 79 91 … … 86 98 echo "<table>\n"; 87 99 foreach ($routes as $r) { 88 print "<tr><td>$r</td> <td><input type='text' size=15 name='range_$r' value='All' tabindex='++$tabindex'></td>"; 89 print "<td><input type=submit name=on_$r value=Allow></td><td><input type=submit name=off_$r value=Deny></td></tr>"; 100 print "<tr>\n<td>$r</td><td><input type='text' size=15 name='range_$r' value='All' "; 101 print "tabindex='".++$tabindex."'></td>\n"; 102 print "<td><input type='submit' name=on_$r value=Allow></td><td><input type='submit' "; 103 print "name=off_$r value=Deny></td>\n"; 104 print "<td><input type='text' size=15 name='rp-redir_$r' value='' tabindex='".++$tabindex."'>"; 105 print "</td>\n<td><input type='submit' name='redirect_$r' value='Redirect'></td></tr>\n"; 90 106 } 91 echo '<tr><td colspan="5"><br><h5>'._("Default Destination if denied").':<hr></h5></td></tr>'; 107 echo "</table><table>"; 108 echo '<tr><td colspan="6"><br><h5>'._("Default Destination if denied").':<hr></h5></td></tr>'; 92 109 $res=sql("SELECT faildest FROM routepermissions where exten='-1'", "getRow"); 93 110 if (isset($res[0])) {
