Changeset 10372
- Timestamp:
- 10/06/10 13:40:56 (3 years ago)
- Files:
-
- modules/branches/2.8/blacklist/functions.inc.php (modified) (8 diffs)
- modules/branches/2.8/blacklist/page.blacklist.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
modules/branches/2.8/blacklist/functions.inc.php
r10371 r10372 16 16 // 17 17 // Copyright (C) 2006 Magnus Ullberg (magnus@ullberg.us) 18 // Portions Copyright (C) 2010 Mikael Carlsson (mickecamino@gmail.com)19 18 // 20 19 … … 26 25 global $version; 27 26 global $astman; 28 29 27 switch($engine) { 30 28 case "asterisk": … … 46 44 $ext->add($id, $c, 'check-blocked', new ext_gotoif('$["${DB(blacklist/blocked)}" = "1"]','blacklisted')); 47 45 } 48 46 49 47 if (version_compare($version, "1.6", "ge")) { 50 48 $ext->add($id, $c, 'check', new ext_gotoif('$["${BLACKLIST()}"="1"]', 'blacklisted')); … … 53 51 $ext->add($id, $c, '', new ext_gotoif('$["${LOOKUPBLSTATUS}"="FOUND"]', 'blacklisted')); 54 52 } 55 $ext->add($id, $c, '', new ext_setvar('CALLED_BLACKLIST','1'));53 $ext->add($id, $c, '', new ext_setvar('CALLED_BLACKLIST','1')); 56 54 $ext->add($id, $c, '', new ext_return('')); 57 55 $ext->add($id, $c, 'blacklisted', new ext_answer('')); … … 213 211 global $astman; 214 212 215 $engineinfo = engine_getinfo();216 $astver = $engineinfo['version'];217 213 if ($astman) { 218 $list = $astman->database_show('blacklist'); 219 if(version_compare($astver, "1.6", "ge")) { 220 foreach ($list as $k => $v) { 221 $numbers = substr($k, 11); 222 $blacklisted[] = array('number' => $numbers, 'description' => $v); 223 } 224 if (isset($blacklisted) && is_array($blacklisted)) 225 // Why this sorting? When used it does not yield the result I want 226 // natsort($blacklisted); 227 return isset($blacklisted)?$blacklisted:null; 228 } else { 229 foreach ($list as $k => $v) { 230 $numbers[substr($k, 11)] = substr($k, 11); 231 } 232 if (isset($numbers) && is_array($numbers)) 233 natcasesort($numbers); 234 return isset($numbers)?$numbers:null; 235 } 214 $list = $astman->database_show(); 215 foreach ($list as $k => $v) { 216 if (substr($k, 1, 9) == 'blacklist') 217 { 218 $numbers[substr($k, 11)] = substr($k, 11); 219 } 220 } 221 222 if (isset($numbers) && is_array($numbers)) 223 natcasesort($numbers); 224 225 return isset($numbers)?$numbers:null; 236 226 } else { 237 227 fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]); … … 242 232 global $amp_conf; 243 233 global $astman; 234 244 235 if ($astman) { 245 236 $astman->database_del("blacklist",$number); … … 253 244 global $astman; 254 245 255 $engineinfo = engine_getinfo();256 $astver = $engineinfo['version'];257 258 246 if(!blacklist_chk($post)) 259 247 return false; … … 261 249 extract($post); 262 250 if ($astman) { 263 if (version_compare($astver, "1.6", "ge")) { 264 $post['description']==""?$post['description'] = '1':$post['description']; 265 $astman->database_put("blacklist",$post['number'], '"'.$post['description'].'"'); 266 } else { 267 $astman->database_put("blacklist",$number, '1'); 268 } 251 $astman->database_put("blacklist",$number, '1'); 269 252 // Remove filtering for blocked/unknown cid 270 253 $astman->database_del("blacklist","blocked"); modules/branches/2.8/blacklist/page.blacklist.php
r10371 r10372 15 15 // along with FreePBX. If not, see <http://www.gnu.org/licenses/>. 16 16 // 17 // Copyright (C) 2006 Magnus Ullberg (magnus@ullberg.us) 18 // Portions Copyright (C) 2010 Mikael Carlsson (mickecamino@gmail.com) 17 //Copyright (C) 2006 Magnus Ullberg (magnus@ullberg.us) 19 18 // 19 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action=''; 20 20 21 $engineinfo = engine_getinfo();22 $astver = $engineinfo['version'];23 24 isset($_REQUEST['action'])?$action = $_REQUEST['action']:$action='';25 21 isset($_REQUEST['number'])?$number = $_REQUEST['number']:$number=''; 26 27 if(version_compare($astver, "1,6", "ge")) {28 isset($_REQUEST['description'])?$description = $_REQUEST['description']:$description='';29 }30 22 31 23 isset($_REQUEST['editnumber'])?$editnumber = $_REQUEST['editnumber']:$editnumber=''; 32 24 33 25 $dispnum = "blacklist"; //used for switch on config.php 34 26 35 27 //if submitting form, update database 36 28 … … 50 42 redirect_standard('editnumber'); 51 43 break; 44 45 52 46 } 53 47 } … … 75 69 76 70 <tr> 77 78 <?php 79 if(version_compare($astver, "1,6", "ge")) { 80 echo "<td><b>"._("Number")."</b></td>"; 81 echo "<td><b>"._("Description")."</b></td>"; 82 } else { 83 echo "<td><b>"._("Number")."</b></td>"; 84 echo "<td> </td>"; 85 } 86 ?> 87 <td> </td> 71 <td><b><?php echo _("Number") ?></b></td> 72 <td> </td> 73 <td> </td> 88 74 </tr> 89 75 … … 97 83 else { 98 84 99 if(version_compare($astver, "1,6", "ge")) {100 print('<tr>');101 printf('<td>%s</td>', $num['number']);102 printf('<td>%s</td>', $num['description']);103 printf('<td><a href="%s?type=setup&display=%s&number=%s&action=delete">%s</a></td>',104 $_SERVER['PHP_SELF'], urlencode($dispnum), urlencode($num['number']), _("Delete"));105 printf('<td><a href="#" onClick="theForm.number.value = \'%s\';106 theForm.editnumber.value = \'%s\' ;107 theForm.description.value = \'%s\';108 theForm.editdescription.value = \'%s\' ;109 theForm.action.value = \'edit\' ; ">%s</a></td>',$num['number'], $num['number'], $num['description'], $num['description'], _("Edit"));110 print('</tr>');111 112 } else {113 85 print('<tr>'); 114 86 printf('<td>%s</td>', $num); 115 printf('<td>%s</td>', $description);116 87 printf('<td><a href="%s?type=setup&display=%s&number=%s&action=delete">%s</a></td>', 117 88 $_SERVER['PHP_SELF'], urlencode($dispnum), urlencode($num), _("Delete")); 118 89 printf('<td><a href="#" onClick="theForm.number.value = \'%s\'; theForm.editnumber.value = \'%s\' ; theForm.action.value = \'edit\' ; ">%s</a></td>',$num, $num, _("Edit")); 119 90 print('</tr>'); 120 }121 91 } 122 92 } 93 123 94 print('</table>'); 124 95 } 96 125 97 ?> 98 126 99 127 100 <form autocomplete="off" name="edit" action="<?php $_SERVER['PHP_SELF'] ?>" method="post" onsubmit="return edit_onsubmit();"> … … 130 103 <input type="hidden" name="editnumber" value=""> 131 104 132 <?php if(version_compare($astver, "1,6", "ge")) {133 echo "<input type=\"hidden\" name=\"editdescripton\" value=\"\">";134 }?>135 105 <table> 136 106 <tr><td colspan="2"><h5><?php echo _("Add or replace entry") ?><hr></h5></td></tr> 137 107 138 108 <tr> 139 <td><a href="#" class="info"><?php echo _("Number:")?>140 <span><?php echo _("Enter the number you want to block")?></span></a></td>109 <td><a href="#" class="info"><?php echo _("Number:")?> 110 <span><?php echo _("Enter the number you want to block")?></span></a></td> 141 111 <td><input type="text" name="number"></td> 142 112 </tr> 143 <?php if(version_compare($astver, "1,6", "ge")) {144 echo "<tr>";145 echo "<td><a href=\"#\" class=\"info\">"._("Description:");146 echo "<span>"._("Enter a description for the number you want to block")."</span></a></td>";147 echo "<td><input type=\"text\" name=\"description\"></td>";148 echo "</tr>";149 }?>150 151 113 <tr> 152 114 <td><a href="#" class="info"><?php echo _("Block Unknown/Blocked Caller ID:")?>
