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\" ?>
19 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
20 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
21 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
22 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
23 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
24 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0",
34 case ACTIVITY_DISLIKE:
38 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
39 $obj = parse_xml_string($xmlhead.$it['object']);
40 $it['fname'] = $obj->title;
44 if ($it['parent']!=$it['id']) $comments[] = $it;
49 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
50 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
51 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
52 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
53 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
54 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
63 case ACTIVITY_DISLIKE:
67 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
68 $obj = parse_xml_string($xmlhead.$it['object']);
69 $it['fname'] = $obj->title;
73 if ($it['parent']!=$it['id']) $comments[] = $it;
78 $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
79 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
80 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
81 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
84 $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
85 `contact`.`name`, `contact`.`url`, `contact`.`photo`
86 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
87 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
91 $intro = $intros1[0]['total'] + $intros2[0]['total'];
92 if ($intros1[0]['total']==0) $intros1=Array();
93 if ($intros2[0]['total']==0) $intros2=Array();
94 $intros = $intros1+$intros2;
98 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
99 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
100 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
101 intval(local_user()),
104 $mail = $mails[0]['total'];
106 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
107 $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");
108 $register = $regs[0]['total'];
114 function xmlize($href, $name, $url, $photo, $date, $message){
115 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
116 return sprintf ( $notsxml,
117 $href, $name, $url, $photo, $date, $message
122 echo "<intro>$intro</intro>
126 if ($register!=0) echo "<register>$register</register>";
128 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends);
130 echo ' <notif count="'.$tot.'">';
132 foreach ($intros as $i) {
133 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") );
137 foreach ($mails as $i) {
138 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") );
142 foreach ($regs as $i) {
143 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
147 if (count($comments)){
148 foreach ($comments as $i) {
149 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'] ) );
153 foreach ($likes as $i) {
154 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} like %s's post"), $i['pname'] ) );
157 if (count($dislikes)){
158 foreach ($dislikes as $i) {
159 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} dislike %s's post"), $i['pname'] ) );
162 if (count($friends)){
163 foreach ($friends 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} is now friend with %s"), $i['fname'] ) );
173 if(x($_SESSION,'sysmsg')){
174 foreach ($_SESSION['sysmsg'] as $m){
175 echo "<notice>".($m)."</notice>";
177 //$_SESSION['sysmsg']=array();
178 unset($_SESSION['sysmsg']);
180 if(x($_SESSION,'sysmsg_info')){
181 foreach ($_SESSION['sysmsg_info'] as $m){
182 echo "<info>".($m)."</info>";
184 //$_SESSION['sysmsg_info']=array();
185 unset($_SESSION['sysmsg_info']);