<?php
/*super_peter*/
$functionall=array(
array('0','uc','ucenter'),
array('1','uch','uchome'),
array('2','dz','discuz'),
array('3','dz_full','discuz_full'),
array('4','ec','ecshop'),
array('5','sup','supesite'),
array('6','sh','shopex'),
array('7','pc','phpcms'),
array('8','pw','phpwind'),
array('9','dede','dedecms'),
array('10','ep','empirecms'),
array('11','dzx','discuz X')
);
import_request_variables("gP", "_");
htmlheader();
echo "<h5>欢迎使用php程序管理员密码重置工具(测试版)</h5><br>";
$action=$_GET['action'];
if($action==""){
echo "<h5>[<font color=red>使用方法</font>]:<br><p>
1.将此文件放到对应程序的根目录下;<br><p>
2.选择对应的程序类型即可。</h5>";
}
/*重置ucenter*/
elseif($action=="uc"){
if(file_exists("./data/config.inc.php")){
echo "<center><h4>您所要重置的程序是<font color=red>[ ucenter ] !<br>
</font>请输入要重置的创始人密码即可</h4></center>";
include("./data/config.inc.php");
if($action=$_reset){
define(ROOT_DIR,dirname(__FILE__)."/");
$configfile = ROOT_DIR."./data/config.inc.php";
$salt = substr(uniqid(rand()), 0, 6);
$newpwd = md5(md5($_repwd).$salt);
$config = file_get_contents($configfile);
$config = preg_replace("/define\('UC_FOUNDERSALT',\s*'.*?'\);/i", "define('UC_FOUNDERSALT', '$salt');", $config);
$config = preg_replace("/define\('UC_FOUNDERPW',\s*'.*?'\);/i", "define('UC_FOUNDERPW', '$newpwd');", $config);
$fp = @fopen($configfile, 'w');
@fwrite($fp, $config);
@fclose($fp);
echo "<center><font color=red size=5>已经将创始人密码重置为$_repwd!</font></center>";
back();
exit();
}
htmlbody1();
}
else{
err();
}
}
/*重置uchome*/
elseif($action=="uch"){
if(file_exists("config.php")){
echo "<center><h4>您所要重置的程序是<font color=red>[ uchome ] !</font></h4></center>";
include("config.php");
$dbhost=$_SC['dbhost'];$dbuser=$_SC['dbuser'];$dbpw=$_SC['dbpw'];$dbname=$_SC['dbname'];
$db=mysql_connect("$dbhost","$dbuser","$dbpw");
mysql_select_db("$dbname");
if($action=$_find){
$result=mysql_query("select username from ".$_SC['tablepre']."space where groupid='1'");
$n=mysql_num_rows($result);
echo"<center><font color=red size=5>已存在的管理员用户有".$n."个,如下:</font></center><br>";
for($i=0;$i<$n;$i++)
{
$username=mysql_result($result,$i,username);
echo "<center><font color=red size=5>$username</font></center><br>";
}
back();
exit();
}
if($action=$_reset){
$result=mysql_query("select * from".UC_DBTABLEPRE."members where username='$_existuser'");
$row=mysql_fetch_array($result);
$salt=$row['salt'];
$newpwd=md5(md5($_repwd).$salt);
mysql_query("update".UC_DBTABLEPRE."members set password='$newpwd' where username='$_existuser'");
echo "<center><font color=red size=5>已经将管理员密码重置为$_repwd!</font></center>";
back();
exit();
}
htmlbody();
}
else{
err();
}
}
/*重置discuz*/
elseif($action=="dz"){
if(file_exists("config.inc.php")){
echo "<center><h4>您所要重置的程序是<font color=red>[ discuz ] !</font></h4></center>";
include("config.inc.php");
$db=mysql_connect("$dbhost","$dbuser","$dbpw");
mysql_select_db("$dbname");
if($action=$_find){
$result=mysql_query("select username from ".$tablepre."members where adminid='1'");
$n=mysql_num_rows($result);
echo"<center><font color=red size=5>已存在的管理员用户有".$n."个,如下:</font></center><br>";
for($i=0;$i<$n;$i++)
{
$username=mysql_result($result,$i,username);
echo "<center><font color=red size=5>$username</font></center><br>";
}
back();
exit();
}
if($action=$_reset){
$result=mysql_query("select * from ".UC_DBTABLEPRE."members where username='$_existuser'");
$row=mysql_fetch_array($result);
$salt=$row['salt'];
$newpwd=md5(md5($_repwd).$salt);
mysql_query("update ".UC_DBTABLEPRE."members set password='$newpwd' where username='$_existuser'");
echo "<center><font color=red size=5>已经将管理员密码重置为$_repwd!</font></center>";
back();
exit();
}
htmlbody();
}
else{
err();
}
}
/*重置discuz_full*/
elseif($action=="dz_full"){
if(file_exists("config.inc.php")){
echo "<center><h4>您所要重置的程序是<font color=red>[ discuz_full ] !</font></h4></center>";
include("config.inc.php");
$db=mysql_connect("$dbhost","$dbuser","$dbpw");
mysql_select_db("$dbname");
if($action=$_find){
$result=mysql_query("select username from ".$tablepre."members where adminid='1'");
$n=mysql_num_rows($result);
echo"<center><font color=red size=5>已存在的管理员用户有".$n."个,如下:</font></center><br>";
for($i=0;$i<$n;$i++)
{
$username=mysql_result($result,$i,username);
echo "<center><font color=red size=5>$username</font></center><br>";
}
back();
exit();
}
if($action=$_reset){
$result=mysql_query("select * from ".UC_DBTABLEPRE."members where username='$_existuser'");
$row=mysql_fetch_array($result);
$salt=$row['salt'];
$newpwd=md5(md5($_repwd).$salt);
mysql_query("update ".UC_DBTABLEPRE."members set password='$newpwd' where username='$_existuser'");
echo "<center><font color=red size=5>已经将管理员密码重置为$_repwd!</font></center>";
back();
exit();
}
htmlbody();
}
else{
err();
}
}
/*重置ecshop*/
elseif($action=="ec"){
if(file_exists("./data/config.php")){
echo "<center><h4>您所要重置的程序是<font color=red>[ ecshop ] !</font></h4></center>";
include("./data/config.php");
$db=mysql_connect("$db_host","$db_user","$db_pass");
mysql_select_db("$db_name");
if($action=$_find){
$result=mysql_query("select * from ".$prefix."admin_user");
$username=mysql_result($result,0,user_name);
echo"<center><font color=red size=5>已存在的管理员用户为".$username." !</font></center><br>";
}
if($action=$_reset){
$newpwd=md5($_repwd);
mysql_query("update ".$prefix."admin_user set password='$newpwd' where user_name='$_existuser'");
echo "<center><font color=red size=5>已经将管理员密码重置为$_repwd!</font></center>";
back();
exit();
}
htmlbody();
}
else{
err();
}
}
/*重置supesite*/
elseif($action=="sup"){
if(file_exists("config.php")){
echo "<center><h4>您所要重置的程序是<font color=red>[ supesite ] !</font></h4></center>";
include("config.php");
$dbhost=$_SC['dbhost'];$dbuser=$_SC['dbuser'];$dbpw=$_SC['dbpw'];$dbname=$_SC['dbname'];
$db=mysql_connect("$dbhost","$dbuser","$dbpw");
mysql_select_db("$dbname");
if($action=$_find){
$r