mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-05-03 04:14:43 +00:00
cgi access checking
git-svn-id: https://linkchecker.svn.sourceforge.net/svnroot/linkchecker/trunk/linkchecker@786 e7d03fd6-7b0d-0410-9947-9c21f3af8025
This commit is contained in:
parent
b570df925b
commit
cb5c9ec700
4 changed files with 25 additions and 4 deletions
7
lc.cgi
7
lc.cgi
|
|
@ -19,9 +19,12 @@ import re, cgi, sys, urlparse, time, os
|
|||
# log errors to stdout
|
||||
sys.stderr = sys.stdout
|
||||
|
||||
# access
|
||||
ALLOWED_HOSTS = ['127.0.0.1']
|
||||
ALLOWED_SERVERS = ['127.0.0.1']
|
||||
# uncomment the following lines to test your CGI values
|
||||
#cgi.test()
|
||||
#sys.exit(0)
|
||||
import linkcheck.lc_cgi
|
||||
form = cgi.FieldStorage()
|
||||
linkcheck.lc_cgi.checklink(form=form, env=form)
|
||||
linkcheck.lc_cgi.checkaccess(hosts=ALLOWED_HOSTS, servers=ALLOWED_SERVERS)
|
||||
linkcheck.lc_cgi.checklink(form=cgi.FieldStorage())
|
||||
|
|
|
|||
7
lc.fcgi
7
lc.fcgi
|
|
@ -1,5 +1,5 @@
|
|||
#!/usr/bin/python
|
||||
# Copyright (C) 2000-2002 Bastian Kleineidam
|
||||
# Copyright (C) 2000-2003 Bastian Kleineidam
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
|
@ -18,10 +18,15 @@
|
|||
import sys, re, os, fcgi
|
||||
import linkcheck.lc_cgi
|
||||
|
||||
# access
|
||||
ALLOWED_HOSTS = ['127.0.0.1']
|
||||
ALLOWED_SERVERS = ['127.0.0.1']
|
||||
# main
|
||||
try:
|
||||
while fcgi.isFCGI():
|
||||
req = fcgi.FCGI()
|
||||
linkcheck.lc_cgi.checkaccess(out=req.out, hosts=ALLOWED_HOSTS,
|
||||
servers=ALLOWED_SERVERS, env=req.env)
|
||||
linkcheck.lc_cgi.checklink(out=req.out, form=req.getFieldStorage(),
|
||||
env=req.env)
|
||||
req.Finish()
|
||||
|
|
|
|||
|
|
@ -18,7 +18,13 @@
|
|||
import sys, re, thread, sz_fcgi
|
||||
import linkcheck.lc_cgi
|
||||
|
||||
# access
|
||||
ALLOWED_HOSTS = ['127.0.0.1']
|
||||
ALLOWED_SERVERS = ['127.0.0.1']
|
||||
def func (fcg, req):
|
||||
linkcheck.lc_cgi.checkaccess(out=req.out, hosts=ALLOWED_HOSTS,
|
||||
servers=ALLOWED_SERVERS,
|
||||
env=req.env)
|
||||
linkcheck.lc_cgi.checklink(out=req.out, form=req.getFieldStorage(),
|
||||
env=req.env)
|
||||
req.Finish()
|
||||
|
|
|
|||
|
|
@ -32,7 +32,14 @@ class FormError (Exception):
|
|||
pass
|
||||
|
||||
|
||||
def checklink (out=sys.stdout, form={}, env={}):
|
||||
def checkaccess (out=sys.stdout, hosts=[], servers=[], env=os.environ):
|
||||
if os.environ.get('REMOTE_ADDR') not in hosts or \
|
||||
os.environ.get('SERVER_ADDR') not in servers:
|
||||
logit({}, env)
|
||||
printError(out, "Access denied")
|
||||
|
||||
|
||||
def checklink (out=sys.stdout, form={}, env=os.environ):
|
||||
"""main cgi function, check the given links and print out the result"""
|
||||
out.write("Content-type: text/html\r\n"
|
||||
"Cache-Control: no-cache\r\n"
|
||||
|
|
|
|||
Loading…
Reference in a new issue