# Copyright for the Uniform Repository Service (c) 1995 - 2021, 2025
# by Gerald Banon. All rights reserved.
# Version 2.1
# created in 2021-04-30 by GJFB to resolve IBI and DOI
# example:
# http://gjfb:1905/resolve2?ibienter=LK47B6W/E6H5HH&ibi=&languagebutton=pt-BR
# http://www.urlib.net/resolve2?ibienter=LK47B6W/E6H5HH&ibi=&languagebutton=pt-BR
# ----------------------------------------------------------------------
# Resolve2
proc Resolve2 {} {
if [catch {
global currentProcedureName ;# used in LoopOverEntries
global currentProcedureFileName ;# used in CreateOutput and LoopOverEntries
global env
global cgi
global currentRep
global language
global homePath ;# used in CreateOutput and FindLanguage
global URLibServiceRepository ;# used in MultipleSubmit (called in MultipleExecute2 called in CreateOutput)
global queueLengthFlag ;# used in MultipleSubmit (called in MultipleExecute2 called in CreateOutput)
global mirrorHomePageRepository ;# used in LoopOverEntries to access submission.js
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 ;# ReturnHTTPHost
set homePath $env(DOCUMENT_ROOT)
set currentProcedureName MirrorResolve
set currentProcedureFileName $homePath/col/$URLibServiceRepository/doc/cgi/MirrorResolve.tcl
# localSite
# set localSite $env(SERVER_NAME):$env(SERVER_PORT)
set localSite [ReturnHTTPHost]
# used with GET
# doesn't hidden password1 and codedpassword1
if [info exists env(QUERY_STRING)] {
set queryString $env(QUERY_STRING)
foreach {name value} [split $queryString &=] {
set cgi([DecodeURL $name]) [DecodeURL $value]
}
}
CreateCGIArray ;# used with POST
if 0 {
puts {Content-Type: text/html}
puts {}
puts $env(QUERY_STRING)
puts
puts
puts [array get cgi]
}
if [string equal {} $cgi(ibienter)] {set ibi $cgi(ibi)}
if [string equal {} $cgi(ibi)] {set ibi $cgi(ibienter)}
if ![info exists ibi] {set ibi $cgi(ibienter)}
if [regexp -nocase {.+:.+} $ibi] {
# ark:13030/c7cv4br18
puts "Location: http://$localSite/$ibi?ibiurl.backgroundlanguage=$cgi(languagebutton)"
} else {
set splitID [file split $ibi]
if {[llength $splitID] == 2} {
# ibi or doi
# LK47B6W/E6H5HH
# 10.1087/20110107
if [regexp {^10\.} $ibi] { ;# added by GJFB in 2025-09-07 to detect DOI
# doi
# 10.1087/20110107
puts "Location: http://doi.org/$ibi"
} else {
# ibi
# LK47B6W/E6H5HH
puts "Location: http://$localSite/ibi/$ibi?ibiurl.backgroundlanguage=$cgi(languagebutton)"
}
} elseif {[llength $splitID] == 4} {
# ibi
# iconet.com.br/banon/2001/02.10.22.55
puts "Location: http://$localSite/ibi/$ibi?ibiurl.backgroundlanguage=$cgi(languagebutton)"
} else {
# Syntax Error
puts {Content-Type: text/html}
puts {
Syntax Error
} puts "<$ibi> has not the right syntax.
" puts {To resolve an IBI the syntax is <prefix/sufix> or <ibi:prefix/sufix>.
To resolve a DOI the syntax is <prefix/sufix> or <doi:prefix/sufix> or <urn:doi:prefix/sufix>.
Resolve: $m" if 0 {global errorInfo; puts
$errorInfo} } } } # Resolve2 - end # ----------------------------------------------------------------------