Example #1
0
	public function edit() {
		$id = isset($_GET['id']) && intval($_GET['id']) ? intval($_GET['id']) : showmessage(L('illegal_parameters'), HTTP_REFERER);
		$data = $this->db->get_one(array('id'=>$id));
		if ($data) {
			if (isset($_POST['dosubmit'])) {
				$password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : '';
				$issuper = isset($_POST['issuper']) && intval($_POST['issuper']) ? intval($_POST['issuper']) : 0;
				$update = array('issuper'=>$issuper);
				if ($password) {
					if (strlen($password) > 20 || strlen($password) < 6) {
					showmessage(L('password_len_error'), HTTP_REFERER);
					}
					list($password, $encrypt) = creat_password($password);
					$update['password'] = $password;
					$update['encrypt'] = $encrypt;
				}
				if ($this->db->update($update, array('id'=>$id))) {
					showmessage(L('operation_success'), 'm=admin&c=administrator&a=init');
				} else {
					showmessage(L('database_error'), HTTP_REFERER);
				}
			}
			include $this->admin_tpl('administrator_edit');
		} else {
			showmessage(L('User_name_could_not_find'), HTTP_REFERER);
		}
	}
Example #2
0
	public function init() {
		if (isset($_POST['dosubmit'])) {
			$password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : showmessage(L('the_password_cannot_be_empty'), HTTP_REFERER);
			$newpassword = isset($_POST['newpassword']) && trim($_POST['newpassword']) ? trim($_POST['newpassword']) : showmessage(L('new_password_cannot_be_empty'), HTTP_REFERER);
			$newpassword2 = isset($_POST['newpassword2']) && trim($_POST['newpassword2']) ? trim($_POST['newpassword2']) : '';
			if (strlen($newpassword) > 20 || strlen($newpassword) < 6) {
				 showmessage(L('password_len_error'), HTTP_REFERER);
			} elseif ($newpassword != $newpassword2) {
				 showmessage(L('the_two_passwords_are_not_the_same_admin_zh'), HTTP_REFERER);
			}
			$info = $this->get_userinfo();
			if (md5(md5($password).$info['encrypt']) != $info['password']) {
				 showmessage(L('old_password_incorrect'), HTTP_REFERER);
			}
			list($password, $encrypt) = creat_password($newpassword);
			if ($this->db->update(array('password'=>$password, 'encrypt'=>$encrypt), array('id'=>$this->get_userid()))) {
				showmessage(L('operation_success'), HTTP_REFERER);
			} else {
				showmessage(L('operation_failure'), HTTP_REFERER);
			}
		}
		include $this->admin_tpl('password');
	}
Example #3
0
 /**
  * 编辑会员
  */
 public function edit()
 {
     if (isset($_POST['dosubmit'])) {
         $uid = isset($_POST['uid']) && trim($_POST['uid']) ? trim($_POST['uid']) : showmessage(L('nameerror'), HTTP_REFERER);
         $password = isset($_POST['password']) && trim($_POST['password']) ? trim($_POST['password']) : '';
         $email = isset($_POST['email']) && is_email(trim($_POST['email'])) ? trim($_POST['email']) : showmessage(L('email_format_incorrect'), HTTP_REFERER);
         $updateinfo['random'] = '';
         if (!empty($password)) {
             if (strlen($password) > 20 || strlen($password) < 6) {
                 showmessage(L('password_len_error'), HTTP_REFERER);
             } else {
                 $passwordarr = creat_password($password);
                 $updateinfo['password'] = $passwordarr[0];
                 $updateinfo['random'] = $passwordarr[1];
             }
         }
         if ($this->db->get_one("`email` = '{$email}' AND `uid` != '{$uid}'")) {
             showmessage(L('email_already_exist'), HTTP_REFERER);
         }
         $updateinfo['email'] = $email;
         //是否删除头像
         if (isset($_POST['avatar']) && $_POST['avatar'] == 1) {
             $updateinfo['avatar'] = 0;
             $dir = ps_getavatar($uid, 1);
             ps_unlink($dir);
         }
         //ucenter部份
         if ($this->config['ucuse']) {
             pc_base::load_config('uc_config');
             include PHPCMS_PATH . 'api/uc_client/client.php';
             $userinfo = $this->db->get_one(array('uid' => $uid));
             $r = uc_user_edit($userinfo['username'], '', !empty($password) ? $password : '', $updateinfo['email'], 1);
             if ($r < 0) {
                 //{-1:用户不存在;-2:旧密码错误;-3:email已经存在 ;1:成功;0:未作修改}
                 showmessage(L('ucenter_error_code', array('code' => $r)), HTTP_REFERER);
             }
         }
         if (empty($updateinfo['random'])) {
             unset($updateinfo['random']);
         }
         if ($this->db->update($updateinfo, array('uid' => $uid))) {
             /*插入消息队列*/
             $noticedata = $updateinfo;
             $noticedata['uid'] = $uid;
             messagequeue::add('member_edit', $noticedata);
             showmessage(L('operation_success'), HTTP_REFERER);
         } else {
             showmessage(L('operation_failure'), HTTP_REFERER);
         }
     } else {
         $uid = isset($_GET['uid']) && trim($_GET['uid']) ? trim($_GET['uid']) : showmessage(L('user_not_exist'), HTTP_REFERER);
         if (!($userinfo = $this->db->get_one(array('uid' => $uid)))) {
             showmessage(L('user_not_exist'), HTTP_REFERER);
         }
         include $this->admin_tpl('member_edit');
     }
 }