dcba97b3f88e88e9e59b85f87647d0ba9f2d4503 hiram Mon Jun 21 10:56:49 2021 -0700 replacing hgBotDelay with earlyBotCheck refs #23217 diff --git src/hg/hgGene/hgGene.c src/hg/hgGene/hgGene.c index bbefda5..6173af9 100644 --- src/hg/hgGene/hgGene.c +++ src/hg/hgGene/hgGene.c @@ -35,30 +35,34 @@ char *curGeneChrom; /* Chromosome current gene is on. */ char *curAlignId; /* Align id from knownGene genePred */ struct trackDb *globalTdb; struct genePred *curGenePred; /* Current gene prediction structure. */ boolean isGencode; /* is this based on the Gencode models */ boolean isGencode2; /* is this based on the Gencode models and use ensembl id as primary id */ boolean isGencode3; /* is this based on the Gencode models and use ensembl id as primary id */ int curGeneStart,curGeneEnd; /* Position in chromosome. */ struct sqlConnection *spConn; /* Connection to SwissProt database. */ char *swissProtAcc; /* SwissProt accession (may be NULL). */ int kgVersion = KG_UNKNOWN; /* KG version */ int measureTiming = FALSE; //#include "rgdInfo.c" +/* for earlyBotCheck() function at the beginning of main() */ +#define delayFraction 1.0 /* standard penalty for most CGIs */ +boolean issueBotWarning = FALSE; + void usage() /* Explain usage and exit. */ { errAbort( "hgGene - A CGI script to display the gene details page.\n" "usage:\n" " hgGene cgi-vars in var=val format\n" "options:\n" " -hgsid=XXX Session ID to grab vars from session database\n" " -db=XXX Genome database associated with gene\n" " -org=XXX Organism associated with gene\n" " -hgg_gene=XXX ID of gene\n" ); } @@ -680,31 +684,39 @@ * Method, Credits, and Data Use Restrictions) */ { cartWebStart(cart, database, "Methods, Credits, and Use Restrictions"); char *tableName = cartUsualString(cart, hggType, NULL); if (tableName == NULL) tableName = "knownGene"; struct trackDb *tdb = hTrackDbForTrack(database, tableName); hPrintf("%s", tdb->html); cartWebEnd(); } void cartMain(struct cart *theCart) /* We got the persistent/CGI variable cart. Now * set up the globals and make a web page. */ { -hgBotDelay(); +/* used to have hgBotDelay() here, replaced with earlyBotCheck() + * at the beginning of main() to output message here if in delay time + * 2021-06-21 - Hiram + */ +if (issueBotWarning) + { + char *ip = getenv("REMOTE_ADDR"); + botDelayMessage(ip, botDelayMillis); + } cart = theCart; getDbAndGenome(cart, &database, &genome, oldVars); initGenbankTableNames(database); getGenomeSettings(); if (cartVarExists(cart, hggDoKgMethod)) doKgMethod(); else if (cartVarExists(cart, hggDoTxInfoDescription)) doTxInfoDescription(); else { struct sqlConnection *conn = NULL; char *geneName = cartUsualString(cart, hggGene, NULL); if (isEmpty(geneName)) { // Silly googlebots. @@ -773,24 +785,27 @@ webMain(conn, tdb); cartWebEnd(); } hFreeConn(&spConn); hFreeConn(&conn); } cartRemovePrefix(cart, hggDoPrefix); } char *excludeVars[] = {"Submit", "submit", "ajax", hggAjaxSection, NULL}; int main(int argc, char *argv[]) /* Process command line. */ { long enteredMainTime = clock1000(); +/* 0, 0, == use default 10 second for warning, 20 second for immediate exit */ +issueBotWarning = earlyBotCheck(enteredMainTime, "hgGene", delayFraction, 0, 0, "html"); + cgiSpoof(&argc, argv); htmlSetStyle(htmlStyleUndecoratedLink); if (argc != 1) usage(); oldVars = hashNew(10); cartEmptyShell(cartMain, hUserCookie(), excludeVars, oldVars); cgiExitTime("hgGene", enteredMainTime); return 0; }