From c8bbe19b3fd2ba268c98561690de37fe599ff055 Mon Sep 17 00:00:00 2001 From: nicosomb Date: Fri, 12 Apr 2013 13:13:21 +0200 Subject: =?UTF-8?q?possibilit=C3=A9=20de=20mettre=20en=20fav=20ou=20en=20a?= =?UTF-8?q?rchive=20un=20article=20depuis=20la=20page=20article?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- inc/functions.php | 101 +++++++++++++++++------------------------------------- 1 file changed, 31 insertions(+), 70 deletions(-) (limited to 'inc/functions.php') diff --git a/inc/functions.php b/inc/functions.php index 6fa5a17a..37a56038 100755 --- a/inc/functions.php +++ b/inc/functions.php @@ -1,32 +1,46 @@ assign( "url", $url); - $tpl->assign( "title", $title); - $tpl->assign( "content", $content); + $tpl->assign("id", $entry['id']); + $tpl->assign("url", $entry['url']); + $tpl->assign("title", $entry['title']); + $tpl->assign("content", $entry['content']); + $tpl->assign("is_fav", $entry['is_fav']); + $tpl->assign("is_read", $entry['is_read']); - $tpl->draw( "index"); // draw the template + $tpl->draw( "index"); } // function define to retrieve url content -function get_external_file($url, $timeout) { +function get_external_file($url, $timeout) +{ // spoofing FireFox 18.0 $useragent="Mozilla/5.0 (Windows NT 5.1; rv:18.0) Gecko/20100101 Firefox/18.0"; @@ -95,57 +109,4 @@ function get_external_file($url, $timeout) { else { return FALSE; } -} - -function rel2abs($rel, $base) -{ - /* return if already absolute URL */ - if (parse_url($rel, PHP_URL_SCHEME) != '') return $rel; - - /* queries and anchors */ - if ($rel[0]=='#' || $rel[0]=='?') return $base.$rel; - - /* parse base URL and convert to local variables: - $scheme, $host, $path */ - extract(parse_url($base)); - - /* remove non-directory element from path */ - $path = preg_replace('#/[^/]*$#', '', $path); - - /* destroy path if relative url points to root */ - if ($rel[0] == '/') $path = ''; - - /* dirty absolute URL */ - $abs = "$host$path/$rel"; - - /* replace '//' or '/./' or '/foo/../' with '/' */ - $re = array('#(/\.?/)#', '#/(?!\.\.)[^/]+/\.\./#'); - for($n=1; $n>0; $abs=preg_replace($re, '/', $abs, -1, $n)) {} - - /* absolute URL is ready! */ - return $scheme.'://'.$abs; -} - -// $str=preg_replace('#(href|src)="([^:"]*)("|(?:(?:%20|\s|\+)[^"]*"))#','$1="http://wintermute.com.au/$2$3',$str); - -function absolutes_links($data, $base) { - // cherche les balises 'a' qui contiennent un href - $matches = array(); - preg_match_all('#(href|src)="([^:"]*)("|(?:(?:%20|\s|\+)[^"]*"))#Si', $data, $matches, PREG_SET_ORDER); - - // ne conserve que les liens ne commençant pas par un protocole « protocole:// » ni par une ancre « # » - foreach($matches as $i => $link) { - $link[1] = trim($link[1]); - - if (!preg_match('#^(([a-z]+://)|(\#))#', $link[1]) ) { - - $absolutePath=rel2abs($link[2],$base); - - $data = str_replace($matches[$i][2], $absolutePath, $data); - } - - } - return $data; -} - -?> \ No newline at end of file +} \ No newline at end of file -- cgit v1.2.3