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

Revision 4880, 8.1 kB (checked in by p_lindheimer, 6 years ago)

#2107 some more ext_watiexten got missed, fixed

  • 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, 'end', new extension('WaitExten(60)'));
67   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
68   $c = "1";
69   $ext->add($id, $c, '', new ext_set('DB(blacklist/${blacknr})', 1));
70   $ext->add($id, $c, '', new ext_Playback('num-was-successfully&added'));
71   $ext->add($id, $c, '', new ext_wait(1));
72   $ext->add($id, $c, '', new ext_hangup);
73 }
74
75 function blacklist_blacklist_remove($fc) {
76   global $ext;
77
78   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-remove'));
79
80   $id = "app-blacklist-remove";
81   $c = "s";
82   $ext->add($id, $c, '', new ext_answer);
83   $ext->add($id, $c, '', new ext_wait(1));
84   $ext->add($id, $c, '', new ext_Playback('entr-num-rmv-blklist'));
85   $ext->add($id, $c, '', new ext_digittimeout(5));
86   $ext->add($id, $c, '', new ext_responsetimeout(60));
87   $ext->add($id, $c, '', new ext_read('blacknr', 'then-press-pound'));
88   $ext->add($id, $c, '', new ext_saydigits('${blacknr}'));
89   $ext->add($id, $c, '', new ext_Playback('if-correct-press&digits/1'));
90   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
91   //$ext->add($id, $c, 'end', new ext_waitexten(60));
92   $ext->add($id, $c, 'end', new extension('WaitExten(60)'));
93   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
94   $c = "1";
95   $ext->add($id, $c, '', new ext_dbdel('blacklist/${blacknr}'));
96   $ext->add($id, $c, '', new ext_Playback('num-was-successfully&removed'));
97   $ext->add($id, $c, '', new ext_wait(1));
98   $ext->add($id, $c, '', new ext_hangup);
99 }
100
101 function blacklist_blacklist_last($fc) {
102   global $ext;
103
104   $ext->add('app-blacklist', $fc, '', new ext_goto('1', 's', 'app-blacklist-last'));
105
106   $id = "app-blacklist-last";
107   $c = "s";
108   $ext->add($id, $c, '', new ext_answer);
109   $ext->add($id, $c, '', new ext_wait(1));
110   $ext->add($id, $c, '', new ext_setvar('lastcaller', '${DB(CALLTRACE/${CALLERID(number)})}'));
111   $ext->add($id, $c, '', new ext_gotoif('$[ $[ "${lastcaller}" = "" ] | $[ "${lastcaller}" = "unknown" ] ]', 'noinfo'));
112   $ext->add($id, $c, '', new ext_playback('privacy-to-blacklist-last-caller&telephone-number'));
113   $ext->add($id, $c, '', new ext_saydigits('${lastcaller}'));
114   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(digit)', '3'));
115   $ext->add($id, $c, '', new ext_setvar('TIMEOUT(response)', '7'));
116   $ext->add($id, $c, '', new ext_Playback('if-correct-press&digits/1'));
117   $ext->add($id, $c, '', new ext_goto('end'));
118   $ext->add($id, $c, 'noinfo', new ext_playback('unidentified-no-callback'));
119   $ext->add($id, $c, '', new ext_hangup);
120   $ext->add($id, $c, '', new ext_noop('Waiting for input'));
121   //$ext->add($id, $c, 'end', new ext_waitexten(60));
122   $ext->add($id, $c, 'end', new extension('WaitExten(60)')); // n,VoiceMailMain(${VMCONTEXT})
123   $ext->add($id, $c, '', new ext_Playback('sorry-youre-having-problems&goodbye'));
124   $c = "1";
125   $ext->add($id, $c, '', new ext_set('DB(blacklist/${lastcaller})', 1));
126   $ext->add($id, $c, '', new ext_Playback('num-was-successfully'));
127   $ext->add($id, $c, '', new ext_Playback('added'));
128   $ext->add($id, $c, '', new ext_wait(1));
129   $ext->add($id, $c, '', new ext_hangup);
130 }
131
132 function blacklist_hookGet_config($engine) {
133         global $ext;
134         switch($engine) {
135                 case "asterisk":
136                 // Code from modules/core/functions.inc.php core_get_config inbound routes
137       $didlist = core_did_list();
138       if (is_array($didlist)) {
139         foreach ($didlist as $item) {
140           $did = core_did_get($item['extension'],$item['cidnum'],$item['channel']);
141                           $exten = $item['extension'];
142                           $cidnum = $item['cidnum'];
143                           $channel = $item['channel'];
144
145                           $exten = (empty($exten)?"s":$exten);
146                           $exten = $exten.(empty($cidnum)?"":"/".$cidnum); //if a CID num is defined, add it
147
148                           if (empty($channel))
149                             $context = "ext-did";
150                           else
151                             $context = "macro-from-zaptel-{$channel}";
152
153                           $ext->splice($context, $exten, 1, new ext_gosub('1', 's', 'app-blacklist-check'));
154         }
155       } // else no DID's defined. Not even a catchall.
156                 break;
157         }
158 }
159
160 function blacklist_list() {
161   global $amp_conf;
162   global $astman;
163
164         if ($astman) {
165     $list = $astman->database_show();
166     foreach ($list as $k => $v) {
167       if (substr($k, 1, 9) == 'blacklist')
168       {
169         $numbers[substr($k, 11)] = substr($k, 11);
170       }
171     }
172
173     if (isset($numbers) && is_array($numbers))
174       natcasesort($numbers);
175
176     return isset($numbers)?$numbers:null;
177         } else {
178                 fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);
179         }
180 }
181
182 function blacklist_del($number){
183   global $amp_conf;
184   global $astman;
185
186   if ($astman) {
187     $astman->database_del("blacklist",$number);
188   } else {
189     fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);
190   }
191 }
192
193 function blacklist_add($post){
194   global $amp_conf;
195   global $astman;
196
197   if(!blacklist_chk($post))
198     return false;
199
200   extract($post);
201   if ($astman) {
202     $astman->database_put("blacklist",$number, '1');
203   } else {
204     fatal("Cannot connect to Asterisk Manager with ".$amp_conf["AMPMGRUSER"]."/".$amp_conf["AMPMGRPASS"]);
205   }
206 }
207
208
209 // ensures post vars is valid
210 function blacklist_chk($post){
211   return true;
212 }
213
214 ?>
Note: See TracBrowser for help on using the browser.