From 6c92b5ab86d7f0fee775c2c485f5264ac2b206be Mon Sep 17 00:00:00 2001 From: friendica Date: Thu, 20 Sep 2012 17:04:22 -0700 Subject: separate the public feed from everything else --- mod/events.php | 18 +++++++++++++++++- mod/feed.php | 39 +++++++++++++++++++++++++++++++++++++++ mod/parse_url.php | 26 ++++++++++++++++++-------- 3 files changed, 74 insertions(+), 9 deletions(-) create mode 100644 mod/feed.php (limited to 'mod') diff --git a/mod/events.php b/mod/events.php index bf02f8309..f950b5adc 100755 --- a/mod/events.php +++ b/mod/events.php @@ -141,6 +141,20 @@ function events_content(&$a) { return; } + if(($a->argc > 2) && ($a->argv[1] === 'ignore') && intval($a->argv[2])) { + $r = q("update event set ignore = 1 where id = %d and uid = %d limit 1", + intval($a->argv[2]), + intval(local_user()) + ); + } + + if(($a->argc > 2) && ($a->argv[1] === 'unignore') && intval($a->argv[2])) { + $r = q("update event set ignore = 0 where id = %d and uid = %d limit 1", + intval($a->argv[2]), + intval(local_user()) + ); + } + $htpl = get_markup_template('event_head.tpl'); $a->page['htmlhead'] .= replace_macros($htpl,array('$baseurl' => $a->get_baseurl())); @@ -154,6 +168,7 @@ function events_content(&$a) { $mode = 'view'; $y = 0; $m = 0; + $ignored = ((x($_REQUEST,'ignored')) ? intval($_REQUEST['ignored']) : 0); if($a->argc > 1) { if($a->argc > 2 && $a->argv[1] == 'event') { @@ -231,10 +246,11 @@ function events_content(&$a) { } else { $r = q("SELECT `event`.*, `item`.`id` AS `itemid`,`item`.`plink`, `item`.`author-name`, `item`.`author-avatar`, `item`.`author-link` FROM `event` LEFT JOIN `item` ON `item`.`event-id` = `event`.`id` - WHERE `event`.`uid` = %d + WHERE `event`.`uid` = %d and ignore = %d AND (( `adjust` = 0 AND `finish` >= '%s' AND `start` <= '%s' ) OR ( `adjust` = 1 AND `finish` >= '%s' AND `start` <= '%s' )) ", intval(local_user()), + intval($ignored), dbesc($start), dbesc($finish), dbesc($adjust_start), diff --git a/mod/feed.php b/mod/feed.php new file mode 100644 index 000000000..69d8fdb05 --- /dev/null +++ b/mod/feed.php @@ -0,0 +1,39 @@ + 1) { + $r = q("select * from entity where entity_address = '%s' limit 1", + dbesc(argv(1)) + ); + if(!($r && count($r))) + killme(); + + $channel = $r[0]; + + // check site and channel permissions + + if(!($channel['entity_r_stream'] & PERMS_PUBLIC)) + killme(); + + if((intval(get_config('system','block_public'))) && (! get_account_id())) + killme(); + + logger('mod_feed: public feed request from ' . $_SERVER['REMOTE_ADDR'] . ' for ' . $channel['entity_address']); + echo get_public_feed($channel,$params); + killme(); + } + +} + + diff --git a/mod/parse_url.php b/mod/parse_url.php index 083a39b55..9adee8f65 100644 --- a/mod/parse_url.php +++ b/mod/parse_url.php @@ -307,16 +307,26 @@ function parse_url_content(&$a) { $image = ""; - if(sizeof($siteinfo["images"]) > 0){ - /* - Execute below code only if image is present in siteinfo - */ - foreach ($siteinfo["images"] as $imagedata) - if($textmode) - $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]'; + if(sizeof($siteinfo["images"]) > 0){ + /* Execute below code only if image is present in siteinfo */ + + $total_images = 0; + $max_images = get_config('system','max_bookmark_images'); + if($max_images === false) + $max_images = 2; else - $image .= 'photo'; + $max_images = intval($max_images); + + foreach ($siteinfo["images"] as $imagedata) { + if($textmode) + $image .= '[img='.$imagedata["width"].'x'.$imagedata["height"].']'.$imagedata["src"].'[/img]' . "\n"; + else + $image .= 'photo
'; + $total_images ++; + if($max_images && $max_images >= $total_images) + break; } + } if(strlen($text)) { if($textmode) -- cgit v1.2.3