void palOptions(struct cart *cart, struct sqlConnection *conn, void (*addButtons)(), char *extraVar) /* output the options dialog (select MAF file, output options */ { char *database = sqlGetDatabase(conn); hPrintf("<FORM ACTION=\"%s\" NAME=\"mainForm\" METHOD=POST>\n", cgiScriptName()); cartSaveSession(cart); char *mafTable = outMafTableDrop(cart, conn); char *numColumns = cartUsualString(cart, hgtaCGINumColumns, ""); printf("<BR><BR><B>Formatting options:</B><BR>\n"); jsMakeTrackingCheckBox(cart, hgtaCGIGeneExons, hgtaJSGeneExons, FALSE); printf("Separate into exons<BR>"); jsMakeTrackingCheckBox(cart, hgtaCGIGeneNoTrans, hgtaJSGeneNoTrans, FALSE); printf("Show nucleotides<BR>"); jsMakeTrackingCheckBox(cart, hgtaCGIGeneOutBlank, hgtaJSGeneOutBlank, FALSE); printf("Output lines with just dashes<BR>"); jsMakeTrackingCheckBox(cart, hgtaCGIOutTable, hgtaJSOutTable, FALSE); printf("Format output as table "); jsMakeTrackingCheckBox(cart, hgtaCGITruncHeader, hgtaJSTruncHeader, FALSE); printf("Truncate headers at "); cgiMakeTextVar(hgtaCGINumColumns, numColumns, 2); printf("characters (enter zero for no headers)<BR>"); printf("<BR>"); struct trackDb *maftdb = hTrackDbForTrack(database, mafTable); /* get maf parent (if any) */ maftdb->parent = hCompositeTrackDbForSubtrack(database,maftdb); wigMafSpeciesTable(cart, maftdb, mafTable, database); addButtons(); cartSaveSession(cart); hPrintf("</FORM>\n"); /* Hidden form - for benefit of javascript. */ { static char *saveVars[32]; int varCount = ArraySize(curVars); assert(varCount < (sizeof saveVars / sizeof(char *))); memcpy(saveVars, curVars, varCount * sizeof(saveVars[0])); if (extraVar != NULL) { assert(varCount + 1 < (sizeof saveVars / sizeof(char *))); saveVars[varCount] = extraVar; varCount++; } jsCreateHiddenForm(cart, cgiScriptName(), saveVars, varCount); } }
void jsReloadOnBackButton(struct cart *cart) /* Add some javascript to detect that the back button (or reload) has been pressed, * and to resubmit in that case to redraw the page with the latest cart contents. */ // __detectback trick from // http://siphon9.net/loune/2009/07/detecting-the-back-or-refresh-button-click/ // Yes, I know this along with every other inline <script> here belongs in a .js module { jsInlineF( "document.write(\"<form style='display: none'><input name='__detectback' id='__detectback' " "value=''></form>\");\n" "function checkPageBackOrRefresh() {\n" " if (document.getElementById('__detectback').value) {\n" " return true;\n" " } else {\n" " document.getElementById('__detectback').value = 'been here';\n" " return false;\n" " }\n" "}\n" "window.onload = function() { " " if (checkPageBackOrRefresh()) { \n" " if (window.location.search == '?%s') { \n" // We already have the hgsid-only URL that we want, reload it. // (necessary for IE because IE doesn't reload on replace, // unless window.location and/or window.search changes) " window.location.reload(true);\n" " } else { \n" " window.location.replace('%s?%s');\n" " } \n" " } " "};\n" , cartSidUrlString(cart), cgiScriptName(), cartSidUrlString(cart)); }
static void doBigSelectPage(char *db, char *table) /* Put up big field selection page. Assumes html page open already*/ { struct joiner *joiner = allJoiner; struct dbTable *dtList, *dt; char dbTableBuf[256]; cartSetString(cart, hgtaFieldSelectTable, getDbTable(db, table)); if (strchr(table, '.')) htmlOpen("Select Fields from %s", table); else htmlOpen("Select Fields from %s.%s", db, table); hPrintf("<FORM NAME=\"mainForm\" ACTION=\"%s\" METHOD=%s>\n", cgiScriptName(), cartUsualString(cart, "formMethod", "POST")); cartSaveSession(cart); cgiMakeHiddenVar(hgtaDatabase, db); cgiMakeHiddenVar(hgtaTable, table); dbOverrideFromTable(dbTableBuf, &db, &table); showTableFields(db, table, TRUE); dtList = extraTableList(selFieldLinkedTablePrefix()); showLinkedFields(dtList); dt = dbTableNew(db, table); slAddHead(&dtList, dt); showLinkedTables(joiner, dtList, selFieldLinkedTablePrefix(), hgtaDoSelectFieldsMore, "allow selection from checked tables"); /* clean up. */ hPrintf("</FORM>"); cgiDown(0.9); htmlClose(); joinerFree(&joiner); }
static void doBigFilterPage(struct sqlConnection *conn, char *db, char *table) /* Put up filter page on given db.table. */ { struct joiner *joiner = allJoiner; struct dbTable *dtList, *dt; char dbTableBuf[256]; if (strchr(table, '.')) htmlOpen("Filter on Fields from %s", table); else htmlOpen("Filter on Fields from %s.%s", db, table); jsIncludeFile("jquery.js", NULL); jsIncludeFile("utils.js", NULL); commonCssStyles(); hPrintf("<FORM ACTION=\"%s\" METHOD=%s>\n", cgiScriptName(), cartUsualString(cart, "formMethod", "POST")); cartSaveSession(cart); cgiMakeHiddenVar(hgtaDatabase, db); cgiMakeHiddenVar(hgtaTable, table); dbOverrideFromTable(dbTableBuf, &db, &table); filterControlsForTable(db, table); dtList = extraTableList(filterLinkedTablePrefix); showLinkedFilters(dtList); dt = dbTableNew(db, table); slAddHead(&dtList, dt); showLinkedTables(joiner, dtList, filterLinkedTablePrefix, hgtaDoFilterMore, "allow filtering using fields in checked tables"); hPrintf("</FORM>\n"); cgiDown(0.9); htmlClose(); }
void printGreatSubmitButtons() /* print submit button to create data and then send query results to GREAT. */ { cartSetString(cart, hgtaCompressType, textOutCompressNone); cartSetString(cart, hgtaOutFileName, ""); cgiMakeHiddenVar(hgtaCompressType, textOutCompressNone); cgiMakeHiddenVar(hgtaOutFileName, ""); cgiMakeHiddenVar(hgtaDoGreatOutput, "on"); cgiMakeHiddenVar(hgtaPrintCustomTrackHeaders, "on"); cgiMakeButton(hgtaDoGreatQuery, "Send query to GREAT"); hPrintf("</FORM>\n"); hPrintf(" "); /* new form as action is different */ hPrintf("<FORM ACTION=\"%s\" METHOD=GET>\n", cgiScriptName()); cgiMakeButton(hgtaDoMainPage, "Cancel"); hPrintf("</FORM>\n"); }
void jsMakeSetClearButton(struct cart *cart, char *form, char *buttonVar, char *buttonLabel, char *cartVarPrefix, struct slName *cartVarSuffixList, char *anchor, boolean currentPos, boolean isSet) /* Make a button for setting or clearing all of a list of boolean * cart variables (i.e. checkboxes). If this button was just pressed, * set or clear those cart variables. * Optional html anchor is appended to the form's action if given. * If currentPos, anchor is ignored and jsSetVerticalPosition is used so * that the new page gets the same vertical offset as the current page. */ { struct slName *suffix; char javascript[2048]; char *vertPosJs = ""; if (currentPos) { anchor = NULL; jsInit(); vertPosJs = jsSetVerticalPosition(form); } cgiMakeHiddenVar(buttonVar, ""); safef(javascript, sizeof javascript, "document.%s.action = '%s%s%s'; document.%s.%s.value='%s'; %s" "document.%s.submit();", form, cgiScriptName(), (isNotEmpty(anchor) ? "#" : ""), (isNotEmpty(anchor) ? anchor : ""), form, buttonVar, buttonLabel, vertPosJs, form); cgiMakeOnClickButton(javascript, buttonLabel); if (isNotEmpty(cgiOptionalString(buttonVar))) { char option[1024]; if (cartVarPrefix == NULL) cartVarPrefix = ""; for (suffix = cartVarSuffixList; suffix != NULL; suffix = suffix->next) { safef(option, sizeof(option), "%s%s", cartVarPrefix, suffix->name); cartSetBoolean(cart, option, isSet); } } }
static void phoneHome() { static boolean beenHere = FALSE; if (beenHere) /* one at a time please */ return; beenHere = TRUE; char *expireTime = cfgOptionDefault("browser.cgiExpireMinutes", "20"); unsigned expireMinutes = sqlUnsigned(expireTime); expireSeconds = expireMinutes * 60; char trashFile[PATH_LEN]; safef(trashFile, sizeof(trashFile), "%s/registration.txt", trashDir()); /* trashFile does not exist during command line execution */ if(fileExists(trashFile)) /* update access time for trashFile */ { struct utimbuf ut; struct stat mystat; ZeroVar(&mystat); if (stat(trashFile,&mystat)==0) { ut.actime = clock1(); ut.modtime = mystat.st_mtime; } else { ut.actime = ut.modtime = clock1(); } (void) utime(trashFile, &ut); if (expireSeconds > 0) { (void) signal(SIGALRM, cgiApoptosis); (void) alarm(expireSeconds); /* CGI timeout */ } return; } char *scriptName = cgiScriptName(); char *ip = getenv("SERVER_ADDR"); if (scriptName && ip) /* will not be true from command line execution */ { FILE *f = fopen(trashFile, "w"); if (f) /* rigamarole only if we can get a trash file */ { time_t now = time(NULL); char *localTime; extern char *tzname[2]; struct tm *tm = localtime(&now); localTime = sqlUnixTimeToDate(&now,FALSE); /* FALSE == localtime */ fprintf(f, "%s, %s, %s %s, %s\n", scriptName, ip, localTime, tm->tm_isdst ? tzname[1] : tzname[0], trashFile); fclose(f); chmod(trashFile, 0666); pid_t pid0 = fork(); if (0 == pid0) /* in child */ { close(STDOUT_FILENO); /* do not hang up Apache finish for parent */ expireSeconds = 0; /* no error message from this exit */ (void) signal(SIGALRM, cgiApoptosis); (void) alarm(6); /* timeout here in 6 seconds */ #include "versionInfo.h" char url[1024]; safef(url, sizeof(url), "%s%s%s%s%s%s", "http://", "genomewiki.", "ucsc.edu/", "cgi-bin/useCount?", "version=browser.v", CGI_VERSION); /* 6 second alarm will exit this page fetch if it does not work */ (void) htmlPageGetWithCookies(url, NULL); /* ignore return */ exit(0); } /* child of fork has done exit(0) normally or via alarm */ } /* trash file open OK */ if (expireSeconds > 0) { (void) signal(SIGALRM, cgiApoptosis); (void) alarm(expireSeconds); /* CGI timeout */ } } /* an actual CGI binary */ } /* phoneHome() */
char *menuBar(struct cart *cart) // Return HTML for the menu bar (read from a configuration file); // we fixup internal CGI's to add hgsid's and include the appropriate js and css files. { char *docRoot = hDocumentRoot(); char *menuStr, buf[4096], uiVars[128]; FILE *fd; int len, offset, err; char *navBarFile = "inc/globalNavBar.inc"; struct stat statBuf; regex_t re; regmatch_t match[2]; char *scriptName = cgiScriptName(); if (cart) safef(uiVars, sizeof(uiVars), "%s=%u", cartSessionVarName(), cartSessionId(cart)); else uiVars[0] = 0; if(docRoot == NULL) // tolerate missing docRoot (i.e. don't bother with menu when running from command line) return NULL; jsIncludeFile("jquery.js", NULL); jsIncludeFile("jquery.plugins.js", NULL); webIncludeResourceFile("nice_menu.css"); // Read in menu bar html safef(buf, sizeof(buf), "%s/%s", docRoot, navBarFile); fd = mustOpen(buf, "r"); fstat(fileno(fd), &statBuf); len = statBuf.st_size; menuStr = needMem(len + 1); mustRead(fd, menuStr, statBuf.st_size); menuStr[len] = 0; carefulClose(&fd); if (cart) { // fixup internal CGIs to have hgsid safef(buf, sizeof(buf), "/cgi-bin/hg[A-Za-z]+(%c%c?)", '\\', '?'); err = regcomp(&re, buf, REG_EXTENDED); if(err) errAbort("regcomp failed; err: %d", err); struct dyString *dy = newDyString(0); for(offset = 0; offset < len && !regexec(&re, menuStr + offset, ArraySize(match), match, 0); offset += match[0].rm_eo) { dyStringAppendN(dy, menuStr + offset, match[0].rm_eo); if(match[1].rm_so == match[1].rm_eo) dyStringAppend(dy, "?"); dyStringAppend(dy, uiVars); if(match[1].rm_so != match[1].rm_eo) dyStringAppend(dy, "&"); } if(offset < len) dyStringAppend(dy, menuStr + offset); freez(&menuStr); menuStr = dyStringCannibalize(&dy); } if(!loginSystemEnabled()) stripRegEx(menuStr, "<\\!-- LOGIN_START -->.*<\\!-- LOGIN_END -->", REG_ICASE); if(scriptName) { // Provide optional official mirror servers menu items char *geoMenu = geoMirrorMenu(); char *pattern = "<!-- OPTIONAL_MIRROR_MENU -->"; char *newMenuStr = replaceChars(menuStr, pattern, geoMenu); freez(&menuStr); menuStr = newMenuStr; } if(scriptName) { // Provide view menu for some CGIs. struct dyString *viewItems = dyStringCreate(""); boolean hasViewMenu = TRUE; if (endsWith(scriptName, "hgGenome")) { safef(buf, sizeof(buf), "../cgi-bin/hgGenome?%s&hgGenome_doPsOutput=1", uiVars); dyStringPrintf(viewItems, "<li><a href='%s' id='%s'>%s</a></li>\n", buf, "pdfLink", "PDF/PS"); } else { hasViewMenu = FALSE; } if (hasViewMenu) { struct dyString *viewMenu = dyStringCreate("<li class='menuparent' id='view'><span>View</span>\n<ul style='display: none; visibility: hidden;'>\n"); dyStringAppend(viewMenu, viewItems->string); dyStringAppend(viewMenu, "</ul>\n</li>\n"); menuStr = replaceChars(menuStr, "<!-- OPTIONAL_VIEW_MENU -->", viewMenu->string); dyStringFree(&viewMenu); } dyStringFree(&viewItems); } if(scriptName) { // Provide context sensitive help links for some CGIs. char *link = NULL; char *label = NULL; if (endsWith(scriptName, "hgBlat")) { link = "../goldenPath/help/hgTracksHelp.html#BLATAlign"; label = "Help on Blat"; } else if (endsWith(scriptName, "hgHubConnect")) { link = "../goldenPath/help/hgTrackHubHelp.html"; label = "Help on Track Hubs"; } else if (endsWith(scriptName, "hgNear")) { link = "../goldenPath/help/hgNearHelp.html"; label = "Help on Gene Sorter"; } else if (endsWith(scriptName, "hgTables")) { link = "../goldenPath/help/hgTablesHelp.html"; label = "Help on Table Browser"; } else if (endsWith(scriptName, "hgGenome")) { link = "../goldenPath/help/hgGenomeHelp.html"; label = "Help on Genome Graphs"; } else if (endsWith(scriptName, "hgSession")) { link = "../goldenPath/help/hgSessionHelp.html"; label = "Help on Sessions"; } else if (endsWith(scriptName, "hgVisiGene")) { link = "../goldenPath/help/hgTracksHelp.html#VisiGeneHelp"; label = "Help on VisiGene"; } else if (endsWith(scriptName, "hgCustom")) { link = "../goldenPath/help/customTrack.html"; label = "Help on Custom Tracks"; } // Don't overwrite any previously set defaults if(!contextSpecificHelpLink && link) contextSpecificHelpLink = link; if(!contextSpecificHelpLabel && label) contextSpecificHelpLabel = label; } if(contextSpecificHelpLink) { char buf[1024]; safef(buf, sizeof(buf), "<li><a href='%s'>%s</a></li>", contextSpecificHelpLink, contextSpecificHelpLabel); menuStr = replaceChars(menuStr, "<!-- CONTEXT_SPECIFIC_HELP -->", buf); } return menuStr; }
char *webTimeStampedLinkToResource(char *fileName, boolean wrapInHtml) // If wrapInHtml // returns versioned link embedded in style or script html (free after use). // else // returns full path of a versioned path to the requested resource file (js, or css). // NOTE: png, jpg and gif should also be supported but are untested. // // In production sites we use a versioned softlink that includes the CGI version. This has the following benefits: // a) flushes user's web browser cache when the user visits a GB site whose version has changed since their last visit; // b) enforces the requirement that static files are the same version as the CGIs (something that often fails to happen in mirrors). // (see notes in redmine #3170). // // In dev trees we use mtime to create a pseudo-version; this forces web browsers to reload css/js file when it changes, // so we don't get odd behavior that can be caused by caching of mis-matched javascript and style files in dev trees. // // In either case, the actual file has to have been previously created by running make in the appropriate directory (kent/src/hg/js // or kent/src/hg/htdocs/style). { char baseName[PATH_LEN]; char extension[FILEEXT_LEN]; splitPath(fileName, NULL, baseName, extension); boolean js = sameString(".js",extension); boolean style = !js && sameString(".css",extension); boolean image = !js && !style && ( sameString(".png",extension) || sameString(".jpg",extension) || sameString(".gif",extension)); if (!js && !style) // && !image) NOTE: This code has not been tested on images but should work. errAbort("webTimeStampedLinkToResource: unknown resource type for %s.\n", fileName); // Build and verify directory char *dirName = ""; if (js) dirName = cfgOptionDefault("browser.javaScriptDir", "js"); else if (style) dirName = cfgOptionDefault("browser.styleDir","style"); else if (image) dirName = cfgOptionDefault("browser.styleImagesDir","style/images"); struct dyString *fullDirName = NULL; char *docRoot = hDocumentRoot(); if (docRoot != NULL) fullDirName = dyStringCreate("%s/%s", docRoot, dirName); else // tolerate missing docRoot (i.e. when running from command line) fullDirName = dyStringCreate("%s", dirName); if (!fileExists(dyStringContents(fullDirName))) errAbort("webTimeStampedLinkToResource: dir: %s doesn't exist.\n", dyStringContents(fullDirName)); // build and verify real path to file struct dyString *realFileName = dyStringCreate("%s/%s", dyStringContents(fullDirName), fileName); if (!fileExists(dyStringContents(realFileName))) errAbort("webTimeStampedLinkToResource: file: %s doesn't exist.\n", dyStringContents(realFileName)); // build and verify link path including timestamp in the form of dir/baseName + timeStamp or CGI Version + ext long mtime = fileModTime(dyStringContents(realFileName)); struct dyString *linkWithTimestamp; char *scriptName = cgiScriptName(); if (scriptName == NULL) scriptName = cloneString(""); boolean nonVersionedLinks = FALSE; if (endsWith(scriptName, "qaPushQ")) nonVersionedLinks = TRUE; if (nonVersionedLinks) linkWithTimestamp = dyStringCreate("%s/%s%s", dyStringContents(fullDirName), baseName, extension); else if ((cfgOption("versionStamped") == NULL) && (hIsPreviewHost() || hIsPrivateHost())) linkWithTimestamp = dyStringCreate("%s/%s-%ld%s", dyStringContents(fullDirName), baseName, mtime, extension); else linkWithTimestamp = dyStringCreate("%s/%s-v%s%s", dyStringContents(fullDirName), baseName, CGI_VERSION, extension); if (!fileExists(dyStringContents(linkWithTimestamp))) errAbort("Cannot find correct version of file '%s'; this is due to an installation error\n\nError details: %s does not exist", fileName, dyStringContents(linkWithTimestamp)); // Free up all that extra memory dyStringFree(&realFileName); dyStringFree(&fullDirName); char *linkFull = dyStringCannibalize(&linkWithTimestamp); char *link = linkFull; if (docRoot != NULL) { link = cloneString(linkFull + strlen(docRoot) + 1); freeMem(linkFull); } if (wrapInHtml) // wrapped for christmas { struct dyString *wrapped = dyStringNew(0); if (js) dyStringPrintf(wrapped,"<script type='text/javascript' SRC='/%s'></script>\n", link); else if (style) dyStringPrintf(wrapped,"<LINK rel='STYLESHEET' href='/%s' TYPE='text/css' />\n", link); else // Will be image, since these are the only three choices allowed dyStringPrintf(wrapped,"<IMG src='/%s' />\n", link); freeMem(link); link = dyStringCannibalize(&wrapped); } return link; }
static void webStartWrapperDetailedInternal(struct cart *theCart, char *db, char *headerText, char *textOutBuf, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ { char uiState[256]; char *scriptName = cgiScriptName(); boolean isEncode = FALSE; if (theCart) { char *theGenome = NULL; char *genomeEnc = NULL; getDbAndGenome(theCart, &db, &theGenome, NULL); genomeEnc = cgiEncode(theGenome); safef(uiState, sizeof(uiState), "?%s=%s&%s=%s&%s=%u", orgCgiName, genomeEnc, dbCgiName, db, cartSessionVarName(), cartSessionId(theCart)); } else { uiState[0] = 0; uiState[1] = 0; } if (db == NULL) db = hDefaultDb(); boolean dbIsFound = hDbExists(db); boolean haveBlat = FALSE; if (dbIsFound) haveBlat = hIsBlatIndexedDatabase(db); if (scriptName == NULL) scriptName = cloneString(""); /* don't output two headers */ if(webHeadAlreadyOutputed) return; if (sameString(cgiUsualString("action",""),"encodeReleaseLog") || rStringIn("EncodeDataVersions", scriptName)) isEncode = TRUE; /* Preamble. */ dnaUtilOpen(); if (withHttpHeader) puts("Content-type:text/html\n"); if (withHtmlHeader) { char *newString, *ptr1, *ptr2; char *browserVersion; if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8') puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"); else puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " "\"http://www.w3.org/TR/html4/loose.dtd\">"); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) puts( "<HTML>" "\n" "<HEAD>" "\n" ); printf("\t%s\n", headerText); printf("\t<META HTTP-EQUIV=\"Content-Type\" CONTENT=\"text/html;CHARSET=iso-8859-1\">" "\n" "\t<META http-equiv=\"Content-Script-Type\" content=\"text/javascript\">" "\n" "\t<META HTTP-EQUIV=\"Pragma\" CONTENT=\"no-cache\">" "\n" "\t<META HTTP-EQUIV=\"Expires\" CONTENT=\"-1\">" "\n" "\t<TITLE>" ); /* we need to take any HTML formatting out of the titlebar string */ newString = cloneString(textOutBuf); for(ptr1=newString, ptr2=textOutBuf; *ptr2 ; ptr2++) { if (*ptr2 == '<') { for(; *ptr2 && (*ptr2 != '>'); ptr2++) ; } else *ptr1++ = *ptr2; } *ptr1 = 0; htmlTextOut(newString); printf(" </TITLE>\n "); webIncludeResourceFile("HGStyle.css"); if (extraStyle != NULL) puts(extraStyle); printf("</HEAD>\n"); printBodyTag(stdout); htmlWarnBoxSetup(stdout);// Sets up a warning box which can be filled with errors as they occur puts(commonCssStyles()); } puts( "<A NAME=\"TOP\"></A>" "\n" "" "\n" "<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=0 WIDTH=\"100%\">" "\n"); if (withLogo) { puts("<TR><TH COLSPAN=1 ALIGN=\"left\">"); if (isEncode) { puts("<A HREF=\"http://www.genome.gov/10005107\" TARGET=\"_BLANK\">" "<IMG SRC=\"../images/ENCODE_scaleup_logo.png\" height=50 ALT=\"ENCODE Project at NHGRI\">" "</A>"); puts("<IMG SRC=\"../images/encodeDcc.jpg\" ALT=\"ENCODE Project at UCSC\">"); } else { puts("<IMG SRC=\"../images/title.jpg\">"); } puts("</TH></TR>" "\n" "" "\n" ); } /* Put up the hot links bar. */ char *menuStr = menuBar(theCart); if(menuStr) { puts(menuStr); } if (endsWith(scriptName, "hgGateway") && geoMirrorEnabled()) { // Show an opt-out alert if user is on a host to which user has been automatically redirected (just once, right after they have been redirected) char *source = cgiOptionalString("source"); char *redirect = cgiOptionalString("redirect"); if (source != NULL && redirect != NULL && sameString(redirect, "auto")) { char *domain = cgiServerName(); char *port = cgiServerPort(); // We don't bother maintaining stuff in request URI, because it may contain items like hgsid and other host specific values int newUriSize = 2048; char *newUri = needMem(newUriSize); safef(newUri, newUriSize, "http%s://%s:%s/cgi-bin/hgGateway?redirect=manual&source=%s", cgiServerHttpsIsOn() ? "s" : "", source, port, domain); printf("<TR><TD COLSPAN=3 id='redirectTd' onclick=\"javascript:document.getElementById('redirectTd').innerHTML='';\">" "<div style=\"margin: 10px 25%%; border-style:solid; border-width:thin; border-color:#97D897;\">" "<h3 style=\"background-color: #97D897; text-align: left; margin-top:0px; margin-bottom:0px;\">" " You've been redirected to your nearest mirror - %s" "<idiv style=\"float:right;\">[x]</idiv>" "</h3> " "<ul style=\"margin:5px;\">" "<li>Take me back to <a href=\"%s\">%s</a>" "<idiv style=\"float:right;\"><a href=\"../goldenPath/help/genomeEuro.html\">What is this?</a></idiv>" "</li>" "</ul>" "</div>" "</TD></TR>\n" , domain, newUri, source ); } } if(!skipSectionHeader) /* this HTML must be in calling code if skipSectionHeader is TRUE */ { puts( // TODO: Replace nested tables with CSS (difficulty is that tables are closed elsewhere) "<!-- +++++++++++++++++++++ CONTENT TABLES +++++++++++++++++++ -->" "\n" "<TR><TD COLSPAN=3>\n" "<div id=firstSection>" " <!--outer table is for border purposes-->\n" " <TABLE WIDTH='100%' BGCOLOR='#" HG_COL_BORDER "' BORDER='0' CELLSPACING='0' " "CELLPADDING='1'><TR><TD>\n" " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' BORDER='0' CELLSPACING='0' " "CELLPADDING='0'><TR><TD>\n" " <div class='subheadingBar'><div class='windowSize' id='sectTtl'>" ); htmlTextOut(textOutBuf); puts(" </div></div>\n" " <TABLE BGCOLOR='#" HG_COL_INSIDE "' WIDTH='100%' CELLPADDING=0>" "<TR><TH HEIGHT=10></TH></TR>\n" " <TR><TD WIDTH=10> </TD><TD>\n\n" ); }; webPushErrHandlers(); /* set the flag */ webHeadAlreadyOutputed = TRUE; } /* static void webStartWrapperDetailedInternal() */
void gvDisclaimer () /* displays page with disclaimer forwarding query string that got us here */ { struct cgiVar *cv, *cvList = cgiVarList(); cartHtmlStart("PhenCode Disclaimer"); printf("<TABLE WIDTH=\"%s\" BGCOLOR=\"#888888\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"1\"><TR><TD>", "100%"); printf("<TABLE BGCOLOR=\"fffee8\" WIDTH=\"%s\" BORDER=\"0\" CELLSPACING=\"0\" CELLPADDING=\"0\"><TR><TD>", "100%"); printf("<TABLE BGCOLOR=\"D9E4F8\" BACKGROUND=\"../../images/hr.gif\" WIDTH=%s><TR><TD>", "100%"); printf("<FONT SIZE=\"4\"><b> PhenCode Disclaimer </B></FONT> "); printf("</TD></TR></TABLE>"); printf("<TABLE BGCOLOR=\"fffee8\" WIDTH=\"%s\" CELLPADDING=0><TR><TH HEIGHT=10></TH></TR>", "100%"); printf("<TR><TD WIDTH=10> </TD><TD>"); printf("<b>Usage</b>\n"); printf("<p>\n"); printf("PhenCode is intended for research purposes only. Although the data\n"); printf("are freely available to all, users should treat the reported mutations\n"); printf("with extreme caution in clinical settings or for any diagnostic or\n"); printf("population screening purpose. This information requires expertise\n"); printf("to interpret properly; clinical diagnosis and/or treatment\n"); printf("recommendations should be made only by medical professionals.\n"); printf("<p>\n"); printf("Patients and doctors should not make treatment decisions based on the\n"); printf("information in PhenCode. In particular, <b>PhenCode should not be used\n"); printf("to assess disease risk</b>. Some of these variants are not associated\n"); printf("with disease at all, and for many others the association is slight,\n"); printf("depends on other factors, and/or may not be causative. The mere fact\n"); printf("that a variant is listed here does NOT mean that a particular patient\n"); printf("will become ill.\n"); printf("<p>"); printf("<b>Errors</b>\n"); printf("<p>\n"); printf("The PhenCode track (including, but not limited to, \"Locus Variants\"\n"); printf(") is a compilation of freely-available data\n"); printf("obtained from other sources. While reasonable effort is made to\n"); printf("promote accuracy, nevertheless there may be errors in the original\n"); printf("data and/or the compilation process. <b>By using these data, you\n"); printf("agree and acknowledge that the information is not guaranteed to be\n"); printf("accurate.</b> If you do find any errors, please report them to the\n"); printf("addresses listed on the <a href=\"http://phencode.bx.psu.edu/phencode/contact.html\">Contact us</a> page.\n"); printf("<p>"); printf("<b>Disclaimer</b>\n"); printf("<p>\n"); printf("This resource and data are provided \"as is\", \"where is\" and without\n"); printf("any express or implied warranties, including, but not limited to, any\n"); printf("implied warranties of merchantability and/or fitness for a particular\n"); printf("purpose. In no event shall\n"); printf("<a href=\"http://www.psu.edu/\">The Pennsylvania State University</a>,\n"); printf("<a href=\"http://www.ucsc.edu/\">The University of California Santa Cruz</a>,\n"); printf("or any data contributors,\n"); printf("nor their respective agents, employees or representatives be liable\n"); printf("for any direct, indirect, incidental, special, exemplary, or\n"); printf("consequential damages (including, but not limited to, procurement of\n"); printf("substitute goods or services; loss of use, data, or profits; business\n"); printf("interruption; medical or legal expenses; or pain and suffering),\n"); printf("however caused and on any theory of liability, whether in contract,\n"); printf("strict liability, or tort (including negligence or otherwise) arising\n"); printf("in any way or form out of the use of this resource or data, even if\n"); printf("advised of the possibility of such damage.\n"); printf("<p>\n"); printf("Users assume all risk and responsibility for the accuracy,\n"); printf("completeness, and usefulness, or lack thereof, of any information,\n"); printf("apparatus, product, or process disclosed, and also all risk and\n"); printf("responsibility that the use hereof would or would not infringe the\n"); printf("rights of any other party.\n"); printf("<p>\n"); printf("<br>\n"); printf("<FORM ACTION=\"%s\" METHOD=POST>\n", cgiScriptName()); for (cv = cvList; cv != NULL; cv = cv->next) { cgiContinueHiddenVar(cv->name); } cgiMakeButtonWithMsg("gvDisclaimer", "Agree", NULL); printf(" "); cgiMakeButtonWithMsg("gvDisclaimer", "Disagree", NULL); printf("</FORM>\n"); printf("</td></tr></table></td></tr></table></td></tr></table>"); cartHtmlEnd(); exit(0); }
char *menuBar(struct cart *cart, char *db) // Return HTML for the menu bar (read from a configuration file); // we fixup internal CGI's to add hgsid's and include the appropriate js and css files. // // Note this function is also called by hgTracks which extends the menu bar // with a View menu defined in hgTracks/menu.c { char *docRoot = hDocumentRoot(); char *menuStr, buf[4096], uiVars[128]; FILE *fd; char *navBarFile = "inc/globalNavBar.inc"; struct stat statBuf; char *scriptName = cgiScriptName(); if (cart) safef(uiVars, sizeof(uiVars), "%s=%s", cartSessionVarName(), cartSessionId(cart)); else uiVars[0] = 0; if(docRoot == NULL) // tolerate missing docRoot (i.e. don't bother with menu when running from command line) return NULL; jsIncludeFile("jquery.js", NULL); jsIncludeFile("jquery.plugins.js", NULL); webIncludeResourceFile("nice_menu.css"); // Read in menu bar html safef(buf, sizeof(buf), "%s/%s", docRoot, navBarFile); fd = mustOpen(buf, "r"); fstat(fileno(fd), &statBuf); int len = statBuf.st_size; menuStr = needMem(len + 1); mustRead(fd, menuStr, statBuf.st_size); menuStr[len] = 0; carefulClose(&fd); if (cart) { char *newMenuStr = menuBarAddUiVars(menuStr, "/cgi-bin/hg", uiVars); freez(&menuStr); menuStr = newMenuStr; } if(scriptName) { // Provide hgTables options for some CGIs. char hgTablesOptions[1024] = ""; char *track = (cart == NULL ? NULL : (endsWith(scriptName, "hgGene") ? cartOptionalString(cart, "hgg_type") : cartOptionalString(cart, "g"))); if (track && cart && db && (endsWith(scriptName, "hgc") || endsWith(scriptName, "hgTrackUi") || endsWith(scriptName, "hgGene"))) { struct trackDb *tdb = hTrackDbForTrack(db, track); if (tdb) { struct trackDb *topLevel = trackDbTopLevelSelfOrParent(tdb); safef(hgTablesOptions, sizeof hgTablesOptions, "../cgi-bin/hgTables?hgta_doMainPage=1&hgta_group=%s&hgta_track=%s&hgta_table=%s&", topLevel->grp, topLevel->track, tdb->table); menuStr = replaceChars(menuStr, "../cgi-bin/hgTables?", hgTablesOptions); trackDbFree(&tdb); } } } if(!loginSystemEnabled()) stripRegEx(menuStr, "<\\!-- LOGIN_START -->.*<\\!-- LOGIN_END -->", REG_ICASE); if(scriptName) { // Provide optional official mirror servers menu items char *geoMenu = geoMirrorMenu(); char *pattern = "<!-- OPTIONAL_MIRROR_MENU -->"; char *newMenuStr = replaceChars(menuStr, pattern, geoMenu); freez(&menuStr); menuStr = newMenuStr; } if(scriptName) { // Provide view menu for some CGIs. struct dyString *viewItems = dyStringCreate(""); boolean hasViewMenu = TRUE; if (endsWith(scriptName, "hgGenome")) { safef(buf, sizeof(buf), "../cgi-bin/hgGenome?%s&hgGenome_doPsOutput=1", uiVars); dyStringPrintf(viewItems, "<li><a href='%s' id='%s'>%s</a></li>\n", buf, "pdfLink", "PDF/PS"); } else { hasViewMenu = FALSE; } if (hasViewMenu) { struct dyString *viewMenu = dyStringCreate("<li class='menuparent' id='view'><span>View</span>\n<ul style='display: none; visibility: hidden;'>\n"); dyStringAppend(viewMenu, viewItems->string); dyStringAppend(viewMenu, "</ul>\n</li>\n"); menuStr = replaceChars(menuStr, "<!-- OPTIONAL_VIEW_MENU -->", viewMenu->string); dyStringFree(&viewMenu); } else if (!endsWith(scriptName, "hgTracks")) { replaceChars(menuStr, "<!-- OPTIONAL_VIEW_MENU -->", ""); } dyStringFree(&viewItems); } if(scriptName) { // Provide context sensitive help links for some CGIs. char *link = NULL; char *label = NULL; if (endsWith(scriptName, "hgBlat")) { link = "../goldenPath/help/hgTracksHelp.html#BLATAlign"; label = "Help on Blat"; } else if (endsWith(scriptName, "hgHubConnect")) { link = "../goldenPath/help/hgTrackHubHelp.html"; label = "Help on Track Hubs"; } else if (endsWith(scriptName, "hgNear")) { link = "../goldenPath/help/hgNearHelp.html"; label = "Help on Gene Sorter"; } else if (endsWith(scriptName, "hgTables")) { link = "../goldenPath/help/hgTablesHelp.html"; label = "Help on Table Browser"; } else if (endsWith(scriptName, "hgGenome")) { link = "../goldenPath/help/hgGenomeHelp.html"; label = "Help on Genome Graphs"; } else if (endsWith(scriptName, "hgSession")) { link = "../goldenPath/help/hgSessionHelp.html"; label = "Help on Sessions"; } else if (endsWith(scriptName, "hgVisiGene")) { link = "../goldenPath/help/hgTracksHelp.html#VisiGeneHelp"; label = "Help on VisiGene"; } else if (endsWith(scriptName, "hgCustom")) { link = "../goldenPath/help/customTrack.html"; label = "Help on Custom Tracks"; } // Don't overwrite any previously set defaults if(!contextSpecificHelpLink && link) contextSpecificHelpLink = link; if(!contextSpecificHelpLabel && label) contextSpecificHelpLabel = label; } if(contextSpecificHelpLink) { char buf[1024]; safef(buf, sizeof(buf), "<li><a href='%s'>%s</a></li>", contextSpecificHelpLink, contextSpecificHelpLabel); menuStr = replaceChars(menuStr, "<!-- CONTEXT_SPECIFIC_HELP -->", buf); } return menuStr; }
static void webStartWrapperDetailedInternal(struct cart *theCart, char *db, char *headerText, char *textOutBuf, boolean withHttpHeader, boolean withLogo, boolean skipSectionHeader, boolean withHtmlHeader) /* output a CGI and HTML header with the given title in printf format */ { char uiState[256]; char *scriptName = cgiScriptName(); boolean isEncode = FALSE; if (theCart) { char *theGenome = NULL; char *genomeEnc = NULL; getDbAndGenome(theCart, &db, &theGenome, NULL); genomeEnc = cgiEncode(theGenome); safef(uiState, sizeof(uiState), "?%s=%s&%s=%s&%s=%s", orgCgiName, genomeEnc, dbCgiName, db, cartSessionVarName(), cartSessionId(theCart)); } else { uiState[0] = 0; uiState[1] = 0; } if (db == NULL) db = hDefaultDb(); boolean dbIsFound = hDbExists(db); boolean haveBlat = FALSE; if (dbIsFound) haveBlat = hIsBlatIndexedDatabase(db); if (scriptName == NULL) scriptName = cloneString(""); /* don't output two headers */ if(webHeadAlreadyOutputed) return; if (sameString(cgiUsualString("action",""),"encodeReleaseLog") || rStringIn("EncodeDataVersions", scriptName)) isEncode = TRUE; /* Preamble. */ dnaUtilOpen(); if (withHttpHeader) puts("Content-type:text/html\n"); if (withHtmlHeader) { char *newString, *ptr1, *ptr2; char *browserVersion; if (btIE == cgiClientBrowser(&browserVersion, NULL, NULL) && *browserVersion < '8') puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 3.2//EN\">"); else puts("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\" " "\"http://www.w3.org/TR/html4/loose.dtd\">"); // Strict would be nice since it fixes atleast one IE problem (use of :hover CSS pseudoclass) puts( "<HTML>" "\n" "<HEAD>" "\n" ); printf("\t%s\n", headerText); webPragmasEtc(); printf("\t<TITLE>"); /* we need to take any HTML formatting out of the titlebar string */ newString = cloneString(textOutBuf); for(ptr1=newString, ptr2=textOutBuf; *ptr2 ; ptr2++) { if (*ptr2 == '<') { for(; *ptr2 && (*ptr2 != '>'); ptr2++) ; } else *ptr1++ = *ptr2; } *ptr1 = 0; htmlTextOut(newString); printf(" </TITLE>\n "); webIncludeResourceFile("HGStyle.css"); if (extraStyle != NULL) puts(extraStyle); printf("</HEAD>\n"); printBodyTag(stdout); htmlWarnBoxSetup(stdout);// Sets up a warning box which can be filled with errors as they occur puts(commonCssStyles()); } webStartSectionTables(); if (withLogo) { puts("<TR><TH COLSPAN=1 ALIGN=\"left\">"); if (isEncode) { puts("<A HREF=\"http://www.genome.gov/10005107\" TARGET=\"_BLANK\">" "<IMG SRC=\"../images/ENCODE_scaleup_logo.png\" height=50 ALT=\"ENCODE Project at NHGRI\">" "</A>"); puts("<IMG SRC=\"../images/encodeDcc.jpg\" ALT=\"ENCODE Project at UCSC\">"); } else { puts("<IMG SRC=\"../images/title.jpg\">"); } puts("</TH></TR>" "\n" "" "\n" ); } /* Put up the hot links bar. */ char *menuStr = menuBar(theCart, db); if(menuStr) { puts(menuStr); } if(!skipSectionHeader) /* this HTML must be in calling code if skipSectionHeader is TRUE */ { webFirstSection(textOutBuf); }; webPushErrHandlers(); /* set the flag */ webHeadAlreadyOutputed = TRUE; errAbortSetDoContentType(FALSE); } /* static void webStartWrapperDetailedInternal() */