2000-02-26 10:24:46 +00:00
|
|
|
#!/usr/bin/env python
|
2000-11-11 00:38:04 +00:00
|
|
|
# Copyright (C) 2000 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
|
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
|
# (at your option) any later version.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
2000-02-26 10:24:46 +00:00
|
|
|
|
|
|
|
|
import re,cgi,sys,urlparse,time,os
|
|
|
|
|
sys.stderr = sys.stdout
|
2000-04-24 22:07:48 +00:00
|
|
|
|
|
|
|
|
# begin user configuration
|
2000-06-10 18:06:43 +00:00
|
|
|
dist_dir = "/home/calvin/projects/linkchecker"
|
2000-03-26 18:53:23 +00:00
|
|
|
cgi.logfile = "linkchecker.log" # must be an existing file
|
2000-04-24 22:07:48 +00:00
|
|
|
# end user configuration
|
|
|
|
|
|
|
|
|
|
sys.path.insert(0,dist_dir)
|
2000-02-26 10:24:46 +00:00
|
|
|
|
|
|
|
|
def testit():
|
|
|
|
|
cgi.test()
|
|
|
|
|
sys.exit(0)
|
|
|
|
|
|
|
|
|
|
# main
|
|
|
|
|
print "Content-type: text/html"
|
2000-03-08 12:01:51 +00:00
|
|
|
print "Cache-Control: no-cache"
|
2000-02-26 10:24:46 +00:00
|
|
|
print
|
2000-04-24 22:07:48 +00:00
|
|
|
# uncomment the following line to test your CGI values
|
2000-02-26 10:24:46 +00:00
|
|
|
#testit()
|
|
|
|
|
form = cgi.FieldStorage()
|
2000-07-10 21:55:30 +00:00
|
|
|
if form['language'].value == 'de':
|
|
|
|
|
os.environ['LC_MESSAGES'] = 'de'
|
|
|
|
|
elif form['language'].value == 'fr':
|
|
|
|
|
os.environ['LC_MESSAGES'] = 'fr'
|
|
|
|
|
else:
|
|
|
|
|
os.environ['LC_MESSAGES'] = 'C'
|
|
|
|
|
import linkcheck
|
2000-03-26 18:53:23 +00:00
|
|
|
if not linkcheck.lc_cgi.checkform(form):
|
2000-03-27 13:34:31 +00:00
|
|
|
linkcheck.lc_cgi.logit(form, form)
|
2000-03-26 18:53:23 +00:00
|
|
|
linkcheck.lc_cgi.printError(sys.stdout)
|
2000-02-26 10:24:46 +00:00
|
|
|
sys.exit(0)
|
2000-03-08 12:01:51 +00:00
|
|
|
config = linkcheck.Config.Configuration()
|
|
|
|
|
config["recursionlevel"] = int(form["level"].value)
|
2000-07-10 21:55:30 +00:00
|
|
|
config['log'] = config.newLogger('html')
|
|
|
|
|
if form.has_key('strict'): config['strict'] = 1
|
|
|
|
|
if form.has_key("anchors"): config["anchors"] = 1
|
2000-03-08 12:01:51 +00:00
|
|
|
if not form.has_key("errors"): config["verbose"] = 1
|
2000-02-26 10:24:46 +00:00
|
|
|
if form.has_key("intern"):
|
2000-03-26 18:53:23 +00:00
|
|
|
config["internlinks"].append(re.compile("^(ftp|https?)://"+\
|
|
|
|
|
linkcheck.lc_cgi.getHostName(form)))
|
2000-02-26 10:24:46 +00:00
|
|
|
else:
|
2000-03-08 12:01:51 +00:00
|
|
|
config["internlinks"].append(re.compile(".+"))
|
2000-04-24 22:07:48 +00:00
|
|
|
# avoid checking of local files (security!)
|
2000-03-08 12:01:51 +00:00
|
|
|
config["externlinks"].append((re.compile("^file:"), 1))
|
2000-02-26 10:24:46 +00:00
|
|
|
|
2000-03-08 12:01:51 +00:00
|
|
|
# start checking
|
|
|
|
|
config.appendUrl(linkcheck.UrlData.GetUrlDataFrom(form["url"].value, 0))
|
|
|
|
|
linkcheck.checkUrls(config)
|