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\" ?>
12 $xmlhead="<"."?xml version='1.0' encoding='UTF-8' ?".">";
24 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
25 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`, `item`.`body`,
26 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
27 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
28 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
29 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 0
30 ORDER BY `item`.`created` DESC",
40 $obj = parse_xml_string($xmlhead.$it['object']);
41 $it['tname'] = $obj->content;
47 case ACTIVITY_DISLIKE:
51 $obj = parse_xml_string($xmlhead.$it['object']);
52 $it['fname'] = $obj->title;
56 $reg = "|@\[url=".$a->get_baseurl()."/profile/".$a->user['nickname']."|";
57 if ($it['parent']!=$it['id']) {
59 } else if(preg_match( $reg, $it['body'])){
67 $r = q("SELECT `item`.`id`,`item`.`parent`, `item`.`verb`, `item`.`author-name`,
68 `item`.`author-link`, `item`.`author-avatar`, `item`.`created`, `item`.`object`,
69 `pitem`.`author-name` as `pname`, `pitem`.`author-link` as `plink`
70 FROM `item` INNER JOIN `item` as `pitem` ON `pitem`.`id`=`item`.`parent`
71 WHERE `item`.`unseen` = 1 AND `item`.`visible` = 1 AND
72 `item`.`deleted` = 0 AND `item`.`uid` = %d AND `item`.`wall` = 1",
79 $obj = parse_xml_string($xmlhead.$it['object']);
80 $it['tname'] = $obj->content;
86 case ACTIVITY_DISLIKE:
90 $obj = parse_xml_string($xmlhead.$it['object']);
91 $it['fname'] = $obj->title;
95 if ($it['parent']!=$it['id']) $comments[] = $it;
96 if(preg_match("/@\[[^]]*\]".$a->user['username']."/", $it['body'])){
103 $intros1 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
104 `fcontact`.`name`, `fcontact`.`url`, `fcontact`.`photo`
105 FROM `intro` LEFT JOIN `fcontact` ON `intro`.`fid` = `fcontact`.`id`
106 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`fid`!=0",
109 $intros2 = q("SELECT COUNT(`intro`.`id`) AS `total`, `intro`.`id`, `intro`.`datetime`,
110 `contact`.`name`, `contact`.`url`, `contact`.`photo`
111 FROM `intro` LEFT JOIN `contact` ON `intro`.`contact-id` = `contact`.`id`
112 WHERE `intro`.`uid` = %d AND `intro`.`blocked` = 0 AND `intro`.`ignore` = 0 AND `intro`.`contact-id`!=0",
116 $intro = $intros1[0]['total'] + $intros2[0]['total'];
117 if ($intros1[0]['total']==0) $intros1=Array();
118 if ($intros2[0]['total']==0) $intros2=Array();
119 $intros = $intros1+$intros2;
123 $myurl = $a->get_baseurl() . '/profile/' . $a->user['nickname'] ;
124 $mails = q("SELECT *, COUNT(*) AS `total` FROM `mail`
125 WHERE `uid` = %d AND `seen` = 0 AND `from-url` != '%s' ",
126 intval(local_user()),
129 $mail = $mails[0]['total'];
131 if ($a->config['register_policy'] == REGISTER_APPROVE && is_site_admin()){
132 $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");
133 $register = $regs[0]['total'];
139 function xmlize($href, $name, $url, $photo, $date, $message){
140 $notsxml = '<note href="%s" name="%s" url="%s" photo="%s" date="%s">%s</note>';
141 return sprintf ( $notsxml,
142 xmlify($href), xmlify($name), xmlify($url), xmlify($photo), xmlify($date), xmlify($message)
147 echo "<intro>$intro</intro>
151 if ($register!=0) echo "<register>$register</register>";
153 $tot = $mail+$intro+$register+count($comments)+count($likes)+count($dislikes)+count($friends)+count($posts)+count($tags)+count($cit);
155 echo ' <notif count="'.$tot.'">';
157 foreach ($intros as $i) {
158 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") );
162 foreach ($mails as $i) {
163 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") );
167 foreach ($regs as $i) {
168 echo xmlize( $a->get_baseurl().'/admin/users/', $i['name'], $i['url'], $i['micro'], relative_date($i['created']), t("{0} requested registration") );
172 if (count($comments)){
173 foreach ($comments as $i) {
174 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'] ) );
178 foreach ($likes as $i) {
179 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'] ) );
182 if (count($dislikes)){
183 foreach ($dislikes as $i) {
184 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'] ) );
187 if (count($friends)){
188 foreach ($friends as $i) {
189 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'] ) );
193 foreach ($posts as $i) {
194 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} posted") );
198 foreach ($tags as $i) {
199 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'] ) );
203 foreach ($cit as $i) {
204 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") );
212 if(x($_SESSION,'sysmsg')){
213 foreach ($_SESSION['sysmsg'] as $m){
214 echo "<notice>".xmlify($m)."</notice>";
216 unset($_SESSION['sysmsg']);
218 if(x($_SESSION,'sysmsg_info')){
219 foreach ($_SESSION['sysmsg_info'] as $m){
220 echo "<info>".xmlify($m)."</info>";
222 unset($_SESSION['sysmsg_info']);