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