Fixed: 'Browse foreign values' not working properly
[phpmyadmin/ammaryasirr.git] / scripts / signon.php
blobd80c1cf9deba1f7d0f0897ee51b4e50f4c661079
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Single signon for phpMyAdmin
6 * This is just example how to use session based single signon with
7 * phpMyAdmin, it is not intended to be perfect code and look, only
8 * shows how you can integrate this functionality in your application.
10 * @package phpMyAdmin
11 * @subpackage Example
14 /* Need to have cookie visible from parent directory */
15 session_set_cookie_params(0, '/', '', 0);
16 /* Create signon session */
17 $session_name = 'SignonSession';
18 session_name($session_name);
19 session_start();
21 /* Was data posted? */
22 if (isset($_POST['user'])) {
23 /* Store there credentials */
24 $_SESSION['PMA_single_signon_user'] = $_POST['user'];
25 $_SESSION['PMA_single_signon_password'] = $_POST['password'];
26 $_SESSION['PMA_single_signon_host'] = $_POST['host'];
27 $_SESSION['PMA_single_signon_port'] = $_POST['port'];
28 /* Update another field of server configuration */
29 $_SESSION['PMA_single_signon_cfgupdate'] = array('verbose' => 'Signon test');
30 $id = session_id();
31 /* Close that session */
32 session_write_close();
33 /* Redirect to phpMyAdmin (should use absolute URL here!) */
34 header('Location: ../index.php');
35 } else {
36 /* Show simple form */
37 header('Content-Type: text/html; charset=utf-8');
38 echo '<?xml version="1.0" encoding="utf-8"?>' . "\n";
40 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
41 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
42 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" dir="ltr">
43 <head>
44 <link rel="icon" href="../favicon.ico" type="image/x-icon" />
45 <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
46 <title>phpMyAdmin single signon example</title>
47 </head>
48 <body>
49 <?php
50 if (isset($_SESSION['PMA_single_signon_error_message'])) {
51 echo '<p class="error">' . $_SESSION['PMA_single_signon_error_message'] . '</p>';
54 <form action="signon.php" method="post">
55 Username: <input type="text" name="user" /><br />
56 Password: <input type="password" name="password" /><br />
57 Host: (will use the one from config.inc.php by default) <input type="text" name="host" /><br />
58 Port: (will use the one from config.inc.php by default) <input type="text" name="port" /><br />
59 <input type="submit" />
60 </form>
61 </body>
62 </html>
63 <?php