-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsoap_replay_lib.php
More file actions
152 lines (111 loc) · 4.96 KB
/
soap_replay_lib.php
File metadata and controls
152 lines (111 loc) · 4.96 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
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
<?php
//Setting up the client, specifying the server.
$dsl_soap_client = new SoapClient(null,
array('location' => "http://cyrus.cs.ucdavis.edu/~dslfaith/faith/soap_replay.php",
'uri' => "urn://cyrus.cs.ucdavis.edu/dslfaith",
'trace' => 1,
'exception'=> 1));
function dsl_isPositiveInt($num){
return is_int($num) && ($num>0);
}
//UID to Name
function dsl_uidToName($uid, $logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($uid))
return "";
return $dsl_soap_client->__soapCall("uidToName",array($uid, $logID, $faith_uid, $faith_app_id));
}
//Name to UID
function dsl_nameToUid($name, $logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
return $dsl_soap_client->__soapCall("nameToUid",array($name, $logID, $faith_uid, $faith_app_id));
}
//Note that findSocialPath returns an array of (nodes,trust) pairs connecting the source user to the destination.
function dsl_findSocialPath($src,$dest,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($src))
return -1;
if(!dsl_isPositiveInt($dest))
return -2;
return $dsl_soap_client->__soapCall("findSocialPath",array($src,$dest, $logID, $faith_uid, $faith_app_id));
}
//Like findSocialPath but returns an array of paths.
function dsl_findMultipleSocialPaths($src,$dest,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($src))
return -1;
if(!dsl_isPositiveInt($dest))
return -2;
return $dsl_soap_client->__soapCall("findMultipleSocialPaths",array($src,$dest, $logID, $faith_uid, $faith_app_id));
}
//Note that findTargets (a) requires an array of keywords for input, even if it is only one keyword, and (b) returns an array of (nodes,distance) pairs.
function dsl_findTargets($src,$keywords,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($src))
return -1;
if(!is_array($keywords))
return -2;
return $dsl_soap_client->__soapCall("findTargets",array("3200156",$keywords, $logID, $faith_uid, $faith_app_id));
}
//Note that setOutcome (a) requires an array of nodes along the path for input and (b) returns "1" always.
function dsl_setOutcome($path, $outcome, $logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!is_array($path))
return -1;
if($outcome!=0 && $outcome!=1)
return -2;
return $dsl_soap_client->__soapCall("setOutcome",array($path,$outcome, $logID, $faith_uid, $faith_app_id));
}
//Note that getReceivedKeywords returns a complicated array of
//(keywords, neighbors) pairs where neighbors is an array of neighbors to the
//UID that passed the keyword on to the user.
function dsl_getReceivedKeywords($uid,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($uid))
return array();
return $dsl_soap_client->__soapCall("getReceivedKeywords",array($uid, $logID, $faith_uid, $faith_app_id));
}
//Note that getFriends returns an array. Returns all friends who are also using DSL.
function dsl_getFriends($uid,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($uid))
return array();
return $dsl_soap_client->__soapCall("getFriends",array($uid, $logID, $faith_uid, $faith_app_id));
}
//How much does $truster trust $trustee?
function dsl_getTrust($truster, $trustee, $logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($truster))
return -1;
if(!dsl_isPositiveInt($trustee))
return -2;
return $dsl_soap_client->__soapCall("getTrust",array($truster,$trustee, $logID, $faith_uid, $faith_app_id));
}
//Note that this function will update the trust along the path depending on if the message was successfully sent or not. Be careful when calling this method as it modifies data. Be sure you don't accidentally spam this function.
function dsl_sendMessage($path,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!is_array($path))
return -1;
return $dsl_soap_client->__soapCall("sendMessage",array($path, $logID, $faith_uid, $faith_app_id));
}
//Adds a user to DSL.
function dsl_addUser($uid,$name,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($uid))
return -1;
return $dsl_soap_client->__soapCall("addUser",array($uid,$name, $logID, $faith_uid, $faith_app_id));
}
//Removes a user from DSL.
function dsl_removeUser($uid,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($uid))
return -1;
return $dsl_soap_client->__soapCall("removeUser",array($uid, $logID, $faith_uid, $faith_app_id));
}
//Get the URL for the user's thumbnail picture.
function dsl_getPic($uid,$logID, $faith_uid, $faith_app_id){
global $dsl_soap_client;
if(!dsl_isPositiveInt($uid))
return -1;
return $dsl_soap_client->__soapCall("getPic",array($uid, $logID, $faith_uid, $faith_app_id));
}