Commit 24e3d3fa authored by  JosephK's avatar JosephK

[recovery] fix js, bookmarklet, mail + [tags] icônes cloud, help config

parent 431a2de1
<?php
// remplacer http par https
define('URL_BASE', str_replace($_SERVER['DOCUMENT_ROOT'], 'http://'.$_SERVER['HTTP_HOST'], dirname($_SERVER['SCRIPT_FILENAME'])) );
define('URL_BASE', str_replace($_SERVER['DOCUMENT_ROOT'], isset($_SERVER['HTTPS']) ? 'https' : 'http').'://'.$_SERVER['HTTP_HOST'], dirname($_SERVER['SCRIPT_FILENAME'])) );
define('TITLE', 'MyFrama');
/**
......@@ -133,9 +133,10 @@ function create_account($account, $password, $email) {
1 => 'myframa',
2 => 'recovery',
3 => 'tags_advanced',
4 => 'addlink_toolbar',
5 => 'qrcode',
6 => 'markdown',
4 => 'framanav',
5 => 'addlink_toolbar',
6 => 'qrcode',
7 => 'markdown',
);
writeConfig($GLOBALS, true, $account_path . '/data/config.php');
......
......@@ -14,38 +14,45 @@ var rMsg = document.getElementById('rMsg');
var rForm = document.getElementById('rForm');
var rPwd = document.getElementById('rPwd');
function recoveryForm() {
var rForm = document.getElementById('rForm')
document.loginform.style= 'display:none;';
rForm.style= 'display:block;';
}
if( recovery !== 'undefined' && rMsg !== 'undefined' && rForm !== 'undefined' && document.loginform !== 'undefined' ) {
function recoveryCancel() {
document.loginform.style= 'display:block;';
rForm.style= 'display:none;';
}
// Show/Hide rForm and loginform
function recoveryForm() {
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);
// Show alert warning/danger/success
rMsg.style= "display:block;";
document.loginform.parentNode.insertBefore(recovery, document.loginform);
if(/login&recover/i.test(window.location.href)) {
// Recovery process = keep the rForm visible
if(/login&recover/i.test(window.location.href)) {
recoveryForm();
recoveryForm();
if(/recover\&token/i.test(window.location.href) && rPwd !== 'undefined') {
rForm.style= 'display:none;';
document.loginform.parentNode.insertBefore(rPwd, this.nextSibling);
}
// Check token send by email = if ok → show the change password form
if(/recover\&token/i.test(window.location.href) && rPwd !== 'undefined') {
rForm.style= 'display:none;';
document.loginform.parentNode.insertBefore(rPwd, this.nextSibling);
}
if(/recover&password/i.test(window.location.href)) {
recoveryCancel();
// Password changed !
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>';
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)
}
<?php
$ShaarliRoot = dirname(dirname(dirname($_SERVER['SCRIPT_FILENAME'])));
$ShaarliURL = (isset($_SERVER['HTTPS']) ? 'https' : 'http') . '://'.$_SERVER['HTTP_HOST'].dirname(strtok($_SERVER['REQUEST_URI'],'?'));
// I18n
if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t)) {
function t($txt) { return $txt; }
......@@ -8,7 +9,7 @@ if(!in_array('i18n',$GLOBALS['config']['ENABLED_PLUGINS']) && !function_exists(t
function hook_recovery_render_header($data)
{
if ($data['_PAGE_'] == Router::$PAGE_LOGIN) {
$data['buttons_toolbar'][0] =
$data['login'] =
'<div id="recovery"><div class="row" id="rMsg" style="display:none;"><div class="container">';
if ( isset($_GET['recover'])) {
......@@ -19,20 +20,20 @@ function hook_recovery_render_header($data)
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>';
$data['login'] .= '<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>';
$data['login'] .= '<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>';
$data['login'] .= '<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>';
$data['login'] .= '<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']);
......@@ -53,9 +54,9 @@ function hook_recovery_render_header($data)
<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('You asked to reset your password on ').'<a href="'.$ShaarliURL.'">'.$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>
<a href="'.$ShaarliURL.'?do=login&recover&token='.$c['config']['RECOVERY']['token'].'">'.$ShaarliURL.'?do=login&recover&token='.$c['config']['RECOVERY']['token'].'</a><br>
</p>
<p>
'.t('Regards,').'<br>
......@@ -75,11 +76,11 @@ function hook_recovery_render_header($data)
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>';
$data['login'] .= '<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>
$data['login'] .= '</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>
......@@ -100,7 +101,7 @@ function hook_recovery_render_header($data)
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>';
$data['login'] .= '<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']);
......@@ -109,7 +110,7 @@ function hook_recovery_render_header($data)
}
}
}
$data['buttons_toolbar'][0] .= '</div></div>
$data['login'] .= '</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>
......
<?php
$t['Tags advanced'] = 'Tags spéciaux';
$t['Close'] = 'Fermer';
$t['To view the special tags on the home page, select the checkbox marked with '] = 'Pour afficher les tags spéciaux sur la page d’accueil, cochez la case marquée d’un ';
$t['Pined?'] = 'Épinglé ?';
$t['The same thing with '] = 'De même avec ';
$t['Private?'] = 'Privé ?';
$t['to keep the tags visible only when you are connected.'] = 'pour garder certains tags visibles uniquement lorsque vous êtes connectés.';
$t['Filters '] = 'Les filtres ';
$t[' are optional.'] = ' sont facultatifs.';
$t['They allow you to add tags to your links automatically according to the <a href="https://en.wikipedia.org/wiki/Regular_expression">pattern</a> found in the <abbr>URL</abbr>.'] = 'Ils permettent d’ajouter des tags automatiquement à vos liens selon le <a href="https://fr.wikipedia.org/wiki/Expression_rationnelle">motif</a> trouvé dans l’<abbr>URL</abbr>.';
$t['Order'] = 'Ordre';
$t['Name'] = 'Nom';
$t['Icon'] = 'Icône';
$t['Filter'] = 'Filtre';
$t['Pined?'] = 'Épinglé ?';
$t['Private?'] = 'Privé ?';
$t['Pined'] = 'Épinglé';
$t['Private'] = 'Privé';
$t['Add tag'] = 'Ajouter un tag';
......
......@@ -123,7 +123,18 @@ function hook_tags_advanced_render_tools($data)
*/
function hook_tags_advanced_render_tagcloud($data)
{
// TODO: add tags icons
require_once 'data/tags_advanced.php';
foreach($taData as $k => $v) {
// add icon
if($data['tags'][$v[0]]['count']>0) {
$data['tags'][$v[0]]['icon'] = '<i class="fa fa-fw fa-lg '.htmlentities($v[1]).'"></i>';
}
// remove private tags
if( $v[4] === true && $data['_LOGGEDIN_'] === false ) { // If tag private
unset($data['tags'][$v[0]]);
}
}
return $data;
}
......
......@@ -10,6 +10,20 @@
</div>
<div class="modal-body">
<div class="form-group clearfix">
<div class="alert alert-info">
<p>
{'To view the special tags on the home page, select the checkbox marked with '|t}
<i class="fa fa-fw fa-lg fa-map-pin"></i><span class="sr-only">{'Pined?'|t}</span>.
{'The same thing with '|t}
<i class="fa fa-fw fa-lg fa-key text-warning"></i><span class="sr-only">{'Private?'|t}</span>
{'to keep the tags visible only when you are connected.'|t}
</p>
<p>{'Filters '|t}
<i class="fa fa-fw fa-lg fa-filter"></i>
{' are optional.'|t}
{'They allow you to add tags to your links automatically according to the <a href="https://en.wikipedia.org/wiki/Regular_expression">pattern</a> found in the <abbr>URL</abbr>.'|t}
</p>
</div>
<table class="table table-hover">
<thead>
<tr>
......
......@@ -16,7 +16,7 @@
<div id="loginform" class="container">
{if="!ban_canLogin()"}
{'You have been banned from login after too many failed attempts. Try later.'|t}
<div class="alert alert-danger">{'You have been banned from login after too many failed attempts. Try later.'|t}</div>
{else}
<div class="row">
<form method="post" name="loginform" class="col-md-6 col-md-offset-3 ombre clearfix">
......
......@@ -102,5 +102,6 @@
{/if}
</div>
</div>
{if="!empty($plugins_header.login)"}{$plugins_header.login}{/if}
......@@ -13,7 +13,10 @@
<div id="cloudtag">
{loop="tags"}
<span class="link-tag">
<a href="?searchtags={$key|urlencode}" style="font-size:{$value.size}em;">{$key} <span class="badge">{$value.count}</span></a>
<a href="?searchtags={$key|urlencode}" style="font-size:{$value.size}em;">
{if="!empty($value.icon)"}{$value.icon}{/if}
{$key} <span class="badge">{$value.count}</span>
</a>
</span>
{loop="$value.tag_plugin"}
{$value}
......
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