# submit.tcl # Copyright for the URLibService (c) 1995 - 2018, # by Gerald Banon. All rights reserved. # Version 2.1 # part of URLibService # used to submit a new document or update an already submitted one # ---------------------------------------------------------------------- # Submit # cgi inputs used by Submit # updatetype ## values are: update, {remove before update} (default), add, {add and copy}, run, finish # values are: update, {remove before update}, {update source directory}, {remove before update source directory}, {update agreement directory}, {remove before update agreement directory}, add, {add and copy}, run, and finish, default is given by updateOptionTable in displayControl.tcl # bodylink # defined in Get proc Submit {} { if [catch { set codeTesting 0 set currentProcedureName Submit ;# used in displayControl.tcl among other uses # global searchResultList global env global cgi ;# used in TryFillingOut and SendPermissionTransferWarningEMail global col global mirrorHomePageRep ;# defined in FindLanguage (utilities1.tcl) global homePath ;# used in SynchronizeRepository, TraceProcedure, CreatePDFFile, LoadService, StoreService, StorePassword, SortRandomNumber, FindLanguage, RunRemoteCGIScript, CheckMetadataSimilarity, KeepOldVersionOfTeXTargetFile and SendPermissionTransferWarningEMail global htpasswdPath ;# used in StorePassword global loCoInRep ;# used in SynchronizeRepository, StorePassword, CheckMetadataSimilarity and SendPermissionTransferWarningEMail global loBiMiRep ;# used while executing SynchronizeRepository global currentRep ;# used by CreateMirror, CheckMetadataSimilarity and by DisplaySearch and DisplayNumberOfEntries called within subst (see TCL Page), and by SendPermissionTransferWarningEMail global language languageRep1 languageRep2 firstLanguageRep ;# used by DisplaySearch, by DisplayNumberOfEntries called within subst (see TCL Page), by FindNextUser and SendPermissionTransferWarningEMail global bgColor ;# used when updating the Local Collection Index (see localIndex.html) global localSite ;# used by FindNextUser, SendPermissionTransferWarningEMail and others global ps2pdfConverterPathList ;# defined in displayControl.tcl and used by CreatePDFFile global headerTable ;# defined in displayControl.tcl and used by CreatePDFFile global referenceType ;# used by CreatePDFFile and by FindNextUser global orderingTable ;# used to sort review fields global URLibServiceRepository; # used by SynchronizeRepository, TraceProcedure, SortRandomNumber and by CreateTclPageFile global citationKey ;# set in CheckMetadataSimilarity and used within subst (see: a repository already exists) global multipleLineReferFieldNamePattern global multipleLineReferFieldNamePatternForCreator global http ;# used by FindNextUser global submissionFormRep global submissionFormLanguageRep submissionFormLanguage ;# used by SendPermissionTransferWarningEMail global cssFileURL ;# used in CreateTclPage global creatorFieldArray ;# used in TryFillingOut global thisRepository ;# used in CreateTclPageFile, DisplaySearch and DisplayMultipleSearch global optionTable2 ;# used in ComputeFieldValueList (when making table of contents) global errorInfo global tcl_platform # global targetFileType ;# used in CreateTclPageFile and DisplaySearch global timePeriod ;# set by TestForTclPageUpdate, used in CreateTclPageFile global accentTable2 ;# used in ReturnAttributeValue global serverAddress ;# used in CreateTclPage, SetFieldValue and SendPermissionTransferWarningEMail global serverAddressWithIP ;# used in SynchronizeRepository, FindNextUser, DisplaySearch, CreateTclPage and CreateTclPageFile global numberOfReviewersPerWorkTable ;# set by sourceDisplayControl, used in CreateTclPage global conferenceAcronym ;# set by sourceDisplayControl, used in CreateTclPage global optionTable ;# set by sourceDisplayControl, used in CreateTclPage global display ;# added by GJFB in 2016-06-05 - used in "subst $displayTable($referenceType,$fieldName)" within this procedure # array set environment [array get env] ;# used in MultipleSubmit # homePath (used in LoadService, StoreService, StorePassword and FindLanguage) set homePath $env(DOCUMENT_ROOT) # htpasswdPath (used in StorePassword) set htpasswdPath $env(HTPASSWD_PATH) # loCoInRep (used in StorePassword) set loCoInRep $env(LOCOINREP) # loBiMiRep set loBiMiRep $env(LOBIMIREP) ;# needed while executing SynchronizeRepository # URLibServiceRepository (used by SortRandomNumber and by CreateTclPageFile) set URLibServiceRepository $env(URLIB_SERVICE_REP) # multipleLineReferFieldNamePattern set multipleLineReferFieldNamePattern $env(MULI_PATTERN) # multipleLineReferFieldNamePatternForCreator set multipleLineReferFieldNamePatternForCreator $env(MULI_PATTERN_FOR_CREATOR) # authorFieldNameList set authorFieldNameList $env(AUTHOR_FIELD_NAME_LIST) # mirrorHomePageRepository # used in sourceDisplayControl set mirrorHomePageRepository dpi.inpe.br/banon/2000/01.23.20.24 set col ../../../../.. # set citationKeyRepository dpi.inpe.br/banon/1999/07.11.21.09 set sendMailRep iconet.com.br/lise/2005/06.25.14.21 source ../$col/$URLibServiceRepository/doc/utilities1.tcl source ../$col/$URLibServiceRepository/doc/cgi/mirrorfind-.tcl # set processReviewRep iconet.com.br/banon/2004/07.19.12.32 # serverAddress (used in CreateTclPage and SetFieldValue only) set serverAddress [list $env(SERVER_NAME) $env(URLIB_PORT)] # serverAddressWithIP (used in CreateTclPage and CreateTclPageFile) set serverAddressWithIP [list $env(IP_ADDR) $env(URLIB_PORT)] # localSite # set localSite $env(SERVER_NAME):$env(SERVER_PORT) set localSite [ReturnHTTPHost] # http set http http[expr [info exists env(HTTPS)]?{s}:{}] # set xxx 1a-[pid] # Store xxx C:/tmp/bbb auto 0 a # set xxx 2a-[pid] # Store xxx C:/tmp/bbb auto 0 a if 0 { puts {Content-Type: text/html} puts {} } # update set update [info exists env(PATH_INFO)] # puts $update # currentRep (local mirror repository - contains @siteList.txt) set uri [file split $env(REQUEST_URI)] regsub -all { } [lrange $uri 2 5] {/} currentRep ;# used in mirrorHomePage.html # puts --$env(QUERY_STRING)-- # exit if {[info exists env(QUERY_STRING)] && ![string equal {} $env(QUERY_STRING)]} { if [regexp {(updatetype)=([^&$]*)} $env(QUERY_STRING) m name value] {set cgi($name) $value} if [regexp {(returnaddress)=(.+)$} $env(QUERY_STRING) m name value] { # return address exists and is not empty # for Return Button set cgi($name) $value if [regexp {(attachment)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value } # if [regexp {(%0\+referencetype)=([^&$]*)} $env(QUERY_STRING) m name value] # # in some browser (like konqueror) % is coded %25 - in this case 25 must be omitted if [regexp {(%2?5?0\+referencetype)=([^&$]*)} $env(QUERY_STRING) m name value] { regsub -all {\+} $value { } value set {cgi(%0 referencetype)} $value ;# {Conference Proceedings} } if [regexp {(lastupdate)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value ;# leaves +, in this way value is a one element list and not treated has a check box value by MakeCGIArray (JoinCGIEntries) # set cgi($name) [DecodeURL $value] regsub -all {\+} $cgi(lastupdate) { } metadataLastUpdate2 } if [regexp {(metadatarepository)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value } if [regexp {(returnbutton)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value } if [regexp {(testoutofdateform)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value ;# for example, used with ePrint (when the submission destination is another local collection) } if [regexp {(sourcesite)=([^&$]*)} $env(QUERY_STRING) m name value] { # for example, used with ePrint (when the submission destination is another local collection) set cgi($name) $value ;# leaves +, in this way value is a one element list and not treated has a check box value by MakeCGIArray (JoinCGIEntries) # set cgi($name) [DecodeURL $value] regsub -all {\+} $cgi(sourcesite) { } sourceSite } } else { # return address doesn't exist or is empty # for Copy Button foreach {name value} [split $env(QUERY_STRING) &=] { set cgi([DecodeURL $name]) [DecodeURL $value] } if [info exists cgi(returnaddress)] {unset cgi(returnaddress)} ;# drop empty return address (otherwise the update knowledgement doesn't work) } } # puts [array get cgi] if $update { # update set pathInfo [file split $env(PATH_INFO)] # repName regsub -all { } [lrange $pathInfo 1 4] {/} repName # puts $repName # thisRepository set thisRepository $repName ;# used in CreateTclPageFile, DisplaySearch and DisplayMultipleSearch LoadService $repName userName userName 1 1 ;# must be before source displayControl.tcl for dynamic forms set advancedUser $userName ;# alias - must be before source displayControl.tcl for dynamic forms # metadataRep if [info exists cgi(metadatarepository)] { set metadataRep $cgi(metadatarepository) ;# added by GJFB in 2013-02-11 because FindMetadataRep returns the first encountered, this metadata repository may not be the proper one for the current application } else { set metadataRep [Execute $serverAddressWithIP [list FindMetadataRep $repName]] } # mirrorRepository set mirrorRepository [Execute $serverAddressWithIP [list GetFieldValue $metadataRep-0 mirrorrepository]] if {![string equal {} $mirrorRepository] && [file isdirectory $homePath/col/$mirrorRepository]} { set currentRep $mirrorRepository ;# force to be mirrorRepository } } # Find the language and the language repository # use the same languages as used for the local bibliographic mirror foreach {language languageRep1 languageRep2 firstLanguageRep \ submissionFormRep submissionFormLanguage submissionFormLanguageRep} \ [FindLanguage $currentRep] {break} # Find the language and the language repository - end # set enableTrace 0 # @enableTrace must contain 0 or 1 Load $homePath/col/$URLibServiceRepository/auxdoc/@enableTrace enableTrace TraceProcedure Submit TraceProcedure ;# add executing time interval TraceProcedure [clock format [clock seconds] -format %Y:%m.%d.%H.%M.%S] # puts $env(REQUEST_URI) # puts $currentRep # exit # puts [list $language $languageRep1 $languageRep2 $firstLanguageRep \ $submissionFormRep $submissionFormLanguage $submissionFormLanguageRep] # bgColor, background and bgProperties if 0 { # used in old mirror foreach {bgColor background bgProperties fontTag fontTag2} [GetBg $languageRep1 $language] {break} set background [subst $background] } # display # set display [subst [GetFrameName $mirrorHomePageRep]] set display [GetFrameName] # userGroup set userGroup {} ;# could be any thing - will be set correctly later on (existence is tested in displayControl.tcl and allow the setting of userNameList) # submissionStage set submissionStage perform ;# used in displayControl foreach {language languageRep2} [FindLanguageForSubmissionForm $language $submissionFormLanguage $firstLanguageRep $languageRep2] {break} source ../$col/$languageRep2/doc/mirror/${submissionFormLanguage}Submit.tcl # GetConversionTable $languageRep2 $language GetConversionTable $languageRep2 $submissionFormLanguage global field::conversionTable global "${languageRep2}::submission header" global "${languageRep2}::update header" global "${languageRep2}::footer" # global "${languageRep2}::Return" global "${languageRep2}::Continue" # global "${languageRep2}::Copy" global "${languageRep2}::Yes" global "${languageRep2}::No" global "${languageRep2}::empty field" global "${languageRep2}::empty fields" # global "${languageRep2}::empty checkbox" global "${languageRep2}::no file name" global "${languageRep2}::not a zip arquive" global "${languageRep2}::wrong content type for submission - singular" global "${languageRep2}::wrong content type for submission - plural" global "${languageRep2}::wrong content type for update - singular" global "${languageRep2}::wrong content type for update - plural" global "${languageRep2}::empty username" global "${languageRep2}::wrong username" global "${languageRep2}::unknown username" global "${languageRep2}::empty password" global "${languageRep2}::empty password1 at submission" global "${languageRep2}::empty password2 at submission" global "${languageRep2}::wrong password" global "${languageRep2}::existing user name and wrong password" global "${languageRep2}::passwords are different" # global "${languageRep2}::file not found" global "${languageRep2}::url not found" global "${languageRep2}::maximum size warning" global "${languageRep2}::repository warning for submission" global "${languageRep2}::repository warning for update" global "${languageRep2}::access warning" global "${languageRep2}::update warning" global "${languageRep2}::eprint update warning" global "${languageRep2}::Document" global "${languageRep2}::Reference" global "${languageRep2}::your document" global "${languageRep2}::your reference" global "${languageRep2}::Submission completed successfully..." global "${languageRep2}::Submission NOT completed..." global "${languageRep2}::Update completed successfully..." global "${languageRep2}::a repository already exists" global "${languageRep2}::the current update causes two or more repositories with the same citation key" global "${languageRep2}::out-of-date form" # global "${languageRep2}::no header" global "${languageRep2}::repository not found" global "${languageRep2}::currentVariableFileName" ;# for reverse engineering global "${languageRep2}::closed session" if 0 { # puts --$env(QUERY_STRING)-- # exit if {[info exists env(QUERY_STRING)] && ![string equal {} $env(QUERY_STRING)]} { if [regexp {(updatetype)=([^&$]*)} $env(QUERY_STRING) m name value] {set cgi($name) $value} if [regexp {(returnaddress)=(.+)$} $env(QUERY_STRING) m name value] { # return address exists and is not empty # for Return Button set cgi($name) $value if [regexp {(attachment)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value } # if [regexp {(%0\+referencetype)=([^&$]*)} $env(QUERY_STRING) m name value] # # in some browser (like konqueror) % is coded %25 - in this case 25 must be omitted if [regexp {(%2?5?0\+referencetype)=([^&$]*)} $env(QUERY_STRING) m name value] { regsub -all {\+} $value { } value set {cgi(%0 referencetype)} $value ;# {Conference Proceedings} } if [regexp {(lastupdate)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value ;# leaves +, in this way value is a one element list and not treated has a check box value by MakeCGIArray (JoinCGIEntries) # set cgi($name) [DecodeURL $value] regsub -all {\+} $cgi(lastupdate) { } metadataLastUpdate2 } if [regexp {(returnbutton)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value } if [regexp {(testoutofdateform)=([^&$]*)} $env(QUERY_STRING) m name value] { set cgi($name) $value ;# for example, used with ePrint (when the submission destination is another local collection) } if [regexp {(sourcesite)=([^&$]*)} $env(QUERY_STRING) m name value] { # for example, used with ePrint (when the submission destination is another local collection) set cgi($name) $value ;# leaves +, in this way value is a one element list and not treated has a check box value by MakeCGIArray (JoinCGIEntries) # set cgi($name) [DecodeURL $value] regsub -all {\+} $cgi(sourcesite) { } sourceSite } } else { # return address doesn't exist or is empty # for Copy Button foreach {name value} [split $env(QUERY_STRING) &=] { set cgi([DecodeURL $name]) [DecodeURL $value] } if [info exists cgi(returnaddress)] {unset cgi(returnaddress)} ;# drop empty return address (otherwise the update knowledgement doesn't work) } } } # cssFileURL ConditionalSet cssFileURL cgi(cssfileurl) http://$localSite/col/$languageRep1/doc/mirrorStandard.css if ![info exists cgi(returnbutton)] {set cgi(returnbutton) no} ;# needed for example when using Get set queryInfo ?languagebutton=$language ;# cgi(languagebutton) is not created and not used # append queryInfo "&mirror=$currentRep" ;# commented by GJFB in 2013-01-12 append queryInfo "&requiredmirror=$currentRep" ;# added by GJFB in 2013-01-12 - needed when "a repository already exists" (in case of duplicate) append queryInfo "&returnbutton=$cgi(returnbutton)" # submissionType if $update { # update set submissionType update set header ${update header} } else { # submit set submissionType submit set header ${submission header} } # sourceSite ## must be here because MakeCGIArray (JoinCGIEntries) below change {ePrint.sid.inpe.br 800} into {ePrint.sid.inpe.br; 800.} # if [info exists cgi(sourcesite)] # # regsub -all {\+} $cgi(sourcesite) { } sourceSite # # # attachment if ![info exists cgi(attachment)] {set cgi(attachment) yes} append queryInfo "&attachment=$cgi(attachment)" # referenceType if [info exists cgi(referencetype)] { # url submission # ::http::geturl returns: Illegal encoding character usage "%0+" in URL path # when the query string in the URL contains the string: %0+referencetype # ::http::geturl returns: Illegal encoding character in URL path # when the query string in the URL contains the string: %250+referencetype set referenceType $cgi(referencetype) set {cgi(%0 referencetype)} $referenceType ;# {Conference Proceedings} } else { # form submission # set referenceType ${cgi(%0 referencetype)} ;# doesn't work with tcl 8.0.2p set index {%0 referencetype} set referenceType [join $cgi($index)] ;# {Conference Proceedings} -> Conference Proceedings } if 0 { puts {Content-Type: text/html} puts {} puts --$env(QUERY_STRING)-- puts --[array get cgi]-- puts $cgi($index) puts $referenceType exit } # READ if {[info exists maximumFileSizeTable($referenceType)] && \ $env(CONTENT_LENGTH) > $maximumFileSizeTable($referenceType)} { puts {Content-Type: text/html} puts {} set cgi(returnbutton) yes set returnButton [CreateReturnButton