diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 57 |
1 files changed, 25 insertions, 32 deletions
@@ -161,6 +161,7 @@ require_once 'application/HttpUtils.php'; | |||
161 | require_once 'application/LinkDB.php'; | 161 | require_once 'application/LinkDB.php'; |
162 | require_once 'application/LinkFilter.php'; | 162 | require_once 'application/LinkFilter.php'; |
163 | require_once 'application/LinkUtils.php'; | 163 | require_once 'application/LinkUtils.php'; |
164 | require_once 'application/NetscapeBookmarkUtils.php'; | ||
164 | require_once 'application/TimeZone.php'; | 165 | require_once 'application/TimeZone.php'; |
165 | require_once 'application/Url.php'; | 166 | require_once 'application/Url.php'; |
166 | require_once 'application/Utils.php'; | 167 | require_once 'application/Utils.php'; |
@@ -1584,44 +1585,36 @@ function renderPage() | |||
1584 | } | 1585 | } |
1585 | 1586 | ||
1586 | // -------- Export as Netscape Bookmarks HTML file. | 1587 | // -------- Export as Netscape Bookmarks HTML file. |
1587 | if ($targetPage == Router::$PAGE_EXPORT) | 1588 | if ($targetPage == Router::$PAGE_EXPORT) { |
1588 | { | 1589 | if (empty($_GET['selection'])) { |
1589 | if (empty($_GET['what'])) | ||
1590 | { | ||
1591 | $PAGE->assign('linkcount',count($LINKSDB)); | 1590 | $PAGE->assign('linkcount',count($LINKSDB)); |
1592 | $PAGE->renderPage('export'); | 1591 | $PAGE->renderPage('export'); |
1593 | exit; | 1592 | exit; |
1594 | } | 1593 | } |
1595 | $exportWhat=$_GET['what']; | ||
1596 | if (!array_intersect(array('all','public','private'),array($exportWhat))) die('What are you trying to export???'); | ||
1597 | 1594 | ||
1598 | header('Content-Type: text/html; charset=utf-8'); | 1595 | // export as bookmarks_(all|private|public)_YYYYmmdd_HHMMSS.html |
1599 | header('Content-disposition: attachment; filename=bookmarks_'.$exportWhat.'_'.strval(date('Ymd_His')).'.html'); | 1596 | $selection = $_GET['selection']; |
1600 | $currentdate=date('Y/m/d H:i:s'); | 1597 | try { |
1601 | echo <<<HTML | 1598 | $PAGE->assign( |
1602 | <!DOCTYPE NETSCAPE-Bookmark-file-1> | 1599 | 'links', |
1603 | <!-- This is an automatically generated file. | 1600 | NetscapeBookmarkUtils::filterAndFormat($LINKSDB, $selection) |
1604 | It will be read and overwritten. | 1601 | ); |
1605 | DO NOT EDIT! --> | 1602 | } catch (Exception $exc) { |
1606 | <!-- Shaarli {$exportWhat} bookmarks export on {$currentdate} --> | 1603 | header('Content-Type: text/plain; charset=utf-8'); |
1607 | <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8"> | 1604 | echo $exc->getMessage(); |
1608 | <TITLE>Bookmarks</TITLE> | 1605 | exit; |
1609 | <H1>Bookmarks</H1> | ||
1610 | HTML; | ||
1611 | foreach($LINKSDB as $link) | ||
1612 | { | ||
1613 | if ($exportWhat=='all' || | ||
1614 | ($exportWhat=='private' && $link['private']!=0) || | ||
1615 | ($exportWhat=='public' && $link['private']==0)) | ||
1616 | { | ||
1617 | $date = DateTime::createFromFormat(LinkDB::LINK_DATE_FORMAT, $link['linkdate']); | ||
1618 | echo '<DT><A HREF="'.$link['url'].'" ADD_DATE="'.$date->getTimestamp().'" PRIVATE="'.$link['private'].'"'; | ||
1619 | if ($link['tags']!='') echo ' TAGS="'.str_replace(' ',',',$link['tags']).'"'; | ||
1620 | echo '>'.$link['title']."</A>\n"; | ||
1621 | if ($link['description']!='') echo '<DD>'.$link['description']."\n"; | ||
1622 | } | ||
1623 | } | 1606 | } |
1624 | exit; | 1607 | $now = new DateTime(); |
1608 | header('Content-Type: text/html; charset=utf-8'); | ||
1609 | header( | ||
1610 | 'Content-disposition: attachment; filename=bookmarks_' | ||
1611 | .$selection.'_'.$now->format(LinkDB::LINK_DATE_FORMAT).'.html' | ||
1612 | ); | ||
1613 | $PAGE->assign('date', $now->format(DateTime::RFC822)); | ||
1614 | $PAGE->assign('eol', PHP_EOL); | ||
1615 | $PAGE->assign('selection', $selection); | ||
1616 | $PAGE->renderPage('export.bookmarks'); | ||
1617 | exit; | ||
1625 | } | 1618 | } |
1626 | 1619 | ||
1627 | // -------- User is uploading a file for import | 1620 | // -------- User is uploading a file for import |