Skip to content

A free, self-hostable news aggregator…

Fusion 0.7-dev

Alkarex24d9d1628d67
diff --cc lib/lib_rss.php
index a27994e94,a1fadcb24..dda576b98
--- a/lib/lib_rss.php
+++ b/lib/lib_rss.php
@@@ -169,53 -275,37 +275,50 @@@ function get_content_by_parsing ($url,
}
}
- /* Télécharge le favicon d'un site, le place sur le serveur et retourne l'URL */
- function dowload_favicon ($website, $id) {
- $url = 'http://g.etfv.co/' . $website;
- $favicons_dir = PUBLIC_PATH . '/data/favicons';
- $dest = $favicons_dir . '/' . $id . '.ico';
- $favicon_url = '/data/favicons/' . $id . '.ico';
-
- if (!is_dir ($favicons_dir)) {
- if (!mkdir ($favicons_dir, 0755, true)) {
- return $url;
- }
- }
-
- if (!file_exists ($dest)) {
- $c = curl_init ($url);
- curl_setopt ($c, CURLOPT_HEADER, false);
- curl_setopt ($c, CURLOPT_RETURNTRANSFER, true);
- curl_setopt ($c, CURLOPT_BINARYTRANSFER, true);
- $imgRaw = curl_exec ($c);
+ /**
+ * Add support of image lazy loading
+ * Move content from src attribute to data-original
+ * @param content is the text we want to parse
+ */
+ function lazyimg($content) {
+ return preg_replace(
+ '/<img([^>]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i',
+ '<img$1src="' . Minz_Url::display('/themes/icons/grey.gif') . '" data-original="$2"$3>',
+ $content
+ );
+ }
- if (curl_getinfo ($c, CURLINFO_HTTP_CODE) == 200) {
- $file = fopen ($dest, 'w');
- if ($file === false) {
- return $url;
- }
+ function lazyIframe($content) {
+ return preg_replace(
+ '/<iframe([^>]+?)src=[\'"]([^"\']+)[\'"]([^>]*)>/i',
+ '<iframe$1src="about:blank" data-original="$2"$3>',
+ $content
+ );
+ }
- fwrite ($file, $imgRaw);
- fclose ($file);
- } else {
- return $url;
- }
+ function uTimeString() {
+ $t = @gettimeofday();
+ return $t['sec'] . str_pad($t['usec'], 6, '0');
+ }
- curl_close ($c);
- }
+ function uSecString() {
+ $t = @gettimeofday();
+ return str_pad($t['usec'], 6, '0');
+ }
- return $favicon_url;
+ function invalidateHttpCache() {
+ file_put_contents(DATA_PATH . '/touch.txt', uTimeString());
}
+
+/**
+ * Add support of image lazy loading
+ * Move content from src attribute to data-original
+ * @param content is the text we want to parse
+ */
+function lazyimg($content) {
+ return preg_replace(
+ '/<img([^<]+)src=([\'"])([^"\']*)([\'"])([^<]*)>/i',
+ '<img$1src="' . Url::display('/data/grey.gif') . '" data-original="$3"$5>',
+ $content
+ );
+}