2 require_once("include/datetime.php");
5 function ping_init(&$a) {
7 header("Content-type: text/xml");
8 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
11 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
22 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
23 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
24 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
25 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
26 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
27 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
28 ORDER BY `item`.`created` DESC",
36 $obj = parse_xml_string($xmlhead.$it['object']);
37 $it['tname'] = $obj->content;
43 case ACTIVITY_DISLIKE:
47 $obj = parse_xml_string($xmlhead.$it['object']);
48 $it['fname'] = $obj->title;
52 if ($it['parent']!=$it['id']) {
60 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
61 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
62 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
63 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
64 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
65 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
72 $obj = parse_xml_string($xmlhead.$it['object']);
73 $it['tname'] = $obj->content;
79 case ACTIVITY_DISLIKE:
83 $obj = parse_xml_string($xmlhead.$it['object']);
84 $it['fname'] = $obj->title;
88 if ($it['parent']!=$it['id']) $comments[] = $it;
93 $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
94 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
95 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
96 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
99 $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
100 `contact`.`name`, `contact`.`url`, `contact`.`photo`
101 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
102 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
106 $intro = $intros1[0]['total'] + $intros2[0]['total'];
107 if ($intros1[0]['total']==0) $intros1=Array();
108 if ($intros2[0]['total']==0) $intros2=Array();
109 $intros = $intros1+$intros2;
113 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
114 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
115 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
116 intval(local_user()),
119 $mail = $mails[0]['total'];
121 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
122 $regs = q("SELECT `contact`.`name`, `contact`.`url`, `contact`.`micro`, `register`.`created`, COUNT(*) as `total` FROM `contact` RIGHT JOIN `register` ON `register`.`uid`=`contact`.`uid` WHERE `contact`.`self`=1");
123 $register = $regs[0]['total'];
129 function xmlize($href, $name, $url, $photo, $date, $message){
130 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
131 return sprintf ( $notsxml,
132 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message)
137 echo "<intro>$intro</intro>
141 if ($register!=0) echo "<register>$register</register>";
143 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
145 echo ' <notif count="'.$tot.'">';
147 foreach ($intros as $i) {
148 echo xmlize( $a->get_baseurl().'/notifications/'.$i['id'], $i['name'], $i['url'], $i['photo'], relative_date($i['datetime']), t("{0} wants to be your friend") );
152 foreach ($mails as $i) {
153 echo xmlize( $a->get_baseurl().'/message/'.$i['id'], $i['from-name'], $i['from-url'], $i['from-photo'], relative_date($i['created']), t("{0} sent you a message") );
157 foreach ($regs as $i) {
158 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
162 if (count($comments)){
163 foreach ($comments as $i) {
164 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} commented %s's post"), $i['pname'] ) );
168 foreach ($likes as $i) {
169 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} liked %s's post"), $i['pname'] ) );
172 if (count($dislikes)){
173 foreach ($dislikes as $i) {
174 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} disliked %s's post"), $i['pname'] ) );
177 if (count($friends)){
178 foreach ($friends as $i) {
179 echo xmlize($a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'],$i['author-name'],$i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} is now friends with %s"), $i['fname'] ) );
183 foreach ($posts as $i) {
184 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} posted") ) );
188 foreach ($tags as $i) {
189 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), sprintf( t("{0} tagged %s's post with #%s"), $i['pname'], $i['tname'] ) );
197 if(x($_SESSION,'sysmsg')){
198 foreach ($_SESSION['sysmsg'] as $m){
199 echo "<notice>".xmlify($m)."</notice>";
201 unset($_SESSION['sysmsg']);
203 if(x($_SESSION,'sysmsg_info')){
204 foreach ($_SESSION['sysmsg_info'] as $m){
205 echo "<info>".xmlify($m)."</info>";
207 unset($_SESSION['sysmsg_info']);