aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2016-03-24 19:40:12 +0100
committerArthurHoaro <arthur@hoa.ro>2016-04-09 16:52:32 +0200
commit043eae70c4c57b0447b56a58b64ce9d102895396 (patch)
tree83a40e1f0096059bd9c7c13efbcfdeaa0ea06b5e /index.php
parent9486a2e92911c726673fe50674a0a408be3c774f (diff)
downloadShaarli-043eae70c4c57b0447b56a58b64ce9d102895396.tar.gz
Shaarli-043eae70c4c57b0447b56a58b64ce9d102895396.tar.zst
Shaarli-043eae70c4c57b0447b56a58b64ce9d102895396.zip
Fixes #480: add an option to urlencode redirector URL
* New config: `$GLOBALS['config']['REDIRECTOR_URLENCODE']` (default `true`). * Parameter added to LinkDB constructor. * Fixes a bug with urlencode and escaped url. * In `index.php`, LinkDB is now instanciate once for `importFile()` and `showDaily()`. * TU
Diffstat (limited to 'index.php')
-rw-r--r--index.php30
1 files changed, 11 insertions, 19 deletions
diff --git a/index.php b/index.php
index 735615ff..d3369a2d 100644
--- a/index.php
+++ b/index.php
@@ -100,6 +100,7 @@ $GLOBALS['config']['ENABLE_LOCALCACHE'] = true;
100$GLOBALS['config']['UPDATECHECK_BRANCH'] = 'stable'; 100$GLOBALS['config']['UPDATECHECK_BRANCH'] = 'stable';
101$GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400; 101$GLOBALS['config']['UPDATECHECK_INTERVAL'] = 86400;
102 102
103$GLOBALS['config']['REDIRECTOR_URLENCODE'] = true;
103 104
104/* 105/*
105 * Plugin configuration 106 * Plugin configuration
@@ -706,7 +707,8 @@ function showDailyRSS() {
706 $GLOBALS['config']['DATASTORE'], 707 $GLOBALS['config']['DATASTORE'],
707 isLoggedIn(), 708 isLoggedIn(),
708 $GLOBALS['config']['HIDE_PUBLIC_LINKS'], 709 $GLOBALS['config']['HIDE_PUBLIC_LINKS'],
709 $GLOBALS['redirector'] 710 $GLOBALS['redirector'],
711 $GLOBALS['config']['REDIRECTOR_URLENCODE']
710 ); 712 );
711 713
712 /* Some Shaarlies may have very few links, so we need to look 714 /* Some Shaarlies may have very few links, so we need to look
@@ -791,16 +793,10 @@ function showDailyRSS() {
791 * Show the 'Daily' page. 793 * Show the 'Daily' page.
792 * 794 *
793 * @param PageBuilder $pageBuilder Template engine wrapper. 795 * @param PageBuilder $pageBuilder Template engine wrapper.
796 * @param LinkDB $LINKSDB LinkDB instance.
794 */ 797 */
795function showDaily($pageBuilder) 798function showDaily($pageBuilder, $LINKSDB)
796{ 799{
797 $LINKSDB = new LinkDB(
798 $GLOBALS['config']['DATASTORE'],
799 isLoggedIn(),
800 $GLOBALS['config']['HIDE_PUBLIC_LINKS'],
801 $GLOBALS['redirector']
802 );
803
804 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD. 800 $day=Date('Ymd',strtotime('-1 day')); // Yesterday, in format YYYYMMDD.
805 if (isset($_GET['day'])) $day=$_GET['day']; 801 if (isset($_GET['day'])) $day=$_GET['day'];
806 802
@@ -892,7 +888,8 @@ function renderPage()
892 $GLOBALS['config']['DATASTORE'], 888 $GLOBALS['config']['DATASTORE'],
893 isLoggedIn(), 889 isLoggedIn(),
894 $GLOBALS['config']['HIDE_PUBLIC_LINKS'], 890 $GLOBALS['config']['HIDE_PUBLIC_LINKS'],
895 $GLOBALS['redirector'] 891 $GLOBALS['redirector'],
892 $GLOBALS['config']['REDIRECTOR_URLENCODE']
896 ); 893 );
897 894
898 $updater = new Updater( 895 $updater = new Updater(
@@ -1043,7 +1040,7 @@ function renderPage()
1043 1040
1044 // Daily page. 1041 // Daily page.
1045 if ($targetPage == Router::$PAGE_DAILY) { 1042 if ($targetPage == Router::$PAGE_DAILY) {
1046 showDaily($PAGE); 1043 showDaily($PAGE, $LINKSDB);
1047 } 1044 }
1048 1045
1049 // ATOM and RSS feed. 1046 // ATOM and RSS feed.
@@ -1638,7 +1635,7 @@ HTML;
1638 exit; 1635 exit;
1639 } 1636 }
1640 if (!tokenOk($_POST['token'])) die('Wrong token.'); 1637 if (!tokenOk($_POST['token'])) die('Wrong token.');
1641 importFile(); 1638 importFile($LINKSDB);
1642 exit; 1639 exit;
1643 } 1640 }
1644 1641
@@ -1707,15 +1704,10 @@ HTML;
1707 1704
1708// ----------------------------------------------------------------------------------------------- 1705// -----------------------------------------------------------------------------------------------
1709// Process the import file form. 1706// Process the import file form.
1710function importFile() 1707function importFile($LINKSDB)
1711{ 1708{
1712 if (!isLoggedIn()) { die('Not allowed.'); } 1709 if (!isLoggedIn()) { die('Not allowed.'); }
1713 $LINKSDB = new LinkDB( 1710
1714 $GLOBALS['config']['DATASTORE'],
1715 isLoggedIn(),
1716 $GLOBALS['config']['HIDE_PUBLIC_LINKS'],
1717 $GLOBALS['redirector']
1718 );
1719 $filename=$_FILES['filetoupload']['name']; 1711 $filename=$_FILES['filetoupload']['name'];
1720 $filesize=$_FILES['filetoupload']['size']; 1712 $filesize=$_FILES['filetoupload']['size'];
1721 $data=file_get_contents($_FILES['filetoupload']['tmp_name']); 1713 $data=file_get_contents($_FILES['filetoupload']['tmp_name']);