aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorArthurHoaro <arthur@hoa.ro>2015-02-20 22:28:10 +0100
committerArthurHoaro <arthur@hoa.ro>2015-02-20 22:49:41 +0100
commit329e0768792b4fd22e548c0e1c4153aec3d6bcd1 (patch)
treef77585efe4d00c7a81c4599fdaed951d01b2459e
parentbe3f0b4ec361f63a6fa4ed8291c912c9a426cd16 (diff)
downloadShaarli-329e0768792b4fd22e548c0e1c4153aec3d6bcd1.tar.gz
Shaarli-329e0768792b4fd22e548c0e1c4153aec3d6bcd1.tar.zst
Shaarli-329e0768792b4fd22e548c0e1c4153aec3d6bcd1.zip
shaarli/Shaarli#34: Make update check optional
* Add a check box at installation (checked by default) * Add a check box in configuration page
-rw-r--r--index.php4
-rw-r--r--tpl/configure.html4
-rw-r--r--tpl/install.html25
3 files changed, 22 insertions, 11 deletions
diff --git a/index.php b/index.php
index dfebdcad..9d4ce156 100644
--- a/index.php
+++ b/index.php
@@ -178,6 +178,7 @@ function checkphpversion()
178function checkUpdate() 178function checkUpdate()
179{ 179{
180 if (!isLoggedIn()) return ''; // Do not check versions for visitors. 180 if (!isLoggedIn()) return ''; // Do not check versions for visitors.
181 if (empty($GLOBALS['config']['ENABLE_UPDATECHECK'])) return ''; // Do not check if the user doesn't want to.
181 182
182 // Get latest version number at most once a day. 183 // Get latest version number at most once a day.
183 if (!is_file($GLOBALS['config']['UPDATECHECK_FILENAME']) || (filemtime($GLOBALS['config']['UPDATECHECK_FILENAME'])<time()-($GLOBALS['config']['UPDATECHECK_INTERVAL']))) 184 if (!is_file($GLOBALS['config']['UPDATECHECK_FILENAME']) || (filemtime($GLOBALS['config']['UPDATECHECK_FILENAME'])<time()-($GLOBALS['config']['UPDATECHECK_INTERVAL'])))
@@ -1462,6 +1463,7 @@ function renderPage()
1462 $GLOBALS['disablejquery']=!empty($_POST['disablejquery']); 1463 $GLOBALS['disablejquery']=!empty($_POST['disablejquery']);
1463 $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']); 1464 $GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']);
1464 $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']); 1465 $GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']);
1466 $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
1465 writeConfig(); 1467 writeConfig();
1466 echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>'; 1468 echo '<script>alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
1467 exit; 1469 exit;
@@ -2191,6 +2193,7 @@ function install()
2191 $GLOBALS['salt'] = sha1(uniqid('',true).'_'.mt_rand()); // Salt renders rainbow-tables attacks useless. 2193 $GLOBALS['salt'] = sha1(uniqid('',true).'_'.mt_rand()); // Salt renders rainbow-tables attacks useless.
2192 $GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']); 2194 $GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']);
2193 $GLOBALS['title'] = (empty($_POST['title']) ? 'Shared links on '.htmlspecialchars(indexUrl()) : $_POST['title'] ); 2195 $GLOBALS['title'] = (empty($_POST['title']) ? 'Shared links on '.htmlspecialchars(indexUrl()) : $_POST['title'] );
2196 $GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
2194 writeConfig(); 2197 writeConfig();
2195 echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>'; 2198 echo '<script>alert("Shaarli is now configured. Please enter your login/password and start shaaring your links!");document.location=\'?do=login\';</script>';
2196 exit; 2199 exit;
@@ -2359,6 +2362,7 @@ function writeConfig()
2359 $config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; '; 2362 $config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; ';
2360 $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; '; 2363 $config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; ';
2361 $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; '; 2364 $config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; ';
2365 $config .= '$GLOBALS[\'config\'][\'ENABLE_UPDATECHECK\']='.var_export($GLOBALS['config']['ENABLE_UPDATECHECK'], true).'; ';
2362 $config .= ' ?>'; 2366 $config .= ' ?>';
2363 if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0) 2367 if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
2364 { 2368 {
diff --git a/tpl/configure.html b/tpl/configure.html
index c096018b..887be327 100644
--- a/tpl/configure.html
+++ b/tpl/configure.html
@@ -30,6 +30,10 @@
30 <input type="checkbox" name="enableRssPermalinks" id="enableRssPermalinks" {if="!empty($GLOBALS['config']['ENABLE_RSS_PERMALINKS'])"}checked{/if}/><label for="enableRssPermalinks">&nbsp;Switches the RSS feed URLs between full URLs and shortlinks. Enabling it will show a permalink in the description, and the feed item will be linked to the absolute URL. Disabling it swaps this behaviour around (permalink in title and link in description). RSS Permalinks are currently <b>{if="$GLOBALS['config']['ENABLE_RSS_PERMALINKS']"}enabled{else}disabled{/if}</b></label> 30 <input type="checkbox" name="enableRssPermalinks" id="enableRssPermalinks" {if="!empty($GLOBALS['config']['ENABLE_RSS_PERMALINKS'])"}checked{/if}/><label for="enableRssPermalinks">&nbsp;Switches the RSS feed URLs between full URLs and shortlinks. Enabling it will show a permalink in the description, and the feed item will be linked to the absolute URL. Disabling it swaps this behaviour around (permalink in title and link in description). RSS Permalinks are currently <b>{if="$GLOBALS['config']['ENABLE_RSS_PERMALINKS']"}enabled{else}disabled{/if}</b></label>
31 </td> 31 </td>
32 </tr> 32 </tr>
33 <tr><td valign="top"><b>Update:</b></td><td>
34 <input type="checkbox" name="updateCheck" id="updateCheck" {if="!empty($GLOBALS['config']['ENABLE_UPDATECHECK'])"}checked{/if}/>
35 <label for="updateCheck">&nbsp;Notify me when a new release is ready</label></td>
36 </tr>
33 <tr><td></td><td class="right"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr> 37 <tr><td></td><td class="right"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
34 </table> 38 </table>
35 </form> 39 </form>
diff --git a/tpl/install.html b/tpl/install.html
index df42bf6d..88eb540e 100644
--- a/tpl/install.html
+++ b/tpl/install.html
@@ -3,17 +3,20 @@
3<head>{include="includes"}{$timezone_js}</head> 3<head>{include="includes"}{$timezone_js}</head>
4<body onload="document.installform.setlogin.focus();"> 4<body onload="document.installform.setlogin.focus();">
5<div id="install"> 5<div id="install">
6<h1>Shaarli</h1> 6 <h1>Shaarli</h1>
7It looks like it's the first time you run Shaarli. Please configure it:<br> 7 It looks like it's the first time you run Shaarli. Please configure it:<br>
8<form method="POST" action="#" name="installform" id="installform"> 8 <form method="POST" action="#" name="installform" id="installform">
9<table> 9 <table>
10<tr><td><b>Login:</b></td><td><input type="text" name="setlogin" size="30"></td></tr> 10 <tr><td><b>Login:</b></td><td><input type="text" name="setlogin" size="30"></td></tr>
11<tr><td><b>Password:</b></td><td><input type="password" name="setpassword" size="30"></td></tr> 11 <tr><td><b>Password:</b></td><td><input type="password" name="setpassword" size="30"></td></tr>
12{$timezone_html} 12 {$timezone_html}
13<tr><td><b>Page title:</b></td><td><input type="text" name="title" size="30"></td></tr> 13 <tr><td><b>Page title:</b></td><td><input type="text" name="title" size="30"></td></tr>
14<tr><td colspan="2"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr> 14 <tr><td valign="top"><b>Update:</b></td><td>
15</table> 15 <input type="checkbox" name="updateCheck" id="updateCheck" checked="checked"><label for="updateCheck">&nbsp;Notify me when a new release is ready</label></td>
16</form> 16 </tr>
17 <tr><td colspan="2"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
18 </table>
19 </form>
17</div> 20</div>
18{include="page.footer"} 21{include="page.footer"}
19</body> 22</body>