Example #1
0
def send_check_mail(request):
    game_id = int(request.POST.get('game_id'))
    server_id = int(request.POST.get('server_id'))
    uid = int(request.POST.get('uid'))
    if uid is None or game_id is None or server_id is None:
        return HttpResponse(status=401)
    game = get_object_or_404(Game, pk=game_id)
    server = get_object_or_404(Server, pk=server_id)
    p = option()
    ss = ServerControl(server, uid, p)
    base_info = ss.base_info()
    ugs = request.user.usergame_set.filter(game=game, server=server)
    if len(ugs) > 0:
        ug = ugs[0]
        if (timezone.now() - ug.created_date) < timedelta(seconds=100):
            return HttpResponse(status=401)
        ug.created_date = timezone.now()
    else:
        ug = UserGame(
            user=request.user,
            game=game,
            server=server,
            uin=base_info.get('uin'),
            check=clac_check_no(str(uid)),
            created_date=timezone.now())
    ug.save()
    if int(base_info.get('total_recharge')) < int(p.get('vip', 60)):
        response_id = 0
    else:
        response_id = ss.send_mail(ug.check)
        logger = logging.getLogger(__name__)
        logger.info('Send Check Mail {0} To {1}'.format(response_id, uid))
    tmp = {'result': response_id}
    ret = json.dumps(tmp, ensure_ascii=False)
    return HttpResponse(ret, content_type='application/json')
Example #2
0
def usergame(request, user_game_id, url='information'):
    p = option()
    t = "account/usergame.html"
    data = view_template_base(request, url)
    ug = get_object_or_404(UserGame, pk=user_game_id)
    data['usergame'] = ug
    data['game'] = ug.game
    data['zones'] = ug.server.zone_set.all()
    data['paymentgoods'] = ug.game.paymentgood_set.filter(anyone=0)
    data['paymentgoodsanyone'] = ug.game.paymentgood_set.filter(anyone=1)
    ss = ServerControl(ug.server, 0, option())
    base_info = ss.get_player_world_info(ug.uin)
    data['world_info'] = base_info
    data['min_donate'] = p['min_donate']
    return render(request, t, data)
Example #3
0
def _shipping(dpo):
    logger = logging.getLogger(__name__)
    remarks = eval(dpo.remarks)
    url = dpo.user_game.server.shipping_url
    game_id = dpo.user_game.game.game_id
    money = dpo.money
    ss = ServerControl(dpo.user_game.server, int(remarks[1]), option())
    base_info = ss.base_info()
    values = {
        'gameid_91act': game_id,
        'time': int(time()),
        'sign': 'T',
        'oid': dpo.number,
        'doid': dpo.number,
        'dsid': remarks[0],
        'dext': dpo.paymentgood.dext,
        'drid': remarks[1],
        'drname': remarks[1],
        'uid': base_info.get('uin', ""),
        'money': money,
        'coin': money*10,
        'pid': dpo.paymentgood.payment.act_pid,
    }
    str_encryption = _encryption(values, dpo.user_game.game.key)
    values['sign'] = str_encryption
    data_json = json.dumps(values)
    req = urllib2.Request(url, data_json)
    req.add_header('User-Agent', 'Who is your daddy')
    req.add_header('Content-Type', 'application/json')
    try:
        response = urllib2.urlopen(req, timeout=20)
        html = response.read()
        ret = json.loads(html)
    except Exception as e:
        logger.error('Shipping Exception : {0}|{1}'.format(dpo.number, e))
        return False
    if ret['state'] == 1:
        dpo.status = 'done'
        dpo.done_date = timezone.now()
        dpo.game_status = str(ret)
        dpo.save()
        return True
    dpo.done_date = timezone.now()
    dpo.game_status = str(ret)
    dpo.save()
    return False
Example #4
0
def uid(request, uid):
    p = option()
    user_game_id = int(p['donate_user_game_id'])
    ug = get_object_or_404(UserGame, pk=user_game_id)
    ss = ServerControl(ug.server, int(uid), p)
    try:
        base_info = ss.base_info()
    except Exception as e:
        logger = logging.getLogger(__name__)
        logger.error('Get UID Exception : {0}|{1}'.format(uid, e))
        tmp = {'result': 1}
        ret = json.dumps(tmp, ensure_ascii=False)
        return HttpResponse(ret, content_type='application/json')
    tmp = {
        'result': 0,
        'name': base_info['name'],
        'zone': base_info['world_id']}
    ret = json.dumps(tmp, ensure_ascii=False)
    return HttpResponse(ret, content_type='application/json')