Merge remote-tracking branch 'origin/master'
Conflicts: tpl/editlink.html
This commit is contained in:
commit
dc21529403
3 changed files with 25 additions and 9 deletions
20
index.php
20
index.php
|
@ -78,26 +78,32 @@ header("Cache-Control: post-check=0, pre-check=0", false);
|
||||||
header("Pragma: no-cache");
|
header("Pragma: no-cache");
|
||||||
|
|
||||||
// Directories creations (Note that your web host may require differents rights than 705.)
|
// Directories creations (Note that your web host may require differents rights than 705.)
|
||||||
|
if (!is_writable(realpath(dirname(__FILE__)))) die('<pre>ERROR: Shaarli does not have the right to write in its own directory ('.realpath(dirname(__FILE__)).').</pre>');
|
||||||
if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); }
|
if (!is_dir($GLOBALS['config']['DATADIR'])) { mkdir($GLOBALS['config']['DATADIR'],0705); chmod($GLOBALS['config']['DATADIR'],0705); }
|
||||||
if (!is_dir('tmp')) { mkdir('tmp',0705); chmod('tmp',0705); } // For RainTPL temporary files.
|
if (!is_dir('tmp')) { mkdir('tmp',0705); chmod('tmp',0705); } // For RainTPL temporary files.
|
||||||
if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files.
|
if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['DATADIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files.
|
||||||
|
// Second check to see if Shaarli can write in its directory, because on some hosts is_writable() is not reliable.
|
||||||
|
if (!is_file($GLOBALS['config']['DATADIR'].'/.htaccess')) die('<pre>ERROR: Shaarli does not have the right to write in its own directory ('.realpath(dirname(__FILE__)).').</pre>');
|
||||||
if ($GLOBALS['config']['ENABLE_LOCALCACHE'])
|
if ($GLOBALS['config']['ENABLE_LOCALCACHE'])
|
||||||
{
|
{
|
||||||
if (!is_dir($GLOBALS['config']['CACHEDIR'])) { mkdir($GLOBALS['config']['CACHEDIR'],0705); chmod($GLOBALS['config']['CACHEDIR'],0705); }
|
if (!is_dir($GLOBALS['config']['CACHEDIR'])) { mkdir($GLOBALS['config']['CACHEDIR'],0705); chmod($GLOBALS['config']['CACHEDIR'],0705); }
|
||||||
if (!is_file($GLOBALS['config']['CACHEDIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['CACHEDIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files.
|
if (!is_file($GLOBALS['config']['CACHEDIR'].'/.htaccess')) { file_put_contents($GLOBALS['config']['CACHEDIR'].'/.htaccess',"Allow from none\nDeny from all\n"); } // Protect data files.
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Handling of old config file which do not have the new parameters.
|
||||||
|
if (empty($GLOBALS['title'])) $GLOBALS['title']='Shared links on '.htmlspecialchars(indexUrl());
|
||||||
|
if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get();
|
||||||
|
if (empty($GLOBALS['redirector'])) $GLOBALS['redirector']='';
|
||||||
|
if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false;
|
||||||
|
if (empty($GLOBALS['disablejquery'])) $GLOBALS['disablejquery']=false;
|
||||||
|
if (empty($GLOBALS['privateLinkByDefault'])) $GLOBALS['privateLinkByDefault']=false;
|
||||||
|
// I really need to rewrite Shaarli with a proper configuation manager.
|
||||||
|
|
||||||
// Run config screen if first run:
|
// Run config screen if first run:
|
||||||
if (!is_file($GLOBALS['config']['CONFIG_FILE'])) install();
|
if (!is_file($GLOBALS['config']['CONFIG_FILE'])) install();
|
||||||
|
|
||||||
require $GLOBALS['config']['CONFIG_FILE']; // Read login/password hash into $GLOBALS.
|
require $GLOBALS['config']['CONFIG_FILE']; // Read login/password hash into $GLOBALS.
|
||||||
|
|
||||||
// Handling of old config file which do not have the new parameters.
|
|
||||||
if (empty($GLOBALS['title'])) $GLOBALS['title']='Shared links on '.htmlspecialchars(indexUrl());
|
|
||||||
if (empty($GLOBALS['timezone'])) $GLOBALS['timezone']=date_default_timezone_get();
|
|
||||||
if (empty($GLOBALS['disablesessionprotection'])) $GLOBALS['disablesessionprotection']=false;
|
|
||||||
if (empty($GLOBALS['disablejquery'])) $GLOBALS['disablejquery']=false;
|
|
||||||
// I really need to rewrite Shaarli with a proper configuation manager.
|
|
||||||
|
|
||||||
autoLocale(); // Sniff browser language and set date format accordingly.
|
autoLocale(); // Sniff browser language and set date format accordingly.
|
||||||
header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling.
|
header('Content-Type: text/html; charset=utf-8'); // We use UTF-8 for proper international characters handling.
|
||||||
|
@ -1372,6 +1378,7 @@ function renderPage()
|
||||||
$GLOBALS['redirector']=$_POST['redirector'];
|
$GLOBALS['redirector']=$_POST['redirector'];
|
||||||
$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']);
|
||||||
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;
|
||||||
|
@ -2174,6 +2181,7 @@ function writeConfig()
|
||||||
$config .= '$GLOBALS[\'redirector\']='.var_export($GLOBALS['redirector'],true).'; ';
|
$config .= '$GLOBALS[\'redirector\']='.var_export($GLOBALS['redirector'],true).'; ';
|
||||||
$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 .= ' ?>';
|
$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)
|
||||||
{
|
{
|
||||||
|
|
|
@ -19,8 +19,10 @@
|
||||||
|
|
||||||
<tr><td valign="top"><b>Features:</b></td><td>
|
<tr><td valign="top"><b>Features:</b></td><td>
|
||||||
<input type="checkbox" name="disablejquery" id="disablejquery" {if="!empty($GLOBALS['disablejquery'])"}checked{/if}><label for="disablejquery"> Disable jQuery and all heavy javascript (for example: Autocomplete in tags. Useful for slow computers.)</label>
|
<input type="checkbox" name="disablejquery" id="disablejquery" {if="!empty($GLOBALS['disablejquery'])"}checked{/if}><label for="disablejquery"> Disable jQuery and all heavy javascript (for example: Autocomplete in tags. Useful for slow computers.)</label>
|
||||||
|
</td></tr>
|
||||||
|
<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>
|
||||||
</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>
|
||||||
</form>
|
</form>
|
||||||
|
|
|
@ -16,7 +16,13 @@
|
||||||
<i>Snippet</i><br><textarea name="lf_snippet" rows="4" cols="25" style="width:100%">{$link.snippet|htmlspecialchars}</textarea><br>
|
<i>Snippet</i><br><textarea name="lf_snippet" rows="4" cols="25" style="width:100%">{$link.snippet|htmlspecialchars}</textarea><br>
|
||||||
<i>Tags</i><br><input type="text" id="lf_tags" name="lf_tags" value="{$link.tags|htmlspecialchars}" style="width:100%"><br>
|
<i>Tags</i><br><input type="text" id="lf_tags" name="lf_tags" value="{$link.tags|htmlspecialchars}" style="width:100%"><br>
|
||||||
<i>Via</i><br><input type="text" name="lf_via" value="{$link.via|htmlspecialchars}" style="width:100%"><br>
|
<i>Via</i><br><input type="text" name="lf_via" value="{$link.via|htmlspecialchars}" style="width:100%"><br>
|
||||||
<input type="checkbox" {if condition="$link.private!=0"}checked="yes"{/if} style="margin:7 0 10 0;" name="lf_private" id="lf_private"> <label for="lf_private"><i>Private</i></label><br>
|
{if condition="($link_is_new && $GLOBALS['privateLinkByDefault']==true) || $link.private == true"}
|
||||||
|
<input type="checkbox" checked="checked" name="lf_private" id="lf_private">
|
||||||
|
<label for="lf_private"><i>Private</i></label><br>
|
||||||
|
{else}
|
||||||
|
<input type="checkbox" name="lf_private" id="lf_private">
|
||||||
|
<label for="lf_private"><i>Private</i></label><br>
|
||||||
|
{/if}
|
||||||
<input type="submit" value="Save" name="save_edit" class="bigbutton" style="margin-left:40px;">
|
<input type="submit" value="Save" name="save_edit" class="bigbutton" style="margin-left:40px;">
|
||||||
<input type="submit" value="Cancel" name="cancel_edit" class="bigbutton" style="margin-left:40px;">
|
<input type="submit" value="Cancel" name="cancel_edit" class="bigbutton" style="margin-left:40px;">
|
||||||
{if condition="!$link_is_new"}<input type="submit" value="Delete" name="delete_link" class="bigbutton" style="margin-left:180px;" onClick="return confirmDeleteLink();">{/if}
|
{if condition="!$link_is_new"}<input type="submit" value="Delete" name="delete_link" class="bigbutton" style="margin-left:180px;" onClick="return confirmDeleteLink();">{/if}
|
||||||
|
|
Reference in a new issue