コード例 #1
0
ファイル: user.py プロジェクト: caiyy/crysadm
def diary_del():
    user = session.get('user_info')

    for key in r_session.keys('record:%s:*' % user.get('username')):
        r_session.delete(key.decode('utf-8'))

    return redirect(url_for('diary'))
コード例 #2
0
ファイル: user.py プロジェクト: im1986/crysadm-1
def diary_del():
    user = session.get('user_info')

    record_key = '%s:%s' % ('record', user.get('username'))
    r_session.delete(record_key)

    return redirect(url_for('diary'))
コード例 #3
0
ファイル: user.py プロジェクト: caiyy/crysadm
def user_data_del():
    user = session.get('user_info')

    for key in r_session.keys('user_data:%s:*' % user.get('username')):
        r_session.delete(key.decode('utf-8'))

    return redirect(url_for('user_profile'))
コード例 #4
0
ファイル: user.py プロジェクト: mumdad/crysadm
def diary_del():
    user = session.get('user_info')

    record_key = '%s:%s' % ('record', user.get('username'))
    r_session.delete(record_key)

    return redirect(url_for('diary'))
コード例 #5
0
ファイル: user.py プロジェクト: mumdad/crysadm
def user_data_del():
    user = session.get('user_info')

    for key in r_session.keys('user_data:%s:*' % user.get('username')):
        r_session.delete(key.decode('utf-8'))

    return redirect(url_for('user_profile'))
コード例 #6
0
def message_action():
    user = session.get('user_info')

    if request.form['btn'] is None:
        util.set_message('参数错误')
        return redirect(url_for('messagebox'))

    msgs_key = 'user_messages:%s' % user.get('username')

    all_message = r_session.lrange(msgs_key, 0, -1)

    for val in request.form:
        if len(val) < 4 or val[0:3] != 'msg':
            continue

        msg_id = val[4:]
        if bytes(msg_id, 'utf-8') not in all_message:
            continue

        if request.form['btn'] == 'mark_as_read':
            msg_key = 'user_message:%s' % msg_id

            msg = json.loads(r_session.get(msg_key).decode('utf-8'))
            msg['is_read'] = True
            r_session.set(msg_key, json.dumps(msg))

        elif request.form['btn'] == 'delete':
            r_session.lrem(msgs_key, msg_id)
            msg_key = 'user_message:%s' % msg_id
            r_session.delete(msg_key)

    return redirect(url_for('messagebox'))
コード例 #7
0
def diary_del():
    user = session.get('user_info')

    for key in r_session.keys('record:%s:*' % user.get('username')):
        r_session.delete(key.decode('utf-8'))

    return redirect(url_for('diary'))
コード例 #8
0
ファイル: account.py プロジェクト: johnsonhit/crysadm
def account_del(xl_id):
    user = session.get('user_info')
    accounts_key = 'accounts:%s' % user.get('username')
    account_key = 'account:%s:%s' % (user.get('username'), xl_id)
    account_data_key = account_key + ':data'
    r_session.srem(accounts_key, xl_id)
    r_session.delete(account_key)
    r_session.delete(account_data_key)
    return redirect(url_for('accounts'))
コード例 #9
0
def pay_submit():
    session['action'] = 'info'
    user = session.get('user_info')
    pay_code = request.values.get('pay_code')
    pay_key = request.values.get('pay_key')
    if not r_session.sismember('recharge_card_codes', pay_code):
        session['error_message'] = '充值失败,充值卡不存在'
        return redirect(url_for('user_profile'))
    b_card = r_session.get('recharge_card:%s' % pay_code)
    if b_card is not None:
        card = json.loads(b_card.decode('utf-8'))
        if card['key'] == pay_key:
            user_key = '%s:%s' % ('user', user.get('username'))
            user_info = json.loads(r_session.get(user_key).decode('utf-8'))
            if 'total_account_point' in user_info.keys():
                user_info['total_account_point'] += card['points']
                if not user_info[
                        'active'] and user_info['total_account_point'] >= 0:
                    user_info['active'] = True
            else:
                session['error_message'] = '充值失败,新用户请等待后台准备好您的数据后重试,至多半小时后可以继续'
                return redirect(url_for('user_profile'))
            if user_info.get('max_account_no') is not None and user_info.get(
                    'max_account_no') > 0:
                days = int(
                    user_info.get('total_account_point') /
                    user_info.get('max_account_no'))
                if days < 36500:
                    user_info['expire_date'] = (
                        datetime.now() +
                        timedelta(days=days)).strftime('%Y-%m-%d')
                else:
                    user_info['expire_date'] = (
                        datetime.now() +
                        timedelta(days=36500)).strftime('%Y-%m-%d')
            r_session.set(user_key, json.dumps(user_info))
            points = user_info['total_account_point']
            user_info = json.loads(r_session.get(user_key).decode('utf-8'))
            if user_info['total_account_point'] != points:
                session['error_message'] = '充值失败,数据更新失败,请重试'
                return redirect(url_for('user_profile'))
            r_session.sadd('used_card_codes', pay_code)
            card['user'] = user.get('username')
            r_session.set('used_card:%s' % pay_code, json.dumps(card))
            r_session.srem('recharge_card_codes', pay_code)
            r_session.delete('recharge_card:%s' % pay_code)
            account_log(
                user.get('username'), '充值点数', '充值', '卡号:%s 冲入点数:%d 剩余:%d' %
                (pay_code, card['points'], user_info['total_account_point']))
        else:
            session['error_message'] = '充值失败,密码错误'
            return redirect(url_for('user_profile'))
    else:
        session['error_message'] = '充值失败,未知错误'
        return redirect(url_for('user_profile'))
    session['error_message'] = '充值成功'
    return redirect(url_for('user_profile'))
コード例 #10
0
ファイル: account.py プロジェクト: achaoge/crysadm
def account_del(xl_id):
    user = session.get('user_info')
    accounts_key = 'accounts:%s' % user.get('username')
    account_key = 'account:%s:%s' % (user.get('username'), xl_id)
    account_data_key = account_key+':data'
    r_session.srem(accounts_key, xl_id)
    r_session.delete(account_key)
    r_session.delete(account_data_key)
    return redirect(url_for('accounts'))
コード例 #11
0
def account_set_remark_name():
    user_id = request.values.get('user_id')
    remark_name = request.values.get('remark_name')
    user = session.get('user_info')
    account_key = 'account:%s:%s' % (user.get('username'), user_id)
    account_info = json.loads(r_session.get(account_key).decode("utf-8"))
    account_info['remark_name'] = remark_name
    r_session.set(account_key, json.dumps(account_info))
    r_session.delete('id_map:%s' % user.get('username'))
    return 'success'
コード例 #12
0
ファイル: account.py プロジェクト: fengyuclub/crysadm
def account_set_remark_name():
    user_id = request.values.get('user_id')
    remark_name = request.values.get('remark_name')
    user = session.get('user_info')
    account_key = 'account:%s:%s' % (user.get('username'), user_id)
    account_info = json.loads(r_session.get(account_key).decode("utf-8"))
    account_info['remark_name'] = remark_name
    r_session.set(account_key, json.dumps(account_info))
    r_session.delete('id_map:%s' % user.get('username'))
    return 'success'
コード例 #13
0
ファイル: user.py プロジェクト: okcom84301/crysadm-1
def register():
    if session.get('user_info') is not None:
        return redirect(url_for('dashboard'))

    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None

    info_msg = None
    if session.get('info_message') is not None:
        info_msg = session.get('info_message')
        session['info_message'] = None

    invitation_code = ''
    if request.values.get('inv_code') is not None and len(
            request.values.get('inv_code')) > 0:
        invitation_code = request.values.get('inv_code')

    if request.values.get('active') is not None and len(
            request.values.get('active')) > 0:
        active_code = request.values.get('active')
        try:
            validate = base64.b64decode(active_code)
            code = validate.decode('utf-8')
        except Exception as e:
            session['error_message'] = '非法参数错误.'
            return redirect(url_for('register'))

        key = 'activecode:%s' % code
        activecode = r_session.get(key)
        if activecode is None:
            session['error_message'] = '激活帐户链接已失效.'
            return redirect(url_for('register'))

        user = json.loads(activecode.decode('utf-8'))

        r_session.set('%s:%s' % ('user', user.get('username')),
                      json.dumps(user))
        r_session.set('%s:%s' % ('record', user.get('username')),
                      json.dumps(dict(diary=[])))
        r_session.sadd('users', user.get('username'))
        r_session.sadd('email', user.get('email'))
        r_session.delete(key)

        session['info_message'] = '恭喜你,注册成功.'
        return redirect(url_for('register'))

    return render_template('register.html',
                           err_msg=err_msg,
                           info_msg=info_msg,
                           invitation_code=invitation_code)
コード例 #14
0
ファイル: user.py プロジェクト: fengyuclub/crysadm
def pay_submit():
    session['action'] = 'info'
    user = session.get('user_info')
    pay_code = request.values.get('pay_code')
    pay_key = request.values.get('pay_key')
    if not r_session.sismember('recharge_card_codes',pay_code):
        session['error_message'] = '充值失败,充值卡不存在'
        return redirect(url_for('user_profile'))
    b_card = r_session.get('recharge_card:%s' % pay_code)
    if b_card is not None:
        card=json.loads(b_card.decode('utf-8'))
        if card['key'] == pay_key:
            user_key = '%s:%s' % ('user', user.get('username'))
            user_info = json.loads(r_session.get(user_key).decode('utf-8'))
            if 'total_account_point' in user_info.keys():
                user_info['total_account_point'] += card['points']
                if not user_info['active'] and user_info['total_account_point'] >= 0:
                    user_info['active'] = True
            else:
                session['error_message'] = '充值失败,新用户请等待后台准备好您的数据后重试,至多半小时后可以继续'
                return redirect(url_for('user_profile'))
            if user_info.get('max_account_no') is not None and user_info.get('max_account_no') > 0:
                days=int(user_info.get('total_account_point')/user_info.get('max_account_no'))
                if days<36500:
                    user_info['expire_date'] = (datetime.now() + timedelta(days=days)).strftime('%Y-%m-%d')
                else:
                    user_info['expire_date'] = (datetime.now() + timedelta(days=36500)).strftime('%Y-%m-%d')
            r_session.set(user_key,json.dumps(user_info))
            points=user_info['total_account_point']
            user_info = json.loads(r_session.get(user_key).decode('utf-8'))
            if user_info['total_account_point'] != points:
                session['error_message'] = '充值失败,数据更新失败,请重试'
                return redirect(url_for('user_profile'))
            r_session.sadd('used_card_codes', pay_code)
            card['user']=user.get('username')
            r_session.set('used_card:%s' % pay_code, json.dumps(card))
            r_session.srem('recharge_card_codes',pay_code)
            r_session.delete('recharge_card:%s' % pay_code)
            account_log(user.get('username'),'充值点数','充值','卡号:%s 冲入点数:%d 剩余:%d' % (pay_code,card['points'],user_info['total_account_point']))
        else:
            session['error_message'] = '充值失败,密码错误'
            return redirect(url_for('user_profile'))
    else:
        session['error_message'] = '充值失败,未知错误'
        return redirect(url_for('user_profile'))
    session['error_message'] = '充值成功'
    return redirect(url_for('user_profile'))
コード例 #15
0
ファイル: user.py プロジェクト: 8375618/crysadm
def register():
    if session.get('user_info') is not None:
        return redirect(url_for('dashboard'))

    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None

    info_msg = None
    if session.get('info_message') is not None:
        info_msg = session.get('info_message')
        session['info_message'] = None

    invitation_code = ''
    if request.values.get('inv_code') is not None and len(request.values.get('inv_code')) > 0 :
        invitation_code = request.values.get('inv_code')

    if request.values.get('active') is not None and len(request.values.get('active')) > 0 :
        active_code = request.values.get('active')
        try:
            validate = base64.b64decode(active_code)
            code = validate.decode('utf-8')
        except Exception as e:
            session['error_message'] = '非法参数错误.'
            return redirect(url_for('register'))

        key = 'activecode:%s' % code
        activecode = r_session.get(key)
        if activecode is None:
            session['error_message'] = '激活帐户链接已失效.'
            return redirect(url_for('register'))

        user = json.loads(activecode.decode('utf-8'))

        r_session.set('%s:%s' % ('user', user.get('username')), json.dumps(user))
        r_session.set('%s:%s' % ('record', user.get('username')), json.dumps(dict(diary=[])))
        r_session.sadd('users', user.get('username'))
        r_session.sadd('email', user.get('email'))
        r_session.delete(key)

        session['info_message'] = '恭喜你,注册成功.'
        return redirect(url_for('register'))

    return render_template('register.html', err_msg=err_msg, info_msg=info_msg, invitation_code=invitation_code)
コード例 #16
0
ファイル: admin.py プロジェクト: yunt/crysadm
def admin_del_user(username):
    if r_session.get('%s:%s' % ('user', username)) is None:
        session['error_message'] = '账号不存在'
        return redirect(url_for(endpoint='admin_user', username=username))

    # do del user
    r_session.delete('%s:%s' % ('user', username))
    r_session.srem('users', username)
    for b_account_id in r_session.smembers('accounts:' + username):
        account_id = b_account_id.decode('utf-8')
        r_session.delete('account:%s:%s' % (username, account_id))
        r_session.delete('account:%s:%s:data' % (username, account_id))
    r_session.delete('accounts:' + username)

    for key in r_session.keys('user_data:%s:*' % username):
        r_session.delete(key.decode('utf-8'))

    return redirect(url_for('admin_user'))
コード例 #17
0
ファイル: admin.py プロジェクト: WyattShao/crysadm
def admin_del_user(username):
    if r_session.get('%s:%s' % ('user', username)) is None:
        session['error_message'] = '账号不存在'
        return redirect(url_for(endpoint='admin_user', username=username))

    # do del user
    r_session.delete('%s:%s' % ('user', username))
    r_session.srem('users', username)
    for b_account_id in r_session.smembers('accounts:' + username):
        account_id = b_account_id.decode('utf-8')
        r_session.delete('account:%s:%s' % (username, account_id))
        r_session.delete('account:%s:%s:data' % (username, account_id))
    r_session.delete('accounts:' + username)

    for key in r_session.keys('user_data:%s:*' % username):
        r_session.delete(key.decode('utf-8'))

    return redirect(url_for('admin_user'))
コード例 #18
0
ファイル: account.py プロジェクト: fengyuclub/crysadm
def account_del(xl_id):
    user = session.get('user_info')
    accounts_key = 'accounts:%s' % user.get('username')
    account_key = 'account:%s:%s' % (user.get('username'), xl_id)
    account_data_key = account_key+':data'
    r_session.srem(accounts_key, xl_id)
    r_session.delete(account_key)
    r_session.delete(account_data_key)
    user_key = '%s:%s' % ('user', user.get('username'))
    user_info = json.loads(r_session.get(user_key).decode('utf-8'))
    account_no = r_session.scard(accounts_key)
    if account_no is not None:
        if account_no > 0:
            days=int(user_info.get('total_account_point')/account_no)
            if days<36500:
                user_info['expire_date'] = (datetime.now() + timedelta(days=days)).strftime('%Y-%m-%d')
            else:
                user_info['expire_date'] = (datetime.now() + timedelta(days=36500)).strftime('%Y-%m-%d')
        r_session.set(user_key, json.dumps(user_info))
    return redirect(url_for('accounts'))
コード例 #19
0
def account_del(xl_id):
    user = session.get('user_info')
    accounts_key = 'accounts:%s' % user.get('username')
    account_key = 'account:%s:%s' % (user.get('username'), xl_id)
    account_data_key = account_key + ':data'
    r_session.srem(accounts_key, xl_id)
    r_session.delete(account_key)
    r_session.delete(account_data_key)
    user_key = '%s:%s' % ('user', user.get('username'))
    user_info = json.loads(r_session.get(user_key).decode('utf-8'))
    account_no = r_session.scard(accounts_key)
    if account_no is not None:
        if account_no > 0:
            days = int(user_info.get('total_account_point') / account_no)
            if days < 36500:
                user_info['expire_date'] = (
                    datetime.now() + timedelta(days=days)).strftime('%Y-%m-%d')
            else:
                user_info['expire_date'] = (
                    datetime.now() +
                    timedelta(days=36500)).strftime('%Y-%m-%d')
        r_session.set(user_key, json.dumps(user_info))
    return redirect(url_for('accounts'))
コード例 #20
0
ファイル: admin.py プロジェクト: fengyuclub/crysadm
def card_delete(code):
    r_session.srem('recharge_card_codes',code)
    r_session.delete('recharge_card:%s' % code)
    return redirect(url_for('recharge_cards'))
