Use the user password to log on to phpMyAdmin

Source: Internet
Author: User

People who have used phpMyAdmin know that in phpMyAdmin, the file config. inc. php saves the user name and password. You must modify the config. inc. PHP files, and then upload them again, which is especially inconvenient. Even more, if the root account is used to modify the MYSQL database or table, the index is automatically searched by other websites. it is quite dangerous to continue executing every step of php. Therefore, the user login mechanism is required. It is much safer to enter the user name and password for each use.
The following are some changes made to phpMyAdmin during the management process based on actual needs. To minimize the impact on the structure of the original phpMyAdmin, I added a file index0.php Based on phpMyAdmin, only one file config. inc. php does not have any impact on phpMyAdmin. You can either use the original phpMyAdmin or use the New User Password Logon mechanism.
The following are two file lists. Copy these two files to the phpMyAdmin directory and execute index0.php, the program runs normally in Apache + PHP + MYSQL and IIS5 + PHP + MYSQl and PWS + PHP + MYSQL.
Download phpMyAdmin:
Set of PHP3-scripts to adminstrate MySQL over the WWW.
Version 2.1.0-08/06/2000
Http://www.phpwizard.net/projects/phpMyAdmin/

Index0.php file:

<Html> <! --

<? Php
// Code to prevent display on the address bar
Function b2h ($ string ){
Return (bin2hex (strrev ($ string )));
}

// Anti-encoding to prevent display on the address bar
Function h2b ($ string ){
$ Stringtmp = "";
For ($ I = 0; $ I <strlen ($ string); $ I ++ = 2 ){
$ Stringtmp. = pack ("C", hexdec (substr ($ string, $ I, 2 )));
}
Return (strrev ($ stringtmp ));
}
Global $ PHP_SELF;

If (1 = 0 ){
Echo "--> PHP is not running properly. Please check. <! --";
} Else {
Echo "--". "> ";
}
?>

