Пример #1
0
def cat_image(web, typ):
    try:
        hash = web['QUERY_STRING']
        iscat = typ in cache(hash)[2]
        nr = cache(hash)[3][ord(typ)-65]
    except Exception as e: return notfound(str(e))
    yield_file("static/img/{0}acat{1}.jpeg".\
        format(not iscat and "not" or "", nr))
Пример #2
0
def captcha_is_ok(web):
    found, hash = False, web.input('hash')
    captcha, tip = web.input('tcha'), None
    if captcha == "sum":
        typ, tip = 1, web.input('sumtcha')
        try:    tip = int(tip)
        except: tip = None
    elif captcha == "cat":
        typ, tip = 2, web.input('cat')
        if not isinstance(tip, list): tip = [tip]
    else:
        typ, tip = 0, -1
    if hash is not None:
        if in_cache(hash):
            found = cache(hash)[typ] == tip
    clean_cache(hash)
    return found