dfd69d02b4d35ccafd84a4d712086ef61a9db487 hiram Mon Jun 21 14:12:34 2021 -0700 replacing hgBotDelay with earlyBotCheck refs #23217 diff --git src/hg/cartDump/cartDump.c src/hg/cartDump/cartDump.c index 0933b10..2cfe27c 100644 --- src/hg/cartDump/cartDump.c +++ src/hg/cartDump/cartDump.c @@ -1,29 +1,32 @@ /* cartDump - Dump contents of cart. */ /* Copyright (C) 2014 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "cheapcgi.h" #include "cart.h" #include "hdb.h" #include "jsHelper.h" #include "hui.h" #include "botDelay.h" +/* for earlyBotCheck() function at the beginning of main() */ +#define delayFraction 1.0 /* standard penalty for most CGIs */ +static boolean issueBotWarning = FALSE; #define CART_DUMP_REMOVE_VAR "n/a" struct hash *oldVars = NULL; void doMiddle(struct cart *cart) /* cartDump - Dump contents of cart. */ { #define MATCH_VAR "match" char *vName = "cartDump.varName"; char *vVal = "cartDump.newValue"; char *wildcard; boolean asTable = cartVarExists(cart,CART_DUMP_AS_TABLE); if (cgiVarExists("submit")) @@ -51,31 +54,39 @@ { char *db = cartString(cart, "db"); struct trackDb *tdb = hTrackDbForTrack(db, trackName); if (tdb != NULL && tdbIsComposite(tdb)) { struct lm *lm = lmInit(0); cartTdbTreeCleanupOverrides(tdb,cart,oldVars,lm); lmCleanup(&lm); } } return; } // To discourage hacking, call bottleneck -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); + } if (asTable) { jsIncludeFile("jquery.js",NULL); // required by utils.js jsIncludeFile("utils.js",NULL); jsIncludeFile("ajax.js",NULL); printf("Show as plain text.
",CART_DUMP_AS_TABLE); printf("
\n"); cartSaveSession(cart); printf("Variables can be altered by changing the values and then leaving the field (onchange event will use ajax).\n"); printf("Enter %s or %s to remove a variable.", COLOR_DARKBLUE,CART_DUMP_REMOVE_VAR,COLOR_DARKBLUE,CART_VAR_EMPTY); printf("
Add a variable named: "); cgiMakeTextVar(vName, "", 12); printf(" value: "); @@ -110,21 +121,23 @@ cgiMakeButton("submit", "submit"); printf("
Put %s in for the new value to clear a variable.", COLOR_DARKBLUE,CART_DUMP_REMOVE_VAR); printf("
\n"); } printf("

Cookies passed to %s:
\n%s\n

\n", cgiServerNamePort(), getenv("HTTP_COOKIE")); } char *excludeVars[] = { "submit", "Submit", "noDisplay", MATCH_VAR, 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, "cartDump", delayFraction, 0, 0, "html"); cgiSpoof(&argc, argv); oldVars = hashNew(10); cartHtmlShell("Cart Dump", doMiddle, hUserCookie(), excludeVars, oldVars); cgiExitTime("cartDump", enteredMainTime); return 0; }