From f604f13d7da004b52c5858091aeecc678ee54082 Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Tue, 2 Feb 2016 20:57:19 +0100 Subject: [PATCH 1/3] New method to create a guid if none was given --- include/items.php | 43 ++++++++++++++++--------------------------- 1 file changed, 16 insertions(+), 27 deletions(-) diff --git a/include/items.php b/include/items.php index 21a0c414d..ff5d919c9 100644 --- a/include/items.php +++ b/include/items.php @@ -773,6 +773,18 @@ function item_add_language_opt(&$arr) { } } +function uri_to_guid($uri) { + $parsed = parse_url($uri); + $guid_prefix = hash("crc32", $parsed["host"]); + + unset($parsed["scheme"]); + + $host_id = implode("/", $parsed); + $host_hash = hash("ripemd128", $host_id); + + return $guid_prefix.$host_hash; +} + function item_store($arr,$force_parent = false, $notify = false, $dontcache = false) { // If it is a posting where users should get notifications, then define it as wall posting @@ -848,33 +860,6 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa } } - // If there is no guid then take the same guid that was taken before for the same uri - if ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "") AND (trim($arr['network']) != "")) { - logger('item_store: checking for an existing guid for uri '.$arr['uri'], LOGGER_DEBUG); - $r = q("SELECT `guid` FROM `guid` WHERE `uri` = '%s' AND `network` = '%s' LIMIT 1", - dbesc(trim($arr['uri'])), dbesc(trim($arr['network']))); - - if(count($r)) { - $arr['guid'] = $r[0]["guid"]; - logger('item_store: found guid '.$arr['guid'].' for uri '.$arr['uri'], LOGGER_DEBUG); - } - } - - // If there is no guid then take the same guid that was taken before for the same plink - if ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "") AND (trim($arr['network']) != "")) { - logger('item_store: checking for an existing guid for plink '.$arr['plink'], LOGGER_DEBUG); - $r = q("SELECT `guid`, `uri` FROM `guid` WHERE `plink` = '%s' AND `network` = '%s' LIMIT 1", - dbesc(trim($arr['plink'])), dbesc(trim($arr['network']))); - - if(count($r)) { - $arr['guid'] = $r[0]["guid"]; - logger('item_store: found guid '.$arr['guid'].' for plink '.$arr['plink'], LOGGER_DEBUG); - - if ($r[0]["uri"] != $arr['uri']) - logger('Different uri for same guid: '.$arr['uri'].' and '.$r[0]["uri"].' - this shouldnt happen!', LOGGER_DEBUG); - } - } - // Shouldn't happen but we want to make absolutely sure it doesn't leak from a plugin. // Deactivated, since the bbcode parser can handle with it - and it destroys posts with some smileys that contain "<" //if((strpos($arr['body'],'<') !== false) || (strpos($arr['body'],'>') !== false)) @@ -884,6 +869,10 @@ function item_store($arr,$force_parent = false, $notify = false, $dontcache = fa if ($notify) $guid_prefix = ""; + elseif ((trim($arr['guid']) == "") AND (trim($arr['plink']) != "")) + $arr['guid'] = uri_to_guid($arr['plink']); + elseif ((trim($arr['guid']) == "") AND (trim($arr['uri']) != "")) + $arr['guid'] = uri_to_guid($arr['uri']); else { $parsed = parse_url($arr["author-link"]); $guid_prefix = hash("crc32", $parsed["host"]); From 58c1f9a60f951b5dad39f33cce5fd7d5e2538ef6 Mon Sep 17 00:00:00 2001 From: rabuzarus <> Date: Wed, 3 Feb 2016 03:59:42 +0100 Subject: [PATCH 2/3] vier: use object-fit: cover for recent photos view --- view/theme/vier/style.css | 42 ++++++++++++++++++++++----------------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/view/theme/vier/style.css b/view/theme/vier/style.css index 16685e55e..e0abee837 100644 --- a/view/theme/vier/style.css +++ b/view/theme/vier/style.css @@ -2947,35 +2947,41 @@ a.mail-list-link { color: #999999; } +/* photo album page */ .photo-top-image-wrapper { - position: relative; - float: left; - margin-top: 15px; - margin-right: 15px; - width: 200px; height: 200px; - overflow: hidden; + position: relative; + float: left; + margin-top: 15px; + margin-right: 15px; + width: 200px; height: 200px; + overflow: hidden; } .photo-top-album-name { - width: 100%; - min-height: 2em; - position: absolute; - bottom: 0px; - padding: 0px 3px; - padding-top: 0.5em; - background-color: rgb(255, 255, 255); + width: 100%; + min-height: 2em; + position: absolute; + bottom: 0px; + padding: 0px 3px; + padding-top: 0.5em; + background-color: rgb(255, 255, 255); } #photo-top-end { - clear: both; + clear: both; } #photo-top-links { - margin-bottom: 30px; - margin-left: 30px; + margin-bottom: 30px; + margin-left: 30px; } #photos-upload-newalbum-div { - float: left; - width: 175px; + float: left; + width: 175px; +} +img.photo-top-photo { + width: 100%; + height: 100%; + object-fit: cover; } .menu-profile-list{ From 47d2e3b1424bdbc903a84ea94b9d3c7dfe4b5c9f Mon Sep 17 00:00:00 2001 From: Michael Vogel Date: Wed, 3 Feb 2016 05:00:26 +0100 Subject: [PATCH 3/3] Added some documentation --- include/items.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/items.php b/include/items.php index ff5d919c9..c149660fa 100644 --- a/include/items.php +++ b/include/items.php @@ -773,13 +773,25 @@ function item_add_language_opt(&$arr) { } } +/** + * @brief Creates an unique guid out of a given uri + * + * @param string $uri uri of an item entry + * @return string unique guid + */ function uri_to_guid($uri) { + + // Our regular guid routine is using this kind of prefix as well + // We have to avoid that different routines could accidentally create the same value $parsed = parse_url($uri); $guid_prefix = hash("crc32", $parsed["host"]); + // Remove the scheme to make sure that "https" and "http" doesn't make a difference unset($parsed["scheme"]); $host_id = implode("/", $parsed); + + // We could use any hash algorithm since it isn't a security issue $host_hash = hash("ripemd128", $host_id); return $guid_prefix.$host_hash;