@@ -41,6 +41,9 @@ |
||
41 | 41 | */ |
42 | 42 | if ( ! function_exists('singular')) |
43 | 43 | { |
44 | + /** |
|
45 | + * @param string $str |
|
46 | + */ |
|
44 | 47 | function singular($str) |
45 | 48 | { |
46 | 49 | $result = strval($str); |
@@ -27,18 +27,18 @@ discard block |
||
27 | 27 | private $errorCallbackFunction; |
28 | 28 | private $errorMsgFormat; |
29 | 29 | public function __construct($dsn = "", $user = "", $passwd = "") { |
30 | - $config = parse_ini_file ( "/var/lib/astpp/astpp-config.conf" ); |
|
30 | + $config = parse_ini_file("/var/lib/astpp/astpp-config.conf"); |
|
31 | 31 | |
32 | - $options = array ( |
|
32 | + $options = array( |
|
33 | 33 | PDO::ATTR_PERSISTENT => true, |
34 | 34 | PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION |
35 | 35 | ); |
36 | 36 | |
37 | 37 | try { |
38 | - parent::__construct ( "mysql:host=" . $config ['dbhost'] . ";dbname=" . $config ['dbname'] . "", $config ['dbuser'], $config ['dbpass'], $options ); |
|
39 | - } catch ( PDOException $e ) { |
|
38 | + parent::__construct("mysql:host=".$config ['dbhost'].";dbname=".$config ['dbname']."", $config ['dbuser'], $config ['dbpass'], $options); |
|
39 | + } catch (PDOException $e) { |
|
40 | 40 | |
41 | - $this->error = $e->getMessage (); |
|
41 | + $this->error = $e->getMessage(); |
|
42 | 42 | } |
43 | 43 | echo $this->error; |
44 | 44 | } |
@@ -48,39 +48,39 @@ discard block |
||
48 | 48 | * @param string $bind |
49 | 49 | */ |
50 | 50 | public function cleanup($bind) { |
51 | - if (! is_array ( $bind )) { |
|
52 | - if (! empty ( $bind )) |
|
53 | - $bind = array ( |
|
51 | + if ( ! is_array($bind)) { |
|
52 | + if ( ! empty ($bind)) |
|
53 | + $bind = array( |
|
54 | 54 | $bind |
55 | 55 | ); |
56 | 56 | else |
57 | - $bind = array (); |
|
57 | + $bind = array(); |
|
58 | 58 | } |
59 | 59 | return $bind; |
60 | 60 | } |
61 | 61 | public function run($sql, $bind = "") { |
62 | - $this->sql = trim ( $sql ); |
|
63 | - $this->bind = $this->cleanup ( $bind ); |
|
62 | + $this->sql = trim($sql); |
|
63 | + $this->bind = $this->cleanup($bind); |
|
64 | 64 | $this->error = ""; |
65 | 65 | |
66 | 66 | try { |
67 | - $pdostmt = $this->prepare ( $this->sql ); |
|
68 | - if ($pdostmt->execute ( $this->bind ) !== false) { |
|
69 | - if (preg_match ( "/^(" . implode ( "|", array ( |
|
67 | + $pdostmt = $this->prepare($this->sql); |
|
68 | + if ($pdostmt->execute($this->bind) !== false) { |
|
69 | + if (preg_match("/^(".implode("|", array( |
|
70 | 70 | "select", |
71 | 71 | "describe", |
72 | 72 | "pragma" |
73 | - ) ) . ") /i", $this->sql )) |
|
74 | - return $pdostmt->fetchAll ( PDO::FETCH_ASSOC ); |
|
75 | - elseif (preg_match ( "/^(" . implode ( "|", array ( |
|
73 | + )).") /i", $this->sql)) |
|
74 | + return $pdostmt->fetchAll(PDO::FETCH_ASSOC); |
|
75 | + elseif (preg_match("/^(".implode("|", array( |
|
76 | 76 | "delete", |
77 | 77 | "insert", |
78 | 78 | "update" |
79 | - ) ) . ") /i", $this->sql )) |
|
80 | - return $pdostmt->rowCount (); |
|
79 | + )).") /i", $this->sql)) |
|
80 | + return $pdostmt->rowCount(); |
|
81 | 81 | } |
82 | - } catch ( PDOException $e ) { |
|
83 | - $this->error = $e->getMessage (); |
|
82 | + } catch (PDOException $e) { |
|
83 | + $this->error = $e->getMessage(); |
|
84 | 84 | return $this->error; |
85 | 85 | } |
86 | 86 | } |
@@ -49,12 +49,13 @@ discard block |
||
49 | 49 | */ |
50 | 50 | public function cleanup($bind) { |
51 | 51 | if (! is_array ( $bind )) { |
52 | - if (! empty ( $bind )) |
|
53 | - $bind = array ( |
|
52 | + if (! empty ( $bind )) { |
|
53 | + $bind = array ( |
|
54 | 54 | $bind |
55 | 55 | ); |
56 | - else |
|
57 | - $bind = array (); |
|
56 | + } else { |
|
57 | + $bind = array (); |
|
58 | + } |
|
58 | 59 | } |
59 | 60 | return $bind; |
60 | 61 | } |
@@ -70,14 +71,15 @@ discard block |
||
70 | 71 | "select", |
71 | 72 | "describe", |
72 | 73 | "pragma" |
73 | - ) ) . ") /i", $this->sql )) |
|
74 | - return $pdostmt->fetchAll ( PDO::FETCH_ASSOC ); |
|
75 | - elseif (preg_match ( "/^(" . implode ( "|", array ( |
|
74 | + ) ) . ") /i", $this->sql )) { |
|
75 | + return $pdostmt->fetchAll ( PDO::FETCH_ASSOC ); |
|
76 | + } elseif (preg_match ( "/^(" . implode ( "|", array ( |
|
76 | 77 | "delete", |
77 | 78 | "insert", |
78 | 79 | "update" |
79 | - ) ) . ") /i", $this->sql )) |
|
80 | - return $pdostmt->rowCount (); |
|
80 | + ) ) . ") /i", $this->sql )) { |
|
81 | + return $pdostmt->rowCount (); |
|
82 | + } |
|
81 | 83 | } |
82 | 84 | } catch ( PDOException $e ) { |
83 | 85 | $this->error = $e->getMessage (); |
@@ -23,7 +23,7 @@ discard block |
||
23 | 23 | |
24 | 24 | // If module/app not found |
25 | 25 | function xml_not_found() { |
26 | - header ( 'Content-Type: text/xml' ); |
|
26 | + header('Content-Type: text/xml'); |
|
27 | 27 | |
28 | 28 | $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; |
29 | 29 | $xml .= "<document type=\"freeswitch/xml\">\n"; |
@@ -46,28 +46,28 @@ discard block |
||
46 | 46 | |
47 | 47 | // For customer and provider ips |
48 | 48 | $query = "SELECT ip FROM ip_map,accounts WHERE ip_map.accountid=accounts.id AND ip_map.status=0 AND accounts.status=0 AND accounts.deleted=0"; |
49 | - $logger->log ( "ACL Query : " . $query ); |
|
50 | - $res_acl = $db->run ( $query ); |
|
51 | - $logger->log ( $res_acl ); |
|
49 | + $logger->log("ACL Query : ".$query); |
|
50 | + $res_acl = $db->run($query); |
|
51 | + $logger->log($res_acl); |
|
52 | 52 | |
53 | - foreach ( $res_acl as $res_acl_key => $res_acl_value ) { |
|
54 | - $xml .= " <node type=\"allow\" cidr=\"" . $res_acl_value ['ip'] . "\"/>\n"; |
|
53 | + foreach ($res_acl as $res_acl_key => $res_acl_value) { |
|
54 | + $xml .= " <node type=\"allow\" cidr=\"".$res_acl_value ['ip']."\"/>\n"; |
|
55 | 55 | } |
56 | 56 | |
57 | 57 | // For gateways |
58 | 58 | $query = "SELECT * FROM gateways WHERE status=0"; |
59 | - $logger->log ( "Sofia Gateway Query : " . $query ); |
|
60 | - $sp_gw = $db->run ( $query ); |
|
61 | - $logger->log ( $sp_gw ); |
|
59 | + $logger->log("Sofia Gateway Query : ".$query); |
|
60 | + $sp_gw = $db->run($query); |
|
61 | + $logger->log($sp_gw); |
|
62 | 62 | |
63 | - foreach ( $sp_gw as $sp_gw_key => $sp_gw_value ) { |
|
63 | + foreach ($sp_gw as $sp_gw_key => $sp_gw_value) { |
|
64 | 64 | |
65 | - $sp_gw_settings = json_decode ( $sp_gw_value ['gateway_data'], true ); |
|
66 | - foreach ( $sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value ) { |
|
65 | + $sp_gw_settings = json_decode($sp_gw_value ['gateway_data'], true); |
|
66 | + foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) { |
|
67 | 67 | if ($sp_gw_settings_value != "" && $sp_gw_settings_key == "proxy") { |
68 | - $tmp_ip_arr = explode ( ":", $sp_gw_settings_value ); |
|
69 | - if (! filter_var ( $tmp_ip_arr [0], FILTER_VALIDATE_IP ) === false) { |
|
70 | - $xml .= " <node type=\"allow\" cidr=\"" . $tmp_ip_arr [0] . "/32\"/>\n"; |
|
68 | + $tmp_ip_arr = explode(":", $sp_gw_settings_value); |
|
69 | + if ( ! filter_var($tmp_ip_arr [0], FILTER_VALIDATE_IP) === false) { |
|
70 | + $xml .= " <node type=\"allow\" cidr=\"".$tmp_ip_arr [0]."/32\"/>\n"; |
|
71 | 71 | } |
72 | 72 | } |
73 | 73 | } |
@@ -75,7 +75,7 @@ discard block |
||
75 | 75 | |
76 | 76 | // For opensips |
77 | 77 | if ($config ['opensips'] == '0') { |
78 | - $xml .= "<node type=\"allow\" cidr=\"" . $config ['opensips_domain'] . "/32\"/>\n"; |
|
78 | + $xml .= "<node type=\"allow\" cidr=\"".$config ['opensips_domain']."/32\"/>\n"; |
|
79 | 79 | } |
80 | 80 | |
81 | 81 | $xml .= " </list>\n"; |
@@ -83,20 +83,20 @@ discard block |
||
83 | 83 | // For loopback |
84 | 84 | if ($config ['opensips'] == '0') { |
85 | 85 | $xml .= "<list name=\"loopback.auto\" default=\"allow\">\n"; |
86 | - $xml .= "<node type=\"allow\" cidr=\"" . $config ['opensips_domain'] . "/32\"/>\n"; |
|
86 | + $xml .= "<node type=\"allow\" cidr=\"".$config ['opensips_domain']."/32\"/>\n"; |
|
87 | 87 | $xml .= "</list>\n"; |
88 | 88 | } |
89 | 89 | |
90 | 90 | // For event handing |
91 | 91 | $xml .= "<list name=\"event\" default=\"deny\">\n"; |
92 | - $xml .= ($config ['opensips'] == "0") ? "<node type=\"allow\" cidr=\"" . $config ['opensips_domain'] . "/32\"/>\n" : "\n"; |
|
92 | + $xml .= ($config ['opensips'] == "0") ? "<node type=\"allow\" cidr=\"".$config ['opensips_domain']."/32\"/>\n" : "\n"; |
|
93 | 93 | $xml .= "<node type=\"allow\" cidr=\"127.0.0.0/8\"/>\n"; |
94 | 94 | $xml .= "</list>\n"; |
95 | 95 | $xml .= " </network-lists>\n"; |
96 | 96 | $xml .= " </configuration>\n"; |
97 | 97 | $xml .= " </section>\n"; |
98 | 98 | $xml .= "</document>\n"; |
99 | - $logger->log ( $xml ); |
|
99 | + $logger->log($xml); |
|
100 | 100 | return $xml; |
101 | 101 | } |
102 | 102 | |
@@ -109,18 +109,18 @@ discard block |
||
109 | 109 | $xml .= " <profiles>\n"; |
110 | 110 | |
111 | 111 | $query = "SELECT * FROM sip_profiles WHERE status=0"; |
112 | - $logger->log ( "Sofia Query : " . $query ); |
|
113 | - $res_sp = $db->run ( $query ); |
|
112 | + $logger->log("Sofia Query : ".$query); |
|
113 | + $res_sp = $db->run($query); |
|
114 | 114 | // $logger->log($res_sp); |
115 | 115 | |
116 | - foreach ( $res_sp as $sp_key => $sp_value ) { |
|
116 | + foreach ($res_sp as $sp_key => $sp_value) { |
|
117 | 117 | |
118 | - $settings = json_decode ( $sp_value ['profile_data'], true ); |
|
118 | + $settings = json_decode($sp_value ['profile_data'], true); |
|
119 | 119 | // $logger->log(print_r($settings,true)); |
120 | - $xml .= " <profile name=\"" . $sp_value ['name'] . "\">\n"; |
|
120 | + $xml .= " <profile name=\"".$sp_value ['name']."\">\n"; |
|
121 | 121 | |
122 | 122 | $xml .= " <domains>\n"; |
123 | - $xml .= " <domain name=\"" . $sp_value ['sip_ip'] . "\" alias=\"true\" parse=\"true\"/>\n"; |
|
123 | + $xml .= " <domain name=\"".$sp_value ['sip_ip']."\" alias=\"true\" parse=\"true\"/>\n"; |
|
124 | 124 | $xml .= " </domains>\n"; |
125 | 125 | /* |
126 | 126 | * $xml .= " <aliases>\n"; |
@@ -129,26 +129,26 @@ discard block |
||
129 | 129 | */ |
130 | 130 | |
131 | 131 | $xml .= " <settings>\n"; |
132 | - $xml .= " <param name=\"sip-ip\" value=\"" . $sp_value ['sip_ip'] . "\"/>\n"; |
|
133 | - $xml .= " <param name=\"sip-port\" value=\"" . $sp_value ['sip_port'] . "\"/>\n"; |
|
134 | - foreach ( $settings as $set_key => $set_val ) { |
|
135 | - $xml .= " <param name=\"" . $set_key . "\" value=\"" . $set_val . "\"/>\n"; |
|
132 | + $xml .= " <param name=\"sip-ip\" value=\"".$sp_value ['sip_ip']."\"/>\n"; |
|
133 | + $xml .= " <param name=\"sip-port\" value=\"".$sp_value ['sip_port']."\"/>\n"; |
|
134 | + foreach ($settings as $set_key => $set_val) { |
|
135 | + $xml .= " <param name=\"".$set_key."\" value=\"".$set_val."\"/>\n"; |
|
136 | 136 | } |
137 | 137 | $xml .= " </settings>\n"; |
138 | 138 | |
139 | 139 | // Gateway block start |
140 | 140 | $xml .= " <gateways>\n"; |
141 | - $query = "SELECT * FROM gateways WHERE sip_profile_id=" . $sp_value ['id'] . " AND status=0"; |
|
142 | - $logger->log ( "Sofia Gateway Query : " . $query ); |
|
143 | - $sp_gw = $db->run ( $query ); |
|
144 | - $logger->log ( $sp_gw ); |
|
145 | - foreach ( $sp_gw as $sp_gw_key => $sp_gw_value ) { |
|
146 | - $xml .= " <gateway name=\"" . $sp_gw_value ['name'] . "\">\n"; |
|
141 | + $query = "SELECT * FROM gateways WHERE sip_profile_id=".$sp_value ['id']." AND status=0"; |
|
142 | + $logger->log("Sofia Gateway Query : ".$query); |
|
143 | + $sp_gw = $db->run($query); |
|
144 | + $logger->log($sp_gw); |
|
145 | + foreach ($sp_gw as $sp_gw_key => $sp_gw_value) { |
|
146 | + $xml .= " <gateway name=\"".$sp_gw_value ['name']."\">\n"; |
|
147 | 147 | |
148 | - $sp_gw_settings = json_decode ( $sp_gw_value ['gateway_data'], true ); |
|
149 | - foreach ( $sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value ) { |
|
148 | + $sp_gw_settings = json_decode($sp_gw_value ['gateway_data'], true); |
|
149 | + foreach ($sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value) { |
|
150 | 150 | if ($sp_gw_settings_value != "") |
151 | - $xml .= " <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n"; |
|
151 | + $xml .= " <param name=\"".$sp_gw_settings_key."\" value=\"".$sp_gw_settings_value."\"/>\n"; |
|
152 | 152 | } |
153 | 153 | $xml .= " </gateway>\n"; |
154 | 154 | } |
@@ -162,47 +162,47 @@ discard block |
||
162 | 162 | $xml .= " </configuration>\n"; |
163 | 163 | $xml .= " </section>\n"; |
164 | 164 | $xml .= "</document>\n"; |
165 | - $logger->log ( $xml ); |
|
165 | + $logger->log($xml); |
|
166 | 166 | return $xml; |
167 | 167 | } |
168 | 168 | function update_vm_data($logger, $db, $password, $user) { |
169 | - $query = "SELECT * FROM sip_devices where username='" . $_REQUEST ['user'] . "' limit 1"; |
|
170 | - $logger->log ( "Directory Query : " . $query ); |
|
171 | - $res_dir = $db->run ( $query ); |
|
172 | - $params = json_decode ( $res_dir [0] ['dir_params'], true ); |
|
169 | + $query = "SELECT * FROM sip_devices where username='".$_REQUEST ['user']."' limit 1"; |
|
170 | + $logger->log("Directory Query : ".$query); |
|
171 | + $res_dir = $db->run($query); |
|
172 | + $params = json_decode($res_dir [0] ['dir_params'], true); |
|
173 | 173 | $params ['vm-password'] = $password; |
174 | 174 | |
175 | - $query = "update sip_devices set dir_params = '" . json_encode ( $params, true ) . "' where username='" . $_REQUEST ['user'] . "' limit 1"; |
|
176 | - $res_dir = $db->run ( $query ); |
|
175 | + $query = "update sip_devices set dir_params = '".json_encode($params, true)."' where username='".$_REQUEST ['user']."' limit 1"; |
|
176 | + $res_dir = $db->run($query); |
|
177 | 177 | } |
178 | 178 | |
179 | 179 | // Build directory xml |
180 | 180 | function load_directory($logger, $db) { |
181 | 181 | $xml = ""; |
182 | 182 | |
183 | - $query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE sip_devices.status=0 AND accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='" . $_REQUEST ['user'] . "' limit 1"; |
|
183 | + $query = "SELECT username,dir_params,dir_vars,number as accountcode,accountid FROM sip_devices,accounts WHERE sip_devices.status=0 AND accounts.status=0 AND accounts.deleted=0 AND accounts.id=sip_devices.accountid AND username='".$_REQUEST ['user']."' limit 1"; |
|
184 | 184 | |
185 | - $logger->log ( "Directory Query : " . $query ); |
|
186 | - $res_dir = $db->run ( $query ); |
|
187 | - $logger->log ( $res_dir ); |
|
185 | + $logger->log("Directory Query : ".$query); |
|
186 | + $res_dir = $db->run($query); |
|
187 | + $logger->log($res_dir); |
|
188 | 188 | |
189 | - foreach ( $res_dir as $res_dir_key => $res_dir_value ) { |
|
189 | + foreach ($res_dir as $res_dir_key => $res_dir_value) { |
|
190 | 190 | $xml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n"; |
191 | 191 | $xml .= "<document type=\"freeswitch/xml\">\n"; |
192 | 192 | $xml .= " <section name=\"Directory\" description=\"Directory\">\n"; |
193 | - $xml .= " <domain name=\"" . $_REQUEST ['domain'] . "\" alias=\"true\">\n"; |
|
194 | - $xml .= " <user id=\"" . $_REQUEST ['user'] . "\">\n"; |
|
193 | + $xml .= " <domain name=\"".$_REQUEST ['domain']."\" alias=\"true\">\n"; |
|
194 | + $xml .= " <user id=\"".$_REQUEST ['user']."\">\n"; |
|
195 | 195 | |
196 | - $params = json_decode ( $res_dir_value ['dir_params'], true ); |
|
196 | + $params = json_decode($res_dir_value ['dir_params'], true); |
|
197 | 197 | |
198 | - $vars = json_decode ( $res_dir_value ['dir_vars'], true ); |
|
198 | + $vars = json_decode($res_dir_value ['dir_vars'], true); |
|
199 | 199 | $param_xml = $var_xml = ""; |
200 | - foreach ( $params as $parms_key => $res_dir_params ) { |
|
201 | - $param_xml .= "<param name=\"" . $parms_key . "\" value=\"" . $res_dir_params . "\"/>\n"; |
|
200 | + foreach ($params as $parms_key => $res_dir_params) { |
|
201 | + $param_xml .= "<param name=\"".$parms_key."\" value=\"".$res_dir_params."\"/>\n"; |
|
202 | 202 | } |
203 | 203 | |
204 | - foreach ( $vars as $var_key => $res_dir_vars ) { |
|
205 | - $var_xml .= "<variable name=\"" . $var_key . "\" value=\"" . $res_dir_vars . "\"/>\n"; |
|
204 | + foreach ($vars as $var_key => $res_dir_vars) { |
|
205 | + $var_xml .= "<variable name=\"".$var_key."\" value=\"".$res_dir_vars."\"/>\n"; |
|
206 | 206 | } |
207 | 207 | |
208 | 208 | $xml .= " <params>\n"; |
@@ -214,8 +214,8 @@ discard block |
||
214 | 214 | $xml .= " <variables>\n"; |
215 | 215 | $xml .= $var_xml; |
216 | 216 | $xml .= "<variable name=\"sipcall\" value=\"true\"/>\n"; |
217 | - $xml .= "<variable name=\"accountcode\" value=\"" . $res_dir_value ['accountcode'] . "\"/>\n"; |
|
218 | - $xml .= "<variable name=\"domain_name\" value=\"" . $_REQUEST ['domain'] . "\"/>\n"; |
|
217 | + $xml .= "<variable name=\"accountcode\" value=\"".$res_dir_value ['accountcode']."\"/>\n"; |
|
218 | + $xml .= "<variable name=\"domain_name\" value=\"".$_REQUEST ['domain']."\"/>\n"; |
|
219 | 219 | $xml .= " </variables>\n"; |
220 | 220 | |
221 | 221 | $xml .= " </user>\n"; |
@@ -224,7 +224,7 @@ discard block |
||
224 | 224 | $xml .= "</document>\n"; |
225 | 225 | } |
226 | 226 | |
227 | - $logger->log ( $xml ); |
|
227 | + $logger->log($xml); |
|
228 | 228 | return $xml; |
229 | 229 | } |
230 | 230 |
@@ -147,8 +147,9 @@ |
||
147 | 147 | |
148 | 148 | $sp_gw_settings = json_decode ( $sp_gw_value ['gateway_data'], true ); |
149 | 149 | foreach ( $sp_gw_settings as $sp_gw_settings_key => $sp_gw_settings_value ) { |
150 | - if ($sp_gw_settings_value != "") |
|
151 | - $xml .= " <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n"; |
|
150 | + if ($sp_gw_settings_value != "") { |
|
151 | + $xml .= " <param name=\"" . $sp_gw_settings_key . "\" value=\"" . $sp_gw_settings_value . "\"/>\n"; |
|
152 | + } |
|
152 | 153 | } |
153 | 154 | $xml .= " </gateway>\n"; |
154 | 155 | } |
@@ -28,20 +28,20 @@ |
||
28 | 28 | // $this->config['log_path'] = "/var/log/astpp/"; |
29 | 29 | if ($this->config ['debug'] == '0') { |
30 | 30 | // $this->fp = fopen($this->config['log_path'] . 'astpp_' . date('Y-m-d') . '.txt', 'a+'); |
31 | - $this->fp = fopen ( $this->config ['log_path'] . 'astpp.log', 'a+' ); |
|
31 | + $this->fp = fopen($this->config ['log_path'].'astpp.log', 'a+'); |
|
32 | 32 | } |
33 | 33 | } |
34 | 34 | function log($log) { |
35 | 35 | if ($this->config ['debug'] == '0') { |
36 | - if (is_array ( $log )) |
|
37 | - fwrite ( $this->fp, "[" . date ( 'Y-m-d H:i:s' ) . "] " . print_r ( $log, TRUE ) ); |
|
36 | + if (is_array($log)) |
|
37 | + fwrite($this->fp, "[".date('Y-m-d H:i:s')."] ".print_r($log, TRUE)); |
|
38 | 38 | else |
39 | - fwrite ( $this->fp, "[" . date ( 'Y-m-d H:i:s' ) . "] " . $log . "\n" ); |
|
39 | + fwrite($this->fp, "[".date('Y-m-d H:i:s')."] ".$log."\n"); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | function close() { |
43 | 43 | if ($this->config ['debug'] == '0') |
44 | - fclose ( $this->fp ); |
|
44 | + fclose($this->fp); |
|
45 | 45 | } |
46 | 46 | } |
47 | 47 |
@@ -33,15 +33,17 @@ |
||
33 | 33 | } |
34 | 34 | function log($log) { |
35 | 35 | if ($this->config ['debug'] == '0') { |
36 | - if (is_array ( $log )) |
|
37 | - fwrite ( $this->fp, "[" . date ( 'Y-m-d H:i:s' ) . "] " . print_r ( $log, TRUE ) ); |
|
38 | - else |
|
39 | - fwrite ( $this->fp, "[" . date ( 'Y-m-d H:i:s' ) . "] " . $log . "\n" ); |
|
36 | + if (is_array ( $log )) { |
|
37 | + fwrite ( $this->fp, "[" . date ( 'Y-m-d H:i:s' ) . "] " . print_r ( $log, TRUE ) ); |
|
38 | + } else { |
|
39 | + fwrite ( $this->fp, "[" . date ( 'Y-m-d H:i:s' ) . "] " . $log . "\n" ); |
|
40 | + } |
|
40 | 41 | } |
41 | 42 | } |
42 | 43 | function close() { |
43 | - if ($this->config ['debug'] == '0') |
|
44 | - fclose ( $this->fp ); |
|
44 | + if ($this->config ['debug'] == '0') { |
|
45 | + fclose ( $this->fp ); |
|
46 | + } |
|
45 | 47 | } |
46 | 48 | } |
47 | 49 |
@@ -22,7 +22,7 @@ discard block |
||
22 | 22 | // ############################################################################## |
23 | 23 | |
24 | 24 | // Define user rates array for parsing |
25 | -$CONST_USER_RATE = array ( |
|
25 | +$CONST_USER_RATE = array( |
|
26 | 26 | 'RID' => 'id', |
27 | 27 | 'RCD' => 'code', |
28 | 28 | 'RDS' => 'destination', |
@@ -36,7 +36,7 @@ discard block |
||
36 | 36 | ); |
37 | 37 | |
38 | 38 | // Define carrier rates array for parsing |
39 | -$CONST_CARRIER_RATE = array ( |
|
39 | +$CONST_CARRIER_RATE = array( |
|
40 | 40 | 'CID' => 'id', |
41 | 41 | 'CCD' => 'code', |
42 | 42 | 'CDS' => 'destination', |
@@ -47,5 +47,5 @@ discard block |
||
47 | 47 | 'CBB' => 'billing_block' |
48 | 48 | ); |
49 | 49 | |
50 | -define ( "tbl_configuration", "system" ); |
|
50 | +define("tbl_configuration", "system"); |
|
51 | 51 | ?> |
@@ -24,8 +24,8 @@ |
||
24 | 24 | var $config; |
25 | 25 | function get_configurations($db) { |
26 | 26 | $query = "SELECT * FROM system WHERE group_title IN ('global','opensips')"; |
27 | - $res_conf = $db->run ( $query ); |
|
28 | - foreach ( $res_conf as $res_conf_key => $res_conf_value ) |
|
27 | + $res_conf = $db->run($query); |
|
28 | + foreach ($res_conf as $res_conf_key => $res_conf_value) |
|
29 | 29 | $this->config [$res_conf_value ['name']] = $res_conf_value ['value']; |
30 | 30 | |
31 | 31 | return $this->config; |
@@ -25,8 +25,9 @@ |
||
25 | 25 | function get_configurations($db) { |
26 | 26 | $query = "SELECT * FROM system WHERE group_title IN ('global','opensips')"; |
27 | 27 | $res_conf = $db->run ( $query ); |
28 | - foreach ( $res_conf as $res_conf_key => $res_conf_value ) |
|
29 | - $this->config [$res_conf_value ['name']] = $res_conf_value ['value']; |
|
28 | + foreach ( $res_conf as $res_conf_key => $res_conf_value ) { |
|
29 | + $this->config [$res_conf_value ['name']] = $res_conf_value ['value']; |
|
30 | + } |
|
30 | 31 | |
31 | 32 | return $this->config; |
32 | 33 | } |
@@ -23,20 +23,20 @@ discard block |
||
23 | 23 | |
24 | 24 | // Parse user and rates array which we got in cdr xml |
25 | 25 | function parse_rates_array($xml_rate, $constant_array, $logger) { |
26 | - $rates_array = array (); |
|
26 | + $rates_array = array(); |
|
27 | 27 | |
28 | 28 | // decode string using urldecode |
29 | - $xml_rate = urldecode ( $xml_rate ); |
|
30 | - $xml_rate_array = explode ( "||", $xml_rate ); |
|
29 | + $xml_rate = urldecode($xml_rate); |
|
30 | + $xml_rate_array = explode("||", $xml_rate); |
|
31 | 31 | |
32 | - foreach ( $xml_rate_array as $rate_key => $rate_value ) { |
|
33 | - $rates_array = explode ( "|", $rate_value ); |
|
32 | + foreach ($xml_rate_array as $rate_key => $rate_value) { |
|
33 | + $rates_array = explode("|", $rate_value); |
|
34 | 34 | |
35 | - $user_id_param = $rates_array [count ( $rates_array ) - 1]; |
|
36 | - $user_id = (substr ( $user_id_param, 0, 3 ) == 'UID') ? substr ( $user_id_param, 3 ) : 0; |
|
35 | + $user_id_param = $rates_array [count($rates_array) - 1]; |
|
36 | + $user_id = (substr($user_id_param, 0, 3) == 'UID') ? substr ($user_id_param, 3) : 0; |
|
37 | 37 | |
38 | - foreach ( $rates_array as $key => $value ) { |
|
39 | - $rates_array_info [$user_id] [$constant_array [substr ( $value, 0, 3 )]] = substr ( $value, 3 ); |
|
38 | + foreach ($rates_array as $key => $value) { |
|
39 | + $rates_array_info [$user_id] [$constant_array [substr($value, 0, 3)]] = substr($value, 3); |
|
40 | 40 | } |
41 | 41 | } |
42 | 42 | return $rates_array_info; |
@@ -50,50 +50,50 @@ discard block |
||
50 | 50 | if ($duration > 0 && $xml_cdr->variables->call_direction == 'outbound') { |
51 | 51 | $destination_number = $xml_cdr->variables->effective_destination_number; |
52 | 52 | |
53 | - $number_len = strlen ( $destination_number ); |
|
53 | + $number_len = strlen($destination_number); |
|
54 | 54 | $number_loop_str = '('; |
55 | - while ( $number_len > 0 ) { |
|
56 | - $number_loop_str .= " code='" . substr ( $destination_number, 0, $number_len ) . "' OR "; |
|
55 | + while ($number_len > 0) { |
|
56 | + $number_loop_str .= " code='".substr($destination_number, 0, $number_len)."' OR "; |
|
57 | 57 | $number_len -= 1; |
58 | 58 | } |
59 | 59 | $number_loop_str .= " code='--')"; |
60 | 60 | |
61 | - $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE " . $number_loop_str . " AND B.package_id = A.id AND A.ratecard_id=" . $rates_array ['ratecard_id'] . " AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
62 | - $logger->log ( "Package Query : " . $query ); |
|
63 | - $res_package = $db->run ( $query ); |
|
61 | + $query = "SELECT A.id as package_id,code,includedseconds FROM tbl_package AS A ,tbl_package_codes AS B WHERE ".$number_loop_str." AND B.package_id = A.id AND A.ratecard_id=".$rates_array ['ratecard_id']." AND A.status=0 AND A.is_del=0 ORDER BY length(code) DESC"; |
|
62 | + $logger->log("Package Query : ".$query); |
|
63 | + $res_package = $db->run($query); |
|
64 | 64 | |
65 | - foreach ( $res_package as $res_package_key => $package_info ) { |
|
66 | - if (isset ( $package_info ['package_id'] )) { |
|
67 | - $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=" . $package_info ['code'] . " AND package_id=" . $package_info ['package_id'] . " AND user_id=" . $user_id; |
|
68 | - $logger->log ( "Package usage Query : " . $query ); |
|
69 | - $res_pkg_usg = $db->run ( $query ); |
|
65 | + foreach ($res_package as $res_package_key => $package_info) { |
|
66 | + if (isset ($package_info ['package_id'])) { |
|
67 | + $query = "SELECT SUM(used_seconds) as used_seconds FROM tbl_package_usage WHERE code=".$package_info ['code']." AND package_id=".$package_info ['package_id']." AND user_id=".$user_id; |
|
68 | + $logger->log("Package usage Query : ".$query); |
|
69 | + $res_pkg_usg = $db->run($query); |
|
70 | 70 | $package_usage_info = $res_pkg_usg [0]; |
71 | 71 | |
72 | - $used_seconds = (isset ( $package_usage_info ['used_seconds'] )) ? $package_usage_info ['used_seconds'] : 0; |
|
72 | + $used_seconds = (isset ($package_usage_info ['used_seconds'])) ? $package_usage_info ['used_seconds'] : 0; |
|
73 | 73 | |
74 | - $logger->log ( "Included seconds : " . $package_info ['includedseconds'] . ", Used seconds : " . $used_seconds ); |
|
74 | + $logger->log("Included seconds : ".$package_info ['includedseconds'].", Used seconds : ".$used_seconds); |
|
75 | 75 | if ($package_info ['includedseconds'] > $used_seconds) { |
76 | 76 | $remaining_seconds = $package_info ['includedseconds'] - ($duration + $used_seconds); |
77 | 77 | if ($remaining_seconds > 0) { |
78 | 78 | $dud_sec = $duration; |
79 | 79 | $duration = 0; |
80 | 80 | } else { |
81 | - $dud_sec = $duration - abs ( $remaining_seconds ); |
|
82 | - $duration = abs ( $remaining_seconds ); |
|
81 | + $dud_sec = $duration - abs($remaining_seconds); |
|
82 | + $duration = abs($remaining_seconds); |
|
83 | 83 | } |
84 | 84 | $flag = true; |
85 | 85 | $xml_cdr->variables->package_id = $package_info ['package_id']; |
86 | 86 | |
87 | - $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (" . $package_info ['package_id'] . "," . $user_id . ",'" . $package_info ['code'] . "'," . $dud_sec . ") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+" . $dud_sec; |
|
88 | - $logger->log ( "Package Usage Query : " . $query ); |
|
89 | - $db->run ( $query ); |
|
87 | + $query = "INSERT INTO tbl_package_usage (package_id,user_id,code,used_seconds) VALUES (".$package_info ['package_id'].",".$user_id.",'".$package_info ['code']."',".$dud_sec.") ON DUPLICATE KEY UPDATE used_seconds=used_seconds+".$dud_sec; |
|
88 | + $logger->log("Package Usage Query : ".$query); |
|
89 | + $db->run($query); |
|
90 | 90 | |
91 | 91 | break; |
92 | 92 | } |
93 | 93 | } |
94 | 94 | } |
95 | 95 | } |
96 | - return array ( |
|
96 | + return array( |
|
97 | 97 | $duration, |
98 | 98 | $flag |
99 | 99 | ); |
@@ -101,22 +101,22 @@ discard block |
||
101 | 101 | |
102 | 102 | // Process user/vendor cdr |
103 | 103 | function do_cdr_process($xml_cdr, $debit, $cost, $vendor_cost, $rates_array, $parent_id = 0, $parent_rates, $carrier_rates_array, $logger, $db) { |
104 | - $query_string = "'" . $xml_cdr->variables->uuid . "','" . $xml_cdr->variables->user_id . "','" . $xml_cdr->variables->entity_id . "','" . urldecode ( $xml_cdr->variables->effective_caller_id_name ) . "','" . $xml_cdr->variables->effective_caller_id_number . "','" . $xml_cdr->variables->effective_destination_number . "'," . $xml_cdr->variables->duration . ",'" . $xml_cdr->variables->carrier_id . "','" . $xml_cdr->callflow [0]->caller_profile->originatee->originatee_caller_profile->network_addr . "','" . $xml_cdr->variables->sip_contact_host . "','" . $xml_cdr->variables->hangup_cause . "','" . urldecode ( $xml_cdr->variables->start_stamp ) . "'," . $debit . "," . $cost . ",'" . $xml_cdr->variables->vendor_id . "'," . $vendor_cost . "," . $rates_array ['ratecard_id'] . "," . $xml_cdr->variables->package_id . ",'" . $rates_array ['code'] . "','" . $rates_array ['destination'] . "','" . $rates_array ['cost'] . "','" . $parent_id . "','" . @$parent_rates ['code'] . "','" . @$parent_rates ['destination'] . "','" . @$parent_rates ['cost'] . "','" . @$carrier_rates_array ['code'] . "','" . @$carrier_rates_array ['destination'] . "','" . @$carrier_rates_array ['cost'] . "','" . $xml_cdr->variables->call_direction . "','" . urldecode ( $xml_cdr->variables->profile_start_stamp ) . "','" . urldecode ( $xml_cdr->variables->answer_stamp ) . "','" . urldecode ( $xml_cdr->variables->bridge_stamp ) . "','" . urldecode ( $xml_cdr->variables->progress_stamp ) . "','" . urldecode ( $xml_cdr->variables->progress_media_stamp ) . "','" . urldecode ( $xml_cdr->variables->end_stamp ) . "'," . $xml_cdr->variables->billmsec . "," . $xml_cdr->variables->answermsec . "," . $xml_cdr->variables->waitmsec . "," . $xml_cdr->variables->progress_mediamsec . "," . $xml_cdr->variables->flow_billmsec; |
|
104 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".$xml_cdr->variables->entity_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->carrier_id."','".$xml_cdr->callflow [0]->caller_profile->originatee->originatee_caller_profile->network_addr."','".$xml_cdr->variables->sip_contact_host."','".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",'".$xml_cdr->variables->vendor_id."',".$vendor_cost.",".$rates_array ['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array ['code']."','".$rates_array ['destination']."','".$rates_array ['cost']."','".$parent_id."','".@$parent_rates ['code']."','".@$parent_rates ['destination']."','".@$parent_rates ['cost']."','".@$carrier_rates_array ['code']."','".@$carrier_rates_array ['destination']."','".@$carrier_rates_array ['cost']."','".$xml_cdr->variables->call_direction."','".urldecode($xml_cdr->variables->profile_start_stamp)."','".urldecode($xml_cdr->variables->answer_stamp)."','".urldecode($xml_cdr->variables->bridge_stamp)."','".urldecode($xml_cdr->variables->progress_stamp)."','".urldecode($xml_cdr->variables->progress_media_stamp)."','".urldecode($xml_cdr->variables->end_stamp)."',".$xml_cdr->variables->billmsec.",".$xml_cdr->variables->answermsec.",".$xml_cdr->variables->waitmsec.",".$xml_cdr->variables->progress_mediamsec.",".$xml_cdr->variables->flow_billmsec; |
|
105 | 105 | |
106 | 106 | $query = "INSERT INTO tbl_cdrs (uniqueid,user_id,entity_id,callerid_name,callerid_number,dstnum,duration,carrier_id,carrierip,callerip,disposition,start_stamp,debit,cost,vendor_id,vendor_cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,carrier_code,carrier_code_destination ,carrier_cost,call_direction,profile_start_stamp,answer_stamp,bridge_stamp,progress_stamp,progress_media_stamp,end_stamp,billmsec,answermsec,waitmsec,progress_mediamsec,flow_billmsec) values ($query_string)"; |
107 | 107 | |
108 | - $logger->log ( "CDR Query : " . $query ); |
|
109 | - $db->run ( $query ); |
|
108 | + $logger->log("CDR Query : ".$query); |
|
109 | + $db->run($query); |
|
110 | 110 | } |
111 | 111 | |
112 | 112 | // Process reseller cdr |
113 | 113 | function do_reseller_cdr_process($xml_cdr, $debit, $cost, $rates_array, $parent_id = 0, $parent_rates, $logger, $db) { |
114 | - $query_string = "'" . $xml_cdr->variables->uuid . "','" . $xml_cdr->variables->user_id . "','" . urldecode ( $xml_cdr->variables->effective_caller_id_name ) . "','" . $xml_cdr->variables->effective_caller_id_number . "','" . $xml_cdr->variables->effective_destination_number . "'," . $xml_cdr->variables->duration . ",'" . $xml_cdr->variables->hangup_cause . "','" . urldecode ( $xml_cdr->variables->start_stamp ) . "'," . $debit . "," . $cost . "," . $rates_array ['ratecard_id'] . "," . $xml_cdr->variables->package_id . ",'" . $rates_array ['code'] . "','" . $rates_array ['destination'] . "','" . $rates_array ['cost'] . "','" . $parent_id . "','" . @$parent_rates ['code'] . "','" . @$parent_rates ['destination'] . "','" . @$parent_rates ['cost'] . "','" . $xml_cdr->variables->call_direction . "'"; |
|
114 | + $query_string = "'".$xml_cdr->variables->uuid."','".$xml_cdr->variables->user_id."','".urldecode($xml_cdr->variables->effective_caller_id_name)."','".$xml_cdr->variables->effective_caller_id_number."','".$xml_cdr->variables->effective_destination_number."',".$xml_cdr->variables->duration.",'".$xml_cdr->variables->hangup_cause."','".urldecode($xml_cdr->variables->start_stamp)."',".$debit.",".$cost.",".$rates_array ['ratecard_id'].",".$xml_cdr->variables->package_id.",'".$rates_array ['code']."','".$rates_array ['destination']."','".$rates_array ['cost']."','".$parent_id."','".@$parent_rates ['code']."','".@$parent_rates ['destination']."','".@$parent_rates ['cost']."','".$xml_cdr->variables->call_direction."'"; |
|
115 | 115 | |
116 | 116 | $query = "INSERT INTO tbl_cdrs_reseller (uniqueid,reseller_id,callerid_name,callerid_number,dstnum,duration,disposition,start_stamp,debit,cost,ratecard_id,package_id,rate_code,rate_code_destination,rate_cost,parent_id,parent_code,parent_code_destination,parent_cost,call_direction) values ($query_string)"; |
117 | 117 | |
118 | - $logger->log ( "CDR Query : " . $query ); |
|
119 | - $db->run ( $query ); |
|
118 | + $logger->log("CDR Query : ".$query); |
|
119 | + $db->run($query); |
|
120 | 120 | } |
121 | 121 | |
122 | 122 | // Update user balance |
@@ -127,16 +127,16 @@ discard block |
||
127 | 127 | function update_balance($user_id, $amount, $entity_id, $logger, $db) { |
128 | 128 | if ($amount > 0) { |
129 | 129 | $math_sign = ($entity_id == 0 || $entity_id == 1) ? '-' : '+'; |
130 | - $query = "UPDATE tbl_users SET credit=credit$math_sign" . $amount . " WHERE id=" . $user_id; |
|
131 | - $logger->log ( "Balance update : " . $query ); |
|
132 | - $db->run ( $query ); |
|
130 | + $query = "UPDATE tbl_users SET credit=credit$math_sign".$amount." WHERE id=".$user_id; |
|
131 | + $logger->log("Balance update : ".$query); |
|
132 | + $db->run($query); |
|
133 | 133 | } |
134 | 134 | } |
135 | 135 | |
136 | 136 | // Get user info |
137 | 137 | function get_user_info($parent_id, $db) { |
138 | - $query = "SELECT * FROM tbl_users WHERE id=" . $parent_id; |
|
139 | - $res_user = $db->run ( $query ); |
|
138 | + $query = "SELECT * FROM tbl_users WHERE id=".$parent_id; |
|
139 | + $res_user = $db->run($query); |
|
140 | 140 | return $res_user [0]; |
141 | 141 | } |
142 | 142 |
@@ -62,7 +62,7 @@ |
||
62 | 62 | $db->run ( "SET NAMES utf8" ); |
63 | 63 | //$data = json_decode ( file_get_contents ( "php://input" ), true ); |
64 | 64 | $data = file_get_contents("php://input"); |
65 | - $data = utf8_encode($data); |
|
65 | + $data = utf8_encode($data); |
|
66 | 66 | $data = json_decode($data,true); |
67 | 67 | |
68 | 68 | // error_log(print_r($data,true)); |
@@ -20,21 +20,21 @@ discard block |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -define ( 'ENVIRONMENT', 'production' ); |
|
24 | -if (defined ( 'ENVIRONMENT' )) { |
|
23 | +define('ENVIRONMENT', 'production'); |
|
24 | +if (defined('ENVIRONMENT')) { |
|
25 | 25 | switch (ENVIRONMENT) { |
26 | 26 | case 'development' : |
27 | 27 | // error_reporting(E_ALL); |
28 | - error_reporting ( E_ERROR | E_WARNING | E_PARSE ); |
|
28 | + error_reporting(E_ERROR | E_WARNING | E_PARSE); |
|
29 | 29 | break; |
30 | 30 | |
31 | 31 | case 'testing' : |
32 | 32 | case 'production' : |
33 | - error_reporting ( 0 ); |
|
33 | + error_reporting(0); |
|
34 | 34 | break; |
35 | 35 | |
36 | 36 | default : |
37 | - exit ( 'The application environment is not set correctly.' ); |
|
37 | + exit ('The application environment is not set correctly.'); |
|
38 | 38 | } |
39 | 39 | } |
40 | 40 | |
@@ -45,35 +45,35 @@ discard block |
||
45 | 45 | include ("lib/astpp.cdr.php"); |
46 | 46 | |
47 | 47 | // Define db object |
48 | -$db = new db (); |
|
48 | +$db = new db(); |
|
49 | 49 | |
50 | 50 | // Get default configuration |
51 | -$lib = new lib (); |
|
52 | -$config = $lib->get_configurations ( $db ); |
|
51 | +$lib = new lib(); |
|
52 | +$config = $lib->get_configurations($db); |
|
53 | 53 | |
54 | 54 | // Set default decimal points |
55 | 55 | $decimal_points = ($config ['decimal_points'] <= 0) ? 4 : $config ['decimal_points']; |
56 | 56 | |
57 | 57 | // Define logger object |
58 | -$logger = new logger ( $lib ); |
|
58 | +$logger = new logger($lib); |
|
59 | 59 | |
60 | -if (isset ( $_SERVER ["CONTENT_TYPE"] ) && $_SERVER ["CONTENT_TYPE"] == "application/json") { |
|
60 | +if (isset ($_SERVER ["CONTENT_TYPE"]) && $_SERVER ["CONTENT_TYPE"] == "application/json") { |
|
61 | 61 | |
62 | - $db->run ( "SET NAMES utf8" ); |
|
62 | + $db->run("SET NAMES utf8"); |
|
63 | 63 | //$data = json_decode ( file_get_contents ( "php://input" ), true ); |
64 | 64 | $data = file_get_contents("php://input"); |
65 | 65 | $data = utf8_encode($data); |
66 | - $data = json_decode($data,true); |
|
66 | + $data = json_decode($data, true); |
|
67 | 67 | |
68 | 68 | // error_log(print_r($data,true)); |
69 | - $logger->log ( print_r ( $data, true ) ); |
|
69 | + $logger->log(print_r($data, true)); |
|
70 | 70 | // process_cdr($data,$db,$logger,$decimal_points); |
71 | 71 | if ($data ['variables'] ['calltype'] == "CALLINGCARD") { |
72 | - if (isset ( $data ['variables'] ['originating_leg_uuid'] )) { |
|
73 | - process_cdr ( $data, $db, $logger, $decimal_points ); |
|
72 | + if (isset ($data ['variables'] ['originating_leg_uuid'])) { |
|
73 | + process_cdr($data, $db, $logger, $decimal_points); |
|
74 | 74 | } |
75 | 75 | } else { |
76 | - process_cdr ( $data, $db, $logger, $decimal_points ); |
|
76 | + process_cdr($data, $db, $logger, $decimal_points); |
|
77 | 77 | } |
78 | 78 | } |
79 | 79 |
@@ -20,20 +20,20 @@ |
||
20 | 20 | // You should have received a copy of the GNU Affero General Public License |
21 | 21 | // along with this program. If not, see <http://www.gnu.org/licenses/>. |
22 | 22 | // ############################################################################## |
23 | -$logger->log ( "*************************** Configuration Starts ********************************" ); |
|
23 | +$logger->log("*************************** Configuration Starts ********************************"); |
|
24 | 24 | |
25 | 25 | $xml = ""; |
26 | 26 | if ($_REQUEST ['key_value'] == 'sofia.conf') { |
27 | - $xml = load_sofia ( $logger, $db ); |
|
28 | - header ( 'Content-Type: text/xml' ); |
|
27 | + $xml = load_sofia($logger, $db); |
|
28 | + header('Content-Type: text/xml'); |
|
29 | 29 | echo $xml; |
30 | 30 | } elseif ($_REQUEST ['key_value'] == 'acl.conf') { |
31 | - $xml = load_acl ( $logger, $db, $config ); |
|
32 | - header ( 'Content-Type: text/xml' ); |
|
31 | + $xml = load_acl($logger, $db, $config); |
|
32 | + header('Content-Type: text/xml'); |
|
33 | 33 | echo $xml; |
34 | 34 | } else { |
35 | - xml_not_found (); |
|
35 | + xml_not_found(); |
|
36 | 36 | } |
37 | -$logger->log ( "*************************** Configuration Ends **********************************" ); |
|
37 | +$logger->log("*************************** Configuration Ends **********************************"); |
|
38 | 38 | exit (); |
39 | 39 | ?> |