1 | <?php
|
---|
2 | /* $Id: signon.php 9366 2006-08-27 11:46:12Z lem9 $ */
|
---|
3 | // vim: expandtab sw=4 ts=4 sts=4:
|
---|
4 |
|
---|
5 | // Single signon for phpMyAdmin
|
---|
6 | //
|
---|
7 | // This is just example how to use single signon with phpMyAdmin, it is
|
---|
8 | // not intended to be perfect code and look, only shows how you can
|
---|
9 | // integrate this functionality in your application.
|
---|
10 |
|
---|
11 | /* Was data posted? */
|
---|
12 | if (isset($_POST['user'])) {
|
---|
13 | /* Need to have cookie visible from parent directory */
|
---|
14 | session_set_cookie_params(0, '/', '', 0);
|
---|
15 | /* Create signon session */
|
---|
16 | $session_name = 'SignonSession';
|
---|
17 | session_name($session_name);
|
---|
18 | session_start();
|
---|
19 | /* Store there credentials */
|
---|
20 | $_SESSION['PMA_single_signon_user'] = $_POST['user'];
|
---|
21 | $_SESSION['PMA_single_signon_password'] = $_POST['password'];
|
---|
22 | $id = session_id();
|
---|
23 | /* Close that session */
|
---|
24 | session_write_close();
|
---|
25 | /* Redirect to phpMyAdmin (should use absolute URL here!) */
|
---|
26 | header('Location: ../index.php');
|
---|
27 | } else {
|
---|
28 | /* Show simple form */
|
---|
29 | header('Content-Type: text/html; charset=utf-8');
|
---|
30 | echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
|
---|
31 | ?>
|
---|
32 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
---|
33 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
---|
34 | <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
|
---|
35 | <head>
|
---|
36 | <link rel="icon" href="../favicon.ico" type="image/x-icon" />
|
---|
37 | <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
|
---|
38 | <title>phpMyAdmin single signon example</title>
|
---|
39 | <html>
|
---|
40 | <body>
|
---|
41 | <form action="signon.php" method="post">
|
---|
42 | Username: <input type="text" name="user" /><br />
|
---|
43 | Password: <input type="password" name="password" /><br />
|
---|
44 | <input type="submit" />
|
---|
45 | </form>
|
---|
46 | </body>
|
---|
47 | </html>
|
---|
48 | <?php
|
---|
49 | }
|
---|
50 | ?>
|
---|