diff options
Diffstat (limited to 'index.php')
-rw-r--r-- | index.php | 17 |
1 files changed, 12 insertions, 5 deletions
@@ -96,6 +96,8 @@ require $GLOBALS['config']['CONFIG_FILE']; // Read login/password hash into $GL | |||
96 | if (empty($GLOBALS['title'])) $GLOBALS['title']='Shared links on '.htmlspecialchars(indexUrl()); | 96 | if (empty($GLOBALS['title'])) $GLOBALS['title']='Shared links on '.htmlspecialchars(indexUrl()); |
97 | if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get(); | 97 | if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get(); |
98 | if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false; | 98 | if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false; |
99 | if (empty($GLOBALS['disablejquery'])) $GLOBALS['disablejquery']=false; | ||
100 | // I really need to rewrite Shaarli with a proper configuation manager. | ||
99 | 101 | ||
100 | autoLocale(); // Sniff browser language and set date format accordingly. | 102 | autoLocale(); // Sniff browser language and set date format accordingly. |
101 | header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling. | 103 | header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling. |
@@ -1350,6 +1352,7 @@ function renderPage() | |||
1350 | $GLOBALS['title']=$_POST['title']; | 1352 | $GLOBALS['title']=$_POST['title']; |
1351 | $GLOBALS['redirector']=$_POST['redirector']; | 1353 | $GLOBALS['redirector']=$_POST['redirector']; |
1352 | $GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']); | 1354 | $GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']); |
1355 | $GLOBALS['disablejquery']=!empty($_POST['disablejquery']); | ||
1353 | writeConfig(); | 1356 | writeConfig(); |
1354 | echo '<script language="JavaScript">alert("Configuration was saved.");document.location=\'?do=tools\';</script>'; | 1357 | echo '<script language="JavaScript">alert("Configuration was saved.");document.location=\'?do=tools\';</script>'; |
1355 | exit; | 1358 | exit; |
@@ -1951,6 +1954,11 @@ function lazyThumbnail($url,$href=false) | |||
1951 | $html='<a href="'.htmlspecialchars($t['href']).'">'; | 1954 | $html='<a href="'.htmlspecialchars($t['href']).'">'; |
1952 | 1955 | ||
1953 | // Lazy image (only loaded by javascript when in the viewport). | 1956 | // Lazy image (only loaded by javascript when in the viewport). |
1957 | if (!empty($GLOBALS['disablejquery'])) // (except if jQuery is disabled) | ||
1958 | $html.='<img class="lazyimage" src="'.htmlspecialchars($t['src']).'"'; | ||
1959 | else | ||
1960 | $html.='<img class="lazyimage" src="#" data-original="'.htmlspecialchars($t['src']).'"'; | ||
1961 | |||
1954 | $html.='<img class="lazyimage" src="#" data-original="'.htmlspecialchars($t['src']).'"'; | 1962 | $html.='<img class="lazyimage" src="#" data-original="'.htmlspecialchars($t['src']).'"'; |
1955 | if (!empty($t['width'])) $html.=' width="'.htmlspecialchars($t['width']).'"'; | 1963 | if (!empty($t['width'])) $html.=' width="'.htmlspecialchars($t['width']).'"'; |
1956 | if (!empty($t['height'])) $html.=' height="'.htmlspecialchars($t['height']).'"'; | 1964 | if (!empty($t['height'])) $html.=' height="'.htmlspecialchars($t['height']).'"'; |
@@ -1958,7 +1966,7 @@ function lazyThumbnail($url,$href=false) | |||
1958 | if (!empty($t['alt'])) $html.=' alt="'.htmlspecialchars($t['alt']).'"'; | 1966 | if (!empty($t['alt'])) $html.=' alt="'.htmlspecialchars($t['alt']).'"'; |
1959 | $html.='>'; | 1967 | $html.='>'; |
1960 | 1968 | ||
1961 | // No-javascript fallback: | 1969 | // No-javascript fallback. |
1962 | $html.='<noscript><img src="'.htmlspecialchars($t['src']).'"'; | 1970 | $html.='<noscript><img src="'.htmlspecialchars($t['src']).'"'; |
1963 | if (!empty($t['width'])) $html.=' width="'.htmlspecialchars($t['width']).'"'; | 1971 | if (!empty($t['width'])) $html.=' width="'.htmlspecialchars($t['width']).'"'; |
1964 | if (!empty($t['height'])) $html.=' height="'.htmlspecialchars($t['height']).'"'; | 1972 | if (!empty($t['height'])) $html.=' height="'.htmlspecialchars($t['height']).'"'; |
@@ -2065,8 +2073,8 @@ function templateTZform($ptz=false) | |||
2065 | foreach($continents as $continent) | 2073 | foreach($continents as $continent) |
2066 | $continents_html.='<option value="'.$continent.'"'.($pcontinent==$continent?'selected':'').'>'.$continent.'</option>'; | 2074 | $continents_html.='<option value="'.$continent.'"'.($pcontinent==$continent?'selected':'').'>'.$continent.'</option>'; |
2067 | $cities_html = $cities[$pcontinent]; | 2075 | $cities_html = $cities[$pcontinent]; |
2068 | $timezone_form = "Continent: <select name=\"continent\" id=\"continent\" onChange=\"onChangecontinent();\">${continents_html}</select><br /><br />"; | 2076 | $timezone_form = "Continent: <select name=\"continent\" id=\"continent\" onChange=\"onChangecontinent();\">${continents_html}</select>"; |
2069 | $timezone_form .= "City: <select name=\"city\" id=\"city\">${cities[$pcontinent]}</select><br /><br />"; | 2077 | $timezone_form .= " City: <select name=\"city\" id=\"city\">${cities[$pcontinent]}</select><br />"; |
2070 | $timezone_js = "<script language=\"JavaScript\">"; | 2078 | $timezone_js = "<script language=\"JavaScript\">"; |
2071 | $timezone_js .= "function onChangecontinent(){document.getElementById(\"city\").innerHTML = citiescontinent[document.getElementById(\"continent\").value];}"; | 2079 | $timezone_js .= "function onChangecontinent(){document.getElementById(\"city\").innerHTML = citiescontinent[document.getElementById(\"continent\").value];}"; |
2072 | $timezone_js .= "var citiescontinent = ".json_encode($cities).";" ; | 2080 | $timezone_js .= "var citiescontinent = ".json_encode($cities).";" ; |
@@ -2137,12 +2145,11 @@ function processWS() | |||
2137 | function writeConfig() | 2145 | function writeConfig() |
2138 | { | 2146 | { |
2139 | if (is_file($GLOBALS['config']['CONFIG_FILE']) && !isLoggedIn()) die('You are not authorized to alter config.'); // Only logged in user can alter config. | 2147 | if (is_file($GLOBALS['config']['CONFIG_FILE']) && !isLoggedIn()) die('You are not authorized to alter config.'); // Only logged in user can alter config. |
2140 | if (empty($GLOBALS['redirector'])) $GLOBALS['redirector']=''; | ||
2141 | if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false; | ||
2142 | $config='<?php $GLOBALS[\'login\']='.var_export($GLOBALS['login'],true).'; $GLOBALS[\'hash\']='.var_export($GLOBALS['hash'],true).'; $GLOBALS[\'salt\']='.var_export($GLOBALS['salt'],true).'; '; | 2148 | $config='<?php $GLOBALS[\'login\']='.var_export($GLOBALS['login'],true).'; $GLOBALS[\'hash\']='.var_export($GLOBALS['hash'],true).'; $GLOBALS[\'salt\']='.var_export($GLOBALS['salt'],true).'; '; |
2143 | $config .='$GLOBALS[\'timezone\']='.var_export($GLOBALS['timezone'],true).'; date_default_timezone_set('.var_export($GLOBALS['timezone'],true).'); $GLOBALS[\'title\']='.var_export($GLOBALS['title'],true).';'; | 2149 | $config .='$GLOBALS[\'timezone\']='.var_export($GLOBALS['timezone'],true).'; date_default_timezone_set('.var_export($GLOBALS['timezone'],true).'); $GLOBALS[\'title\']='.var_export($GLOBALS['title'],true).';'; |
2144 | $config .= '$GLOBALS[\'redirector\']='.var_export($GLOBALS['redirector'],true).'; '; | 2150 | $config .= '$GLOBALS[\'redirector\']='.var_export($GLOBALS['redirector'],true).'; '; |
2145 | $config .= '$GLOBALS[\'disablesessionprotection\']='.var_export($GLOBALS['disablesessionprotection'],true).'; '; | 2151 | $config .= '$GLOBALS[\'disablesessionprotection\']='.var_export($GLOBALS['disablesessionprotection'],true).'; '; |
2152 | $config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; '; | ||
2146 | $config .= ' ?>'; | 2153 | $config .= ' ?>'; |
2147 | if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) | 2154 | if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) |
2148 | { | 2155 | { |