Changeset 7588

Show
Ignore:
Timestamp:
04/27/09 02:58:06 (4 years ago)
Author:
xrobau
Message:

Snapshot of where I'm up to - don't use yet.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • contributed_modules/modules/routepermissions/functions.inc.php

    r7583 r7588  
    6565        $currentcomponent->setoptlistopts('rpyn', 'sort', false); 
    6666 
    67         // Add the 'proces' function 
     67        // Add the 'process' function 
    6868        $currentcomponent->addguifunc('rp_configpageload'); 
    6969} 
     
    8282    foreach ($routes as $route) { 
    8383      $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)); 
    8485    } 
    8586  } 
     
    9596      $rps[substr($r, 3)]=$val; 
    9697    } 
     98    if (!strncmp($_REQUEST[$r], "rp-redir_", 9)) { 
     99      $redir[substr($r, 9)]=$val; 
     100    } 
    97101  } 
    98102        //if submitting form, update database 
     
    102106    rp_purge_ext($extdisplay); 
    103107    rp_set_perm($extdisplay, $rps); 
     108    print "Fucker\n"; 
     109    rp_set_redir($extdispay, $redir); 
    104110                break; 
    105111                case "del": 
     
    125131} 
    126132 
     133function 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 
    127147function rp_set_perm($ext, $rps) { 
    128148  global $db; 
     
    136156  } 
    137157} 
     158 
     159function 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 
    138171 
    139172function rp_purge_ext($ext) { 
  • contributed_modules/modules/routepermissions/page.routepermissions.php

    r7585 r7588  
    11<?php  
    2 /* $Id$ */ 
     2/* $Id:$ */ 
    33 
    44// Original Release by Rob Thomas (xrobau@gmail.com) 
     
    1515// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the 
    1616// GNU General Public License for more details. 
    17  
    18  
    19  
    2017 
    2118 
     
    4239    // Figure out which button has been pushed. 
    4340    foreach ($_REQUEST as $r=>$val) { 
    44                   if (!strncmp($r, "on_", 3)) { 
     41    if (!strncmp($r, "on_", 3)) { 
    4542        $route=substr($r,3); 
    4643        print "<h4>Route $route set to ALLOW for supplied range</h4>\n"; 
    4744        rp_allow($route, $_REQUEST["range_$route"]); 
    48                   } 
    49                   if (!strncmp($r, "off_", 3)) { 
     45   
     46    if (!strncmp($r, "off_", 3)) { 
    5047        $route=substr($r,4); 
    5148        print "<h4>Route $route set to DENY for supplied range</h4>\n"; 
    5249        rp_deny($route, $_REQUEST["range_$route"]); 
    53                   } 
     50   
    5451      if ($r == 'update_dest') { 
    5552        $dest = $_REQUEST[$_REQUEST['gotofaildest'].'faildest']; 
     
    6562  <tr><td colspan=2><span id="instructions"> 
    6663  <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> 
    7284<?php 
    7385  echo "<p><h3>"._("Bulk Changes"); echo "</h3></p> "; 
     
    7587  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."); 
    7688  echo "</p>\n "; 
    77   echo "<p>"._("Note that there is NO UNDO and changes take effect IMMEDATELY. Be cautious.")."</p>"; 
     89  echo "<p>"._("Note that there is NO UNDO and changes take effect IMMEDIATELY. Be cautious.")."</p>"; 
    7890   
    7991 
     
    8698  echo "<table>\n"; 
    8799  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"; 
    90106  } 
    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>'; 
    92109  $res=sql("SELECT faildest FROM routepermissions where exten='-1'", "getRow"); 
    93110  if (isset($res[0])) {