]> git.mxchange.org Git - friendica.git/commitdiff
cleanup
authorMike Macgirvin <mike@macgirvin.com>
Thu, 9 Sep 2010 23:48:33 +0000 (16:48 -0700)
committerMike Macgirvin <mike@macgirvin.com>
Thu, 9 Sep 2010 23:48:33 +0000 (16:48 -0700)
boot.php
include/items.php
include/notifier.php
mod/dfrn_notify.php
mod/redir.php

index 4c2526d66d779fcec9a14ec3eccb3ba932fc5145..b262c0718a6978408d0be6089be84d9254e785fd 100644 (file)
--- a/boot.php
+++ b/boot.php
@@ -5,6 +5,7 @@ set_time_limit(0);
 define ( 'BUILD_ID' , 1001 );
 
 define ( 'EOL', "<br />\r\n");
+define ( 'ATOM_TIME',  'Y-m-d\TH:i:s\Z' );
 
 define ( 'REGISTER_CLOSED',  0);
 define ( 'REGISTER_APPROVE', 1);
@@ -15,6 +16,10 @@ define ( 'DIRECTION_IN',   1);                       // VIP e.g. has FAN
 define ( 'DIRECTION_OUT',  2);                 // FAN to a VIP
 define ( 'DIRECTION_BOTH', 3);                 // Mutual Friends
 
+define ( 'REL_VIP',        1);
+define ( 'REL_FAN',        2);
+define ( 'REL_BUD',        3);
+
 define ( 'NOTIFY_INTRO',   0x0001 );
 define ( 'NOTIFY_CONFIRM', 0x0002 );
 define ( 'NOTIFY_WALL',    0x0004 );
@@ -22,6 +27,8 @@ define ( 'NOTIFY_COMMENT', 0x0008 );
 define ( 'NOTIFY_MAIL',    0x0010 );
 
 define ( 'NAMESPACE_DFRN' ,      'http://purl.org/macgirvin/dfrn/1.0' ); 
+define ( 'NAMESPACE_THREAD' ,    'http://purl.org/syndication/thread/1.0' );
+define ( 'NAMESPACE_TOMB' ,      'http://purl.org/atompub/tombstones/1.0' );
 define ( 'NAMESPACE_ACTIVITY',   'http://activitystrea.ms/spec/1.0/' );
 define ( 'NAMESPACE_ACTIVITY_SCHEMA', 'http://activitystrea.ms/schema/1.0/');
 define ( 'ACTIVITY_LIKE',        NAMESPACE_ACTIVITY_SCHEMA . 'like' );
@@ -37,8 +44,7 @@ define ( 'ACTIVITY_OBJ_P_PHOTO', NAMESPACE_ACTIVITY_SCHEMA . 'profile-photo' );
 define ( 'ACTIVITY_OBJ_ALBUM',   NAMESPACE_ACTIVITY_SCHEMA . 'photo-album' );
 
 
-define ( 'ACTIVITY_OBJ_HEART',    NAMESPACE_DFRN     . '/heart' );
-
+define ( 'ACTIVITY_OBJ_HEART',   NAMESPACE_DFRN     . '/heart' );
 
 
 if(! class_exists('App')) {
index a4521eddaa2910508bd42e74a1fec8e59841c30e..45116a3bdb07131a87cd6ec742b533e04b024a11 100644 (file)
@@ -97,17 +97,16 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
 
 
        $atom .= replace_macros($feed_template, array(
-                       '$feed_id' => xmlify($a->get_baseurl() . '/profile/' . $owner_nick),
-                       '$feed_title' => xmlify($owner['name']),
-                       '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$name' => xmlify($owner['name']),
+                       '$feed_id'      => xmlify($a->get_baseurl() . '/profile/' . $owner_nick),
+                       '$feed_title'   => xmlify($owner['name']),
+                       '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
+                       '$name'         => xmlify($owner['name']),
                        '$profile_page' => xmlify($owner['url']),
-                       '$photo' => xmlify($owner['photo']),
-                       '$thumb' => xmlify($owner['thumb']),
-                       '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date']    . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date']   . '+00:00' , 'Y-m-d\TH:i:s\Z')) 
-
+                       '$photo'        => xmlify($owner['photo']),
+                       '$thumb'        => xmlify($owner['thumb']),
+                       '$picdate'      => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
+                       '$uridate'      => xmlify(datetime_convert('UTC','UTC',$owner['uri-date']    . '+00:00' , ATOM_TIME)) ,
+                       '$namdate'      => xmlify(datetime_convert('UTC','UTC',$owner['name-date']   . '+00:00' , ATOM_TIME)) 
        ));
 
        
