-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsavepcap.php
43 lines (32 loc) · 1.2 KB
/
savepcap.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
<?php
require_once('config.inc.php');
// Open MySQL connection
$db = new mysqli($db_host, $db_user, $db_pass, $db_name);
if ($db->connect_errno) {
echo "Failed to connect to MySQL: (" . $db->connect_errno . ") " . $db->connect_error;
}
$callid = $_GET['id'];
if (!$callid) {
die("No call ID specified!");
}
$sql = "SELECT cdr.id, cdr_next.fbasename, cdr.calldate, cdr.caller, cdr.called FROM `cdr` LEFT JOIN cdr_next ON cdr.id = cdr_next.cdr_ID WHERE cdr.id = $callid";
if(!$result = $db->query($sql)){
die('There was an error running the query [' . $db->error . ']');
}
$row = $result->fetch_assoc();
$calldatelong = $row['calldate'];
$calltime = strtotime($calldatelong);
$callday = date('Y-m-d', $calltime);
$calltimestamp = date('YmdHis', $calltime);
$caller = $row['caller'];
$called = $row['called'];
$wavfile = $wav_path . "{$callday}/" . $row['fbasename'] . '.pcap';
$outfilename = "/home/traceroutes/pcaps/{$calltimestamp}-{$caller}-to-{$called}.pcap";
//echo "$calldatelong $calltime $callday $calltimestamp $caller $called $wavfile $outfilename";
if (file_exists($wavfile)) {
copy($wavfile, $outfilename);
echo "Saved to $outfilename";
} else {
die("File {$wavfile} does not exist.");
}
?>