public function login()
 {
     $data = array();
     $usersCollection = new UserCollection();
     $errors = array();
     if ($_SERVER['REQUEST_METHOD'] === 'POST') {
         if (isset($_POST['username'])) {
             if (isset($_POST['username']) && isset($_POST['password']) && strlen($_POST['username']) > 3 && strlen($_POST['password']) > 3) {
                 $password = sha1($_POST['password']);
                 $username = htmlspecialchars(trim($_POST['username']));
                 $where = array('username' => $username);
                 $result = $usersCollection->getAll($where);
                 if ($result != null && $result[0]->getPassword() == $password) {
                     $_SESSION['user'] = $result[0];
                     $_SESSION['logged_in'] = 1;
                     header('Location: index.php?c=dashboard');
                 } else {
                     $errors['login'] = '******';
                 }
             } else {
                 $errors['login'] = '******';
             }
         }
     }
     $data['errors'] = $errors;
     $this->loadView('login', $data);
 }
 public function index()
 {
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     $data = array();
     $usersCollection = new UserCollection();
     $page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
     $perPage = 5;
     $offset = $page ? ($page - 1) * $perPage : 0;
     $rows = count($usersCollection->getAll());
     $pagination = new Pagination();
     $pagination->setPerPage($perPage);
     $pagination->setTotalRows($rows);
     $pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/admin/index.php?c=user&m=index");
     $users = $usersCollection->getAll(array(), $offset, $perPage);
     $data['users'] = $users;
     $data['pagination'] = $pagination;
     $this->loadView('users/listing', $data);
 }
 public function index()
 {
     if (!$this->loggedIn()) {
         header('Location: index.php?c=login&m=login');
     }
     $data = array();
     //users
     $userCollection = new UserCollection();
     $users = count($userCollection->getAll());
     //customers
     $clientCollection = new ClientsCollection();
     $client = count($clientCollection->getAll());
     //tours
     $toursCollection = new ToursCollection();
     $tours = count($toursCollection->getAll());
     //blog posts
     $blogpostCollection = new BlogCollection();
     $blogs = count($blogpostCollection->getAll());
     $data['users'] = $users;
     $data['client'] = $client;
     $data['tours'] = $tours;
     $data['blogs'] = $blogs;
     $this->loadView('dashboard', $data);
 }
Example #4
0


</head>

<body>

<?php 
$usersCollection = new UserCollection();
$errors = array();
if (isset($_POST['username'])) {
    if (isset($_POST['username']) && isset($_POST['password']) && strlen($_POST['username']) > 3 && strlen($_POST['password']) > 3) {
        $password = sha1($_POST['password']);
        $username = htmlspecialchars(trim($_POST['username']));
        $where = array('username' => $username);
        $result = $usersCollection->getAll($where);
        if ($result != null && $result[0]->getPassword() == $password) {
            $_SESSION['user'] = $result[0];
            $_SESSION['logged_in'] = 1;
            header('Location: index.php');
        } else {
            $errors['login'] = '******';
        }
    } else {
        $errors['login'] = '******';
    }
}
?>

<div class="container-fluid-full">
    <div class="row-fluid">
Example #5
0
                <a href="addUser.php" class="btn btn-large btn-success pull-right">Create new user</a>
                <table class="table table-striped">
                    <thead>
                    <tr>
                        <th>Username</th>
                        <th>Email</th>
                        <th>Description</th>
                    </tr>
                    </thead>
                    <tbody>
                    <?php 
$usersCollection = new UserCollection();
$page = isset($_GET['page']) ? (int) $_GET['page'] : 1;
$perPage = 5;
$offset = $page ? ($page - 1) * $perPage : 0;
$rows = count($usersCollection->getAll());
$pagination = new Pagination();
$pagination->setPerPage($perPage);
$pagination->setTotalRows($rows);
$pagination->setBaseUrl("http://localhost/Lectures/Lek15/softacadTours/admin/users.php");
$users = $usersCollection->getAll(array(), $offset, $perPage);
foreach ($users as $user) {
    ?>
                        <tr>
                            <td><?php 
    echo $user->getUsername();
    ?>
</td>
                            <td class="center"><?php 
    echo $user->getEmail();
    ?>