Ejemplo n.º 1
0
<?php

require_once '../includes/base.inc.php';
$auth = new Authentication();
$users = new Users();
if (!isset($_SESSION['auth']['id'])) {
    header('Location: index.php');
    exit;
}
if (!empty($_POST)) {
    if (!empty($_POST['oldpw']) && !empty($_POST['newpw']) && !empty($_POST['newpw2'])) {
        if ($_POST['newpw'] == $_POST['newpw2']) {
            $change = $auth->changePassword($_SESSION['auth']['user'], $_POST['oldpw'], $_POST['newpw']);
            if ($change == false) {
                $smarty->assign('error', 'Unable to change password. Please try again');
            } else {
                $smarty->assign('error', 'Your password has been changed');
            }
        } else {
            $smarty->assign('error', 'New passwords do not match');
        }
    }
    if (!empty($_POST['user']) && !empty($_POST['pass'])) {
        $add = $users->createUser($_POST['user'], $_POST['pass']);
        if ($add != false) {
            header('Location: users.php');
        }
        $smarty->assign('error', 'Unable to create user. Please try again');
    }
}
if (!empty($_GET['delete'])) {
Ejemplo n.º 2
0
//If user is not logged in then return to index page
if (!isset($_SESSION['user_id'])) {
    header("Location: index.php");
    exit;
}
$post_value = $_POST;
//Check logout request.
if (isset($post_value['value']) && $post_value['value'] == 'logout') {
    //Call logout function
    Authentication::logout();
} elseif (!empty($post_value['update'])) {
    //Call Update profile function
    Authentication::updateProfile($post_value);
} elseif (isset($post_value['newpassword']) && !empty($post_value['newpassword'])) {
    //Call change Password function
    Authentication::changePassword($post_value);
} elseif (isset($post_value['password']) && !empty($post_value['password'])) {
    //Call Set password function
    Authentication::setPassword($post_value);
} elseif (isset($post_value['value']) && $post_value['value'] == 'accountUnLink') {
    //Call Update profile function
    Authentication::unlinkAccount($post_value);
} elseif (isset($post_value['value']) && $post_value['value'] == 'accountLink') {
    //Call Update profile function
    Authentication::linkAccount($post_value);
}
$data = $_SESSION['userprofile'];
include_once 'includes/header.php';
?>
<!-- Add Profile page content-->
<div class="lr-profile-frame lr-input-style">