# Copyright for the Uniform Repository Service (c) 1995 - 2003, # by Gerald Banon. All rights reserved. # Version 2.1 # mirrorsearch.tcl # example: # http://banon-pc2/col/dpi.inpe.br/banon/1999/06.19.17.00/doc/mirrorsearch.cgi?languagebutton=pt-BR&returnbutton=yes&query=ti+clipping*&choice=briefTitleAuthor&linktype=2&cssfileurl=http://banon-pc2/col/dpi.inpe.br/banon/1999/06.19.22.43/doc/mirrorStandard.css # ---------------------------------------------------------------------- # MirrorSearch proc MirrorSearch {} { if [catch { global currentProcedureName ;# used in LoopOverEntries set currentProcedureName MirrorSearch global env global cgi global currentRep # global maximumNumberOfReferences global language # global col global administratorUserName ;# used in CreateReturnButton global homePath ;# used in CreateOutput and FindLanguage # global returnButton ;# used in LoopOverEntries # global targetFrame ;# used in LoopOverEntries array set environment [array get env] ;# used in MultipleSubmit # > set col ../../../../.. set URLibServiceRepository dpi.inpe.br/banon/1998/08.02.08.56 source ../$col/$URLibServiceRepository/doc/utilities1.tcl source ../$col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl # homePath (used in CreateReturnButton and FindLanguage) set homePath $env(DOCUMENT_ROOT) set pathInfo [file split $env(PATH_INFO)] # currentRep regsub -all { } [lrange $pathInfo 1 4] {/} currentRep # set serverAddress [list $env(SERVER_NAME) $env(URLIB_PORT)] # serverAddressWithIP set serverAddressWithIP [list $env(IP_ADDR) $env(URLIB_PORT)] ## localSite # set localSite $env(SERVER_NAME):$env(SERVER_PORT) ;# $env(HTTP_HOST) not used because can be shorter like sputnik:1909 # administratorUserName regsub {@.*$} $env(SERVER_ADMIN) {} administratorUserName # Find the language and the language repository foreach {language languageRep1 languageRep2 firstLanguageRep \ submissionFormRep submissionFormLanguage submissionFormLanguageRep} \ [FindLanguage $currentRep] {break} # Find the language and the language repository - end # used with GET # doesn't hidden password1 and codedpassword1 if [info exists env(QUERY_STRING)] { foreach {name value} [split $env(QUERY_STRING) &=] { set cgi([DecodeURL $name]) [DecodeURL $value] } } CreateCGIArray ;# used with POST if ![info exists cgi(query)] {set cgi(query) {}} if ![info exists cgi(accent)] {set cgi(accent) no} ;# values are: yes no if [info exists cgi(case2)] {set cgi(case) $cgi(case2)} if ![info exists cgi(case)] {set cgi(case) no} ;# values are: yes no if ![info exists cgi(choice)] {set cgi(choice) brief} ;# values are: short brief briefTitleAuthor briefTitleAuthorMisc full fullbibtex fullrefer fullBibINPE fullXML if ![info exists cgi(returnbutton)] {set cgi(returnbutton) no} ;# values are: yes no # if ![info exists cgi(targetframe)] {set cgi(targetframe) {}} ;# needed when calling CreateReturnButton in topForContinue if ![info exists cgi(sort)] {set cgi(sort) {}} ;# values are: key dateplus dateminus if ![info exists cgi(outputformat)] {set cgi(outputformat) 1} ;# used with the option briefTitleAuthorMisc - ex: outputformat=e-mailaddress+abstract if ![info exists cgi(subsetofgroups)] {set cgi(subsetofgroups) {}} if ![info exists cgi(languagebutton)] {set cgi(languagebutton) $language} ;# values are: en pt-BR if ![info exists cgi(username)] {set cgi(username) {}} if ![info exists cgi(session)] {set cgi(session) {}} # linkType used by CreateBriefTitleAuthorEntry (see CreateBriefTitleAuthorEntry) ConditionalSet linkType cgi(linktype) 0 ;# values are: 0 1 2 3 4 5 6 7 (see CreateBriefTitleAuthorEntry) ConditionalSet cssFileURL cgi(cssfileurl) {} set returnButton $cgi(returnbutton) ;# used in LoopOverEntries # set targetFrame $cgi(targetframe) ;# used in LoopOverEntries ProcessQuery ;# compute cgi(query) # Update @searchExpressionLog # Waiting for the completion of other search while {[EnterQueue [pid] search]} { set x 0; after 100 {set x 1}; vwait x } # Waiting for the completion of other search - end Store cgi(query) $homePath/@searchExpressionLog auto 0 a LeaveQueue [pid] search # Update @searchExpressionLog - end if [regexp {fullXML} $cgi(choice)] { set header 0 puts {Content-Type: text/xml} } else { set header 1 puts {Content-Type: text/html} } puts {} # puts $env(QUERY_STRING) # return # puts [array get cgi] # puts $env(REQUEST_URI) # puts $cgi(case) # exit if {[string compare {full} $cgi(choice)] == 0} { source ../$col/$languageRep2/doc/mirror/${language}FieldName.tcl ;# for full format } # set query {list GetEntries $cgi(query) $cgi(case) $cgi(choice)} # set query {list ${searchRepository}::MountSearch $cgi(query) $cgi(case)} # set query {list SearchMetadataRepositories $cgi(query) $cgi(case)} # set query2 $cgi(query) if {$cgi(choice) == "site"} { set stampName lastupdate } else { set stampName metadatalastupdate } # Similar to Submit set passwordError 0 ;# no password error if [info exists cgi(codedpassword1)] { set password1 $cgi(codedpassword1) } elseif [info exists cgi(password1)] { set password1 $cgi(password1) } elseif [info exists cgi(pid)] { # used to search hidden references (see xxUpdateSubmission.html, mirror.tcl and submit.tcl) set pid $cgi(pid) Load ../tmpForAdministratorPassword-$pid password1 binary file delete ../tmpForAdministratorPassword-$pid } else { set password1 {} } if {[info exists cgi(username)] && [string compare {} $cgi(username)] != 0} { # not a query from the simple form # puts [list CheckPassword administrator $password1] set flag [Execute $serverAddressWithIP [list CheckPassword $cgi(username) $password1]] if {$flag && [string compare {} $password1] != 0} { # unknown username or wrong password set passwordError 1 } } # Similar to Submit - end # puts --$password1-- # set query "list GetMetadataRepositories \$currentRep 3 \$cgi(query) \$cgi(accent) \$cgi(case) 1 $stampName repArray $password1" # set query "list GetMetadataRepositories \$currentRep 3 \$cgi(query) \$cgi(accent) \$cgi(case) 0 $stampName repArray $password1" # set query "list GetMetadataRepositories \$currentRep 3 \$cgi(query) \$cgi(accent) \$cgi(case) 0 $stampName repArray $password1 \$cgi(sort) 0" # set query "list GetMetadataRepositories \$currentRep 3 \$cgi(query) \$cgi(accent) \$cgi(case) 0 $stampName repArray $password1 \$cgi(sort) 0 $cgi(subsetofgroups)" set query [list list GetMetadataRepositories $currentRep 3 $cgi(query) $cgi(accent) $cgi(case) 0 $stampName repArray $password1 $cgi(sort) 0 $cgi(subsetofgroups)] # values defined in query2String are used in mirrorget.tcl set query2String {query2=$cgi(query)&choice2=$cgi(choice)&accent2=$cgi(accent)&case2=$cgi(case)} # create output with a maximum of 10 references set maximumNumberOfReferences 10 ## query log (iris example) # set xxx [list [pid] $cgi(query) [clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S]] # Store xxx /dados/URLib/tmp/aaa auto 0 a if [catch {CreateOutput $language $languageRep1 $languageRep2 $query $query2String Search {} \ 0 $maximumNumberOfReferences $cgi(choice) $header \ {^$} 0 {} $cgi(outputformat) \ {#EEEEEE #E3E3E3} {} no \ yes $linkType $passwordError \ _blank metadatalastupdate \ site $returnButton $cssFileURL} output2] { global errorInfo; puts $errorInfo # puts $output2 # set xxx $output2 # Store xxx /dados/URLib/tmp/aaa auto 0 a } if [regexp {fullXML} $cgi(choice)] { puts {} puts puts [join $output2 \n] puts } return # < } m] {puts $m; if 0 {global errorInfo; puts $errorInfo}} } # MirrorSearch - end # ----------------------------------------------------------------------