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

PHP
用PHP实现ODBC数据分页显示一例
用DBSQL类加快开发MySQL数据库程序的速度
多php服务器实现多session并发运行
多核编程中的负载平衡难题
将Oracle内置的安全特性用于php
在PHP中使用ASP.NET AJAX
php中计算时间差的几种方法
PHP 5.0对象模型深度探索之类的静态成员
让PHP管理小型的邮件列表
MagickWand for PHP linux INSTALL 安装
PHP中数组元素升序、降序及重新排序的函数
PHP后门的隐藏技巧测试报告
配置Apache 1.3或者Apache 2.0服务器的5个技巧
用Suhosin加强PHP脚本语言安全性
PHP动态网页编程常用技巧四则
解答:如何使用PHP开发高效的WEB系统
PHP实现上传文件生成小图加文字的实例
PHP实现定时生成HTML网站首页
教你用PHP写MySQL数据库的用户认证系统
加速动态网站 MySQL索引分析和优化

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 25 ::
收藏到网摘: 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