コード例 #1
0
ファイル: views.py プロジェクト: LubyRuffy/WhoDat
def __createRequestContext__(request, data = None):
    #Default to adding search forms to every context
    search_f = domain_form()
    pdns_f = pdns_form()
    pdns_r_f = pdns_r_form()
    advdomain_f = advdomain_form()

    ctx_var = { 'domain_form' : search_f,
                'advdomain_form': advdomain_f,
                'pdns_form': pdns_f,
                'pdns_r_form': pdns_r_f,
                'latest_version': handler.lastVersion(),
                'handler': settings.HANDLER
              } 

    if settings.HANDLER == 'es':
        ctx_var['health'] = handler.cluster_health().capitalize()
        ctx_var['record_count'] = handler.record_count()
        ctx_var['last_import'] = handler.lastVersion()
        ctx_var['scripting'] = settings.ES_SCRIPTING_ENABLED

    if data is not None:
        ctx_var.update(data)
        if 'active' not in data:
            if 'pdns_form' in data:
                ctx_var['active'] = 1
            elif 'pdns_r_form' in data:
                ctx_var['active'] = 2
            else:
                ctx_var['active'] = 0

    return RequestContext(request, ctx_var)
コード例 #2
0
def __createRequestContext__(request, data=None):
    #Default to adding search forms to every context
    search_f = domain_form()
    pdns_f = pdns_form()
    pdns_r_f = pdns_r_form()
    advdomain_f = advdomain_form()

    ctx_var = {
        'domain_form': search_f,
        'advdomain_form': advdomain_f,
        'pdns_form': pdns_f,
        'pdns_r_form': pdns_r_f,
        'latest_version': handler.lastVersion(),
        'handler': settings.HANDLER
    }

    if settings.HANDLER == 'es':
        ctx_var['health'] = handler.cluster_health().capitalize()
        ctx_var['record_count'] = handler.record_count()
        ctx_var['last_import'] = handler.lastVersion()
        ctx_var['scripting'] = settings.ES_SCRIPTING_ENABLED

    if data is not None:
        ctx_var.update(data)
        if 'active' not in data:
            if 'pdns_form' in data:
                ctx_var['active'] = 1
            elif 'pdns_r_form' in data:
                ctx_var['active'] = 2
            else:
                ctx_var['active'] = 0

    return RequestContext(request, ctx_var)
コード例 #3
0
def __createRequestContext__(data=None):
    #Default to adding search forms to every context
    search_f = domain_form()
    pdns_f_dyn = pdns_form_dynamic()
    rpdns_f_dyn = rpdns_form_dynamic()
    advdomain_f = advdomain_form()

    ctx_var = { 'domain_form': search_f,
                'advdomain_form': advdomain_f,
                'pdns_form_dynamic': pdns_f_dyn,
                'rpdns_form_dynamic': rpdns_f_dyn,   
                'latest_version': handler.lastVersion(),
                'handler': settings.HANDLER, 
                'pdns_sources':[mod_data.config for mod_data in passive.PDNS_HANDLER_MODS.values()]
            }

    if settings.HANDLER == 'es':
        ctx_var['health'] = handler.cluster_health().capitalize()
        ctx_var['record_count'] = handler.record_count()
        ctx_var['last_import'] = handler.lastUpdate()

    if data is not None:
        ctx_var.update(data)
        if 'active' not in data:
            if 'pdns_form' in data:
                ctx_var['active'] = 1
            elif 'pdns_r_form' in data:
                ctx_var['active'] = 2
            else:
                ctx_var['active'] = 0

    return ctx_var
コード例 #4
0
ファイル: views.py プロジェクト: fork42541/WhoDat
def __createRequestContext__(request, data = None):
    #Default to adding search forms to every context
    search_f = domain_form()
    pdns_f = pdns_form()
    pdns_r_f = pdns_r_form()
   
    ctx_var = { 'domain_form' : search_f,
                'pdns_form': pdns_f,
                'pdns_r_form': pdns_r_f,
                'latest_version': handler.lastVersion()
              } 

    if data is not None:
        ctx_var.update(data)
        if 'active' not in data:
            if 'pdns_form' in data:
                ctx_var['active'] = 1
            elif 'pdns_r_form' in data:
                ctx_var['active'] = 2
            else:
                ctx_var['active'] = 0

    return RequestContext(request, ctx_var)
コード例 #5
0
ファイル: views.py プロジェクト: mpars0ns/WhoDat
def __createRequestContext__(request, data=None):
    #Default to adding search forms to every context
    search_f = domain_form()
    pdns_f = pdns_form()
    pdns_r_f = pdns_r_form()

    ctx_var = {
        'domain_form': search_f,
        'pdns_form': pdns_f,
        'pdns_r_form': pdns_r_f,
        'latest_version': handler.lastVersion()
    }

    if data is not None:
        ctx_var.update(data)
        if 'active' not in data:
            if 'pdns_form' in data:
                ctx_var['active'] = 1
            elif 'pdns_r_form' in data:
                ctx_var['active'] = 2
            else:
                ctx_var['active'] = 0

    return RequestContext(request, ctx_var)
