From 9aadcdaefaceec86c0610499e48bc41273f5d26f Mon Sep 17 00:00:00 2001 From: Emilien Klein Date: Wed, 21 Sep 2011 22:01:56 +0200 Subject: =?UTF-8?q?Version=200.0.15=20beta:=20-=20Bug=20corrected=20in=20i?= =?UTF-8?q?mport:=20HTML=20entities=20were=20not=20properly=20decoded.=20I?= =?UTF-8?q?f=20you=20imported=20your=20Delicious/Diigo=20bookmarks,=20your?= =?UTF-8?q?=20should=20import=20them=20again=20an=20use=20the=20'overwrite?= =?UTF-8?q?'=20option=20of=20the=20import=20feature.=20-=20Removed=20some?= =?UTF-8?q?=20parameters=20in=20URL=20added=20by=20some=20feed=20proxies?= =?UTF-8?q?=20(#xtor=3DRSS-=E2=80=A6)=20-=20On=20free.fr,=20automatic=20cr?= =?UTF-8?q?eation=20of=20the=20/sessions=20directory.=20-=20CSS=20Styleshe?= =?UTF-8?q?et=20is=20now=20an=20external=20file=20(shaarli.css).=20This=20?= =?UTF-8?q?reduces=20page=20size=20and=20eases=20customization.=20-=20New?= =?UTF-8?q?=20in=20import:=20Option=20to=20overwrite=20existing=20links=20?= =?UTF-8?q?when=20importing.=20-=20Bug=20corrected:=20Prevented=20loop=20o?= =?UTF-8?q?n=20login=20screen=20upon=20successful=20login=20after=20a=20fa?= =?UTF-8?q?iled=20login.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.php | 106 ++++++++++++++++-------------------------------------------- shaarli.css | 63 ++++++++++++++++++++++++++++++++++++ 2 files changed, 90 insertions(+), 79 deletions(-) create mode 100644 shaarli.css diff --git a/index.php b/index.php index 520d7d30..babce3dc 100644 --- a/index.php +++ b/index.php @@ -1,5 +1,5 @@ getLinkFromUrl($url); // Check if URL is not already in database (in this case, we will edit the existing link) @@ -853,7 +858,8 @@ Import Netscape html bookmarks (as exported from Firefox/Chrome/Opera/delicious/
-  Import all links as private +  Import all links as private
+  Overwrite existing links HTML; @@ -884,6 +890,8 @@ function importFile() $filesize=$_FILES['filetoupload']['size']; $data=file_get_contents($_FILES['filetoupload']['tmp_name']); $private = (empty($_POST['private']) ? 0 : 1); // Should the links be imported as private ? + $overwrite = !empty($_POST['overwrite']) ; // Should the imported links overwrite existing ones ? + $import_count=0; // Sniff file type: $type='unknown'; @@ -895,35 +903,35 @@ function importFile() // This is a standard Netscape-style bookmark file. // This format is supported by all browsers (except IE, of course), also delicious, diigo and others. // I didn't want to use DOM... anyway, this is FAST (less than 1 second to import 7200 links (2.1 Mb html file)). - $before=count($LINKSDB); foreach(explode('
',$data) as $html) // explode is very fast { $link = array('linkdate'=>'','title'=>'','url'=>'','description'=>'','tags'=>'','private'=>0); $d = explode('
',$html); if (startswith($d[0],'(.*?)!i',$d[0],$matches); $link['title'] = (isset($matches[1]) ? trim($matches[1]) : ''); // Get title + $link['title'] = html_entity_decode($link['title'],ENT_QUOTES,'UTF-8'); preg_match_all('! ([A-Z_]+)=\"(.*?)"!i',$html,$matches,PREG_SET_ORDER); // Get all other attributes foreach($matches as $m) { $attr=$m[1]; $value=$m[2]; - if ($attr=='HREF') $link['url']=$value; + if ($attr=='HREF') $link['url']=html_entity_decode($value,ENT_QUOTES,'UTF-8'); elseif ($attr=='ADD_DATE') $link['linkdate']=date('Ymd_His',intval($value)); elseif ($attr=='PRIVATE') $link['private']=($value=='0'?0:1); - elseif ($attr=='TAGS') $link['tags']=str_replace(',',' ',$value); + elseif ($attr=='TAGS') $link['tags']=html_entity_decode(str_replace(',',' ',$value),ENT_QUOTES,'UTF-8'); } - if ($link['linkdate']!='' && $link['url']!='' && empty($LINKSDB[$link['linkdate']])) + if ($link['linkdate']!='' && $link['url']!='' && ($overwrite || empty($LINKSDB[$link['linkdate']]))) { if ($private==1) $link['private']=1; $LINKSDB[$link['linkdate']] = $link; + $import_count++; } } } - $import_count = count($LINKSDB)-$before; $LINKSDB->savedb(); invalidateCaches(); - echo ''; + echo ''; } else { @@ -1095,70 +1103,9 @@ JS; {$open}Shaarli - Let's shaare your links... - + + {$jsincludes} -