1
|
|
|
<?php |
2
|
|
|
############################################################################### |
3
|
|
|
# ASTPP - Open Source VoIP Billing Solution |
4
|
|
|
# |
5
|
|
|
# Copyright (C) 2016 iNextrix Technologies Pvt. Ltd. |
6
|
|
|
# Samir Doshi <[email protected]> |
7
|
|
|
# ASTPP Version 3.0 and above |
8
|
|
|
# License https://www.gnu.org/licenses/agpl-3.0.html |
9
|
|
|
# |
10
|
|
|
# This program is free software: you can redistribute it and/or modify |
11
|
|
|
# it under the terms of the GNU Affero General Public License as |
12
|
|
|
# published by the Free Software Foundation, either version 3 of the |
13
|
|
|
# License, or (at your option) any later version. |
14
|
|
|
# |
15
|
|
|
# This program is distributed in the hope that it will be useful, |
16
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
17
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
18
|
|
|
# GNU Affero General Public License for more details. |
19
|
|
|
# |
20
|
|
|
# You should have received a copy of the GNU Affero General Public License |
21
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>. |
22
|
|
|
############################################################################### |
23
|
|
|
|
24
|
|
|
define('ENVIRONMENT', 'production'); |
25
|
|
|
if (defined('ENVIRONMENT')) |
26
|
|
|
{ |
27
|
|
|
switch (ENVIRONMENT) |
28
|
|
|
{ |
29
|
|
|
case 'development': |
30
|
|
|
// error_reporting(E_ALL); |
|
|
|
|
31
|
|
|
error_reporting(E_ERROR|E_WARNING|E_PARSE); |
32
|
|
|
break; |
33
|
|
|
|
34
|
|
|
case 'testing': |
35
|
|
|
case 'production': |
36
|
|
|
error_reporting(0); |
37
|
|
|
break; |
38
|
|
|
|
39
|
|
|
default: |
40
|
|
|
exit('The application environment is not set correctly.'); |
41
|
|
|
} |
42
|
|
|
} |
43
|
|
|
|
44
|
|
|
include ("lib/astpp.db.php"); |
45
|
|
|
include ("lib/astpp.logger.php"); |
46
|
|
|
include ("lib/astpp.lib.php"); |
47
|
|
|
include ("lib/astpp.constants.php"); |
48
|
|
|
include ("lib/astpp.cdr.php"); |
49
|
|
|
|
50
|
|
|
//Define db object |
51
|
|
|
$db = new db(); |
52
|
|
|
|
53
|
|
|
//Get default configuration |
54
|
|
|
$lib = new lib(); |
55
|
|
|
$config = $lib->get_configurations($db); |
56
|
|
|
|
57
|
|
|
//Set default decimal points |
58
|
|
|
$decimal_points = ($config['decimal_points'] <= 0)?4:$config['decimal_points']; |
59
|
|
|
|
60
|
|
|
//Define logger object |
61
|
|
|
$logger = new logger($lib); |
62
|
|
|
|
63
|
|
|
if(isset($_SERVER["CONTENT_TYPE"]) && $_SERVER["CONTENT_TYPE"] == "application/json") { |
64
|
|
|
|
65
|
|
|
$db->run("SET NAMES utf8"); |
66
|
|
|
$data = json_decode(file_get_contents("php://input"),true); |
67
|
|
|
//error_log(print_r($data,true)); |
|
|
|
|
68
|
|
|
$logger->log(print_r($data,true)); |
69
|
|
|
if($data['variables']['calltype']== "CALLINGCARD"){ |
70
|
|
|
if(isset($data['variables']['originating_leg_uuid'])) |
71
|
|
|
{ |
72
|
|
|
process_cdr($data,$db,$logger,$decimal_points); |
73
|
|
|
} |
74
|
|
|
}else{ |
75
|
|
|
process_cdr($data,$db,$logger,$decimal_points); |
76
|
|
|
} |
77
|
|
|
} |
78
|
|
|
|
79
|
|
|
//$db->cleanup(); |
|
|
|
|
80
|
|
|
?> |
|
|
|
|
81
|
|
|
|
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.