From eae4f48bf0b4137ee4764d06678ba6e6a9c74978 Mon Sep 17 00:00:00 2001 From: Seb Sauvage Date: Wed, 21 Sep 2011 10:50:54 +0200 Subject: [PATCH] =?utf8?q?Version=200.0.15=20beta:=20-=20Bug=20corrected?= =?utf8?q?=20in=20import:=20HTML=20entities=20were=20not=20properly=20deco?= =?utf8?q?ded.=20If=20you=20imported=20your=20Delicious/Diigo=20bookmarks,?= =?utf8?q?=20your=20should=20import=20them=20again=20an=20use=20the=20'ove?= =?utf8?q?rwrite'=20option=20of=20the=20import=20feature.=20-=20Removed=20?= =?utf8?q?some=20parameters=20in=20URL=20added=20by=20some=20feed=20proxie?= =?utf8?q?s=20(#xtor=3DRSS-=E2=80=A6)=20-=20On=20free.fr,=20automatic=20cr?= =?utf8?q?eation=20of=20the=20/sessions=20directory.=20-=20CSS=20Styleshee?= =?utf8?q?t=20is=20now=20an=20external=20file=20(shaarli.css).=20This=20re?= =?utf8?q?duces=20page=20size=20and=20eases=20customization.=20-=20New=20i?= =?utf8?q?n=20import:=20Option=20to=20overwrite=20existing=20links=20when?= =?utf8?q?=20importing.=20-=20Bug=20corrected:=20Prevented=20loop=20on=20l?= =?utf8?q?ogin=20screen=20upon=20successful=20login=20after=20a=20failed?= =?utf8?q?=20login.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 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} -