root/modules/branches/2.4/core/agi-bin/recordingcheck

Revision 5823, 3.9 kB (checked in by p_lindheimer, 4 years ago)

#2857 recording check should check all extensions in a ringgroup in case bogus entries exist

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
Line 
1 #!/usr/bin/php -q
2 <?php
3 /**
4 // recordingcheck Copyright (C) Coalescent Systems Inc. (info@coalescentsystems.ca)
5 // Asterisk Management Portal Copyright (C) 2004 Coalescent Systems Inc. (info@coalescentsystems.ca)
6 //
7 //This program is free software; you can redistribute it and/or
8 //modify it under the terms of the GNU General Public License
9 //as published by the Free Software Foundation; either version 2
10 //of the License, or (at your option) any later version.
11 //
12 //This program is distributed in the hope that it will be useful,
13 //but WITHOUT ANY WARRANTY; without even the implied warranty of
14 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 //GNU General Public License for more details.
16
17 The program checks determines if Asterisk should record a call
18 */
19
20 /* --------WARNING---------
21  *
22  * This script is auto-copied from an included module and will get overwritten.
23  * If you modify it, you must change it to write only, in the agi-bin directory,
24  * to keep it from getting changed.
25  */
26
27
28 include("phpagi.php");
29
30
31 /**********************************************************************************************************************/
32
33 $agi = new AGI();
34
35 $timestamp = $argv[1];
36 $uniqueid = $argv[2];
37 $type = $agi->get_variable("ARG2");
38
39 switch($type['data']) {
40   case "Group":
41  
42     $r = $agi->get_variable("ARG1");
43     if ($r["result"] == 0) {
44       $agi->verbose("Extension List not set -- nothing to do");
45       exit(1);
46     }
47     $extenlist = $r["data"];
48    
49     $agi->set_variable("RecEnable", "DISABLED"); //disable by default
50    
51     $list = explode("-",$extenlist);
52     if(!empty($list)) {
53       foreach($list as $exten) {
54         $setting = $agi->database_get("AMPUSER",$exten."/recording");
55         if ($setting["result"] == 0) {
56           $agi->verbose("No DB Entry AMPUSER/$exten/recording - Not Recording for $exten, checking for others");
57           continue;
58         }
59         //explode recording vars
60         $recording = explode("|",$setting["data"]);
61         $recout = substr($recording[0],4);
62         $recin = substr($recording[1],3);
63         if ($recin == "Always") {
64           $agi->verbose("Recording enable for ".$exten);
65           $agi->verbose("CALLFILENAME=g{$exten}-{$timestamp}-{$uniqueid}");
66           $agi->set_variable("CALLFILENAME","g{$exten}-{$timestamp}-{$uniqueid}");
67           $agi->set_priority(999);
68           exit(0);
69         }
70       }
71     } else {
72       $agi->verbose("Extension List is empty -- nothing to do");
73       exit(1);   
74     }
75  
76   break;
77   case "OUT":
78     $exten = $agi->get_variable("ARG1");
79    
80     $options = $agi->database_get("AMPUSER","{$exten['data']}/recording");
81    
82     if ($options["result"] == "0") {
83       $agi->verbose("No AMPUSER db entry for ".$exten["data"].". Not recording");
84       exit(1);   
85     }
86
87     //explode recording vars
88     $recording = explode("|",$options["data"]);
89     $recout = substr($recording[0],4);
90     $recin = substr($recording[1],3);
91  
92     if($recout == "Always") {
93       $agi->verbose("Outbound recording enabled.");
94       $agi->verbose("CALLFILENAME=OUT{$exten['data']}-{$timestamp}-{$uniqueid}");
95       $agi->set_variable("CALLFILENAME","OUT{$exten['data']}-{$timestamp}-{$uniqueid}");
96       $agi->set_priority(999);
97       exit(0);
98     } else {
99       $agi->verbose("Outbound recording not enabled");
100       exit(1);   
101     }
102   break;
103   case "IN":
104     $exten = $agi->get_variable("ARG1"); 
105     $options = $agi->database_get("AMPUSER","{$exten['data']}/recording");
106    
107     if ($options["result"] == "0") {
108       $agi->verbose("No AMPUSER db entry for ".$exten["data"].". Not recording");
109       exit(1);   
110     }
111     //explode recording vars
112     $recording = explode("|",$options["data"]);
113     $recout = substr($recording[0],4);
114     $recin = substr($recording[1],3);
115    
116     if($recin == "Always")  {
117       $agi->verbose("Inbound recording enabled.");
118       $agi->verbose("CALLFILENAME={$timestamp}-{$uniqueid}");
119       $agi->set_variable("CALLFILENAME","{$timestamp}-{$uniqueid}");
120       $agi->set_priority(999);
121       exit(0); 
122     } else {
123       $agi->verbose("Inbound recording not enabled");
124       exit(1);   
125     }
126   break;
127 }
128
129 // we just exit with no changes to the variable.
130 exit(1);
131
132 ?>
Note: See TracBrowser for help on using the browser.