<? Php
If ($ step = ""){
?>

<P> welcome </p> this tool is used to maintain the MySQL database. </p>
<P> <a href = "<? Echo basename ($ PHP_SELF) ;?>? Step = 2 "> next step-> </a> </p>

<? Php
}
If ($ step = 2 ){

$ Userfiletmp = "/tmp /~ Userfile /~ Tmp. inc ";
If (file_exists ($ userfiletmp )){
Include $ userfiletmp;
// $ Dbservertype, $ servername, $ dbusername, $ dbpassword, $ dbname;
$ Dbservertype = h2b ($ dbservertype );
$ Servername = h2b ($ servername );
$ Dbusername = h2b ($ dbusername );
$ Dbname = h2b ($ dbname );
$ Curtime = h2b ($ curtime );
If (time ()-$ curtime <120 ){
$ Dbpassword = h2b ($ dbpassword );
} Else {
$ Dbpassword = "";
}
} Else {
$ Dbservertype = "mysql ";
$ Servername = "localhost ";
$ Dbusername = "";
$ Dbpassword = "";
$ Dbname = "";
}

$ Dbservertype = ($ dbservertype = ""? "Mysql": $ dbservertype );
$ Servername = ($ servername = ""? "Localhost": $ servername );

?>

<P> enter the connection information. </p>
<Div align = "center">
<Center>
<Table border = "1" width = "53%" height = "111">
<Tr>
<Td width = "100%" height = "105">

<Form method = "POST" action = "<? Echo basename ($ PHP_SELF) ;?>? Step = 3 ">

<Div align = "center">
<Center>
<Table border = "1" width = "83%" height = "60">
<Tr>
<Td width = "34%" height = "10"> host type: </td>
<Td width = "66%" height = "10"> <input type = "text" name = "dbservertype" size = "20" value = "<? Echo $ dbservertype;?> "> </Td>
</Tr>
<Tr>
<Td width = "34%" height = "10"> host address: </td>
<Td width = "66%" height = "10"> <input type = "text" name = "servername" size = "20" value = "<? Echo $ servername;?> "> </Td>
</Tr>
<Tr>
<Td width = "34%" height = "10"> User name: </td>
<Td width = "66%" height = "10"> <input type = "text" name = "dbusername" size = "20" value = "<? Echo $ dbusername;?> "> </Td>
</Tr>
<Tr>
<Td width = "34%" height = "16"> password: </td>
<Td width = "66%" height = "16"> <input type = "password" name = "dbpassword" size = "20" value = "<? Echo $ dbpassword;?> "> </Td>
</Tr>
<Tr>
<Td width = "34%" height = "16"> Database Name: </td>
<Td width = "66%" height = "16"> <input type = "text" name = "dbname" size = "20" value = "<? Echo $ dbname;?> "> </Td>
</Tr>
</Table>
</Center>
</Div>
<P align = "center"> <input type = "submit" value = "next" name = "next"> <input type = "reset" value = "clear" name = "reset"> </p>
</Form>
</Td>
</Tr>
</Table>
</Center>
</Div>

<? Php
}
If ($ step = 3 ){
$ Dbservertype = trim ($ dbservertype );
$ Servername = trim ($ servername );
$ Dbusername = trim ($ dbusername );
$ Dbpassword = trim ($ dbpassword );
$ Dbname = trim ($ dbname );

Echo "<p> confirm the correctness: </p> n ";
Echo "<p> <B> Database server type: </B> $ dbservertype </p> n ";
Echo "<p> <B> Database server hostname/IP address: </B> $ servername </p> n ";
Echo "<p> <B> Database username: </B> $ dbusername </p> n ";
Echo "<p> <B> Database password: </B> ****** </p> n ";
Echo "<p> <B> Database name: </B> $ dbname </p> n ";
Echo "<p> the above parameters are correct before continuing </p> ";

$ Dbservertype = b2h ($ dbservertype );
$ Servername = b2h ($ servername );
$ Dbusername = b2h ($ dbusername );
$ Dbpassword = b2h ($ dbpassword );
$ Dbname = b2h ($ dbname );

$ Userfiletmp = "/tmp /~ Userfile /~ Tmp. inc ";
If (! File_exists (dirname ($ userfiletmp ))){
Mkdir (dirname ($ userfiletmp), 0700 );
}
$ Handertmp = fopen ($ userfiletmp, "w ");
Fputs ($ handertmp, "<? Phpn ");
Fputs ($ handertmp, "$". "dbservertype =" $ dbservertype "; n ");
Fputs ($ handertmp, "$". "servername =" $ servername "; n ");
Fputs ($ handertmp, "$". "dbusername =" $ dbusername "; n ");
Fputs ($ handertmp, "$". "dbpassword =" $ dbpassword "; n ");
Fputs ($ handertmp, "$". "dbname =" $ dbname "; n ");
$ Curtime = time ();
$ Curtime = b2h ($ curtime );
Fputs ($ handertmp, "$". "curtime =" $ curtime "; n ");
Fputs ($ handertmp, "?> N ");
Fclose ($ handertmp );


// Echo "<p> <a href =" ". basename ($ PHP_SELF )."? Step = 4 & servername = $ servername & dbusername = $ dbusername & dbpassword = $ dbpassword & dbname = $ dbname "> next step-> </a> </p> ";
Echo "<p> <a href =" index. php "> next-> </a> </p> ";
}

If ($ step = 4 ){
}

If ($ step = 44 ){
$ Step = 0;
$ Userfiletmp = "/tmp /~ Userfile /~ Tmp. inc ";
If (file_exists ($ userfiletmp )){
Include $ userfiletmp;
// Save the file again and remove the password
$ Dbpassword = "";
$ Handertmp = fopen ($ userfiletmp, "w ");
Fputs ($ handertmp, "<? Phpn ");
Fputs ($ handertmp, "$". "dbservertype =" $ dbservertype "; n ");
Fputs ($ handertmp, "$". "servername =" $ servername "; n ");
Fputs ($ handertmp, "$". "dbusername =" $ dbusername "; n ");
Fputs ($ handertmp, "$". "dbpassword =" $ dbpassword "; n ");
Fputs ($ handertmp, "$". "dbname =" $ dbname "; n ");
$ Curtime = time ();
$ Curtime = b2h ($ curtime );
Fputs ($ handertmp, "$". "curtime =" $ curtime "; n ");
Fputs ($ handertmp, "?> N ");
Fclose ($ handertmp );
Echo "</p> <center> <a href = "". basename ($ PHP_SELF ). ""> log out successfully. Please log in again </a> </center> ";
}
}
?>

<? Php
If ($ step> 1 ){
Echo "</p> <a href = javascript: location. reload ()> refresh </a> ";
Echo "<a href = javascript: history. back ()> previous </a> ";
}
?>

<? Php
Echo "</". "body> ";
Echo "<"."! --";
?>

-->
</Html>

Config. inc. php file

<? Php
/* $ Id: config. inc. php, v 1.28 2000/07/13 13:52:48 tobias Exp $ */

// Code to prevent display on the address bar
Function b2h ($ string ){
Return (bin2hex (strrev ($ string )));
}

// Anti-encoding to prevent display on the address bar
Function h2b ($ string)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.