コード例 #6
0
def domains(request, key=None, value=None):
    if request.method == "POST":
        search_f = domain_form(request.POST)

    elif request.method == "GET":
        search_f = domain_form(QueryDict(''))
        search_f.data['key'] = key
        search_f.data['value'] = value
        search_f.data['fmt'] = request.GET.get('fmt', 'normal')
        search_f.data['limit'] = request.GET.get('limit', settings.LIMIT)
        search_f.data['filt'] = request.GET.get('filt',
                                                settings.SEARCH_KEYS[0][0])
        search_f.data['latest'] = request.GET.get('latest', False)

    else:
        return __renderErrorPage__(request, 'Bad Method.')

    if not search_f.is_valid():
        return __renderErrorResponse__(request, 'domain.html', '',
                                       {'domain_form': search_f})

    key = urllib.unquote(search_f.cleaned_data['key'])
    value = urllib.unquote(search_f.cleaned_data['value'])

    filt_key = search_f.cleaned_data['filt']
    fmt = search_f.cleaned_data['fmt']
    limit = int(search_f.cleaned_data.get('limit', settings.LIMIT))
    latest = search_f.cleaned_data['latest']

    if latest:
        low_version = handler.lastVersion()
        high_version = low_version
    else:
        low_version = None
        high_version = None

    filt = None
    if fmt == 'list':  #Only filter if a list was requested
        filt = filt_key

    #All web searches are AJAXy
    if fmt == "normal":
        low_version_js = low_version
        high_version_js = high_version
        if low_version == None:
            low_version_js = 'null'
        if high_version == None:
            high_version_js = 'null'
        context = __createRequestContext__(request,
                                           data={
                                               'key': urllib.quote(key),
                                               'value': urllib.quote(value),
                                               'low_version': low_version_js,
                                               'high_version': high_version_js,
                                               'domain_form': search_f,
                                               'legacy_search': True,
                                           })
        return render_to_response('domain_results.html', context)

    else:
        results = handler.search(key,
                                 value,
                                 filt=filt,
                                 limit=limit,
                                 low=low_version)
        if results['success'] == False:
            return __renderErrorPage__(request, results['message'])
        if fmt == 'json':
            return HttpResponse(json.dumps(results),
                                content_type='application/json')
        elif fmt == 'list':
            data = '\n'.join([d[filt_key] for d in results['data']])
            return HttpResponse(data, content_type='text/plain')
        else:
            return __renderErrorPage__(request, 'Invalid Format.')
コード例 #7
0
ファイル: ajax.py プロジェクト: LubyRuffy/WhoDat
def domain_latest(request, domainName):
    return domain(request, domainName, low = handler.lastVersion());
コード例 #8
0
ファイル: ajax.py プロジェクト: LubyRuffy/WhoDat
def domains_latest(request, key, value):
    return domains(request, key, value, low = handler.lastVersion())
コード例 #9
0
ファイル: ajax.py プロジェクト: mpars0ns/WhoDat
def domain_latest(request, domainName):
    return domain(request, domainName, low = handler.lastVersion());
コード例 #10
0
ファイル: ajax.py プロジェクト: mpars0ns/WhoDat
def domains_latest(request, key, value):
    return domains(request, key, value, low = handler.lastVersion())
コード例 #11
0
ファイル: views.py プロジェクト: LubyRuffy/WhoDat
def domains(request, key=None, value=None):
    if request.method == "POST":
        search_f = domain_form(request.POST)

    elif request.method == "GET":
        search_f = domain_form(QueryDict(''))
        search_f.data['key'] = key
        search_f.data['value'] = value
        search_f.data['fmt'] = request.GET.get('fmt','normal')
        search_f.data['limit'] = request.GET.get('limit', settings.LIMIT)
        search_f.data['filt'] = request.GET.get('filt', settings.SEARCH_KEYS[0][0])
        search_f.data['latest'] = request.GET.get('latest', False)

    else:
        return __renderErrorPage__(request, 'Bad Method.')

    if not search_f.is_valid():
        return __renderErrorResponse__(request, 'domain.html', '', {'domain_form' : search_f})

    key = urllib.unquote(search_f.cleaned_data['key'])
    value = urllib.unquote(search_f.cleaned_data['value'])

    filt_key = search_f.cleaned_data['filt']
    fmt = search_f.cleaned_data['fmt']
    limit = int(search_f.cleaned_data.get('limit', settings.LIMIT))
    latest = search_f.cleaned_data['latest']

    if latest:
        low_version = handler.lastVersion()
        high_version = low_version
    else:
        low_version = None
        high_version = None
    
    filt = None
    if fmt == 'list': #Only filter if a list was requested
        filt = filt_key

    #All web searches are AJAXy
    if fmt == "normal":
        low_version_js = low_version
        high_version_js = high_version
        if low_version == None:
            low_version_js = 'null'
        if high_version == None:
            high_version_js = 'null'
        context = __createRequestContext__(request, data = { 'key': urllib.quote(key),
                                                             'value': urllib.quote(value),
                                                             'low_version': low_version_js,
                                                             'high_version': high_version_js,
                                                             'domain_form': search_f,
                                                             'legacy_search': True,
               })
        return render_to_response('domain_results.html', context)

    else:
        results = handler.search(key, value, filt=filt, limit=limit, low = low_version)
        if results['success'] == False:
            return __renderErrorPage__(request, results['message'])
        if fmt == 'json':
            return HttpResponse(json.dumps(results), content_type='application/json')
        elif fmt == 'list':
            data = '\n'.join([d[filt_key] for d in results['data']])
            return HttpResponse(data, content_type='text/plain')
        else:
            return __renderErrorPage__(request, 'Invalid Format.')