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

PHP
让我们来编写一些PHP实用的脚本
七种缓存使用武器 为网站应用和访问加速
动态网页PHP中引用&的使用注意事项
在PHP中全面阻止SQL注入式攻击
PHP自带可以代替echo调试的unit函数
小结:PHP动态网页程序优化及高效提速问题
php对特殊语句查询结果进行数组排序
实例:用PHP技术解决网站URL格式过长的问题
小结:PHP动态网页程序两个有用的小技巧
动态网页中直接不让访问PHP程序文件
网页实例:详细介绍用PHP来编写网页记数器
菜鸟学习:动态网页PHP基础学习笔记
利用Apache实现禁止图片盗链
PHP编程中常用的三则技巧
PHP制作的网站意见在线反馈表
大型Web需求解决方案 PHP定位突出
PHP实例:精确到每一秒钟的在线人数显示代码
实用:动态网页制作技术PHP的十个应用技巧
常见php页面漏洞分析及相关问题解决
PHP和MYSQL制作动态网站开发经验之谈

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


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