]> git.immae.eu Git - github/shaarli/Shaarli.git/blobdiff - index.php
LinkDB: do not access global variables
[github/shaarli/Shaarli.git] / index.php
index dd3ec3a41a4fd3bc2e2a641707e52d7768aba94f..bbe302a63a4c9bb32ef85df27bd689432f14e286 100644 (file)
--- a/index.php
+++ b/index.php
@@ -41,8 +41,6 @@ $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false;
 if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php');
 
 define('shaarli_version','0.0.45beta');
-define('PHPPREFIX','<?php /* '); // Prefix to encapsulate data in PHP code.
-define('PHPSUFFIX',' */ ?>'); // Suffix to encapsulate data in PHP code.
 // http://server.com/x/shaarli --> /shaarli/
 define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0)));
 
@@ -269,23 +267,6 @@ function logm($message)
     file_put_contents($GLOBALS['config']['DATADIR'].'/log.txt',$t,FILE_APPEND);
 }
 
-// Same as nl2br(), but escapes < and >
-function nl2br_escaped($html)
-{
-    return str_replace('>','&gt;',str_replace('<','&lt;',nl2br($html)));
-}
-
-function escape($str) {
-    return htmlspecialchars($str, ENT_COMPAT, 'UTF-8', false);
-}
-
-function sanitizeLink(&$link) {
-    $link['url'] = escape($link['url']); // useful?
-    $link['title'] = escape($link['title']);
-    $link['description'] = escape($link['description']);
-    $link['tags'] = escape($link['tags']);
-}
-
 // In a string, converts URLs to clickable links.
 // Function inspired from http://www.php.net/manual/en/function.preg-replace.php#85722
 function text2clickable($url)
@@ -717,6 +698,7 @@ function showRSS()
 
     // If cached was not found (or not usable), then read the database and build the response:
     $LINKSDB = new LinkDB(
+        $GLOBALS['config']['DATASTORE'],
         isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
         $GLOBALS['config']['HIDE_PUBLIC_LINKS']
     );
@@ -797,6 +779,7 @@ function showATOM()
 
 // Read links from database (and filter private links if used it not logged in).
     $LINKSDB = new LinkDB(
+        $GLOBALS['config']['DATASTORE'],
         isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
         $GLOBALS['config']['HIDE_PUBLIC_LINKS']
     );
@@ -883,6 +866,7 @@ function showDailyRSS()
 
 // Read links from database (and filter private links if used it not logged in).
     $LINKSDB = new LinkDB(
+        $GLOBALS['config']['DATASTORE'],
         isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
         $GLOBALS['config']['HIDE_PUBLIC_LINKS']
     );
@@ -954,6 +938,7 @@ function showDailyRSS()
 function showDaily()
 {
     $LINKSDB = new LinkDB(
+        $GLOBALS['config']['DATASTORE'],
         isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
         $GLOBALS['config']['HIDE_PUBLIC_LINKS']
     );
@@ -1023,6 +1008,7 @@ function showDaily()
 function renderPage()
 {
     $LINKSDB = new LinkDB(
+        $GLOBALS['config']['DATASTORE'],
         isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
         $GLOBALS['config']['HIDE_PUBLIC_LINKS']
     );
@@ -1604,6 +1590,7 @@ function importFile()
 {
     if (!(isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'])) { die('Not allowed.'); }
     $LINKSDB = new LinkDB(
+        $GLOBALS['config']['DATASTORE'],
         isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'],
         $GLOBALS['config']['HIDE_PUBLIC_LINKS']
     );