aboutsummaryrefslogtreecommitdiffhomepage
path: root/inc
diff options
context:
space:
mode:
authornicosomb <nicolas@loeuillet.org>2013-04-15 09:04:23 +0200
committernicosomb <nicolas@loeuillet.org>2013-04-15 09:04:23 +0200
commit3c8d80aec5f5ba15910014bb4dcb48e948041ec9 (patch)
tree184309cb2e5ac888daa4ffc6450e2048064431c4 /inc
parent421b65ebaf928f1a75a2b3b3602b88fc0e094e8b (diff)
downloadwallabag-3c8d80aec5f5ba15910014bb4dcb48e948041ec9.tar.gz
wallabag-3c8d80aec5f5ba15910014bb4dcb48e948041ec9.tar.zst
wallabag-3c8d80aec5f5ba15910014bb4dcb48e948041ec9.zip
déplacement code dans functions.php
Diffstat (limited to 'inc')
-rwxr-xr-xinc/functions.php31
1 files changed, 31 insertions, 0 deletions
diff --git a/inc/functions.php b/inc/functions.php
index 37a56038..0b9eb936 100755
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -109,4 +109,35 @@ function get_external_file($url, $timeout)
109 else { 109 else {
110 return FALSE; 110 return FALSE;
111 } 111 }
112}
113
114function prepare_url($url)
115{
116 $parametres = array();
117 $url = html_entity_decode(trim($url));
118
119 // We remove the annoying parameters added by FeedBurner and GoogleFeedProxy (?utm_source=...)
120 // from shaarli, by sebsauvage
121 $i=strpos($url,'&utm_source='); if ($i!==false) $url=substr($url,0,$i);
122 $i=strpos($url,'?utm_source='); if ($i!==false) $url=substr($url,0,$i);
123 $i=strpos($url,'#xtor=RSS-'); if ($i!==false) $url=substr($url,0,$i);
124
125 $title = $url;
126 if (!preg_match('!^https?://!i', $url))
127 $url = 'http://' . $url;
128
129 $html = Encoding::toUTF8(get_external_file($url,15));
130 if (isset($html) and strlen($html) > 0)
131 {
132 $r = new Readability($html, $url);
133 if($r->init())
134 {
135 $title = $r->articleTitle->innerHTML;
136 }
137 }
138
139 $parametres['title'] = $title;
140 $parametres['content'] = $r->articleContent->innerHTML;
141
142 return $parametres;
112} \ No newline at end of file 143} \ No newline at end of file