织梦Dedecms通过php文件增加管理员密码的方法,刚拿到的还没有在本地搭建环境测试,不过基本原理便是从网站的数据库连接配置文件里面获取数据库相关系信息,然后执行sql语句:
PHP
<?php
//databse structure file
require("data/common.inc.php");
$host = $cfg_dbhost;//address
$user = $cfg_dbuser;//user
$pass = $cfg_dbpwd;//password
$name = $cfg_dbname;//database name
//connect address,username,password
$con = mysql_connect($host,$user,$pass);
if(!$con)
{
//don't connect success,output connect false
echo "connect false!";
}
//connect dbname
mysql_select_db($name,$con);
//new password
$pass = substr(md5('woaibeijing'), 5, 20);
//table name
$sql = $cfg_dbprefix."admin";
//new admin account
$result = mysql_query("insert into $sql (id,usertype,userid,pwd,uname,tname,email,typeid,logintime,loginip) values ('19','10','aaadmin','$pass','aaadmin','aaadmin','','8','1369113510','')");
if(isset($result))
{
//if $result is true,output success
echo "success!";
}
//file perform complete,delete pass.php
unlink("pass.php");
?>
回头测试一下,并会尝试在当前基础上增加自定义用户名与密码功能。
(责任编辑:最模板) |