home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 35 Internet
/
35-Internet.zip
/
srev13g.zip
/
mtchfile.rx0
< prev
next >
Wrap
Text File
|
1999-03-01
|
3KB
|
131 lines
/* the "find best matching files" INTERPRETable sre-http addon
nshow: number of matches to list (default = 5)
prefix: prefix (default= <li> )
noscore: If 1, then do not display "match score"
altname: if not '', then use this (instead of the actual request selector)
The DIR_EXCLUSION parameter is read, directories and filenames (files may
be wildcarded) that appear in dir_exclusion will NOT be displayed
*/
parse arg nshow prefix noscore altname
if prefix='' then prefix='<li>'
if nshow='' then nshow=5
basis=''
if altname='' then
dname=strip(docname,,'/')
else
dname=strip(altname,,'/')
ii=lastpos('/',dname)
checkname=substr(dname,ii+1)
if ii=0 then do
seldir='/'
basis=ddir
end
else do
seldir=left(dname,ii)
end
direx=translate(get_value('dir_exclusion'))
do until basis<>''
basis2=sref_do_virtual(ddir,seldir||checkname,enmadd,0,,,host_nickhame)
gg=filespec('d',basis2)||filespec('p',basis2)
gg=strip(gg,,'\') ; if right(gg,1)=':' then gg=gg'\'
ipoo=lastpos('\',gg)
naa=''
if ipoo>0 then do
naa=substr(gg,ipoo)
end
if wordpos(naa,direx)=0 then do
if dosisdir(gg)=1 then do
basis=gg
leave
end
end
oy=lastpos('/',seldir,length(seldir)-1)
if oy=0 then do
seldir='/'
basis=ddir
leave
end
seldir=left(seldir,oy)
end
basis=strip(translate(basis,'\','/'),,'\')'\'
seldir='/'||strip(seldir,'l','/')
if basis<>'' then do
aa=sysfiletree(basis'*.*','goos','fo')
parse upper var checkname aname '.' aext
nwild=0
do ii=1 to words(direx)
aw=strip(word(direx,ii))
if left(aw,1)='\' then iterate
if pos('*',aw)=0 then iterate
nwild=nwild+1
wlist.nwild=aw
end
maxscore=-1
do mm=1 to goos.0
score1=0 ; score2=0
tname=filespec('n',goos.mm)
if wordpos(translate(tname),direx)>0 then do
goos.mm.!score=-2
end
IF GOOS.MM.!SCORE<>-2 THEN DO
do ii=1 to nwild
if sref_wild_match(TRANSLATE(tname),wlist.ii,'')<>0 then do
goos.mm.!score=-2
leave
end
end
END
if goos.mm.!SCORE<>-2 then do
parse upper var tname bname '.' bext
sc1=sref_compword(aname,bname)
sc2=sref_compword(aext,bext)
score1=((3*sc1)+sc2)/4
sc1=sref_compword(bname,aname)
sc2=sref_compword(bext,aext)
score2=((3*sc1)+sc2)/4
score=(score1+score2)/2
goos.mm.!score=trunc(score*100)
end
end
/* find top nshow */
do mm=1 to min(goos.0,nshow)
amax=-1
do nn=1 to goos.0
if goos.nn.!score>amax then do
amax=goos.nn.!score ; iat=nn
end
end
if amax<0 then do
nshow=mm-1
leave
end
bests.mm=goos.iat' 'goos.iat.!score
goos.iat.!score=-1
end
do mm=1 to min(goos.0,nshow)
parse var bests.mm a1a score
a1=filespec('n',a1a)
mkk=prefix'<a href="'seldir||a1'">'a1'</a>'
if noscore<>1 then mkk=mkk' <em>('score')</em>'
queue mkk
end
end