root/modules/branches/2.4/blacklist/functions.inc.php

Revision 6209, 8.0 kB (checked in by p_lindheimer, 4 years ago)

Merged revisions 6208 via svnmerge from and ref #2956
http://svn.freepbx.org/modules/branches/2.5

........

r6208 | p_lindheimer | 2008-07-26 22:11:04 -0700 (Sat, 26 Jul 2008) | 1 line


closes #2956 no more channel to be spliced

........

  • Property svn:mime-type set to text/plain
  • Property svn:eol-style set to native
Line 
1 <?php /* $Id */
2
3 if( !class_exists('extension') ) {
4   require('extensions.class.php');
5 }
6 function blacklist_get_config($engine) {
7         global $ext;
8         global $version;
9         switch($engine) {
10                 case "asterisk":
11
12           $id = "app-blacklist";
13           $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
14
15           $id = "app-blacklist-check";
16           $c = "s";
17                       if (version_compare($version, "1.6", "ge")) {
18                              $ext->add($id, $c, '', new ext_gotoif('$["${BLACKLIST()}"="1"]', 'blacklisted'));
19                       } else {
20                              $ext->add($id, $c, '', new ext_lookupblacklist(''));
21                              $ext->add($id, $c, '', new ext_gotoif('$["${LOOKUPBLSTATUS}"="FOUND"]', 'blacklisted'));
22                       }
23                       $ext->add($id, $c, '', new ext_return(''));
24                       $ext->add($id, $c, 'blacklisted', new ext_answer(''));
25                       $ext->add($id, $c, '', new ext_wait(1));
26                       $ext->add($id, $c, '', new ext_zapateller(''));
27                       $ext->add($id, $c, '', new ext_playback('ss-noservice'));
28                       $ext->add($id, $c, '', new ext_hangup(''));
29
30           $modulename = 'blacklist';
31
32                         if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) {
33                                 foreach($featurelist as $item) {
34                                         $featurename = $item['featurename'];
35                                         $fname = $modulename.'_'.$featurename;
36                                         if (function_exists($fname)) {
37                                                 $fcc = new featurecode($modulename, $featurename);
38                                                 $fc = $fcc->getCodeActive();
39                                                 unset($fcc);
40
41                                                 if ($fc != '')
42                                                         $fname($fc);
43                                         } else {
44                                                 $ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename.": No func $fname"));
45                                                 var_dump($item);
46                                         }
47                                 }
48                         }
49
50                       break;
51         }
52 }
53
54 function blacklist_blacklist_add($fc) {
55   global $ext;
56
57   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-add'));
58
59   $id = "app-blacklist-add";
60   $c = "s";
61   $ext->add($id, $c, '', new ext_answer);
62   $ext->add($id, $c, '', new ext_wait(1));
63   $ext->add($id, $c, '', new ext_playback('enter-num-blacklist'));
64   $ext->add($id, $c, '', new ext_digittimeout(5));
65   $ext->add($id, $c, '', new ext_responsetimeout(60));
66   $ext->add($id, $c, '', new ext_read('blacknr', 'then-press-pound'));
67   $ext->add($id, $c, '', new ext_saydigits('${blacknr}'));
68   $ext->add($id, $c, '', new ext_playback('if-correct-press&digits/1'));
69   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
70   $ext->add($id, $c, 'end', new ext_waitexten(60));
71   $ext->add($id, $c, '', new ext_playback('sorry-youre-having-problems&goodbye'));
72   $c = "1";
73   $ext->add($id, $c, '', new ext_set('DB(blacklist/${blacknr})', 1));
74   $ext->add($id, $c, '', new ext_playback('num-was-successfully&added'));
75   $ext->add($id, $c, '', new ext_wait(1));
76   $ext->add($id, $c, '', new ext_hangup);
77 }
78
79 function blacklist_blacklist_remove($fc) {
80   global $ext;
81
82   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-remove'));
83
84   $id = "app-blacklist-remove";
85   $c = "s";
86   $ext->add($id, $c, '', new ext_answer);
87   $ext->add($id, $c, '', new ext_wait(1));
88   $ext->add($id, $c, '', new ext_playback('entr-num-rmv-blklist'));
89   $ext->add($id, $c, '', new ext_digittimeout(5));
90   $ext->add($id, $c, '', new ext_responsetimeout(60));
91   $ext->add($id, $c, '', new ext_read('blacknr', 'then-press-pound'));
92   $ext->add($id, $c, '', new ext_saydigits('${blacknr}'));
93   $ext->add($id, $c, '', new ext_playback('if-correct-press&digits/1'));
94   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
95   $ext->add($id, $c, 'end', new ext_waitexten(60));
96   $ext->add($id, $c, '', new ext_playback('sorry-youre-having-problems&goodbye'));
97   $c = "1";
98   $ext->add($id, $c, '', new ext_dbdel('blacklist/${blacknr}'));
99   $ext->add($id, $c, '', new ext_playback('num-was-successfully&removed'));
100   $ext->add($id, $c, '', new ext_wait(1));
101   $ext->add($id, $c, '', new ext_hangup);
102 }
103
104 function blacklist_blacklist_last($fc) {
105   global $ext;
106
107   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-last'));
108
109   $id = "app-blacklist-last";
110   $c = "s";
111   $ext->add($id, $c, '', new ext_answer);
112   $ext->add($id, $c, '', new ext_wait(1));
113   $ext->add($id, $c, '', new ext_setvar('lastcaller', '${DB(CALLTRACE/${CALLERID(number)})}'));
114   $ext->add($id, $c, '', new ext_gotoif('$[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]', 'noinfo'));
115   $ext->add($id, $c, '', new ext_playback('privacy-to-blacklist-last-caller&telephone-number'));
116   $ext->add($id, $c, '', new ext_saydigits('${lastcaller}'));
117   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(digit)', '3'));
118   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(response)', '7'));
119   $ext->add($id, $c, '', new ext_playback('if-correct-press&digits/1'));
120   $ext->add($id, $c, '', new ext_goto('end'));
121   $ext->add($id, $c, 'noinfo', new ext_playback('unidentified-no-callback'));
122   $ext->add($id, $c, '', new ext_hangup);
123   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
124   $ext->add($id, $c, 'end', new ext_waitexten(60));
125   $ext->add($id, $c, '', new ext_playback('sorry-youre-having-problems&goodbye'));
126   $c = "1";
127   $ext->add($id, $c, '', new ext_set('DB(blacklist/${lastcaller})', 1));
128   $ext->add($id, $c, '', new ext_playback('num-was-successfully'));
129   $ext->add($id, $c, '', new ext_playback('added'));
130   $ext->add($id, $c, '', new ext_wait(1));
131   $ext->add($id, $c, '', new ext_hangup);
132 }
133
134 function blacklist_hookGet_config($engine) {
135         global $ext;
136         switch($engine) {
137                 case "asterisk":
138                 // Code from modules/core/functions.inc.php core_get_config inbound routes
139       $didlist = core_did_list();
140       if (is_array($didlist)) {
141         foreach ($didlist as $item) {
142           $did = core_did_get($item['extension'],$item['cidnum']);
143                           $exten = $item['extension'];
144                           $cidnum = $item['cidnum'];
145
146                           $exten = (empty($exten)?"s":$exten);
147                           $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it
148
149                           $context = "ext-did";
150                           $ext->splice($context, $exten, 1, new ext_gosub('1', 's', 'app-blacklist-check'));
151         }
152       } // else no DID's defined. Not even a catchall.
153                 break;
154         }
155 }
156
157 function blacklist_list() {
158   global $amp_conf;
159   global $astman;
160
161         if ($astman) {
162     $list = $astman->database_show();
163     foreach ($list as $k => $v) {
164       if (substr($k, 1, 9) == 'blacklist')
165       {
166         $numbers[substr($k, 11)] = substr($k, 11);
167       }
168     }
169
170     if (isset($numbers) && is_array($numbers))
171       natcasesort($numbers);
172
173     return isset($numbers)?$numbers:null;
174         } else {
175                 fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);
176         }
177 }
178
179 function blacklist_del($number){
180   global $amp_conf;
181   global $astman;
182
183   if ($astman) {
184     $astman->database_del("blacklist",$number);
185   } else {
186     fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);
187   }
188 }
189
190 function blacklist_add($post){
191   global $amp_conf;
192   global $astman;
193
194   if(!blacklist_chk($post))
195     return false;
196
197   extract($post);
198   if ($astman) {
199     $astman->database_put("blacklist",$number, '1');
200   } else {
201     fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);
202   }
203 }
204
205
206 // ensures post vars is valid
207 function blacklist_chk($post){
208   return true;
209 }
210
211 ?>
Note: See TracBrowser for help on using the browser.