-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrebuild_vqr.php
56 lines (27 loc) · 947 Bytes
/
rebuild_vqr.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
<?php
require_once("CouchDB.php");
//require_once("parse_function.2.php");
require_once("parse_function.php");
global $CDB;
$CBOPTS['host'] = "127.0.0.1";
$CBOPTS['port'] = 5984;
$CDB = new CouchDB($CBOPTS); // See if we can make a connection
$testing = $CDB->send("GET","/vqmon/_design/generic/_view/by_callid");
foreach( $testing['rows'] as $row ) {
//print_r($row);
$pd = @parse_sip_vqr($row['value']);
if( isset($pd['From']) && !stristr($pd['From']['sip_address'], $pd['From']['username']) ) {
//print_r($pd['From']);
//print_r($pd['To']);
//This is really really lazy
if( !stristr($pd['From']['sip_address'],$pd['From']['username']) ) {
$tmp = $pd['From']['sip_address'];
$pd['From']['sip_address'] = $pd['To']['sip_address'];
$pd['To']['sip_address'] = $tmp;
}
$resp = $CDB->send("PUT","/vqr/{$row['id']}",json_encode($pd));
echo "/vqr/{$row['id']}\n";
print_r($resp);
}
}
?>