1<?php
2/**
3 * Test for the LiveUser class
4 * ===============================
5 *
6 * This example sets up an authorization system using the LiveUser
7 * class. You don't have to use this to use the LiveUser class(es), but
8 * this way you don't need to take care of the login-process, storing
9 * the user object in a session and more...
10 *
11 * This example is intended to be used with the DB_Medium Perm driver.
12 *
13 * @version $Id: coffeemaker.php 175041 2004-12-18 21:59:05Z lsmith $
14 **/
15
16// Include configuration.
17require_once 'conf.php';
18
19if (!$LU) {
20    die('An unknown error occurred');
21}
22
23?>
24<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
25<html>
26<head>
27    <title>Example Coffeemaker</title>
28    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
29    <style type="text/css">
30    <!--
31    table {
32        background-color: #CCCCCC;
33        border-color: 1px solid #000;
34    }
35    body {
36        font-family: Verdana, Arial, Helvetica, sans-serif;
37        font-size: 12px;
38        color: #000000;
39        background-color: #FFFFFF
40    }
41
42    .center {
43           text-align: center;
44    }
45    .center table {
46           margin: auto;
47    }
48    -->
49    </style>
50</head>
51
52<body>
53    <h1>Welcome in the Coffeemaker section!</h1>
54    <p>&nbsp;</p>
55<?php
56// check login status
57if (!$LU->isLoggedIn()) {
58    $target = 'coffeemaker.php';
59    include_once 'loginscreen.php';
60    exit();
61} else {
62    if (!$LU->checkRight(MAKE_COFFEE) && !$LU->checkRight(DRINK_COFFEE)) {
63?>
64            <p>Sorry, but you don't have any rights in this section</p>
65<?php
66    } else {
67        // Okay, he's in. Now let's display some content dependent of
68        // his access rights in our application. Let's pretend the current
69        // AuthArea of our application is the Coffeemaker section and we want to
70        // know whether to user is allowed to make some coffee
71        // (the area is not needed until we won't know whether our user is an area
72        // admin).
73        if ($LU->checkRight(MAKE_COFFEE)) {
74?>
75            <p>Congrats, you're in the Coffeemaker section and have
76            the right to make coffee!</p>
77<?php
78        } else {
79?>
80            <p>Your coffee tastes so bad, I won't allow you to make some</p>
81<?php
82        }
83        // check if the user is allowed to drink coffee. checkRight will return the level.
84        if ($LU->checkRight(DRINK_COFFEE) == 1) {
85?>
86                <p>Yey ! You can even drink some coffee (but perhaps you should ask your boss first ;-) ))</p>
87<?php
88        } elseif ($LU->checkRight(DRINK_COFFEE) == 3) {
89?>
90                <p>Hi <?php echo $LU->getProperty('handle'); ?>! Taste this delicious coffee.</p>
91<?php
92        } else {
93?>
94                <p>Well, sorry dude, you cannot drink in here</p>
95<?php
96        }
97    }
98}
99?>
100    <p>&nbsp;</p>
101    <p class="center"><a href="coffeemaker.php?logout=1">Logout</a></p>
102</body>
103</html>