root/modules/branches/2.10/paging/agi-bin/page.agi

Revision 12942, 2.0 kB (checked in by mbrevda, 2 years ago)

closes #5443 - paging improvements, revert some accidental checkins. Bugs/more features in NEW tickets please

Line 
1 #!/usr/bin/php -q
2 <?php
3 //include freepbx configuration
4 $restrict_mods = true;
5 if (!@include_once(getenv('FREEPBX_CONF') ? getenv('FREEPBX_CONF') : '/etc/freepbx.conf')) {
6     include_once('/etc/asterisk/freepbx.conf');
7 }
8 list($agi, $vars) = __agi();
9 $vars['extensions'] = explode(':', $vars['extensions']);
10 dbug('extensions', $vars);
11
12 /* TODO: run through the list here first and check for:
13  *       extension -- current device doing the page and yank them out if so
14  *       if not force page -- check if target extension (or is it device) is busy if so pull out of list
15  *       future - check if each specific extension needs modifications to auto-answer channel variables
16  *                so the conditional assignments can be skipped
17  *
18  *       extension will have to be changed to the raw extension and more intelligence added to here to
19  *       properly accomodated the above, and then changes to the auto-answer macro, etc.
20  */
21
22 foreach ($vars['extensions'] as $ext) {   
23     /*if (strstr($ext, $vars['AMPUSER'] . '@ext-paging')) {
24         continue;
25     }*/
26     $astman->Originate(array(
27                             'Channel'        => $ext,
28                             'CallerID'        => $vars['calleridname'] . ' <' . $vars['callerid'] . '>',
29                             'Async'            => 'true',
30                             'Set'            => 'AMPUSER=' . $vars['AMPUSER'],
31                             'Application'    => 'meetme',
32                             'Data'            => $vars['meetmeopts']
33                             ));
34 }
35
36 function __agi(){
37     require_once('phpagi.php');
38     $agi=new AGI();
39     foreach($agi->request as $key => $value){//strip agi_ prefix from keys
40         if(substr($key,0,4)=='agi_'){
41             $opts[substr($key,4)]=$value;
42         }
43     }
44
45     foreach($opts as $key => $value){//get passed in vars
46         if(substr($key,0,4)=='arg_'){
47             $expld=explode('=',$value);
48             $opts[$expld[0]]=$expld[1];
49             unset($opts[$key]);
50         }
51     }
52     
53     array_shift($_SERVER['argv']);
54     foreach($_SERVER['argv'] as $arg){
55         $arg=explode('=',$arg);
56         //remove leading '--'
57         if(substr($arg['0'],0,2) == '--'){$arg['0']=substr($arg['0'],2);}
58         $opts[$arg['0']]=isset($arg['1'])?$arg['1']:null;
59     }
60
61     return array($agi, $opts);
62 }
63 ?>
64
Note: See TracBrowser for help on using the browser.