Upgraded phpmyadmin to 4.0.4 (All Languages) - No modifications yet
[openemr.git] / phpmyadmin / libraries / plugins / auth / AuthenticationConfig.class.php
blob07ad7cb5537b7d2e23d532f0479c24481f821612
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Config Authentication plugin for phpMyAdmin
6 * @package PhpMyAdmin-Authentication
7 * @subpackage Config
8 */
9 if (! defined('PHPMYADMIN')) {
10 exit;
13 /* Get the authentication interface */
14 require_once 'libraries/plugins/AuthenticationPlugin.class.php';
16 /**
17 * Handles the config authentication method
19 * @package PhpMyAdmin-Authentication
21 class AuthenticationConfig extends AuthenticationPlugin
23 /**
24 * Displays authentication form
26 * @return boolean always true
28 public function auth()
30 return true;
33 /**
34 * Gets advanced authentication settings
36 * @return boolean always true
38 public function authCheck()
40 return true;
43 /**
44 * Set the user and password after last checkings if required
46 * @return boolean always true
48 public function authSetUser()
50 return true;
53 /**
54 * User is not allowed to login to MySQL -> authentication failed
56 * @global string the MySQL error message PHP returns
57 * @global string the connection type (persistent or not)
58 * @global string the MySQL server port to use
59 * @global string the MySQL socket port to use
60 * @global array the current server settings
61 * @global string the font face to use in case of failure
62 * @global string the default font size to use in case of failure
63 * @global string the big font size to use in case of failure
64 * @global boolean tell the "PMA_mysqlDie()" function headers have been
65 * sent
67 * @return boolean always true (no return indeed)
69 public function authFails()
71 $conn_error = PMA_DBI_getError();
72 if (! $conn_error) {
73 $conn_error = __('Cannot connect: invalid settings.');
76 /* HTML header */
77 $response = PMA_Response::getInstance();
78 $response->getFooter()->setMinimal();
79 $header = $response->getHeader();
80 $header->setBodyId('loginform');
81 $header->setTitle(__('Access denied'));
82 $header->disableMenu();
83 echo '<br /><br />
84 <center>
85 <h1>';
86 echo sprintf(__('Welcome to %s'), ' phpMyAdmin ');
87 echo '</h1>
88 </center>
89 <br />
90 <table cellpadding="0" cellspacing="3" style="margin: 0 auto" width="80%">
91 <tr>
92 <td>';
93 if (isset($GLOBALS['allowDeny_forbidden'])
94 && $GLOBALS['allowDeny_forbidden']
95 ) {
96 trigger_error(__('Access denied'), E_USER_NOTICE);
97 } else {
98 // Check whether user has configured something
99 if ($GLOBALS['PMA_Config']->source_mtime == 0) {
100 echo '<p>' . sprintf(
102 'You probably did not create a configuration file.'
103 . ' You might want to use the %1$ssetup script%2$s to'
104 . ' create one.'
106 '<a href="setup/">',
107 '</a>'
108 ) . '</p>' . "\n";
109 } elseif (! isset($GLOBALS['errno'])
110 || (isset($GLOBALS['errno']) && $GLOBALS['errno'] != 2002)
111 && $GLOBALS['errno'] != 2003
113 // if we display the "Server not responding" error, do not confuse
114 // users by telling them they have a settings problem
115 // (note: it's true that they could have a badly typed host name,
116 // but anyway the current message tells that the server
117 // rejected the connection, which is not really what happened)
118 // 2002 is the error given by mysqli
119 // 2003 is the error given by mysql
120 trigger_error(
122 'phpMyAdmin tried to connect to the MySQL server, and the'
123 . ' server rejected the connection. You should check the'
124 . ' host, username and password in your configuration and'
125 . ' make sure that they correspond to the information given'
126 . ' by the administrator of the MySQL server.'
127 ), E_USER_WARNING
130 echo PMA_Util::mysqlDie(
131 $conn_error, '', true, '', false
134 $GLOBALS['error_handler']->dispUserErrors();
135 echo '</td>
136 </tr>
137 <tr>
138 <td>' . "\n";
139 echo '<a href="'
140 . $GLOBALS['cfg']['DefaultTabServer']
141 . PMA_generate_common_url(array()) . '" class="button disableAjax">'
142 . __('Retry to connect')
143 . '</a>' . "\n";
144 echo '</td>
145 </tr>' . "\n";
146 if (count($GLOBALS['cfg']['Servers']) > 1) {
147 // offer a chance to login to other servers if the current one failed
148 include_once './libraries/select_server.lib.php';
149 echo '<tr>' . "\n";
150 echo ' <td>' . "\n";
151 echo PMA_selectServer(true, true);
152 echo ' </td>' . "\n";
153 echo '</tr>' . "\n";
155 echo '</table>' . "\n";
156 exit;
157 return true;
161 * This method is called when any PluginManager to which the observer
162 * is attached calls PluginManager::notify()
164 * @param SplSubject $subject The PluginManager notifying the observer
165 * of an update.
167 * @return void
169 public function update (SplSubject $subject)