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\" ?>
20 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
21 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
22 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
23 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
24 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
25 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0 ORDER BY `item`.`created` DESC",
35 case ACTIVITY_DISLIKE:
39 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
40 $obj = parse_xml_string($xmlhead.$it['object']);
41 $it['fname'] = $obj->title;
45 if ($it['parent']!=$it['id']) {
53 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
54 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
55 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
56 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
57 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
58 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
67 case ACTIVITY_DISLIKE:
71 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
72 $obj = parse_xml_string($xmlhead.$it['object']);
73 $it['fname'] = $obj->title;
77 if ($it['parent']!=$it['id']) $comments[] = $it;
82 $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
83 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
84 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
85 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
88 $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
89 `contact`.`name`, `contact`.`url`, `contact`.`photo`
90 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
91 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
95 $intro = $intros1[0]['total'] + $intros2[0]['total'];
96 if ($intros1[0]['total']==0) $intros1=Array();
97 if ($intros2[0]['total']==0) $intros2=Array();
98 $intros = $intros1+$intros2;
102 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
103 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
104 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
105 intval(local_user()),
108 $mail = $mails[0]['total'];
110 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
111 $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");
112 $register = $regs[0]['total'];
118 function xmlize($href, $name, $url, $photo, $date, $message){
119 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
120 return sprintf ( $notsxml,
121 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message)
126 echo "<intro>$intro</intro>
130 if ($register!=0) echo "<register>$register</register>";
132 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts);
134 echo ' <notif count="'.$tot.'">';
136 foreach ($intros as $i) {
137 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") );
141 foreach ($mails as $i) {
142 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") );
146 foreach ($regs as $i) {
147 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
151 if (count($comments)){
152 foreach ($comments as $i) {
153 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'] ) );
157 foreach ($likes as $i) {
158 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'] ) );
161 if (count($dislikes)){
162 foreach ($dislikes as $i) {
163 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'] ) );
166 if (count($friends)){
167 foreach ($friends as $i) {
168 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'] ) );
172 foreach ($posts as $i) {
173 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") ) );
181 if(x($_SESSION,'sysmsg')){
182 foreach ($_SESSION['sysmsg'] as $m){
183 echo "<notice>".xmlify($m)."</notice>";
185 unset($_SESSION['sysmsg']);
187 if(x($_SESSION,'sysmsg_info')){
188 foreach ($_SESSION['sysmsg_info'] as $m){
189 echo "<info>".xmlify($m)."</info>";
191 unset($_SESSION['sysmsg_info']);