diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 208 |
1 files changed, 128 insertions, 80 deletions
@@ -11,7 +11,8 @@ | |||
11 | date_default_timezone_set('UTC'); | 11 | date_default_timezone_set('UTC'); |
12 | 12 | ||
13 | // ----------------------------------------------------------------------------------------------- | 13 | // ----------------------------------------------------------------------------------------------- |
14 | // Hardcoded parameter (These parameters can be overwritten by creating the file /data/options.php) | 14 | // Hardcoded parameter (These parameters can be overwritten by editing the file /data/config.php) |
15 | // You should not touch any code below (or at your own risks!) | ||
15 | $GLOBALS['config']['DATADIR'] = 'data'; // Data subdirectory | 16 | $GLOBALS['config']['DATADIR'] = 'data'; // Data subdirectory |
16 | $GLOBALS['config']['CONFIG_FILE'] = $GLOBALS['config']['DATADIR'].'/config.php'; // Configuration file (user login/password) | 17 | $GLOBALS['config']['CONFIG_FILE'] = $GLOBALS['config']['DATADIR'].'/config.php'; // Configuration file (user login/password) |
17 | $GLOBALS['config']['DATASTORE'] = $GLOBALS['config']['DATADIR'].'/datastore.php'; // Data storage file. | 18 | $GLOBALS['config']['DATASTORE'] = $GLOBALS['config']['DATADIR'].'/datastore.php'; // Data storage file. |
@@ -36,10 +37,6 @@ $GLOBALS['config']['ARCHIVE_ORG'] = false; // For each link, add a link to an ar | |||
36 | $GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = true; // Enable RSS permalinks by default. This corresponds to the default behavior of shaarli before this was added as an option. | 37 | $GLOBALS['config']['ENABLE_RSS_PERMALINKS'] = true; // Enable RSS permalinks by default. This corresponds to the default behavior of shaarli before this was added as an option. |
37 | $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false; | 38 | $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = false; |
38 | // ----------------------------------------------------------------------------------------------- | 39 | // ----------------------------------------------------------------------------------------------- |
39 | // You should not touch below (or at your own risks!) | ||
40 | // Optional config file. | ||
41 | if (is_file($GLOBALS['config']['DATADIR'].'/options.php')) require($GLOBALS['config']['DATADIR'].'/options.php'); | ||
42 | |||
43 | define('shaarli_version','0.0.45beta'); | 40 | define('shaarli_version','0.0.45beta'); |
44 | // http://server.com/x/shaarli --> /shaarli/ | 41 | // http://server.com/x/shaarli --> /shaarli/ |
45 | define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0))); | 42 | define('WEB_PATH', substr($_SERVER["REQUEST_URI"], 0, 1+strrpos($_SERVER["REQUEST_URI"], '/', 0))); |
@@ -66,9 +63,15 @@ checkphpversion(); | |||
66 | error_reporting(E_ALL^E_WARNING); // See all error except warnings. | 63 | error_reporting(E_ALL^E_WARNING); // See all error except warnings. |
67 | //error_reporting(-1); // See all errors (for debugging only) | 64 | //error_reporting(-1); // See all errors (for debugging only) |
68 | 65 | ||
66 | // User configuration | ||
67 | if (is_file($GLOBALS['config']['CONFIG_FILE'])) { | ||
68 | require_once $GLOBALS['config']['CONFIG_FILE']; | ||
69 | } | ||
70 | |||
69 | // Shaarli library | 71 | // Shaarli library |
70 | require_once 'application/LinkDB.php'; | 72 | require_once 'application/LinkDB.php'; |
71 | require_once 'application/Utils.php'; | 73 | require_once 'application/Utils.php'; |
74 | require_once 'application/Config.php'; | ||
72 | 75 | ||
73 | include "inc/rain.tpl.class.php"; //include Rain TPL | 76 | include "inc/rain.tpl.class.php"; //include Rain TPL |
74 | raintpl::$tpl_dir = $GLOBALS['config']['RAINTPL_TPL']; // template directory | 77 | raintpl::$tpl_dir = $GLOBALS['config']['RAINTPL_TPL']; // template directory |
@@ -100,15 +103,15 @@ if (empty($GLOBALS['title'])) $GLOBALS['title']='Shared links on '.escape(indexU | |||
100 | if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get(); | 103 | if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get(); |
101 | if (empty($GLOBALS['redirector'])) $GLOBALS['redirector']=''; | 104 | if (empty($GLOBALS['redirector'])) $GLOBALS['redirector']=''; |
102 | if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false; | 105 | if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false; |
103 | if (empty($GLOBALS['disablejquery'])) $GLOBALS['disablejquery']=false; | ||
104 | if (empty($GLOBALS['privateLinkByDefault'])) $GLOBALS['privateLinkByDefault']=false; | 106 | if (empty($GLOBALS['privateLinkByDefault'])) $GLOBALS['privateLinkByDefault']=false; |
105 | if (empty($GLOBALS['titleLink'])) $GLOBALS['titleLink']='?'; | 107 | if (empty($GLOBALS['titleLink'])) $GLOBALS['titleLink']='?'; |
106 | // I really need to rewrite Shaarli with a proper configuation manager. | 108 | // I really need to rewrite Shaarli with a proper configuation manager. |
107 | 109 | ||
108 | // Run config screen if first run: | 110 | // Run config screen if first run: |
109 | if (!is_file($GLOBALS['config']['CONFIG_FILE'])) install(); | 111 | if (! is_file($GLOBALS['config']['CONFIG_FILE'])) { |
112 | install(); | ||
113 | } | ||
110 | 114 | ||
111 | require $GLOBALS['config']['CONFIG_FILE']; // Read login/password hash into $GLOBALS. | ||
112 | $GLOBALS['title'] = !empty($GLOBALS['title']) ? escape($GLOBALS['title']) : ''; | 115 | $GLOBALS['title'] = !empty($GLOBALS['title']) ? escape($GLOBALS['title']) : ''; |
113 | $GLOBALS['titleLink'] = !empty($GLOBALS['titleLink']) ? escape($GLOBALS['titleLink']) : ''; | 116 | $GLOBALS['titleLink'] = !empty($GLOBALS['titleLink']) ? escape($GLOBALS['titleLink']) : ''; |
114 | $GLOBALS['redirector'] = !empty($GLOBALS['redirector']) ? escape($GLOBALS['redirector']) : ''; | 117 | $GLOBALS['redirector'] = !empty($GLOBALS['redirector']) ? escape($GLOBALS['redirector']) : ''; |
@@ -856,15 +859,18 @@ function showATOM() | |||
856 | // Daily RSS feed: 1 RSS entry per day giving all the links on that day. | 859 | // Daily RSS feed: 1 RSS entry per day giving all the links on that day. |
857 | // Gives the last 7 days (which have links). | 860 | // Gives the last 7 days (which have links). |
858 | // This RSS feed cannot be filtered. | 861 | // This RSS feed cannot be filtered. |
859 | function showDailyRSS() | 862 | function showDailyRSS() { |
860 | { | ||
861 | // Cache system | 863 | // Cache system |
862 | $query = $_SERVER["QUERY_STRING"]; | 864 | $query = $_SERVER["QUERY_STRING"]; |
863 | $cache = new pageCache(pageUrl(),startsWith($query,'do=dailyrss') && !isLoggedIn()); | 865 | $cache = new pageCache(pageUrl(), startsWith($query, 'do=dailyrss') && !isLoggedIn()); |
864 | $cached = $cache->cachedVersion(); if (!empty($cached)) { echo $cached; exit; } | 866 | $cached = $cache->cachedVersion(); |
865 | // If cached was not found (or not usable), then read the database and build the response: | 867 | if (!empty($cached)) { |
868 | echo $cached; | ||
869 | exit; | ||
870 | } | ||
866 | 871 | ||
867 | // Read links from database (and filter private links if used it not logged in). | 872 | // If cached was not found (or not usable), then read the database and build the response: |
873 | // Read links from database (and filter private links if used it not logged in). | ||
868 | $LINKSDB = new LinkDB( | 874 | $LINKSDB = new LinkDB( |
869 | $GLOBALS['config']['DATASTORE'], | 875 | $GLOBALS['config']['DATASTORE'], |
870 | isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], | 876 | isLoggedIn() || $GLOBALS['config']['OPEN_SHAARLI'], |
@@ -874,60 +880,75 @@ function showDailyRSS() | |||
874 | /* Some Shaarlies may have very few links, so we need to look | 880 | /* Some Shaarlies may have very few links, so we need to look |
875 | back in time (rsort()) until we have enough days ($nb_of_days). | 881 | back in time (rsort()) until we have enough days ($nb_of_days). |
876 | */ | 882 | */ |
877 | $linkdates=array(); foreach($LINKSDB as $linkdate=>$value) { $linkdates[]=$linkdate; } | 883 | $linkdates = array(); |
884 | foreach ($LINKSDB as $linkdate => $value) { | ||
885 | $linkdates[] = $linkdate; | ||
886 | } | ||
878 | rsort($linkdates); | 887 | rsort($linkdates); |
879 | $nb_of_days=7; // We take 7 days. | 888 | $nb_of_days = 7; // We take 7 days. |
880 | $today=Date('Ymd'); | 889 | $today = Date('Ymd'); |
881 | $days=array(); | 890 | $days = array(); |
882 | foreach($linkdates as $linkdate) | 891 | |
883 | { | 892 | foreach ($linkdates as $linkdate) { |
884 | $day=substr($linkdate,0,8); // Extract day (without time) | 893 | $day = substr($linkdate, 0, 8); // Extract day (without time) |
885 | if (strcmp($day,$today)<0) | 894 | if (strcmp($day,$today) < 0) { |
886 | { | 895 | if (empty($days[$day])) { |
887 | if (empty($days[$day])) $days[$day]=array(); | 896 | $days[$day] = array(); |
888 | $days[$day][]=$linkdate; | 897 | } |
898 | $days[$day][] = $linkdate; | ||
899 | } | ||
900 | |||
901 | if (count($days) > $nb_of_days) { | ||
902 | break; // Have we collected enough days? | ||
889 | } | 903 | } |
890 | if (count($days)>$nb_of_days) break; // Have we collected enough days? | ||
891 | } | 904 | } |
892 | 905 | ||
893 | // Build the RSS feed. | 906 | // Build the RSS feed. |
894 | header('Content-Type: application/rss+xml; charset=utf-8'); | 907 | header('Content-Type: application/rss+xml; charset=utf-8'); |
895 | $pageaddr=escape(indexUrl()); | 908 | $pageaddr = escape(indexUrl()); |
896 | echo '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">'; | 909 | echo '<?xml version="1.0" encoding="UTF-8"?><rss version="2.0">'; |
897 | echo '<channel><title>Daily - '.$GLOBALS['title'].'</title><link>'.$pageaddr.'</link>'; | 910 | echo '<channel>'; |
898 | echo '<description>Daily shared links</description><language>en-en</language><copyright>'.$pageaddr.'</copyright>'."\n"; | 911 | echo '<title>Daily - '. $GLOBALS['title'] . '</title>'; |
899 | 912 | echo '<link>'. $pageaddr .'</link>'; | |
900 | foreach($days as $day=>$linkdates) // For each day. | 913 | echo '<description>Daily shared links</description>'; |
901 | { | 914 | echo '<language>en-en</language>'; |
902 | $daydate = utf8_encode(strftime('%A %d, %B %Y',linkdate2timestamp($day.'_000000'))); // Full text date | 915 | echo '<copyright>'. $pageaddr .'</copyright>'. PHP_EOL; |
916 | |||
917 | // For each day. | ||
918 | foreach ($days as $day => $linkdates) { | ||
919 | $daydate = linkdate2timestamp($day.'_000000'); // Full text date | ||
903 | $rfc822date = linkdate2rfc822($day.'_000000'); | 920 | $rfc822date = linkdate2rfc822($day.'_000000'); |
904 | $absurl=escape(indexUrl().'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page. | 921 | $absurl = escape(indexUrl().'?do=daily&day='.$day); // Absolute URL of the corresponding "Daily" page. |
905 | echo '<item><title>'.$GLOBALS['title'].' - '.$daydate.'</title><guid>'.$absurl.'</guid><link>'.$absurl.'</link>'; | ||
906 | echo '<pubDate>'.escape($rfc822date)."</pubDate>"; | ||
907 | 922 | ||
908 | // Build the HTML body of this RSS entry. | 923 | // Build the HTML body of this RSS entry. |
909 | $html=''; | 924 | $html = ''; |
910 | $href=''; | 925 | $href = ''; |
911 | $links=array(); | 926 | $links = array(); |
927 | |||
912 | // We pre-format some fields for proper output. | 928 | // We pre-format some fields for proper output. |
913 | foreach($linkdates as $linkdate) | 929 | foreach ($linkdates as $linkdate) { |
914 | { | ||
915 | $l = $LINKSDB[$linkdate]; | 930 | $l = $LINKSDB[$linkdate]; |
916 | $l['formatedDescription']=nl2br(keepMultipleSpaces(text2clickable($l['description']))); | 931 | $l['formatedDescription'] = nl2br(keepMultipleSpaces(text2clickable($l['description']))); |
917 | $l['thumbnail'] = thumbnail($l['url']); | 932 | $l['thumbnail'] = thumbnail($l['url']); |
918 | $l['timestamp'] = linkdate2timestamp($l['linkdate']); | 933 | $l['timestamp'] = linkdate2timestamp($l['linkdate']); |
919 | if (startsWith($l['url'],'?')) $l['url']=indexUrl().$l['url']; // make permalink URL absolute | 934 | if (startsWith($l['url'], '?')) { |
920 | $links[$linkdate]=$l; | 935 | $l['url'] = indexUrl() . $l['url']; // make permalink URL absolute |
936 | } | ||
937 | $links[$linkdate] = $l; | ||
921 | } | 938 | } |
939 | |||
922 | // Then build the HTML for this day: | 940 | // Then build the HTML for this day: |
923 | $tpl = new RainTPL; | 941 | $tpl = new RainTPL; |
924 | $tpl->assign('links',$links); | 942 | $tpl->assign('title', $GLOBALS['title']); |
925 | $html = $tpl->draw('dailyrss',$return_string=true); | 943 | $tpl->assign('daydate', $daydate); |
926 | echo "\n"; | 944 | $tpl->assign('absurl', $absurl); |
927 | echo '<description><![CDATA['.$html.']]></description>'."\n</item>\n\n"; | 945 | $tpl->assign('links', $links); |
946 | $tpl->assign('rfc822date', escape($rfc822date)); | ||
947 | $html = $tpl->draw('dailyrss', $return_string=true); | ||
928 | 948 | ||
949 | echo $html . PHP_EOL; | ||
929 | } | 950 | } |
930 | echo '</channel></rss><!-- Cached version of '.escape(pageUrl()).' -->'; | 951 | echo '</channel></rss><!-- Cached version of '. escape(pageUrl()) .' -->'; |
931 | 952 | ||
932 | $cache->cache(ob_get_contents()); | 953 | $cache->cache(ob_get_contents()); |
933 | ob_end_flush(); | 954 | ob_end_flush(); |
@@ -948,16 +969,22 @@ function showDaily() | |||
948 | 969 | ||
949 | $days = $LINKSDB->days(); | 970 | $days = $LINKSDB->days(); |
950 | $i = array_search($day,$days); | 971 | $i = array_search($day,$days); |
951 | if ($i==false) { $i=count($days)-1; $day=$days[$i]; } | 972 | if ($i===false) { $i=count($days)-1; $day=$days[$i]; } |
952 | $previousday=''; | 973 | $previousday=''; |
953 | $nextday=''; | 974 | $nextday=''; |
954 | if ($i!==false) | 975 | if ($i!==false) |
955 | { | 976 | { |
956 | if ($i>1) $previousday=$days[$i-1]; | 977 | if ($i>=1) $previousday=$days[$i-1]; |
957 | if ($i<count($days)-1) $nextday=$days[$i+1]; | 978 | if ($i<count($days)-1) $nextday=$days[$i+1]; |
958 | } | 979 | } |
959 | 980 | ||
960 | $linksToDisplay=$LINKSDB->filterDay($day); | 981 | try { |
982 | $linksToDisplay = $LINKSDB->filterDay($day); | ||
983 | } catch (Exception $exc) { | ||
984 | error_log($exc); | ||
985 | $linksToDisplay = []; | ||
986 | } | ||
987 | |||
961 | // We pre-format some fields for proper output. | 988 | // We pre-format some fields for proper output. |
962 | foreach($linksToDisplay as $key=>$link) | 989 | foreach($linksToDisplay as $key=>$link) |
963 | { | 990 | { |
@@ -1214,7 +1241,19 @@ function renderPage() | |||
1214 | // Save new password | 1241 | // Save new password |
1215 | $GLOBALS['salt'] = sha1(uniqid('',true).'_'.mt_rand()); // Salt renders rainbow-tables attacks useless. | 1242 | $GLOBALS['salt'] = sha1(uniqid('',true).'_'.mt_rand()); // Salt renders rainbow-tables attacks useless. |
1216 | $GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']); | 1243 | $GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']); |
1217 | writeConfig(); | 1244 | try { |
1245 | writeConfig($GLOBALS, isLoggedIn()); | ||
1246 | } | ||
1247 | catch(Exception $e) { | ||
1248 | error_log( | ||
1249 | 'ERROR while writing config file after changing password.' . PHP_EOL . | ||
1250 | $e->getMessage() | ||
1251 | ); | ||
1252 | |||
1253 | // TODO: do not handle exceptions/errors in JS. | ||
1254 | echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do=tools\';</script>'; | ||
1255 | exit; | ||
1256 | } | ||
1218 | echo '<script>alert("Your password has been changed.");document.location=\'?do=tools\';</script>'; | 1257 | echo '<script>alert("Your password has been changed.");document.location=\'?do=tools\';</script>'; |
1219 | exit; | 1258 | exit; |
1220 | } | 1259 | } |
@@ -1243,12 +1282,23 @@ function renderPage() | |||
1243 | $GLOBALS['titleLink']=$_POST['titleLink']; | 1282 | $GLOBALS['titleLink']=$_POST['titleLink']; |
1244 | $GLOBALS['redirector']=$_POST['redirector']; | 1283 | $GLOBALS['redirector']=$_POST['redirector']; |
1245 | $GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']); | 1284 | $GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']); |
1246 | $GLOBALS['disablejquery']=!empty($_POST['disablejquery']); | ||
1247 | $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']); | 1285 | $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']); |
1248 | $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']); | 1286 | $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']); |
1249 | $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']); | 1287 | $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']); |
1250 | $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = !empty($_POST['hidePublicLinks']); | 1288 | $GLOBALS['config']['HIDE_PUBLIC_LINKS'] = !empty($_POST['hidePublicLinks']); |
1251 | writeConfig(); | 1289 | try { |
1290 | writeConfig($GLOBALS, isLoggedIn()); | ||
1291 | } | ||
1292 | catch(Exception $e) { | ||
1293 | error_log( | ||
1294 | 'ERROR while writing config file after configuration update.' . PHP_EOL . | ||
1295 | $e->getMessage() | ||
1296 | ); | ||
1297 | |||
1298 | // TODO: do not handle exceptions/errors in JS. | ||
1299 | echo '<script>alert("'. $e->getMessage() .'");document.location=\'?do=tools\';</script>'; | ||
1300 | exit; | ||
1301 | } | ||
1252 | echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>'; | 1302 | echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>'; |
1253 | exit; | 1303 | exit; |
1254 | } | 1304 | } |
@@ -2008,7 +2058,19 @@ function install() | |||
2008 | $GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']); | 2058 | $GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']); |
2009 | $GLOBALS['title'] = (empty($_POST['title']) ? 'Shared links on '.escape(indexUrl()) : $_POST['title'] ); | 2059 | $GLOBALS['title'] = (empty($_POST['title']) ? 'Shared links on '.escape(indexUrl()) : $_POST['title'] ); |
2010 | $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']); | 2060 | $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']); |
2011 | writeConfig(); | 2061 | try { |
2062 | writeConfig($GLOBALS, isLoggedIn()); | ||
2063 | } | ||
2064 | catch(Exception $e) { | ||
2065 | error_log( | ||
2066 | 'ERROR while writing config file after installation.' . PHP_EOL . | ||
2067 | $e->getMessage() | ||
2068 | ); | ||
2069 | |||
2070 | // TODO: do not handle exceptions/errors in JS. | ||
2071 | echo '<script>alert("'. $e->getMessage() .'");document.location=\'?\';</script>'; | ||
2072 | exit; | ||
2073 | } | ||
2012 | echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>'; | 2074 | echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>'; |
2013 | exit; | 2075 | exit; |
2014 | } | 2076 | } |
@@ -2122,30 +2184,7 @@ if (!function_exists('json_encode')) { | |||
2122 | } | 2184 | } |
2123 | } | 2185 | } |
2124 | 2186 | ||
2125 | // Re-write configuration file according to globals. | 2187 | |
2126 | // Requires some $GLOBALS to be set (login,hash,salt,title). | ||
2127 | // If the config file cannot be saved, an error message is displayed and the user is redirected to "Tools" menu. | ||
2128 | // (otherwise, the function simply returns.) | ||
2129 | function writeConfig() | ||
2130 | { | ||
2131 | if (is_file($GLOBALS['config']['CONFIG_FILE']) && !isLoggedIn()) die('You are not authorized to alter config.'); // Only logged in user can alter config. | ||
2132 | $config='<?php $GLOBALS[\'login\']='.var_export($GLOBALS['login'],true).'; $GLOBALS[\'hash\']='.var_export($GLOBALS['hash'],true).'; $GLOBALS[\'salt\']='.var_export($GLOBALS['salt'],true).'; '; | ||
2133 | $config .='$GLOBALS[\'timezone\']='.var_export($GLOBALS['timezone'],true).'; date_default_timezone_set('.var_export($GLOBALS['timezone'],true).'); $GLOBALS[\'title\']='.var_export($GLOBALS['title'],true).';'; | ||
2134 | $config .= '$GLOBALS[\'titleLink\']='.var_export($GLOBALS['titleLink'],true).'; '; | ||
2135 | $config .= '$GLOBALS[\'redirector\']='.var_export($GLOBALS['redirector'],true).'; '; | ||
2136 | $config .= '$GLOBALS[\'disablesessionprotection\']='.var_export($GLOBALS['disablesessionprotection'],true).'; '; | ||
2137 | $config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; '; | ||
2138 | $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; '; | ||
2139 | $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; '; | ||
2140 | $config .= '$GLOBALS[\'config\'][\'ENABLE_UPDATECHECK\']='.var_export($GLOBALS['config']['ENABLE_UPDATECHECK'], true).'; '; | ||
2141 | $config .= '$GLOBALS[\'config\'][\'HIDE_PUBLIC_LINKS\']='.var_export($GLOBALS['config']['HIDE_PUBLIC_LINKS'], true).'; '; | ||
2142 | $config .= ' ?>'; | ||
2143 | if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) | ||
2144 | { | ||
2145 | echo '<script>alert("Shaarli could not create the config file. Please make sure Shaarli has the right to write in the folder is it installed in.");document.location=\'?\';</script>'; | ||
2146 | exit; | ||
2147 | } | ||
2148 | } | ||
2149 | 2188 | ||
2150 | /* Because some f*cking services like flickr require an extra HTTP request to get the thumbnail URL, | 2189 | /* Because some f*cking services like flickr require an extra HTTP request to get the thumbnail URL, |
2151 | I have deported the thumbnail URL code generation here, otherwise this would slow down page generation. | 2190 | I have deported the thumbnail URL code generation here, otherwise this would slow down page generation. |
@@ -2374,6 +2413,15 @@ function invalidateCaches() | |||
2374 | pageCache::purgeCache(); // Purge page cache shared by sessions. | 2413 | pageCache::purgeCache(); // Purge page cache shared by sessions. |
2375 | } | 2414 | } |
2376 | 2415 | ||
2416 | try { | ||
2417 | mergeDeprecatedConfig($GLOBALS, isLoggedIn()); | ||
2418 | } catch(Exception $e) { | ||
2419 | error_log( | ||
2420 | 'ERROR while merging deprecated options.php file.' . PHP_EOL . | ||
2421 | $e->getMessage() | ||
2422 | ); | ||
2423 | } | ||
2424 | |||
2377 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. | 2425 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=genthumbnail')) { genThumbnail(); exit; } // Thumbnail generation/cache does not need the link database. |
2378 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; } | 2426 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=rss')) { showRSS(); exit; } |
2379 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } | 2427 | if (isset($_SERVER["QUERY_STRING"]) && startswith($_SERVER["QUERY_STRING"],'do=atom')) { showATOM(); exit; } |