-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.php
157 lines (119 loc) · 2.87 KB
/
functions.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
<?php
use PHPMailer\PHPMailer\PHPMailer;
use PHPMailer\PHPMailer\SMTP;
use PHPMailer\PHPMailer\Exception;
require './vendor/autoload.php';
use Medoo\Medoo;
$database = new Medoo([
// required
'database_type' => 'mysql',
'database_name' => 'cdr',
'server' => 'localhost',
'username' => 'root',
'password' => '',
// [optional]
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'port' => 3306,
]);
date_default_timezone_set('America/New_York');
$weekStartDay = 0;//0:Sunday, 1:Monday, others does not support
$testuser = new Medoo([
// required
'database_type' => 'mysql',
'database_name' => 'test',
'server' => 'localhost',
'username' => 'root',
'password' => '',
// [optional]
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_general_ci',
'port' => 3306,
]);
function getTimeFrom($type){
global $weekStartDay;
switch($type){
case 'Day':
return date('Y-m-d 00:00:00');
break;
case 'Week':
return date('Y-m-d 00:00:00', strtotime("-".(date('w')-$weekStartDay)." days"));
break;
case 'Month':
return date('Y-m-01 00:00:00');
break;
default:
break;
}
}
function getTimeTo($type, $totime){
global $weekStartDay;
switch($type){
case 'Day':
return date('Y-m-d ' . $totime);
break;
case 'Week':
return date('Y-m-d ' . $totime, strtotime("+".(6-date('w')+$weekStartDay)." days"));
break;
case 'Month':
return date('Y-m-t ' . $totime);
break;
default:
break;
}
}
function getDeviceIdentity(){
ob_start(); // Turn on output buffering
system('ipconfig /all'); //Execute external program to display output
$mycom=ob_get_contents(); // Capture the output into a variable
ob_clean(); // Clean (erase) the output buffer
$findme = "Physical";
$pmac = strpos($mycom, $findme); // Find the position of Physical text
$mac=str_replace([':', '-', ' '], '', substr($mycom,($pmac+36),17)); // Get Physical Address
if($mac){
return md5($mac);
}else{
return null;
}
}
function checkLicense(){
if(!file_exists('license.key')){
return false;
}
$hash = trim(file_get_contents('license.key'));
if($hash === getDeviceIdentity()){
return true;
}
return false;
}
function getWhere($from, $to, $callfrom, $callto, $callduration, $talkduration, $status, $drunk, $communicationtype, $pincode){
$selector = [
"datetime[<>]" => [$from, $to],
'ORDER' => ['datetime'=>'DESC'],
];
if($callfrom){
$selector["clid[~]"] = $callfrom;
}
if($callto){
$selector["dst[~]"] = $callto;
}
if($callduration){
$selector["billable[~]"] = $callduration;
}
if($talkduration){
$selector["duration[>=]"] = $talkduration;
}
if($status){
$selector["disposition[~]"] = $status;
}
if($drunk){
$selector["OR"] = ['srctrunk' => $drunk, 'dstrunk' => $drunk];
}
if($communicationtype){
$selector["calltype"] = $communicationtype;
}
if($pincode){
$selector["accountcode"] = $pincode;
}
return $selector;
}