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 $firehose = intval(get_pconfig(local_user(),'system','notify_full'));
17 $z = q("select * from notify where seen = 0 and uid = %d
31 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
32 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
33 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
34 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
35 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
36 `item`.`deleted` = 0 AND `item`.`uid` = %d
37 ORDER BY `item`.`created` DESC",
52 $obj = parse_xml_string($xmlhead.$it['object']);
53 $it['tname'] = $obj->content;
59 case ACTIVITY_DISLIKE:
63 $obj = parse_xml_string($xmlhead.$it['object']);
64 $it['fname'] = $obj->title;
68 if ($it['parent']!=$it['id']) {
78 $intros1 = q("SELECT `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 `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 = count($intros1) + count($intros2);
92 $intros = $intros1+$intros2;
96 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
97 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
98 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
103 $mail = $mails[0]['total'];
105 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
106 $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 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message)
121 echo "<intro>$intro</intro>
125 if ($register!=0) echo "<register>$register</register>";
127 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags);
129 require_once('include/bbcode.php');
132 echo ' <notif count="'.$tot.'">';
135 echo ' <notif count="'. count($z) .'">';
138 echo xmlize($a->get_baseurl() . '/notify/view' . $zz['id'], $zz['name'],$zz['url'],$zz['photo'],relative_date($zz['date']), strip_tags(bbcode($zz['msg'])));
145 foreach ($intros as $i) {
146 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") );
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'] ) );
192 foreach ($cit as $i) {
193 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") );
202 if(x($_SESSION,'sysmsg')){
203 foreach ($_SESSION['sysmsg'] as $m){
204 echo "<notice>".xmlify($m)."</notice>";
206 unset($_SESSION['sysmsg']);
208 if(x($_SESSION,'sysmsg_info')){
209 foreach ($_SESSION['sysmsg_info'] as $m){
210 echo "<info>".xmlify($m)."</info>";
212 unset($_SESSION['sysmsg_info']);