2 require_once("include/datetime.php");
5 function ping_init(&$a) {
7 header("Content-type: text/xml");
9 echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>
12 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
15 $z = q("select * from notify where seen = 0 and uid = %d
30 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
31 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
32 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
33 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
34 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
35 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
36 ORDER BY `item`.`created` DESC",
44 $obj = parse_xml_string($xmlhead.$it['object']);
45 $it['tname'] = $obj->content;
51 case ACTIVITY_DISLIKE:
55 $obj = parse_xml_string($xmlhead.$it['object']);
56 $it['fname'] = $obj->title;
60 if ($it['parent']!=$it['id']) {
68 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
69 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
70 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
71 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
72 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
73 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
80 $obj = parse_xml_string($xmlhead.$it['object']);
81 $it['tname'] = $obj->content;
87 case ACTIVITY_DISLIKE:
91 $obj = parse_xml_string($xmlhead.$it['object']);
92 $it['fname'] = $obj->title;
96 if ($it['parent']!=$it['id']) $comments[] = $it;
101 $intros1 = q("SELECT `intro`.`id`, `intro`.`datetime`,
102 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
103 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
104 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
107 $intros2 = q("SELECT `intro`.`id`, `intro`.`datetime`,
108 `contact`.`name`, `contact`.`url`, `contact`.`photo`
109 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
110 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
114 $intro = count($intros1) + count($intros2);
115 $intros = $intros1+$intros2;
119 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
120 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
121 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
122 intval(local_user()),
125 $mail = $mails[0]['total'];
127 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
128 $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");
129 $register = $regs[0]['total'];
135 function xmlize($href, $name, $url, $photo, $date, $message){
136 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
137 return sprintf ( $notsxml,
138 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message)
143 echo "<intro>$intro</intro>
147 if ($register!=0) echo "<register>$register</register>";
149 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
151 echo ' <notif count="'.$tot.'">';
153 require_once('include/bbcode.php');
157 echo xmlize($a->get_baseurl() . '/notify/' . $zz['id'], $zz['name'],$zz['url'],$zz['photo'],relative_date($zz['date']), bbcode($zz['msg']));
169 foreach ($intros as $i) {
170 echo xmlize( $a->get_baseurl().'/notifications/intros/'.$i['id'], $i['name'], $i['url'], $i['photo'], relative_date($i['datetime']), t("{0} wants to be your friend") );
174 foreach ($mails as $i) {
175 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") );
179 foreach ($regs as $i) {
180 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
184 if (count($comments)){
185 foreach ($comments as $i) {
186 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'] ) );
190 foreach ($likes as $i) {
191 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'] ) );
194 if (count($dislikes)){
195 foreach ($dislikes as $i) {
196 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'] ) );
199 if (count($friends)){
200 foreach ($friends as $i) {
201 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'] ) );
205 foreach ($posts as $i) {
206 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") ) );
210 foreach ($tags as $i) {
211 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'] ) );
216 foreach ($cit as $i) {
217 echo xmlize( $a->get_baseurl().'/display/'.$a->user['nickname']."/".$i['parent'], $i['author-name'], $i['author-link'], $i['author-avatar'], relative_date($i['created']), t("{0} mentioned you in a post") );
227 if(x($_SESSION,'sysmsg')){
228 foreach ($_SESSION['sysmsg'] as $m){
229 echo "<notice>".xmlify($m)."</notice>";
231 unset($_SESSION['sysmsg']);
233 if(x($_SESSION,'sysmsg_info')){
234 foreach ($_SESSION['sysmsg_info'] as $m){
235 echo "<info>".xmlify($m)."</info>";
237 unset($_SESSION['sysmsg_info']);