home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2001 October
/
Chip_2001-10_cd1.bin
/
sharewar
/
gdidbpro
/
data1.cab
/
Example_Files
/
projects
/
default
/
linkcheck.scp
< prev
next >
Wrap
Text File
|
2000-05-26
|
2KB
|
85 lines
##########################################################
# GDIdb demo script (c) 1998 Global Data Industries
#
# This script is designed to check web URL's held in a
# database. GDIdb will attempt to retrieve the status of
# each URL, if the server responds with a code of 404
# (404=http 'Object not found' code) then GDIdb will
# delete the database record that contains the URL.
##########################################################
##########################################################
# this database contains our table of links
&datasource("Driver={Microsoft Access Driver (*.mdb)};DBQ=examples.mdb")
##########################################################
# define variables used in script
&defvar(?content?,?header?,?error?,?errorcode?)
##########################################################
# if you don't want GDIdb to dial your Internet connection
# before checking the URL's, change the following line
# to &dialup(FALSE)
&dialup(TRUE)
{
&getdata("SELECT * FROM tblURLs")
{
# get HTTP header from web server
&assign(?error?,0)
&http(?header?,?content?,"?URL?","HEAD")
# If server didn't respond
&if(?error?)
{
# if you don't want links removed where the server didn't respond
# (the server could be temporarily down), remove the following line
&removelink
&continue
}
# if server responds with code 404 (object not found), delete link
&split(?c?,"?header?")
&if(?c[2]?==404)
{
&removelink
}
&arraydelete(?c?)
}
}
##########################################################
# GDIdb will run this subroutine when a bad URL is found.
&defsub("removelink")
{
&print("Deleting ?URL?")
&sqlnr("DELETE FROM tblURLs WHERE URL='?URL?'")
}
##########################################################
# catch HTTP errors
&defsub("on_error")
{
&geterror(?errorcode?,FALSE)
&if((?errorcode?==119)||(?errorcode?==106))
{
&assign(?error?,1)
&ignore
}
}