コード例 #1
0
ファイル: admin.py プロジェクト: fengyuclub/crysadm
def recharge_cards():
    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None
    recharge_cards=[]
    for code in r_session.smembers('recharge_card_codes'):
        b_card = r_session.get('recharge_card:%s' % code.decode('utf-8'))
        if b_card is not None:
            card=json.loads(b_card.decode('utf-8'))
            if card.get('status') == '待售':
                card['operation']='''
<form style="display: inline-block" role="form" action="/admin/card_sold/''' + card['code'] + '''" method="post">
    <button type="submit" class="btn btn-outline btn-default btn-xs">售出</button>
</form>
    '''
            elif card.get('status') == '售出':
                card['operation']='''
<form style="display: inline-block" role="form" action="/admin/card_delete/''' + card['code'] + '''" method="post">
    <button type="submit" class="btn btn-outline btn-default btn-xs">销毁</button>
</form>
    '''
            card['code']='卡号:%s'%card['code']
            card['key']='密码:%s'%card['key']
            recharge_cards.append(card)
    used_cards=[]
    for code in r_session.smembers('used_card_codes'):
        b_card = r_session.get('used_card:%s' % code.decode('utf-8'))
        if b_card is not None:
            card=json.loads(b_card.decode('utf-8'))
            used_cards.append(card)
    return render_template('admin_recharge.html',err_msg=err_msg,recharge_cards=recharge_cards,used_cards=used_cards)
コード例 #2
0
ファイル: web_common.py プロジェクト: HuiMi24/crysadm
def accounts_count():
    count_key = 'count:accounts'
    b_count_info = r_session.get(count_key)
    if b_count_info is not None:
        return dict(accounts_count=json.loads(r_session.get(count_key).decode('utf-8')))
    users = r_session.scard('users')
    accounts = 0
    accountsk = 0
    for name in r_session.smembers('users'):
        accounts_key = 'accounts:%s' % name.decode('utf-8')
        for acct in r_session.smembers(accounts_key):
            account_key = 'account:%s:%s' % (
                name.decode('utf-8'), acct.decode("utf-8"))
            account_data_key = account_key + ':data'
            account_data_value = r_session.get(account_data_key)
            if account_data_value is None:
                continue
            account_info = json.loads(account_data_value.decode("utf-8"))
            for i in account_info.get('device_info'):
                accountsk += 1

        accounts += r_session.scard(accounts_key)
    accounts_count = dict(users=users, accounts=accounts, accountsk=accountsk)
    r_session.setex(count_key, json.dumps(accounts_count), 120)
    return dict(accounts_count=accounts_count)
コード例 #3
0
ファイル: admin.py プロジェクト: HuiMi24/crysadm
def admin_clear_no_device_user():
    for b_user in r_session.smembers('users'):
        username = b_user.decode('utf-8')
        accounts_count = r_session.smembers('accounts:%s' % username)
        if accounts_count is None or len(accounts_count) == 0:
            admin_del_user(username)
        return redirect(url_for('admin_user'))
コード例 #4
0
ファイル: admin.py プロジェクト: HuiMi24/crysadm
def generate_inv_code():
    _chars = "0123456789ABCDEF"
    r_session.smembers('invitation_codes')

    for i in range(0, 30 - r_session.scard('invitation_codes')):
        r_session.sadd('invitation_codes', ''.join(random.sample(_chars, 10)))

    return redirect(url_for('admin_invitation'))
コード例 #5
0
ファイル: web_common.py プロジェクト: chongzi0307/crysadm-1
def dashboard_speed_share():
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username

    account_key = ['account:%s:%s:data' % (username, name.decode('utf-8')) for name in sorted(r_session.smembers(accounts_key))]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    drilldown_data = []
    for b_acct in r_session.mget(*['account:%s:%s:data' % (username, name.decode('utf-8'))
                                   for name in sorted(r_session.smembers(accounts_key))]):

        account_info = json.loads(b_acct.decode("utf-8"))
        mid = str(account_info.get('privilege').get('mid'))

        total_speed = 0
        device_speed = []

        for device_info in account_info.get('device_info'):
            if device_info.get('status') != 'online':
                continue
            uploadspeed = int(int(device_info.get('dcdn_upload_speed')) / 1024)            
            #downloadspeed = int(int(device_info.get('dcdn_deploy_speed')) / 1024)
            # total_speed += downloadspeed
            total_speed += uploadspeed            
            device_speed.append(dict(name=device_info.get('device_name'), value=uploadspeed))            
            # device_speed.append(dict(name=device_info.get('device_name'), value=total_speed))

        # 显示在速度分析器圆形图表上的设备ID
        drilldown_data.append(dict(name='矿主ID:' + mid, value=total_speed, drilldown_data=device_speed))
        #drilldown_data.append(dict(name='设备名:' + device_info.get('device_name'), value=total_speed, drilldown_data=device_speed))

    return Response(json.dumps(dict(data=drilldown_data)), mimetype='application/json')
コード例 #6
0
ファイル: excavator.py プロジェクト: 998k998/baojiangong
def excavators():
    user = session.get('user_info')
    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

    accounts_key = 'accounts:%s' % user.get('username')
    accounts = list()

    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        if account_data_value is not None:
            account_info['data'] = json.loads(account_data_value.decode("utf-8"))

        accounts.append(account_info)

    show_drawcash = not (r_session.get('can_drawcash') is None or
                         r_session.get('can_drawcash').decode('utf-8') == '0')

    return render_template('excavators.html', err_msg=err_msg, info_msg=info_msg, accounts=accounts,
                           show_drawcash=show_drawcash)
コード例 #7
0
ファイル: web_common.py プロジェクト: chongzi0307/crysadm-1
def dashboard_speed_detail():
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username

    account_key = ['account:%s:%s:data' % (username, name.decode('utf-8')) for name in sorted(r_session.smembers(accounts_key))]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    device_speed = []
    for b_acct in r_session.mget(*['account:%s:%s:data' % (username, name.decode('utf-8'))
                                   for name in sorted(r_session.smembers(accounts_key))]):

        account_info = json.loads(b_acct.decode("utf-8"))

        for device_info in account_info.get('device_info'):
            if device_info.get('status') != 'online':
                continue
            upload_speed = int(int(device_info.get('dcdn_upload_speed')) / 1024)
            deploy_speed = int(device_info.get('dcdn_download_speed') / 1024)

            device_speed.append(dict(name=device_info.get('device_name'), upload_speed=upload_speed, deploy_speed=deploy_speed))

    device_speed = sorted(device_speed, key=lambda k: k.get('name'))
    categories = []
    upload_series = dict(name='上传速度', data=[], pointPadding=0.3, pointPlacement=-0.2)
    deploy_series = dict(name='下载速度', data=[], pointPadding=0.4, pointPlacement=-0.2)
    for d_s in device_speed:
        categories.append(d_s.get('name'))
        upload_series.get('data').append(d_s.get('upload_speed'))
        deploy_series.get('data').append(d_s.get('deploy_speed'))

    return Response(json.dumps(dict(categories=categories, series=[upload_series, deploy_series])), mimetype='application/json')
