<?php include_once 'includes/config.php'; /* * Traitement du formulaire. */ if (Session::isAlreadyConnected()) { $usr = User::findByEmail(Session::getSessionEmail()); if ($usr == null) { $errors["other"] = "Impossible to load your data."; } else { if (isset($_POST["changepwd"])) { $errors = array(); $formValid = true; $old = Tools::prepareUserArgString($_POST["old"]); $new = Tools::prepareUserArgString($_POST["new"]); $new2 = Tools::prepareUserArgString($_POST["new2"]); if (!$usr->isPasswordCorrect($old)) { $formValid = false; $errors["old"] = "The old password is not correct."; } if (!Tools::verifyPassword($new)) { $formValid = false; $errors["new"] = "You must insert a valid password see password <a href=\"#\">hint</a>."; } // Si non-identique. if ($new !== $new2) { $formValid = false; $errors["new2"] = "You must insert the same password twice."; } if ($formValid) {
$message = Message::create($subject, $texte, Session::getSessionEmail(), $to); } catch (Exception $e) { $errors["other"] = $e->getMessage(); } } } } else { if (isset($get)) { if (Tools::isStringValid($get) && isGetType($type)) { $type = $get; if (!isNew($type)) { $id = Tools::prepareUserArgInteger($_GET["id"]); try { $message = Message::readMessage($get, Session::getSessionEmail(), $id); if (isReceive($type)) { $message->setUnread(false, Session::getSessionEmail())->doUpdate(); } } catch (Exception $e) { $validRequest = false; } } } } } } } } ?> <!DOCTYPE html> <html lang="en">
<th class="col-sm-3"><?php if ($page == "inbox") { echo "From"; } else { echo "To"; } ?> </th> <th class="col-sm-3">Subject</th> <th class="col-sm-2">Message</th> <th class="col-sm-2">Action</th> </tr> </thead> <tbody> <?php $messages = $page == "inbox" ? Message::getMessagesReceive(Session::getSessionEmail()) : Message::getMessagesSent(Session::getSessionEmail()); foreach ($messages as $key => $msg) { ?> <tr <?php if ($page == "inbox" && $msg->isUnread()) { echo 'class="info"'; } ?> > <td><?php echo $msg->getDate(); ?> </td> <td><?php if ($page == "inbox") {
<!-- END user is not connected --> <?php } ?> </ul> <!-- END left navbar --> <!-- Right navbar --> <ul class="nav navbar-nav navbar-right"> <?php if (Session::isAlreadyConnected()) { ?> <!-- User is connected --> <li> <p class="navbar-text">Logged as <?php echo Session::getSessionEmail(); ?> </p> </li> <li><a href="<?php echo $LOGOUT; ?> "><span class="glyphicon glyphicon-log-out"></span> Logout</a></li> <!-- END user is connected --> <?php } else { ?> <!-- User is not connected --> <!-- Login form --> <li>