From: Sébastien SAUVAGE Date: Fri, 29 Nov 2013 21:01:08 +0000 (-0800) Subject: Merge pull request #145 from Alkarex/patch-1 X-Git-Tag: v0.0.42beta~4 X-Git-Url: https://git.immae.eu/?a=commitdiff_plain;h=ab0638edb0b23e404e05c88c1029b98ad4dd9613;hp=-c;p=github%2Fshaarli%2FShaarli.git Merge pull request #145 from Alkarex/patch-1 smallHash: simplified and improved performance --- ab0638edb0b23e404e05c88c1029b98ad4dd9613 diff --combined index.php index 884b2afd,24fbe436..acc3fe49 --- a/index.php +++ b/index.php @@@ -221,7 -221,7 +221,7 @@@ function nl2br_escaped($html return str_replace('>','>',str_replace('<','<',nl2br($html))); } - /* Returns the small hash of a string + /* Returns the small hash of a string, using RFC 4648 base64url format eg. smallHash('20111006_131924') --> yZH23w Small hashes: - are unique (well, as unique as crc32, at last) @@@ -233,10 -233,7 +233,7 @@@ function smallHash($text) { $t = rtrim(base64_encode(hash('crc32',$text,true)),'='); - $t = str_replace('+','-',$t); // Get rid of characters which need encoding in URLs. - $t = str_replace('/','_',$t); - $t = str_replace('=','@',$t); - return $t; + return strtr($t, '+/', '-_'); } // In a string, converts urls to clickable links. @@@ -942,7 -939,7 +939,7 @@@ function showRSS( echo ''."\n\n"; $i++; } - echo ''; + echo ''; $cache->cache(ob_get_contents()); ob_end_flush(); @@@ -1027,7 -1024,7 +1024,7 @@@ function showATOM( $feed.=''.htmlspecialchars($pageaddr).''.htmlspecialchars($pageaddr).''; $feed.=''.htmlspecialchars($pageaddr).''."\n\n"; // Yes, I know I should use a real IRI (RFC3987), but the site URL will do. $feed.=$entries; - $feed.=''; + $feed.=''; echo $feed; $cache->cache(ob_get_contents()); @@@ -1104,7 -1101,7 +1101,7 @@@ function showDailyRSS( echo ''."\n\n\n"; } - echo ''; + echo ''; $cache->cache(ob_get_contents()); ob_end_flush(); @@@ -1747,11 -1744,11 +1744,11 @@@ function importFile( } $LINKSDB->savedb(); - echo ''; + echo ''; } else { - echo ''; + echo ''; } }