예제 #1
0
<?php

use App\App;
use Core\Config;
use App\Vendor\InfoUser;
use App\Vendor\User;
use App\Vendor\Follow;
require 'core/init.php';
if (!connect()) {
    User::redirect('/home.php');
}
//On défini le titre
App::setTitle('Profil');
$id_page = "profil";
/* Si le profil selectionné n'est pas le notre */
if (isset($_GET['user']) && $_GET['user'] != $_SESSION['username']) {
    $profil_userid = $_GET['user'];
    $profil_user = InfoUser::getInstance($DB_con, $profil_userid);
} else {
    /* Sinon si c'est le notre */
    $profil_user = InfoUser::getInstance($DB_con, $_SESSION['username']);
}
/* On récupère ensuite les infos */
$info_profil = $profil_user->getInfo();
$follow = Follow::getInstance($DB_con, $info_profil->id);
if (isset($_POST['SubmitFollow'])) {
    $UserToFollow = htmlspecialchars(trim($_POST['ProfilUserid']));
    if (!empty($UserToFollow)) {
        $follow->Follow();
    }
}
예제 #2
0
    $encoding = 'utf-8';
    $username = htmlspecialchars(trim($_POST['InputUsername']), ENT_QUOTES, $encoding);
    $password = htmlspecialchars(trim($_POST['InputPassword']), ENT_QUOTES, $encoding);
    if (isset($_POST['InputStayOnline'])) {
        $stayonline = htmlspecialchars($_POST['InputStayOnline']);
    } else {
        $stayonline = null;
    }
    /* On vérifie que tous les champs sont saisies */
    if (empty($username) || empty($password)) {
        $errors['FieldsEmpty'] = "Veuillez saisir tous les champs de texte";
    }
    /* On vérifie qu'il n'y a pas d'erreurs */
    if ($errors) {
        $allerror = "<ul>";
        foreach ($errors as $key) {
            $allerror .= "<li>" . $key . "</li>";
        }
        $allerror .= "</ul>";
        setFlash($allerror, "danger");
    } else {
        if ($user->login($username, $password, $stayonline)) {
            User::redirect('/');
        } else {
            $errors['LoginFail'] = "Identifiant ou mot de passe incorrect :/";
            setFlash($errors['LoginFail'], "danger");
        }
    }
}
//On importe la vue
require Config::get('view.paths') . 'connexion.view.php';