@@ -126,7 +125,7 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
                if($item['deleted']) {
                        $atom .= replace_macros($tomb_template, array(
                                '$id' => xmlify($item['uri']),
-                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
+                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME))
                        ));
                }
                else {
@@ -143,14 +142,14 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
                                        '$owner_thumb' => xmlify($item['owner-avatar']),
                                        '$item_id' => xmlify($item['uri']),
                                        '$title' => xmlify($item['title']),
-                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
                                        '$location' => xmlify($item['location']),
                                        '$type' => $type,
                                        '$content' => xmlify($item['body']),
                                        '$verb' => xmlify($verb),
                                        '$actobj' => $actobj,  // do not xmlify
-                                       '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0)
+                                       '$comment_allow' => ((($item['last-child']) && ($contact['rel']) && ($contact['rel'] != REL_FAN)) ? 1 : 0)
                                ));
                        }
                        else {
@@ -160,8 +159,8 @@ function get_feed_for(&$a, $dfrn_id, $owner_id, $last_update) {
                                        '$thumb' => xmlify($item['thumb']),
                                        '$item_id' => xmlify($item['uri']),
                                        '$title' => xmlify($item['title']),
-                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
+                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
                                        '$type' => $type,
                                        '$content' =>xmlify($item['body']),
                                        '$verb' => xmlify($verb),
index 24e54373aacee8ddf9a3f86fefc8e196962faf7a..a703dbee9c46bbb66868144f4947245b27c9eb02 100644 (file)
@@ -69,7 +69,9 @@
                        killme();
        }
 
-       $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1",
+       $r = q("SELECT `contact`.*, `user`.`nickname` 
+               FROM `contact` LEFT JOIN `user` ON `user`.`uid` = `contact`.`uid` 
+               WHERE `contact`.`uid` = %d AND `contact`.`self` = 1 LIMIT 1",
                intval($uid)
        );
 
 
 
        $atom .= replace_macros($feed_template, array(
-                       '$feed_id' => xmlify($a->get_baseurl()),
-                       '$feed_title' => xmlify($owner['name']),
-                       '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                               $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$name' => xmlify($owner['name']),
+                       '$feed_id'      => xmlify($a->get_baseurl() . '/profile/' . $owner['nickname'] ),
+                       '$feed_title'   => xmlify($owner['name']),
+                       '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', $updated . '+00:00' , ATOM_TIME)) ,
+                       '$name'         => xmlify($owner['name']),
                        '$profile_page' => xmlify($owner['url']),
-                       '$photo' => xmlify($owner['photo']),
-                       '$thumb' => xmlify($owner['thumb']),
-                       '$picdate' => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$uridate' => xmlify(datetime_convert('UTC','UTC',$owner['uri-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) ,
-                       '$namdate' => xmlify(datetime_convert('UTC','UTC',$owner['name-date'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
+                       '$photo'        => xmlify($owner['photo']),
+                       '$thumb'        => xmlify($owner['thumb']),
+                       '$picdate'      => xmlify(datetime_convert('UTC','UTC',$owner['avatar-date'] . '+00:00' , ATOM_TIME)) ,
+                       '$uridate'      => xmlify(datetime_convert('UTC','UTC',$owner['uri-date']    . '+00:00' , ATOM_TIME)) ,
+                       '$namdate'      => xmlify(datetime_convert('UTC','UTC',$owner['name-date']   . '+00:00' , ATOM_TIME))
        ));
 
        if($cmd == 'mail') {
                $atom .= replace_macros($mail_template, array(
-                       '$name' => xmlify($owner['name']),
+                       '$name'         => xmlify($owner['name']),
                        '$profile_page' => xmlify($owner['url']),
-                       '$thumb' => xmlify($owner['thumb']),
-                       '$item_id' => xmlify($item['uri']),
-                       '$subject' => xmlify($item['title']),
-                       '$created' => xmlify(datetime_convert('UTC', 'UTC', 
-                               $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                       '$content' =>xmlify($item['body']),
-                       '$parent_id' => xmlify($item['parent-uri'])
-
+                       '$thumb'        => xmlify($owner['thumb']),
+                       '$item_id'      => xmlify($item['uri']),
+                       '$subject'      => xmlify($item['title']),
+                       '$created'      => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                       '$content'      => xmlify($item['body']),
+                       '$parent_id'    => xmlify($item['parent-uri'])
                ));
        }
        else {
                        foreach($items as $item) {
                                if($item['id'] == $item_id) {
                                        $atom .= replace_macros($cmnt_template, array(
-                                               '$name' => xmlify($owner['name']),
-                                               '$profile_page' => xmlify($owner['url']),
-                                               '$thumb' => xmlify($owner['thumb']),
-                                               '$item_id' => xmlify($item['uri']),
-                                               '$title' => xmlify($item['title']),
-                                               '$published' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                       $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                       $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                               '$location' => xmlify($item['location']),
-                                               '$type' => 'text',
-                                               '$verb' => xmlify($verb),
-                                               '$actobj' => $actobj,
-                                               '$content' => xmlify($item['body']),
-                                               '$parent_id' => xmlify($item['parent-uri']),
-                                               '$comment_allow' => 0
+                                               '$name'               => xmlify($owner['name']),
+                                               '$profile_page'       => xmlify($owner['url']),
+                                               '$thumb'              => xmlify($owner['thumb']),
+                                               '$owner_name'         => xmlify($item['owner-name']),
+                                               '$owner_profile_page' => xmlify($item['owner-link']),
+                                               '$owner_thumb'        => xmlify($item['owner-avatar']),
+                                               '$item_id'            => xmlify($item['uri']),
+                                               '$title'              => xmlify($item['title']),
+                                               '$published'          => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                               '$updated'            => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
+                                               '$location'           => xmlify($item['location']),
+                                               '$type'               => 'text',
+                                               '$verb'               => xmlify($verb),
+                                               '$actobj'             => $actobj,
+                                               '$content'            => xmlify($item['body']),
+                                               '$parent_id'          => xmlify($item['parent-uri']),
+                                               '$comment_allow'      => 0
                                        ));
                                }
                        }
                                if($item['deleted']) {
                                        $atom .= replace_macros($tomb_template, array(
                                                '$id' => xmlify($item['uri']),
-                                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                       $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z'))
+                                               '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME))
                                        ));
                                }
                                else {
                                                if($item['contact-id'] == $contact['id']) {
                                                        if($item['parent'] == $item['id']) {
                                                                $atom .= replace_macros($item_template, array(
-                                                                       '$name' => xmlify($contact['name']),
-                                                                       '$profile_page' => xmlify($contact['url']),
-                                                                       '$thumb' => xmlify($contact['thumb']),
-                                                                       '$owner_name' => xmlify($item['owner-name']),
+                                                                       '$name'               => xmlify($contact['name']),
+                                                                       '$profile_page'       => xmlify($contact['url']),
+                                                                       '$thumb'              => xmlify($contact['thumb']),
+                                                                       '$owner_name'         => xmlify($item['owner-name']),
                                                                        '$owner_profile_page' => xmlify($item['owner-link']),
-                                                                       '$owner_thumb' => xmlify($item['owner-avatar']),
-                                                                       '$item_id' => xmlify($item['uri']),
-                                                                       '$title' => xmlify($item['title']),
-                                                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$location' => xmlify($item['location']),
-                                                                       '$type' => 'text',
-                                                                       '$verb' => xmlify($verb),
-                                                                       '$actobj' => $actobj,
-                                                                       '$content' =>xmlify($item['body']),
-                                                                       '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0)
+                                                                       '$owner_thumb'        => xmlify($item['owner-avatar']),
+                                                                       '$item_id'            => xmlify($item['uri']),
+                                                                       '$title'              => xmlify($item['title']),
+                                                                       '$published'          => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                                                       '$updated'            => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
+                                                                       '$location'           => xmlify($item['location']),
+                                                                       '$type'               => 'text',
+                                                                       '$verb'               => xmlify($verb),
+                                                                       '$actobj'             => $actobj,
+                                                                       '$content'            => xmlify($item['body']),
+                                                                       '$comment_allow'      => (($item['last-child'] && ($contact['rel']) && ($contact['rel'] != REL_FAN)) ? 1 : 0)
                                                                ));
                                                        }
                                                        else {
                                                                $atom .= replace_macros($cmnt_template, array(
-                                                                       '$name' => xmlify($contact['name']),
-                                                                       '$profile_page' => xmlify($contact['url']),
-                                                                       '$thumb' => xmlify($contact['thumb']),
-                                                                       '$item_id' => xmlify($item['uri']),
-                                                                       '$title' => xmlify($item['title']),
-                                                                       '$published' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$updated' => xmlify(datetime_convert('UTC', 'UTC', 
-                                                                               $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')),
-                                                                       '$content' =>xmlify($item['body']),
-                                                                       '$location' =>xmlify($item['location']),
-                                                                       '$type' => 'text',
-                                                                       '$verb' => xmlify($verb),
-                                                                       '$actobj' => $actobj,
-                                                                       '$parent_id' => xmlify($item['parent-uri']),
+                                                                       '$name'          => xmlify($contact['name']),
+                                                                       '$profile_page'  => xmlify($contact['url']),
+                                                                       '$thumb'         => xmlify($contact['thumb']),
+                                                                       '$item_id'       => xmlify($item['uri']),
+                                                                       '$title'         => xmlify($item['title']),
+                                                                       '$published'     => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , ATOM_TIME)),
+                                                                       '$updated'       => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , ATOM_TIME)),
+                                                                       '$content'       => xmlify($item['body']),
+                                                                       '$location'      => xmlify($item['location']),
+                                                                       '$type'          => 'text',
+                                                                       '$verb'          => xmlify($verb),
+                                                                       '$actobj'        => $actobj,
+                                                                       '$parent_id'     => xmlify($item['parent-uri']),
                                                                        '$comment_allow' => (($item['last-child']) ? 1 : 0)
                                                                ));
                                                        }
                if((intval($res->status) != 0) || (! strlen($res->challenge)) || (! strlen($res->dfrn_id)))
                        continue;
 
-               $postvars = array();
+               $postvars     = array();
+
                $sent_dfrn_id = hex2bin($res->dfrn_id);
-               $challenge = hex2bin($res->challenge);
+               $challenge    = hex2bin($res->challenge);
+
                $final_dfrn_id = '';
 
                if($rr['duplex'] && strlen($rr['prvkey'])) {
 
                $postvars['dfrn_id'] = $idtosend;
 
-               if((($rr['rel'] == DIRECTION_OUT) || ($rr['rel'] == DIRECTION_BOTH)) && (! $rr['blocked']) && (! $rr['readonly'])) {
+               if(($rr['rel']) && ($rr['rel'] != REL_FAN) && (! $rr['blocked']) && (! $rr['readonly'])) {
                        $postvars['data'] = $atom;
                }
                else {
index 1164bafe39ccf0029512018478caa956fc627949..7bcf2af09c6d8ef13b89f4549750b4a40b72ce35 100644 (file)
@@ -92,8 +92,8 @@ function dfrn_notify_post(&$a) {
                                '$body' => strip_tags(bbcode($msg['body']))
                        ));
 
-                       $res = mail($importer['email'], t("New mail received at ") . $a->config['sitename'],
-                               $email_tpl,t("From: Administrator@") . $a->get_hostname() );
+                       $res = mail($importer['email'], t('New mail received at ') . $a->config['sitename'],
+                               $email_tpl, 'From: ' . t('Administrator') . '@' . $a->get_hostname() );
                }
                xml_status(0);
                return; // NOTREACHED
@@ -109,7 +109,7 @@ function dfrn_notify_post(&$a) {
 
                $deleted = false;
 
-               $rawdelete = $item->get_item_tags("http://purl.org/atompub/tombstones/1.0", 'deleted-entry');
+               $rawdelete = $item->get_item_tags( NAMESPACE_TOMB , 'deleted-entry');
                if(isset($rawdelete[0]['attribs']['']['ref'])) {
                        $uri = $rawthread[0]['attribs']['']['ref'];
                        $deleted = true;
@@ -170,7 +170,7 @@ function dfrn_notify_post(&$a) {
 
                $is_reply = false;              
                $item_id = $item->get_id();
-               $rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0",'in-reply-to');
+               $rawthread = $item->get_item_tags( NAMESPACE_THREAD, 'in-reply-to');
                if(isset($rawthread[0]['attribs']['']['ref'])) {
                        $is_reply = true;
                        $parent_uri = $rawthread[0]['attribs']['']['ref'];
index 88b291146bed494e32d83fed9385f290635a9fed..688e516ab1636482e67f631d9aeb96c3d9b2b3e7 100644 (file)
@@ -10,7 +10,9 @@ function redir_init(&$a) {
        if(! count($r))
                goaway($a->get_baseurl());
 
-       $dfrn_id = (($r[0]['duplex']) ? $r[0]['dfrn-id'] : $r[0]['issued-id']);
+       $dfrn_id = $r[0]['issued-id'];
+       if((! $dfrn_id) && ($r[0]['duplex']))
+               $dfrn_id = $r[0]['dfrn-id'];
 
        q("INSERT INTO `profile_check` ( `uid`, `dfrn_id`, `expire`)
                VALUES( %d, '%s', %d )",
@@ -20,5 +22,4 @@ function redir_init(&$a) {
        goaway ($r[0]['poll'] . '?dfrn_id=' . $dfrn_id . '&type=profile');
 
        
-       
 }
\ No newline at end of file