Commit 431a2de1 authored by  JosephK's avatar JosephK

Recovery + Bouton changement de compte + txt tags séparés par espaces

parent 49fd4d23
......@@ -143,6 +143,12 @@ function create_account($account, $password, $email) {
}
//------------------------------------------------------------------
// ~~~~~~~~~~~~~~~~~~~~~~ 0. Unset Cookie ~~~~~~~~~~~~~~~~~~~~~~~~~~
if(isset($_GET['cookie']) && $_GET['cookie']=='unset') {
setcookie('myframa', '', time()+365*24*60*60, dirname($_SERVER["SCRIPT_NAME"]).'/');
$_COOKIE['myframa'] = '';
}
// ~~~~~~~~~~~~~~~~~~~~~~ 1. Bookmarklet ~~~~~~~~~~~~~~~~~~~~~~~~~~~
function encodeURIComponent($str) {
$revert = array('%21'=>'!', '%2A'=>'*', '%27'=>"'", '%28'=>'(', '%29'=>')');
......@@ -221,9 +227,4 @@ if (!is_writable(PATH_ACCOUNTS)) {
}
}
// Tempfix redirect on shaarli's home when user logged in
if(isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], '?do=login')) {
header('Location: '.str_replace('?do=login', '?', $_SERVER['HTTP_REFERER']));
}
include 'layout.php';
......@@ -52,7 +52,7 @@
</a></p>
<p>ou</p>
<p><a href="javascript:void(0)" class="btn btn-primary btn-lg btn-block">
<i class="fa fa-fw fa-lock"></i> '.t('Access Your Account').'
<i class="fa fa-fw fa-lock"></i> '.t('Access your account').'
</a></p>
</div>
</div>';
......
......@@ -71,7 +71,7 @@ $t['Private'] = 'Privé';
$t['Save'] = 'Enregistrer';
$t['Cancel'] = 'Annuler';
$t['Delete'] = 'Supprimer';
$t['Tags must be delimited by spaces.<br><small>(ex: "free opensource bookmarks")</small>'] = 'Les tags doivent être séparés par des espaces.<br><small>(ex : « libre opensource marque-pages »)</small>';
// export.bookmarks.html
// nothing to do (not really a template file)
......@@ -129,7 +129,7 @@ $t['Username'] = 'Utilisateur';
$t['username'] = 'Votre nom'; // placeholder
$t['Password'] = 'Mot de passe';
$t['password'] = ' '; // placeholder
$t['Stay signed in (Do not check on public computers)'] = 'Rester connecté (Ne pas cocher sur un ordinateur public)';
$t['Stay signed in (Do not check on public computers)'] = 'Rester connecté (ne pas cocher sur un ordinateur public)';
$t['Login'] = 'Connexion';
// opensearch.html
......
......@@ -4,6 +4,7 @@ $t['Hide links descriptions'] = 'Masquer la description des liens';
$t['Show links descriptions'] = 'Afficher la description des liens';
$t['Close'] = 'Fermer';
$t['Cancel'] = 'Annuler';
$t['Use an other account'] = 'Utiliser un autre compte';
$t['Your account has been successfully created. You can sign in now.'] = 'Votre compte MyFrama a bien été créé. Vous pouvez à présent vous y connecter.';
$t['Add this link'] = 'Ajouter ce lien';
$t['Edit this link'] = 'Modifier ce lien';
......
......@@ -66,10 +66,10 @@ jQuery(document).ready(function(){
jQuery('input[type="checkbox"][readonly]').on("click.readonly", function(event){event.preventDefault();});
}
if(/\&source\=bookmarklet/i.test(window.location.href)) {
if(/\&source\=bookmarklet/i.test(window.location.href) && (jQuery('#editlinkform').length == 1) ) {
jQuery('#editlinkform').hide();
var editbtn = (jQuery('#editlink[name="delete_link"]').length == 1)
var editbtn = (jQuery('[name="delete_link"]').length == 1)
? '<?php echo t('Edit this link');?>'
: '<?php echo t('Add this link');?>';
var editlink = (jQuery('#lf_url').val().length > 40)
......@@ -84,7 +84,7 @@ jQuery(document).ready(function(){
'<br><small>'+editlink+'</small>'+
'</a></p>'+
'<p><?php echo t('or');?></p>'+
'<p><a href="javascript:void(0)" class="btn btn-primary btn-lg btn-block">'+
'<p><a href="'+window.location.href.split('?')[0]+'" class="btn btn-primary btn-lg btn-block">'+
'<i class="fa fa-fw fa-link"></i> <?php echo t('See all my links');?>'+
'</a></p>'+
'</div>'+
......@@ -98,6 +98,7 @@ jQuery(document).ready(function(){
jQuery('#choose .btn-primary').on('click', function() {
window.open(window.location.href.split('?')[0]);
self.close();
return false;
});
}
......@@ -109,7 +110,10 @@ jQuery(document).ready(function(){
jQuery('[name="returnurl"]').val('');
}
if(/\&source\=bookmarklet/i.test(window.location.href)) {
jQuery('.btn-success').before('<button class="btn btn-default pull-left" type="button" onclick="self.close();"><?php echo t('Cancel');?></button>');
jQuery('.btn-success').before(
'<button class="btn btn-default pull-left" type="button" onclick="self.close();"><?php echo t('Cancel');?></button>'+
'<a class="btn btn-primary pull-left" style="margin-left:5px" href="'+window.location.href.replace('u/<?php echo $account[count($account)-1] ?>/?do=login', '?')+'&cookie=unset"><?php echo t('Use an other account');?></a></p>'
);
}
<?php
if($GLOBALS['login'] == $account[count($account)-1]) {
......
<?php
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
require_once $ShaarliRoot . 'data/config.php';
require_once $ShaarliRoot . 'application/Config.php';
// From index.php
/**
* Enable session
**/
session_name('shaarli');
// Start session if needed (Some server auto-start sessions).
if (session_id() == '') {
session_start();
}
/**
* Test token
**/
function tokenOk($token)
{
if (isset($_SESSION['tokens'][$token]))
{
unset($_SESSION['tokens'][$token]); // Token is used: destroy it.
return true; // Token is OK.
}
return false; // Wrong token, or already used.
}
if (!empty($_POST['email']) && strstr($_POST['email'], '@')) {
if (!tokenOk($_POST['token'])) {
die('Wrong token.'); // Go away!
}
$c = $GLOBALS;
$c['config']['email'] = $_POST['email'];
try {
writeConfig($c, true);
echo '<script>console.log("'.$_POST['token'].' '.$_POST['email'].'");</script>';
}
catch(Exception $e) {
error_log(
'ERROR while writing config file after configuration update.' . PHP_EOL .
$e->getMessage()
);
// TODO: do not handle exceptions/errors in JS.
// echo '<script>alert("'. $e->getMessage() .'");document.location=\'../../?do=tools\';</script>';
exit;
}
//echo '<script>alert("Configuration was saved.");document.location=\'../../?do=tools\';</script>';
exit;
}
else // Nothing to do return to tools
{
//echo '<script>document.location=\'../../?do=tools\';</script>';
exit;
}
?>
\ No newline at end of file
<?php
// recovery.js
$t['I lost my password'] = 'J’ai perdu mon mot de passe';
// loginform.html
$t['Password recovery'] = 'Récupération de mot de passe';
$t['Email'] = 'Courriel';
$t['Recover'] = 'Récupérer';
$t['I lost my password'] = 'J’ai perdu mon mot de passe';
$t['Too many password recovery attempts. Please contact an administrator.'] = 'Trop de tentatives de récupération de mot de passe. Veuillez contacter un administrateur.';
$t['The email address is incorrectly formatted. Try Again.'] = 'L’adresse email est mal formatée. Veuillez réessayer.';
$t['The email address does not match what was stored. Please try again or contact an administrator.'] = 'L’adresse email ne correspond pas à celle qui est enregistrée. Réessayez ou contactez un administrateur.';
$t['An email has been sent to your address. It contains a link that will allow you to change your password.'] = 'Un courriel vient d’être envoyé à votre adresse. Il contient un lien vous qui vous permettra de changer votre mot de passe.';
$t['Hello'] = 'Bonjour';
$t['You asked to reset your password on '] = 'Vous avez demandé à réinitialiser votre mot de passe sur ';
$t['Please click on the link below in order to complete the change password form:'] = 'Veuillez cliquer sur le lien ci-dessous pour pouvoir remplir le formulaire de changement de mot de passe : ';
$t['Regards,'] = 'Cordialement,';
$t['The team Framasoft'] = 'L’équipe Framasoft';
$t['New password'] = 'Nouveau mot de passe';
// tools.html
$t['Change email'] = 'Changer le courriel';
......@@ -11,4 +23,6 @@ $t['Change your recovery email'] = 'Changer votre courriel de restauration de co
$t['Close'] = 'Fermer';
$t['Email'] = 'Courriel';
$t['Save config'] = 'Enregistrer la configuration';
?>
\ No newline at end of file
......@@ -9,37 +9,43 @@ if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t
require_once $ShaarliRoot . '/plugins/i18n/i18n.php';
}
?>
var recovery = document.getElementById('recovery');
var rMsg = document.getElementById('rMsg');
var rForm = document.getElementById('rForm');
var rPwd = document.getElementById('rPwd');
if(/do=login/i.test(window.location.href)) {
var rForm = document.createElement('div');
rForm.style = 'display:none;';
rForm.id = 'rForm';
rForm.innerHTML =
'<form class="col-md-6 col-md-offset-3 ombre clearfix">'+
'<h2><?php echo t('Password recovery'); ?></h2>'+
'<div class="form-group">'+
'<label for="email"><?php echo t('Email'); ?></label>'+
'<input type="email" id="email" name="email" placeholder="@" class="form-control">'+
'</div>'+
'<button type="submit" value="Recover" class="btn btn-warning pull-right"><?php echo t('Recover'); ?></button>'+
'</form>';
document.loginform.parentNode.insertBefore(rForm, this.nextSibling)
function recoveryForm() {
var rLink = document.getElementById('rLink');
var rForm = document.getElementById('rForm')
if (rLink) {
rLink.parentNode.removeChild(rLink);
rForm.style= 'display:block;';
}
function recoveryForm() {
var rForm = document.getElementById('rForm')
document.loginform.style= 'display:none;';
rForm.style= 'display:block;';
}
function recoveryCancel() {
document.loginform.style= 'display:block;';
rForm.style= 'display:none;';
}
rMsg.style= "display:block;";
document.loginform.parentNode.insertBefore(recovery, document.loginform);
if(/login&recover/i.test(window.location.href)) {
recoveryForm();
if(/recover\&token/i.test(window.location.href) && rPwd !== 'undefined') {
rForm.style= 'display:none;';
document.loginform.parentNode.insertBefore(rPwd, this.nextSibling);
}
var rLink = document.createElement('p');
rLink.className = 'help-block text-right';
rLink.id = 'rLink';
rLink.innerHTML = '<a href="javascript:void(0);" onclick="recoveryForm();return false;" class="text-muted"><?php echo t('I lost my password'); ?></a>';
if(/recover&password/i.test(window.location.href)) {
recoveryCancel();
}
}
var rLink = document.createElement('p');
rLink.className = 'help-block text-right';
rLink.id = 'rLink';
rLink.innerHTML = '<a href="javascript:void(0);" onclick="recoveryForm();return false;" class="text-muted"><?php echo t('I lost my password'); ?></a>';
document.loginform.password.parentNode.insertBefore(rLink, this.nextSibling)
document.loginform.password.parentNode.insertBefore(rLink, this.nextSibling)
}
\ No newline at end of file
<?php
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
// I18n
if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t)) {
function t($txt) { return $txt; }
}
function hook_recovery_render_header($data)
{
if ($data['_PAGE_'] == Router::$PAGE_LOGIN) {
$data['buttons_toolbar'][0] =
'<div id="recovery"><div class="row" id="rMsg" style="display:none;"><div class="container">';
if ( isset($_GET['recover'])) {
/* Step 1 : check email */
if( isset($_POST['email']) && isset($_POST['token']) && tokenOk($_POST['token']) ) {
unset($_SESSION['tokens'][$_POST['token']]);
$c = $GLOBALS;
if($GLOBALS['config']['RECOVERY']['attempt'] >= 10) {
$data['buttons_toolbar'][0] .= '<p class="alert alert-danger">'.t('Too many password recovery attempts. Please contact an administrator.').'</p>';
} elseif (!strstr( $_POST['email'], '@')) {
$data['buttons_toolbar'][0] .= '<p class="alert alert-warning">'.t('The email address is incorrectly formatted. Try Again.').'</p>';
} elseif ( $_POST['email'] != $GLOBALS['config']['RECOVERY']['email'] ) {
$c['config']['RECOVERY']['attempt']++;
$data['buttons_toolbar'][0] .= '<p class="alert alert-warning">'.t('The email address does not match what was stored. Please try again or contact an administrator.').'</p>';
} else {
$data['buttons_toolbar'][0] .= '<p class="alert alert-success">'.t('An email has been sent to your address. It contains a link that will allow you to change your password.').'</p>';
// → create token
$c['config']['RECOVERY']['token'] = sha1(uniqid('',true).'_'.mt_rand().$GLOBALS['salt']);
// → reinit attempt
$c['config']['RECOVERY']['attempt'] = 0;
// → send email with link and token param
$headers = "From: ".$c['title']." <".$c['config']['RECOVERY']['noreply'].">\n";
$headers .= "Reply-To: ".$c['config']['RECOVERY']['noreply']."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Auto-Submitted:auto-generated\n";
$headers .= "Return-Path: <>";
$body = '<html>
<body>
<div>
<p>'.t('Hello').' '.$c['login'].',</p>
<p>
'.t('You asked to reset your password on ').'<a href="'.strtok($_SERVER["REQUEST_URI"],'?').'">'.$c['title'].'</a>.<br>
'.t('Please click on the link below in order to complete the change password form:').'<br/>
<a href="'.strtok($_SERVER["REQUEST_URI"],'?').'?do=login&recover&token='.$c['config']['RECOVERY']['token'].'"></a>
</p>
<p>
'.t('Regards,').'<br>
'.t('The team Framasoft').'
</p>
</div>
</body>
</html>';
mail($c['config']['RECOVERY']['email'], t('New password').' - '.$c['title'], $body, $headers, '');
}
// → write token and/or attempt in data/config.php
writeConfig($c, true);
/* Step 2 : check token */
} elseif (isset($_GET['token'])) {
if($_GET['token'] != $GLOBALS['config']['RECOVERY']['token'] ) {
$data['buttons_toolbar'][0] .= '<p class="alert alert-warning">Le lien pour la récupération du mot de passe n’est pas valide ou a expiré.</p>';
} else {
$data['buttons_toolbar'][0] .= '</div></div>
<div id="rPwd"><form method="POST" class="col-md-6 col-md-offset-3 ombre clearfix" action="?do=login&recover&password" name="changepasswordform" id="changepasswordform">
<input type="hidden" name="token" value="'.getToken().'">
<h2>'. t('Change password') .'</h2>
<div class="form-group clearfix">
<label class="col-sm-4" for="setpassword">'.t('New password:').'</label>
<div class="col-sm-8">
<input type="password" id="setpassword" name="setpassword" class="form-control">
</div>
</div>
<button type="submit" value="Recover" class="btn btn-success pull-right">'. t('Save password') .'</button>
</form></div><div><div>';
}
/* Step 3 : check passwords */
} else {
if( isset($_GET['password']) && isset($_POST['setpassword']) && isset($_POST['token']) ) {
unset($_SESSION['tokens'][$_POST['token']]);
$c = $GLOBALS;
$data['buttons_toolbar'][0] .= '<p class="alert alert-success">Le nouveau mot de passe a bien été enregistré. Vous pouvez à présent vous connecter.</p>';
// on écrit le hash et réinit le token dans la config
$c['hash'] = sha1($_POST['setpassword'].$c['login'].$c['salt']);
$c['config']['RECOVERY']['token'] = '';
writeConfig($c, true);
}
}
}
$data['buttons_toolbar'][0] .= '</div></div>
<div id="rForm" style="display:none;"><form method="POST" class="col-md-6 col-md-offset-3 ombre clearfix" action="?do=login&recover" name="recoverform" id="recoverform">
<input type="hidden" name="token" value="'.getToken().'">
<h2>'. t('Password recovery') .'</h2>
<div class="form-group">
<label for="email">'. t('Email') .'</label>
<input type="email" id="email" name="email" placeholder="@" class="form-control">
</div>
<a href="javascript:void(0);" class="btn btn-default pull-left" onclick="recoveryCancel();return false;">'. t('Cancel') .'</a>
<button type="submit" value="Recover" class="btn btn-warning pull-right">'. t('Recover') .'</button>
</form></div></div>';
}
return $data;
}
function hook_recovery_render_footer($data)
{
if ($data['_LOGGEDIN_'] === false ) {
if ($data['_LOGGEDIN_'] === false && ($data['_PAGE_'] == Router::$PAGE_LOGIN) && !empty($GLOBALS['config']['RECOVERY']['email'])) {
$data['js_files'][] = PluginManager::$PLUGINS_PATH . '/recovery/recovery.js.php';
}
return $data;
}
function hook_recovery_render_tools($data)
{
$html = file_get_contents(PluginManager::$PLUGINS_PATH .'/recovery/tools.html');
// Save new email in config
if( isset($_POST['saveEmail']) && isset($_POST['token']) && tokenOk($_POST['token']) ) {
unset($_SESSION['tokens'][$_POST['token']]);
if(!function_exists(translate)) {
function translate($matches) { return t($matches[1]); }
}
$html = preg_replace_callback('/\{\'(.+)\'\|t\}/i', 'translate', $html );
if (!empty($_POST['email']) && strstr($_POST['email'], '@')) {
if (isset ($GLOBALS['config']['email'])) {
$html = str_replace('value=""', 'value="' . htmlentities($GLOBALS['config']['email']) . '"', $html);
$html = str_replace('{$token}', getToken(), $html);
}
$c = $GLOBALS;
$c['config']['RECOVERY']['email'] = $GLOBALS['config']['RECOVERY']['email'] = $_POST['email'];
$c['config']['RECOVERY']['token'] = '';
// Save new config
try {
writeConfig($c, true);
// Then redirect on the page
if(isset($_SERVER['HTTP_REFERER']) && strstr($_SERVER['HTTP_REFERER'], 'do=tools')) {
header('Location: '.$_SERVER['HTTP_REFERER']);
} else {
header('Location: '.$ShaarliRoot);
}
}
catch(Exception $e) {
error_log(
'ERROR while writing config file after configuration update.' . PHP_EOL .
$e->getMessage()
);
exit;
}
exit;
}
exit;
} else {
$data['tools_plugin'][] = $html;
// Display menu and modal
$html = file_get_contents(PluginManager::$PLUGINS_PATH .'/recovery/tools.html');
return $data;
if(!function_exists('translate')) {
function translate($matches) { return t($matches[1]); }
}
$html = preg_replace_callback('/\{\'(.+)\'\|t\}/i', 'translate', $html );
if (isset ($GLOBALS['config']['RECOVERY']['email'])) {
$html = str_replace('value=""', 'value="' . htmlentities($GLOBALS['config']['RECOVERY']['email']) . '"', $html);
$html = str_replace('{$token}', getToken(), $html);
}
$data['tools_plugin'][] = $html;
return $data;
}
}
......
<?php
$u = $_GET['u'];
if (is_file('u/'.$u.'/data/config.php')) {
require_once 'u/'.$u.'/data/config.php';
require_once 'setconfig.php';
function randomPassword() {
$alphabet = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890';
$pass = array();
$alphaLength = strlen($alphabet) - 1;
for ($i = 0; $i < 8; $i++) {
$n = rand(0, $alphaLength);
$pass[] = $alphabet[$n];
}
return implode($pass);
}
$password = randomPassword();
$c = $GLOBALS;
$c['hash'] = sha1($password.$c['login'].$c['salt']);
$headers = "From: MyFrama <ne-pas-repondre@framasoft.org>\n";
$headers .= "Reply-To: ne-pas-repondre@framasoft.org\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Auto-Submitted:auto-generated\n";
$headers .= "Return-Path: <>";
$body = '<html>
<body>
<div>
<p>Bonjour '.$c['login'].',</p>
<p>
Vous avez demandé à réinitialiser votre mot de passe sur <a href="https://my.framasoft.org/u/'.$c['login'].'">My Frama</a>.<br>
Voici votre nouveau mot de passe : '.$password.'
</p>
<p>
Connectez-vous et changez-le rapidement depuis les paramètres de votre compte.
</p>
<p>
Cordialement,<br>
L’équipe Framasoft
</p>
</div>
</body>
</html>';
writeConfig($c, true, 'u/'.$u.'/data/config.php');
mail($c['config']['email'], 'Nouveau mot de passe - My Frama', $body, $headers, '');
} else {
echo 'pas de fichier config';
}
?>
\ No newline at end of file
<?php
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
require_once $ShaarliRoot . 'data/config.php';
require_once $ShaarliRoot . 'application/Config.php';
$ShaarliURL = str_replace('plugins/recovery', '', dirname($_SERVER['SCRIPT_FILENAME'])); // To change
$c = $GLOBALS;
/* Step 1 : check email */
if( isset($_POST['email'])) {
if($GLOBALS['config']['RECOVERY']['attempt'] >= 10) {
echo "Trop de tentatives de récupération de mot de passe. Veuillez contacter un administrateur.";
exit;
} elseif (strstr( $_POST['email'], '@') {
echo "L'adresse email est mal formatée. Veuillez réessayer.";
exit;
} elseif ( empty($GLOBALS['config']['RECOVERY']['email']) ) {
echo "La configuration du site ne contient pas d'email pour récupérer un mot de passe. Veuillez contacter un administrateur.";
exit;
} else {
if ( $_POST['email'] == $GLOBALS['config']['RECOVERY']['email'] ) {
echo "Ok vous allez recevoir un mail";
// → create token
$c['config']['RECOVERY']['token'] = sha1(uniqid('',true).'_'.mt_rand().$GLOBALS['salt']);
// → reinit attempt
$c['config']['RECOVERY']['attempt'] = 0;
// → send email with link and token param
$headers = "From: ".$c['title']." <".$c['config']['RECOVERY']['noreply'].">\n";
$headers .= "Reply-To: ".$c['config']['RECOVERY']['noreply']."\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-Type: text/html; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "Auto-Submitted:auto-generated\n";
$headers .= "Return-Path: <>";
$body = '<html>
<body>
<div>
<p>Bonjour '.$c['login'].',</p>
<p>
Vous avez demandé à réinitialiser votre mot de passe sur <a href="'.$ShaarliURL.'">'.$c['title'].'</a>.<br>
Veuillez cliquer sur le lien ci-dessous pour pouvoir remplir le formulaire de changement de mot de passe : <br/>
<a href="'.$ShaarliURL.'plugin/recovery/resetpassword.php?token='.$c['config']['RECOVERY']['token'].'"></a>
</p>
<p>
Cordialement,<br>
L’équipe Framasoft
</p>
</div>
</body>
</html>';
mail($c['config']['RECOVERY']['email'], 'Nouveau mot de passe - '.$c['title'], $body, $headers, '');
} else {
$c['config']['RECOVERY']['attempt']++;
echo "L'adresse email ne correspond pas à celle qui est enregistrée. Réessayez ou contactez un administrateur."
}
// → write token and/or attempt in data/config.php
writeConfig($c, true, $ShaarliRoot . 'data/config.php');
}
}
/* Step 2 : check token */
if( isset($_GET['token'])) {
if ( $_GET['token'] == $GLOBALS['config']['RECOVERY']['token'] ) {
// → go form mot de passe. (ajouter input hidden token
} else {
echo "Le lien pour la récupération du mot de passe n'est pas valide ou a expiré."
}
}
/* Step 3 : check passwords */
if( isset($_POST['password1']) && isset($_POST['password2']) && isset($_POST['token'] ) {
if( $_POST['password1'] != $_POST['password2'] ) {
echo "Les mots de passe ne correspondent pas. Veuillez recommencer.";
} else {
// ¬ on écrit le hash et réinit le token dans la config
$c['hash'] = sha1($_POST['password1'].$c['login'].$c['salt']);
$c['config']['RECOVERY']['token'] = '';
writeConfig($c, true, $ShaarliRoot . 'data/config.php');
}
}
?>
\ No newline at end of file
......@@ -6,7 +6,7 @@
<div class="modal fade" id="recovery" tabindex="-1" role="dialog" aria-labelledby="recoveryLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form method="POST" action="?do=configure" name="configform" id="configform">
<form method="POST" action="?do=tools" name="configform" id="configform">
<input type="hidden" name="token" value="{$token}">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">x</span><span class="sr-only">{'Close'|t}</span></button>
......@@ -21,7 +21,7 @@
</div>
</div>
<div class="modal-footer text-right">
<input type="submit" name="Save" value="{'Save config'|t}" class="btn btn-success">
<input type="submit" name="saveEmail" value="{'Save config'|t}" class="btn btn-success">
</div>
</form>
</div>
......
......@@ -10,7 +10,7 @@ function tags_advanced_config($taData)
$html = file_get_contents(PluginManager::$PLUGINS_PATH .'/tags_advanced/tools.html');
$html = str_replace('{$token}', getToken() , $html);
if(!function_exists(translate)) {
if(!function_exists('translate')) {
function translate($matches) { return t($matches[1]); }
}
$html = preg_replace_callback('/\{\'(.+)\'\|t\}/i', 'translate', $html );
......
......@@ -19,8 +19,10 @@
<label for="lf_title">{'Title'|t}</label><input type="text" name="lf_title" id="lf_title" value="{$link.title}" class="form-control"><br>
<label for="lf_description">{'Description'|t}</label><textarea name="lf_description" id="lf_description" class="form-control" rows="4" cols="25">{$link.description}</textarea><br>
<label for="lf_tags">{'Tags'|t}</label>
<input type="text" name="lf_tags" id="lf_tags" value="{$link.tags}" class="form-control"
data-list="{loop="$tags"}{$key}, {/loop}" data-multiple autocomplete="off" ><br>
<input type="text" name="lf_tags" id="lf_tags" aria-describedBy="tagsHelp" value="{$link.tags}" class="form-control"
data-list="{loop="$tags"}{$key}, {/loop}" data-multiple autocomplete="off" >
<p class="text-muted pull-right" id="tagsHelp">{'Tags must be delimited by spaces.<br><small>(ex: "free opensource bookmarks")</small>'|t}</p>
<br>
<label>
<input type="checkbox" name="lf_private" id="lf_private"
......
......@@ -20,6 +20,9 @@
</ul>
<ul class="list-inline pull-right navbar-nav navbar-brand">
{loop="$plugins_header.buttons_toolbar"}
{$value}
{/loop}
<li><a href="#globalSearch" data-toggle="modal" title="{'Search'|t}">
<i class="fa fa-fw fa-lg fa-search"></i><span class="sr-only">{'Search'|t}</span>
</a></li>
......@@ -101,4 +104,3 @@
</div>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment