示例#1
0
function _login($forward = '')
{
    global $_GPC;
    require_once IA_ROOT . '/source/model/member.mod.php';
    hooks('member:login:before');
    $member = array();
    $username = trim($_GPC['username']);
    if (empty($username)) {
        message('请输入要登录的用户名');
    }
    $member['username'] = $username;
    $member['password'] = $_GPC['password'];
    if (empty($member['password'])) {
        message('请输入密码');
    }
    $record = member_single($member);
    if (!empty($record)) {
        if ($record['status'] == -1) {
            message('您的账号正在核合或是已经被系统禁止,请联系网站管理员解决!');
        }
        $cookie = array();
        $cookie['uid'] = $record['uid'];
        $cookie['lastvisit'] = $record['lastvisit'];
        $cookie['lastip'] = $record['lastip'];
        $cookie['hash'] = md5($record['password'] . $record['salt']);
        $session = base64_encode(json_encode($cookie));
        isetcookie('__session', $session, !empty($_GPC['rember']) ? 7 * 86400 : 0);
        $status = array();
        $status['uid'] = $record['uid'];
        $status['lastvisit'] = TIMESTAMP;
        $status['lastip'] = CLIENT_IP;
        member_update($status);
        hooks('member:login:success');
        if (empty($forward)) {
            $forward = $_GPC['forward'];
        }
        if (empty($forward)) {
            $forward = './index.php?refersh';
        }
        message("欢迎回来,{$record['username']}。", $forward);
    } else {
        message('登录失败,请检查您输入的用户名和密码!');
    }
}
    if (istrlen($member['password']) < 8) {
        message('必须输入密码,且密码长度不得低于8位。');
    }
    $member['remark'] = $_GPC['remark'];
    $member['groupid'] = intval($_GPC['groupid']);
    $uid = member_register($member);
    if ($uid > 0) {
        unset($member['password']);
        $member['uid'] = $uid;
        //有用户组则添加相关权限
        if (!empty($member['groupid'])) {
            $group = pdo_fetch("SELECT modules FROM " . tablename('members_group') . " WHERE id = :id", array(':id' => $member['groupid']));
            if (!empty($group['modules'])) {
                $group['modules'] = iunserializer($group['modules']);
                if (is_array($group['modules'])) {
                    $modules = pdo_fetchall("SELECT mid FROM " . tablename('modules') . " WHERE mid IN ('" . implode("','", $group['modules']) . "')");
                    if (!empty($modules)) {
                        foreach ($modules as $row) {
                            pdo_insert('members_permission', array('uid' => $uid, 'resourceid' => $row['mid'], 'type' => 1));
                        }
                    }
                }
            }
        }
        hooks('member:register:success', $member);
        message('用户增加成功!', create_url('member/edit', array('uid' => $uid)));
    }
    message('增加用户失败,请稍候重试或联系网站管理员解决!');
}
$groups = pdo_fetchall("SELECT id, name FROM " . tablename('members_group') . " ORDER BY id ASC");
template('member/create');
<?php

/**
 * [WeEngine System] Copyright (c) 2013 WE7.CC
 */
defined('IN_IA') or exit('Access Denied');
$operation = !empty($_GPC['op']) ? $_GPC['op'] : 'search';
if ($operation == 'save') {
    if (checksubmit()) {
        require_once IA_ROOT . '/source/model/member.mod.php';
        hooks('member:register:before');
        $member = array();
        $uid = intval($_GPC['uid']);
        $data = member_single(array('uid' => $uid));
        if ($data['uid'] > 0) {
            $stattime = strtotime($_GPC['stattime'] . ' 00:00:00');
            $endtime = strtotime($_GPC['endtime'] . ' 23:59:59');
            $groupid = intval($_GPC['groupid']);
            $sql = 'UPDATE ' . tablename('members') . " SET `groupid`='{$groupid}' WHERE  `uid`=:uid";
            $pars = array();
            $pars[':uid'] = $data['uid'];
            pdo_query($sql, $pars);
            $wedata = pdo_fetch("SELECT * FROM " . tablename('members_status') . " WHERE uid = '{$data['uid']}' LIMIT 1");
            if ($wedata) {
                $datastatus = array();
                $datastatus['endtime'] = $endtime;
                $datastatus['stattime'] = $stattime;
                $datastatus['uid'] = $data['uid'];
                $datastatus['gid'] = $groupid;
                $datastatus['status'] = 0;
                pdo_update('members_status', $datastatus, array('id' => $wedata['id']));