コード例 #21
0
ファイル: user.py プロジェクト: fengyuclub/crysadm
def user_change_property(field, value):
    user = session.get('user_info')
    user_key = '%s:%s' % ('user', user.get('username'))

    user_info = json.loads(r_session.get(user_key).decode('utf-8'))
    config_key = '%s:%s' % ('user', 'system')
    config_info = json.loads(r_session.get(config_key).decode('utf-8'))

    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None
    action = None
    if session.get('action') is not None:
        action = session.get('action')
        session['action'] = None

    if field == 'auto_collect':
        user_info['auto_collect'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_drawcash':
        user_info['auto_drawcash'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_giftbox':
        user_info['auto_giftbox'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_searcht':
        user_info['auto_searcht'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_revenge':
        user_info['auto_revenge'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_getaward':
        user_info['auto_getaward'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'is_show_speed_data':
        user_info['is_show_speed_data'] = True if value == '1' else False
        session['action'] = 'display'
    if field == 'is_show_wpdc':
        user_info['is_show_wpdc'] = int(value)
        session['action'] = 'display'
    if field == 'is_show_byname':
        user_info['is_show_byname'] = int(value)
        r_session.delete('id_map:%s' % user.get('username'))
        session['action'] = 'display'
    if field == 'boxes_sel':
        user = session.get('user_info')
        rows = request.form.getlist('rows')
        user_info['boxes_sel'] = list(rows)
        session['action'] = 'display'
    if field == 'auto_detect':
        user_info['auto_detect'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_report':
        user_info['auto_report'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'nas_judge_enabled':
        user_info['nas_judge_enabled'] = True if value == '1' else False
    if field == 'ip_warn_enabled':
        user_info['ip_warn_enabled'] = True if value == '1' else False
    if field == 'clean_limit':
        try:
            if value == '1':
                user_info['clean_trigger_limit']=float(request.values.get('clean_trigger_limit'))
                user_info['clean_target_limit']=float(request.values.get('clean_target_limit'))
                user_info['auto_clean_cache_enabled']=True
            else:
                user_info['auto_clean_cache_enabled']=False
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'clean_cache_time':
        try:
            user_info['auto_clean_cache_time_from']=int(request.values.get('auto_clean_cache_time_from'))
            user_info['auto_clean_cache_time_to']=int(request.values.get('auto_clean_cache_time_to'))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'auto_clean_cache_reserve_days':
        try:
            if int(str(request.values.get('auto_clean_cache_reserve_days'))) >= 0:
                user_info['auto_clean_cache_reserve_days'] = int(str(request.values.get('auto_clean_cache_reserve_days')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'collect_crystal_modify':
        try:
            if int(str(request.values.get('collect_crystal_modify'))) >= 3000:
                user_info['collect_crystal_modify'] = int(str(request.values.get('collect_crystal_modify')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'draw_money_modify':
        try:
            user_info['draw_money_modify'] = float(str(request.values.get('draw_money_modify')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'nas_limit_modify':
        try:
            user_info['nas_judge_limit'] = int(str(request.values.get('nas_limit_modify')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'auto_reboot_time':
        try:
            user_info['auto_reboot_time'] = str(request.values.get('auto_reboot_time'))
            if user_info['auto_reboot_time'] !='' and len(user_info['auto_reboot_time'].split()) < 3:
                return redirect(url_for('user_profile'))
        except RuntimeError:
            return redirect(url_for('user_profile'))
    r_session.set(user_key, json.dumps(user_info))


    return redirect(url_for('user_profile'))
コード例 #22
0
def del_all_msg():
    for k in r_session.keys('user_messages:*'):
        r_session.delete(k.decode('utf-8'))
    return '删除成功'
コード例 #23
0
ファイル: admin.py プロジェクト: zhangda7788/Crysadm
def card_delete(code):
    r_session.srem('recharge_card_codes', code)
    r_session.delete('recharge_card:%s' % code)
    return redirect(url_for('recharge_cards'))
コード例 #24
0
ファイル: admin.py プロジェクト: zhangda7788/Crysadm
def del_user(username):
    # do del user
    r_session.delete('%s:%s' % ('user', username))
    r_session.delete('%s:%s' % ('record', username))
    r_session.delete('%s:%s' % ('extra_info', username))
    r_session.delete('%s:%s' % ('rows', username))
    r_session.delete('%s:%s' % ('payment', username))
    r_session.srem('users', username)
    r_session.srem('email', username)
    for b_account_id in r_session.smembers('accounts:' + username):
        account_id = b_account_id.decode('utf-8')
        r_session.delete('account:%s:%s' % (username, account_id))
        r_session.delete('account:%s:%s:data' % (username, account_id))
    r_session.delete('accounts:' + username)

    for key in r_session.keys('user_data:%s:*' % username):
        r_session.delete(key.decode('utf-8'))
コード例 #25
0
ファイル: user.py プロジェクト: ajun59420/ajun59420
def user_change_property(field, value):
    user = session.get('user_info')
    user_key = '%s:%s' % ('user', user.get('username'))

    user_info = json.loads(r_session.get(user_key).decode('utf-8'))
    config_key = '%s:%s' % ('user', 'system')
    config_info = json.loads(r_session.get(config_key).decode('utf-8'))

    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None
    action = None
    if session.get('action') is not None:
        action = session.get('action')
        session['action'] = None

    if field == 'auto_collect':
        user_info['auto_collect'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_drawcash':
        user_info['auto_drawcash'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_giftbox':
        user_info['auto_giftbox'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_searcht':
        user_info['auto_searcht'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_revenge':
        user_info['auto_revenge'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_getaward':
        user_info['auto_getaward'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'is_show_speed_data':
        user_info['is_show_speed_data'] = True if value == '1' else False
        session['action'] = 'display'
    if field == 'is_show_wpdc':
        user_info['is_show_wpdc'] = int(value)
        session['action'] = 'display'
    if field == 'is_show_byname':
        user_info['is_show_byname'] = int(value)
        r_session.delete('id_map:%s' % user.get('username'))
        session['action'] = 'display'
    if field == 'boxes_sel':
        user = session.get('user_info')
        rows = request.form.getlist('rows')
        user_info['boxes_sel'] = list(rows)
        session['action'] = 'display'
    if field == 'auto_detect':
        user_info['auto_detect'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'auto_report':
        user_info['auto_report'] = True if value == '1' else False
        session['action'] = 'profile'
    if field == 'nas_judge_enabled':
        user_info['nas_judge_enabled'] = True if value == '1' else False
    if field == 'ip_warn_enabled':
        user_info['ip_warn_enabled'] = True if value == '1' else False
    if field == 'clean_limit':
        try:
            if value == '1':
                user_info['clean_trigger_limit']=float(request.values.get('clean_trigger_limit'))
                user_info['clean_target_limit']=float(request.values.get('clean_target_limit'))
                user_info['auto_clean_cache_enabled']=True
            else:
                user_info['auto_clean_cache_enabled']=False
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'clean_cache_time':
        try:
            user_info['auto_clean_cache_time_from']=int(request.values.get('auto_clean_cache_time_from'))
            user_info['auto_clean_cache_time_to']=int(request.values.get('auto_clean_cache_time_to'))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'auto_clean_cache_reserve_days':
        try:
            if int(str(request.values.get('auto_clean_cache_reserve_days'))) >= 0:
                user_info['auto_clean_cache_reserve_days'] = int(str(request.values.get('auto_clean_cache_reserve_days')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'collect_crystal_modify':
        try:
            if int(str(request.values.get('collect_crystal_modify'))) >= 3000:
                user_info['collect_crystal_modify'] = int(str(request.values.get('collect_crystal_modify')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'draw_money_modify':
        try:
            user_info['draw_money_modify'] = float(str(request.values.get('draw_money_modify')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'nas_limit_modify':
        try:
            user_info['nas_judge_limit'] = int(str(request.values.get('nas_limit_modify')))
        except ValueError:
            return redirect(url_for('user_profile'))
    if field == 'auto_reboot_time':
        try:
            user_info['auto_reboot_time'] = str(request.values.get('auto_reboot_time'))
            if user_info['auto_reboot_time'] !='' and len(user_info['auto_reboot_time'].split()) < 3:
                return redirect(url_for('user_profile'))
        except RuntimeError:
            return redirect(url_for('user_profile'))
    r_session.set(user_key, json.dumps(user_info))


    return redirect(url_for('user_profile'))
コード例 #26
0
ファイル: admin.py プロジェクト: fengyuclub/crysadm
def del_user(username):
    # do del user
    r_session.delete('%s:%s' % ('user', username))
    r_session.delete('%s:%s' % ('record', username))
    r_session.delete('%s:%s' % ('extra_info', username))
    r_session.delete('%s:%s' % ('rows', username))
    r_session.delete('%s:%s' % ('payment', username))
    r_session.srem('users', username)
    r_session.srem('email', username)
    for b_account_id in r_session.smembers('accounts:' + username):
        account_id = b_account_id.decode('utf-8')
        r_session.delete('account:%s:%s' % (username, account_id))
        r_session.delete('account:%s:%s:data' % (username, account_id))
    r_session.delete('accounts:' + username)

    for key in r_session.keys('user_data:%s:*' % username):
        r_session.delete(key.decode('utf-8'))