aboutsummaryrefslogtreecommitdiffhomepage
path: root/index.php
diff options
context:
space:
mode:
authorVirtualTam <virtualtam@flibidi.net>2015-06-24 23:01:21 +0200
committerVirtualTam <virtualtam@flibidi.net>2015-06-24 23:26:52 +0200
commit9c8752a2061e67c719125edb6e0d6717d1af8553 (patch)
treed7f05ff1ce871105bb44625baeacc8e8b2bfec2b /index.php
parent64bc92e3ac8f5e66d2bc14206ede31e6679d8c13 (diff)
downloadShaarli-9c8752a2061e67c719125edb6e0d6717d1af8553.tar.gz
Shaarli-9c8752a2061e67c719125edb6e0d6717d1af8553.tar.zst
Shaarli-9c8752a2061e67c719125edb6e0d6717d1af8553.zip
LinkDB: do not access global variables
Relates to #218 Removes "hidden" access to the following variables: - $GLOBALS['config']['datastore'] - PHPPREFIX - PHPSUFFIX Signed-off-by: VirtualTam <virtualtam@flibidi.net>
Diffstat (limited to 'index.php')
-rw-r--r--index.php8
1 files changed, 6 insertions, 2 deletions
diff --git a/index.php b/index.php
index 96a601de..bbe302a6 100644
--- a/index.php
+++ b/index.php
@@ -41,8 +41,6 @@ $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false;
41if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php'); 41if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php');
42 42
43define('shaarli_version','0.0.45beta'); 43define('shaarli_version','0.0.45beta');
44define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in PHP code.
45define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in PHP code.
46// http://server.com/x/shaarli --> /shaarli/ 44// http://server.com/x/shaarli --> /shaarli/
47define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0))); 45define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0)));
48 46
@@ -700,6 +698,7 @@ function showRSS()
700 698
701 // If cached was not found (or not usable), then read the database and build the response: 699 // If cached was not found (or not usable), then read the database and build the response:
702 $LINKSDB = new LinkDB( 700 $LINKSDB = new LinkDB(
701 $GLOBALS['config']['DATASTORE'],
703 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], 702 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
704 $GLOBALS['config']['HIDE_PUBLIC_LINKS'] 703 $GLOBALS['config']['HIDE_PUBLIC_LINKS']
705 ); 704 );
@@ -780,6 +779,7 @@ function showATOM()
780 779
781// Read links from database (and filter private links if used it not logged in). 780// Read links from database (and filter private links if used it not logged in).
782 $LINKSDB = new LinkDB( 781 $LINKSDB = new LinkDB(
782 $GLOBALS['config']['DATASTORE'],
783 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], 783 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
784 $GLOBALS['config']['HIDE_PUBLIC_LINKS'] 784 $GLOBALS['config']['HIDE_PUBLIC_LINKS']
785 ); 785 );
@@ -866,6 +866,7 @@ function showDailyRSS()
866 866
867// Read links from database (and filter private links if used it not logged in). 867// Read links from database (and filter private links if used it not logged in).
868 $LINKSDB = new LinkDB( 868 $LINKSDB = new LinkDB(
869 $GLOBALS['config']['DATASTORE'],
869 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], 870 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
870 $GLOBALS['config']['HIDE_PUBLIC_LINKS'] 871 $GLOBALS['config']['HIDE_PUBLIC_LINKS']
871 ); 872 );
@@ -937,6 +938,7 @@ function showDailyRSS()
937function showDaily() 938function showDaily()
938{ 939{
939 $LINKSDB = new LinkDB( 940 $LINKSDB = new LinkDB(
941 $GLOBALS['config']['DATASTORE'],
940 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], 942 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
941 $GLOBALS['config']['HIDE_PUBLIC_LINKS'] 943 $GLOBALS['config']['HIDE_PUBLIC_LINKS']
942 ); 944 );
@@ -1006,6 +1008,7 @@ function showDaily()
1006function renderPage() 1008function renderPage()
1007{ 1009{
1008 $LINKSDB = new LinkDB( 1010 $LINKSDB = new LinkDB(
1011 $GLOBALS['config']['DATASTORE'],
1009 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], 1012 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
1010 $GLOBALS['config']['HIDE_PUBLIC_LINKS'] 1013 $GLOBALS['config']['HIDE_PUBLIC_LINKS']
1011 ); 1014 );
@@ -1587,6 +1590,7 @@ function importFile()
1587{ 1590{
1588 if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); } 1591 if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); }
1589 $LINKSDB = new LinkDB( 1592 $LINKSDB = new LinkDB(
1593 $GLOBALS['config']['DATASTORE'],
1590 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], 1594 isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
1591 $GLOBALS['config']['HIDE_PUBLIC_LINKS'] 1595 $GLOBALS['config']['HIDE_PUBLIC_LINKS']
1592 ); 1596 );