addzhanghao.inc.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. global $_GPC, $_W;
  3. $seller_id=$_COOKIE["storeid"];
  4. $uid=$_COOKIE["uid"];
  5. $GLOBALS['frames'] = $this->getMainMenu($seller_id, $action='start',$uid);
  6. $id = intval($_GPC['id']);
  7. //echo $id;die;
  8. $user_id = intval($_GPC['user_id']);
  9. if (!empty($id)) {
  10. $account = pdo_fetch("SELECT * FROM " . tablename('zhtc_account') . " WHERE weid = :weid AND id=:id ORDER BY id DESC", array(':weid' => $_W['uniacid'],':id' => $id));
  11. }
  12. if (!empty($account)) {
  13. $users = user_single($account['uid']);
  14. }
  15. if (checksubmit('submit')) {
  16. load()->model('user');
  17. $user = array();
  18. $user['username'] = trim($_GPC['username']);
  19. if (!preg_match(REGULAR_USERNAME, $user['username'])) {
  20. message('必须输入用户名,格式为 3-15 位字符,可以包括汉字、字母(不区分大小写)、数字、下划线和句点。');
  21. }
  22. if (empty($users)) {
  23. $user['password'] = $_GPC['password'];
  24. if (istrlen($user['password']) < 8) {
  25. message('必须输入密码,且密码长度不得低于8位。');
  26. }
  27. }
  28. if (!empty($_GPC['password'])) {
  29. $user['password'] = $_GPC['password'];
  30. if (istrlen($user['password']) < 8) {
  31. message('必须输入密码,且密码长度不得低于8位。');
  32. }
  33. }
  34. if (empty($_GPC['form_array'])) {
  35. $user['password'] = $_GPC['password'];
  36. message('权限管理不能为空');
  37. }
  38. if (!empty($account)) {
  39. $user['salt'] = $users['salt'];
  40. $user['uid'] = $account['uid'];
  41. }
  42. $user['remark'] = $_GPC['remark'];
  43. $user['status'] = $_GPC['status'];
  44. $user['groupid'] = -1;
  45. if (empty($users)) {
  46. if (user_check(array('username' => $user['username']))) {
  47. message('非常抱歉,此用户名已经被注册,你需要更换注册名称!');
  48. }
  49. $uid = user_register($user,$source='');
  50. if ($uid > 0) {
  51. unset($user['password']);
  52. //operator
  53. $data = array(
  54. 'uniacid' => $_W['uniacid'],
  55. 'uid' => $uid,
  56. 'role' => 'operator',
  57. );
  58. $exists = pdo_fetch("SELECT * FROM " . tablename('uni_account_users') . " WHERE uid = :uid AND uniacid = :uniacid", array(':uniacid' => $_W['uniacid'], ':uid' => $uid));
  59. if (empty($exists)) {
  60. pdo_insert('uni_account_users', $data);
  61. }
  62. //permission
  63. pdo_insert('users_permission', array(
  64. 'uid' => $uid,
  65. 'uniacid' => $_W['uniacid'],
  66. 'url' => '',
  67. 'type' => 'zh_tcwq',
  68. 'permission' => 'zh_tcwq_menu_stores2'
  69. ));
  70. pdo_insert('zhtc_account', array(
  71. 'uid' => $uid,
  72. 'weid' => $_W['uniacid'],
  73. 'storeid' => $seller_id,
  74. 'from_user' => trim($_GPC['from_user']),
  75. 'email' => trim($_GPC['email']),
  76. 'mobile' => trim($_GPC['mobile']),
  77. 'pay_account' => trim($_GPC['pay_account']),
  78. 'status' => intval($_GPC['status']),
  79. 'remark' => trim($_GPC['remark']),
  80. 'dateline' => TIMESTAMP,
  81. 'username' => trim($_GPC['truename']),
  82. 'role' => 2,
  83. 'is_admin_order' => intval($_GPC['is_admin_order']),
  84. 'is_notice_order' => intval($_GPC['is_notice_order']),
  85. 'is_notice_service' => intval($_GPC['is_notice_service']),
  86. 'is_notice_boss' => intval($_GPC['is_notice_boss']),
  87. 'is_notice_queue' => intval($_GPC['is_notice_queue']),
  88. 'authority'=> $_GPC['form_array'],
  89. ));
  90. message('用户增加成功!!', $this->createWebUrl('zhanghao', array(), true));
  91. }
  92. }else {
  93. user_update($user);
  94. pdo_update('zhtc_account', array(
  95. 'weid' => $_W['uniacid'],
  96. 'storeid' => $seller_id,
  97. 'from_user' => trim($_GPC['from_user']),
  98. 'email' => trim($_GPC['email']),
  99. 'mobile' => trim($_GPC['mobile']),
  100. 'pay_account' => trim($_GPC['pay_account']),
  101. 'status' => intval($_GPC['status']),
  102. 'remark' => trim($_GPC['remark']),
  103. 'dateline' => TIMESTAMP,
  104. 'role' => 2,
  105. 'username' => trim($_GPC['truename']),
  106. 'is_admin_order' => intval($_GPC['is_admin_order']),
  107. 'is_notice_order' => intval($_GPC['is_notice_order']),
  108. 'is_notice_service' => intval($_GPC['is_notice_service']),
  109. 'is_notice_boss' => intval($_GPC['is_notice_boss']),
  110. 'is_notice_queue' => intval($_GPC['is_notice_queue']),
  111. 'authority'=> $_GPC['form_array'],
  112. ), array('id' => $id));
  113. message('更新成功!', $this->createWebUrl('zhanghao', array(), true));
  114. }
  115. message('操作用户失败,请稍候重试或联系网站管理员解决!');
  116. }
  117. include $this->template('web/addzhanghao');