Edit password almost working

This commit is contained in:
Phyks 2013-08-09 23:43:56 +02:00
parent 399f1bd09f
commit 8970322808
7 changed files with 99 additions and 39 deletions

8
TODO
View File

@ -2,3 +2,11 @@
* Vérification des variables dans les classes + throw exception * Vérification des variables dans les classes + throw exception
* tokens + ban system * tokens + ban system
* TRUNCATE before CREATE TABLE in install.php * TRUNCATE before CREATE TABLE in install.php
install.php :
=============
* Link beside password field to toggle visible / not visible
index.php :
===========
* Edit password doesn't work

View File

@ -10,6 +10,7 @@
$tpl->assign('instance_title', INSTANCE_TITLE); $tpl->assign('instance_title', INSTANCE_TITLE);
$tpl->assign('connection', false); $tpl->assign('connection', false);
$tpl->assign('notice', ''); $tpl->assign('notice', '');
$tpl->assign('error', '');
session_start(); session_start();
$current_user = (isset($_SESSION['current_user']) ? unserialize($_SESSION['current_user']) : false); $current_user = (isset($_SESSION['current_user']) ? unserialize($_SESSION['current_user']) : false);
@ -52,7 +53,22 @@
break; break;
case 'password': case 'password':
if(!empty($_POST['password']) && !empty($_POST['password_confirm'])) {
if($_POST['password'] == $_POST['password_confirm']) {
$user = new User();
$user->setLogin($current_user['login']);
$user->setPassword($user->encrypt($_POST['password']));
$user->setAdmin($current_user['admin']);
$user->setId($current_user['id']);
$user->save();
header('location: index.php');
exit();
}
else {
$tpl->assign('error', 'The content of the two password fields doesn\'t match.');
}
}
$tpl->draw('edit_users'); $tpl->draw('edit_users');
break; break;

View File

@ -1,10 +1,10 @@
<?php if(!class_exists('raintpl')){exit;}?><?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("header") . ( substr("header",-1,1) != "/" ? "/" : "" ) . basename("header") );?> <?php if(!class_exists('raintpl')){exit;}?><?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("header") . ( substr("header",-1,1) != "/" ? "/" : "" ) . basename("header") );?>
<h1><?php echo $instance_title;?> - Connexion</h1> <h1 id="title"><?php echo $instance_title;?> - Connexion</h1>
<form method="post" action="index.php?do=connect"> <form method="post" action="index.php?do=connect" id="connexion_form">
<p><label for="login">Username : </label><input type="text" name="login" id="login"/></p> <p><label for="login" class="label-block">Username : </label><input type="text" name="login" id="login"/></p>
<p><label for="password">Password : </label><input type="password" name="password" id="password"/></p> <p><label for="password" class="label-block">Password : </label><input type="password" name="password" id="password"/></p>
<p><input type="submit" value="Connect"/></p> <p><input type="submit" value="Connect"/></p>
</form> </form>

View File

@ -3,7 +3,36 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title><?php echo $instance_title;?></title> <title><?php echo $instance_title;?></title>
<link rel="stylesheet" media="screen" type="text/css" href="tpl/./misc/style.css" /> <link rel="stylesheet" media="screen" type="text/css" href="tpl/./css/style.css" />
<link rel="icon" href="tpl/./favicon.ico" /> <link rel="icon" href="tpl/./favicon.ico" />
</head> </head>
<body> <body>
<?php if( !$connection ){ ?>
<h1 id="title"><?php echo $instance_title;?></h1>
<?php if( $notice != '' ){ ?>
<p><?php echo $notice;?></p>
<?php } ?>
<div id="menu">
<ul>
<li><a href="index.php?do=new_invoice">Add a bill</a></li>
<li><a href="index.php?do=password">Change your password</a></li>
<li><a href="index.php?do=paybacks">See paybacks</a></li>
</ul>
<?php if( $admin == 1 ){ ?>
<ul>
<li><a href="index.php?do=manage_paybacks">Manage paybacks</a></li>
<li><a href="index.php?do=edit_users">Edit users</a></li>
<li><a href="index.php?do=edit_notics">Edit notice on homepage</a></li>
<li><a href="index.php?do=disconnect">Disconnect</a></li>
</ul>
<?php } ?>
</div>
<?php } ?>

View File

