Translated using Weblate (Japanese)
[phpmyadmin.git] / examples / signon.php
blob0927fa84e2b75ad1ed7c32001e081c048af8a171
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 /* Change this to true if using phpMyAdmin over https */
15 $secure_cookie = false;
16 /* Need to have cookie visible from parent directory */
17 session_set_cookie_params(0, '/', '', $secure_cookie, true);
18 /* Create signon session */
19 $session_name = 'SignonSession';
20 session_name($session_name);
21 // Uncomment and change the following line to match your $cfg['SessionSavePath']
22 //session_save_path('/foobar');
23 @session_start();
25 /* Was data posted? */
26 if (isset($_POST['user'])) {
27 /* Store there credentials */
28 $_SESSION['PMA_single_signon_user'] = $_POST['user'];
29 $_SESSION['PMA_single_signon_password'] = $_POST['password'];
30 $_SESSION['PMA_single_signon_host'] = $_POST['host'];
31 $_SESSION['PMA_single_signon_port'] = $_POST['port'];
32 /* Update another field of server configuration */
33 $_SESSION['PMA_single_signon_cfgupdate'] = array('verbose' => 'Signon test');
34 $id = session_id();
35 /* Close that session */
36 @session_write_close();
37 /* Redirect to phpMyAdmin (should use absolute URL here!) */
38 header('Location: ../index.php');
39 } else {
40 /* Show simple form */
41 header('Content-Type: text/html; charset=utf-8');
42 echo '<?xml version="1.0" encoding="utf-8"?>' , "\n";
44 <!DOCTYPE HTML>
45 <html lang="en" dir="ltr">
46 <head>
47 <link rel="icon" href="../favicon.ico" type="image/x-icon" />
48 <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
49 <meta charset="utf-8" />
50 <title>phpMyAdmin single signon example</title>
51 </head>
52 <body>
53 <?php
54 if (isset($_SESSION['PMA_single_signon_error_message'])) {
55 echo '<p class="error">';
56 echo $_SESSION['PMA_single_signon_error_message'];
57 echo '</p>';
60 <form action="signon.php" method="post">
61 Username: <input type="text" name="user" /><br />
62 Password: <input type="password" name="password" /><br />
63 Host: (will use the one from config.inc.php by default)
64 <input type="text" name="host" /><br />
65 Port: (will use the one from config.inc.php by default)
66 <input type="text" name="port" /><br />
67 <input type="submit" />
68 </form>
69 </body>
70 </html>
71 <?php