-
Notifications
You must be signed in to change notification settings - Fork 3
/
add_node.php
94 lines (82 loc) · 3.88 KB
/
add_node.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
<?php
$node=$_GET['nodeID'];
$sessionID = $_GET['sessionID'];
$timestep = $_GET['timestep'];
$timestep2 = $timestep+1;
# echo $node;
include 'settings.php';
$link = mysqli_connect($dbHost,$dbUser,$dbPass, $dbName);
if (!$link) {
die('Could not connect: ' . mysql_error());
}
if($_GET['type'] == 'agent'){
//Do something
# echo "id is ".substr($_GET['nodeID'],4);
$sql="call copy_trust('".$sessionID."',".$timestep.",".$timestep2.",-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$sql="call copy_beliefs('".$sessionID."',".$timestep.",".$timestep2.",-1,-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$sql="call copy_question('".$sessionID."',".$timestep.",".$timestep2.",-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
mysqli_close($link);
$script = "python addItems.py -s ".$sessionID . " -t ".$timestep2 . " -a ".$_GET['fromAgent'] . " -b ".$_GET['toAgent']. " -l ".$_GET['trust'];
exec($script);
# echo $script;
if(!array_key_exists('headless', $_GET)){
header( 'Location: index.php?sessionID='.$sessionID.'×tep='.$timestep2 );
}
}else if($_GET['type'] == 'fact'){
$sql="call copy_trust('".$sessionID."',".$timestep.",".$timestep2.",-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$sql="call copy_beliefs('".$sessionID."',".$timestep.",".$timestep2.",-1,-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$sql="call copy_question('".$sessionID."',".$timestep.",".$timestep2.",-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
mysqli_close($link);
$script = "python addItems.py -s ".$sessionID . " -t ".$timestep2 . " -a ".$_GET['agent'] . " -e \"".$_GET['belief']. "\" -l ".$_GET['trust'];
$result = exec($script);
// echo $script;
if(!array_key_exists('headless', $_GET)){
header( 'Location: index.php?sessionID='.$sessionID.'×tep='.$timestep2 );
}
}else if($_GET['type'] == 'rule'){
$sql="call copy_trust('".$sessionID."',".$timestep.",".$timestep2.",-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$sql="call copy_beliefs('".$sessionID."',".$timestep.",".$timestep2.",-1,-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$sql="call copy_question('".$sessionID."',".$timestep.",".$timestep2.",-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
mysqli_close($link);
$script = "python addItems.py -s ".$sessionID . " -t ".$timestep2 . " -a ".$_GET['agent'] . " -c \"".$_GET['conclusion']. "\" -l ".$_GET['trust']. " -p \"".$_GET['premise']. "\"";
$result = exec($script);
# echo $script;
if(!array_key_exists('headless', $_GET)){
header( 'Location: index.php?sessionID='.$sessionID.'×tep='.$timestep2 );
}
}else if($_GET['type'] == 'question'){
$sql="call copy_trust('".$sessionID."',".$timestep.",".$timestep2.",-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$sql="call copy_beliefs('".$sessionID."',".$timestep.",".$timestep2.",-1,-1);";
$result=mysqli_query($link,$sql);
# mysqli_free_result($result);
$script = "python addItems.py -s ".$sessionID . " -t ".$timestep2 . " -a ".$_GET['agent'] . " -q \"".$_GET['question']."\"";
$result = exec($script);
if(!array_key_exists('headless', $_GET)){
header( 'Location: index.php?sessionID='.$sessionID.'×tep='.$timestep2 );
}
}else{
mysqli_close($link);
echo "in else";
# header( 'Location: index.php?sessionID='.$sessionID.'×tep='.$timestep );
}
?>