code checkpoint

This commit is contained in:
Matt Wells 2014-02-09 16:41:43 -07:00
parent f420bd2769
commit ecdd167d9b
10 changed files with 94 additions and 60 deletions

View File

@ -4,7 +4,7 @@ CC=g++
OBJS = Tfndb.o UdpSlot.o Rebalance.o \
Msg13.o Mime.o IndexReadInfo.o \
PageGet.o PageHosts.o PageIndexdb.o PageLogin.o \
PageGet.o PageHosts.o PageIndexdb.o \
PageParser.o PageInject.o PagePerf.o PageReindex.o PageResults.o \
PageAddUrl.o PageRoot.o PageSockets.o PageStats.o \
PageTitledb.o \
@ -77,7 +77,8 @@ ifeq ("titan","$(HOST)")
# in 2013. So it just uses clone() and does its own "threading". Unfortunately,
# the way it works is not even possible on newer kernels because they no longer
# allow you to override the _errno_location() function. -- matt
CPPFLAGS = -m32 -g -Wall -pipe -Wno-write-strings -Wstrict-aliasing=0 -Wno-uninitialized -static -DMATTWELLS
# -DMATTWELLS
CPPFLAGS = -m32 -g -Wall -pipe -Wno-write-strings -Wstrict-aliasing=0 -Wno-uninitialized -static -DTITAN
LIBS = ./libz.a ./libssl.a ./libcrypto.a ./libiconv.a ./libm.a
else
# use -m32 to force 32-bit mode compilation.

View File

