~ubuntu-branches/ubuntu/utopic/lasso/utopic-proposed

« back to all changes in this revision

Viewing changes to php/examples/sample-sp/index.php

  • Committer: Bazaar Package Importer
  • Author(s): Frederic Peters
  • Date: 2004-09-13 09:26:34 UTC
  • Revision ID: james.westby@ubuntu.com-20040913092634-01vdfl8j9cp94exa
Tags: upstream-0.4.1
ImportĀ upstreamĀ versionĀ 0.4.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?php
 
2
/*  
 
3
 * Service Provider Example -- Index File
 
4
 *
 
5
 * Copyright (C) 2004 Entr'ouvert
 
6
 * http://lasso.entrouvert.org
 
7
 * 
 
8
 * Authors: Christophe Nowicki <cnowicki@easter-eggs.com>
 
9
 *
 
10
 * This program is free software; you can redistribute it and/or modify
 
11
 * it under the terms of the GNU General Public License as published by
 
12
 * the Free Software Foundation; either version 2 of the License, or
 
13
 * (at your option) any later version.
 
14
 * 
 
15
 * This program is distributed in the hope that it will be useful,
 
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
18
 * GNU General Public License for more details.
 
19
 * 
 
20
 * You should have received a copy of the GNU General Public License
 
21
 * along with this program; if not, write to the Free Software
 
22
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
23
 */
 
24
 
 
25
 if(!extension_loaded('lasso')) {
 
26
        $ret = @dl('lasso.' . PHP_SHLIB_SUFFIX);
 
27
        if ($ret == FALSE)
 
28
        {
 
29
?>
 
30
<p align='center'><b>The Lasso Extension is not available</b><br>
 
31
Please check your PHP extensions<br>
 
32
You can get more informations about <b>Lasso</b> at <br>
 
33
<a href='http://lasso.entrouvert.org/'>http://lasso.entrouvert.org/</a></p>
 
34
<?php
 
35
        exit();
 
36
        }
 
37
 }
 
38
 
 
39
 if (!file_exists('config.inc'))
 
40
  {
 
41
?>
 
42
<p align='center'><b>Service Provider Configuration file is not available</b><br>
 
43
Please run the setup script :<br>
 
44
<a href='setup.php'>Lasso Service Provider Setup</a><br>
 
45
You can get more informations about <b>Lasso</b> at <br>
 
46
<a href='http://lasso.entrouvert.org/'>http://lasso.entrouvert.org/</a></p>
 
47
<?php
 
48
  exit();
 
49
  }
 
50
 
 
51
 $config = unserialize(file_get_contents('config.inc'));
 
52
 
 
53
 require_once 'DB.php';
 
54
 
 
55
 if (!empty($_GET['SID'])) 
 
56
  session_start($_GET['SID']);
 
57
 else
 
58
  session_start();
 
59
 
 
60
 lasso_init();
 
61
 
 
62
?>
 
63
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
64
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 
65
<head>
 
66
<title>Lasso Service Provider Example</title>
 
67
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-15" />
 
68
</head>
 
69
 
 
70
<body>
 
71
<p>
 
72
<table border="1" frame="above">
 
73
<tr>
 
74
  <td><b>Service Provider Administration</b></td>
 
75
</tr>
 
76
<tr>
 
77
  <td><a href="setup.php">Setup</a></td>
 
78
</tr>
 
79
<tr>
 
80
  <td><a href="admin_user.php">Users Management</a></td>
 
81
</tr>
 
82
<tr>
 
83
  <td><b>Serice Provider Fonctionnality</b></td>
 
84
</tr>
 
85
<?php
 
86
  if (!isset($_SESSION["nameidentifier"])) {  
 
87
  ?>
 
88
<tr>
 
89
  <td><a href="login.php">Login!</a></td>
 
90
</tr>
 
91
<?php } else { ?>
 
92
<tr>
 
93
  <td><a href="logout.php?SID=<?php echo $SID ?>">Logout!</a></td>
 
94
</tr>
 
95
<?php } ?>
 
96
</table>
 
97
</p>
 
98
<p>
 
99
<table border="1" frame="above">
 
100
<caption><b>Status</b></caption>
 
101
<tr>
 
102
  <?php 
 
103
        if (!isset($_SESSION["nameidentifier"]))
 
104
        {
 
105
          echo "<td>User is <b>not</b> logged in!</td>";
 
106
        }
 
107
        else 
 
108
        { 
 
109
          ?>
 
110
        <td colspan='2' align="center">User <b>is</b> logged in!</td>
 
111
</tr>
 
112
<tr>
 
113
        <td><b>Name Identifier:</b></td><td><?php echo $_SESSION["nameidentifier"]; ?></td>
 
114
</tr>
 
115
<tr>
 
116
        <td><b>UserID:</b></td><td><?php echo $_SESSION["user_id"]; ?></td>
 
117
</tr>
 
118
<?php
 
119
  $db = &DB::connect($config['dsn']);
 
120
 
 
121
  if (DB::isError($db)) 
 
122
        die($db->getMessage());
 
123
 
 
124
  $query = "SELECT * FROM users WHERE user_id='". $_SESSION["user_id"] ."'"; 
 
125
 
 
126
  $res =& $db->query($query);
 
127
  if (DB::isError($res)) 
 
128
        print $res->getMessage(). "\n";
 
129
 
 
130
  list($user_id, $identity_dump, $first_name, $last_name, $created, $last_login) = $res->fetchRow();
 
131
 
 
132
  ?>
 
133
<tr>
 
134
        <td><b>Last Name:</b></td><td><?php echo $last_name; ?></td>
 
135
</tr>
 
136
<tr>
 
137
        <td><b>First Name:</b></td><td><?php echo $first_name; ?></td>
 
138
</tr>
 
139
<tr>
 
140
        <td><b>PHP Session ID:</b></td><td><?php echo session_id(); ?></td>
 
141
</tr>
 
142
<tr>
 
143
        <td><b>Account Created:</b></td><td><?php echo $created; ?></td>
 
144
</tr>
 
145
<tr>
 
146
        <td><b>Last Login:</b></td><td><?php echo $last_login; ?></td>
 
147
  <?php 
 
148
        $db->disconnect();
 
149
        } 
 
150
        ?>
 
151
</tr>
 
152
</table>
 
153
</p>
 
154
<!-- <p>Lasso Version : <?php // echo lasso_version(); ?></p> -->
 
155
 
 
156
<br>
 
157
<p>Copyright &copy; 2004 Entr'ouvert</p>
 
158
 
 
159
</body>
 
160
 
 
161
</html>
 
162
<?php
 
163
        lasso_shutdown();
 
164
  ?>