diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/bbcode.php | 1 | ||||
-rw-r--r-- | include/channel.php | 6 | ||||
-rw-r--r-- | include/event.php | 6 | ||||
-rw-r--r-- | include/follow.php | 2 | ||||
-rwxr-xr-x | include/items.php | 19 | ||||
-rw-r--r-- | include/nav.php | 2 | ||||
-rw-r--r-- | include/opengraph.php | 75 | ||||
-rw-r--r-- | include/zot.php | 9 |
8 files changed, 109 insertions, 11 deletions
diff --git a/include/bbcode.php b/include/bbcode.php index 485a1f5b2..bb9144b1d 100644 --- a/include/bbcode.php +++ b/include/bbcode.php @@ -1346,6 +1346,7 @@ function bbcode($Text, $options = []) { $Text = preg_replace("/\[event\-finish\](.*?)\[\/event\-finish\]/ism",'',$Text); $Text = preg_replace("/\[event\-id\](.*?)\[\/event\-id\]/ism",'',$Text); $Text = preg_replace("/\[event\-location\](.*?)\[\/event\-location\]/ism",'',$Text); + $Text = preg_replace("/\[event\-timezone\](.*?)\[\/event\-timezone\]/ism",'',$Text); $Text = preg_replace("/\[event\-adjust\](.*?)\[\/event\-adjust\]/ism",'',$Text); $Text = str_replace("\0",'$',$Text); diff --git a/include/channel.php b/include/channel.php index 5d583e4f1..29835eac6 100644 --- a/include/channel.php +++ b/include/channel.php @@ -2254,19 +2254,19 @@ function get_zcard($channel, $observer_hash = '', $args = array()) { $cover_width = 425; $size = 'hz_small'; $cover_size = PHOTO_RES_COVER_425; - $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 80 , 'height' => 80, 'href' => $channel['xchan_photo_m'].'?rev='.strtotime($channel['xchan_photo_date'])); } elseif($maxwidth <= 900) { $width = 900; $cover_width = 850; $size = 'hz_medium'; $cover_size = PHOTO_RES_COVER_850; - $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 160 , 'height' => 160, 'href' => $channel['xchan_photo_l'].'?rev='.strtotime($channel['xchan_photo_date'])); } elseif($maxwidth <= 1200) { $width = 1200; $cover_width = 1200; $size = 'hz_large'; $cover_size = PHOTO_RES_COVER_1200; - $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l']); + $pphoto = array('mimetype' => $channel['xchan_photo_mimetype'], 'width' => 300 , 'height' => 300, 'href' => $channel['xchan_photo_l'].'?rev='.strtotime($channel['xchan_photo_date'])); } // $scale = (float) $maxwidth / $width; diff --git a/include/event.php b/include/event.php index 6689919cf..6be1b6705 100644 --- a/include/event.php +++ b/include/event.php @@ -276,6 +276,9 @@ function format_event_bbcode($ev) { if($ev['event_hash']) $o .= '[event-id]' . $ev['event_hash'] . '[/event-id]'; + if($ev['timezone']) + $o .= '[event-timezone]' . $ev['timezone'] . '[/event-timezone]'; + if($ev['adjust']) $o .= '[event-adjust]' . $ev['adjust'] . '[/event-adjust]'; @@ -324,6 +327,9 @@ function bbtoevent($s) { if(preg_match("/\[event\-id\](.*?)\[\/event\-id\]/is",$s,$match)) $ev['event_hash'] = $match[1]; $match = ''; + if(preg_match("/\[event\-timezone\](.*?)\[\/event\-timezone\]/is",$s,$match)) + $ev['timezone'] = $match[1]; + $match = ''; if(preg_match("/\[event\-adjust\](.*?)\[\/event\-adjust\]/is",$s,$match)) $ev['adjust'] = $match[1]; if(array_key_exists('dtstart',$ev)) { diff --git a/include/follow.php b/include/follow.php index 50b952881..a4d382545 100644 --- a/include/follow.php +++ b/include/follow.php @@ -142,7 +142,7 @@ function new_contact($uid,$url,$channel,$interactive = false, $confirm = false) $sql_options = (($protocol) ? " and xchan_network = '" . dbesc($protocol) . "' " : ''); - $r = q("select * from xchan where xchan_hash = '%s' or xchan_url = '%s' $sql_options ", + $r = q("select * from xchan where (xchan_addr = '%s' or xchan_url = '%s') $sql_options ", dbesc($url), dbesc($url) ); diff --git a/include/items.php b/include/items.php index 6786b8b05..917808ad5 100755 --- a/include/items.php +++ b/include/items.php @@ -206,6 +206,25 @@ function collect_recipients($item, &$private_envelope,$include_groups = true) { } function comments_are_now_closed($item) { + + $x = [ + 'item' => $item, + 'closed' => 'unset' + ]; + + /** + * @hooks comments_are_now_closed + * Called to determine whether commenting should be closed + * * \e array \b item + * * \e boolean \b closed - return value + */ + + call_hooks('comments_are_now_closed', $x); + + if ($x['closed'] != 'unset') { + return $x['closed']; + } + if($item['comments_closed'] > NULL_DATE) { $d = datetime_convert(); if($d > $item['comments_closed']) diff --git a/include/nav.php b/include/nav.php index 3e1acd306..672cc2689 100644 --- a/include/nav.php +++ b/include/nav.php @@ -80,7 +80,7 @@ function nav($template = 'default') { if($observer) { $userinfo = [ - 'icon' => $observer['xchan_photo_m'], + 'icon' => $observer['xchan_photo_m'].'?rev='.strtotime($observer['xchan_photo_date']), 'name' => $observer['xchan_addr'], ]; } diff --git a/include/opengraph.php b/include/opengraph.php new file mode 100644 index 000000000..ba97d4f4f --- /dev/null +++ b/include/opengraph.php @@ -0,0 +1,75 @@ +<?php +/** + * @file include/opengraph.php + * @brief Add Opengraph metadata and related functions. + */ + + + /** + * @brief Adds Opengraph meta tags into HTML head + * + * @param array $item + * @param array $profile + * + */ + + function opengraph_add_meta($item, $profile) { + + if(! empty($item)) { + + if(! empty($item['title'])) + $ogtitle = $item['title']; + + // find first image if exist + if(preg_match("/\[[zi]mg(=[0-9]+x[0-9]+)?\]([^\[]+)/is", $item['body'], $matches)) { + $ogimage = $matches[2]; + $ogimagetype = guess_image_type($ogimage); + } + + // use summary as description if exist + $ogdesc = (empty($item['summary']) ? $item['body'] : $item['summary'] ); + + $ogdesc = str_replace("#^[", "[", $ogdesc); + + $ogdesc = bbcode($ogdesc, [ 'tryoembed' => false ]); + $ogdesc = trim(html2plain($ogdesc, 0, true)); + $ogdesc = html_entity_decode($ogdesc, ENT_QUOTES, 'UTF-8'); + + // remove all URLs + $ogdesc = preg_replace("/https?\:\/\/[a-zA-Z0-9\:\/\-\?\&\;\.\=\_\~\#\%\$\!\+\,\@]+/", "", $ogdesc); + + // shorten description + $ogdesc = substr($ogdesc, 0, 300); + $ogdesc = str_replace("\n", " ", $ogdesc); + while (strpos($ogdesc, " ") !== false) + $ogdesc = str_replace(" ", " ", $ogdesc); + $ogdesc = rtrim(substr($ogdesc, 0, strrpos($ogdesc, " ")), "?.,:;!-") . "..."; + + $ogtype = "article"; + } + + $channel = channelx_by_n($profile['profile_uid']); + + if(! isset($ogdesc)) { + if($profile['about'] && perm_is_allowed($channel['channel_id'],get_observer_hash(),'view_profile')) { + $ogdesc = $profile['about']; + } + else { + $ogdesc = sprintf( t('This is the home page of %s.'), $channel['channel_name']); + } + } + + if(! isset($ogimage)) { + $ogimage = $channel['xchan_photo_l']; + $ogimagetype = $channel['xchan_photo_mimetype']; + } + + App::$page['htmlhead'] .= '<meta property="og:title" content="' . htmlspecialchars((isset($ogtitle) ? $ogtitle : $channel['channel_name'])) . '">' . "\r\n"; + App::$page['htmlhead'] .= '<meta property="og:image" content="' . $ogimage . '">' . "\r\n"; + App::$page['htmlhead'] .= '<meta property="og:image:type" content="' . $ogimagetype . '">' . "\r\n"; + App::$page['htmlhead'] .= '<meta property="og:description" content="' . htmlspecialchars($ogdesc) . '">' . "\r\n"; + App::$page['htmlhead'] .= '<meta property="og:type" content="' . (isset($ogtype) ? $ogtype : "profile") . '">' . "\r\n"; + + return true; + } +
\ No newline at end of file diff --git a/include/zot.php b/include/zot.php index bd85dd755..d08146287 100644 --- a/include/zot.php +++ b/include/zot.php @@ -1776,17 +1776,14 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ $DR = new Zotlabs\Lib\DReport(z_root(),$sender['hash'],$d['hash'],$arr['mid']); - $r = q("select * from channel where channel_hash = '%s' limit 1", - dbesc($d['hash']) - ); + $channel = channelx_by_hash($d['hash']); - if(! $r) { + if(! $channel) { $DR->update('recipient not found'); $result[] = $DR->get(); continue; } - $channel = $r[0]; $DR->set_name($channel['channel_name'] . ' <' . channel_reddress($channel) . '>'); /* blacklisted channels get a permission denied, no special message to tip them off */ @@ -2032,7 +2029,7 @@ function process_delivery($sender, $arr, $deliveries, $relay, $public = false, $ // if it's a sourced post, call the post_local hooks as if it were // posted locally so that crosspost connectors will be triggered. - if(check_item_source($arr['uid'], $arr)) { + if(check_item_source($arr['uid'], $arr) || ($channel['xchan_pubforum'] == 1)) { /** * @hooks post_local * Called when an item has been posted on this machine via mod/item.php (also via API). |