]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
Url: introduce global helper functions for cleanup and scheme detection
[github/shaarli/Shaarli.git] / index.php
index e39cff38cbb40321295269820a2cab542e7f17ad..61d92f04d8fd1bc61dde6167bd56096a9efc318e 100755 (executable)
--- a/index.php
+++ b/index.php
@@ -1454,12 +1454,11 @@ function renderPage()
 
     // -------- User want to post a new link: Display link edit form.
     if (isset($_GET['post'])) {
-        $url = new Url($_GET['post']);
-        $url->cleanup();
+        $url = cleanup_url($_GET['post']);
 
         $link_is_new = false;
         // Check if URL is not already in database (in this case, we will edit the existing link)
-        $link = $LINKSDB->getLinkFromUrl((string)$url);
+        $link = $LINKSDB->getLinkFromUrl($url);
         if (!$link)
         {
             $link_is_new = true;
@@ -1471,7 +1470,7 @@ function renderPage()
             $tags = (empty($_GET['tags']) ? '' : $_GET['tags'] );
             $private = (!empty($_GET['private']) && $_GET['private'] === "1" ? 1 : 0);
             // If this is an HTTP(S) link, we try go get the page to extract the title (otherwise we will to straight to the edit form.)
-            if (empty($title) && strpos($url->getScheme(), 'http') !== false) {
+            if (empty($title) && strpos(get_url_scheme($url), 'http') !== false) {
                 // Short timeout to keep the application responsive
                 list($headers, $data) = get_http_url($url, 4);
                 // FIXME: Decode charset according to specified in either 1) HTTP response headers or 2) <head> in html
@@ -1505,7 +1504,7 @@ function renderPage()
             $link = array(
                 'linkdate' => $linkdate,
                 'title' => $title,
-                'url' => (string)$url,
+                'url' => $url,
                 'description' => $description,
                 'tags' => $tags,
                 'private' => $private