aboutsummaryrefslogtreecommitdiff
path: root/srcs/phpmyadmin/examples/signon.php
diff options
context:
space:
mode:
authorCharles <sircharlesaze@gmail.com>2020-01-09 10:55:03 +0100
committerCharles <sircharlesaze@gmail.com>2020-01-09 13:09:38 +0100
commit04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa (patch)
tree5c691241355c943a3c68ddb06b8cf8c60aa11319 /srcs/phpmyadmin/examples/signon.php
parent7e0d85db834d6351ed85d01e5126ac31dc510b86 (diff)
downloadft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.gz
ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.tar.bz2
ft_server-04d6d5ca99ebfd1cebb8ce06618fb3811fc1a8aa.zip
phpmyadmin working
Diffstat (limited to 'srcs/phpmyadmin/examples/signon.php')
-rw-r--r--srcs/phpmyadmin/examples/signon.php76
1 files changed, 76 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/examples/signon.php b/srcs/phpmyadmin/examples/signon.php
new file mode 100644
index 0000000..73f26fe
--- /dev/null
+++ b/srcs/phpmyadmin/examples/signon.php
@@ -0,0 +1,76 @@
+<?php
+/* vim: set expandtab sw=4 ts=4 sts=4: */
+/**
+ * Single signon for phpMyAdmin
+ *
+ * This is just example how to use session based single signon with
+ * phpMyAdmin, it is not intended to be perfect code and look, only
+ * shows how you can integrate this functionality in your application.
+ *
+ * @package PhpMyAdmin
+ * @subpackage Example
+ */
+declare(strict_types=1);
+
+/* Use cookies for session */
+ini_set('session.use_cookies', 'true');
+/* Change this to true if using phpMyAdmin over https */
+$secure_cookie = false;
+/* Need to have cookie visible from parent directory */
+session_set_cookie_params(0, '/', '', $secure_cookie, true);
+/* Create signon session */
+$session_name = 'SignonSession';
+session_name($session_name);
+// Uncomment and change the following line to match your $cfg['SessionSavePath']
+//session_save_path('/foobar');
+@session_start();
+
+/* Was data posted? */
+if (isset($_POST['user'])) {
+ /* Store there credentials */
+ $_SESSION['PMA_single_signon_user'] = $_POST['user'];
+ $_SESSION['PMA_single_signon_password'] = $_POST['password'];
+ $_SESSION['PMA_single_signon_host'] = $_POST['host'];
+ $_SESSION['PMA_single_signon_port'] = $_POST['port'];
+ /* Update another field of server configuration */
+ $_SESSION['PMA_single_signon_cfgupdate'] = ['verbose' => 'Signon test'];
+ $id = session_id();
+ /* Close that session */
+ @session_write_close();
+ /* Redirect to phpMyAdmin (should use absolute URL here!) */
+ header('Location: ../index.php');
+} else {
+ /* Show simple form */
+ header('Content-Type: text/html; charset=utf-8');
+ echo '<?xml version="1.0" encoding="utf-8"?>' , "\n";
+ ?>
+ <!DOCTYPE HTML>
+ <html lang="en" dir="ltr">
+ <head>
+ <link rel="icon" href="../favicon.ico" type="image/x-icon">
+ <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon">
+ <meta charset="utf-8">
+ <title>phpMyAdmin single signon example</title>
+ </head>
+ <body>
+ <?php
+ if (isset($_SESSION['PMA_single_signon_error_message'])) {
+ echo '<p class="error">';
+ echo $_SESSION['PMA_single_signon_error_message'];
+ echo '</p>';
+ }
+ ?>
+ <form action="signon.php" method="post">
+ Username: <input type="text" name="user"><br>
+ Password: <input type="password" name="password"><br>
+ Host: (will use the one from config.inc.php by default)
+ <input type="text" name="host"><br>
+ Port: (will use the one from config.inc.php by default)
+ <input type="text" name="port"><br>
+ <input type="submit">
+ </form>
+ </body>
+ </html>
+ <?php
+}
+?>