-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddMile.php
More file actions
75 lines (54 loc) · 1.77 KB
/
addMile.php
File metadata and controls
75 lines (54 loc) · 1.77 KB
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
<?php
require_once('cps_simple.php');
// Connection hubs
// Note, replace 'api-eu' with appropriate Cloud server you use - 'api-us' or 'api-uk'
$connectionStrings = array(
'tcp://cloud-us-0.clusterpoint.com:9007',
'tcp://cloud-us-1.clusterpoint.com:9007',
'tcp://cloud-us-2.clusterpoint.com:9007',
'tcp://cloud-us-3.clusterpoint.com:9007'
);
// Creating a CPS_Connection instance
$cpsConn = new CPS_Connection(
new CPS_LoadBalancer($connectionStrings), 'DATABASENAME', 'USERNAME', 'PASSWORD', 'document',
'//document/id', array('account' => ID)
);
$cpsConn2 = new CPS_Connection(
new CPS_LoadBalancer($connectionStrings), 'DATABASENAME', 'USERNAME', 'PASSWORD', 'document',
'//document/id', array('account' => ID)
);
$cpsSimple = new CPS_Simple($cpsConn);
$cpsSimple2 = new CPS_Simple($cpsConn2);
$goal = $cpsSimple->retrieveSingle($_POST['id']);
$id = $_POST['id'];
$goalCounter = $cpsSimple->retrieveSingle('size');
$newGoal = array(
'title' => $_POST["name"],
'achieved' => "false",
'date' => $_POST["date"]
);
//var_dump($goalPage);
$goalCounter->title+=1;
$cpsSimple->updateSingle('size', $goalCounter);
$oldData = ($goal->milestones);
var_dump($goalCounter);
$cpsSimple->insertSingle((string)$goalCounter->title, $newGoal);
echo("ohp");
var_dump($oldData);
$xml = simplexml_load_string($oldData->asXML(), 'SimpleXMLElement', LIBXML_NOCDATA);
$array = json_decode(json_encode($xml), TRUE);
var_dump($array);
if(!empty($array)) {
eval('$array = ' . $array . ';');
} else {
$array = array();
}
array_push($array, (string)$goalCounter->title);
var_dump($array);
ob_start();
var_export ($array);
$result = ob_get_clean();
$goal->milestones = $result;
$cpsSimple2->updateSingle($id, $goal);
header("Location: goals.php?id=" . $_POST["id"] . "&user=" . $_POST["user"]);
?>