forked from HSJared/Social-Network
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getfriends.php
49 lines (42 loc) · 1.46 KB
/
getfriends.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
<?php
include("authen.php");
include("config.php");
include("friendingfunctions.php");
header('content-type: text/xml');
$userid = intval($_GET['id']);
$myuserid = $_SESSION['userid'];
//If not own profile, let's look into friend status
$friendsquery="SELECT * FROM relations RIGHT JOIN userinfo ON
(userinfo.`userid` = relations.`userid1`
OR
userinfo.`userid` = relations.`userid2`)
AND
userinfo.`userid` != '$userid'
AND
relations.`relation` = '2'
WHERE
relations.`userid1` = '$userid'
OR
relations.`userid2` = '$userid';";
$friendsresult=mysql_query($friendsquery) or die("Unable to query DB!");
$xml = new SimpleXMLElement('<xml/>');
while ($row = mysql_fetch_assoc($friendsresult))
{
$friendsstatusquery ="SELECT userid1,userid2 FROM relations where (`userid1` = '$myuserid' AND relation = '2') OR (`userid2` = '$myuserid' AND relation = '2');";
$friendsstatus=mysql_query($friendsquery) or die("Unable to query DB!");
$friend = $xml->addChild('friend');
$userid = $row['userid'];
$friend->addChild('userid', "$userid");
$fname = $row['fname'];
$friend->addChild('fname', "$fname");
$lname = $row['lname'];
$friend->addChild('lname', "$lname");
$gender = $row['gender'];
$friend->addChild('gender', "$gender");
$bdate = $row['bdate'];
$friend->addChild('bdate', "$bdate");
$friendstatus = friendStatus($userid,$myuserid);
$friend->addChild('friendsstatus', "$friendstatus");
}
print($xml->asXML());
?>