Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / examples / signon.php
blob6ab9e240aa2437cf340508119b64de927f69a4cc
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>
41 <html lang="en" dir="ltr">
42 <head>
43 <link rel="icon" href="../favicon.ico" type="image/x-icon" />
44 <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
45 <meta charset="utf-8" />
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