From 059e090b53643cb07a2634b700ada5cf3b6894e8 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Fri, 16 Jul 2010 06:24:41 -0700 Subject: [PATCH 01/16] sorting out visitor sessions --- include/auth.php | 2 + include/notifier.php | 3 + mod/dfrn_notify.php | 14 ++- mod/dfrn_poll.php | 2 +- mod/profile.php | 23 ++-- simplepie/simplepie.inc | 232 ++++++++++++++++++++-------------------- update.sql | 6 +- view/atom_item.tpl | 5 + 8 files changed, 158 insertions(+), 129 deletions(-) diff --git a/include/auth.php b/include/auth.php index 5e454745e3..387cab0afd 100644 --- a/include/auth.php +++ b/include/auth.php @@ -7,6 +7,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) { unset($_SESSION['authenticated']); unset($_SESSION['uid']); unset($_SESSION['visitor_id']); + unset($_SESSION['is_visitor']); unset($_SESSION['administrator']); unset($_SESSION['cid']); $_SESSION['sysmsg'] = "Logged out." . EOL; @@ -34,6 +35,7 @@ else { unset($_SESSION['authenticated']); unset($_SESSION['uid']); unset($_SESSION['visitor_id']); + unset($_SESSION['is_visitor']); unset($_SESSION['administrator']); unset($_SESSION['cid']); $encrypted = hash('whirlpool',trim($_POST['password'])); diff --git a/include/notifier.php b/include/notifier.php index 4d114a4e33..f7c0570d80 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -151,6 +151,9 @@ if($argc < 3) '$name' => xmlify($contact['name']), '$profile_page' => xmlify($contact['url']), '$thumb' => xmlify($contact['thumb']), + '$owner_name' => xmlify($owner['name']), + '$owner_profile_page' => xmlify($owner['url']), + '$owner_thumb' => xmlify($owner['thumb']), '$item_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), '$title' => xmlify($contact['name']), '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 5011471426..6ab8d584a0 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -32,6 +32,13 @@ function get_atom_elements($item) { if($rawedited) $res['edited'] = $rawcreated[0]['data']; + $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0", 'owner'); + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']) + $res['owner-name'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']; + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']) + $res['owner-link'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']; + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']) + $res['owner-avatar'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']; return $res; @@ -45,13 +52,18 @@ function post_remote($arr) { $arr['remote-name'] = notags(trim($arr['remote-name'])); $arr['remote-link'] = notags(trim($arr['remote-link'])); $arr['remote-avatar'] = notags(trim($arr['remote-avatar'])); + $arr['owner-name'] = notags(trim($arr['owner-name'])); + $arr['owner-link'] = notags(trim($arr['owner-link'])); + $arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); if(! strlen($arr['remote-avatar'])) $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; + if(! strlen($arr['owner-avatar'])) + $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); $arr['title'] = notags(trim($arr['title'])); $arr['body'] = escape_tags(trim($arr['body'])); - $arr['last-child'] = intval($arr['last_child']); + $arr['last-child'] = intval($arr['last-child']); $arr['visible'] = 1; $arr['deleted'] = 0; diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index da60eb6292..8873526943 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -39,7 +39,7 @@ function dfrn_poll_init(&$a) { } } $profile = ((strlen($r[0]['nickname'])) ? $r[0]['nickname'] : $r[0]['uid']); - goaway($a->get_baseurl() . "/profile/$profile"); + goaway($a->get_baseurl() . "/profile/$profile/visit"); } goaway($a->get_baseurl()); } diff --git a/mod/profile.php b/mod/profile.php index 5a1ac06391..6bd265562d 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -43,12 +43,6 @@ function profile_load(&$a,$uid,$profile = 0) { function profile_init(&$a) { - if($_SESSION['authenticated']) { - - // choose which page to show (could be remote auth) - - } - if($a->argc > 1) $which = $a->argv[1]; else { @@ -57,6 +51,15 @@ function profile_init(&$a) { return; } + if(($remote_user) && ($a->argc > 2) && ($a->argv[2] == 'visit')) + $_SESSION['is_visitor'] = 1; + else { + unset($_SESSION['is_visitor']); + unset($_SESSION['visitor_id']); + if(! $_SESSION['uid']) + unset($_SESSION['authenticated']); + } + profile_load($a,$which); $a->page['htmlhead'] .= "get_baseurl() . "/profile/%s" . "\" />\r\n"; @@ -79,9 +82,9 @@ function item_display(&$a, $item,$template,$comment) { $o .= replace_macros($template,array( '$id' => $item['item_id'], - '$profile_url' => $profile_url, - '$name' => $item['name'], - '$thumb' => $thumb, + '$profile_url' => ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url), + '$name' => ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']), + '$thumb' => ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb), '$body' => bbcode($item['body']), '$ago' => relative_date($item['created']), '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), @@ -196,7 +199,7 @@ function profile_content(&$a) { if(count($r)) $a->set_pager_total($r[0]['total']); - +dbg(2); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, diff --git a/simplepie/simplepie.inc b/simplepie/simplepie.inc index 1f40ac5934..cd5f469442 100644 --- a/simplepie/simplepie.inc +++ b/simplepie/simplepie.inc @@ -735,7 +735,7 @@ class SimplePie function SimplePie($feed_url = null, $cache_location = null, $cache_duration = null) { // Other objects, instances created here so we can set options on them - $this->sanitize =& new SimplePie_Sanitize; + $this->sanitize = new SimplePie_Sanitize; // Set options if they're passed to the constructor if ($cache_location !== null) @@ -1105,7 +1105,7 @@ class SimplePie { if (SimplePie_Misc::is_subclass_of($class, 'SimplePie_Sanitize')) { - $this->sanitize =& new $class; + $this->sanitize = new $class; return true; } return false; @@ -1599,7 +1599,7 @@ class SimplePie { $headers['if-none-match'] = '"' . $this->data['headers']['etag'] . '"'; } - $file =& new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen); + $file = new $this->file_class($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen); if ($file->success) { if ($file->status_code === 304) @@ -1640,7 +1640,7 @@ class SimplePie } else { - $file =& new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen); + $file = new $this->file_class($this->feed_url, $this->timeout, 5, null, $this->useragent, $this->force_fsockopen); } } // If the file connection has an error, set SimplePie::error to that and quit @@ -1660,7 +1660,7 @@ class SimplePie if (!$this->force_feed) { // Check if the supplied URL is a feed, if it isn't, look for it. - $locate =& new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class); + $locate = new $this->locator_class($file, $this->timeout, $this->useragent, $this->file_class, $this->max_checked_feeds, $this->content_type_sniffer_class); if (!$locate->is_feed($file)) { // We need to unset this so that if SimplePie::set_file() has been called that object is untouched @@ -1690,7 +1690,7 @@ class SimplePie $headers = $file->headers; $data = $file->body; - $sniffer =& new $this->content_type_sniffer_class($file); + $sniffer = new $this->content_type_sniffer_class($file); $sniffed = $sniffer->get_type(); } else @@ -1760,7 +1760,7 @@ class SimplePie if ($utf8_data = SimplePie_Misc::change_encoding($data, $encoding, 'UTF-8')) { // Create new parser - $parser =& new $this->parser_class(); + $parser = new $this->parser_class(); // If it's parsed fine if ($parser->parse($utf8_data, 'UTF-8')) @@ -1971,11 +1971,11 @@ class SimplePie } else { - $file =& new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); + $file = new $this->file_class($favicon, $this->timeout / 10, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300)) && strlen($file->body) > 0) { - $sniffer =& new $this->content_type_sniffer_class($file); + $sniffer = new $this->content_type_sniffer_class($file); if (substr($sniffer->get_type(), 0, 6) === 'image/') { if ($cache->save(array('headers' => $file->headers, 'body' => $file->body))) @@ -2374,7 +2374,7 @@ class SimplePie { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories[] =& new $this->category_class($term, $scheme, $label); + $categories[] = new $this->category_class($term, $scheme, $label); } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { @@ -2389,15 +2389,15 @@ class SimplePie { $scheme = null; } - $categories[] =& new $this->category_class($term, $scheme, null); + $categories[] = new $this->category_class($term, $scheme, null); } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { - $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) { - $categories[] =& new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $categories[] = new $this->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } if (!empty($categories)) @@ -2450,7 +2450,7 @@ class SimplePie } if ($name !== null || $email !== null || $uri !== null || $avatar !== null) { - $authors[] =& new $this->author_class($name, $uri, $email, $avatar); + $authors[] = new $this->author_class($name, $uri, $email, $avatar); } } if ($author = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'author')) @@ -2472,20 +2472,20 @@ class SimplePie } if ($name !== null || $email !== null || $url !== null) { - $authors[] =& new $this->author_class($name, $url, $email); + $authors[] = new $this->author_class($name, $url, $email); } } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) { - $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) { - $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) { - $authors[] =& new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } if (!empty($authors)) @@ -2533,7 +2533,7 @@ class SimplePie } if ($name !== null || $email !== null || $uri !== null) { - $contributors[] =& new $this->author_class($name, $uri, $email); + $contributors[] = new $this->author_class($name, $uri, $email); } } foreach ((array) $this->get_channel_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) @@ -2555,7 +2555,7 @@ class SimplePie } if ($name !== null || $email !== null || $url !== null) { - $contributors[] =& new $this->author_class($name, $url, $email); + $contributors[] = new $this->author_class($name, $url, $email); } } @@ -2969,7 +2969,7 @@ class SimplePie $keys = array_keys($items); foreach ($keys as $key) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $this->data['items'][] = new $this->item_class($this, $items[$key]); } } if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'entry')) @@ -2977,7 +2977,7 @@ class SimplePie $keys = array_keys($items); foreach ($keys as $key) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $this->data['items'][] = new $this->item_class($this, $items[$key]); } } if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_10, 'item')) @@ -2985,7 +2985,7 @@ class SimplePie $keys = array_keys($items); foreach ($keys as $key) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $this->data['items'][] = new $this->item_class($this, $items[$key]); } } if ($items = $this->get_feed_tags(SIMPLEPIE_NAMESPACE_RSS_090, 'item')) @@ -2993,7 +2993,7 @@ class SimplePie $keys = array_keys($items); foreach ($keys as $key) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $this->data['items'][] = new $this->item_class($this, $items[$key]); } } if ($items = $this->get_channel_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'item')) @@ -3001,7 +3001,7 @@ class SimplePie $keys = array_keys($items); foreach ($keys as $key) { - $this->data['items'][] =& new $this->item_class($this, $items[$key]); + $this->data['items'][] = new $this->item_class($this, $items[$key]); } } } @@ -3352,7 +3352,7 @@ class SimplePie_Item { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); + $categories[] = new $this->feed->category_class($term, $scheme, $label); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { @@ -3367,15 +3367,15 @@ class SimplePie_Item { $scheme = null; } - $categories[] =& new $this->feed->category_class($term, $scheme, null); + $categories[] = new $this->feed->category_class($term, $scheme, null); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { - $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) { - $categories[] =& new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $categories[] = new $this->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } if (!empty($categories)) @@ -3436,7 +3436,7 @@ class SimplePie_Item } if ($name !== null || $email !== null || $uri !== null) { - $contributors[] =& new $this->feed->author_class($name, $uri, $email); + $contributors[] = new $this->feed->author_class($name, $uri, $email); } } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) @@ -3458,7 +3458,7 @@ class SimplePie_Item } if ($name !== null || $email !== null || $url !== null) { - $contributors[] =& new $this->feed->author_class($name, $url, $email); + $contributors[] = new $this->feed->author_class($name, $url, $email); } } @@ -3499,7 +3499,7 @@ class SimplePie_Item } if ($name !== null || $email !== null || $uri !== null || $avatar !== null) { - $authors[] =& new $this->feed->author_class($name, $uri, $email, $avatar); + $authors[] = new $this->feed->author_class($name, $uri, $email, $avatar); } } @@ -3522,24 +3522,24 @@ class SimplePie_Item } if ($name !== null || $email !== null || $url !== null) { - $authors[] =& new $this->feed->author_class($name, $url, $email); + $authors[] = new $this->feed->author_class($name, $url, $email); } } if ($author = $this->get_item_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'author')) { - $authors[] =& new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); + $authors[] = new $this->feed->author_class(null, null, $this->sanitize($author[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT)); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) { - $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) { - $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) { - $authors[] =& new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } if (!empty($authors)) @@ -3849,7 +3849,7 @@ class SimplePie_Item { $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } } elseif ($captions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'text')) @@ -3881,7 +3881,7 @@ class SimplePie_Item { $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $captions_parent[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + $captions_parent[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } } if (is_array($captions_parent)) @@ -3911,7 +3911,7 @@ class SimplePie_Item { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); } foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'category') as $category) { @@ -3934,7 +3934,7 @@ class SimplePie_Item { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); } foreach ((array) $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'category') as $category) { @@ -3945,7 +3945,7 @@ class SimplePie_Item { $label = $this->sanitize($category['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); if (isset($category['child'][SIMPLEPIE_NAMESPACE_ITUNES]['category'])) { @@ -3955,7 +3955,7 @@ class SimplePie_Item { $label = $this->sanitize($subcategory['attribs']['']['text'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories_parent[] =& new $this->feed->category_class($term, $scheme, $label); + $categories_parent[] = new $this->feed->category_class($term, $scheme, $label); } } } @@ -3977,7 +3977,7 @@ class SimplePie_Item { $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label); + $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label); } elseif ($copyright = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'copyright')) { @@ -3991,7 +3991,7 @@ class SimplePie_Item { $copyright_label = $this->sanitize($copyright[0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $copyrights_parent =& new $this->feed->copyright_class($copyright_url, $copyright_label); + $copyrights_parent = new $this->feed->copyright_class($copyright_url, $copyright_label); } // CREDITS @@ -4018,7 +4018,7 @@ class SimplePie_Item { $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } } elseif ($credits = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'credit')) @@ -4044,7 +4044,7 @@ class SimplePie_Item { $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $credits_parent[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + $credits_parent[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } } if (is_array($credits_parent)) @@ -4233,7 +4233,7 @@ class SimplePie_Item { $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); } } elseif ($ratings = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) @@ -4246,7 +4246,7 @@ class SimplePie_Item { $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); } } elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'rating')) @@ -4267,7 +4267,7 @@ class SimplePie_Item { $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); } } elseif ($ratings = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'explicit')) @@ -4280,7 +4280,7 @@ class SimplePie_Item { $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $ratings_parent[] =& new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings_parent[] = new $this->feed->rating_class($rating_scheme, $rating_value); } } if (is_array($ratings_parent)) @@ -4308,7 +4308,7 @@ class SimplePie_Item { $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } } elseif ($restrictions = $this->get_item_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) @@ -4322,7 +4322,7 @@ class SimplePie_Item { $restriction_relationship = 'deny'; } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } } elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_MEDIARSS, 'restriction')) @@ -4344,7 +4344,7 @@ class SimplePie_Item { $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } } elseif ($restrictions = $parent->get_channel_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'block')) @@ -4358,7 +4358,7 @@ class SimplePie_Item { $restriction_relationship = 'deny'; } - $restrictions_parent[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions_parent[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } } if (is_array($restrictions_parent)) @@ -4564,7 +4564,7 @@ class SimplePie_Item { $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } if (is_array($captions)) { @@ -4600,7 +4600,7 @@ class SimplePie_Item { $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } if (is_array($captions)) { @@ -4636,7 +4636,7 @@ class SimplePie_Item { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); + $categories[] = new $this->feed->category_class($term, $scheme, $label); } } if (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['category'])) @@ -4662,7 +4662,7 @@ class SimplePie_Item { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); + $categories[] = new $this->feed->category_class($term, $scheme, $label); } } if (is_array($categories) && is_array($categories_parent)) @@ -4691,7 +4691,7 @@ class SimplePie_Item { $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label); + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); } elseif (isset($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'])) { @@ -4705,7 +4705,7 @@ class SimplePie_Item { $copyright_label = $this->sanitize($group['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label); + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); } else { @@ -4736,7 +4736,7 @@ class SimplePie_Item { $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } if (is_array($credits)) { @@ -4766,7 +4766,7 @@ class SimplePie_Item { $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } if (is_array($credits)) { @@ -4919,7 +4919,7 @@ class SimplePie_Item { $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); } if (is_array($ratings)) { @@ -4944,7 +4944,7 @@ class SimplePie_Item { $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); } if (is_array($ratings)) { @@ -4976,7 +4976,7 @@ class SimplePie_Item { $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } if (is_array($restrictions)) { @@ -5002,7 +5002,7 @@ class SimplePie_Item { $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } if (is_array($restrictions)) { @@ -5056,7 +5056,7 @@ class SimplePie_Item $title = $title_parent; } - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); } } } @@ -5186,7 +5186,7 @@ class SimplePie_Item { $caption_text = $this->sanitize($caption['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $captions[] =& new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); + $captions[] = new $this->feed->caption_class($caption_type, $caption_lang, $caption_startTime, $caption_endTime, $caption_text); } if (is_array($captions)) { @@ -5222,7 +5222,7 @@ class SimplePie_Item { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories[] =& new $this->feed->category_class($term, $scheme, $label); + $categories[] = new $this->feed->category_class($term, $scheme, $label); } } if (is_array($categories) && is_array($categories_parent)) @@ -5255,7 +5255,7 @@ class SimplePie_Item { $copyright_label = $this->sanitize($content['child'][SIMPLEPIE_NAMESPACE_MEDIARSS]['copyright'][0]['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $copyrights =& new $this->feed->copyright_class($copyright_url, $copyright_label); + $copyrights = new $this->feed->copyright_class($copyright_url, $copyright_label); } else { @@ -5286,7 +5286,7 @@ class SimplePie_Item { $credit_name = $this->sanitize($credit['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $credits[] =& new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); + $credits[] = new $this->feed->credit_class($credit_role, $credit_scheme, $credit_name); } if (is_array($credits)) { @@ -5390,7 +5390,7 @@ class SimplePie_Item { $rating_value = $this->sanitize($rating['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $ratings[] =& new $this->feed->rating_class($rating_scheme, $rating_value); + $ratings[] = new $this->feed->rating_class($rating_scheme, $rating_value); } if (is_array($ratings)) { @@ -5422,7 +5422,7 @@ class SimplePie_Item { $restriction_value = $this->sanitize($restriction['data'], SIMPLEPIE_CONSTRUCT_TEXT); } - $restrictions[] =& new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); + $restrictions[] = new $this->feed->restriction_class($restriction_relationship, $restriction_type, $restriction_value); } if (is_array($restrictions)) { @@ -5461,7 +5461,7 @@ class SimplePie_Item $title = $title_parent; } - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions, $categories, $channels, $copyrights, $credits, $description, $duration, $expression, $framerate, $hashes, $height, $keywords, $lang, $medium, $player, $ratings, $restrictions, $samplingrate, $thumbnails, $title, $width); } } } @@ -5497,7 +5497,7 @@ class SimplePie_Item } // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); } } @@ -5532,7 +5532,7 @@ class SimplePie_Item } // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); } } @@ -5567,14 +5567,14 @@ class SimplePie_Item } // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); } } if (sizeof($this->data['enclosures']) === 0 && ($url || $type || $length || $bitrate || $captions_parent || $categories_parent || $channels || $copyrights_parent || $credits_parent || $description_parent || $duration_parent || $expression || $framerate || $hashes_parent || $height || $keywords_parent || $lang || $medium || $player_parent || $ratings_parent || $restrictions_parent || $samplingrate || $thumbnails_parent || $title_parent || $width)) { // Since we don't have group or content for these, we'll just pass the '*_parent' variables directly to the constructor - $this->data['enclosures'][] =& new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); + $this->data['enclosures'][] = new $this->feed->enclosure_class($url, $type, $length, $this->feed->javascript, $bitrate, $captions_parent, $categories_parent, $channels, $copyrights_parent, $credits_parent, $description_parent, $duration_parent, $expression, $framerate, $hashes_parent, $height, $keywords_parent, $lang, $medium, $player_parent, $ratings_parent, $restrictions_parent, $samplingrate, $thumbnails_parent, $title_parent, $width); } $this->data['enclosures'] = array_values(SimplePie_Misc::array_unique($this->data['enclosures'])); @@ -5851,7 +5851,7 @@ class SimplePie_Source { $label = $this->sanitize($category['attribs']['']['label'], SIMPLEPIE_CONSTRUCT_TEXT); } - $categories[] =& new $this->item->feed->category_class($term, $scheme, $label); + $categories[] = new $this->item->feed->category_class($term, $scheme, $label); } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_RSS_20, 'category') as $category) { @@ -5866,15 +5866,15 @@ class SimplePie_Source { $scheme = null; } - $categories[] =& new $this->item->feed->category_class($term, $scheme, null); + $categories[] = new $this->item->feed->category_class($term, $scheme, null); } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'subject') as $category) { - $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'subject') as $category) { - $categories[] =& new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $categories[] = new $this->item->feed->category_class($this->sanitize($category['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } if (!empty($categories)) @@ -5926,7 +5926,7 @@ class SimplePie_Source } if ($name !== null || $email !== null || $uri !== null || $avatar !== null) { - $authors[] =& new $this->item->feed->author_class($name, $uri, $email, $avatar); + $authors[] = new $this->item->feed->author_class($name, $uri, $email, $avatar); } } @@ -5949,20 +5949,20 @@ class SimplePie_Source } if ($name !== null || $email !== null || $url !== null) { - $authors[] =& new $this->item->feed->author_class($name, $url, $email); + $authors[] = new $this->item->feed->author_class($name, $url, $email); } } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_11, 'creator') as $author) { - $authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_DC_10, 'creator') as $author) { - $authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ITUNES, 'author') as $author) { - $authors[] =& new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); + $authors[] = new $this->item->feed->author_class($this->sanitize($author['data'], SIMPLEPIE_CONSTRUCT_TEXT), null, null); } if (!empty($authors)) @@ -6010,7 +6010,7 @@ class SimplePie_Source } if ($name !== null || $email !== null || $uri !== null) { - $contributors[] =& new $this->item->feed->author_class($name, $uri, $email); + $contributors[] = new $this->item->feed->author_class($name, $uri, $email); } } foreach ((array) $this->get_source_tags(SIMPLEPIE_NAMESPACE_ATOM_03, 'contributor') as $contributor) @@ -6032,7 +6032,7 @@ class SimplePie_Source } if ($name !== null || $email !== null || $url !== null) { - $contributors[] =& new $this->item->feed->author_class($name, $url, $email); + $contributors[] = new $this->item->feed->author_class($name, $url, $email); } } @@ -6485,7 +6485,7 @@ class SimplePie_Enclosure $this->width = $width; if (class_exists('idna_convert')) { - $idn =& new idna_convert; + $idn = new idna_convert; $parsed = SimplePie_Misc::parse_url($link); $this->link = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); } @@ -7683,7 +7683,7 @@ class SimplePie_File { if (class_exists('idna_convert')) { - $idn =& new idna_convert; + $idn = new idna_convert; $parsed = SimplePie_Misc::parse_url($url); $url = SimplePie_Misc::compress_parse_url($parsed['scheme'], $idn->encode($parsed['authority']), $parsed['path'], $parsed['query'], $parsed['fragment']); } @@ -7744,7 +7744,7 @@ class SimplePie_File curl_close($fp); $this->headers = explode("\r\n\r\n", $this->headers, $info['redirect_count'] + 1); $this->headers = array_pop($this->headers); - $parser =& new SimplePie_HTTP_Parser($this->headers); + $parser = new SimplePie_HTTP_Parser($this->headers); if ($parser->parse()) { $this->headers = $parser->headers; @@ -7825,7 +7825,7 @@ class SimplePie_File } if (!$info['timed_out']) { - $parser =& new SimplePie_HTTP_Parser($this->headers); + $parser = new SimplePie_HTTP_Parser($this->headers); if ($parser->parse()) { $this->headers = $parser->headers; @@ -7844,7 +7844,7 @@ class SimplePie_File { case 'gzip': case 'x-gzip': - $decoder =& new SimplePie_gzdecode($this->body); + $decoder = new SimplePie_gzdecode($this->body); if (!$decoder->parse()) { $this->error = 'Unable to decode HTTP "gzip" stream'; @@ -8656,7 +8656,7 @@ class SimplePie_Cache */ function create($location, $filename, $extension) { - $location_iri =& new SimplePie_IRI($location); + $location_iri = new SimplePie_IRI($location); switch ($location_iri->get_scheme()) { case 'mysql': @@ -9370,7 +9370,7 @@ class SimplePie_Misc function parse_url($url) { - $iri =& new SimplePie_IRI($url); + $iri = new SimplePie_IRI($url); return array( 'scheme' => (string) $iri->get_scheme(), 'authority' => (string) $iri->get_authority(), @@ -9382,7 +9382,7 @@ class SimplePie_Misc function compress_parse_url($scheme = '', $authority = '', $path = '', $query = '', $fragment = '') { - $iri =& new SimplePie_IRI(''); + $iri = new SimplePie_IRI(''); $iri->set_scheme($scheme); $iri->set_authority($authority); $iri->set_path($path); @@ -9393,7 +9393,7 @@ class SimplePie_Misc function normalize_url($url) { - $iri =& new SimplePie_IRI($url); + $iri = new SimplePie_IRI($url); return $iri->get_iri(); } @@ -10913,7 +10913,7 @@ class SimplePie_Misc */ function entities_decode($data) { - $decoder =& new SimplePie_Decode_HTML_Entities($data); + $decoder = new SimplePie_Decode_HTML_Entities($data); return $decoder->parse(); } @@ -11309,7 +11309,7 @@ class SimplePie_Misc { if ($pos = strpos($data, "\x00\x00\x00\x3F\x00\x00\x00\x3E")) { - $parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')); + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32BE', 'UTF-8')); if ($parser->parse()) { $encoding[] = $parser->encoding; @@ -11322,7 +11322,7 @@ class SimplePie_Misc { if ($pos = strpos($data, "\x3F\x00\x00\x00\x3E\x00\x00\x00")) { - $parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')); + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 20), 'UTF-32LE', 'UTF-8')); if ($parser->parse()) { $encoding[] = $parser->encoding; @@ -11335,7 +11335,7 @@ class SimplePie_Misc { if ($pos = strpos($data, "\x00\x3F\x00\x3E")) { - $parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')); + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16BE', 'UTF-8')); if ($parser->parse()) { $encoding[] = $parser->encoding; @@ -11348,7 +11348,7 @@ class SimplePie_Misc { if ($pos = strpos($data, "\x3F\x00\x3E\x00")) { - $parser =& new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')); + $parser = new SimplePie_XML_Declaration_Parser(SimplePie_Misc::change_encoding(substr($data, 20, $pos - 10), 'UTF-16LE', 'UTF-8')); if ($parser->parse()) { $encoding[] = $parser->encoding; @@ -11361,7 +11361,7 @@ class SimplePie_Misc { if ($pos = strpos($data, "\x3F\x3E")) { - $parser =& new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); + $parser = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); if ($parser->parse()) { $encoding[] = $parser->encoding; @@ -11736,7 +11736,7 @@ class SimplePie_IRI $relative = (string) $relative; if ($relative !== '') { - $relative =& new SimplePie_IRI($relative); + $relative = new SimplePie_IRI($relative); if ($relative->get_scheme() !== null) { $target = $relative; @@ -11750,7 +11750,7 @@ class SimplePie_IRI } else { - $target =& new SimplePie_IRI(''); + $target = new SimplePie_IRI(''); $target->set_scheme($base->get_scheme()); $target->set_userinfo($base->get_userinfo()); $target->set_host($base->get_host()); @@ -13102,7 +13102,7 @@ class SimplePie_Parse_Date static $object; if (!$object) { - $object =& new SimplePie_Parse_Date; + $object = new SimplePie_Parse_Date; } return $object; } @@ -14137,7 +14137,7 @@ class SimplePie_Locator if ($this->file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) { - $sniffer =& new $this->content_type_sniffer_class($this->file); + $sniffer = new $this->content_type_sniffer_class($this->file); if ($sniffer->get_type() !== 'text/html') { return null; @@ -14183,7 +14183,7 @@ class SimplePie_Locator { if ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE) { - $sniffer =& new $this->content_type_sniffer_class($file); + $sniffer = new $this->content_type_sniffer_class($file); $sniffed = $sniffer->get_type(); if (in_array($sniffed, array('application/rss+xml', 'application/rdf+xml', 'text/rdf', 'application/atom+xml', 'text/xml', 'application/xml'))) { @@ -14247,7 +14247,7 @@ class SimplePie_Locator if (!in_array($href, $done) && in_array('feed', $rel) || (in_array('alternate', $rel) && !empty($link['attribs']['type']['data']) && in_array(strtolower(SimplePie_Misc::parse_mime($link['attribs']['type']['data'])), array('application/rss+xml', 'application/atom+xml'))) && !isset($feeds[$href])) { $this->checked_feeds++; - $feed =& new $this->file_class($href, $this->timeout, 5, null, $this->useragent); + $feed = new $this->file_class($href, $this->timeout, 5, null, $this->useragent); if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { $feeds[$href] = $feed; @@ -14319,7 +14319,7 @@ class SimplePie_Locator if (in_array(strtolower(strrchr($value, '.')), array('.rss', '.rdf', '.atom', '.xml'))) { $this->checked_feeds++; - $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent); + $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { return $feed; @@ -14344,7 +14344,7 @@ class SimplePie_Locator if (preg_match('/(rss|rdf|atom|xml)/i', $value)) { $this->checked_feeds++; - $feed =& new $this->file_class($value, $this->timeout, 5, null, $this->useragent); + $feed = new $this->file_class($value, $this->timeout, 5, null, $this->useragent); if ($feed->success && ($feed->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($feed->status_code === 200 || $feed->status_code > 206 && $feed->status_code < 300)) && $this->is_feed($feed)) { return $feed; @@ -14418,7 +14418,7 @@ class SimplePie_Parser if (substr($data, 0, 5) === '')) !== false) { - $declaration =& new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); + $declaration = new SimplePie_XML_Declaration_Parser(substr($data, 5, $pos - 5)); if ($declaration->parse()) { $data = substr($data, $pos + 2); @@ -14468,7 +14468,7 @@ class SimplePie_Parser else { libxml_clear_errors(); - $xml =& new XMLReader(); + $xml = new XMLReader(); $xml->xml($data); while (@$xml->read()) { @@ -14954,7 +14954,7 @@ class SimplePie_Sanitize } else { - $file =& new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); + $file = new $this->file_class($img['attribs']['src']['data'], $this->timeout, 5, array('X-FORWARDED-FOR' => $_SERVER['REMOTE_ADDR']), $this->useragent, $this->force_fsockopen); $headers = $file->headers; if ($file->success && ($file->method & SIMPLEPIE_FILE_SOURCE_REMOTE === 0 || ($file->status_code === 200 || $file->status_code > 206 && $file->status_code < 300))) diff --git a/update.sql b/update.sql index 64f338c51f..b3196a1dee 100644 --- a/update.sql +++ b/update.sql @@ -7,4 +7,8 @@ alter table `item` insert `remote-id` char( 255 ) character set utf-8 collate ut ALTER TABLE `item` ADD `remote-name` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `remote-id` , ADD `remote-link` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `remote-name` , -ADD `remote-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `remote-link` ; \ No newline at end of file +ADD `remote-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `remote-link` ; + +ALTER TABLE `item` ADD `owner-name` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `contact-id` , +ADD `owner-link` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-name` , +ADD `owner-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-link` ; diff --git a/view/atom_item.tpl b/view/atom_item.tpl index db2d7dfb5f..16581fc897 100644 --- a/view/atom_item.tpl +++ b/view/atom_item.tpl @@ -4,6 +4,11 @@ $profile_page $thumb + + $owner_name + $owner_profile_page + $owner_thumb + $item_id $title -- 2.39.2 From 5e4df4b3f7782f8a82664d24b86d46a14b3d178b Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Fri, 16 Jul 2010 17:16:50 -0700 Subject: [PATCH 02/16] added network page --- boot.php | 1 + include/auth.php | 1 + include/nav.php | 2 + include/notifier.php | 6 +- mod/item.php | 13 ++-- mod/network.php | 138 +++++++++++++++++++++++++++++++++++++++++ mod/profile.php | 15 ++++- view/style.css | 5 ++ view/wallwall_item.tpl | 23 +++++++ 9 files changed, 194 insertions(+), 10 deletions(-) create mode 100644 mod/network.php create mode 100644 view/wallwall_item.tpl diff --git a/boot.php b/boot.php index c94548c3f3..754be48126 100644 --- a/boot.php +++ b/boot.php @@ -22,6 +22,7 @@ class App { public $profile; public $user; public $cid; + public $contact; public $content; public $error = false; public $cmd; diff --git a/include/auth.php b/include/auth.php index 387cab0afd..ef5c6f0b44 100644 --- a/include/auth.php +++ b/include/auth.php @@ -26,6 +26,7 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) { $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); if(count($r)) { + $a->contact = $r[0]; $a->cid = $r[0]['id']; $_SESSION['cid'] = $a->cid; } diff --git a/include/nav.php b/include/nav.php index d24abd4ac5..a7a2cf3f88 100644 --- a/include/nav.php +++ b/include/nav.php @@ -23,6 +23,8 @@ $a->page['nav'] .= "Contacts\r\n"; $a->page['nav'] .= "Home\r\n"; + + $a->page['nav'] .= "Network\r\n"; } diff --git a/include/notifier.php b/include/notifier.php index f7c0570d80..cf1076aad8 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -151,9 +151,9 @@ if($argc < 3) '$name' => xmlify($contact['name']), '$profile_page' => xmlify($contact['url']), '$thumb' => xmlify($contact['thumb']), - '$owner_name' => xmlify($owner['name']), - '$owner_profile_page' => xmlify($owner['url']), - '$owner_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("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), '$title' => xmlify($contact['name']), '$published' => xmlify(datetime_convert('UTC', 'UTC', $item['created'] . '+00:00' , 'Y-m-d\TH:i:s\Z')), diff --git a/mod/item.php b/mod/item.php index c7b5b48858..3340183b0b 100644 --- a/mod/item.php +++ b/mod/item.php @@ -73,10 +73,12 @@ function item_post(&$a) { if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id']))) $contact_id = $_SESSION['visitor_id']; else { - $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); - if(count($r)) + if(count($r)) { + $contact_record = $r[0]; $contact_id = $r[0]['id']; + } } $notify_type = (($parent) ? 'comment-new' : 'wall-new' ); @@ -93,12 +95,15 @@ function item_post(&$a) { } while($dups == true); - $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`created`,`edited`,`hash`,`body`, + $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,`edited`,`hash`,`body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) - VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($profile_uid), "jot", intval($contact_id), + dbesc($contact_record['name']), + dbesc($contact_record['url']), + dbesc($contact_record['thumb']), datetime_convert(), datetime_convert(), dbesc($hash), diff --git a/mod/network.php b/mod/network.php new file mode 100644 index 0000000000..0dc743533d --- /dev/null +++ b/mod/network.php @@ -0,0 +1,138 @@ +cid; + + + $tpl = file_get_contents('view/jot-header.tpl'); + + $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl())); + require_once('view/acl_selectors.php'); + + $tpl = file_get_contents("view/jot.tpl"); + + $o .= replace_macros($tpl,array( + '$baseurl' => $a->get_baseurl(), + '$visitor' => 'block', + '$lockstate' => 'unlock', + '$acl' => populate_acl(), + '$profile_uid' => $_SESSION['uid'] + )); + + + // TODO + // Alter registration and settings + // and profile to update contact table when names and photos change. + // work on item_display and can_write_wall + + // Add comments. + + + $sql_extra = ''; + + + $r = q("SELECT COUNT(*) AS `total` + FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 + AND `contact`.`blocked` = 0 + $sql_extra ", + intval($_SESSION['uid']) + + ); + + if(count($r)) + $a->set_pager_total($r[0]['total']); +dbg(2); + + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, + `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, + `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` + FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 + AND `contact`.`blocked` = 0 + $sql_extra + ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", + intval($_SESSION['uid']), + intval($a->pager['start']), + intval($a->pager['itemspage']) + + ); + + + $cmnt_tpl = file_get_contents('view/comment_item.tpl'); + + + $tpl = file_get_contents('view/wall_item.tpl'); + $wallwall = file_get_contents('view/wallwall_item.tpl'); + + if(count($r)) { + foreach($r as $rr) { + $comment = ''; + + if($rr['last-child']) { + $comment = replace_macros($cmnt_tpl,array( + '$id' => $rr['item_id'], + '$parent' => $rr['parent'], + '$profile_uid' => $_SESSION['uid'] + )); + } + + $item = $rr; + $template = $tpl; + + $profile_url = $item['url']; + + if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] )) + $profile_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + + $photo = $item['photo']; + $thumb = $item['thumb']; + + $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); + $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url); + $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb); + + if(($item['parent'] == $item['item_id']) && (! $item['self'])) { + $template = $wallwall; // FIXME also if remote owner + $owner_url = $a->contact['url']; + $owner_photo = $a->contact['thumb']; + $owner_name = $a->contact['name']; + } + + $o .= replace_macros($template,array( + '$id' => $item['item_id'], + '$profile_url' => $profile_link, + '$name' => $profile_name, + '$thumb' => $profile_avatar, + '$body' => bbcode($item['body']), + '$ago' => relative_date($item['created']), + '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), + '$owner_url' => $owner_url, + '$owner_photo' => $owner_photo, + '$owner_name' => $owner_name, + '$comment' => $comment + )); + + } + } + + $o .= paginate($a); + + return $o; + + +} \ No newline at end of file diff --git a/mod/profile.php b/mod/profile.php index 6bd265562d..76ebe7d844 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -79,12 +79,21 @@ function item_display(&$a, $item,$template,$comment) { $photo = (($item['self']) ? $a->profile['photo'] : $item['photo']); $thumb = (($item['self']) ? $a->profile['thumb'] : $item['thumb']); + + $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); + $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url); + $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb); + +// if(! $item['owner-link']) { +// $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1". + + $o .= replace_macros($template,array( '$id' => $item['item_id'], - '$profile_url' => ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url), - '$name' => ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']), - '$thumb' => ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb), + '$profile_url' => $profile_link, + '$name' => $profile_name, + '$thumb' => $profile_avatar, '$body' => bbcode($item['body']), '$ago' => relative_date($item['created']), '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), diff --git a/view/style.css b/view/style.css index f8582d97bf..574e99e837 100644 --- a/view/style.css +++ b/view/style.css @@ -425,6 +425,11 @@ input#dfrn-url { width: 100px; float: left; } +.wall-item-arrowphoto-wrapper { + margin-top: 40px; + margin-right: 20px; + float: left; +} .wall-item-wrapper { margin-top: 30px; float: left; diff --git a/view/wallwall_item.tpl b/view/wallwall_item.tpl new file mode 100644 index 0000000000..ac3a4e34fa --- /dev/null +++ b/view/wallwall_item.tpl @@ -0,0 +1,23 @@ + + +
+ -- 2.39.2 From f937de932d87737d14278003f80b5bc5025acdc6 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Fri, 16 Jul 2010 23:14:37 -0700 Subject: [PATCH 03/16] fixing stuff that broke with the last big code push --- mod/dfrn_notify.php | 17 +++--- mod/item.php | 35 ++++++------ mod/network.php | 44 +++++++++------ mod/profile.php | 120 +++++++++++++++++++++++++---------------- view/comment_item.tpl | 4 +- view/jot.tpl | 3 +- view/style.css | 10 ++++ view/wallwall_item.tpl | 2 +- 8 files changed, 145 insertions(+), 90 deletions(-) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 6ab8d584a0..c5c05134ae 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -32,13 +32,13 @@ function get_atom_elements($item) { if($rawedited) $res['edited'] = $rawcreated[0]['data']; - $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0", 'owner'); + $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0', 'owner'); if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']) - $res['owner-name'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']; + $res['owner-name'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']; if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']) - $res['owner-link'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']; + $res['owner-link'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']; if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']) - $res['owner-avatar'] = rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']; + $res['owner-avatar'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']; return $res; @@ -55,10 +55,11 @@ function post_remote($arr) { $arr['owner-name'] = notags(trim($arr['owner-name'])); $arr['owner-link'] = notags(trim($arr['owner-link'])); $arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); - if(! strlen($arr['remote-avatar'])) - $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - if(! strlen($arr['owner-avatar'])) - $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; +// must pass $a +// if(! strlen($arr['remote-avatar'])) +// $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; +// if(! strlen($arr['owner-avatar'])) +// $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); $arr['title'] = notags(trim($arr['title'])); diff --git a/mod/item.php b/mod/item.php index 3340183b0b..437e6ac596 100644 --- a/mod/item.php +++ b/mod/item.php @@ -22,7 +22,7 @@ function item_post(&$a) { ); if(! count($r)) { notice("Unable to locate original post." . EOL); - goaway($a->get_baseurl() . "/profile/$profile_uid"); + goaway($a->get_baseurl() . "/" . $_POST['return'] ); } $parent_item = $r[0]; } @@ -67,23 +67,32 @@ function item_post(&$a) { if(! strlen($body)) { notice("Empty post discarded." . EOL ); - goaway($a->get_baseurl() . "/profile/$profile_uid"); + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + } + // get contact info for poster if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id']))) $contact_id = $_SESSION['visitor_id']; else { $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); - if(count($r)) { - $contact_record = $r[0]; + if(count($r)) $contact_id = $r[0]['id']; - } - } + } + + // get contact info for owner + + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", + intval($profile_uid) + ); + if(count($r)) + $contact_record = $r[0]; + $notify_type = (($parent) ? 'comment-new' : 'wall-new' ); - if($_POST['type'] == 'jot') { + if(($_POST['type'] == 'wall') || ($_POST['type'] == 'wall-comment')) { do { $dups = false; @@ -99,7 +108,7 @@ function item_post(&$a) { `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($profile_uid), - "jot", + dbesc($_POST['type']), intval($contact_id), dbesc($contact_record['name']), dbesc($contact_record['url']), @@ -154,12 +163,6 @@ function item_post(&$a) { array(),$foo)); } - goaway($a->get_baseurl() . "/profile/$profile_uid"); - - - - - - - + goaway($a->get_baseurl() . "/" . $_POST['return'] ); + return; // NOTREACHED } \ No newline at end of file diff --git a/mod/network.php b/mod/network.php index 0dc743533d..7fb12bd39f 100644 --- a/mod/network.php +++ b/mod/network.php @@ -25,6 +25,7 @@ function network_content(&$a) { $tpl = file_get_contents("view/jot.tpl"); $o .= replace_macros($tpl,array( + '$return_path' => $a->cmd, '$baseurl' => $a->get_baseurl(), '$visitor' => 'block', '$lockstate' => 'unlock', @@ -38,8 +39,6 @@ function network_content(&$a) { // and profile to update contact table when names and photos change. // work on item_display and can_write_wall - // Add comments. - $sql_extra = ''; @@ -80,19 +79,38 @@ dbg(2); $wallwall = file_get_contents('view/wallwall_item.tpl'); if(count($r)) { - foreach($r as $rr) { + foreach($r as $item) { + $comment = ''; + $template = $tpl; + $commentww = ''; + + if(($item['parent'] == $item['item_id']) && (! $item['self'])) { + if($item['type'] == 'wall') { + $owner_url = $a->contact['url']; + $owner_photo = $a->contact['thumb']; + $owner_name = $a->contact['name']; + $template = $wallwall; + $commentww = 'ww'; + } + if($item['type'] == 'remote' && ($item['owner-link'] != $item['remote-link'])) { + $owner_url = $item['owner-link']; + $owner_photo = $item['owner-avatar']; + $owner_name = $item['owner-name']; + $template = $wallwall; + $commentww = 'ww'; + } + } - if($rr['last-child']) { + if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( - '$id' => $rr['item_id'], - '$parent' => $rr['parent'], - '$profile_uid' => $_SESSION['uid'] + '$id' => $item['item_id'], + '$parent' => $item['parent'], + '$profile_uid' => $_SESSION['uid'], + '$ww' => $commentww )); } - $item = $rr; - $template = $tpl; $profile_url = $item['url']; @@ -101,17 +119,11 @@ dbg(2); $photo = $item['photo']; $thumb = $item['thumb']; - + $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url); $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb); - if(($item['parent'] == $item['item_id']) && (! $item['self'])) { - $template = $wallwall; // FIXME also if remote owner - $owner_url = $a->contact['url']; - $owner_photo = $a->contact['thumb']; - $owner_name = $a->contact['name']; - } $o .= replace_macros($template,array( '$id' => $item['item_id'], diff --git a/mod/profile.php b/mod/profile.php index 76ebe7d844..f3ec57329c 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -51,7 +51,7 @@ function profile_init(&$a) { return; } - if(($remote_user) && ($a->argc > 2) && ($a->argv[2] == 'visit')) + if((remote_user()) && ($a->argc > 2) && ($a->argv[2] == 'visit')) $_SESSION['is_visitor'] = 1; else { unset($_SESSION['is_visitor']); @@ -69,41 +69,6 @@ function profile_init(&$a) { } -function item_display(&$a, $item,$template,$comment) { - - - $profile_url = $item['url']; - - if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] )) - $profile_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; - - $photo = (($item['self']) ? $a->profile['photo'] : $item['photo']); - $thumb = (($item['self']) ? $a->profile['thumb'] : $item['thumb']); - - $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); - $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url); - $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb); - -// if(! $item['owner-link']) { -// $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1". - - - - $o .= replace_macros($template,array( - '$id' => $item['item_id'], - '$profile_url' => $profile_link, - '$name' => $profile_name, - '$thumb' => $profile_avatar, - '$body' => bbcode($item['body']), - '$ago' => relative_date($item['created']), - '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), - '$comment' => $comment - )); - - - return $o; -} - function profile_content(&$a) { @@ -153,6 +118,7 @@ function profile_content(&$a) { $o .= replace_macros($tpl,array( '$baseurl' => $a->get_baseurl(), + '$return_path' => $a->cmd, '$visitor' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? 'block' : 'none'), '$lockstate' => 'unlock', '$acl' => (($_SESSION['uid'] == $a->profile['profile_uid']) ? populate_acl() : ''), @@ -216,7 +182,7 @@ dbg(2); `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `contact`.`blocked` = 0 + AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 $sql_extra ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", intval($a->profile['uid']), @@ -226,23 +192,85 @@ dbg(2); ); - $template = file_get_contents('view/comment_item.tpl'); - + $cmnt_tpl = file_get_contents('view/comment_item.tpl'); $tpl = file_get_contents('view/wall_item.tpl'); + $wallwall = file_get_contents('view/wallwall_item.tpl'); + + if(count($r)) { - foreach($r as $rr) { + foreach($r as $item) { $comment = ''; + $template = $tpl; + $commentww = ''; + if(($item['parent'] == $item['item_id']) && (! $item['self'])) { + if($item['type'] == 'wall') { + $owner_url = $a->contact['url']; + $owner_photo = $a->contact['thumb']; + $owner_name = $a->contact['name']; + $template = $wallwall; + $commentww = 'ww'; + } + if($item['type'] == 'remote' && ($item['owner-link'] != $item['remote-link'])) { + $owner_url = $item['owner-link']; + $owner_photo = $item['owner-avatar']; + $owner_name = $item['owner-name']; + $template = $wallwall; + $commentww = 'ww'; + } + } + + + if(can_write_wall($a,$a->profile['profile_uid'])) { - if($rr['last-child']) { - $comment = replace_macros($template,array( - '$id' => $rr['item_id'], - '$parent' => $rr['parent'], - '$profile_uid' => $a->profile['profile_uid'] + if($item['last-child']) { + $comment = replace_macros($cmnt_tpl,array( + '$id' => $item['item_id'], + '$parent' => $item['parent'], + '$profile_uid' => $a->profile['profile_uid'], + '$ww' => $commentww )); } } - $o .= item_display($a,$rr,$tpl,$comment); + + + $profile_url = $item['url']; + + if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] )) + $profile_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + + // $photo = (($item['self']) ? $a->profile['photo'] : $item['photo']); + // $thumb = (($item['self']) ? $a->profile['thumb'] : $item['thumb']); + + $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); + $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url); + $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $item['thumb']); + + + + $o .= replace_macros($template,array( + '$id' => $item['item_id'], + '$profile_url' => $profile_link, + '$name' => $profile_name, + '$thumb' => $profile_avatar, + '$body' => bbcode($item['body']), + '$ago' => relative_date($item['created']), + '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), + '$owner_url' => $owner_url, + '$owner_photo' => $owner_photo, + '$owner_name' => $owner_name, + '$comment' => $comment + )); + + + + + + + + + + } } diff --git a/view/comment_item.tpl b/view/comment_item.tpl index d6dcd8e4a0..530244e8ee 100644 --- a/view/comment_item.tpl +++ b/view/comment_item.tpl @@ -1,8 +1,8 @@ -
+
-$name to $owner_name via Wall-To-Wall:
+
$name to $owner_name via Wall-To-Wall:
$body
$ago
-- 2.39.2 From 2a17c20fb8e910aeb814ab999cf9131478dd2b03 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sat, 17 Jul 2010 07:03:06 -0700 Subject: [PATCH 04/16] remote comments - though still needs a bit more work --- include/notifier.php | 23 ++-------- mod/dfrn_notify.php | 62 ++++++++++++++++++-------- mod/network.php | 52 +++++++++++++--------- mod/profile.php | 102 ++++++++++++++----------------------------- 4 files changed, 112 insertions(+), 127 deletions(-) diff --git a/include/notifier.php b/include/notifier.php index cf1076aad8..37a1e0d308 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -170,7 +170,6 @@ if($argc < 3) '$item_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), '$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']), '$parent_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$items[0]['hash']}"), @@ -184,18 +183,10 @@ if($argc < 3) } $atom .= "\r\n"; - // create a separate feed with comments disabled and send to those who can't respond. + // create a clone of this feed but with comments disabled to send to those who can't respond. $atom_nowrite = str_replace('1','0',$atom); -print_r($atom); - - -dbg(3); - - - -print_r($recipients); if($followup) $recip_str = $parent['contact-id']; @@ -217,17 +208,13 @@ print_r($recipients); if(! strlen($rr['dfrn-id'])) continue; $url = $rr['notify'] . '?dfrn_id=' . $rr['dfrn-id']; -print_r($url); + $xml = fetch_url($url); -echo $xml; -print_r($xml); if(! $xml) continue; $res = simplexml_load_string($xml); -print_r($res); -var_dump($res); if((intval($res->status) != 0) || (! strlen($res->challenge)) || ($res->dfrn_id != $rr['dfrn-id'])) continue; @@ -236,9 +223,6 @@ var_dump($res); $postvars['dfrn_id'] = $rr['dfrn-id']; $challenge = hex2bin($res->challenge); -echo "dfrn-id:" . $res->dfrn_id . "\r\n"; -echo "challenge:" . $res->challenge . "\r\n"; -echo "pubkey:" . $rr['pubkey'] . "\r\n"; openssl_public_decrypt($challenge,$postvars['challenge'],$rr['pubkey']); @@ -247,10 +231,9 @@ echo "pubkey:" . $rr['pubkey'] . "\r\n"; else $postvars['data'] = $atom_nowrite; -print_r($postvars); + $xml = post_url($url,$postvars); -print_r($xml); } killme(); diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index c5c05134ae..0f5f5eb6c3 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -45,7 +45,7 @@ function get_atom_elements($item) { } -function post_remote($arr) { +function post_remote($a,$arr) { $arr['hash'] = random_string(); $arr['type'] = 'remote'; @@ -55,11 +55,10 @@ function post_remote($arr) { $arr['owner-name'] = notags(trim($arr['owner-name'])); $arr['owner-link'] = notags(trim($arr['owner-link'])); $arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); -// must pass $a -// if(! strlen($arr['remote-avatar'])) -// $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; -// if(! strlen($arr['owner-avatar'])) -// $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; + if(! strlen($arr['remote-avatar'])) + $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; + if(! strlen($arr['owner-avatar'])) + $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); $arr['title'] = notags(trim($arr['title'])); @@ -68,9 +67,17 @@ function post_remote($arr) { $arr['visible'] = 1; $arr['deleted'] = 0; - $parent = $arr['parent_urn']; + $local_parent = false; - unset($arr['parent_urn']); + if(isset($arr['parent_hash'])) { + $local_parent = true; + $parent = $arr['parent_hash']; + unset($arr['parent_hash']); + } + else { + $parent = $arr['parent_urn']; + unset($arr['parent_urn']); + } $parent_id = 0; @@ -82,11 +89,18 @@ function post_remote($arr) { . implode("', '", array_values($arr)) . "')" ); - - $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", - dbesc($parent), - intval($arr['uid']) - ); + if($local_parent) { + $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1", + dbesc($parent), + intval($arr['uid']) + ); + } + else { + $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + dbesc($parent), + intval($arr['uid']) + ); + } if(count($r)) $parent_id = $r[0]['id']; @@ -103,10 +117,11 @@ function post_remote($arr) { intval($current_post) ); + return $current_post; } function dfrn_notify_post(&$a) { -dbg(3); + $dfrn_id = notags(trim($_POST['dfrn_id'])); $challenge = notags(trim($_POST['challenge'])); $data = $_POST['data']; @@ -160,8 +175,21 @@ dbg(3); if($is_reply) { - if($x == ($total_items - 1)) { + if($feed->get_item_quantity() == 1) { // remote reply to our post. Import and then notify everybody else. + $datarray = get_atom_elements($item); + $urn = explode(':',$parent_urn); + $datarray['parent_hash'] = $urn[4]; + $datarray['uid'] = $importer['uid']; + $datarray['contact-id'] = $importer['id']; + $r = post_remote($a,$datarray); + + $url = bin2hex($a->get_baseurl()); + + proc_close(proc_open("php include/notifier.php $url $notify_type $r > notify.log &", array(),$foo)); + + return; + } else { // regular comment that is part of this total conversation. Have we seen it? If not, import it. @@ -186,7 +214,7 @@ dbg(3); $datarray['parent_urn'] = $parent_urn; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; - $r = post_remote($datarray); + $r = post_remote($a,$datarray); continue; } } @@ -214,7 +242,7 @@ dbg(3); $datarray['parent_urn'] = $item_id; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; - $r = post_remote($datarray); + $r = post_remote($a,$datarray); continue; } diff --git a/mod/network.php b/mod/network.php index 7fb12bd39f..2685959a3e 100644 --- a/mod/network.php +++ b/mod/network.php @@ -13,13 +13,13 @@ function network_content(&$a) { require_once("include/bbcode.php"); - $contact_id = $a->cid; $tpl = file_get_contents('view/jot-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, array('$baseurl' => $a->get_baseurl())); + require_once('view/acl_selectors.php'); $tpl = file_get_contents("view/jot.tpl"); @@ -34,12 +34,6 @@ function network_content(&$a) { )); - // TODO - // Alter registration and settings - // and profile to update contact table when names and photos change. - // work on item_display and can_write_wall - - $sql_extra = ''; @@ -49,12 +43,10 @@ function network_content(&$a) { AND `contact`.`blocked` = 0 $sql_extra ", intval($_SESSION['uid']) - ); if(count($r)) $a->set_pager_total($r[0]['total']); -dbg(2); $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, @@ -68,13 +60,11 @@ dbg(2); intval($_SESSION['uid']), intval($a->pager['start']), intval($a->pager['itemspage']) - ); $cmnt_tpl = file_get_contents('view/comment_item.tpl'); - $tpl = file_get_contents('view/wall_item.tpl'); $wallwall = file_get_contents('view/wallwall_item.tpl'); @@ -85,8 +75,17 @@ dbg(2); $template = $tpl; $commentww = ''; + $profile_url = $item['url']; + $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + + + // Top-level wall post not written by the wall owner (wall-to-wall) + // First figure out who owns it. + if(($item['parent'] == $item['item_id']) && (! $item['self'])) { + if($item['type'] == 'wall') { + // I do. Put me on the left of the wall-to-wall notice. $owner_url = $a->contact['url']; $owner_photo = $a->contact['thumb']; $owner_name = $a->contact['name']; @@ -94,11 +93,16 @@ dbg(2); $commentww = 'ww'; } if($item['type'] == 'remote' && ($item['owner-link'] != $item['remote-link'])) { + // Could be anybody. $owner_url = $item['owner-link']; $owner_photo = $item['owner-avatar']; $owner_name = $item['owner-name']; $template = $wallwall; - $commentww = 'ww'; + $commentww = 'ww'; + // If it is our contact, use a friendly redirect link + if($item['owner-link'] == $item['url']) + $owner_url = $redirect_url; + } } @@ -112,18 +116,29 @@ dbg(2); } - $profile_url = $item['url']; - if(($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] )) - $profile_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + $profile_url = $redirect_url; $photo = $item['photo']; $thumb = $item['thumb']; + // Post was remotely authored. + $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); - $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url); $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb); + $profile_link = $profile_url; + + // Can we use our special contact URL for this author? + + if(strlen($item['remote-link'])) { + if($item['remote-link'] == $item['url']) + $profile_link = $redirect_url; + else + $profile_link = $item['remote-link']; + } + + // Build the HTML $o .= replace_macros($template,array( '$id' => $item['item_id'], @@ -138,13 +153,8 @@ dbg(2); '$owner_name' => $owner_name, '$comment' => $comment )); - } } - $o .= paginate($a); - return $o; - - } \ No newline at end of file diff --git a/mod/profile.php b/mod/profile.php index f3ec57329c..7b54340a91 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -27,7 +27,7 @@ function profile_load(&$a,$uid,$profile = 0) { ); if(($r === false) || (! count($r))) { - $_SESSION['sysmsg'] .= "No profile" . EOL ; + notice("No profile" . EOL ); $a->error = 404; return; } @@ -46,7 +46,7 @@ function profile_init(&$a) { if($a->argc > 1) $which = $a->argv[1]; else { - $_SESSION['sysmsg'] .= "No profile" . EOL ; + notice("No profile" . EOL ); $a->error = 404; return; } @@ -75,7 +75,6 @@ function profile_content(&$a) { require_once("include/bbcode.php"); require_once('include/security.php'); - $a->page['htmlhead'] .= ''; $groups = array(); $tab = 'posts'; @@ -95,19 +94,14 @@ function profile_content(&$a) { $groups = init_groups_visitor($contact_id); } if(local_user()) { - $r = q("SELECT `id` FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", - $_SESSION['uid'] - ); - if(count($r)) - $contact_id = $r[0]['id']; + $contact_id = $_SESSION['cid']; } if($tab == 'profile') { - require_once('view/profile_advanced.php'); - return $o; } + if(can_write_wall($a,$a->profile['profile_uid'])) { $tpl = file_get_contents('view/jot-header.tpl'); @@ -127,14 +121,9 @@ function profile_content(&$a) { } - // TODO - // Alter registration and settings - // and profile to update contact table when names and photos change. - // work on item_display and can_write_wall - - // Add comments. + // TODO alter registration and settings and profile to update contact table when names and photos change. - // default - anonymous user + // default permissions - anonymous user $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' "; @@ -166,7 +155,7 @@ function profile_content(&$a) { $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `contact`.`blocked` = 0 + AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 $sql_extra ", intval($a->profile['uid']) @@ -174,7 +163,7 @@ function profile_content(&$a) { if(count($r)) $a->set_pager_total($r[0]['total']); -dbg(2); + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, `contact`.`name`, `contact`.`photo`, `contact`.`url`, @@ -195,40 +184,22 @@ dbg(2); $cmnt_tpl = file_get_contents('view/comment_item.tpl'); $tpl = file_get_contents('view/wall_item.tpl'); - $wallwall = file_get_contents('view/wallwall_item.tpl'); if(count($r)) { foreach($r as $item) { $comment = ''; $template = $tpl; - $commentww = ''; - if(($item['parent'] == $item['item_id']) && (! $item['self'])) { - if($item['type'] == 'wall') { - $owner_url = $a->contact['url']; - $owner_photo = $a->contact['thumb']; - $owner_name = $a->contact['name']; - $template = $wallwall; - $commentww = 'ww'; - } - if($item['type'] == 'remote' && ($item['owner-link'] != $item['remote-link'])) { - $owner_url = $item['owner-link']; - $owner_photo = $item['owner-avatar']; - $owner_name = $item['owner-name']; - $template = $wallwall; - $commentww = 'ww'; - } - } - - - + + $redirect_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + if(can_write_wall($a,$a->profile['profile_uid'])) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $a->profile['profile_uid'], - '$ww' => $commentww + '$ww' => '' )); } } @@ -236,47 +207,40 @@ dbg(2); $profile_url = $item['url']; + // This is my profile but I'm not the author of this post/comment. If it's somebody that's a fan or mutual friend, + // I can go directly to their profile as an authenticated guest. + if(local_user() && ($item['contact-uid'] == $_SESSION['uid']) && (strlen($item['dfrn-id'])) && (! $item['self'] )) - $profile_url = $a->get_baseurl() . '/redir/' . $item['cid'] ; + $profile_url = $redirect_url; + + // FIXME tryng to solve the mishmash of profile photos. // $photo = (($item['self']) ? $a->profile['photo'] : $item['photo']); // $thumb = (($item['self']) ? $a->profile['thumb'] : $item['thumb']); + + // We received this post via a remote feed. It's either a wall-to-wall or a remote comment. The author is + // known to us and is reflected in the contact-id for this item. We can use the contact url or redirect rather than + // use the link in the feed. This is different than on the network page where we may not know the author. + $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); - $profile_link = ((strlen($item['remote-link'])) ? $item['remote-link'] : $profile_url); $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $item['thumb']); - - + $profile_link = $profile_url; $o .= replace_macros($template,array( - '$id' => $item['item_id'], - '$profile_url' => $profile_link, - '$name' => $profile_name, - '$thumb' => $profile_avatar, - '$body' => bbcode($item['body']), - '$ago' => relative_date($item['created']), - '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), - '$owner_url' => $owner_url, - '$owner_photo' => $owner_photo, - '$owner_name' => $owner_name, - '$comment' => $comment - )); - - - - - - - - - - + '$id' => $item['item_id'], + '$profile_url' => $profile_link, + '$name' => $profile_name, + '$thumb' => $profile_avatar, + '$body' => bbcode($item['body']), + '$ago' => relative_date($item['created']), + '$indent' => (($item['parent'] != $item['item_id']) ? 'comment-' : ''), + '$comment' => $comment + )); } } $o .= paginate($a); return $o; - - } \ No newline at end of file -- 2.39.2 From aff4f63ff8e005bb3ce1d726405fd6d5d2dcfa60 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sat, 17 Jul 2010 19:26:00 -0700 Subject: [PATCH 05/16] remote comments working now --- boot.php | 5 ++++ include/notifier.php | 45 +++++++++++++++++------------- mod/dfrn_notify.php | 65 ++++++++++++++++++++++++++++--------------- mod/item.php | 11 +++++--- mod/network.php | 1 + mod/profile.php | 1 + update.sql | 2 ++ view/comment_item.tpl | 1 + 8 files changed, 86 insertions(+), 45 deletions(-) diff --git a/boot.php b/boot.php index 754be48126..02c37a93f1 100644 --- a/boot.php +++ b/boot.php @@ -370,6 +370,11 @@ function xmlify($str) { return($buffer); }} +function unxmlify($s) { + $ret = str_replace('&','&', $s); + $ret = str_replace(array('<','>','"','''),array('<','>','"',"'"),$ret); + return $ret; +} function hex2bin($s) { return(pack("H*",$s)); diff --git a/include/notifier.php b/include/notifier.php index 37a1e0d308..6d6146a2a0 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -1,5 +1,6 @@ xmlify($contact['name']), - '$profile_page' => xmlify($contact['url']), - '$thumb' => xmlify($contact['thumb']), - '$item_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), - '$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']), - '$parent_id' => xmlify("{$items[0]['remote-id']}"), - '$comment_allow' => 0 - )); + 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("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), + '$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']), + '$parent_id' => xmlify("{$items[0]['remote-id']}"), + '$comment_allow' => 0 + )); + } + } } else { foreach($items as $item) { @@ -154,7 +156,7 @@ if($argc < 3) '$owner_name' => xmlify($item['owner-name']), '$owner_profile_page' => xmlify($item['owner-link']), '$owner_thumb' => xmlify($item['owner-avatar']), - '$item_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), + '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), '$title' => xmlify($contact['name']), '$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')), @@ -167,7 +169,7 @@ if($argc < 3) '$name' => xmlify($contact['name']), '$profile_page' => xmlify($contact['url']), '$thumb' => xmlify($contact['thumb']), - '$item_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), + '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), '$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')), @@ -193,6 +195,7 @@ if($argc < 3) else $recip_str = implode(', ', $recipients); + $r = q("SELECT * FROM `contact` WHERE `id` IN ( %s ) ", dbesc($recip_str) ); @@ -202,6 +205,8 @@ if($argc < 3) // delivery loop foreach($r as $rr) { + +echo "In delivery loop:"; if($rr['self']) continue; @@ -230,9 +235,11 @@ if($argc < 3) $postvars['data'] = $atom; else $postvars['data'] = $atom_nowrite; - +echo "URL:" . $url; +echo "POSTVARS:" . print_r($postvars); $xml = post_url($url,$postvars); +echo "XML response:" . $xml; } diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 0f5f5eb6c3..f81eb9cfb7 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -8,12 +8,12 @@ function get_atom_elements($item) { $res = array(); $author = $item->get_author(); - $res['remote-name'] = $author->get_name(); - $res['remote-link'] = $author->get_link(); - $res['remote-avatar'] = $author->get_avatar(); - $res['remote-id'] = $item->get_id(); - $res['title'] = $item->get_title(); - $res['body'] = $item->get_content(); + $res['remote-name'] = unxmlify($author->get_name()); + $res['remote-link'] = unxmlify($author->get_link()); + $res['remote-avatar'] = unxmlify($author->get_avatar()); + $res['remote-id'] = unxmlify($item->get_id()); + $res['title'] = unxmlify($item->get_title()); + $res['body'] = unxmlify($item->get_content()); if(strlen($res['body']) > 100000) $res['body'] = substr($res['body'],0,10000) . "\r\n[Extremely large post truncated.]\r\n" ; @@ -26,19 +26,19 @@ function get_atom_elements($item) { $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published'); if($rawcreated) - $res['created'] = $rawcreated[0]['data']; + $res['created'] = unxmlify($rawcreated[0]['data']); $rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated'); if($rawedited) - $res['edited'] = $rawcreated[0]['data']; + $res['edited'] = unxmlify($rawcreated[0]['data']); $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0', 'owner'); if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']) - $res['owner-name'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']; + $res['owner-name'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']); if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']) - $res['owner-link'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']; + $res['owner-link'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']); if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']) - $res['owner-avatar'] = $rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']; + $res['owner-avatar'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']); return $res; @@ -48,7 +48,8 @@ function get_atom_elements($item) { function post_remote($a,$arr) { $arr['hash'] = random_string(); - $arr['type'] = 'remote'; + if(! x($arr,'type')) + $arr['type'] = 'remote'; $arr['remote-name'] = notags(trim($arr['remote-name'])); $arr['remote-link'] = notags(trim($arr['remote-link'])); $arr['remote-avatar'] = notags(trim($arr['remote-avatar'])); @@ -82,7 +83,7 @@ function post_remote($a,$arr) { $parent_id = 0; dbesc_array($arr); - +dbg(3); $r = q("INSERT INTO `item` (`" . implode("`, `", array_keys($arr)) . "`) VALUES ('" @@ -121,7 +122,7 @@ function post_remote($a,$arr) { } function dfrn_notify_post(&$a) { - +dbg(3); $dfrn_id = notags(trim($_POST['dfrn_id'])); $challenge = notags(trim($_POST['challenge'])); $data = $_POST['data']; @@ -179,15 +180,32 @@ function dfrn_notify_post(&$a) { // remote reply to our post. Import and then notify everybody else. $datarray = get_atom_elements($item); $urn = explode(':',$parent_urn); - $datarray['parent_hash'] = $urn[4]; + $datarray['type'] = 'remote-comment'; + $datarray['parent_hash'] = $urn[5]; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; - $r = post_remote($a,$datarray); + $posted_id = post_remote($a,$datarray); + + $r = q("SELECT `parent` FROM `item` WHERE `id` = %d AND `uid` = %d LIMIT 1", + intval($posted_id), + intval($importer['uid']) + ); + if(count($r)) { + $r1 = q("UPDATE `item` SET `last-child` = 0 WHERE `uid` = %d AND `parent` = %d", + intval($importer['uid']), + intval($r[0]['parent']) + ); + } + $r2 = q("UPDATE `item` SET `last-child` = 1 WHERE `uid` = %d AND `id` = %d LIMIT 1", + intval($importer['uid']), + intval($posted_id) + ); $url = bin2hex($a->get_baseurl()); - proc_close(proc_open("php include/notifier.php $url $notify_type $r > notify.log &", array(),$foo)); + proc_close(proc_open("php include/notifier.php $url comment-import $posted_id > remote-notify.log &", array(),$foo)); + xml_status(0); return; } @@ -196,16 +214,18 @@ function dfrn_notify_post(&$a) { $item_id = $item->get_id(); - $r = q("SELECT `uid`, `last-child` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); + // FIXME update content if 'updated' changes if(count($r)) { $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); if($allow && $allow[0]['data'] != $r[0]['last-child']) { $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), - dbesc($item_id) + dbesc($item_id), + intval($importer['uid']) ); } continue; @@ -222,7 +242,7 @@ function dfrn_notify_post(&$a) { // Head post of a conversation. Have we seen it? If not, import it. $item_id = $item->get_id(); - $r = q("SELECT `uid` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); @@ -231,7 +251,8 @@ function dfrn_notify_post(&$a) { if($allow && $allow[0]['data'] != $r[0]['last-child']) { $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), - dbesc($item_id) + dbesc($item_id), + intval($importer['uid']) ); } continue; @@ -249,7 +270,7 @@ function dfrn_notify_post(&$a) { } - + xml_status(0); killme(); } diff --git a/mod/item.php b/mod/item.php index 437e6ac596..1584c7ddbd 100644 --- a/mod/item.php +++ b/mod/item.php @@ -72,8 +72,10 @@ function item_post(&$a) { } // get contact info for poster - if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id']))) + + if((x($_SESSION,'visitor_id')) && (intval($_SESSION['visitor_id']))) { $contact_id = $_SESSION['visitor_id']; + } else { $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); @@ -104,15 +106,16 @@ function item_post(&$a) { } while($dups == true); - $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`,`edited`,`hash`,`body`, + $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `remote-id`, `created`,`edited`,`hash`,`body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) - VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($profile_uid), dbesc($_POST['type']), intval($contact_id), dbesc($contact_record['name']), dbesc($contact_record['url']), dbesc($contact_record['thumb']), + dbesc("urn:X-dfrn:" . $a->get_baseurl() . ':' . intval($profile_uid) . ':' . $hash), datetime_convert(), datetime_convert(), dbesc($hash), @@ -159,7 +162,7 @@ function item_post(&$a) { $url = bin2hex($a->get_baseurl()); - proc_close(proc_open("php include/notifier.php $url $notify_type $post_id > notify.log &", + proc_close(proc_open("php include/notifier.php \"$url\" \"$notify_type\" \"$post_id\" > notify.log &", array(),$foo)); } diff --git a/mod/network.php b/mod/network.php index 2685959a3e..94ea065e95 100644 --- a/mod/network.php +++ b/mod/network.php @@ -108,6 +108,7 @@ function network_content(&$a) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( + '$return_path' => $a->cmd, '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $_SESSION['uid'], diff --git a/mod/profile.php b/mod/profile.php index 7b54340a91..f14cdbd111 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -196,6 +196,7 @@ function profile_content(&$a) { if(can_write_wall($a,$a->profile['profile_uid'])) { if($item['last-child']) { $comment = replace_macros($cmnt_tpl,array( + '$return_path' => $a->cmd, '$id' => $item['item_id'], '$parent' => $item['parent'], '$profile_uid' => $a->profile['profile_uid'], diff --git a/update.sql b/update.sql index b3196a1dee..0a606e5279 100644 --- a/update.sql +++ b/update.sql @@ -12,3 +12,5 @@ ADD `remote-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT N ALTER TABLE `item` ADD `owner-name` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `contact-id` , ADD `owner-link` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-name` , ADD `owner-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-link` ; + +ALTER TABLE `item` ADD `remote-parent` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `parent` ; \ No newline at end of file diff --git a/view/comment_item.tpl b/view/comment_item.tpl index 530244e8ee..b91be5ab5a 100644 --- a/view/comment_item.tpl +++ b/view/comment_item.tpl @@ -5,6 +5,7 @@ + -- 2.39.2 From 83ee7909cddaed3d25c4b52f197ac470e8150ee0 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 18 Jul 2010 01:24:51 -0700 Subject: [PATCH 06/16] password reset --- mod/lostpass.php | 104 +++++++++++++++++++++++++++++++++++++++ update.sql | 2 +- view/login.tpl | 2 +- view/lostpass.tpl | 18 +++++++ view/lostpass_eml.tpl | 32 ++++++++++++ view/passchanged_eml.tpl | 20 ++++++++ view/pwdreset.tpl | 16 ++++++ 7 files changed, 192 insertions(+), 2 deletions(-) create mode 100644 mod/lostpass.php create mode 100644 view/lostpass.tpl create mode 100644 view/lostpass_eml.tpl create mode 100644 view/passchanged_eml.tpl create mode 100644 view/pwdreset.tpl diff --git a/mod/lostpass.php b/mod/lostpass.php new file mode 100644 index 0000000000..fb219072ef --- /dev/null +++ b/mod/lostpass.php @@ -0,0 +1,104 @@ +get_baseurl()); + + $r = q("SELECT * FROM `user` WHERE `email` = '%s' LIMIT 1", + dbesc($email) + ); + if(! count($r)) + goaway($a->get_baseurl()); + $uid = $r[0]['uid']; + $username = $r[0]['username']; + + $new_password = autoname(12) . mt_rand(100,9999); + $new_password_encoded = hash('whirlpool',$new_password); + + $r = q("UPDATE `user` SET `pwdreset` = '%s' WHERE `uid` = %d LIMIT 1", + dbesc($new_password_encoded), + intval($uid) + ); + if($r) + notice("Password reset request issued. Check your email."); + + $email_tpl = file_get_contents("view/lostpass_eml.tpl"); + $email_tpl = replace_macros($email_tpl, array( + '$sitename' => $a->config['sitename'], + '$siteurl' => $a->get_baseurl(), + '$username' => $username, + '$email' => $email, + '$reset_link' => $a->get_baseurl() . '/lostpass?verify=' . $new_password + )); + + $res = mail($email,"Password reset requested at {$a->config['sitename']}",$email_tpl,"From: Administrator@{$_SERVER[SERVER_NAME]}"); + + + + goaway($a->get_baseurl()); +} + + +function lostpass_content(&$a) { + + + if(x($_GET,'verify')) { + $verify = $_GET['verify']; + $hash = hash('whirlpool', $verify); + + $r = q("SELECT * FROM `user` WHERE `pwdreset` = '%s' LIMIT 1", + dbesc($hash) + ); + if(! count($r)) { + notice("Request could not be verified. (You may have previously submitted it.) Password reset failed." . EOL); + goaway($a->get_baseurl()); + return; + } + $uid = $r[0]['uid']; + $username = $r[0]['username']; + $email = $r[0]['email']; + + $new_password = autoname(6) . mt_rand(100,9999); + $new_password_encoded = hash('whirlpool',$new_password); + + $r = q("UPDATE `user` SET `password` = '%s', `pwdreset` = '' WHERE `uid` = %d LIMIT 1", + dbesc($new_password_encoded), + intval($uid) + ); + if($r) { + $tpl = file_get_contents('view/pwdreset.tpl'); + $o .= replace_macros($tpl,array( + '$newpass' => $new_password, + '$baseurl' => $a->get_baseurl() + )); + notice("Your password has been reset." . EOL); + + + + $email_tpl = file_get_contents("view/passchanged_eml.tpl"); + $email_tpl = replace_macros($email_tpl, array( + '$sitename' => $a->config['sitename'], + '$siteurl' => $a->get_baseurl(), + '$username' => $username, + '$email' => $email, + '$new_password' => $new_password, + '$uid' => $newuid )); + + $res = mail($email,"Your password has changed at {$a->config['sitename']}",$email_tpl,"From: Administrator@{$_SERVER[SERVER_NAME]}"); + + return $o; + } + + } + else { + $tpl = file_get_contents('view/lostpass.tpl'); + + $o .= $tpl; + + return $o; + } + +} \ No newline at end of file diff --git a/update.sql b/update.sql index 0a606e5279..fc4a63fd9e 100644 --- a/update.sql +++ b/update.sql @@ -13,4 +13,4 @@ ALTER TABLE `item` ADD `owner-name` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_ ADD `owner-link` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-name` , ADD `owner-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-link` ; -ALTER TABLE `item` ADD `remote-parent` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `parent` ; \ No newline at end of file +ALTER TABLE `user` ADD `pwdreset` CHAR( 255 ) NOT NULL AFTER `blocked` ; \ No newline at end of file diff --git a/view/login.tpl b/view/login.tpl index 2ce7241fc9..c7cae1bb71 100644 --- a/view/login.tpl +++ b/view/login.tpl @@ -14,7 +14,7 @@
diff --git a/view/lostpass.tpl b/view/lostpass.tpl new file mode 100644 index 0000000000..9de0a2acfc --- /dev/null +++ b/view/lostpass.tpl @@ -0,0 +1,18 @@ +

Forgot your Password?

+ +

+Enter your email address and submit to have your password reset. Then check your email for further instructions. +

+ + +
+ + +
+
+
+ +
+
+ + diff --git a/view/lostpass_eml.tpl b/view/lostpass_eml.tpl new file mode 100644 index 0000000000..c350236a43 --- /dev/null +++ b/view/lostpass_eml.tpl @@ -0,0 +1,32 @@ + +Dear $username, + A request was recently received at $sitename to reset your account +password. In order to confirm this request, please select the verification link +below or paste it into your web browser address bar. + +If you did NOT request this change, please DO NOT follow the link +provided and ignore and/or delete this email. + +Your password will not be changed unless we can verify that you +issued this request. + +Follow this link to verify your identity: + +$reset_link + +You will then receive a follow-up message containing the new password. + +You may change that password from your account settings page after logging in. + +The login details are as follows: + +Site Location: $siteurl +Login Name: $email + + + + +Sincerely, + $sitename Administrator + + diff --git a/view/passchanged_eml.tpl b/view/passchanged_eml.tpl new file mode 100644 index 0000000000..9692159e18 --- /dev/null +++ b/view/passchanged_eml.tpl @@ -0,0 +1,20 @@ + +Dear $username, + Your password has been changed as requested. Please retain this +information for your records (or change your password immediately to +something that you will remember). + + +Your login details are as follows: + +Site Location: $siteurl +Login Name: $email +Password: $new_password + +You may change that password from your account settings page after logging in. + + +Sincerely, + $sitename Administrator + + diff --git a/view/pwdreset.tpl b/view/pwdreset.tpl new file mode 100644 index 0000000000..dd609f0610 --- /dev/null +++ b/view/pwdreset.tpl @@ -0,0 +1,16 @@ +

Password Reset

+ +

+Your password has been reset as requested. +

+

+Your new password is +

+

+$newpass +

+

+Save or copy your new password - and then click here to login. +

+

+Your password may be changed from the 'Settings' page after successful login. \ No newline at end of file -- 2.39.2 From 95d0a9e2bfd7ae36a1b2f27cacb22290297c1128 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 18 Jul 2010 02:49:38 -0700 Subject: [PATCH 07/16] dfrn_poll underway --- mod/dfrn_poll.php | 108 ++++++++++++++++++++++++++++++++++++++++++++++ update.sql | 7 ++- 2 files changed, 114 insertions(+), 1 deletion(-) diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 8873526943..042a15f5eb 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -55,4 +55,112 @@ function dfrn_poll_init(&$a) { return; // NOTREACHED } + + if($dfrn_id != '*') { + // initial communication from external contact + $hash = random_string(); + + $status = 0; + + $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); + + $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` ) + VALUES( '%s', '%s', '%s', '%s', '%s' ) ", + dbesc($hash), + dbesc(notags(trim($_GET['dfrn_id']))), + intval(time() + 60 ), + dbesc($type), + dbesc($last_update) + ); + + $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 LIMIT 1", + dbesc($_GET['dfrn_id'])); + if((! count($r)) || (! strlen($r[0]['prvkey']))) + $status = 1; + + $challenge = ''; + + openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']); + $challenge = bin2hex($challenge); + echo '' .$status . '' . $_GET['dfrn_id'] . '' + . '' . $challenge . '' . "\r\n" ; + session_write_close(); + exit; + } } + + + +function dfrn_poll_post(&$a) { + + $dfrn_id = notags(trim($_POST['dfrn_id'])); + $challenge = notags(trim($_POST['challenge'])); + $url = $_POST['url']; + $r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", + dbesc($dfrn_id), + dbesc($challenge) + ); + if(! count($r)) + xml_status(3); + + $type = $r[0]['type']; + $last_update = $r[0]['last_update']; + + $r = q("DELETE FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", + dbesc($dfrn_id), + dbesc($challenge) + ); + + + $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' LIMIT 1", + dbesc($dfrn_id) + ); + if(! count($r)) + xml_status(3); + + $owner_uid = $r[0]['uid']; + $contact_id = $r[0]['id']; + + + if($type == 'reputation' && strlen($url)) { + $r = q("SELECT * FROM `contact` WHERE `url` = '%s' AND `uid` = %d LIMIT 1", + dbesc($url), + intval($owner_uid) + ); + $reputation = 0; + $text = ''; + + if(count($r)) { + $reputation = $r[0]['rating']; + $text = $r[0]['reason']; + + if($r[0]['id'] == $contact_id) { // inquiring about own reputation not allowed + $reputation = 0; + $text = ''; + } + } + + echo " + + $url + $reputation + $text + + "; + killme(); + return; // NOTREACHED + } + + + +} + + + + +function dfrn_poll_content(&$a) { + + + + +} \ No newline at end of file diff --git a/update.sql b/update.sql index fc4a63fd9e..752c6b775b 100644 --- a/update.sql +++ b/update.sql @@ -13,4 +13,9 @@ ALTER TABLE `item` ADD `owner-name` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_ ADD `owner-link` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-name` , ADD `owner-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL AFTER `owner-link` ; -ALTER TABLE `user` ADD `pwdreset` CHAR( 255 ) NOT NULL AFTER `blocked` ; \ No newline at end of file +ALTER TABLE `user` ADD `pwdreset` CHAR( 255 ) NOT NULL AFTER `blocked` ; + + ALTER TABLE `challenge` ADD `cmd` CHAR( 255 ) NOT NULL AFTER `expire` , +ADD `url` CHAR( 255 ) NOT NULL AFTER `cmd` , +ADD `last_update` CHAR( 255 ) NOT NULL AFTER `url` ; + -- 2.39.2 From 5ed87a44e61fe4318fd1cb34ca1f3feed67a5f72 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 18 Jul 2010 02:54:47 -0700 Subject: [PATCH 08/16] fix reference to if(item->remote-id), which now gets set more often --- include/notifier.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/notifier.php b/include/notifier.php index 6d6146a2a0..68ff8a5c3c 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -65,7 +65,7 @@ if($argc < 3) $parent = $items[0]; - if(strlen($parent['remote-id'])) { + if((strlen($parent['remote-id'])) && ($parent['type'] == 'remote')) { $followup = true; $conversant_str = dbesc($parent['contact-id']); } -- 2.39.2 From 5bdff4d44ceefc9fa1b9936a8ec6ef05b18334d3 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 18 Jul 2010 06:02:19 -0700 Subject: [PATCH 09/16] more dfrn_poll --- mod/dfrn_poll.php | 23 ++++++++++++++--------- update.sql | 1 + 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 042a15f5eb..ae3dc892dc 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -1,5 +1,6 @@ argc > 1) && (intval($a->argv[1]))) { + $o = get_feed_for($a,'*', $a->argv[1],$last_update); + echo $o; + killme(); + } + if((x($type)) && ($type == 'profile')) { $r = q("SELECT `contact`.*, `user`.`nickname` @@ -101,7 +108,7 @@ function dfrn_poll_post(&$a) { dbesc($challenge) ); if(! count($r)) - xml_status(3); + killme(); $type = $r[0]['type']; $last_update = $r[0]['last_update']; @@ -116,7 +123,7 @@ function dfrn_poll_post(&$a) { dbesc($dfrn_id) ); if(! count($r)) - xml_status(3); + killme(); $owner_uid = $r[0]['uid']; $contact_id = $r[0]['id']; @@ -150,17 +157,15 @@ function dfrn_poll_post(&$a) { killme(); return; // NOTREACHED } + else { + $o = get_feed_for($a,$dfrn_id, $a->argv[1], $last_update); + echo $o; + killme(); - + } } -function dfrn_poll_content(&$a) { - - - - -} \ No newline at end of file diff --git a/update.sql b/update.sql index 752c6b775b..be6a6a36cc 100644 --- a/update.sql +++ b/update.sql @@ -19,3 +19,4 @@ ALTER TABLE `user` ADD `pwdreset` CHAR( 255 ) NOT NULL AFTER `blocked` ; ADD `url` CHAR( 255 ) NOT NULL AFTER `cmd` , ADD `last_update` CHAR( 255 ) NOT NULL AFTER `url` ; +ALTER TABLE `contact` ADD `last-update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `ret-pubkey` ; -- 2.39.2 From 07274bb922204a39889e8a3db42adb94708572fb Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 18 Jul 2010 06:02:55 -0700 Subject: [PATCH 10/16] feed generator --- include/items.php | 133 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 include/items.php diff --git a/include/items.php b/include/items.php new file mode 100644 index 0000000000..d0ec64fb98 --- /dev/null +++ b/include/items.php @@ -0,0 +1,133 @@ +>'; // should be impossible to match + if(count($groups)) { + foreach($groups as $g) + $gs .= '|<' . intval($g) . '>'; + } + $sql_extra = sprintf( + " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' ) + AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' ) + AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' ) + AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ", + + intval($_SESSION['visitor_id']), + intval($_SESSION['visitor_id']), + dbesc($gs), + dbesc($gs) + ); + } + + if(! strlen($last_update)) + $last_update = 'now - 30 days'; + $check_date = datetime_convert('UTC','UTC',$last_update,'Y-m-d H:i:s'); + + $r = q("SELECT `item`.*, `item`.`id` AS `item_id`, + `contact`.`name`, `contact`.`photo`, `contact`.`url`, + `contact`.`thumb`, `contact`.`dfrn-id`, `contact`.`self`, + `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid` + FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` + WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 + AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 + AND `item`.`edited` > '%s' + $sql_extra + ORDER BY `parent` DESC, `id` ASC LIMIT 0, 300", + intval($owner_id), + dbesc($check_date) + ); + if(! count($r)) + killme(); + + $items = $r; + + $feed_template = file_get_contents('view/atom_feed.tpl'); + $tomb_template = file_get_contents('view/atom_tomb.tpl'); + $item_template = file_get_contents('view/atom_item.tpl'); + $cmnt_template = file_get_contents('view/atom_cmnt.tpl'); + + $atom = ''; + + + $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']), + '$profile_page' => xmlify($owner['url']), + '$photo' => xmlify($owner['photo']) + )); + + foreach($items as $item) { + if($item['deleted']) { + $atom .= replace_macros($tomb_template, array( + '$id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) + )); + } + else { + + if($item['parent'] == $item['id']) { + $atom .= replace_macros($item_template, array( + '$name' => xmlify($item['name']), + '$profile_page' => xmlify($item['url']), + '$thumb' => xmlify($item['thumb']), + '$owner_name' => xmlify($item['owner-name']), + '$owner_profile_page' => xmlify($item['owner-link']), + '$owner_thumb' => xmlify($item['owner-avatar']), + '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$title' => xmlify($item['name']), + '$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']), + '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'] && (! $contact['blocked']))) ? 1 : 0) + )); + } + else { + $atom .= replace_macros($cmnt_template, array( + '$name' => xmlify($item['name']), + '$profile_page' => xmlify($item['url']), + '$thumb' => xmlify($item['thumb']), + '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$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']), + '$parent_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$items[0]['hash']}"), + '$comment_allow' => (($item['last-child']) ? 1 : 0) + )); + } + } + } + + + $atom .= "\r\n"; + + return $atom; +} \ No newline at end of file -- 2.39.2 From 21f0cd206d1f533af8754542821f18c82e5c8df5 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 18 Jul 2010 20:49:10 -0700 Subject: [PATCH 11/16] more poll stuff ahead of item revamp --- boot.php | 18 +++++- htconfig.php | 5 ++ include/items.php | 147 +++++++++++++++++++++++++++++++++++++++++--- mod/dfrn_notify.php | 127 +------------------------------------- mod/dfrn_poll.php | 80 ++++++++++++++---------- mod/network.php | 2 +- update.sql | 5 +- view/atom_feed.tpl | 1 + 8 files changed, 213 insertions(+), 172 deletions(-) diff --git a/boot.php b/boot.php index 02c37a93f1..1ecd6e677c 100644 --- a/boot.php +++ b/boot.php @@ -33,6 +33,7 @@ class App { private $scheme; private $hostname; private $path; + private $baseurl; private $db; function __construct() { @@ -69,12 +70,20 @@ class App { } function get_baseurl($ssl = false) { - - return (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname + if(strlen($this->baseurl)) + return $this->baseurl; + + $this->baseurl = (($ssl) ? 'https' : $this->scheme) . "://" . $this->hostname . ((isset($this->path) && strlen($this->path)) ? '/' . $this->path : '' ); + return $this->baseurl; + } + + function set_baseurl($url) { + $this->baseurl = $url; } + function set_path($p) { $this->path = ltrim(trim($p),'/'); } @@ -330,6 +339,11 @@ function notice($s) { }} +if(! function_exists('get_max_import_size')) { +function get_max_import_size() { + global $a; + return ((x($a->config,'max_import_size')) ? $a->config['max_import_size'] : 0 ); +}} if(! function_exists('xmlify')) { function xmlify($str) { diff --git a/htconfig.php b/htconfig.php index cf52b396a5..ef3855978a 100644 --- a/htconfig.php +++ b/htconfig.php @@ -22,3 +22,8 @@ $a->config['sitename'] = "DFRN developer"; // first before you close it. $a->config['register_policy'] = REGISTER_OPEN; + + +// Maximum size of an imported message, 0 is unlimited. + +$a->config['max_import_size'] = 10000; \ No newline at end of file diff --git a/include/items.php b/include/items.php index d0ec64fb98..e6a78f9ec2 100644 --- a/include/items.php +++ b/include/items.php @@ -7,6 +7,14 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { $sql_extra = " AND `allow_cid` = '' AND `allow_gid` = '' AND `deny_cid` = '' AND `deny_gid` = '' "; + if(strlen($owner_id) && ! intval($owner_id)) { + $r = q("SELECT `uid` FROM `user` WHERE `nickname` = '%s' LIMIT 1", + dbesc($owner_id) + ); + if(count($r)) + $owner_id = $r[0]['uid']; + } + $r = q("SELECT * FROM `contact` WHERE `self` = 1 AND `uid` = %d LIMIT 1", intval($owner_id) ); @@ -38,8 +46,8 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' ) AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ", - intval($_SESSION['visitor_id']), - intval($_SESSION['visitor_id']), + intval($contact['id']), + intval($contact['id']), dbesc($gs), dbesc($gs) ); @@ -58,7 +66,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `item`.`edited` > '%s' $sql_extra - ORDER BY `parent` DESC, `id` ASC LIMIT 0, 300", + ORDER BY `parent` ASC, `created` ASC LIMIT 0, 300", intval($owner_id), dbesc($check_date) ); @@ -87,7 +95,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { foreach($items as $item) { if($item['deleted']) { $atom .= replace_macros($tomb_template, array( - '$id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) )); } @@ -101,7 +109,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { '$owner_name' => xmlify($item['owner-name']), '$owner_profile_page' => xmlify($item['owner-link']), '$owner_thumb' => xmlify($item['owner-avatar']), - '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")), '$title' => xmlify($item['name']), '$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')), @@ -114,20 +122,141 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { '$name' => xmlify($item['name']), '$profile_page' => xmlify($item['url']), '$thumb' => xmlify($item['thumb']), - '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")), '$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']), - '$parent_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$items[0]['hash']}"), + + // ......this is wrong!!!! + '$parent_id' => xmlify("urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$items[0]['hash']}"), '$comment_allow' => (($item['last-child']) ? 1 : 0) )); } } } - $atom .= "\r\n"; return $atom; -} \ No newline at end of file +} + + + + +function get_atom_elements($item) { + + $res = array(); + + $author = $item->get_author(); + $res['remote-name'] = unxmlify($author->get_name()); + $res['remote-link'] = unxmlify($author->get_link()); + $res['remote-avatar'] = unxmlify($author->get_avatar()); + $res['remote-id'] = unxmlify($item->get_id()); + $res['title'] = unxmlify($item->get_title()); + $res['body'] = unxmlify($item->get_content()); + + $maxlen = get_max_import_size(); + if($maxlen && (strlen($res['body']) > $maxlen)) + $res['body'] = substr($res['body'],0, $maxlen); + + $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); + if($allow && $allow[0]['data'] == 1) + $res['last-child'] = 1; + else + $res['last-child'] = 0; + + $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published'); + if($rawcreated) + $res['created'] = unxmlify($rawcreated[0]['data']); + + $rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated'); + if($rawedited) + $res['edited'] = unxmlify($rawcreated[0]['data']); + + $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0', 'owner'); + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']) + $res['owner-name'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']); + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']) + $res['owner-link'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']); + if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']) + $res['owner-avatar'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']); + + return $res; +} + +function post_remote($a,$arr) { + + $arr['hash'] = random_string(); + if(! x($arr,'type')) + $arr['type'] = 'remote'; + $arr['remote-name'] = notags(trim($arr['remote-name'])); + $arr['remote-link'] = notags(trim($arr['remote-link'])); + $arr['remote-avatar'] = notags(trim($arr['remote-avatar'])); + $arr['owner-name'] = notags(trim($arr['owner-name'])); + $arr['owner-link'] = notags(trim($arr['owner-link'])); + $arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); + if(! strlen($arr['remote-avatar'])) + $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; + if(! strlen($arr['owner-avatar'])) + $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; + $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); + $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); + $arr['title'] = notags(trim($arr['title'])); + $arr['body'] = escape_tags(trim($arr['body'])); + $arr['last-child'] = intval($arr['last-child']); + $arr['visible'] = 1; + $arr['deleted'] = 0; + + $local_parent = false; + + if(isset($arr['parent_hash'])) { + $local_parent = true; + $parent = $arr['parent_hash']; + unset($arr['parent_hash']); + } + else { + $parent = $arr['parent_urn']; + unset($arr['parent_urn']); + } + + $parent_id = 0; + + dbesc_array($arr); +dbg(3); + $r = q("INSERT INTO `item` (`" + . implode("`, `", array_keys($arr)) + . "`) VALUES ('" + . implode("', '", array_values($arr)) + . "')" ); + + if($local_parent) { + $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1", + dbesc($parent), + intval($arr['uid']) + ); + } + else { + $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + dbesc($parent), + intval($arr['uid']) + ); + } + if(count($r)) + $parent_id = $r[0]['id']; + + + $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $arr['remote-id'], + intval($arr['uid']) + ); + if(count($r)) + $current_post = $r[0]['id']; + + $r = q("UPDATE `item` SET `parent` = %d WHERE `id` = %d LIMIT 1", + intval($parent_id), + intval($current_post) + ); + + return $current_post; +} diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index f81eb9cfb7..ed2222d6aa 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -1,126 +1,9 @@ get_author(); - $res['remote-name'] = unxmlify($author->get_name()); - $res['remote-link'] = unxmlify($author->get_link()); - $res['remote-avatar'] = unxmlify($author->get_avatar()); - $res['remote-id'] = unxmlify($item->get_id()); - $res['title'] = unxmlify($item->get_title()); - $res['body'] = unxmlify($item->get_content()); - - if(strlen($res['body']) > 100000) - $res['body'] = substr($res['body'],0,10000) . "\r\n[Extremely large post truncated.]\r\n" ; - - $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); - if($allow && $allow[0]['data'] == 1) - $res['last-child'] = 1; - else - $res['last-child'] = 0; - - $rawcreated = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'published'); - if($rawcreated) - $res['created'] = unxmlify($rawcreated[0]['data']); - - $rawedited = $item->get_item_tags(SIMPLEPIE_NAMESPACE_ATOM_10,'updated'); - if($rawedited) - $res['edited'] = unxmlify($rawcreated[0]['data']); - - $rawowner = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0', 'owner'); - if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']) - $res['owner-name'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['name'][0]['data']); - if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']) - $res['owner-link'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['uri'][0]['data']); - if($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']) - $res['owner-avatar'] = unxmlify($rawowner[0]['child']['http://purl.org/macgirvin/dfrn/1.0']['avatar'][0]['data']); - - - return $res; - -} - -function post_remote($a,$arr) { - - $arr['hash'] = random_string(); - if(! x($arr,'type')) - $arr['type'] = 'remote'; - $arr['remote-name'] = notags(trim($arr['remote-name'])); - $arr['remote-link'] = notags(trim($arr['remote-link'])); - $arr['remote-avatar'] = notags(trim($arr['remote-avatar'])); - $arr['owner-name'] = notags(trim($arr['owner-name'])); - $arr['owner-link'] = notags(trim($arr['owner-link'])); - $arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); - if(! strlen($arr['remote-avatar'])) - $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - if(! strlen($arr['owner-avatar'])) - $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); - $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); - $arr['title'] = notags(trim($arr['title'])); - $arr['body'] = escape_tags(trim($arr['body'])); - $arr['last-child'] = intval($arr['last-child']); - $arr['visible'] = 1; - $arr['deleted'] = 0; - - $local_parent = false; - - if(isset($arr['parent_hash'])) { - $local_parent = true; - $parent = $arr['parent_hash']; - unset($arr['parent_hash']); - } - else { - $parent = $arr['parent_urn']; - unset($arr['parent_urn']); - } - - $parent_id = 0; - - dbesc_array($arr); -dbg(3); - $r = q("INSERT INTO `item` (`" - . implode("`, `", array_keys($arr)) - . "`) VALUES ('" - . implode("', '", array_values($arr)) - . "')" ); - - if($local_parent) { - $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1", - dbesc($parent), - intval($arr['uid']) - ); - } - else { - $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", - dbesc($parent), - intval($arr['uid']) - ); - } - if(count($r)) - $parent_id = $r[0]['id']; - - - $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", - $arr['remote-id'], - intval($arr['uid']) - ); - if(count($r)) - $current_post = $r[0]['id']; - - $r = q("UPDATE `item` SET `parent` = %d WHERE `id` = %d LIMIT 1", - intval($parent_id), - intval($current_post) - ); - - return $current_post; -} - function dfrn_notify_post(&$a) { dbg(3); $dfrn_id = notags(trim($_POST['dfrn_id'])); @@ -276,14 +159,6 @@ dbg(3); } - - - - - - - - function dfrn_notify_content(&$a) { if(x($_GET,'dfrn_id')) { diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index ae3dc892dc..6b4c50ad2e 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -1,6 +1,8 @@ ' .$status . '' . $_GET['dfrn_id'] . '' - . '' . $challenge . '' . "\r\n" ; - session_write_close(); - exit; - } } @@ -103,6 +74,7 @@ function dfrn_poll_post(&$a) { $dfrn_id = notags(trim($_POST['dfrn_id'])); $challenge = notags(trim($_POST['challenge'])); $url = $_POST['url']; + $r = q("SELECT * FROM `challenge` WHERE `dfrn-id` = '%s' AND `challenge` = '%s' LIMIT 1", dbesc($dfrn_id), dbesc($challenge) @@ -166,6 +138,52 @@ function dfrn_poll_post(&$a) { } } +function dfrn_poll_content(&$a) { + + if(x($_GET,'dfrn_id')) + $dfrn_id = $a->config['dfrn_poll_dfrn_id'] = $_GET['dfrn_id']; + if(x($_GET,'type')) + $type = $a->config['dfrn_poll_type'] = $_GET['type']; + if(x($_GET,'last_update')) + $last_update = $a->config['dfrn_poll_last_update'] = $_GET['last_update']; + + + if($dfrn_id != '*') { + // initial communication from external contact + $hash = random_string(); + + $status = 0; + + $r = q("DELETE FROM `challenge` WHERE `expire` < " . intval(time())); + + $r = q("INSERT INTO `challenge` ( `challenge`, `dfrn-id`, `expire` , `type`, `last_update` ) + VALUES( '%s', '%s', '%s', '%s', '%s' ) ", + dbesc($hash), + dbesc(notags(trim($_GET['dfrn_id']))), + intval(time() + 60 ), + dbesc($type), + dbesc($last_update) + ); + $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 LIMIT 1", + dbesc($_GET['dfrn_id'])); + if((! count($r)) || (! strlen($r[0]['prvkey']))) + $status = 1; + + $challenge = ''; + + openssl_private_encrypt($hash,$challenge,$r[0]['prvkey']); + $challenge = bin2hex($challenge); + echo '' .$status . '' . $_GET['dfrn_id'] . '' + . '' . $challenge . '' . "\r\n" ; + session_write_close(); + exit; + } + + + + + +} diff --git a/mod/network.php b/mod/network.php index 94ea065e95..aa662c79cc 100644 --- a/mod/network.php +++ b/mod/network.php @@ -56,7 +56,7 @@ function network_content(&$a) { WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 AND `contact`.`blocked` = 0 $sql_extra - ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", + ORDER BY `parent` DESC, `created` ASC LIMIT %d ,%d ", intval($_SESSION['uid']), intval($a->pager['start']), intval($a->pager['itemspage']) diff --git a/update.sql b/update.sql index be6a6a36cc..a576adb88d 100644 --- a/update.sql +++ b/update.sql @@ -15,8 +15,7 @@ ADD `owner-avatar` CHAR( 255 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NU ALTER TABLE `user` ADD `pwdreset` CHAR( 255 ) NOT NULL AFTER `blocked` ; - ALTER TABLE `challenge` ADD `cmd` CHAR( 255 ) NOT NULL AFTER `expire` , -ADD `url` CHAR( 255 ) NOT NULL AFTER `cmd` , -ADD `last_update` CHAR( 255 ) NOT NULL AFTER `url` ; + ALTER TABLE `challenge` ADD `type` CHAR( 255 ) NOT NULL AFTER `expire` , +ADD `last_update` CHAR( 255 ) NOT NULL AFTER `type` ; ALTER TABLE `contact` ADD `last-update` DATETIME NOT NULL DEFAULT '0000-00-00 00:00:00' AFTER `ret-pubkey` ; diff --git a/view/atom_feed.tpl b/view/atom_feed.tpl index c283ad8f75..00ac6c4063 100644 --- a/view/atom_feed.tpl +++ b/view/atom_feed.tpl @@ -1,3 +1,4 @@ + Date: Sun, 18 Jul 2010 20:49:54 -0700 Subject: [PATCH 12/16] poller --- include/poller.php | 167 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) create mode 100644 include/poller.php diff --git a/include/poller.php b/include/poller.php new file mode 100644 index 0000000000..8c3110746b --- /dev/null +++ b/include/poller.php @@ -0,0 +1,167 @@ +set_baseurl($argv[1]); + + $contacts = q("SELECT * FROM `contact` WHERE `dfrn-id` != '' AND `self` = 0 ORDER BY RAND()"); + + if(! count($contacts)) + killme(); + + foreach($contacts as $contact) { + + $importer_uid = $contact['uid']; + + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `self` = 1 LIMIT 1", + intval($importer_uid) + ); + if(! count($r)) + continue; + + $importer = $r[0]; + + $last_update = (($contact['last-update'] == '0000-00-00 00:00:00') + ? datetime_convert('UTC','UTC','now - 30 days','Y-m-d\TH:i:s\Z') + : datetime_convert('UTC','UTC',$contact['last-update'],'Y-m-d\TH:i:s\Z')); + + $url = $contact['poll'] . '?dfrn_id=' . $contact['dfrn-id'] . '&type=data&last_update=' . $last_update ; + + $xml = fetch_url($url); + + if(! $xml) + continue; + + $res = simplexml_load_string($xml); + + if((intval($res->status) != 0) || (! strlen($res->challenge)) || ($res->dfrn_id != $contact['dfrn-id'])) + continue; + + $postvars = array(); + + $postvars['dfrn_id'] = $contact['dfrn-id']; + $challenge = hex2bin($res->challenge); + + openssl_public_decrypt($challenge,$postvars['challenge'],$contact['pubkey']); + + $xml = post_url($contact['poll'],$postvars); + if(! strlen($xml)) + continue; + +echo "XML response:" . $xml . "\r\n"; +echo "Length:" . strlen($xml) . "\r\n"; + + $feed = new SimplePie(); + $feed->set_raw_data($xml); + $feed->enable_order_by_date(false); + $feed->init(); + + foreach($feed->get_items() as $item) { + + $rawdelete = $item->get_item_tags("http://purl.org/atompub/tombstones/1.0", 'deleted-entry'); + print_r($rawdelete); + if($deleted) { + // pick out ref and when from attribs + // check hasn't happened already, verify ownership and then process it + + + continue; + } + + $is_reply = false; + $item_id = $item->get_id(); + $rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0",'in-reply-to'); + if(isset($rawthread[0]['attribs']['']['ref'])) { + $is_reply = true; + $parent_urn = $rawthread[0]['attribs']['']['ref']; + } + + + if($is_reply) { + + // Have we seen it? If not, import it. + + $item_id = $item->get_id(); + + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + dbesc($item_id), + intval($importer['uid']) + ); + // FIXME update content if 'updated' changes + if(count($r)) { + $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); + if($allow && $allow[0]['data'] != $r[0]['last-child']) { + $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + intval($allow[0]['data']), + dbesc($item_id), + intval($importer['uid']) + ); + } + continue; + } + $datarray = get_atom_elements($item); + $datarray['parent_urn'] = $parent_urn; + $datarray['uid'] = $importer['uid']; + $datarray['contact-id'] = $importer['id']; + $r = post_remote($a,$datarray); + continue; + } + + else { + // Head post of a conversation. Have we seen it? If not, import it. + + $item_id = $item->get_id(); + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + dbesc($item_id), + intval($importer['uid']) + ); + if(count($r)) { + $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); + if($allow && $allow[0]['data'] != $r[0]['last-child']) { + $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + intval($allow[0]['data']), + dbesc($item_id), + intval($importer['uid']) + ); + } + continue; + } + + $datarray = get_atom_elements($item); + $datarray['parent_urn'] = $item_id; + $datarray['uid'] = $importer['uid']; + $datarray['contact-id'] = $importer['id']; + $r = post_remote($a,$datarray); + continue; + + } + + } + + $r = q("UPDATE `contact` SET `last-update` = '%s' WHERE `id` = %d LIMIT 1", + dbesc(datetime_convert()), + intval($contact['id']) + ); + + } + + killme(); + + + -- 2.39.2 From 9b0584e59338f0b75c6b8a9a1b5def33da5de5f6 Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Sun, 18 Jul 2010 23:23:18 -0700 Subject: [PATCH 13/16] revamp of item structure --- boot.php | 10 ++++++- include/items.php | 69 +++++++++++++++----------------------------- include/notifier.php | 58 ++++++++++++++++++++----------------- include/poller.php | 14 ++++----- mod/dfrn_notify.php | 18 ++++++------ mod/item.php | 28 ++++++++++-------- mod/network.php | 12 ++++---- mod/profile.php | 10 +++---- 8 files changed, 108 insertions(+), 111 deletions(-) diff --git a/boot.php b/boot.php index 1ecd6e677c..1a60ee173d 100644 --- a/boot.php +++ b/boot.php @@ -30,6 +30,7 @@ class App { public $argc; public $module; public $pager; + private $scheme; private $hostname; private $path; @@ -83,6 +84,13 @@ class App { $this->baseurl = $url; } + function get_hostname() { + return $this->hostname; + } + + function set_hostname($h) { + $this->hostname = $h; + } function set_path($p) { $this->path = ltrim(trim($p),'/'); @@ -306,7 +314,7 @@ function goaway($s) { if(! function_exists('xml_status')) { function xml_status($st) { - header( "Content-type: text/xml"); + header( "Content-type: text/xml" ); echo ''."\r\n"; echo "$st\r\n"; killme(); diff --git a/include/items.php b/include/items.php index e6a78f9ec2..d583ffecc3 100644 --- a/include/items.php +++ b/include/items.php @@ -95,7 +95,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { foreach($items as $item) { if($item['deleted']) { $atom .= replace_macros($tomb_template, array( - '$id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")), + '$id' => xmlify($item['uri']), '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) )); } @@ -109,7 +109,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { '$owner_name' => xmlify($item['owner-name']), '$owner_profile_page' => xmlify($item['owner-link']), '$owner_thumb' => xmlify($item['owner-avatar']), - '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")), + '$item_id' => xmlify($item['uri']), '$title' => xmlify($item['name']), '$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')), @@ -122,14 +122,12 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { '$name' => xmlify($item['name']), '$profile_page' => xmlify($item['url']), '$thumb' => xmlify($item['thumb']), - '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$item['hash']}")), + '$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']), - - // ......this is wrong!!!! - '$parent_id' => xmlify("urn:X-dfrn:" . $a->get_baseurl() . ":{$owner['uid']}:{$items[0]['hash']}"), + '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => (($item['last-child']) ? 1 : 0) )); } @@ -149,10 +147,10 @@ function get_atom_elements($item) { $res = array(); $author = $item->get_author(); - $res['remote-name'] = unxmlify($author->get_name()); - $res['remote-link'] = unxmlify($author->get_link()); - $res['remote-avatar'] = unxmlify($author->get_avatar()); - $res['remote-id'] = unxmlify($item->get_id()); + $res['author-name'] = unxmlify($author->get_name()); + $res['author-link'] = unxmlify($author->get_link()); + $res['author-avatar'] = unxmlify($author->get_avatar()); + $res['uri'] = unxmlify($item->get_id()); $res['title'] = unxmlify($item->get_title()); $res['body'] = unxmlify($item->get_content()); @@ -187,19 +185,16 @@ function get_atom_elements($item) { function post_remote($a,$arr) { - $arr['hash'] = random_string(); + if(! x($arr,'type')) $arr['type'] = 'remote'; - $arr['remote-name'] = notags(trim($arr['remote-name'])); - $arr['remote-link'] = notags(trim($arr['remote-link'])); - $arr['remote-avatar'] = notags(trim($arr['remote-avatar'])); + $arr['uri'] = notags(trim($arr['uri'])); + $arr['author-name'] = notags(trim($arr['author-name'])); + $arr['author-link'] = notags(trim($arr['author-link'])); + $arr['author-avatar'] = notags(trim($arr['author-avatar'])); $arr['owner-name'] = notags(trim($arr['owner-name'])); $arr['owner-link'] = notags(trim($arr['owner-link'])); $arr['owner-avatar'] = notags(trim($arr['owner-avatar'])); - if(! strlen($arr['remote-avatar'])) - $arr['remote-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; - if(! strlen($arr['owner-avatar'])) - $arr['owner-avatar'] = $a->get_baseurl() . '/images/default-profile-sm.jpg'; $arr['created'] = datetime_convert('UTC','UTC',$arr['created'],'Y-m-d H:i:s'); $arr['edited'] = datetime_convert('UTC','UTC',$arr['edited'],'Y-m-d H:i:s'); $arr['title'] = notags(trim($arr['title'])); @@ -207,18 +202,7 @@ function post_remote($a,$arr) { $arr['last-child'] = intval($arr['last-child']); $arr['visible'] = 1; $arr['deleted'] = 0; - - $local_parent = false; - - if(isset($arr['parent_hash'])) { - $local_parent = true; - $parent = $arr['parent_hash']; - unset($arr['parent_hash']); - } - else { - $parent = $arr['parent_urn']; - unset($arr['parent_urn']); - } + $arr['parent-uri'] = notags(trim($arr['parent-uri'])); $parent_id = 0; @@ -230,24 +214,19 @@ dbg(3); . implode("', '", array_values($arr)) . "')" ); - if($local_parent) { - $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' AND `uid` = %d LIMIT 1", - dbesc($parent), - intval($arr['uid']) - ); - } - else { - $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", - dbesc($parent), - intval($arr['uid']) - ); - } + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + dbesc($arr['parent-uri']), + intval($arr['uid']) + ); + if(count($r)) $parent_id = $r[0]['id']; - + else { + // if parent is missing, what do we do? + } - $r = q("SELECT `id` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", - $arr['remote-id'], + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", + $arr['uri'], intval($arr['uid']) ); if(count($r)) diff --git a/include/notifier.php b/include/notifier.php index 68ff8a5c3c..76694f4aec 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -12,11 +12,12 @@ $db = new dba($db_host, $db_user, $db_pass, $db_data, $install); require_once("session.php"); require_once("datetime.php"); -dbg(3); + if($argc < 3) exit; - $baseurl = trim(hex2bin($argv[1])); + $baseurl = $argv[1]); + $a->set_baseurl($argv[1]); $cmd = $argv[2]; @@ -65,7 +66,8 @@ if($argc < 3) $parent = $items[0]; - if((strlen($parent['remote-id'])) && ($parent['type'] == 'remote')) { + if($parent['type'] == 'remote') { + // local followup to remote post $followup = true; $conversant_str = dbesc($parent['contact-id']); } @@ -94,7 +96,7 @@ if($argc < 3) $conversant_str = dbesc(implode(', ',$conversants)); } - $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) "); + $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 "); if( ! count($r)) killme(); @@ -111,9 +113,10 @@ if($argc < 3) $atom .= replace_macros($feed_template, array( - '$feed_id' => xmlify($baseurl), + '$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')) , + '$feed_updated' => xmlify(datetime_convert('UTC', 'UTC', + $updated . '+00:00' , 'Y-m-d\TH:i:s\Z')) , '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$photo' => xmlify($owner['photo']) @@ -126,12 +129,14 @@ if($argc < 3) '$name' => xmlify($owner['name']), '$profile_page' => xmlify($owner['url']), '$thumb' => xmlify($owner['thumb']), - '$item_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), + '$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' , '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']), - '$parent_id' => xmlify("{$items[0]['remote-id']}"), + '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => 0 )); } @@ -141,8 +146,9 @@ if($argc < 3) foreach($items as $item) { if($item['deleted']) { $atom .= replace_macros($tomb_template, array( - '$id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}"), - '$updated' => xmlify(datetime_convert('UTC', 'UTC', $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) + '$id' => xmlify($item['uri']), + '$updated' => xmlify(datetime_convert('UTC', 'UTC', + $item['edited'] . '+00:00' , 'Y-m-d\TH:i:s\Z')) )); } else { @@ -156,12 +162,14 @@ if($argc < 3) '$owner_name' => xmlify($item['owner-name']), '$owner_profile_page' => xmlify($item['owner-link']), '$owner_thumb' => xmlify($item['owner-avatar']), - '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$item_id' => xmlify($item['uri']), '$title' => xmlify($contact['name']), - '$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' , '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']), - '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'] && (! $contact['blocked']))) ? 1 : 0) + '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0) )); } else { @@ -169,12 +177,14 @@ if($argc < 3) '$name' => xmlify($contact['name']), '$profile_page' => xmlify($contact['url']), '$thumb' => xmlify($contact['thumb']), - '$item_id' => xmlify(((strlen($item['remote-id'])) ? $item['remote-id'] : "urn:X-dfrn:$baseurl:{$owner['uid']}:{$item['hash']}")), + '$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' , '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']), - '$parent_id' => xmlify("urn:X-dfrn:$baseurl:{$owner['uid']}:{$items[0]['hash']}"), + '$parent_id' => xmlify($item['parent-uri']), '$comment_allow' => (($item['last-child']) ? 1 : 0) )); } @@ -187,7 +197,7 @@ if($argc < 3) // create a clone of this feed but with comments disabled to send to those who can't respond. - $atom_nowrite = str_replace('1','0',$atom); + $atom_nowrite = str_replace('1','0',$atom); if($followup) @@ -206,7 +216,6 @@ if($argc < 3) foreach($r as $rr) { -echo "In delivery loop:"; if($rr['self']) continue; @@ -235,11 +244,8 @@ echo "In delivery loop:"; $postvars['data'] = $atom; else $postvars['data'] = $atom_nowrite; -echo "URL:" . $url; -echo "POSTVARS:" . print_r($postvars); - $xml = post_url($url,$postvars); -echo "XML response:" . $xml; + $xml = post_url($rr['notify'],$postvars); } diff --git a/include/poller.php b/include/poller.php index 8c3110746b..08028cdeed 100644 --- a/include/poller.php +++ b/include/poller.php @@ -89,7 +89,7 @@ echo "Length:" . strlen($xml) . "\r\n"; $rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0",'in-reply-to'); if(isset($rawthread[0]['attribs']['']['ref'])) { $is_reply = true; - $parent_urn = $rawthread[0]['attribs']['']['ref']; + $parent_uri = $rawthread[0]['attribs']['']['ref']; } @@ -99,7 +99,7 @@ echo "Length:" . strlen($xml) . "\r\n"; $item_id = $item->get_id(); - $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); @@ -107,7 +107,7 @@ echo "Length:" . strlen($xml) . "\r\n"; if(count($r)) { $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); if($allow && $allow[0]['data'] != $r[0]['last-child']) { - $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), dbesc($item_id), intval($importer['uid']) @@ -116,7 +116,7 @@ echo "Length:" . strlen($xml) . "\r\n"; continue; } $datarray = get_atom_elements($item); - $datarray['parent_urn'] = $parent_urn; + $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; $r = post_remote($a,$datarray); @@ -127,14 +127,14 @@ echo "Length:" . strlen($xml) . "\r\n"; // Head post of a conversation. Have we seen it? If not, import it. $item_id = $item->get_id(); - $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); if(count($r)) { $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); if($allow && $allow[0]['data'] != $r[0]['last-child']) { - $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), dbesc($item_id), intval($importer['uid']) @@ -144,7 +144,7 @@ echo "Length:" . strlen($xml) . "\r\n"; } $datarray = get_atom_elements($item); - $datarray['parent_urn'] = $item_id; + $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; $r = post_remote($a,$datarray); diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index ed2222d6aa..1d7ca3a505 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -54,7 +54,7 @@ dbg(3); $rawthread = $item->get_item_tags("http://purl.org/syndication/thread/1.0",'in-reply-to'); if(isset($rawthread[0]['attribs']['']['ref'])) { $is_reply = true; - $parent_urn = $rawthread[0]['attribs']['']['ref']; + $parent_uri = $rawthread[0]['attribs']['']['ref']; } @@ -64,7 +64,7 @@ dbg(3); $datarray = get_atom_elements($item); $urn = explode(':',$parent_urn); $datarray['type'] = 'remote-comment'; - $datarray['parent_hash'] = $urn[5]; + $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; $posted_id = post_remote($a,$datarray); @@ -84,7 +84,7 @@ dbg(3); intval($posted_id) ); - $url = bin2hex($a->get_baseurl()); + $url = $a->get_baseurl(); proc_close(proc_open("php include/notifier.php $url comment-import $posted_id > remote-notify.log &", array(),$foo)); @@ -97,7 +97,7 @@ dbg(3); $item_id = $item->get_id(); - $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); @@ -105,7 +105,7 @@ dbg(3); if(count($r)) { $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); if($allow && $allow[0]['data'] != $r[0]['last-child']) { - $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), dbesc($item_id), intval($importer['uid']) @@ -114,7 +114,7 @@ dbg(3); continue; } $datarray = get_atom_elements($item); - $datarray['parent_urn'] = $parent_urn; + $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; $r = post_remote($a,$datarray); @@ -125,14 +125,14 @@ dbg(3); // Head post of a conversation. Have we seen it? If not, import it. $item_id = $item->get_id(); - $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("SELECT `uid`, `last-child`, `edited` FROM `item` WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", dbesc($item_id), intval($importer['uid']) ); if(count($r)) { $allow = $item->get_item_tags('http://purl.org/macgirvin/dfrn/1.0','comment-allow'); if($allow && $allow[0]['data'] != $r[0]['last-child']) { - $r = q("UPDATE `item` SET `last-child` = %d WHERE `remote-id` = '%s' AND `uid` = %d LIMIT 1", + $r = q("UPDATE `item` SET `last-child` = %d WHERE `uri` = '%s' AND `uid` = %d LIMIT 1", intval($allow[0]['data']), dbesc($item_id), intval($importer['uid']) @@ -143,7 +143,7 @@ dbg(3); $datarray = get_atom_elements($item); - $datarray['parent_urn'] = $item_id; + $datarray['parent-uri'] = $item['uri'] $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; $r = post_remote($a,$datarray); diff --git a/mod/item.php b/mod/item.php index 1584c7ddbd..e0497af7a5 100644 --- a/mod/item.php +++ b/mod/item.php @@ -99,26 +99,28 @@ function item_post(&$a) { do { $dups = false; $hash = random_string(); - $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' LIMIT 1", - dbesc($hash)); + + $uri = "urn:X-dfrn:" . $a->get_hostname() . ':' . $profile_uid . ':' . $hash; + + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", + dbesc($uri)); if(count($r)) $dups = true; } while($dups == true); - $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `remote-id`, `created`,`edited`,`hash`,`body`, - `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) - VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", + $r = q("INSERT INTO `item` (`uid`,`type`,`contact-id`,`owner-name`,`owner-link`,`owner-avatar`, `created`, + `edited`, `uri`, `body`, `allow_cid`, `allow_gid`, `deny_cid`, `deny_gid`) + VALUES( %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s', '%s' )", intval($profile_uid), dbesc($_POST['type']), intval($contact_id), dbesc($contact_record['name']), dbesc($contact_record['url']), dbesc($contact_record['thumb']), - dbesc("urn:X-dfrn:" . $a->get_baseurl() . ':' . intval($profile_uid) . ':' . $hash), datetime_convert(), datetime_convert(), - dbesc($hash), + dbesc($uri), dbesc(escape_tags(trim($_POST['body']))), dbesc($str_contact_allow), dbesc($str_group_allow), @@ -126,8 +128,8 @@ function item_post(&$a) { dbesc($str_group_deny) ); - $r = q("SELECT `id` FROM `item` WHERE `hash` = '%s' LIMIT 1", - dbesc($hash)); + $r = q("SELECT `id` FROM `item` WHERE `uri` = '%s' LIMIT 1", + dbesc($uri)); if(count($r)) { $post_id = $r[0]['id']; @@ -154,13 +156,15 @@ function item_post(&$a) { $parent = $post_id; } - $r = q("UPDATE `item` SET `parent` = %d, `last-child` = 1, `visible` = 1 + $r = q("UPDATE `item` SET `parent` = %d, `parent-uri` = '%s', `last-child` = 1, `visible` = 1 WHERE `id` = %d LIMIT 1", intval($parent), - intval($post_id)); + dbesc(($parent == $post_id) ? $uri : $parent_item['uri']), + intval($post_id) + ); } - $url = bin2hex($a->get_baseurl()); + $url = $a->get_baseurl(); proc_close(proc_open("php include/notifier.php \"$url\" \"$notify_type\" \"$post_id\" > notify.log &", array(),$foo)); diff --git a/mod/network.php b/mod/network.php index aa662c79cc..3ccd8be485 100644 --- a/mod/network.php +++ b/mod/network.php @@ -92,7 +92,7 @@ function network_content(&$a) { $template = $wallwall; $commentww = 'ww'; } - if($item['type'] == 'remote' && ($item['owner-link'] != $item['remote-link'])) { + if($item['type'] == 'remote' && ($item['owner-link'] != $item['author-link'])) { // Could be anybody. $owner_url = $item['owner-link']; $owner_photo = $item['owner-avatar']; @@ -125,18 +125,18 @@ function network_content(&$a) { // Post was remotely authored. - $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); - $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $thumb); + $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); + $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $thumb); $profile_link = $profile_url; // Can we use our special contact URL for this author? - if(strlen($item['remote-link'])) { - if($item['remote-link'] == $item['url']) + if(strlen($item['author-link'])) { + if($item['author-link'] == $item['url']) $profile_link = $redirect_url; else - $profile_link = $item['remote-link']; + $profile_link = $item['author-link']; } // Build the HTML diff --git a/mod/profile.php b/mod/profile.php index f14cdbd111..7a3858ba26 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -141,9 +141,9 @@ function profile_content(&$a) { } $sql_extra = sprintf( " AND ( `allow_cid` = '' OR `allow_cid` REGEXP '<%d>' ) - AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' ) - AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' ) - AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ", + AND ( `deny_cid` = '' OR NOT `deny_cid` REGEXP '<%d>' ) + AND ( `allow_gid` = '' OR `allow_gid` REGEXP '%s' ) + AND ( `deny_gid` = '' OR NOT `deny_gid` REGEXP '%s') ", intval($_SESSION['visitor_id']), intval($_SESSION['visitor_id']), @@ -224,8 +224,8 @@ function profile_content(&$a) { // known to us and is reflected in the contact-id for this item. We can use the contact url or redirect rather than // use the link in the feed. This is different than on the network page where we may not know the author. - $profile_name = ((strlen($item['remote-name'])) ? $item['remote-name'] : $item['name']); - $profile_avatar = ((strlen($item['remote-avatar'])) ? $item['remote-avatar'] : $item['thumb']); + $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']); + $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']); $profile_link = $profile_url; $o .= replace_macros($template,array( -- 2.39.2 From bbe53699f26bfa4e4d17da097fd8f2fc14da47dd Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Mon, 19 Jul 2010 05:24:22 -0700 Subject: [PATCH 14/16] bug fixes --- include/auth.php | 8 ++++++++ include/notifier.php | 8 ++++---- include/poller.php | 4 ++-- mod/contacts.php | 12 ++++++------ mod/dfrn_request.php | 7 +++---- mod/home.php | 2 +- mod/item.php | 4 ++-- mod/login.php | 3 --- view/profile.php | 2 +- view/profile_tabs.tpl | 5 ++--- 10 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/auth.php b/include/auth.php index ef5c6f0b44..bbbe8eb0db 100644 --- a/include/auth.php +++ b/include/auth.php @@ -23,12 +23,20 @@ if((x($_SESSION,'authenticated')) && (! ($_POST['auth-params'] == 'login'))) { if(strlen($a->user['timezone'])) date_default_timezone_set($a->user['timezone']); + if(x($a->user,'nickname')) + $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['nickname']; + else + $_SESSION['my_url'] = $a->get_baseurl() . '/profile/' . $r[0]['uid']; + + + $r = q("SELECT * FROM `contact` WHERE `uid` = %s AND `self` = 1 LIMIT 1", intval($_SESSION['uid'])); if(count($r)) { $a->contact = $r[0]; $a->cid = $r[0]['id']; $_SESSION['cid'] = $a->cid; + } } } diff --git a/include/notifier.php b/include/notifier.php index 76694f4aec..b8eef3971f 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -15,8 +15,8 @@ require_once("datetime.php"); if($argc < 3) exit; - - $baseurl = $argv[1]); +dbg(3); + $baseurl = $argv[1]; $a->set_baseurl($argv[1]); $cmd = $argv[2]; @@ -224,7 +224,7 @@ if($argc < 3) $url = $rr['notify'] . '?dfrn_id=' . $rr['dfrn-id']; $xml = fetch_url($url); - +echo $xml; if(! $xml) continue; @@ -246,7 +246,7 @@ if($argc < 3) $postvars['data'] = $atom_nowrite; $xml = post_url($rr['notify'],$postvars); - +echo $xml; } killme(); diff --git a/include/poller.php b/include/poller.php index 08028cdeed..ab030a7091 100644 --- a/include/poller.php +++ b/include/poller.php @@ -118,7 +118,7 @@ echo "Length:" . strlen($xml) . "\r\n"; $datarray = get_atom_elements($item); $datarray['parent-uri'] = $parent_uri; $datarray['uid'] = $importer['uid']; - $datarray['contact-id'] = $importer['id']; + $datarray['contact-id'] = $contact['id']; $r = post_remote($a,$datarray); continue; } @@ -146,7 +146,7 @@ echo "Length:" . strlen($xml) . "\r\n"; $datarray = get_atom_elements($item); $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['uid']; - $datarray['contact-id'] = $importer['id']; + $datarray['contact-id'] = $contact['id']; $r = post_remote($a,$datarray); continue; diff --git a/mod/contacts.php b/mod/contacts.php index 999617aa19..585ac14232 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -184,7 +184,7 @@ function contacts_content(&$a) { return $o; } - +dbg(2); if(($a->argc == 2) && ($a->argv[1] == 'all')) $sql_extra = ''; else @@ -198,21 +198,21 @@ function contacts_content(&$a) { switch($sort_type) { case DIRECTION_BOTH : - $sql_extra = " AND `dfrn-id` != '' AND `issued-id` != '' "; + $sql_extra2 = " AND `dfrn-id` != '' AND `issued-id` != '' "; break; case DIRECTION_IN : - $sql_extra = " AND `dfrn-id` = '' AND `issued-id` != '' "; + $sql_extra2 = " AND `dfrn-id` = '' AND `issued-id` != '' "; break; case DIRECTION_OUT : - $sql_extra = " AND `dfrn-id` != '' AND `issued-id` = '' "; + $sql_extra2 = " AND `dfrn-id` != '' AND `issued-id` = '' "; break; case DIRECTION_ANY : default: - $sql_extra = ''; + $sql_extra2 = ''; break; } - $r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra $sql_extra2 ", intval($_SESSION['uid'])); if(count($r)) { diff --git a/mod/dfrn_request.php b/mod/dfrn_request.php index 7fb55c4bfe..b0c7b36aae 100644 --- a/mod/dfrn_request.php +++ b/mod/dfrn_request.php @@ -39,7 +39,6 @@ function dfrn_request_post(&$a) { // to confirm the request. We've done so and clicked submit, // which brings us here. - $dfrn_url = notags(trim($_POST['dfrn_url'])); $aes_allow = (((x($_POST,'aes_allow')) && ($_POST['aes_allow'] == 1)) ? 1 : 0); $confirm_key = ((x($_POST,'confirm_key')) ? $_POST['confirm_key'] : ""); @@ -48,7 +47,7 @@ function dfrn_request_post(&$a) { if(x($dfrn_url)) { - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `dfrn-url` = '%s' LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `url` = '%s' LIMIT 1", intval($_SESSION['uid']), dbesc($dfrn_url) ); @@ -88,7 +87,7 @@ function dfrn_request_post(&$a) { if($invalid) { notice( $invalid . ' required DFRN parameter' . (($invalid == 1) ? " was " : "s were " ) - . "not found at the given URL" . EOL ); + . "not found at the given URL" . EOL . print_r($parms,true)) ; return; } } @@ -220,7 +219,7 @@ function dfrn_request_post(&$a) { if($invalid) { notice( $invalid . ' required DFRN parameter' . (($invalid == 1) ? " was " : "s were " ) - . "not found at the given URL" . EOL) ; + . "not found at the given URL" . EOL . print_r($parms,true)) ; return; } diff --git a/mod/home.php b/mod/home.php index d796052ade..07087bb2cc 100644 --- a/mod/home.php +++ b/mod/home.php @@ -19,7 +19,7 @@ function home_content(&$a) { $a->page['footer'] .= "

Powered by DFRN
"; $o .= '

Welcome' . ((x($a->config,'sitename')) ? " to {$a->config['sitename']}" : "" ) . '

'; - $o .= login(($a->config['register_html'] == REGISTER_CLOSED) ? 0 : 1); + $o .= login(($a->config['register_policy'] == REGISTER_CLOSED) ? 0 : 1); return $o; diff --git a/mod/item.php b/mod/item.php index e0497af7a5..4de9dc59f8 100644 --- a/mod/item.php +++ b/mod/item.php @@ -5,7 +5,7 @@ function sanitise_acl(&$item) { } function item_post(&$a) { - +dbg(3); if((! local_user()) && (! remote_user())) return; @@ -170,6 +170,6 @@ function item_post(&$a) { array(),$foo)); } - goaway($a->get_baseurl() . "/" . $_POST['return'] ); +// goaway($a->get_baseurl() . "/" . $_POST['return'] ); return; // NOTREACHED } \ No newline at end of file diff --git a/mod/login.php b/mod/login.php index ba232a9432..6ee625966d 100644 --- a/mod/login.php +++ b/mod/login.php @@ -1,8 +1,5 @@ config['register_enabled']); return login(($a->config['register_policy'] == REGISTER_CLOSED) ? false : true); } \ No newline at end of file diff --git a/view/profile.php b/view/profile.php index d1e53ad56d..d95edb952e 100644 --- a/view/profile.php +++ b/view/profile.php @@ -29,7 +29,7 @@ || (strlen($profile['region'])) || (strlen($profile['postal-code'])) || (strlen($profile['country-name']))) { ?> - Location: +
Location:
diff --git a/view/profile_tabs.tpl b/view/profile_tabs.tpl index 052b2405ac..95c0ba1d27 100644 --- a/view/profile_tabs.tpl +++ b/view/profile_tabs.tpl @@ -1,4 +1,3 @@ -
@@ -6,11 +5,11 @@
-- 2.39.2 From 6695b4a203ab03941c8b3305a3e55cc02b85a5ac Mon Sep 17 00:00:00 2001 From: Mike Macgirvin Date: Mon, 19 Jul 2010 06:58:03 -0700 Subject: [PATCH 15/16] more bugs --- boot.php | 6 ++---- include/items.php | 4 ++-- include/notifier.php | 2 +- include/security.php | 2 +- mod/contacts.php | 6 +++--- mod/dfrn_confirm.php | 4 ++-- mod/dfrn_notify.php | 4 ++-- mod/dfrn_poll.php | 2 +- mod/item.php | 4 ++-- mod/network.php | 4 ++-- mod/profile.php | 4 ++-- mod/register.php | 4 ++-- view/acl_selectors.php | 4 +++- 13 files changed, 25 insertions(+), 25 deletions(-) diff --git a/boot.php b/boot.php index 1a60ee173d..56d85f6382 100644 --- a/boot.php +++ b/boot.php @@ -205,12 +205,10 @@ function notags($string) { return(str_replace(array("<",">","\xBA","\xBC","\xBE"), array('[',']','','',''), $string)); }} -// The PHP built-in tag escape function has traditionally been buggy if(! function_exists('escape_tags')) { function escape_tags($string) { - return(str_replace( - array('&', '"', "'", '<', '>'), - array('&', '"', ''', '<', '>'), $string)); + + return(htmlspecialchars($string)); }} if(! function_exists('login')) { diff --git a/include/items.php b/include/items.php index d583ffecc3..937fc39fd9 100644 --- a/include/items.php +++ b/include/items.php @@ -63,7 +63,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { `contact`.`id` AS `contact-id`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 + AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 AND `item`.`edited` > '%s' $sql_extra ORDER BY `parent` ASC, `created` ASC LIMIT 0, 300", @@ -114,7 +114,7 @@ function get_feed_for(&$a,$dfrn_id,$owner_id,$last_update) { '$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']), - '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'] && (! $contact['blocked']))) ? 1 : 0) + '$comment_allow' => (($item['last-child'] && strlen($contact['dfrn-id'])) ? 1 : 0) )); } else { diff --git a/include/notifier.php b/include/notifier.php index b8eef3971f..bd787dbfb8 100644 --- a/include/notifier.php +++ b/include/notifier.php @@ -96,7 +96,7 @@ dbg(3); $conversant_str = dbesc(implode(', ',$conversants)); } - $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 "); + $r = q("SELECT * FROM `contact` WHERE `id` IN ( $conversant_str ) AND `blocked` = 0 AND `pending` = 0"); if( ! count($r)) killme(); diff --git a/include/security.php b/include/security.php index 8b34525349..a71391dbac 100644 --- a/include/security.php +++ b/include/security.php @@ -6,7 +6,7 @@ function can_write_wall(&$a,$owner) { if((local_user()) && ($_SESSION['uid'] == $owner)) return true; - $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `id` = %d AND `blocked` = 0", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `id` = %d AND `blocked` = 0 AND `pending` = 0 LIMIT 1", intval($owner), intval($_SESSION['visitor_id']) ); diff --git a/mod/contacts.php b/mod/contacts.php index 585ac14232..4f48c1c3d5 100644 --- a/mod/contacts.php +++ b/mod/contacts.php @@ -119,7 +119,7 @@ function contacts_content(&$a) { $p['id']); } } - if($intval($contact_id)) + if(intval($contact_id)) q("DELETE FROM `item` WHERE `contact-id` = %d LIMIT 1", intval($contact_id) ); @@ -184,7 +184,7 @@ function contacts_content(&$a) { return $o; } -dbg(2); + if(($a->argc == 2) && ($a->argv[1] == 'all')) $sql_extra = ''; else @@ -212,7 +212,7 @@ dbg(2); break; } - $r = q("SELECT * FROM `contact` WHERE `uid` = %d $sql_extra $sql_extra2 ", + $r = q("SELECT * FROM `contact` WHERE `uid` = %d AND `pending` = 0 $sql_extra $sql_extra2 ", intval($_SESSION['uid'])); if(count($r)) { diff --git a/mod/dfrn_confirm.php b/mod/dfrn_confirm.php index e02fbf3d0a..1a3947d970 100644 --- a/mod/dfrn_confirm.php +++ b/mod/dfrn_confirm.php @@ -136,7 +136,7 @@ function dfrn_confirm_post(&$a) { $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; } - $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `blocked` = 0 WHERE `id` = %d LIMIT 1", + $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `blocked` = 0, `pending` = 0 WHERE `id` = %d LIMIT 1", dbesc($photo), dbesc($thumb), intval($dfrn_record) @@ -361,7 +361,7 @@ function dfrn_confirm_post(&$a) { $thumb = $a->get_baseurl() . '/images/default-profile-sm.jpg'; } - $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `blocked` = 0 WHERE `id` = %d LIMIT 1", + $r = q("UPDATE `contact` SET `photo` = '%s', `thumb` = '%s', `blocked` = 0, `pending` = 0 WHERE `id` = %d LIMIT 1", dbesc($photo), dbesc($thumb), intval($contact_id) diff --git a/mod/dfrn_notify.php b/mod/dfrn_notify.php index 1d7ca3a505..ead49982be 100644 --- a/mod/dfrn_notify.php +++ b/mod/dfrn_notify.php @@ -143,7 +143,7 @@ dbg(3); $datarray = get_atom_elements($item); - $datarray['parent-uri'] = $item['uri'] + $datarray['parent-uri'] = $item_id; $datarray['uid'] = $importer['uid']; $datarray['contact-id'] = $importer['id']; $r = post_remote($a,$datarray); @@ -176,7 +176,7 @@ function dfrn_notify_content(&$a) { intval(time() + 60 ) ); - $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 AND `pending` = 0 LIMIT 1", dbesc($_GET['dfrn_id'])); if((! count($r)) || (! strlen($r[0]['prvkey']))) $status = 1; diff --git a/mod/dfrn_poll.php b/mod/dfrn_poll.php index 6b4c50ad2e..e3da6c9526 100644 --- a/mod/dfrn_poll.php +++ b/mod/dfrn_poll.php @@ -165,7 +165,7 @@ function dfrn_poll_content(&$a) { dbesc($last_update) ); - $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 LIMIT 1", + $r = q("SELECT * FROM `contact` WHERE `issued-id` = '%s' AND `blocked` = 0 AND `pending` = 0 LIMIT 1", dbesc($_GET['dfrn_id'])); if((! count($r)) || (! strlen($r[0]['prvkey']))) $status = 1; diff --git a/mod/item.php b/mod/item.php index 4de9dc59f8..e0497af7a5 100644 --- a/mod/item.php +++ b/mod/item.php @@ -5,7 +5,7 @@ function sanitise_acl(&$item) { } function item_post(&$a) { -dbg(3); + if((! local_user()) && (! remote_user())) return; @@ -170,6 +170,6 @@ dbg(3); array(),$foo)); } -// goaway($a->get_baseurl() . "/" . $_POST['return'] ); + goaway($a->get_baseurl() . "/" . $_POST['return'] ); return; // NOTREACHED } \ No newline at end of file diff --git a/mod/network.php b/mod/network.php index 3ccd8be485..51b528832a 100644 --- a/mod/network.php +++ b/mod/network.php @@ -40,7 +40,7 @@ function network_content(&$a) { $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `contact`.`blocked` = 0 + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ", intval($_SESSION['uid']) ); @@ -54,7 +54,7 @@ function network_content(&$a) { `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `contact`.`blocked` = 0 + AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ORDER BY `parent` DESC, `created` ASC LIMIT %d ,%d ", intval($_SESSION['uid']), diff --git a/mod/profile.php b/mod/profile.php index 7a3858ba26..5cd13d5961 100644 --- a/mod/profile.php +++ b/mod/profile.php @@ -155,7 +155,7 @@ function profile_content(&$a) { $r = q("SELECT COUNT(*) AS `total` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 + AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ", intval($a->profile['uid']) @@ -171,7 +171,7 @@ function profile_content(&$a) { `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid` FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id` WHERE `item`.`uid` = %d AND `item`.`visible` = 1 AND `item`.`deleted` = 0 - AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 + AND `item`.`type` != 'remote' AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0 $sql_extra ORDER BY `parent` DESC, `id` ASC LIMIT %d ,%d ", intval($a->profile['uid']), diff --git a/mod/register.php b/mod/register.php index 2e5d02273a..53ead682f1 100644 --- a/mod/register.php +++ b/mod/register.php @@ -123,9 +123,9 @@ function register_post(&$a) { intval($newuid)); return; } - $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `photo`, `thumb`, `blocked`, `url`, + $r = q("INSERT INTO `contact` ( `uid`, `created`, `self`, `name`, `photo`, `thumb`, `blocked`, `pending`, `url`, `request`, `notify`, `poll`, `confirm` ) - VALUES ( %d, '%s', 1, '%s', '%s', '%s', 0, '%s', '%s', '%s', '%s', '%s' ) ", + VALUES ( %d, '%s', 1, '%s', '%s', '%s', 0, 0, '%s', '%s', '%s', '%s', '%s' ) ", intval($newuid), datetime_convert(), dbesc($username), diff --git a/view/acl_selectors.php b/view/acl_selectors.php index e3ee8c8792..09ce24d0e5 100644 --- a/view/acl_selectors.php +++ b/view/acl_selectors.php @@ -36,7 +36,9 @@ function contact_select($selname,$selclass,$preselected = false,$size = 4) { $o .= " + diff --git a/view/profile_edit.tpl b/view/profile_edit.tpl index 3dcf8df2cd..20b9a0993e 100644 --- a/view/profile_edit.tpl +++ b/view/profile_edit.tpl @@ -2,6 +2,10 @@ + + + + $default
diff --git a/view/profile_entry.tpl b/view/profile_entry.tpl index 9b3be79d31..db28c0a8fe 100644 --- a/view/profile_entry.tpl +++ b/view/profile_entry.tpl @@ -1,13 +1,10 @@
-Profile Image +Profile Image
+
$profile_name
-
-Edit Profile -Delete Profile -
diff --git a/view/profile_entry_default.tpl b/view/profile_entry_default.tpl index bd74b9c54b..e9bceba896 100644 --- a/view/profile_entry_default.tpl +++ b/view/profile_entry_default.tpl @@ -1,11 +1,9 @@
-Profile Image +Profile Image
+
$profile_name
-
-Edit Profile -
diff --git a/view/profile_listing_header.tpl b/view/profile_listing_header.tpl index ce052658dc..d4b139a698 100644 --- a/view/profile_listing_header.tpl +++ b/view/profile_listing_header.tpl @@ -1,6 +1,6 @@

Profiles

-Click photo to change profile image or use controls to edit/delete profile details. +Change profile photo