@ -1,49 +1,52 @@
<?php if(!class_exists('raintpl')){exit;}?><?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("header") . ( substr("header",-1,1) != "/" ? "/" : "" ) . basename("header") );?> <?php if(!class_exists('raintpl')){exit;}?><?php $tpl = new RainTPL;$tpl_dir_temp = self::$tpl_dir;$tpl->assign( $this->var );$tpl->draw( dirname("header") . ( substr("header",-1,1) != "/" ? "/" : "" ) . basename("header") );?>
<h1><?php echo $title;?></h1>
<?php echo $notice;?>
<div id="menu">
<ul>
<li><a href="modif.php">Ajouter une dépense</a></li>
<li><a href="modif_password.php">Modifier le mot de passe</a></li>
<li><a href="rbmt.php">Consulter les remboursements</a></li>
</ul>
<?php if( $admin ){ ?>
<ul>
<li><a href="rbmt_admin.php">Gérer les rembourements</a></li>
<li><a href="copains.php">Modifier les copains</a></li>
<li><a href="modif_annonce.php">Modifier l'annonce d'accueil</a></li>
<li><a href="connexion.php?deco=1">Déconnexion</a></li>
</ul>
<?php } ?>
</div>
<div id="quick_summary"> <div id="quick_summary">
<h2>Qui doit quoi ?</h2> <h2>Balance</h2>
<p>Lire <em>ligne</em> doit <em>case</em> à <em>colonne</em>. Les liens permettent de confirmer le paiement des dettes.</p> <p class="center">Read <em>line</em> owes <em>case</em> to <em>column</em>. You can click on links to confirm the payback.
<table> <table>
<tr> <tr>
<th>Doit\À</th> <th>Owes\To</th>
<?php $counter1=-1; if( isset($users) && is_array($users) && sizeof($users) ) foreach( $users as $key1 => $value1 ){ $counter1++; ?>
<th><?php echo $value1["name"];?></th>
<?php } ?>
</tr> </tr>
<?php $counter1=-1; if( isset($users) && is_array($users) && sizeof($users) ) foreach( $users as $key1 => $value1 ){ $counter1++; ?>
<tr>
<th><?php echo $value1["name"];?></th>
</tr>
<?php } ?>
</table> </table>
</div> </div>
<div id="detailed_summary"> <div id="detailed_summary">
<h2>Dépenses détaillées du mois actuel</h2> <h2>Detailed list of bills for last month</h2>
<table> <table>
<tr> <tr>
<th>Date</th> <th>Date</th>
<th>Papar</th> <th>Paid by</th>
<th>Participants</th> <th>Users in</th>
<th>Montant</th> <th>Amount</th>
<th>Menu</th> <th>What ?</th>
<th>Modifier</th> <th>Edit</th>
<th>Supprimer</th> <th>Delete</th>
</tr> </tr>
<?php $counter1=-1; if( isset($bill) && is_array($bill) && sizeof($bill) ) foreach( $bill as $key1 => $value1 ){ $counter1++; ?>
<tr>
<td><?php echo $value1["date"];?></td>
<td><?php echo $value1["buyer"];?></td>
<td><?php echo $value1["users_in"];?></td>
<td><?php echo $value1["amount"];?></td>
<td><?php echo $value1["what"];?></td>
<td><a href="index.php?do=edit_bill&id=">Edit</a></td>
<td><a href="index.php?do=delete_bill&id=">Delete</a></td>
</tr>
<?php } ?>
</table> </table>
</div> </div>

View File

@ -94,7 +94,7 @@ input[type=submit] {
margin: 0; margin: 0;
} }
#install .error { .error {
font-size: 1.5em; font-size: 1.5em;
color: red; color: red;
font-weight: bold; font-weight: bold;

View File

@ -1,5 +1,9 @@
{include="header"} {include="header"}
{if condition="$error != ''"}
<p class="error">{$error}</p>
{/if}
<h2>Edit your password</h2> <h2>Edit your password</h2>
<form method="post" action="index.php?do=password" id="edit_password_form"> <form method="post" action="index.php?do=password" id="edit_password_form">
<p><label for="password" class="label-block">New password : </label><input type="password" id="password" name="password"/></p> <p><label for="password" class="label-block">New password : </label><input type="password" id="password" name="password"/></p>