当前位置: 首页 > 图文教程 > 网络编程 > PHP > 在phpMyAdmin使用用户口令登陆

PHP
PHP教程:插件机制在PHP中实现方案
PHP开源网站程序如何使用的更好
PHP和mysql+jqueyr建立类twitter站点
PHP服务端代理页面开发
PHP理论教程:如何才能自动获取关键词
PHP教程:imagefilledrectangle函数生成渐变图片
PHP教程:配置smarty开发环境
PHP扩展curl和正则表达式轻松采集新闻
PHP4,PHP5,ASP.NET开发优劣比较
PHP教程:PHP随机显示目录下图片的源码
HTTP Headers简明易懂的教程
PHP导入和导出Excel文件
PHP 5.3 的重要特性:命名空间
PHP教程:GD库的imagecolorset函数简单修改图片颜色
PHP5教程:PHP的GD模块生成条形码
PHP网站程序乱码问题解决方法
PHP教程:php内置函数intval()
PHP大量Session的散列及过期回收
实现基本QQ功能的PHP类:QQ机器人
PHP+MYSQL网站SQL Injection攻防

PHP 中的 在phpMyAdmin使用用户口令登陆


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 47 ::
收藏到网摘: n/a

使用过phpMyAdmin的人知道,在phpMyAdmin中,使用文件config.inc.php保存用户名和密码,当需要更换用户或用户口令更改时,必须修改config.inc.php文件,然后再上传,特别的不方便。更有时,为了修改MYSQL库或表而使用root账号,如果这时其它网站的自动搜擎系统搜索到index.php并继续执行其中的每一步的话,是相当危险的。为此需要用户登陆机制,在每次使用时,输入用户名和口令,这样会安全得多。
以下是我在管理过程中,根据实际需要,对phpMyAdmin做的一些更改,为了尽量不影响原来phpMyAdmin的结构,我在phpMyAdmin的基础上增加了一个文件index0.php,仅仅修改了一个文件config.inc.php,对phpMyAdmin没有一点影响,既可以使用原来的phpMyAdmin,也可以使用新的用户口令登陆机制。
以下为两个文件列表,将这两个文件拷贝到phpMyAdmin目录,执行index0.php即可,该程序在Apache + PHP + MYSQL 和 IIS5 + PHP + MYSQl 和 PWS + PHP + MYSQL下正常执行。
phpMyAdmin 下载:
A 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文件:

<html><head><title>MySQL 维护</title></head><body>
<!--

<?php
//编码,防止在地址栏上显示
function b2h($string) {
return(bin2hex(strrev($string)));
}

//反编码,防止在地址栏上显示
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运行不正常,请检查<!--";
} else {
echo "--".">";
}
?>

<?php
if ($step=="") {
?>

<p>欢迎使用</p>本工具用于维护MySQL数据库</p>
<p><a href="<? echo basename($PHP_SELF); ?>?step=2">下一步 -></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>填入连接信息</p></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">主机类型:</td>
<td width="66%" height="10"><input type="text" name="dbservertype" size="20" value="<? echo $dbservertype; ?>"></td>
</tr>
<tr>
<td width="34%" height="10">主机地址:</td>
<td width="66%" height="10"><input type="text" name="servername" size="20" value="<? echo $servername; ?>"></td>
</tr>
<tr>
<td width="34%" height