summaryrefslogtreecommitdiffstats
path: root/apps/bookmarks/bookmarksHelper.php
diff options
context:
space:
mode:
authorArthur Schiwon <blizzz@arthur-schiwon.de>2011-08-24 22:16:44 +0200
committerArthur Schiwon <blizzz@arthur-schiwon.de>2011-08-24 22:16:44 +0200
commit7cd592e055c8519d08cbfcb370572810b3edc96b (patch)
tree9bb4c4d79404ed176a925468e85f84a8d71d02d8 /apps/bookmarks/bookmarksHelper.php
parent365c4fdae24ea9f04f3c92f26182d148a8363776 (diff)
downloadnextcloud-server-7cd592e055c8519d08cbfcb370572810b3edc96b.tar.gz
nextcloud-server-7cd592e055c8519d08cbfcb370572810b3edc96b.zip
Added a Bookmarklet for the Bookmarks app
Diffstat (limited to 'apps/bookmarks/bookmarksHelper.php')
-rw-r--r--apps/bookmarks/bookmarksHelper.php22
1 files changed, 22 insertions, 0 deletions
diff --git a/apps/bookmarks/bookmarksHelper.php b/apps/bookmarks/bookmarksHelper.php
new file mode 100644
index 00000000000..be6ac098d0f
--- /dev/null
+++ b/apps/bookmarks/bookmarksHelper.php
@@ -0,0 +1,22 @@
+<?php
+
+function getURLMetadata($url) {
+ //allow only http(s) and (s)ftp
+ $protocols = '/^[hs]{0,1}[tf]{0,1}tp[s]{0,1}\:\/\//i';
+ //if not (allowed) protocol is given, assume http
+ if(preg_match($protocols, $url) == 0) {
+ $url = 'http://' . $url;
+ }
+
+ $page = file_get_contents($url);
+ @preg_match( "/<title>(.*)<\/title>/si", $page, $match );
+ $metadata['title'] = htmlentities(strip_tags(@$match[1]));
+
+ $meta = get_meta_tags($url);
+
+ if(array_key_exists('description', $meta)) {
+ $metadata['description'] = $meta['description'];
+ }
+
+ return $metadata;
+} \ No newline at end of file