aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
Diffstat (limited to 'index.php')
-rw-r--r--index.php36
1 files changed, 21 insertions, 15 deletions
diff --git a/index.php b/index.php
index dd876a66..1eaf70ce 100644
--- a/index.php
+++ b/index.php
@@ -690,7 +690,7 @@ class pageBuilder
690// This RSS feed cannot be filtered. 690// This RSS feed cannot be filtered.
691function showDailyRSS() { 691function showDailyRSS() {
692 // Cache system 692 // Cache system
693 $query = $_SERVER["QUERY_STRING"]; 693 $query = $_SERVER['QUERY_STRING'];
694 $cache = new CachedPage( 694 $cache = new CachedPage(
695 $GLOBALS['config']['PAGECACHE'], 695 $GLOBALS['config']['PAGECACHE'],
696 page_url($_SERVER), 696 page_url($_SERVER),
@@ -951,7 +951,7 @@ function renderPage()
951 exit; 951 exit;
952 } 952 }
953 // -------- User wants to logout. 953 // -------- User wants to logout.
954 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=logout')) 954 if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=logout'))
955 { 955 {
956 invalidateCaches($GLOBALS['config']['PAGECACHE']); 956 invalidateCaches($GLOBALS['config']['PAGECACHE']);
957 logout(); 957 logout();
@@ -1202,12 +1202,6 @@ function renderPage()
1202 exit; 1202 exit;
1203 } 1203 }
1204 1204
1205 // Same case as above except that user tried to access ?do=addlink without being logged in
1206 // Note: passing empty parameters makes Shaarli generate default URLs and descriptions.
1207 if (isset($_GET['do']) && $_GET['do'] === 'addlink') {
1208 header('Location: ?do=login&post=');
1209 exit;
1210 }
1211 showLinkList($PAGE, $LINKSDB); 1205 showLinkList($PAGE, $LINKSDB);
1212 if (isset($_GET['edit_link'])) { 1206 if (isset($_GET['edit_link'])) {
1213 header('Location: ?do=login&edit_link='. escape($_GET['edit_link'])); 1207 header('Location: ?do=login&edit_link='. escape($_GET['edit_link']));
@@ -1593,8 +1587,9 @@ function renderPage()
1593 exit; 1587 exit;
1594 } 1588 }
1595 1589
1596 // -------- Export as Netscape Bookmarks HTML file.
1597 if ($targetPage == Router::$PAGE_EXPORT) { 1590 if ($targetPage == Router::$PAGE_EXPORT) {
1591 // Export links as a Netscape Bookmarks file
1592
1598 if (empty($_GET['selection'])) { 1593 if (empty($_GET['selection'])) {
1599 $PAGE->assign('linkcount',count($LINKSDB)); 1594 $PAGE->assign('linkcount',count($LINKSDB));
1600 $PAGE->renderPage('export'); 1595 $PAGE->renderPage('export');
@@ -1603,10 +1598,21 @@ function renderPage()
1603 1598
1604 // export as bookmarks_(all|private|public)_YYYYmmdd_HHMMSS.html 1599 // export as bookmarks_(all|private|public)_YYYYmmdd_HHMMSS.html
1605 $selection = $_GET['selection']; 1600 $selection = $_GET['selection'];
1601 if (isset($_GET['prepend_note_url'])) {
1602 $prependNoteUrl = $_GET['prepend_note_url'];
1603 } else {
1604 $prependNoteUrl = false;
1605 }
1606
1606 try { 1607 try {
1607 $PAGE->assign( 1608 $PAGE->assign(
1608 'links', 1609 'links',
1609 NetscapeBookmarkUtils::filterAndFormat($LINKSDB, $selection) 1610 NetscapeBookmarkUtils::filterAndFormat(
1611 $LINKSDB,
1612 $selection,
1613 $prependNoteUrl,
1614 index_url($_SERVER)
1615 )
1610 ); 1616 );
1611 } catch (Exception $exc) { 1617 } catch (Exception $exc) {
1612 header('Content-Type: text/plain; charset=utf-8'); 1618 header('Content-Type: text/plain; charset=utf-8');
@@ -1627,7 +1633,7 @@ function renderPage()
1627 } 1633 }
1628 1634
1629 // -------- User is uploading a file for import 1635 // -------- User is uploading a file for import
1630 if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=upload')) 1636 if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=upload'))
1631 { 1637 {
1632 // If file is too big, some form field may be missing. 1638 // If file is too big, some form field may be missing.
1633 if (!isset($_POST['token']) || (!isset($_FILES)) || (isset($_FILES['filetoupload']['size']) && $_FILES['filetoupload']['size']==0)) 1639 if (!isset($_POST['token']) || (!isset($_FILES)) || (isset($_FILES['filetoupload']['size']) && $_FILES['filetoupload']['size']==0))
@@ -1730,7 +1736,7 @@ function importFile($LINKSDB)
1730 { 1736 {
1731 $link = array('linkdate'=>'','title'=>'','url'=>'','description'=>'','tags'=>'','private'=>0); 1737 $link = array('linkdate'=>'','title'=>'','url'=>'','description'=>'','tags'=>'','private'=>0);
1732 $d = explode('<DD>',$html); 1738 $d = explode('<DD>',$html);
1733 if (startswith($d[0],'<A ')) 1739 if (startsWith($d[0], '<A '))
1734 { 1740 {
1735 $link['description'] = (isset($d[1]) ? html_entity_decode(trim($d[1]),ENT_QUOTES,'UTF-8') : ''); // Get description (optional) 1741 $link['description'] = (isset($d[1]) ? html_entity_decode(trim($d[1]),ENT_QUOTES,'UTF-8') : ''); // Get description (optional)
1736 preg_match('!<A .*?>(.*?)</A>!i',$d[0],$matches); $link['title'] = (isset($matches[1]) ? trim($matches[1]) : ''); // Get title 1742 preg_match('!<A .*?>(.*?)</A>!i',$d[0],$matches); $link['title'] = (isset($matches[1]) ? trim($matches[1]) : ''); // Get title
@@ -2201,7 +2207,7 @@ function genThumbnail()
2201 2207
2202 // Is this a link to an image, or to a flickr page ? 2208 // Is this a link to an image, or to a flickr page ?
2203 $imageurl=''; 2209 $imageurl='';
2204 if (endswith(parse_url($url,PHP_URL_PATH),'.jpg')) 2210 if (endsWith(parse_url($url, PHP_URL_PATH), '.jpg'))
2205 { // This is a direct link to an image. e.g. http://farm1.staticflickr.com/5/5921913_ac83ed27bd_o.jpg 2211 { // This is a direct link to an image. e.g. http://farm1.staticflickr.com/5/5921913_ac83ed27bd_o.jpg
2206 preg_match('!(http://farm\d+\.staticflickr\.com/\d+/\d+_\w+_)\w.jpg!',$url,$matches); 2212 preg_match('!(http://farm\d+\.staticflickr\.com/\d+/\d+_\w+_)\w.jpg!',$url,$matches);
2207 if (!empty($matches[1])) $imageurl=$matches[1].'m.jpg'; 2213 if (!empty($matches[1])) $imageurl=$matches[1].'m.jpg';
@@ -2378,8 +2384,8 @@ function resizeImage($filepath)
2378 return true; 2384 return true;
2379} 2385}
2380 2386
2381if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. 2387if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database.
2382if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=dailyrss')) { showDailyRSS(); exit; } 2388if (isset($_SERVER['QUERY_STRING']) && startsWith($_SERVER['QUERY_STRING'], 'do=dailyrss')) { showDailyRSS(); exit; }
2383if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE']; 2389if (!isset($_SESSION['LINKS_PER_PAGE'])) $_SESSION['LINKS_PER_PAGE']=$GLOBALS['config']['LINKS_PER_PAGE'];
2384renderPage(); 2390renderPage();
2385?> 2391?>