@ -449,6 +449,7 @@ bool Mem::init ( long long maxMem ) {
log(LOG_INIT,"mem: using electric fence!!!!!!!");
#endif
#ifndef TITAN
// if we can't alloc 3gb exit and retry
long long start = gettimeofdayInMilliseconds();
char *pools[30];
@ -471,6 +472,7 @@ bool Mem::init ( long long maxMem ) {
if ( took > 20 ) log("mem: took %lli ms to check memory ceiling",took);
// return if could not alloc the full 3GB
if ( i < 30 ) return false;
#endif
// reset this, our max mem used over time ever because we don't
// want the mem test we did above to count towards it

View File

@ -24,8 +24,8 @@ bool sendPageBasicSettings ( TcpSocket *socket , HttpRequest *hr ) {
if ( fs && strcmp(fs,"xml") == 0 ) fmt = FORMAT_XML;
// false = usedefault coll?
CollectionRec *cr = g_collectiondb.getRec ( hr , false );
// true = usedefault coll?
CollectionRec *cr = g_collectiondb.getRec ( hr , true );
if ( ! cr ) {
g_httpServer.sendErrorReply(socket,500,"invalid collection");
return true;
@ -370,8 +370,8 @@ char *getMatchingUrlPattern ( SpiderColl *sc , SpiderRequest *sreq ) {
bool printSiteListBox ( SafeBuf *sb , HttpRequest *hr ) {
// false = useDefault?
CollectionRec *cr = g_collectiondb.getRec ( hr , false );
// true = useDefault?
CollectionRec *cr = g_collectiondb.getRec ( hr , true );
if ( ! cr ) return true;
//char *submittedSiteList = hr->getString("sitelist" );
@ -431,17 +431,19 @@ bool printSiteListBox ( SafeBuf *sb , HttpRequest *hr ) {
// now list of sites to include, or exclude
sb->safePrintf ( "List of sites to spider, one per line. "
"Gigablast uses the \"insitelist\" directive in "
"the <a href=/scheduler>spider scheduler</a> "
"to make sure that the spider only indexed urls "
"Gigablast uses the "
"<a href=/admin/scheduler#insitelist</a> "
"directive in "
"the <a href=/admin/scheduler>spider scheduler</a> "
"to make sure that the spider only indexes urls "
"that match the patterns you specify here. "
"See examples below."
"See <a href=#examples>examples below</a>."
"<br>"
"%s"
"<br>"
"<textarea cols=80 rows=40%s>"
"<textarea cols=80 rows=20%s>"
, msg2
, status
);
@ -689,8 +691,8 @@ bool sendPageBasicStatus ( TcpSocket *socket , HttpRequest *hr ) {
if ( fs && strcmp(fs,"xml") == 0 ) fmt = FORMAT_XML;
// false = usedefault coll?
CollectionRec *cr = g_collectiondb.getRec ( hr , false );
// true = usedefault coll?
CollectionRec *cr = g_collectiondb.getRec ( hr , true );
if ( ! cr ) {
g_httpServer.sendErrorReply(socket,500,"invalid collection");
return true;

102
Pages.cpp
View File

@ -902,6 +902,8 @@ bool Pages::printAdminTop (SafeBuf *sb ,
//char *username = g_users.getUsername ( r );
char *username = NULL;
char *coll = r->getString ( "c" );
if ( ! coll ) coll = "main";
//char *pwd = r->getString ( "pwd" );
// get username
@ -926,31 +928,19 @@ bool Pages::printAdminTop (SafeBuf *sb ,
//sprintf ( p , "<center>\n");
//p += gbstrlen ( p );
// table
sb->safePrintf( "<table border=0><tr><td>");
sb->safePrintf( "<table border=0>"
"<tr><td>");
// print the logo in upper left corner
status &= printLogo ( sb , coll );
// after logo text
//if ( user == USER_SPAM ) {
// sb->safePrintf( " &nbsp; <font size=+1><b>"
// "Quality Control</b></font>" );
//}
//#ifdef SPLIT_INDEXDB
// long split = INDEXDB_SPLIT;
//#else
// long split = 1;
//#endif
//long split = g_hostdb.m_indexSplits;
// the version info
//sb->safePrintf ("<br/><b>%s</b>",
// //"&nbsp;&nbsp; split=%li tfndbext=%li" ,
// GBVersion);//, split,
// //g_conf.m_tfndbExtBits );
sb->safePrintf("</td>\n<td>");
// print the hosts navigation bar
status &= printHostLinks ( sb, page ,
username , pwd ,
coll, NULL, s->m_ip, qs );
// end table
sb->safePrintf ("</td></tr></table><br/>\n");//<br/>\n");
@ -1035,7 +1025,7 @@ bool Pages::printAdminTop (SafeBuf *sb ,
// pass on this stuff
//if ( ! pwd ) pwd = "";
//sb->safePrintf ( "<input type=hidden name=pwd value=\"%s\">\n",pwd);
if ( ! coll ) coll = "";
//if ( ! coll ) coll = "";
sb->safePrintf ( "<input type=hidden name=c value=\"%s\">\n",coll);
// sometimes we do not want to be USER_MASTER for testing
//if ( user == USER_ADMIN ) {
@ -1051,8 +1041,13 @@ bool Pages::printAdminTop (SafeBuf *sb ,
// a new table. on the left is collections, on right is other stuff
sb->safePrintf("<TABLE "
"cellpadding=5 border=0>"
sb->safePrintf(
//"<DIV "
//"style=max-width:100%%;overflow-x:hidden;"
//">"
"<TABLE "
"cellpadding=5 border=0 "
">"
"<TR>"
"<td></td>"
);
@ -1072,25 +1067,39 @@ bool Pages::printAdminTop (SafeBuf *sb ,
//if ( page == PAGE_BASIC_SEARCH ) isBasic = true;
if ( page == PAGE_BASIC_PASSWORDS ) isBasic = true;
//
// print breadcrumb. main > Basic > Settings
char *menu = "Advanced";
if ( isBasic ) menu = "Basic";
//
char *menu = "advanced";
if ( isBasic ) menu = "basic";
sb->safePrintf("<br>");
sb->safePrintf("<b><font color=gray size=+2>"
"%s &gt; %s &gt; %s</font></b>"
"<br><br>\n",
coll, menu, s_pages[page].m_name);
sb->safePrintf("<b>%s > %s > %s", coll, menu, s_pages[page].m_name);
// print Basic | Advanced links
if ( isBasic )
sb->safePrintf ( "<b><font color=red>Basic</font></b>"
sb->safePrintf ( "<u><b><font color=red>basic</font></b></u>"
" &nbsp; "
"<b><a href=/admin/master>Advanced</a>"
"<b><a href=/admin/master "
"style=text-decoration:none;>"
"advanced</a></b>"
);
else
sb->safePrintf ( "<a href=/admin/basic><b>Basic</b></a>"
sb->safePrintf ( "<b><a href=/admin/settings "
"style=text-decoration:none;>"
"basic</a></b>"
" &nbsp; "
"<b>Advanced</b>"
"<br><br>"
"<u><b><font color=red>"
"advanced"
"</font></b></u>"
);
sb->safePrintf("<br><br>");
// print the menu links under that
status &= printAdminLinks ( sb, page , coll , isBasic );
@ -1414,6 +1423,10 @@ bool Pages::printAdminBottom ( SafeBuf *sb ) {
"<input type=submit name=action value=submit /></center>"
"</br>\n" ) )
status = false;
if ( ! sb->safePrintf("</TABLE>\n"
//"</DIV>\n"
) )
status = false;
// end form
if ( ! sb->safePrintf ( "</form>\n</body>\n</html>\n" ) )
status = false;
@ -1683,7 +1696,7 @@ bool Pages::printHostLinks ( SafeBuf* sb ,
// don't print host buttons if only 1 host
if ( total <= 1 ) return status;
sb->safePrintf ( "</td>\n<td> &nbsp; &nbsp; &nbsp; hosts: ");
sb->safePrintf ( "&nbsp; &nbsp; &nbsp; hosts: ");
if ( ! qs ) qs = "";
//if ( ! pwd ) pwd = "";
@ -1850,9 +1863,11 @@ bool Pages::printAdminLinks ( SafeBuf *sb,
//if ( g_users.hasPermission(username,PAGE_ADMIN ) )
// sprintf(buf,"&master=0");
//sb->safePrintf("<div style=max-width:1000px;>");
//long matt1 = atoip ( MATTIP1 , gbstrlen(MATTIP1) );
//long matt2 = atoip ( MATTIP2 , gbstrlen(MATTIP2) );
for ( long i = PAGE_MASTER ; i < s_numPages ; i++ ) {
for ( long i = PAGE_BASIC_SETTINGS ; i < s_numPages ; i++ ) {
// do not print link if no permission for that page
//if ( (s_pages[i].m_perm & user) == 0 ) continue;
//if ( ! g_users.hasPermission(username,i) ) continue;
@ -1953,15 +1968,18 @@ bool Pages::printAdminLinks ( SafeBuf *sb,
}
// print documentation links
sb->safePrintf(" <a style=text-decoration:none "
"href=/admin.html>"
"<b>"
"admin guide"
"</b></a> "
"&nbsp; "
" <a style=text-decoration:none; "
"href=/developer.html>"
"<b>dev guide</b></a>" );
if ( ! isBasic )
sb->safePrintf(" <a style=text-decoration:none "
"href=/admin.html>"
"<b>"
"admin guide"
"</b></a> "
"&nbsp; "
" <a style=text-decoration:none; "
"href=/developer.html>"
"<b>dev guide</b></a>" );
//sb->safePrintf("</div>");
//sb->safePrintf("</center>" );
sb->safePrintf("<br/>" );
@ -1996,9 +2014,9 @@ bool Pages::printCollectionNavBar ( SafeBuf *sb ,
// if not admin just print collection name
//if ( user == USER_ADMIN ) {
//if (g_users.hasPermission(username,PAGE_ADMIN) ){
sb->safePrintf ( "<center><br/>Collection <b>"
"<font color=red>%s</font></b>"
"<br/><br/></center>" , coll );
//sb->safePrintf ( "<center><br/>Collection <b>"
// "<font color=red>%s</font></b>"
// "<br/><br/></center>" , coll );
// return status ;
//}
// print up to 10 names on there

View File

@ -4192,6 +4192,10 @@ bool Parms::setFromFile ( void *THIS ,
continue;
}
/*
// no! now we warn with a redbox alert
// always make sure we got some admin security
if ( g_conf.m_numMasterIps <= 0 && g_conf.m_numMasterPwds <= 0 ) {
//log(LOG_INFO,
@ -4202,6 +4206,7 @@ bool Parms::setFromFile ( void *THIS ,
strcpy ( g_conf.m_masterPwds[0] , "footbar23" );
g_conf.m_numMasterPwds = 1;
}
*/
return true;
}
@ -8490,7 +8495,7 @@ void Parms::init ( ) {
m->m_title = "Admin Passwords";
m->m_desc = "Passwords allowed to change Gigablast's general "
"parameters and also the parameters for any collection. "
"If no AdminPassword or Admin IP is specified then "
"If no Admin Password or Admin IP is specified then "
"Gigablast will only allow local IPs to connect to it "
"as the master admin.";
m->m_cgi = "mpwd";

View File

@ -229,6 +229,12 @@
# comma-separated strings on the same line. ('\n' = OR, ',' = AND)
<banRegex><![CDATA[]]></>
# Passwords allowed to change Gigablast's general parameters and also the
# parameters for any collection. If no Admin Password or Admin IP is specified
# then Gigablast will only allow local IPs to connect to it as the master
# admin.
# Use <masterPassword> tag.
# Any IPs in this list will have administrative access to the Gigablast search
# engine.
# Use <adminIp> tag.

View File

@ -9,7 +9,7 @@ a{cursor:hand;cursor:pointer;text-decoration:none;color:blue;}
<body>
<center>
<a href=/>
<img src=http://www.gigablast.com/logo-med.jpg height=122 width=500>
<img src=/logo-med.jpg height=122 width=500>
</a>
</center>
<br>

View File

@ -9,7 +9,7 @@ a{cursor:hand;cursor:pointer;text-decoration:none;color:blue;}
<body>
<center>
<a href=/>
<img src=http://www.gigablast.com/logo-med.jpg height=122 width=500>
<img src=/logo-med.jpg height=122 width=500>
</a>
</center>
<br>

View File

@ -10,7 +10,7 @@ a{cursor:hand;cursor:pointer;text-decoration:none;color:blue;}
<body>
<center>
<a href=/>
<img src=http://www.gigablast.com/logo-med.jpg height=122 width=500>
<img src=/logo-med.jpg height=122 width=500>
</a>
</center>
<br>

View File

@ -6,7 +6,7 @@
<center>
<a href=/>
<img src=http://www.gigablast.com/logo-med.jpg height=122 width=500>
<img src=/logo-med.jpg height=122 width=500>
</a>
</center>
<br>