countadd.inc.php 6.4 KB

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