basic admin controls page structure

This commit is contained in:
Matt Wells 2014-02-08 00:34:45 -07:00
parent fc47c18aec
commit dabd691626
6 changed files with 100 additions and 35 deletions

@ -4510,3 +4510,43 @@ bool setSpiderParmsFromHtmlRequest ( TcpSocket *socket ,
//bool sendPageLast100Urls ( TcpSocket *socket , HttpRequest *hr ) {
//
// BASIC admin controls
//
bool sendPageBasic ( TcpSocket *socket , HttpRequest *hr ) {
char buf [ 128000 ];
SafeBuf sb(buf,128000);
char *fs = hr->getString("format",NULL,NULL);
char fmt = FMT_HTML;
if ( fs && strcmp(fs,"html") == 0 ) fmt = FMT_HTML;
if ( fs && strcmp(fs,"json") == 0 ) fmt = FMT_JSON;
if ( fs && strcmp(fs,"xml") == 0 ) fmt = FMT_XML;
// print standard header
if ( fmt == FMT_HTML )
g_pages.printAdminTop ( &sb , socket , hr );
sb.safePrintf("BASIC CONTROLS");
if ( fmt == FMT_HTML ) sb.safePrintf ( "<br><br>\n" );
if ( fmt != FMT_JSON )
// wrap up the form, print a submit button
g_pages.printAdminBottom ( &sb );
return g_httpServer.sendDynamicPage ( socket,
sb.getBufStart() ,
sb.length() ,
-1 ,
false,//POSTReply ,
NULL , // contType
-1 , // httpstatus
NULL,//cookie ,
NULL );// charset
}

@ -1259,7 +1259,7 @@ bool gotResults ( void *state ) {
if ( isAdmin ) {
sb.safePrintf(" &nbsp; "
"<font color=red><b>"
"<a href=\"/master?c=%s\">"
"<a href=\"/admin/basic?c=%s\">"
"[admin]"
"</a></b></font>",coll);
// print reindex link
@ -1323,7 +1323,7 @@ bool gotResults ( void *state ) {
// get the filename directly
sb.safePrintf (" &nbsp; "
"<font color=red><b>"
"<a href=\"/master/tagdb?"
"<a href=\"/admin/tagdb?"
"tagtype0=manualban&"
"tagdata0=1&"
"c=%s\">"
@ -1340,7 +1340,7 @@ bool gotResults ( void *state ) {
*sp = '\0';
sb.safePrintf (" &nbsp; "
"<font color=red><b>"
"<a href=\"/master/tagdb?"
"<a href=\"/admin/tagdb?"
//"tagid0=%li&"
"tagtype0=manualban&"
"tagdata0=1&"
@ -1646,7 +1646,7 @@ bool gotResults ( void *state ) {
if ( isAdmin && banSites.length() > 0 )
sb.safePrintf ("<br><br><div align=right><b>"
"<a href=\"/master/tagdb?"
"<a href=\"/admin/tagdb?"
//"tagid0=%li&"
"tagtype0=manualban&"
"tagdata0=1&"
@ -2626,13 +2626,13 @@ static bool printResult ( SafeBuf &sb,
// . if it's local, don't put the hostname/port in
// there cuz it will mess up Global Spec's machine
//if ( h->m_groupId == g_hostdb.m_groupId )
sb.safePrintf(" - <a href=\"/master/titledb?c=%s&"
sb.safePrintf(" - <a href=\"/admin/titledb?c=%s&"
"d=%lli",coll,mr->m_docId);
// then the [info] link to show the TitleRec
sb.safePrintf ( "\">[info]</a>" );
// now the analyze link
sb.safePrintf (" - <a href=\"/master/parser?c=%s&"
sb.safePrintf (" - <a href=\"/admin/parser?c=%s&"
"old=1&hc=%li&u=",
coll,
(long)mr->m_hopcount);
@ -2675,7 +2675,7 @@ static bool printResult ( SafeBuf &sb,
banVal = 0;
}
sb.safePrintf(" - "
" <a href=\"/master/tagdb?"
" <a href=\"/admin/tagdb?"
"user=admin&"
"tagtype0=manualban&"
"tagdata0=%li&"
@ -2692,7 +2692,7 @@ static bool printResult ( SafeBuf &sb,
memcpy ( dbuf , uu.getHost() , dlen );
dbuf [ dlen ] = '\0';
sb.safePrintf(" - "
" <a href=\"/master/tagdb?"
" <a href=\"/admin/tagdb?"
"user=admin&"
"tagtype0=manualban&"
"tagdata0=%li&"

@ -79,7 +79,7 @@ bool printNav ( SafeBuf &sb , HttpRequest *r ) {
);
if ( r->isLocal() )
sb.safePrintf("&nbsp; &nbsp;[<a href=\"/master?\">Admin</a>]");
sb.safePrintf("&nbsp; &nbsp;[<a href=\"/admin/basic\">Admin</a>]");
sb.safePrintf("</p></b></center></body></html>");
return true;
}

@ -94,37 +94,41 @@ static WebPage s_pages[] = {
// "word vectors page",
// sendPageWordVec , 0 } ,
{ PAGE_MASTER , "master" , 0 , "master controls" , 1 , 0 ,
{ PAGE_BASIC , "admin/basic" , 0 , "basic controls" , 1 , 0 ,
"basic controls page",
sendPageBasic , 0 } ,
{ PAGE_MASTER , "admin/master" , 0 , "master controls" , 1 , 0 ,
//USER_MASTER | USER_PROXY ,
"master controls page",
sendPageGeneric , 0 } ,
{ PAGE_HOSTS , "master/hosts" , 0 , "hosts" , 0 , 0 ,
{ PAGE_HOSTS , "admin/hosts" , 0 , "hosts" , 0 , 0 ,
//USER_MASTER | USER_PROXY,
"hosts page",
sendPageHosts , 0 } ,
// master admin pages
{ PAGE_STATS , "master/stats" , 0 , "stats" , 0 , 0 ,
{ PAGE_STATS , "admin/stats" , 0 , "stats" , 0 , 0 ,
//USER_MASTER | USER_PROXY ,
"statistics page",
sendPageStats , 0 } ,
{ PAGE_STATSDB , "master/statsdb" , 0 , "graph" , 0 , 0 ,
{ PAGE_STATSDB , "admin/statsdb" , 0 , "graph" , 0 , 0 ,
//USER_MASTER ,
"statistics page",
sendPageStatsdb , 2 /*niceness*/ },
{ PAGE_PERF , "master/perf" , 0 , "performance" , 0 , 0 ,
{ PAGE_PERF , "admin/perf" , 0 , "performance" , 0 , 0 ,
//USER_MASTER | USER_PROXY ,
"master performance page",
sendPagePerf , 0 } ,
{ PAGE_SOCKETS , "master/sockets" , 0 , "sockets" , 0 , 0 ,
{ PAGE_SOCKETS , "admin/sockets" , 0 , "sockets" , 0 , 0 ,
//USER_MASTER | USER_PROXY,
"sockets page",
sendPageSockets , 0 } ,
{ PAGE_LOG , "master/log" , 0 , "log controls" , 1 , 0 ,
{ PAGE_LOG , "admin/log" , 0 , "log controls" , 1 , 0 ,
//USER_MASTER | USER_PROXY,
"log page",
sendPageGeneric , 0 } ,
@ -137,24 +141,24 @@ static WebPage s_pages[] = {
// "sync page",
// sendPageGeneric , 0 } ,
{ PAGE_SECURITY, "master/security", 0 , "security" , 1 , 0 ,
{ PAGE_SECURITY, "admin/security", 0 , "security" , 1 , 0 ,
//USER_MASTER | USER_PROXY ,
"master security page",
sendPageGeneric , 0 } ,
{ PAGE_ADDCOLL , "master/addcoll" , 0 , "add collection" , 1 , 0 ,
{ PAGE_ADDCOLL , "admin/addcoll" , 0 , "add collection" , 1 , 0 ,
//USER_MASTER ,
"add a new collection using this page",
sendPageAddColl , 0 } ,
{ PAGE_DELCOLL , "master/delcoll" , 0 , "delete collections" , 1 ,0,
{ PAGE_DELCOLL , "admin/delcoll" , 0 , "delete collections" , 1 ,0,
//USER_MASTER ,
"delete a collection using this page",
sendPageDelColl , 0 } ,
{ PAGE_AUTOBAN ,"master/autoban" , 0 , "autoban" , 1 , 1 ,
{ PAGE_AUTOBAN ,"admin/autoban" , 0 , "autoban" , 1 , 1 ,
//USER_MASTER | USER_PROXY ,
"autobanned ips",
sendPageAutoban , 0 },
/*
{ PAGE_SPIDERLOCKS,"master/spiderlocks" , 0 , "spider locks" , 0 , 0 ,
{ PAGE_SPIDERLOCKS,"admin/spiderlocks" , 0 , "spider locks" , 0 , 0 ,
USER_MASTER , sendPageSpiderLocks , 0 },
*/
{ PAGE_PROFILER , "admin/profiler" , 0 , "profiler" , 0 , 1 ,
@ -165,11 +169,11 @@ static WebPage s_pages[] = {
//USER_MASTER ,
"threads page",
sendPageThreads , 0 },
{ PAGE_REPAIR , "master/repair" , 0 , "repair" , 1 , 0 ,
{ PAGE_REPAIR , "admin/repair" , 0 , "repair" , 1 , 0 ,
//USER_MASTER ,
"repair page",
sendPageGeneric , 0 },
//{ PAGE_THESAURUS, "master/thesaurus", 0 , "thesaurus", 0 , 0 ,
//{ PAGE_THESAURUS, "admin/thesaurus", 0 , "thesaurus", 0 , 0 ,
// //USER_MASTER ,
// "thesaurus page",
// sendPageThesaurus , 0 },
@ -188,11 +192,11 @@ static WebPage s_pages[] = {
//USER_ADMIN | USER_MASTER ,
"site rules page",
sendPageGeneric , 0} ,
{ PAGE_INDEXDB , "master/indexdb" , 0 , "indexdb" , 0 , 0,
{ PAGE_INDEXDB , "admin/indexdb" , 0 , "indexdb" , 0 , 0,
//USER_MASTER ,
"indexdb page",
sendPageIndexdb , 0 } ,
{ PAGE_TITLEDB , "master/titledb" , 0 , "titledb" , 0 , 0,
{ PAGE_TITLEDB , "admin/titledb" , 0 , "titledb" , 0 , 0,
//USER_MASTER ,
"titledb page",
sendPageTitledb , 2 } ,
@ -251,15 +255,15 @@ static WebPage s_pages[] = {
//USER_ADMIN | USER_MASTER ,
"search box",
sendPageResults , 0 } ,
{ PAGE_PARSER , "master/parser" , 0 , "parser" , 0 , 1,
{ PAGE_PARSER , "admin/parser" , 0 , "parser" , 0 , 1,
//USER_MASTER ,
"page parser page",
sendPageParser , 2 } ,
{ PAGE_SITEDB , "master/tagdb" , 0 , "tagdb" , 0 , 1,
{ PAGE_SITEDB , "admin/tagdb" , 0 , "tagdb" , 0 , 1,
//USER_MASTER | USER_ADMIN,
"tagdb page to add/remove/get tags",
sendPageTagdb , 0} ,
{ PAGE_CATDB , "master/catdb" , 0 , "catdb" , 0 , 1,
{ PAGE_CATDB , "admin/catdb" , 0 , "catdb" , 0 , 1,
//USER_MASTER | USER_ADMIN,
"catdb page",
sendPageCatdb , 0 } ,
@ -1047,11 +1051,24 @@ bool Pages::printAdminTop (SafeBuf *sb ,
if ( adds )
sb->safePrintf("<br>%s",mb.getBufStart());
// print the links
status &= printAdminLinks ( sb, page , username , coll , pwd, true );
// print the links
status &= printAdminLinks ( sb, page , username , coll ,pwd , false );
// print Basic | Advanced links
if ( page == PAGE_BASIC ) {
sb->safePrintf ( "<b><font color=red>Basic</font></b>"
" &nbsp; "
"<b><a href=/admin/master>Advanced</a>"
);
}
else {
sb->safePrintf ( "<a href=/admin/basic><b>Basic</b></a>"
" &nbsp; "
"<b>Advanced</b>"
"<br><br>"
);
// print the links
status &= printAdminLinks ( sb, page , NULL,coll,NULL, true );
// print the links
status &= printAdminLinks ( sb, page , NULL,coll,NULL, false );
}
// begin 2nd row in big table
sb->safePrintf("</td></TR>");

@ -26,6 +26,7 @@ extern char *g_msg;
// . declare all dynamic functions here
// . these are all defined in Page*.cpp files
// . these are called to send a dynamic page
bool sendPageBasic ( TcpSocket *s , HttpRequest *r );
bool sendPageRoot ( TcpSocket *s , HttpRequest *r );
bool sendPageRoot ( TcpSocket *s , HttpRequest *r, char *cookie );
bool sendPageResults ( TcpSocket *s , HttpRequest *r );
@ -292,7 +293,10 @@ enum {
PAGE_DIRECTORY ,
PAGE_REPORTSPAM ,
//PAGE_WORDVECTOR ,
// basic controls page /admin/basic
PAGE_BASIC ,
// master admin pages
PAGE_MASTER ,
PAGE_HOSTS ,

@ -51,7 +51,7 @@
<readOnlyMode>0</>
# Controls all spidering for all collections
<spideringEnabled>1</>
<spideringEnabled>0</>
# What is the maximum number of web pages the spider is allowed to download
# simultaneously for ALL collections PER HOST?
@ -229,6 +229,10 @@
# comma-separated strings on the same line. ('\n' = OR, ',' = AND)
<banRegex><![CDATA[]]></>
# Any IPs in this list will have administrative access to the Gigablast search
# engine.
# Use <adminIp> tag.
# Log GET and POST requests received from the http server?
<logHttpRequests>1</>