コード例 #8
0
ファイル: excavator.py プロジェクト: 998k998/baojiangong
def drawcash_all():
    user = session.get('user_info')
    username = user.get('username')

    error_message = ''
    success_message = ''
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        r = exec_draw_cash(cookies)
        if r.get('r') != 0:
            error_message += 'Id:%s : %s<br />' % (user_id, r.get('rd'))
        else:
            success_message += 'Id:%s : %s<br />' % (user_id, r.get('rd'))
            account_data_key = account_key + ':data'
            account_data_value = json.loads(r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('income')['r_can_use'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))
    if len(success_message) > 0:
        session['info_message'] = success_message

    if len(error_message) > 0:
        session['error_message'] = error_message

    return redirect(url_for('excavators'))
コード例 #9
0
ファイル: excavator.py プロジェクト: 998k998/baojiangong
def searcht_all():
    user = session.get('user_info')
    username = user.get('username')

    error_message = ''
    success_message = ''
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        r = check_searcht(cookies)
        if r.get('r') != 0:
            error_message += 'Id:%s : %s<br />' % (user_id, regular_html(r.get('rd')))
            red_log('手动执行', '进攻', user_id, regular_html(r.get('rd')))
        else:
            success_message += 'Id:%s : 获得:%s秘银.<br />' % (user_id, r.get('s'))
            red_log('手动执行', '进攻', user_id, '获得:%s秘银.' % r.get('s'))
            account_data_key = account_key + ':data'
            account_data_value = json.loads(r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('mine_info')['td_not_in_a'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))
    if len(success_message) > 0:
        session['info_message'] = success_message

    if len(error_message) > 0:
        session['error_message'] = error_message

    return redirect(url_for('excavators'))
コード例 #10
0
ファイル: excavator.py プロジェクト: qq898232/crysadm
def getaward_all_crystal():
    user = session.get('user_info')
    username = user.get('username')

    error_message = ''
    success_message = ''
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        t = api_getaward(cookies)
        if t.get('rd') != 'ok':
            error_message += 'Id:%s %s<br />' % (user_id, t.get('rd')) 
        else:
            success_message += 'Id:%s 转盘成功,获得:%s  下次转需要:%s 秘银.<br />' % (user_id, unquote(t.get('tip')), t.get('cost'))
            account_data_key = account_key + ':data'
            account_data_value = json.loads(r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('mine_info')['td_not_in_a'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))
    if len(success_message) > 0:
        session['info_message'] = success_message

    if len(error_message) > 0:
        session['error_message'] = error_message

    return redirect(url_for('excavators'))
コード例 #11
0
ファイル: user.py プロジェクト: 8375618/crysadm
def public_inv_code():

    public_key = 'invitation'
    if r_session.get(public_key) is None:
        r_session.set(public_key, json.dumps(dict(diary=[])))
    public_info = json.loads(r_session.get(public_key).decode('utf-8'))

    HTTP_X_REAL_IP = request.environ.get('HTTP_X_REAL_IP')
    for public_code in public_info.get('diary'):
        if HTTP_X_REAL_IP == public_code.get('ip'):
            session['error_message'] = '您已经获取过邀请码了,请勿重复获取.'
            session['invitation_code'] = public_code.get('inv_code')
            return redirect(url_for('public_invitation'))

    inv_codes = r_session.smembers('public_invitation_codes')
    if not inv_codes:
        session['error_message'] = '暂时没有可用的邀请码,请稍后再试.'
        return redirect(url_for('public_invitation'))

    for code in inv_codes: continue
    invitation_code = code.decode('utf-8')

    public_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')

    body = dict(time=public_time, inv_code=invitation_code, ip=HTTP_X_REAL_IP)

    public_body = public_info.get('diary')
    public_body.append(body)

    public_info['diary'] = public_body

    r_session.set(public_key, json.dumps(public_info))

    return render_template('register.html', invitation_code=invitation_code)
コード例 #12
0
ファイル: excavator.py プロジェクト: im1986/crysadm-1
def getaward_all():
    user = session.get('user_info')
    username = user.get('username')

    error_message = ''
    success_message = ''
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        r = api_getaward(cookies)
        if r.get('rd') != 'ok':
            error_message += 'Id:%s : %s<br />' % (user_id, r.get('rd'))
        else:
            success_message += 'Id:%s : 获得:%s  下次转需要:%s 秘银.<br />' % (user_id, regular_html(r.get('tip')), r.get('cost'))

    if len(success_message) > 0:
        session['info_message'] = success_message

    if len(error_message) > 0:
        session['error_message'] = error_message

    return redirect(url_for('excavators'))
コード例 #13
0
ファイル: web_common.py プロジェクト: Tuluobo/crysadm
def dashboard_speed_share():
    user = session.get("user_info")
    username = user.get("username")
    accounts_key = "accounts:%s" % username

    drilldown_data = []
    for b_acct in r_session.mget(
        *["account:%s:%s:data" % (username, name.decode("utf-8")) for name in sorted(r_session.smembers(accounts_key))]
    ):

        account_info = json.loads(b_acct.decode("utf-8"))
        mid = str(account_info.get("privilege").get("mid"))

        total_speed = 0
        device_speed = []

        for device_info in account_info.get("device_info"):
            if device_info.get("status") != "online":
                continue
            speed = int(int(device_info.get("dcdn_upload_speed")) / 1024)
            total_speed += speed
            device_speed.append(dict(name=device_info.get("device_name"), value=speed))

        drilldown_data.append(dict(name="矿主ID:" + mid, value=total_speed, drilldown_data=device_speed))

    return Response(json.dumps(dict(data=drilldown_data)), mimetype="application/json")
コード例 #14
0
ファイル: admin.py プロジェクト: fengyuclub/crysadm
def clear_account_limit():
    for name in r_session.smembers('users'):
        user_key = '%s:%s' % ('user', name.decode('utf-8'))
        user_info = json.loads(r_session.get(user_key).decode('utf-8'))
        user_info.pop('account_limit',0)
        r_session.set(user_key,json.dumps(user_info))	
    return redirect(url_for('admin_debug'))
コード例 #15
0
ファイル: web_common.py プロジェクト: caiyy/crysadm
def dashboard_speed_detail():
    user = session.get('user_info')
    username = user.get('username')

    device_speed = []
    for user_id in sorted(r_session.smembers('accounts:%s' % username)):

        account_data_key = 'account:%s:%s:data' % (username, user_id.decode('utf-8'))
        b_data = r_session.get(account_data_key)
        if b_data is None:
            continue
        data = json.loads(b_data.decode('utf-8'))

        for device in data.get('device_info'):
            if device.get('status') != 'online': continue
            upload_speed = int(int(device.get('dcdn_upload_speed')) / 1024)
            deploy_speed = int(device.get('dcdn_download_speed') / 1024)

            device_speed.append(dict(name=device.get('device_name'), upload_speed=upload_speed, deploy_speed=deploy_speed))

    device_speed = sorted(device_speed, key=lambda k: k.get('name'))

    categories = []
    upload_series = dict(name='上传速度', data=[], pointPadding=0.3, pointPlacement=-0.2)
    deploy_series = dict(name='下载速度', data=[], pointPadding=0.4, pointPlacement=-0.2)
    for d_s in device_speed:
        categories.append(d_s.get('name'))
        upload_series.get('data').append(d_s.get('upload_speed'))
        deploy_series.get('data').append(d_s.get('deploy_speed'))

    return Response(json.dumps(dict(categories=categories, series=[upload_series, deploy_series])), mimetype='application/json')
