diff options
Diffstat (limited to 'inc')
-rwxr-xr-x | inc/functions.php | 31 |
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 | |||
114 | function 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 |