Converting number of Excel column names no longer limited
[phpmyadmin/arisferyanto.git] / libraries / auth / signon.auth.lib.php
blobc4b25a46f6cfc57083283fb7278f58b9fd8ae93e
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Set of functions used to run single signon authentication.
6 * @package phpMyAdmin-Auth-Signon
7 * @version $Id$
8 */
11 /**
12 * Displays authentication form
14 * @global string the font face to use in case of failure
15 * @global string the default font size to use in case of failure
16 * @global string the big font size to use in case of failure
18 * @return boolean always true (no return indeed)
20 * @access public
22 function PMA_auth() {
23 if (empty($GLOBALS['cfg']['Server']['SignonURL'])) {
24 PMA_fatalError('You must set SignonURL!');
25 } elseif (!empty($_REQUEST['old_usr']) && !empty($GLOBALS['cfg']['Server']['LogoutURL'])) {
26 /* Perform logout to custom URL */
27 PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['LogoutURL']);
28 } else {
29 PMA_sendHeaderLocation($GLOBALS['cfg']['Server']['SignonURL']);
31 exit();
32 } // end of the 'PMA_auth()' function
35 /**
36 * Gets advanced authentication settings
38 * @global string the username if register_globals is on
39 * @global string the password if register_globals is on
40 * @global array the array of server variables if register_globals is
41 * off
42 * @global array the array of environment variables if register_globals
43 * is off
44 * @global string the username for the ? server
45 * @global string the password for the ? server
46 * @global string the username for the WebSite Professional server
47 * @global string the password for the WebSite Professional server
48 * @global string the username of the user who logs out
50 * @return boolean whether we get authentication settings or not
52 * @access public
54 function PMA_auth_check()
56 global $PHP_AUTH_USER, $PHP_AUTH_PW;
58 /* Session name */
59 $session_name = $GLOBALS['cfg']['Server']['SignonSession'];
61 /* Current host */
62 $single_signon_host = $GLOBALS['cfg']['Server']['host'];
64 /* Current port */
65 $single_signon_port = $GLOBALS['cfg']['Server']['port'];
67 /* Are we requested to do logout? */
68 $do_logout = !empty($_REQUEST['old_usr']);
70 /* Does session exist? */
71 if (isset($_COOKIE[$session_name])) {
72 /* End current session */
73 $old_session = session_name();
74 $old_id = session_id();
75 session_write_close();
77 /* Load single signon session */
78 session_name($session_name);
79 session_id($_COOKIE[$session_name]);
80 session_start();
82 /* Grab credentials if they exist */
83 if (isset($_SESSION['PMA_single_signon_user'])) {
84 if ($do_logout) {
85 $PHP_AUTH_USER = '';
86 } else {
87 $PHP_AUTH_USER = $_SESSION['PMA_single_signon_user'];
90 if (isset($_SESSION['PMA_single_signon_password'])) {
91 if ($do_logout) {
92 $PHP_AUTH_PW = '';
93 } else {
94 $PHP_AUTH_PW = $_SESSION['PMA_single_signon_password'];
97 if (isset($_SESSION['PMA_single_signon_host'])) {
98 $single_signon_host = $_SESSION['PMA_single_signon_host'];
101 if (isset($_SESSION['PMA_single_signon_port'])) {
102 $single_signon_port = $_SESSION['PMA_single_signon_port'];
106 /* Also get token as it is needed to access subpages */
107 if (isset($_SESSION['PMA_single_signon_token'])) {
108 /* No need to care about token on logout */
109 $pma_token = $_SESSION['PMA_single_signon_token'];
112 /* End single signon session */
113 session_write_close();
115 /* Restart phpMyAdmin session */
116 session_name($old_session);
117 if (!empty($old_id)) {
118 session_id($old_id);
120 session_start();
122 /* Set the single signon host */
123 $GLOBALS['cfg']['Server']['host']=$single_signon_host;
125 /* Set the single signon port */
126 $GLOBALS['cfg']['Server']['port'] = $single_signon_port;
127 /* Restore our token */
128 if (!empty($pma_token)) {
129 $_SESSION[' PMA_token '] = $pma_token;
133 // Returns whether we get authentication settings or not
134 if (empty($PHP_AUTH_USER)) {
135 return false;
136 } else {
137 return true;
139 } // end of the 'PMA_auth_check()' function
143 * Set the user and password after last checkings if required
145 * @global array the valid servers settings
146 * @global integer the id of the current server
147 * @global array the current server settings
148 * @global string the current username
149 * @global string the current password
151 * @return boolean always true
153 * @access public
155 function PMA_auth_set_user()
157 global $cfg;
158 global $PHP_AUTH_USER, $PHP_AUTH_PW;
160 $cfg['Server']['user'] = $PHP_AUTH_USER;
161 $cfg['Server']['password'] = $PHP_AUTH_PW;
163 return true;
164 } // end of the 'PMA_auth_set_user()' function
168 * User is not allowed to login to MySQL -> authentication failed
170 * @return boolean always true (no return indeed)
172 * @access public
174 function PMA_auth_fails()
176 $error = PMA_DBI_getError();
177 if ($error && $GLOBALS['errno'] != 1045) {
178 PMA_fatalError($error);
179 } else {
180 PMA_auth();
181 return true;
184 } // end of the 'PMA_auth_fails()' function