コード例 #16
0
ファイル: web_common.py プロジェクト: fengyuclub/crysadm
def dashboard_today_income_share():
    from user import get_id_map
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username
    user_key = '%s:%s' % ('user', user.get('username'))
    user_info = json.loads(r_session.get(user_key).decode('utf-8'))

    account_key = ['account:%s:%s:data' % (username, name.decode('utf-8')) for name in sorted(r_session.smembers(accounts_key))]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    pie_data = []
    id_map = get_id_map(user.get('username'))

    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        if account_data_value is not None:
            account_info_data=json.loads(account_data_value.decode("utf-8"))
        else:
            continue
        mid = str(account_info_data.get('privilege').get('mid'))

        total_value = 0
        total_value += account_info_data.get('mine_info').get('dev_m').get('pdc')
        if id_map[account_info.get('user_id')] is None:
            pie_data.append(dict(name='账户名:未知', y=total_value))
        else:
            pie_data.append(dict(name='账户名:' + id_map[account_info.get('user_id')], y=total_value))

    return Response(json.dumps(dict(data=pie_data)), mimetype='application/json')
コード例 #17
0
ファイル: admin.py プロジェクト: HuiMi24/crysadm
def admin_message_send():
    to = request.values.get('to')
    subject = request.values.get('subject')
    summary = request.values.get('summary')
    content = request.values.get('content')

    if subject == '':
        session['error_message'] = '标题为必填。'
        return redirect(url_for('admin_message'))

    if to == '':
        session['error_message'] = '收件方必填。'
        return redirect(url_for('admin_message'))

    if summary == '':
        session['error_message'] = '简介必填'
        return redirect(url_for('admin_message'))

    send_content = '{:<30}'.format(summary) + content
    if to == 'all':
        for b_username in r_session.smembers('users'):
            send_msg(b_username.decode('utf-8'), subject,
                     send_content, 3600 * 24 * 7)

    else:
        send_msg(to, subject, send_content, 3600 * 24)

    return redirect(url_for(endpoint='admin_message'))
コード例 #18
0
ファイル: web_common.py プロジェクト: caiyy/crysadm
def dashboard_speed_share():
    user = session.get('user_info')
    username = user.get('username')

    drilldown_data = []
    for user_id in sorted(r_session.smembers('accounts:%s' % username)):

        account_data_key = 'account:%s:%s:data' % (username, user_id.decode('utf-8'))
        b_data = r_session.get(account_data_key)
        if b_data is None:
            continue
        data = json.loads(b_data.decode('utf-8'))

        mid = str(data.get('privilege').get('mid'))

        total_speed = 0
        device_speed = []
        for device in data.get('device_info'):
            if device.get('status') != 'online': continue
            uploadspeed = int(int(device.get('dcdn_upload_speed')) / 1024)
            total_speed += uploadspeed

            device_speed.append(dict(name=device.get('device_name'), value=uploadspeed))

        drilldown_data.append(dict(name='矿主ID:' + mid, value=total_speed, drilldown_data=device_speed))

    return Response(json.dumps(dict(data=drilldown_data)), mimetype='application/json')
コード例 #19
0
ファイル: user.py プロジェクト: care4rei/crysadm
def user_log(sel_type):
    log_as = []
    user = session.get('user_info')

    record_key = '%s:%s' % ('record', user.get('username'))
    record_info = json.loads(r_session.get(record_key).decode('utf-8'))

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

    accounts_key = 'accounts:%s' % user.get('username')
    id_map = {}
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        if user_info.get('is_show_byname') != True:
            id_map[account_info.get('user_id')]=account_info.get('username')
        else:
            id_map[account_info.get('user_id')]=account_info.get('account_name')
    for row in record_info.get('diary'):
        row['id']=id_map.get(row['id'])
        if '1day' == request.args.get('time'):
            if (datetime.now() - datetime.strptime(row.get('time'), '%Y-%m-%d %H:%M:%S')).days < 1:
                if row.get('type').find(str(type_dict.get(sel_type)))!=-1:
                    log_as.append(row)
        elif 'all' == request.args.get('time'):
            if row.get('type').find(str(type_dict.get(sel_type)))!=-1: log_as.append(row)
        else:
            if (datetime.now() - datetime.strptime(row.get('time'), '%Y-%m-%d %H:%M:%S')).days < 7:
                if row.get('type').find(str(type_dict.get(sel_type)))!=-1: log_as.append(row)


    log_as.reverse()

    return render_template('log.html', log_user=log_as)
