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' ?".">";
21 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
22 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
23 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
24 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
25 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
26 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC",
34 $obj = parse_xml_string($xmlhead.$it['object']);
35 $it['tname'] = $obj->content;
41 case ACTIVITY_DISLIKE:
45 $obj = parse_xml_string($xmlhead.$it['object']);
46 $it['fname'] = $obj->title;
50 if ($it['parent']!=$it['id']) {
58 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
59 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
60 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
61 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
62 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
63 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
70 $obj = parse_xml_string($xmlhead.$it['object']);
71 $it['tname'] = $obj->content;
77 case ACTIVITY_DISLIKE:
81 $obj = parse_xml_string($xmlhead.$it['object']);
82 $it['fname'] = $obj->title;
86 if ($it['parent']!=$it['id']) $comments[] = $it;
91 $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
92 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
93 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
94 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
97 $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
98 `contact`.`name`, `contact`.`url`, `contact`.`photo`
99 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
100 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
104 $intro = $intros1[0]['total'] + $intros2[0]['total'];
105 if ($intros1[0]['total']==0) $intros1=Array();
106 if ($intros2[0]['total']==0) $intros2=Array();
107 $intros = $intros1+$intros2;
111 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
112 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
113 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
114 intval(local_user()),
117 $mail = $mails[0]['total'];
119 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
120 $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");
121 $register = $regs[0]['total'];
127 function xmlize($href, $name, $url, $photo, $date, $message){
128 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
129 return sprintf ( $notsxml,
130 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message)
135 echo "<intro>$intro</intro>
139 if ($register!=0) echo "<register>$register</register>";
141 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
143 echo ' <notif count="'.$tot.'">';
145 foreach ($intros as $i) {
146 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") );
150 foreach ($mails as $i) {
151 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") );
155 foreach ($regs as $i) {
156 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
160 if (count($comments)){
161 foreach ($comments as $i) {
162 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'] ) );
166 foreach ($likes as $i) {
167 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'] ) );
170 if (count($dislikes)){
171 foreach ($dislikes as $i) {
172 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'] ) );
175 if (count($friends)){
176 foreach ($friends as $i) {
177 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'] ) );
181 foreach ($posts as $i) {
182 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") ) );
186 foreach ($tags as $i) {
187 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'] ) );
195 if(x($_SESSION,'sysmsg')){
196 foreach ($_SESSION['sysmsg'] as $m){
197 echo "<notice>".xmlify($m)."</notice>";
199 unset($_SESSION['sysmsg']);
201 if(x($_SESSION,'sysmsg_info')){
202 foreach ($_SESSION['sysmsg_info'] as $m){
203 echo "<info>".xmlify($m)."</info>";
205 unset($_SESSION['sysmsg_info']);