-
Notifications
You must be signed in to change notification settings - Fork 57
/
getuserfeed.php
48 lines (44 loc) · 1.35 KB
/
getuserfeed.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
<?php
include("authen.php");
include("config.php");
include("friendingfunctions.php");
header('content-type: text/xml');
$userid = intval($_GET['id']);
$myuserid = $_SESSION['userid'];
$xml = new SimpleXMLElement('<xml/>');
$f = friendStatus($userid,$myuserid);
if ($f == 2 || $f == -1)
{
$friend = $xml->addChild('friendstatus','1');
$statusquery="SELECT * from (SELECT * FROM messages where (userid = '$userid' AND recipientid IS NULL) OR recipientid = '$userid') as feed NATURAL JOIN userinfo as feedwithinfo ORDER BY timestamp DESC;";
$statusesresult=mysql_query($statusquery) or die("Unable to query DB!");
if (mysql_num_rows($statusesresult))
{
$hasp = $xml->addChild('haspostings','1');
$postings = $xml->addChild('postings');
while ($row = mysql_fetch_assoc($statusesresult))
{
$thispost = $postings->addChild('post');
$userid = $row['userid'];
$thispost->addChild('userid', "$userid");
$fname = $row['fname'];
$thispost->addChild('fname', "$fname");
$lname = $row['lname'];
$thispost->addChild('lname', "$lname");
$time = $row['timestamp'];
$thispost->addChild('timestamp', "$time");
$content = $row['content'];
$thispost->addChild('content', "$content");
}
}
else
{
$hasp = $xml->addChild('haspostings','0');
}
}
else
{
$friend = $xml->addChild('friendstatus','0');
}
print($xml->asXML());
?>