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

Revision 4390, 7.9 kB (checked in by p_lindheimer, 6 years ago)

#2061: added waitexten to fix Asterisk 1.4

  • 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         switch($engine) {
9                 case "asterisk":
10
11           $id = "app-blacklist";
12           $ext->addInclude('from-internal-additional', $id); // Add the include from from-internal
13
14           $id = "app-blacklist-check";
15           $c = "s";
16                       $ext->add($id, $c, '', new ext_lookupblacklist(''));
17                       $ext->add($id, $c, '', new ext_gotoif('$["${LOOKUPBLSTATUS}"="FOUND"]', 'blacklisted'));
18                       $ext->add($id, $c, '', new ext_return(''));
19                       $ext->add($id, $c, 'blacklisted', new ext_answer(''));
20                       $ext->add($id, $c, '', new ext_wait(1));
21                       $ext->add($id, $c, '', new ext_zapateller(''));
22                       $ext->add($id, $c, '', new ext_playback('ss-noservice'));
23                       $ext->add($id, $c, '', new ext_hangup(''));
24
25           $modulename = 'blacklist';
26
27                         if (is_array($featurelist = featurecodes_getModuleFeatures($modulename))) {
28                                 foreach($featurelist as $item) {
29                                         $featurename = $item['featurename'];
30                                         $fname = $modulename.'_'.$featurename;
31                                         if (function_exists($fname)) {
32                                                 $fcc = new featurecode($modulename, $featurename);
33                                                 $fc = $fcc->getCodeActive();
34                                                 unset($fcc);
35
36                                                 if ($fc != '')
37                                                         $fname($fc);
38                                         } else {
39                                                 $ext->add('from-internal-additional', 'debug', '', new ext_noop($modulename.": No func $fname"));
40                                                 var_dump($item);
41                                         }
42                                 }
43                         }
44
45                       break;
46         }
47 }
48
49 function blacklist_blacklist_add($fc) {
50   global $ext;
51
52   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-add'));
53
54   $id = "app-blacklist-add";
55   $c = "s";
56   $ext->add($id, $c, '', new ext_answer);
57   $ext->add($id, $c, '', new ext_wait(1));
58   $ext->add($id, $c, '', new ext_Playback('enter-num-blacklist'));
59   $ext->add($id, $c, '', new ext_digittimeout(5));
60   $ext->add($id, $c, '', new ext_responsetimeout(60));
61   $ext->add($id, $c, '', new ext_read('blacknr', 'then-press-pound'));
62   $ext->add($id, $c, '', new ext_saydigits('${blacknr}'));
63   $ext->add($id, $c, '', new ext_Playback('if-correct-press&digits/1'));
64   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
65   $ext->add($id, $c, 'end', new ext_waitexten(60));
66   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
67   $c = "1";
68   $ext->add($id, $c, '', new ext_set('DB(blacklist/${blacknr})', 1));
69   $ext->add($id, $c, '', new ext_Playback('num-was-successfully&added'));
70   $ext->add($id, $c, '', new ext_wait(1));
71   $ext->add($id, $c, '', new ext_hangup);
72 }
73
74 function blacklist_blacklist_remove($fc) {
75   global $ext;
76
77   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-remove'));
78
79   $id = "app-blacklist-remove";
80   $c = "s";
81   $ext->add($id, $c, '', new ext_answer);
82   $ext->add($id, $c, '', new ext_wait(1));
83   $ext->add($id, $c, '', new ext_Playback('entr-num-rmv-blklist'));
84   $ext->add($id, $c, '', new ext_digittimeout(5));
85   $ext->add($id, $c, '', new ext_responsetimeout(60));
86   $ext->add($id, $c, '', new ext_read('blacknr', 'then-press-pound'));
87   $ext->add($id, $c, '', new ext_saydigits('${blacknr}'));
88   $ext->add($id, $c, '', new ext_Playback('if-correct-press&digits/1'));
89   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
90   $ext->add($id, $c, 'end', new ext_waitexten(60));
91   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
92   $c = "1";
93   $ext->add($id, $c, '', new ext_dbdel('blacklist/${blacknr}'));
94   $ext->add($id, $c, '', new ext_Playback('num-was-successfully&removed'));
95   $ext->add($id, $c, '', new ext_wait(1));
96   $ext->add($id, $c, '', new ext_hangup);
97 }
98
99 function blacklist_blacklist_last($fc) {
100   global $ext;
101
102   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-last'));
103
104   $id = "app-blacklist-last";
105   $c = "s";
106   $ext->add($id, $c, '', new ext_answer);
107   $ext->add($id, $c, '', new ext_wait(1));
108   $ext->add($id, $c, '', new ext_setvar('lastcaller', '${DB(CALLTRACE/${CALLERID(number)})}'));
109   $ext->add($id, $c, '', new ext_gotoif('$[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]', 'noinfo'));
110   $ext->add($id, $c, '', new ext_playback('privacy-to-blacklist-last-caller&telephone-number'));
111   $ext->add($id, $c, '', new ext_saydigits('${lastcaller}'));
112   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(digit)', '3'));
113   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(response)', '7'));
114   $ext->add($id, $c, '', new ext_Playback('if-correct-press&digits/1'));
115   $ext->add($id, $c, '', new ext_goto('end'));
116   $ext->add($id, $c, 'noinfo', new ext_playback('unidentified-no-callback'));
117   $ext->add($id, $c, '', new ext_hangup);
118   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
119   $ext->add($id, $c, 'end', new ext_waitexten(60));
120   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
121   $c = "1";
122   $ext->add($id, $c, '', new ext_set('DB(blacklist/${lastcaller})', 1));
123   $ext->add($id, $c, '', new ext_Playback('num-was-successfully'));
124   $ext->add($id, $c, '', new ext_Playback('added'));
125   $ext->add($id, $c, '', new ext_wait(1));
126   $ext->add($id, $c, '', new ext_hangup);
127 }
128
129 function blacklist_hookGet_config($engine) {
130         global $ext;
131         switch($engine) {
132                 case "asterisk":
133                 // Code from modules/core/functions.inc.php core_get_config inbound routes
134       $didlist = core_did_list();
135       if (is_array($didlist)) {
136         foreach ($didlist as $item) {
137           $did = core_did_get($item['extension'],$item['cidnum'],$item['channel']);
138                           $exten = $item['extension'];
139                           $cidnum = $item['cidnum'];
140                           $channel = $item['channel'];
141
142                           $exten = (empty($exten)?"s":$exten);
143                           $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it
144
145                           if (empty($channel))
146                             $context = "ext-did";
147                           else
148                             $context = "macro-from-zaptel-{$channel}";
149
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.