国内流行的内容管理系统(CMS)多端全媒体解决方案 https://www.dedebiz.com
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

92 lines
3.9KB

  1. <?php
  2. /**
  3. * 添加系统管理员
  4. *
  5. * @version $Id: sys_admin_user_add.php 1 16:22 2010年7月20日Z tianya $
  6. * @package DedeCMS.Administrator
  7. * @copyright Copyright (c) 2020, DedeBIZ.COM
  8. * @license https://www.dedebiz.com/license
  9. * @link https://www.dedebiz.com
  10. */
  11. require_once(dirname(__FILE__)."/config.php");
  12. CheckPurview('sys_User');
  13. require_once(DEDEINC."/typelink.class.php");
  14. if(empty($dopost)) $dopost='';
  15. if($dopost=='add')
  16. {
  17. CheckCSRF();
  18. if(preg_match("#[^0-9a-zA-Z_@!\.-]#", $pwd) || preg_match("#[^0-9a-zA-Z_@!\.-]#", $userid))
  19. {
  20. ShowMsg('密码或或用户名不合法,<br />请使用[0-9a-zA-Z_@!.-]内的字符!', '-1', 0, 3000);
  21. exit();
  22. }
  23. $safecodeok = substr(md5($cfg_cookie_encode.$randcode), 0, 24);
  24. if($safecode != $safecodeok )
  25. {
  26. ShowMsg('请填写安全验证串!', '-1', 0, 3000);
  27. exit();
  28. }
  29. $row = $dsql->GetOne("SELECT COUNT(*) AS dd FROM `#@__member` WHERE userid LIKE '$userid' ");
  30. if($row['dd']>0)
  31. {
  32. ShowMsg('用户名已存在!','-1');
  33. exit();
  34. }
  35. $mpwd = md5($pwd);
  36. $pwd = substr(md5($pwd), 5, 20);
  37. $typeid = join(',', $typeids);
  38. if($typeid=='0') $typeid = '';
  39. //关连前台会员帐号
  40. $adminquery = "INSERT INTO `#@__member` (`mtype`,`userid`,`pwd`,`uname`,`sex`,`rank`,`money`,`email`,
  41. `scores` ,`matt` ,`face`,`safequestion`,`safeanswer` ,`jointime` ,`joinip` ,`logintime` ,`loginip` )
  42. VALUES ('个人','$userid','$mpwd','$uname','男','100','0','$email','1000','10','','0','','0','','0',''); ";
  43. $dsql->ExecuteNoneQuery($adminquery);
  44. $mid = $dsql->GetLastID();
  45. if($mid <= 0 )
  46. {
  47. die($dsql->GetError().' 数据库出错!');
  48. }
  49. //后台管理员
  50. $inquery = "INSERT INTO `#@__admin`(id,usertype,userid,pwd,uname,typeid,tname,email)
  51. VALUES('$mid','$usertype','$userid','$pwd','$uname','$typeid','$tname','$email'); ";
  52. $rs = $dsql->ExecuteNoneQuery($inquery);
  53. $adminquery = "INSERT INTO `#@__member_person` (`mid`,`onlynet`,`sex`,`uname`,`qq`,`msn`,`tel`,`mobile`,`place`,`oldplace`,`birthday`,`star`,
  54. `income` , `education` , `height` , `bodytype` , `blood` , `vocation` , `smoke` , `marital` , `house` ,`drink` , `datingtype` , `language` , `nature` , `lovemsg` , `address`,`uptime`)
  55. VALUES ('$mid', '1', '男', '{$userid}', '', '', '', '', '0', '0','1980-01-01', '1', '0', '0', '160', '0', '0', '0', '0', '0', '0','0', '0', '', '', '', '','0'); ";
  56. $dsql->ExecuteNoneQuery($adminquery);
  57. $adminquery = "INSERT INTO `#@__member_tj` (`mid`,`article`,`album`,`archives`,`homecount`,`pagecount`,`feedback`,`friend`,`stow`)
  58. VALUES ('$mid','0','0','0','0','0','0','0','0'); ";
  59. $dsql->ExecuteNoneQuery($adminquery);
  60. $adminquery = "Insert Into `#@__member_space`(`mid` ,`pagesize` ,`matt` ,`spacename` ,`spacelogo` ,`spacestyle`, `sign` ,`spacenews`)
  61. Values('$mid','10','0','{$uname}的空间','','person','',''); ";
  62. $dsql->ExecuteNoneQuery($adminquery);
  63. ShowMsg('成功增加一个用户!', 'sys_admin_user.php');
  64. exit();
  65. }
  66. $randcode = mt_rand(10000, 99999);
  67. $safecode = substr(md5($cfg_cookie_encode.$randcode), 0, 24);
  68. $typeOptions = '';
  69. $dsql->SetQuery(" SELECT id,typename FROM `#@__arctype` WHERE reid=0 AND (ispart=0 OR ispart=1) ");
  70. $dsql->Execute('op');
  71. while($row = $dsql->GetObject('op'))
  72. {
  73. $topc = $row->id;
  74. $typeOptions .= "<option value='{$row->id}' class='btype'>{$row->typename}</option>\r\n";
  75. $dsql->SetQuery(" SELECT id,typename FROM `#@__arctype` WHERE reid={$row->id} AND (ispart=0 OR ispart=1) ");
  76. $dsql->Execute('s');
  77. while($row = $dsql->GetObject('s'))
  78. {
  79. $typeOptions .= "<option value='{$row->id}' class='stype'>—{$row->typename}</option>\r\n";
  80. }
  81. }
  82. make_hash();
  83. include DedeInclude('templets/sys_admin_user_add.htm');