Browse Source

命令行增加修改密码工具

tags/6.2.7
tianya 1 year ago
parent
commit
be2ca68503
1 changed files with 40 additions and 15 deletions
  1. +40
    -15
      dedebiz

+ 40
- 15
dedebiz View File

@@ -13,9 +13,16 @@ define('DEDE_ENVIRONMENT', 'production');
define('DEBUG_LEVEL', FALSE); //如果设置为TRUE则会打印执行SQL的时间和标签加载时间方便调试
//切换工作目录到/src
$workDir = dirname(__FILE__) . "/src";
if (!file_exists($workDir . "/system/common.inc.php")) {
DedeCli::error("检查目录是否正确");
exit;
}
require_once($workDir . "/system/common.inc.php");
require_once(DEDEINC . "/libraries/cli.class.php");
chdir($workDir);
if (substr(php_sapi_name(), 0, 3) === 'cgi') {
die("DedeBIZ:需要使用php-cli运行\n\n");
DedeCli::error("DedeBIZ:需要使用php-cli运行");
exit;
}
$helpStr = "
NAME:
@@ -72,18 +79,13 @@ function RandEncode($length=26)
if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) {
//PHP5.4以下不支持内建服务器,用于开发调试
if (phpversion() < "5.4") {
die("DedeBIZ:命令行Web Server不支持\n\n");
DedeCli::error("DedeBIZ:命令行Web Server不支持");
exit;
}
echo "启动DedeBIZ开发环境\n\r";
echo "浏览器打开 http://localhost:8088\n\r";
passthru(PHP_BINARY . ' -S localhost:8088 -t' . escapeshellarg('./'));
} else if (count($argv) > 1 && ($argv[1] == "make" || $argv[1] == "m")) {
if (!file_exists($workDir . "/system/common.inc.php")) {
DedeCli::error("检查目录是否正确");
exit;
}
require_once($workDir . "/system/common.inc.php");
require_once(DEDEINC . "/libraries/cli.class.php");
//一个命令行的生成工具
if (count($argv) > 2 && ($argv[2] == "arc" || $argv[2] == "a")) {
//生成文档
@@ -256,6 +258,7 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) {
auto,o 自动更新
--start 开始时间(format:2012-03-12)
tdata 更新测试数据
pwd 更改管理员密码
WEBSITE:
https://www.dedebiz.com/help/";
DedeCli::write($helpStr);
@@ -431,8 +434,8 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) {
$db->exec($adminquery);
$adminquery = "INSERT INTO `{$dbprefix}member_space` (`mid`,`pagesize`,`matt`,`spacename`,`spacelogo`,`spacestyle`,`sign`,`spacenews`) VALUES ('1','10','0','{$adminuser}的空间','','person','',''); ";
$db->exec($adminquery);
DedeCli::write("admin user:admin");
DedeCli::write("admin password:admin");
DedeCli::write("用户名:admin");
DedeCli::write("密码:admin");
if (phpversion() < "5.4") {
die("DedeBIZ:命令行Web Server不支持\n\n");
}
@@ -451,7 +454,7 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) {
require_once(DEDEINC . "/libraries/cli.class.php");
$in_query = "INSERT INTO `#@__arctype` (reid,topid,sortrank,typename,cnoverview,enname,enoverview,bigpic,litimg,typedir,isdefault,defaultname,issend,channeltype,tempindex,templist,temparticle,modname,namerule,namerule2,ispart,corank,description,keywords,seotitle,moresite,siteurl,sitepath,ishidden,`cross`,`crossid`,`content`,`smalltypes`) VALUES ('0','0','999','测试栏目','','','','','','{cmspath}/a/ceshilanmu','1','index.html','1','1','{style}/index_article.htm','{style}/list_article.htm','{style}/article_article.htm','default','{typedir}/{aid}.html','{typedir}/{tid}-{page}.html','0','0','测试','测试','','0','','','0','0','','','')";
if (!$dsql->ExecuteNoneQuery($in_query)) {
die("保存目录数据时失败,请检查您的输入资料是否存在问题");
DedeCli::error("保存目录数据时失败,请检查您的输入资料是否存在问题");
}
$typeid = $dsql->GetLastID();
DedeCli::write("开始生成测试数据...");
@@ -460,13 +463,13 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) {
$now = time();
$arcID = GetIndexKey(0, $typeid, $now, 1, $now, 1);
if (empty($arcID)) {
die("无法获得主键,因此无法进行后续操作");
DedeCli::error("无法获得主键,因此无法进行后续操作");
}
$query = "INSERT INTO `#@__archives` (id,typeid,typeid2,sortrank,flag,ismake,channel,arcrank,click,money,title,shorttitle,color,writer,source,litpic,pubdate,senddate,mid,notpost,description,keywords,filename,dutyadmin,weight) VALUES ('$arcID','$typeid','0','$now','','1','1','0','100','0','这是一篇测试文章$arcID','测试文章$arcID','','天涯','DedeBIZ','','$now','$now','1','0','测试描述','测试关键词','','1','');";
if (!$dsql->ExecuteNoneQuery($query)) {
$gerr = $dsql->GetError();
$dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
die("数据保存到数据库主表`#@__archives`时出错,请检查数据库字段".str_replace('"', '', $gerr));
DedeCli::error("数据保存到数据库主表`#@__archives`时出错,请检查数据库字段".str_replace('"', '', $gerr));
}
$body = str_repeat("得德内容管理系统DedeBIZ上海穆云智能科技有限公司,天涯、叙述别离、老岳2023",500);
$query = "INSERT INTO `#@__addonarticle` (aid,typeid,redirecturl,templet,userip,body) VALUES ('$arcID','$typeid','','','127.0.0.1','$body')";
@@ -474,11 +477,33 @@ if (count($argv) > 1 && ($argv[1] == "serv" || $argv[1] == "s")) {
$gerr = $dsql->GetError();
$dsql->ExecuteNoneQuery("DELETE FROM `#@__archives` WHERE id='$arcID'");
$dsql->ExecuteNoneQuery("DELETE FROM `#@__arctiny` WHERE id='$arcID'");
die("数据保存到数据库附加表时出错,请检查数据库字段".str_replace('"', '', $gerr));
DedeCli::error("数据保存到数据库附加表时出错,请检查数据库字段".str_replace('"', '', $gerr));
}
}
DedeCli::write("成功生成所有测试数据");
} else if(count($argv) > 1 && ($argv[1] =="pwd")){
DedeCli::write("请选择需要更改密码的用户名:");
$dsql->Execute('out', "SELECT id,userid FROM `#@__admin`");
$ids = array();
while ($row = $dsql->GetObject('out')) {
DedeCli::write("[id:{$row->id}]{$row->userid}");
$ids[] = $row->id;
}
$id = intval(DedeCli::prompt('输入id?', $ids));
$pwd = DedeCli::prompt('请输入新的密码');
if (function_exists('password_hash')) {
$pwdm = "pwd='',pwd_new='".password_hash($pwd, PASSWORD_BCRYPT)."'";
$pwd = "pwd='',pwd_new='".password_hash($pwd, PASSWORD_BCRYPT)."'";
} else {
$pwdm = "pwd='".md5($pwd)."'";
$pwd = "pwd='".substr(md5($pwd), 5, 20)."'";
}
$query = "UPDATE `#@__admin` SET $pwd WHERE id='$id'";
$dsql->ExecuteNoneQuery($query);
$query = "UPDATE `#@__member` SET $pwdm WHERE mid='$id'";
$dsql->ExecuteNoneQuery($query);
DedeCli::write("成功修改密码");
} else {
echo $helpStr;
DedeCli::write($helpStr);
}
?>

Loading…
Cancel
Save