shaarli/Shaarli#34: Make update check optional
* Add a check box at installation (checked by default) * Add a check box in configuration page
This commit is contained in:
parent
3e361b0394
commit
1687756741
3 changed files with 26 additions and 14 deletions
|
@ -144,6 +144,7 @@ function checkphpversion()
|
||||||
function checkUpdate()
|
function checkUpdate()
|
||||||
{
|
{
|
||||||
if (!isLoggedIn()) return ''; // Do not check versions for visitors.
|
if (!isLoggedIn()) return ''; // Do not check versions for visitors.
|
||||||
|
if (empty($GLOBALS['config']['ENABLE_UPDATECHECK'])) return ''; // Do not check if the user doesn't want to.
|
||||||
|
|
||||||
// Get latest version number at most once a day.
|
// Get latest version number at most once a day.
|
||||||
if (!is_file($GLOBALS['config']['UPDATECHECK_FILENAME']) || (filemtime($GLOBALS['config']['UPDATECHECK_FILENAME'])<time()-($GLOBALS['config']['UPDATECHECK_INTERVAL'])))
|
if (!is_file($GLOBALS['config']['UPDATECHECK_FILENAME']) || (filemtime($GLOBALS['config']['UPDATECHECK_FILENAME'])<time()-($GLOBALS['config']['UPDATECHECK_INTERVAL'])))
|
||||||
|
@ -1440,6 +1441,8 @@ function renderPage()
|
||||||
$GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']);
|
$GLOBALS['disablesessionprotection']=!empty($_POST['disablesessionprotection']);
|
||||||
$GLOBALS['disablejquery']=!empty($_POST['disablejquery']);
|
$GLOBALS['disablejquery']=!empty($_POST['disablejquery']);
|
||||||
$GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']);
|
$GLOBALS['privateLinkByDefault']=!empty($_POST['privateLinkByDefault']);
|
||||||
|
$GLOBALS['config']['ENABLE_RSS_PERMALINKS']= !empty($_POST['enableRssPermalinks']);
|
||||||
|
$GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
|
||||||
writeConfig();
|
writeConfig();
|
||||||
echo '<script language="JavaScript">alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
|
echo '<script language="JavaScript">alert("Configuration was saved.");document.location=\'?do=tools\';</script>';
|
||||||
exit;
|
exit;
|
||||||
|
@ -2190,6 +2193,7 @@ function install()
|
||||||
$GLOBALS['salt'] = sha1(uniqid('',true).'_'.mt_rand()); // Salt renders rainbow-tables attacks useless.
|
$GLOBALS['salt'] = sha1(uniqid('',true).'_'.mt_rand()); // Salt renders rainbow-tables attacks useless.
|
||||||
$GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']);
|
$GLOBALS['hash'] = sha1($_POST['setpassword'].$GLOBALS['login'].$GLOBALS['salt']);
|
||||||
$GLOBALS['title'] = (empty($_POST['title']) ? 'Shared links on '.htmlspecialchars(indexUrl()) : $_POST['title'] );
|
$GLOBALS['title'] = (empty($_POST['title']) ? 'Shared links on '.htmlspecialchars(indexUrl()) : $_POST['title'] );
|
||||||
|
$GLOBALS['config']['ENABLE_UPDATECHECK'] = !empty($_POST['updateCheck']);
|
||||||
writeConfig();
|
writeConfig();
|
||||||
echo '<script language="JavaScript">alert("Shaarli is now configured. Please enter your login/password and start shaaring your links !");document.location=\'?do=login\';</script>';
|
echo '<script language="JavaScript">alert("Shaarli is now configured. Please enter your login/password and start shaaring your links !");document.location=\'?do=login\';</script>';
|
||||||
exit;
|
exit;
|
||||||
|
@ -2357,6 +2361,8 @@ function writeConfig()
|
||||||
$config .= '$GLOBALS[\'disablesessionprotection\']='.var_export($GLOBALS['disablesessionprotection'],true).'; ';
|
$config .= '$GLOBALS[\'disablesessionprotection\']='.var_export($GLOBALS['disablesessionprotection'],true).'; ';
|
||||||
$config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; ';
|
$config .= '$GLOBALS[\'disablejquery\']='.var_export($GLOBALS['disablejquery'],true).'; ';
|
||||||
$config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; ';
|
$config .= '$GLOBALS[\'privateLinkByDefault\']='.var_export($GLOBALS['privateLinkByDefault'],true).'; ';
|
||||||
|
$config .= '$GLOBALS[\'config\'][\'ENABLE_RSS_PERMALINKS\']='.var_export($GLOBALS['config']['ENABLE_RSS_PERMALINKS'], true).'; ';
|
||||||
|
$config .= '$GLOBALS[\'config\'][\'ENABLE_UPDATECHECK\']='.var_export($GLOBALS['config']['ENABLE_UPDATECHECK'], true).'; ';
|
||||||
$config .= ' ?>';
|
$config .= ' ?>';
|
||||||
if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
|
if (!file_put_contents($GLOBALS['config']['CONFIG_FILE'],$config) || strcmp(file_get_contents($GLOBALS['config']['CONFIG_FILE']),$config)!=0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
<tr><td><b>Page title:</b></td><td><input type="text" name="title" id="title" size="50" value="{$title}"></td></tr>
|
<tr><td><b>Page title:</b></td><td><input type="text" name="title" id="title" size="50" value="{$title}"></td></tr>
|
||||||
|
|
||||||
<tr><td><b>Title link:</b></td><td><input type="text" name="titleLink" id="titleLink" size="50" value="{$titleLink}"></td></tr>
|
<tr><td><b>Title link:</b></td><td><input type="text" name="titleLink" id="titleLink" size="50" value="{$titleLink}"></td></tr>
|
||||||
|
|
||||||
<tr><td valign="top"><b>Timezone:</b></td><td valign="top">{$timezone_form}</td></tr>
|
<tr><td valign="top"><b>Timezone:</b></td><td valign="top">{$timezone_form}</td></tr>
|
||||||
|
|
||||||
<tr><td valign="top"><b>Redirector</b></td><td><input type="text" name="redirector" id="redirector" size="50" value="{$redirector}"><br>(e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)</td></tr>
|
<tr><td valign="top"><b>Redirector</b></td><td><input type="text" name="redirector" id="redirector" size="50" value="{$redirector}"><br>(e.g. <i>http://anonym.to/?</i> will mask the HTTP_REFERER)</td></tr>
|
||||||
|
@ -24,6 +24,10 @@
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<tr><td valign="top"><b>New link:</b></td><td>
|
<tr><td valign="top"><b>New link:</b></td><td>
|
||||||
<input type="checkbox" name="privateLinkByDefault" id="privateLinkByDefault" {if="!empty($GLOBALS['privateLinkByDefault'])"}checked{/if}/><label for="privateLinkByDefault"> All new link are private by default</label></td>
|
<input type="checkbox" name="privateLinkByDefault" id="privateLinkByDefault" {if="!empty($GLOBALS['privateLinkByDefault'])"}checked{/if}/><label for="privateLinkByDefault"> All new link are private by default</label></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td valign="top"><b>Update:</b></td><td>
|
||||||
|
<input type="checkbox" name="updateCheck" id="updateCheck" {if="!empty($GLOBALS['config']['ENABLE_UPDATECHECK'])"}checked{/if}/>
|
||||||
|
<label for="updateCheck"> Notify me when a new release is ready</label></td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr><td></td><td align="right"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
|
<tr><td></td><td align="right"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
|
@ -2,19 +2,21 @@
|
||||||
<html>
|
<html>
|
||||||
<head>{include="includes"}{$timezone_js}</head>
|
<head>{include="includes"}{$timezone_js}</head>
|
||||||
<body onload="document.installform.setlogin.focus();">
|
<body onload="document.installform.setlogin.focus();">
|
||||||
<div style="margin-left:20px;">
|
<div id="install">
|
||||||
<h1>Shaarli</h1>
|
<h1>Shaarli</h1>
|
||||||
It looks like it's the first time you run Shaarli. Please configure it:<br>
|
It looks like it's the first time you run Shaarli. Please configure it:<br>
|
||||||
<div style="color:white !important;">
|
<form method="POST" action="#" name="installform" id="installform">
|
||||||
<form method="POST" action="" name="installform" id="installform" style="border:1px solid black; padding:10 10 10 10;">
|
<table>
|
||||||
<table border="0" cellpadding="20">
|
<tr><td><b>Login:</b></td><td><input type="text" name="setlogin" size="30"></td></tr>
|
||||||
<tr><td><b>Login:</b></td><td><input type="text" name="setlogin" size="30"></td></tr>
|
<tr><td><b>Password:</b></td><td><input type="password" name="setpassword" size="30"></td></tr>
|
||||||
<tr><td><b>Password:</b></td><td><input type="password" name="setpassword" size="30"></td></tr>
|
{$timezone_html}
|
||||||
{$timezone_html}
|
<tr><td><b>Page title:</b></td><td><input type="text" name="title" size="30"></td></tr>
|
||||||
<tr><td><b>Page title:</b></td><td><input type="text" name="title" size="30"></td></tr>
|
<tr><td valign="top"><b>Update:</b></td><td>
|
||||||
<tr><td></td><td align="right"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
|
<input type="checkbox" name="updateCheck" id="updateCheck" checked="checked"><label for="updateCheck"> Notify me when a new release is ready</label></td>
|
||||||
</table>
|
</tr>
|
||||||
</form>
|
<tr><td colspan="2"><input type="submit" name="Save" value="Save config" class="bigbutton"></td></tr>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
</div>
|
</div>
|
||||||
{include="page.footer"}
|
{include="page.footer"}
|
||||||
</body>
|
</body>
|
||||||
|
|
Loading…
Reference in a new issue