コード例 #20
0
ファイル: user.py プロジェクト: fengyuclub/crysadm
def get_id_map(username):
    id_map_key = 'id_map:%s' % username;
    b_id_map = r_session.get(id_map_key)
    if b_id_map is not None:
        return json.loads(b_id_map.decode('utf-8'))
    user_key = '%s:%s' % ('user', username)
    user_info = json.loads(r_session.get(user_key).decode('utf-8'))
    accounts_key = 'accounts:%s' % username
    id_map = {}
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (username, acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        if account_data_value is not None:
            account_info['data'] = json.loads(account_data_value.decode("utf-8"))
        if user_info.get('is_show_byname') == None:
            user_info['is_show_byname'] = 1
        if user_info.get('is_show_byname') == 0:
            if account_info.get('remark_name') is None:
                id_map[account_info.get('user_id')]='未备注'
            else:
                id_map[account_info.get('user_id')]=account_info.get('remark_name')
        elif user_info.get('is_show_byname') == 1:
            if 'data' not in account_info.keys():
                id_map[account_info.get('user_id')]=''
            elif 'phone' not in account_info['data']['privilege'].keys():
                id_map[account_info.get('user_id')]=''
            id_map[account_info.get('user_id')]=account_info['data']['privilege']['phone']
        else:
            id_map[account_info.get('user_id')]=account_info.get('username')
    r_session.setex(id_map_key, 60*60, json.dumps(id_map))
    return id_map
コード例 #21
0
ファイル: web_common.py プロジェクト: Tuluobo/crysadm
def dashboard_speed_detail():
    user = session.get("user_info")
    username = user.get("username")
    accounts_key = "accounts:%s" % username

    device_speed = []
    for b_acct in r_session.mget(
        *["account:%s:%s:data" % (username, name.decode("utf-8")) for name in sorted(r_session.smembers(accounts_key))]
    ):

        account_info = json.loads(b_acct.decode("utf-8"))

        for device_info in account_info.get("device_info"):
            if device_info.get("status") != "online":
                continue
            upload_speed = int(int(device_info.get("dcdn_upload_speed")) / 1024)
            deploy_speed = int(device_info.get("dcdn_download_speed") / 1024)

            device_speed.append(
                dict(name=device_info.get("device_name"), upload_speed=upload_speed, deploy_speed=deploy_speed)
            )

    device_speed = sorted(device_speed, key=lambda k: k.get("name"))
    categories = []
    upload_series = dict(name="上传速度", data=[], pointPadding=0.3, pointPlacement=-0.2)
    deploy_series = dict(name="下载速度", data=[], pointPadding=0.4, pointPlacement=-0.2)
    for d_s in device_speed:
        categories.append(d_s.get("name"))
        upload_series.get("data").append(d_s.get("upload_speed"))
        deploy_series.get("data").append(d_s.get("deploy_speed"))

    return Response(
        json.dumps(dict(categories=categories, series=[upload_series, deploy_series])), mimetype="application/json"
    )
コード例 #22
0
ファイル: admin.py プロジェクト: achaoge/crysadm
def del_none_user():
    none_active_xlAcct = list()
    for b_user in r_session.smembers('users'):
        username = b_user.decode('utf-8')

        if r_session.smembers('accounts:' + username) is None or len(r_session.smembers('accounts:' + username)) == 0:
            admin_del_user(username)
        has_active_account = False
        for b_xl_account in r_session.smembers('accounts:' + username):
            xl_account = b_xl_account.decode('utf-8')
            account = json.loads(r_session.get('account:%s:%s' % (username, xl_account)).decode('utf-8'))
            if account.get('active'):
                has_active_account = True
                break
        if not has_active_account:
            none_active_xlAcct.append(username)

    return json.dumps(dict(none_active_xlAcct=none_active_xlAcct))
コード例 #23
0
def dashboard_speed_share():
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username

    account_key = [
        'account:%s:%s:data' % (username, name.decode('utf-8'))
        for name in sorted(r_session.smembers(accounts_key))
    ]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    drilldown_data = []
    for b_acct in r_session.mget(*[
            'account:%s:%s:data' % (username, name.decode('utf-8'))
            for name in sorted(r_session.smembers(accounts_key))
    ]):

        account_info = json.loads(b_acct.decode("utf-8"))
        mid = str(account_info.get('privilege').get('mid'))

        total_speed = 0
        device_speed = []

        for device_info in account_info.get('device_info'):
            if device_info.get('status') != 'online':
                continue
            uploadspeed = int(int(device_info.get('dcdn_upload_speed')) / 1024)
            #downloadspeed = int(int(device_info.get('dcdn_deploy_speed')) / 1024)
            # total_speed += downloadspeed
            total_speed += uploadspeed
            device_speed.append(
                dict(name=device_info.get('device_name'), value=uploadspeed))
            # device_speed.append(dict(name=device_info.get('device_name'), value=total_speed))

        # 显示在速度分析器圆形图表上的设备ID
        drilldown_data.append(
            dict(name='矿主ID:' + mid,
                 value=total_speed,
                 drilldown_data=device_speed))
        #drilldown_data.append(dict(name='设备名:' + device_info.get('device_name'), value=total_speed, drilldown_data=device_speed))

    return Response(json.dumps(dict(data=drilldown_data)),
                    mimetype='application/json')
コード例 #24
0
def none_user():
    none_xlAcct = list()
    none_active_xlAcct = list()
    for b_user in r_session.smembers('users'):
        username = b_user.decode('utf-8')

        if r_session.smembers('accounts:' + username) is None or len(r_session.smembers('accounts:' + username)) == 0:
            none_xlAcct.append(username)
        has_active_account = False
        for b_xl_account in r_session.smembers('accounts:' + username):
            xl_account = b_xl_account.decode('utf-8')
            account = json.loads(r_session.get('account:%s:%s' % (username, xl_account)).decode('utf-8'))
            if account.get('active'):
                has_active_account = True
                break
        if not has_active_account:
            none_active_xlAcct.append(username)

    return json.dumps(dict(none_xlAcct=none_xlAcct, none_active_xlAcct=none_active_xlAcct))
コード例 #25
0
def dashboard_today_income_share():
    from user import get_id_map
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username
    user_key = '%s:%s' % ('user', user.get('username'))
    user_info = json.loads(r_session.get(user_key).decode('utf-8'))

    account_key = [
        'account:%s:%s:data' % (username, name.decode('utf-8'))
        for name in sorted(r_session.smembers(accounts_key))
    ]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    pie_data = []
    id_map = get_id_map(user.get('username'))

    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'),
                                         acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        if account_data_value is not None:
            account_info_data = json.loads(account_data_value.decode("utf-8"))
        else:
            continue
        mid = str(account_info_data.get('privilege').get('mid'))

        total_value = 0
        total_value += account_info_data.get('mine_info').get('dev_m').get(
            'pdc')
        if id_map[account_info.get('user_id')] is None:
            pie_data.append(dict(name='账户名:未知', y=total_value))
        else:
            pie_data.append(
                dict(name='账户名:' + id_map[account_info.get('user_id')],
                     y=total_value))

    return Response(json.dumps(dict(data=pie_data)),
                    mimetype='application/json')
コード例 #26
0
def send_msg(username, subject, content, expire=3600 * 24 * 31, sender='Admin'):
    if bytes(username, 'utf-8') not in r_session.smembers('users'):
        return '找不到该用户。'
    msgs_key = 'user_messages:%s' % username
    msg_id = str(uuid.uuid1())
    msg = dict(id=msg_id, subject=subject, content=content,sender=sender,
               is_read=False, time=datetime.now().strftime('%Y-%m-%d %H:%M'))
    msg_key = 'user_message:%s' % msg_id
    r_session.setex(msg_key, expire, json.dumps(msg))
    r_session.lpush(msgs_key, msg_id)
    return '发送成功'
コード例 #27
0
ファイル: account.py プロジェクト: caiyy/crysadm
def account_activel_all():
    user = session.get('user_info')

    accounts_key = 'accounts:%s' % user.get('username')
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_info['active'] = True
        r_session.set(account_key, json.dumps(account_info))

    return redirect(url_for('accounts'))
コード例 #28
0
def del_none_user():
    none_active_xlAcct = list()
    for b_user in r_session.smembers('users'):
        username = b_user.decode('utf-8')

        if r_session.smembers('accounts:' + username) is None or len(
                r_session.smembers('accounts:' + username)) == 0:
            admin_del_user(username)
        has_active_account = False
        for b_xl_account in r_session.smembers('accounts:' + username):
            xl_account = b_xl_account.decode('utf-8')
            account = json.loads(
                r_session.get('account:%s:%s' %
                              (username, xl_account)).decode('utf-8'))
            if account.get('active'):
                has_active_account = True
                break
        if not has_active_account:
            none_active_xlAcct.append(username)
            admin_del_user(username)
    return redirect(url_for('admin_user'))
コード例 #29
0
ファイル: user.py プロジェクト: im1986/crysadm-1
def diary():
    user = session.get('user_info')

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

    diary_as = list()
    for record in r_session.smembers(record_key):
        diary = json.loads(record.decode('utf-8'))
        if (datetime.now() - datetime.strptime(diary.get('time'), '%Y-%m-%d %H:%M:%S')).days < 7:
            diary_as.append(diary)

    return render_template('diary.html', diary_user=sorted(diary_as, key=lambda x: x['time'], reverse=True))
コード例 #30
0
def account_activel_all():
    user = session.get('user_info')

    accounts_key = 'accounts:%s' % user.get('username')
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'),
                                         acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_info['active'] = True
        r_session.set(account_key, json.dumps(account_info))

    return redirect(url_for('accounts'))
コード例 #31
0
def dashboard_today_income_share():
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username

    account_key = ['account:%s:%s:data' % (username, name.decode(
        'utf-8')) for name in sorted(r_session.smembers(accounts_key))]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    pie_data = []
    for b_acct in r_session.mget(*['account:%s:%s:data' % (username, name.decode('utf-8'))
                                   for name in sorted(r_session.smembers(accounts_key))]):
        account_info = json.loads(b_acct.decode("utf-8"))
        mid = str(account_info.get('privilege').get('mid'))

        total_value = 0
        total_value += account_info.get('mine_info').get('dev_m').get('pdc')

        pie_data.append(dict(name='矿主ID:' + mid, y=total_value))

    return Response(json.dumps(dict(data=pie_data)), mimetype='application/json')
コード例 #32
0
ファイル: web_common.py プロジェクト: HuiMi24/crysadm
def dashboard_today_income_share():
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username

    account_key = ['account:%s:%s:data' % (username, name.decode(
        'utf-8')) for name in sorted(r_session.smembers(accounts_key))]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    pie_data = []
    for b_acct in r_session.mget(*['account:%s:%s:data' % (username, name.decode('utf-8'))
                                   for name in sorted(r_session.smembers(accounts_key))]):
        account_info = json.loads(b_acct.decode("utf-8"))
        mid = str(account_info.get('privilege').get('mid'))

        total_value = 0
        total_value += account_info.get('mine_info').get('dev_m').get('pdc')

        pie_data.append(dict(name='矿主ID:' + mid, y=total_value))

    return Response(json.dumps(dict(data=pie_data)), mimetype='application/json')
コード例 #33
0
def dashboard_speed_detail():
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username

    account_key = ['account:%s:%s:data' % (username, name.decode(
        'utf-8')) for name in sorted(r_session.smembers(accounts_key))]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')

    device_speed = []
    for b_acct in r_session.mget(*['account:%s:%s:data' % (username, name.decode('utf-8'))
                                   for name in sorted(r_session.smembers(accounts_key))]):

        account_info = json.loads(b_acct.decode("utf-8"))

        for device_info in account_info.get('device_info'):
            if device_info.get('status') != 'online':
                continue
            upload_speed = int(
                int(device_info.get('dcdn_upload_speed')) / 1024)
            deploy_speed = int(device_info.get('dcdn_download_speed') / 1024)

            device_speed.append(dict(name=device_info.get(
                'device_name'), upload_speed=upload_speed, deploy_speed=deploy_speed))

    device_speed = sorted(device_speed, key=lambda k: k.get('name'))
    categories = []
    upload_series = dict(name='上传速度', data=[],
                         pointPadding=0.3, pointPlacement=-0.2)
    deploy_series = dict(name='下载速度', data=[],
                         pointPadding=0.4, pointPlacement=-0.2)
    for d_s in device_speed:
        categories.append(d_s.get('name'))
        upload_series.get('data').append(d_s.get('upload_speed'))
        deploy_series.get('data').append(d_s.get('deploy_speed'))

    return Response(json.dumps(dict(categories=categories, series=[upload_series, deploy_series])), mimetype='application/json')
コード例 #34
0
ファイル: admin.py プロジェクト: zhangda7788/Crysadm
def recharge_cards():
    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None
    recharge_cards = []
    for code in r_session.smembers('recharge_card_codes'):
        b_card = r_session.get('recharge_card:%s' % code.decode('utf-8'))
        if b_card is not None:
            card = json.loads(b_card.decode('utf-8'))
            if card.get('status') == '待售':
                card['operation'] = '''
<form style="display: inline-block" role="form" action="/admin/card_sold/''' + card[
                    'code'] + '''" method="post">
    <button type="submit" class="btn btn-outline btn-default btn-xs">售出</button>
</form>
    '''
            elif card.get('status') == '售出':
                card['operation'] = '''
<form style="display: inline-block" role="form" action="/admin/card_delete/''' + card[
                    'code'] + '''" method="post">
    <button type="submit" class="btn btn-outline btn-default btn-xs">销毁</button>
</form>
    '''
            card['code'] = '卡号:%s' % card['code']
            card['key'] = '密码:%s' % card['key']
            recharge_cards.append(card)
    used_cards = []
    for code in r_session.smembers('used_card_codes'):
        b_card = r_session.get('used_card:%s' % code.decode('utf-8'))
        if b_card is not None:
            card = json.loads(b_card.decode('utf-8'))
            used_cards.append(card)
    return render_template('admin_recharge.html',
                           err_msg=err_msg,
                           recharge_cards=recharge_cards,
                           used_cards=used_cards)
コード例 #35
0
def accounts_count():
    count_key = 'count:accounts'
    b_count_info = r_session.get(count_key)
    if b_count_info is not None:
        return dict(accounts_count=json.loads(b_count_info.decode('utf-8')))
    users = r_session.scard('users')
    accounts = 0
    accountsk = 0
    for name in r_session.smembers('users'):
        accounts_key = 'accounts:%s' % name.decode('utf-8')
        for acct in r_session.smembers(accounts_key):
            account_key = 'account:%s:%s' % (name.decode('utf-8'),
                                             acct.decode("utf-8"))
            account_data_key = account_key + ':data'
            account_data_value = r_session.get(account_data_key)
            if account_data_value is None: continue
            account_info = json.loads(account_data_value.decode("utf-8"))
            for i in account_info.get('device_info'):
                accountsk += 1

        accounts += r_session.scard(accounts_key)
    accounts_count = dict(users=users, accounts=accounts, accountsk=accountsk)
    r_session.setex(count_key, 120, json.dumps(accounts_count))
    return dict(accounts_count=accounts_count)
コード例 #36
0
ファイル: user.py プロジェクト: ajun59420/ajun59420
def get_mid_to_uid(username):
    mid_to_uid_key = 'mid_to_uid:%s' % username;
    b_mid_to_uid = r_session.get(mid_to_uid_key)
    if b_mid_to_uid is not None:
        return json.loads(b_mid_to_uid.decode('utf-8'))
    mid_to_uid={}
    accounts_key = 'accounts:%s' % username
    for acct in sorted(r_session.smembers(accounts_key)):
        account_data_key = 'account:%s:%s:data' % (username, acct.decode("utf-8"))
        b_account_data = r_session.get(account_data_key)
        if b_account_data is not None:
            account_data = json.loads(b_account_data.decode("utf-8"))
            mid_to_uid[account_data.get('privilege').get('mid')]=acct.decode("utf-8")
    r_session.setex(mid_to_uid_key, json.dumps(mid_to_uid), 24*60*60)
    return mid_to_uid
コード例 #37
0
ファイル: user.py プロジェクト: fengyuclub/crysadm
def get_mid_to_uid(username):
    mid_to_uid_key = 'mid_to_uid:%s' % username;
    b_mid_to_uid = r_session.get(mid_to_uid_key)
    if b_mid_to_uid is not None:
        return json.loads(b_mid_to_uid.decode('utf-8'))
    mid_to_uid={}
    accounts_key = 'accounts:%s' % username
    for acct in sorted(r_session.smembers(accounts_key)):
        account_data_key = 'account:%s:%s:data' % (username, acct.decode("utf-8"))
        b_account_data = r_session.get(account_data_key)
        if b_account_data is not None:
            account_data = json.loads(b_account_data.decode("utf-8"))
            mid_to_uid[account_data.get('privilege').get('mid')]=acct.decode("utf-8")
    r_session.setex(mid_to_uid_key, 24*60*60, json.dumps(mid_to_uid))
    return mid_to_uid
コード例 #38
0
def user_log():
    log_as = []
    user = session.get('user_info')
    if request.args.get('time') is not None:
        session['log_sel_time'] = request.args.get('time')
    if request.args.get('type') is not None:
        session['log_sel_type'] = request.args.get('type')

    record_key = '%s:%s' % ('record', user.get('username'))
    record_info = json.loads(r_session.get(record_key).decode('utf-8'))

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

    accounts_key = 'accounts:%s' % user.get('username')
    id_map = {}

    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'),
                                         acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        if user_info.get('is_show_byname') != True:
            id_map[account_info.get('user_id')] = account_info.get('username')
        else:
            id_map[account_info.get('user_id')] = account_info.get(
                'account_name')
    for row in record_info.get('diary'):
        row['id'] = id_map.get(row['id'])
        if '1day' == session.get('log_sel_time'):
            if (datetime.now().date() - datetime.strptime(
                    row.get('time'), '%Y-%m-%d %H:%M:%S').date()).days < 1:
                if row.get('type').find(
                        str(type_dict.get(session.get('log_sel_type')))) != -1:
                    log_as.append(row)
        elif 'all' == session.get('log_sel_time'):
            if row.get('type').find(
                    str(type_dict.get(session.get('log_sel_type')))) != -1:
                log_as.append(row)
        else:
            if (datetime.now().date() - datetime.strptime(
                    row.get('time'), '%Y-%m-%d %H:%M:%S').date()).days < 7:
                if row.get('type').find(
                        str(type_dict.get(session.get('log_sel_type')))) != -1:
                    log_as.append(row)

    log_as.reverse()

    return render_template('log.html', log_user=log_as)
コード例 #39
0
ファイル: admin.py プロジェクト: zhangda7788/Crysadm
def admin_message_send():
    send_type = request.values.get('type')
    to = request.values.get('to')
    subject = request.values.get('subject')
    summary = request.values.get('summary')
    content = request.values.get('content')

    if subject == '':
        session['error_message'] = '标题为必填。'
        return redirect(url_for('admin_message'))

    if to == '':
        session['error_message'] = '收件方必填。'
        return redirect(url_for('admin_message'))

    if summary == '':
        session['error_message'] = '简介必填'
        return redirect(url_for('admin_message'))

    send_content = '{:<30}'.format(summary) + content
    if send_type == 'message':
        user = session.get('user_info')
        if to == 'all':
            for b_username in r_session.smembers('users'):
                send_msg(b_username.decode('utf-8'), subject, send_content,
                         3600 * 24 * 31, user.get('username'))

        else:
            send_msg(to, subject, send_content, 3600 * 24 * 31,
                     user.get('username'))
    else:
        from mailsand import send_email
        from mailsand import validateEmail
        to_set = set(to.split(';'))
        to_list = list()
        for email in to_set:
            if validateEmail(email) == 1:
                to_list.append(email)
        config_key = '%s:%s' % ('user', 'system')
        config_info = json.loads(r_session.get(config_key).decode('utf-8'))
        mail = dict()
        mail['to'] = ",".join(to_list)
        mail['subject'] = subject
        mail['text'] = send_content
        if not send_email(mail, config_info):
            session['error_message'] = '发送失败,请检查邮件配置'

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

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

    diary_as = list()
    for record in r_session.smembers(record_key):
        diary = json.loads(record.decode('utf-8'))
        if (datetime.now() - datetime.strptime(diary.get('time'),
                                               '%Y-%m-%d %H:%M:%S')).days < 7:
            diary_as.append(diary)

    return render_template('diary.html',
                           diary_user=sorted(diary_as,
                                             key=lambda x: x['time'],
                                             reverse=True))
コード例 #41
0
def accounts():
    user = session.get('user_info')
    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None

    accounts_key = 'accounts:%s' % user.get('username')

    account_s = list()
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_s.append(account_info)

    return render_template('accounts.html', err_msg=err_msg, accounts=account_s)
コード例 #42
0
ファイル: account.py プロジェクト: achaoge/crysadm
def accounts():
    user = session.get('user_info')
    err_msg = None
    if session.get('error_message') is not None:
        err_msg = session.get('error_message')
        session['error_message'] = None

    accounts_key = 'accounts:%s' % user.get('username')

    account_s = list()
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_s.append(account_info)

    return render_template('accounts.html', err_msg=err_msg, accounts=account_s)
コード例 #43
0
ファイル: web_common.py プロジェクト: fengyuclub/crysadm
def dashboard_speed_share():
    from user import get_id_map
    user = session.get('user_info')
    username = user.get('username')
    accounts_key = 'accounts:%s' % username
    user_key = '%s:%s' % ('user', user.get('username'))
    user_info = json.loads(r_session.get(user_key).decode('utf-8'))
 
    account_key = ['account:%s:%s:data' % (username, name.decode('utf-8')) for name in sorted(r_session.smembers(accounts_key))]
    if len(account_key) == 0:
        return Response(json.dumps(dict(data=[])), mimetype='application/json')
    accounts_key = 'accounts:%s' % user.get('username')
    id_map = get_id_map(user.get('username'))
    drilldown_data = []    
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        if account_data_value is not None:
            account_info_data=json.loads(account_data_value.decode("utf-8"))
        else:
            continue
        mid = str(account_info_data.get('privilege').get('mid'))

        total_speed = 0
        device_speed = []

        for device_info in account_info_data.get('device_info'):
            if device_info.get('status') != 'online':
                continue
            uploadspeed = int(int(device_info.get('dcdn_upload_speed')) / 1024)            
            #downloadspeed = int(int(device_info.get('dcdn_deploy_speed')) / 1024)
            # total_speed += downloadspeed
            total_speed += uploadspeed            
            device_speed.append(dict(name=device_info.get('device_name'), value=uploadspeed))            
            # device_speed.append(dict(name=device_info.get('device_name'), value=total_speed))

        # 显示在速度分析器圆形图表上的设备ID
        if id_map[account_info.get('user_id')] is None:
            drilldown_data.append(dict(name='账户名:未知', value=total_speed, drilldown_data=device_speed))
        else:
            drilldown_data.append(dict(name='账户名:' + id_map[account_info.get('user_id')], value=total_speed, drilldown_data=device_speed))
        #drilldown_data.append(dict(name='设备名:' + device_info.get('device_name'), value=total_speed, drilldown_data=device_speed))

    return Response(json.dumps(dict(data=drilldown_data)), mimetype='application/json')
コード例 #44
0
ファイル: excavator.py プロジェクト: yunt/crysadm
def func_exec_drawcash(USERID=None):
    if DEBUG_MODE:
        print('func_exec_drawcash() : incomingID = %s' % USERID)
    user = session.get('user_info')
    username = user.get('username')
    err_msg = ''
    info_msg = ''

    for b_user_id in r_session.smembers('accounts:%s' % username):
        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        if DEBUG_MODE:
            print(account_key)
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        if DEBUG_MODE:
            print(account_info)
        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        if USERID is not None and user_id != USERID:
            if DEBUG_MODE:
                print(
                    'func_exec_drawcash() : Specify user_id is %s, current id is %s, do not cash!'
                    % (USERID, user_id))
            continue

        cookies = dict(sessionid=session_id, userid=str(user_id))

        r = xunlei_api_exec_getCash2(cookies=cookies, limits=10)
        if DEBUG_MODE:
            print('xunlei_api_exec_getCash(%s) : %s' % (cookies, r))
        if r.get('r') != 0:
            err_msg += '  %s : %s <br />' % (user_id, r['rd'])
        else:
            info_msg += '  %s : %s <br />' % (user_id, r['rd'])
            account_data_key = account_key + ':data'
            account_data_value = json.loads(
                r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('income')['r_can_use'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))
            time.sleep(10)

    if len(info_msg) > 0:
        session['info_message'] = info_msg
    if len(err_msg) > 0:
        session['error_message'] = err_msg
    return redirect(url_for('excavators'))
コード例 #45
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'))
コード例 #46
0
ファイル: excavator.py プロジェクト: crysadm/crysadm
def func_exec_drawcash(USERID=None):
    if DEBUG_MODE:
        print('func_exec_drawcash() : incomingID = %s' % USERID)
    try:
        user = session.get('user_info')
        username = user.get('username')
        err_msg = ''
        info_msg = ''

        for b_user_id in r_session.smembers('accounts:%s' % username):
            account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
            if DEBUG_MODE:
                print(account_key)
            account_info = json.loads(r_session.get(account_key).decode("utf-8"))
            if DEBUG_MODE:
                print(account_info)
            session_id = account_info.get('session_id')
            user_id = account_info.get('user_id')

            if USERID is not None and user_id != USERID:
                if DEBUG_MODE:
                    print('func_exec_drawcash() : Specify user_id is %s, current id is %s, do not cash!' % (USERID, user_id))
                continue

            cookies = dict(sessionid=session_id, userid=str(user_id))

            r = xunlei_api_exec_getCash(cookies=cookies, limits=10)
            if DEBUG_MODE:
                print('xunlei_api_exec_getCash(%s) : %s' % (cookies, r))
            if r.get('r') != 0:
                err_msg += '  %s : %s <br />' % (user_id, r['rd'])
            else:
                info_msg += '  %s : %s <br />' % (user_id, r['rd'])            
                account_data_key = account_key + ':data'
                account_data_value = json.loads(r_session.get(account_data_key).decode("utf-8"))
                account_data_value.get('income')['r_can_use'] = 0
                r_session.set(account_data_key, json.dumps(account_data_value))
                time.sleep(100)

        if len(info_msg) > 0:
            session['info_message'] = info_msg
        if len(err_msg) > 0:
            session['error_message'] = err_msg
        return redirect(url_for('excavators'))
    except Exception as e:
        return
コード例 #47
0
ファイル: excavator.py プロジェクト: baiy8168/crysadm
def async_drawcash_all(username):
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        r = exec_draw_cash(cookies)
        red_log('手动执行', '提现', user_id, r.get('rd'), username)
        if r.get('r') == 0:
            account_data_key = account_key + ':data'
            account_data_value = json.loads(r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('income')['r_can_use'] -= int(account_data_value.get('income')['r_can_use'])
            r_session.set(account_data_key, json.dumps(account_data_value))
コード例 #48
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'))
コード例 #49
0
ファイル: excavator.py プロジェクト: baiy8168/crysadm
def async_umount_disk_all(user):
    accounts_key = 'accounts:%s' % user.get('username')
    for acct in r_session.smembers(accounts_key):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        if account_data_value is not None:
            data = json.loads(account_data_value.decode("utf-8"))
            if 'device_info' in data.keys():
                for device in data['device_info']:
                    if device['status'] == 'offline':
                        continue
                    session_id = account_info['session_id']
                    device_id = device['device_id']
                    account_id = device['account_id']
                    ubus_cd(session_id, account_id, 'umount_usb', ["mnt", "umount_usb", {}], '&device_id=%s' % device_id)
                    time.sleep(5)
コード例 #50
0
ファイル: excavator.py プロジェクト: baiy8168/crysadm
def async_upgrade_device_all(user):
    accounts_key = 'accounts:%s' % user.get('username')
    for acct in r_session.smembers(accounts_key):
        account_key = 'account:%s:%s' % (user.get('username'), acct.decode("utf-8"))
        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        if account_data_value is not None:
            data = json.loads(account_data_value.decode("utf-8"))
            if 'device_info' in data.keys():
                for device in data['device_info']:
                    if not device['upgradeable']:
                        continue
                    session_id = account_info['session_id']
                    device_id = device['device_id']
                    account_id = device['account_id']
                    ubus_cd(session_id, account_id, 'get_progress', ["upgrade", "start", {}], '&device_id=%s' % device_id)
                    ubus_cd(session_id, account_id, 'get_progress', ["upgrade", "get_progress", {}], '&device_id=%s' % device_id)
                    time.sleep(5)
コード例 #51
0
def dashboard_speed_detail():
    user = session.get('user_info')
    username = user.get('username')

    device_speed = []
    for user_id in sorted(r_session.smembers('accounts:%s' % username)):

        account_data_key = 'account:%s:%s:data' % (username,
                                                   user_id.decode('utf-8'))
        b_data = r_session.get(account_data_key)
        if b_data is None:
            continue
        data = json.loads(b_data.decode('utf-8'))

        for device in data.get('device_info'):
            if device.get('status') != 'online': continue
            upload_speed = int(int(device.get('dcdn_upload_speed')) / 1024)
            deploy_speed = int(int(device.get('dcdn_download_speed')) / 1024)

            device_speed.append(
                dict(name=device.get('device_name'),
                     upload_speed=upload_speed,
                     deploy_speed=deploy_speed))

    device_speed = sorted(device_speed, key=lambda k: k.get('name'))

    categories = []
    upload_series = dict(name='上传速度',
                         data=[],
                         pointPadding=0.3,
                         pointPlacement=-0.2)
    deploy_series = dict(name='下载速度',
                         data=[],
                         pointPadding=0.4,
                         pointPlacement=-0.2)
    for d_s in device_speed:
        categories.append(d_s.get('name'))
        upload_series.get('data').append(d_s.get('upload_speed'))
        deploy_series.get('data').append(d_s.get('deploy_speed'))

    return Response(json.dumps(
        dict(categories=categories, series=[upload_series, deploy_series])),
                    mimetype='application/json')
コード例 #52
0
ファイル: excavator.py プロジェクト: baiy8168/crysadm
def async_searcht_all(username):
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        r = check_searcht(cookies)
        if r.get('r') != 0:
            red_log('手动执行', '进攻', user_id, regular_html(r.get('rd')), username)
        else:
            red_log('手动执行', '进攻', user_id, '获得:%s秘银.' % r.get('s'), username)
            account_data_key = account_key + ':data'
            account_data_value = json.loads(r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('mine_info')['td_not_in_a'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))
コード例 #53
0
ファイル: excavator.py プロジェクト: yunt/crysadm
def func_collect_crystal(USERID=None):
    if DEBUG_MODE:
        print('func_collect_crystal() incoming USERID = %s' % USERID)
    user = session.get('user_info')
    username = user.get('username')
    err_msg = ''
    info_msg = ''

    for b_user_id in r_session.smembers('accounts:%s' % username):
        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        if DEBUG_MODE:
            print('collect_crystal() : account_key=%s' % account_key)
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        if DEBUG_MODE:
            print('collect_crystal() : account_info=%s' % account_info)
        user_id = account_info.get('user_id')
        if DEBUG_MODE:
            print('collect_crystal() : user_id=%s' % user_id)
        if USERID is not None and user_id != USERID:
            if DEBUG_MODE:
                print(
                    'collect_crystal() : Specify user_id is %s, current id is %s, do not collected!'
                    % (USERID, user_id))
            continue

        cookies = dict(sessionid=account_info.get('session_id'),
                       userid=str(user_id))
        r = xunlei_api_exec_collect(cookies)
        if r.get('r') != 0:
            err_msg += '  %s : %s <br />' % (user_id, r['rd'])
        else:
            info_msg += '  %s : 收取水晶成功 <br />' % user_id
            account_data_key = account_key + ':data'
            account_data_value = json.loads(
                r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('mine_info')['td_not_in_a'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))

    if len(info_msg) > 0:
        session['info_message'] = info_msg
    if len(err_msg) > 0:
        session['error_message'] = err_msg
    return redirect(url_for('excavators'))
コード例 #54
0
ファイル: excavator.py プロジェクト: baiy8168/crysadm
def async_collect_all(username):
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        mine_info = get_mine_info(cookies)
        time.sleep(5)
        r = collect(cookies)
        if r.get('rd') != 'ok':
            log = '%s' % r.get('rd')
        else:
            log = '收取:%s水晶.' % mine_info.get('td_not_in_a')
            account_data_key = account_key + ':data'
            account_data_value = json.loads(r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('mine_info')['td_not_in_a'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))
        red_log('手动执行', '收取', user_id, log, username)
コード例 #55
0
def dashboard_speed_share():
    user = session.get('user_info')
    username = user.get('username')

    drilldown_data = []
    for user_id in sorted(r_session.smembers('accounts:%s' % username)):

        account_data_key = 'account:%s:%s:data' % (username,
                                                   user_id.decode('utf-8'))
        b_data = r_session.get(account_data_key)
        if b_data is None:
            continue
        data = json.loads(b_data.decode('utf-8'))

        mid = str(data.get('privilege').get('mid'))

        total_speed = 0
        device_speed = []
        for device in data.get('device_info'):
            if device.get('status') != 'online': continue
            uploadspeed = int(int(device.get('dcdn_upload_speed')) / 1024)
            total_speed += uploadspeed

            device_speed.append(
                dict(name=device.get('device_name'), value=uploadspeed))
            # downloadspeed = int(int(device_info.get('dcdn_deploy_speed')) / 1024)
            # total_speed += downloadspeed

            # device_speed.append(dict(name=device_info.get('device_name'), value=total_speed))

        # 显示在速度分析器圆形图表上的设备ID
        drilldown_data.append(
            dict(name='矿主ID:' + mid,
                 value=total_speed,
                 drilldown_data=device_speed))
        # drilldown_data.append(dict(name='设备名:' + device_info.get('device_name'), value=total_speed, drilldown_data=device_speed))

    return Response(json.dumps(dict(data=drilldown_data)),
                    mimetype='application/json')
コード例 #56
0
def dashboard_today_income_share():
    user = session.get('user_info')
    username = user.get('username')

    pie_data = []
    for user_id in sorted(r_session.smembers('accounts:%s' % username)):

        account_data_key = 'account:%s:%s:data' % (username, user_id.decode('utf-8'))
        b_data = r_session.get(account_data_key)
        if b_data is None:
            continue
        data = json.loads(b_data.decode('utf-8'))

        mid = str(data.get('privilege').get('mid'))

        total_value = 0
        this_pdc = data.get('mine_info').get('dev_m').get('pdc')
        total_value += this_pdc

        pie_data.append(dict(name='矿主ID:' + mid, y=total_value))

    return Response(json.dumps(dict(data=pie_data)), mimetype='application/json')
コード例 #57
0
ファイル: admin.py プロジェクト: yunt/crysadm
def admin_user():
    recent_login_users = []
    users = list()

    for b_user in r_session.mget(*[
            'user:%s' % name.decode('utf-8')
            for name in sorted(r_session.smembers('users'))
    ]):
        if b_user is None:
            continue
        user = json.loads(b_user.decode('utf-8'))
        if user.get('login_as_time') is not None:
            if (datetime.now() - datetime.strptime(
                    user.get('login_as_time'), '%Y-%m-%d %H:%M:%S')).days < 3:
                recent_login_users.append(user)
        users.append(user)

    return render_template('admin_user.html',
                           recent_login_users=sorted(
                               recent_login_users,
                               key=lambda k: k['login_as_time'],
                               reverse=True),
                           users=users)
コード例 #58
0
ファイル: excavator.py プロジェクト: okcom84301/crysadm-1
def getaward_all():
    user = session.get('user_info')
    username = user.get('username')

    error_message = ''
    success_message = ''
    for b_user_id in r_session.smembers('accounts:%s' % username):

        account_key = 'account:%s:%s' % (username, b_user_id.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))

        session_id = account_info.get('session_id')
        user_id = account_info.get('user_id')

        cookies = dict(sessionid=session_id, userid=str(user_id))
        r = api_getaward(cookies)
        if r.get('rd') != 'ok':
            error_message += 'Id:%s : %s<br />' % (user_id, r.get('rd'))
            red_log('手动执行', '转盘', user_id, r.get('rd'))
        else:
            success_message += 'Id:%s : 获得:%s  下次转需要:%s 秘银.<br />' % (
                user_id, regular_html(r.get('tip')), r.get('cost'))
            red_log('手动执行', '转盘', user_id,
                    '获得:%s' % regular_html(r.get('tip')))
            account_data_key = account_key + ':data'
            account_data_value = json.loads(
                r_session.get(account_data_key).decode("utf-8"))
            account_data_value.get('mine_info')['td_not_in_a'] = 0
            r_session.set(account_data_key, json.dumps(account_data_value))
    if len(success_message) > 0:
        session['info_message'] = success_message

    if len(error_message) > 0:
        session['error_message'] = error_message

    return redirect(url_for('excavators'))
コード例 #59
0
def get_id_map(username):
    id_map_key = 'id_map:%s' % username
    b_id_map = r_session.get(id_map_key)
    if b_id_map is not None:
        return json.loads(b_id_map.decode('utf-8'))
    user_key = '%s:%s' % ('user', username)
    user_info = json.loads(r_session.get(user_key).decode('utf-8'))
    accounts_key = 'accounts:%s' % username
    id_map = {}
    for acct in sorted(r_session.smembers(accounts_key)):
        account_key = 'account:%s:%s' % (username, acct.decode("utf-8"))
        account_info = json.loads(r_session.get(account_key).decode("utf-8"))
        account_data_key = account_key + ':data'
        account_data_value = r_session.get(account_data_key)
        if account_data_value is not None:
            account_info['data'] = json.loads(
                account_data_value.decode("utf-8"))
        if user_info.get('is_show_byname') == None:
            user_info['is_show_byname'] = 1
        if user_info.get('is_show_byname') == 0:
            if account_info.get('remark_name') is None:
                id_map[account_info.get('user_id')] = '未备注'
            else:
                id_map[account_info.get('user_id')] = account_info.get(
                    'remark_name')
        elif user_info.get('is_show_byname') == 1:
            if 'data' not in account_info.keys():
                id_map[account_info.get('user_id')] = ''
            elif 'phone' not in account_info['data']['privilege'].keys():
                id_map[account_info.get('user_id')] = ''
            id_map[account_info.get(
                'user_id')] = account_info['data']['privilege']['phone']
        else:
            id_map[account_info.get('user_id')] = account_info.get('username')
    r_session.setex(id_map_key, json.dumps(id_map), 60 * 60)
    return id_map