# Copyright for the Uniform Repository Service (c) 1995 - 2025,
# by Gerald Banon. All rights reserved.
# Version 2.1
# customizeerror.tcl

# example of use:
# http://gjfb:1905/customizeerror.cgi/404

# ----------------------------------------------------------------------
# CustomizeError

proc CustomizeError {} {
if [catch {
	global env
	global homePath	;# used in FindLanguage
	global URLibServiceRepository

	set col ../../../../..
	set URLibServiceRepository $env(URLIB_SERVICE_REP)
	
	source ../$col/$URLibServiceRepository/doc/utilities1.tcl
	source ../$col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl

# homePath (used in FindLanguage)
	set homePath $env(DOCUMENT_ROOT)
	
# pathInfo	
	set pathInfo [file split $env(PATH_INFO)]
	
# errorNumber
	set errorNumber [lindex $pathInfo end]

# language
	foreach {language languageRep1} [FindLanguage $env(LOBIMIREP)] {break}

# localSite
	set localSite $env(SERVER_NAME):$env(SERVER_PORT)

	puts {Content-Type: text/html}
	puts {}

	switch $language {
		en {
			puts "
				<HTML>
					<HEAD>
						<TITLE>Warning</TITLE>
						<link rel='stylesheet' type='text/css' href='http://$localSite/col/$languageRep1/doc/mirrorStandard.css'>
					</HEAD>
					<BODY class='errorBody'>
						<br>
						<P ALIGN=CENTER>
							<I>Warning</I>
						</P>
			"
			switch $errorNumber {
				401 {
					puts "
								<P>
									401 - Authorization required.
								</P>
					"
				}
				403 {
					puts "
								<P>
									403 - Forbidden access to the file.
								</P>
					"
				}
				404 {
					puts "
								<P>
									404 - Requested file not found.
								</P>
					"
				}
				409 {
if 0 {
# commented by GJFB in 2025-06-10 - fullypersistenthref not used anymore
					puts "
								<P>
									<!-- 409 - Reserved address - the target file path cannot contain the names 'ibi', 'ibi-', 'rep', 'rep-', 'goto', 'goto-' or 'doi'. -->
									409 - Reserved address - the target file path cannot contain the names 'ibi', 'ibi-', 'goto', 'goto-' or 'fullypersistenthref'.
								</P>
					"
} elseif 0 {
# added by GJFB in 2025-06-10
# commented by GJFB in 2025-09-13
					puts "
								<P>
									<!-- 409 - Reserved address - the target file path cannot contain the names 'ibi', 'ibi-', 'rep', 'rep-', 'goto', 'goto-' or 'doi'. -->
									409 - Reserved address - the target file path cannot begin with the names 'ibi', 'ibi-', 'goto' or 'goto-'.
								</P>
					"
} else {
# added by GJFB in 2025-09-13
					puts "
								<P>
									<!-- 409 - Reserved address - the target file path cannot begin with the names 'ibi', 'ibi-', 'goto' or 'goto-'. -->
									409 - Reserved address - the target file path cannot begin with the names 'goto' or 'goto-'.
								</P>
					"
}
				}
				414 {
					puts "
								<P>
									414 - Requested URI too long.
								</P>
					"
				}
				500 {
					puts "
								<P>
									500 - The server encountered an unexpected condition which prevented it from fulfilling the request.
								</P>
					"
				}
				504 {
					puts "
								<P>
									504 - Socket access time-out or not all are responding.
								</P>
					"
				}
				602 {
					puts "
								<P>
									602 - The name 'ibi' as a URN namespace identifier is not registered with the IANA.
								</P>
					"
				}
				603 {
					puts "
								<P>
									603 - The namespace prefix is not registered with the IANA.
								</P>
					"
				}
				604 {
					puts "
								<P>
									604 - The UPN namespace prefix is not registered.
								</P>
								<p>
									To register a UPN namespace prefix, send an e-mail to: <tt><A HREF=\"mailto:urlibservice@gmail.com\">urlibservice@gmail.com</A></tt>.
								</p>
					"
				}
			}
			puts "
						<TABLE ALIGN=CENTER><TR><TD WIDTH=100><BR><HR></TD></TR></TABLE>
					</BODY>
				</HTML>
			"
		}
		pt-BR {
			puts "
				<HTML>
					<HEAD>
						<TITLE>Aviso</TITLE>
						<link rel='stylesheet' type='text/css' href='http://$localSite/col/$languageRep1/doc/mirrorStandard.css'>
					</HEAD>
					<BODY class='errorBody'>
						<br>
						<P ALIGN=CENTER>
							<I>Aviso</I>
						</P>
			"
			switch $errorNumber {
				401 {
					puts "
								<P>
									401 - Autorização requerida.
								</P>
					"
				}
				403 {
					puts "
								<P>
									403 - Acesso proibido ao arquivo.
								</P>
					"
				}
				404 {
					puts "
								<P>
									404 - Arquivo requerido não encontrado.
								</P>
					"
				}
				409 {
if 0 {
# commented by GJFB in 2025-06-10 - fullypersistenthref not used anymore
					puts "
								<P>
									<!-- 409 - Endereçamento reservado - o caminho do arquivo alvo não pode conter os nomes 'ibi', 'ibi-', 'rep', 'rep-', 'goto', 'goto-' ou 'doi'. -->
									409 - Endereçamento reservado - o caminho do arquivo alvo não pode conter os nomes 'ibi', 'ibi-', 'goto', 'goto-' ou 'fullypersistenthref'.
								</P>
					"
} elseif 0 {
# added by GJFB in 2025-06-10
# commented by GJFB in 2025-09-13
					puts "
								<P>
									<!-- 409 - Reserved address - the target file path cannot contain the names 'ibi', 'ibi-', 'rep', 'rep-', 'goto', 'goto-' or 'doi'. -->
									409 - Endereçamento reservado - o caminho do arquivo alvo não pode começar com os nomes 'ibi', 'ibi-', 'goto' ou 'goto-'.
								</P>
					"
} else {
# added by GJFB in 2025-09-13
					puts "
								<P>
									<!-- 409 - Endereçamento reservado - o caminho do arquivo alvo não pode começar com os nomes 'ibi', 'ibi-', 'goto' ou 'goto-'. -->
									409 - Endereçamento reservado - o caminho do arquivo alvo não pode começar com os nomes 'goto' ou 'goto-'.
								</P>
					"
}
				}
				414 {
					puts "
								<P>
									414 - URI requerida longa demais.
								</P>
					"
				}
				500 {
					puts "
								<P>
									500 - O servidor encontrou uma condição inesperada que o impediu de atender à solicitação.
								</P>
					"
				}
				504 {
					puts "
								<P>
									504 - Tempo esgotado no acesso via soquete ou nem todos estão respondendo.
								</P>
					"
				}
				602 {
					puts "
								<P>
									602 - O nome 'ibi' como identificador de espaço de nomes URN não está cadastrado junto à IANA.
								</P>
					"
				}
				603 {
					puts "
								<P>
									603 - O prefixo do espaço de nome não está cadastrado junto à IANA.
								</P>
					"
				}
				604 {
					puts "
								<P>
									604 - O prefixo do espaço de nome UPN não está cadastrado.
								</P>
								<p>
									Para cadastrar um novo espaço de nome UPN, envie um e-mail para: <tt><A HREF=\"mailto:urlibservice@gmail.com\">urlibservice@gmail.com</A></tt>.
								</p>
					"
				}
			}
			puts "
						<TABLE ALIGN=CENTER><TR><TD WIDTH=100><BR><HR></TD></TR></TABLE>
					</BODY>
				</HTML>
			"

		}
	}
	
} m] {puts <PRE>$m</PRE>; if 0 {global errorInfo; puts <PRE>$errorInfo</PRE>}}
}

# CustomizeError - end
# ----------------------------------------------------------------------
