PageRenderTime 76ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 0ms

/PageRoot.cpp

https://github.com/gigablast/open-source-search-engine
C++ | 3434 lines | 1560 code | 341 blank | 1533 comment | 205 complexity | c7c3cacbb1af6425871752ada1930fa5 MD5 | raw file
Possible License(s): Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. #include "gb-include.h"
  2. #include "Indexdb.h" // makeKey(int64_t docId)
  3. #include "Titledb.h"
  4. #include "Spider.h"
  5. #include "Tagdb.h"
  6. #include "Dns.h"
  7. //#include "PageResults.h" // for query buf, g_qbuf
  8. #include "Collectiondb.h"
  9. //#include "CollectionRec.h"
  10. #include "Clusterdb.h" // for getting # of docs indexed
  11. //#include "Checksumdb.h" // should migrate to this one, though
  12. #include "Pages.h"
  13. #include "Query.h" // MAX_QUERY_LEN
  14. #include "SafeBuf.h"
  15. #include "LanguageIdentifier.h"
  16. #include "LanguagePages.h"
  17. #include "Users.h"
  18. #include "Address.h" // getIPLocation
  19. #include "Proxy.h"
  20. //char *printNumResultsDropDown ( char *p, int32_t n, bool *printedDropDown);
  21. bool printNumResultsDropDown ( SafeBuf& sb, int32_t n, bool *printedDropDown);
  22. //static char *printTopDirectory ( char *p, char *pend );
  23. static bool printTopDirectory ( SafeBuf& sb , char format );
  24. // this prints the last five queries
  25. //static int32_t printLastQueries ( char *p , char *pend ) ;
  26. //static char *expandRootHtml ( char *p , int32_t plen ,
  27. /*
  28. static bool expandRootHtml ( SafeBuf& sb,
  29. uint8_t *html , int32_t htmlLen ,
  30. char *q , int32_t qlen ,
  31. HttpRequest *r ,
  32. TcpSocket *s ,
  33. int64_t docsInColl ,
  34. CollectionRec *cr ) ;
  35. */
  36. bool sendPageRoot ( TcpSocket *s, HttpRequest *r ){
  37. return sendPageRoot ( s, r, NULL );
  38. }
  39. bool printNav ( SafeBuf &sb , HttpRequest *r ) {
  40. /*
  41. char *root = "";
  42. char *rootSecure = "";
  43. if ( g_conf.m_isMattWells ) {
  44. root = "http://www.gigablast.com";
  45. rootSecure = "https://www.gigablast.com";
  46. }
  47. sb.safePrintf("<center><b><p class=nav>"
  48. "<a href=%s/about.html>About</a>"
  49. " &nbsp; &nbsp; "
  50. "<a href=%s/contact.html>Contact</a>"
  51. " &nbsp; &nbsp; "
  52. "<a href=%s/help.html>Help</a>"
  53. " &nbsp; &nbsp; "
  54. "<a href=%s/privacy.html>Privacy Policy</a>"
  55. " &nbsp; &nbsp; "
  56. // TODO: API page must also provide a description
  57. // of the output... like searchfeed.html does already.
  58. // put that in the api page as well.
  59. "<a href=%s/api>API</a>"
  60. , root
  61. , root
  62. , root
  63. , root
  64. , root
  65. );
  66. if ( g_conf.m_isMattWells )
  67. sb.safePrintf(" &nbsp; &nbsp; "
  68. "<a href=%s/seoapi.html>SEO API</a>"
  69. " &nbsp; &nbsp; "
  70. "<a href=%s/account>My Account</a> "
  71. , root
  72. , rootSecure
  73. //" &nbsp; &nbsp; <a href=/logout>Logout</a>"
  74. );
  75. //if ( r->isLocal() )
  76. sb.safePrintf("&nbsp; &nbsp; &nbsp; [<a style=color:green; "
  77. "href=\"/admin/settings\">"
  78. "Admin</a>]");
  79. sb.safePrintf("</p></b></center>");
  80. */
  81. sb.safePrintf("</TD></TR></TABLE>"
  82. "</body></html>");
  83. return true;
  84. }
  85. //////////////
  86. //
  87. // BEGIN expandHtml() helper functions
  88. //
  89. //////////////
  90. bool printFamilyFilter ( SafeBuf& sb , bool familyFilterOn ) {
  91. char *s1 = "";
  92. char *s2 = "";
  93. if ( familyFilterOn ) s1 = " checked";
  94. else s2 = " checked";
  95. //p += sprintf ( p ,
  96. return sb.safePrintf (
  97. "Family filter: "
  98. "<input type=radio name=ff value=1%s>On &nbsp; "
  99. "<input type=radio name=ff value=0%s>Off &nbsp; " ,
  100. s1 , s2 );
  101. //return p;
  102. }
  103. //char *printNumResultsDropDown ( char *p , int32_t n , bool *printedDropDown ) {
  104. bool printNumResultsDropDown ( SafeBuf& sb , int32_t n , bool *printedDropDown ) {
  105. if ( n!=10 && n!=20 && n!=30 && n!=50 && n!=100 )
  106. //return p;
  107. return true;
  108. *printedDropDown = true;
  109. char *d1 = "";
  110. char *d2 = "";
  111. char *d3 = "";
  112. char *d4 = "";
  113. char *d5 = "";
  114. if ( n == 10 ) d1 = " selected";
  115. if ( n == 20 ) d2 = " selected";
  116. if ( n == 30 ) d3 = " selected";
  117. if ( n == 50 ) d4 = " selected";
  118. if ( n ==100 ) d5 = " selected";
  119. //p += sprintf ( p ,
  120. return sb.safePrintf (
  121. "<select name=n>\n"
  122. "<option value=10%s>10\n"
  123. "<option value=20%s>20\n"
  124. "<option value=30%s>30\n"
  125. "<option value=50%s>50\n"
  126. "<option value=100%s>100\n"
  127. "</select>",
  128. d1,d2,d3,d4,d5);
  129. //return p;
  130. }
  131. //char *printDirectorySearchType ( char *p, int32_t sdirt ) {
  132. bool printDirectorySearchType ( SafeBuf& sb, int32_t sdirt ) {
  133. // default to entire directory
  134. if (sdirt < 1 || sdirt > 4)
  135. sdirt = 3;
  136. // by default search the whole thing
  137. sb.safePrintf("<input type=\"radio\" name=\"sdirt\" value=\"3\"");
  138. if (sdirt == 3) sb.safePrintf(" checked>");
  139. else sb.safePrintf(">");
  140. sb.safePrintf("Entire Directory<br>\n");
  141. // entire category
  142. sb.safePrintf("<input type=\"radio\" name=\"sdirt\" value=\"1\"");
  143. if (sdirt == 1) sb.safePrintf(" checked>");
  144. else sb.safePrintf(">");
  145. sb.safePrintf("Entire Category<br>\n");
  146. // base category only
  147. sb.safePrintf("<nobr><input type=\"radio\" name=\"sdirt\" value=\"2\"");
  148. if (sdirt == 2) sb.safePrintf(" checked>");
  149. else sb.safePrintf(">");
  150. sb.safePrintf("Pages in Base Category</nobr><br>\n");
  151. // sites in base category
  152. sb.safePrintf("<input type=\"radio\" name=\"sdirt\" value=\"7\"");
  153. if (sdirt == 7) sb.safePrintf(" checked>");
  154. else sb.safePrintf(">");
  155. sb.safePrintf("Sites in Base Category<br>\n");
  156. // sites in entire category
  157. sb.safePrintf("<input type=\"radio\" name=\"sdirt\" value=\"6\"");
  158. if (sdirt == 6) sb.safePrintf(" checked>");
  159. else sb.safePrintf(">");
  160. sb.safePrintf("Sites in Entire Category<br>\n");
  161. // end it
  162. return true;
  163. }
  164. #include "SearchInput.h"
  165. bool printRadioButtons ( SafeBuf& sb , SearchInput *si ) {
  166. // don't display this for directory search
  167. // look it up. returns catId <= 0 if dmoz not setup yet.
  168. // From PageDirectory.cpp
  169. //int32_t catId= g_categories->getIdFromPath(decodedPath, decodedPathLen);
  170. // if /Top print the directory homepage
  171. //if ( catId == 1 || catId <= 0 )
  172. // return true;
  173. // site
  174. /*
  175. if ( si->m_siteLen > 0 ) {
  176. // . print rest of search box etc.
  177. // . print cobranding radio buttons
  178. //if ( p + si->m_siteLen + 1 >= pend ) return p;
  179. //p += sprintf ( p ,
  180. return sb.safePrintf (
  181. //" &nbsp; "
  182. //"<font size=-1>"
  183. //"<b><a href=\"/\"><font color=red>"
  184. //"Powered by Gigablast</font></a></b>"
  185. //"<br>"
  186. //"<tr align=center><td></td><td>"
  187. "<input type=radio name=site value=\"\">"
  188. "Search the Web "
  189. "<input type=radio name=site "
  190. "value=\"%s\" checked>Search %s" ,
  191. //"</td></tr></table><br>"
  192. //"</td></tr>"
  193. //"<font size=-1>" ,
  194. si->m_site , si->m_site );
  195. }
  196. else if ( si->m_sitesLen > 0 ) {
  197. */
  198. if ( si->m_sites && si->m_sites[0] ) {
  199. // . print rest of search box etc.
  200. // . print cobranding radio buttons
  201. //if ( p + si->m_sitesLen + 1 >= pend ) return p;
  202. // if not explicitly instructed to print all sites
  203. // and they are a int32_t list, do not print all
  204. /*
  205. char tmp[1000];
  206. char *x = si->m_sites;
  207. if ( si->m_sitesLen > 255){//&&!st->m_printAllSites){
  208. // copy what's there
  209. strncpy ( tmp , si->m_sites , 255 );
  210. x = tmp + 254 ;
  211. // do not hack off in the middle of a site
  212. while ( is_alnum(*x) && x > tmp ) x--;
  213. // overwrite it with [more] link
  214. //x += sprintf ( x , "<a href=\"/search?" );
  215. // our current query parameters
  216. //if ( x + uclen + 10 >= xend ) goto skipit;
  217. sprintf ( x , " ..." );
  218. x = tmp;
  219. }
  220. */
  221. //p += sprintf ( p ,
  222. sb.safePrintf (
  223. //" &nbsp; "
  224. //"<font size=-1>"
  225. //"<b><a href=\"/\"><font color=red>"
  226. //"Powered by Gigablast</font></a></b>"
  227. //"<br>"
  228. //"<tr align=center><td></td><td>"
  229. "<input type=radio name=sites value=\"\">"
  230. "Search the Web "
  231. "<input type=radio name=sites "
  232. "value=\"%s\" checked>Search ",
  233. //"</td></tr></table><br>"
  234. //"</td></tr>"
  235. //"<font size=-1>" ,
  236. si->m_sites );
  237. sb.safeTruncateEllipsis ( si->m_sites, 255 );
  238. }
  239. return true;
  240. }
  241. bool printLogo ( SafeBuf& sb , SearchInput *si ) {
  242. // if an image was provided...
  243. if ( ! si->m_imgUrl || ! si->m_imgUrl[0] ) {
  244. // no, now we default to our logo
  245. //return true;
  246. //p += sprintf ( p ,
  247. return sb.safePrintf (
  248. "<a href=\"/\">"
  249. "<img valign=top width=250 height=61 border=0 "
  250. // avoid https for this, so make it absolute
  251. "src=\"/logo-med.jpg\"></a>" );
  252. //return p;
  253. }
  254. // do we have a link?
  255. if ( si->m_imgLink && si->m_imgLink[0])
  256. //p += sprintf ( p , "<a href=\"%s\">",si->m_imgLink);
  257. sb.safePrintf ( "<a href=\"%s\">", si->m_imgLink );
  258. // print image width and length
  259. if ( si->m_imgWidth >= 0 && si->m_imgHeight >= 0 )
  260. //p += sprintf ( p , "<img width=%"INT32" height=%"INT32" ",
  261. sb.safePrintf( "<img width=%"INT32" height=%"INT32" ",
  262. si->m_imgWidth , si->m_imgHeight );
  263. else
  264. //p += sprintf ( p , "<img " );
  265. sb.safePrintf ( "<img " );
  266. //p += sprintf ( p , "border=0 src=\"%s\">",
  267. sb.safePrintf( "border=0 src=\"%s\">",
  268. si->m_imgUrl );
  269. // end the link if we had one
  270. if ( si->m_imgLink && si->m_imgLink[0] )
  271. //p += sprintf ( p , "</a>");
  272. sb.safePrintf ( "</a>");
  273. return true;
  274. }
  275. /////////////
  276. //
  277. // END expandHtml() helper functions
  278. //
  279. /////////////
  280. bool expandHtml ( SafeBuf& sb,
  281. char *head ,
  282. int32_t hlen ,
  283. char *q ,
  284. int32_t qlen ,
  285. HttpRequest *r ,
  286. SearchInput *si,
  287. char *method ,
  288. CollectionRec *cr ) {
  289. //char *pend = p + plen;
  290. // store custom header into buf now
  291. //for ( int32_t i = 0 ; i < hlen && p+10 < pend ; i++ ) {
  292. for ( int32_t i = 0 ; i < hlen; i++ ) {
  293. if ( head[i] != '%' ) {
  294. // *p++ = head[i];
  295. sb.safeMemcpy((char*)&head[i], 1);
  296. continue;
  297. }
  298. if ( i + 1 >= hlen ) {
  299. // *p++ = head[i];
  300. sb.safeMemcpy((char*)&head[i], 1);
  301. continue;
  302. }
  303. if ( head[i+1] == 'S' ) {
  304. // now we got the %S, insert "spiders are [on/off]"
  305. bool spidersOn = true;
  306. if ( ! g_conf.m_spideringEnabled ) spidersOn = false;
  307. if ( ! cr->m_spideringEnabled ) spidersOn = false;
  308. if ( spidersOn )
  309. sb.safePrintf("Spiders are on");
  310. else
  311. sb.safePrintf("Spiders are off");
  312. // skip over %S
  313. i += 1;
  314. continue;
  315. }
  316. if ( head[i+1] == 'q' ) {
  317. // now we got the %q, insert the query
  318. char *p = (char*) sb.getBuf();
  319. char *pend = (char*) sb.getBufEnd();
  320. int32_t eqlen = dequote ( p , pend , q , qlen );
  321. //p += eqlen;
  322. sb.incrementLength(eqlen);
  323. // skip over %q
  324. i += 1;
  325. continue;
  326. }
  327. if ( head[i+1] == 'c' ) {
  328. // now we got the %q, insert the query
  329. if ( cr ) sb.safeStrcpy(cr->m_coll);
  330. // skip over %c
  331. i += 1;
  332. continue;
  333. }
  334. if ( head[i+1] == 'w' &&
  335. head[i+2] == 'h' &&
  336. head[i+3] == 'e' &&
  337. head[i+4] == 'r' &&
  338. head[i+5] == 'e' ) {
  339. // insert the location
  340. int32_t whereLen;
  341. char *where = r->getString("where",&whereLen);
  342. // get it from cookie as well!
  343. if ( ! where )
  344. where = r->getStringFromCookie("where",
  345. &whereLen);
  346. // fix for getStringFromCookie
  347. if ( where && ! where[0] ) where = NULL;
  348. // skip over the %where
  349. i += 5;
  350. // if empty, base it on IP
  351. if ( ! where ) {
  352. double lat;
  353. double lon;
  354. double radius;
  355. char *city,*state,*ctry;
  356. // use this by default
  357. int32_t ip = r->m_userIP;
  358. // ip for testing?
  359. int32_t iplen;
  360. char *ips = r->getString("uip",&iplen);
  361. if ( ips ) ip = atoip(ips);
  362. // returns true if found in db
  363. char buf[128];
  364. getIPLocation ( ip ,
  365. &lat ,
  366. &lon ,
  367. &radius,
  368. &city ,
  369. &state ,
  370. &ctry ,
  371. buf ,
  372. 128 ) ;
  373. if ( city && state )
  374. sb.safePrintf("%s, %s",city,state);
  375. }
  376. else
  377. sb.dequote (where,whereLen);
  378. continue;
  379. }
  380. if ( head[i+1] == 'w' &&
  381. head[i+2] == 'h' &&
  382. head[i+3] == 'e' &&
  383. head[i+4] == 'n' ) {
  384. // insert the location
  385. int32_t whenLen;
  386. char *when = r->getString("when",&whenLen);
  387. // skip over the %when
  388. i += 4;
  389. if ( ! when ) continue;
  390. sb.dequote (when,whenLen);
  391. continue;
  392. }
  393. // %sortby
  394. if ( head[i+1] == 's' &&
  395. head[i+2] == 'o' &&
  396. head[i+3] == 'r' &&
  397. head[i+4] == 't' &&
  398. head[i+5] == 'b' &&
  399. head[i+6] == 'y' ) {
  400. // insert the location
  401. int32_t sortBy = r->getLong("sortby",1);
  402. // print the radio buttons
  403. char *cs[5];
  404. cs[0]="";
  405. cs[1]="";
  406. cs[2]="";
  407. cs[3]="";
  408. cs[4]="";
  409. if ( sortBy >=1 && sortBy <=4 )
  410. cs[sortBy] = " checked";
  411. sb.safePrintf(
  412. "<input type=radio name=sortby value=1%s>date "
  413. "<input type=radio name=sortby value=2%s>distance "
  414. "<input type=radio name=sortby value=3%s>relevancy "
  415. "<input type=radio name=sortby value=4%s>popularity",
  416. cs[1],cs[2],cs[3],cs[4]);
  417. // skip over the %sortby
  418. i += 6;
  419. continue;
  420. }
  421. if ( head[i+1] == 'e' ) {
  422. // now we got the %e, insert the query
  423. char *p = (char*) sb.getBuf();
  424. int32_t plen = sb.getAvail();
  425. int32_t eqlen = urlEncode ( p , plen , q , qlen );
  426. //p += eqlen;
  427. sb.incrementLength(eqlen);
  428. // skip over %e
  429. i += 1;
  430. continue;
  431. }
  432. if ( head[i+1] == 'N' ) {
  433. // now we got the %N, insert the global doc count
  434. //int64_t c=g_checksumdb.getRdb()->getNumGlobalRecs();
  435. //now each host tells us how many docs it has in itsping
  436. int64_t c = g_hostdb.getNumGlobalRecs();
  437. c += g_conf.m_docCountAdjustment;
  438. // never allow to go negative
  439. if ( c < 0 ) c = 0;
  440. //p+=ulltoa(p,c);
  441. char *p = (char*) sb.getBuf();
  442. sb.reserve2x(16);
  443. int32_t len = ulltoa(p, c);
  444. sb.incrementLength(len);
  445. // skip over %N
  446. i += 1;
  447. continue;
  448. }
  449. /*
  450. if ( head[i+1] == 'E' ) {
  451. // now each host tells us how many docs it has in its
  452. // ping request
  453. int64_t c = g_hostdb.getNumGlobalEvents();
  454. char *p = (char*) sb.getBuf();
  455. sb.reserve2x(16);
  456. int32_t len = ulltoa(p, c);
  457. sb.incrementLength(len);
  458. // skip over %E
  459. i += 1;
  460. continue;
  461. }
  462. */
  463. if ( head[i+1] == 'n' ) {
  464. // now we got the %n, insert the collection doc count
  465. //p+=ulltoa(p,docsInColl);
  466. char *p = (char*) sb.getBuf();
  467. sb.reserve2x(16);
  468. int64_t docsInColl = 0;
  469. if ( cr ) docsInColl = cr->getNumDocsIndexed();
  470. int32_t len = ulltoa(p, docsInColl);
  471. sb.incrementLength(len);
  472. // skip over %n
  473. i += 1;
  474. continue;
  475. }
  476. /*
  477. if ( head[i+1] == 'T' ) {
  478. // . print the final tail
  479. // . only print admin link if we're local
  480. //int32_t user = g_pages.getUserType ( s , r );
  481. //char *username = g_users.getUsername(r);
  482. //char *pwd = r->getString ( "pwd" );
  483. char *p = (char*) sb.getBuf();
  484. int32_t plen = sb.getAvail();
  485. //p = g_pages.printTail ( p , p + plen , user , pwd );
  486. char *n = g_pages.printTail(p , p + plen ,
  487. r->isLocal());
  488. sb.incrementLength(n - p);
  489. // skip over %T
  490. i += 1;
  491. continue;
  492. }
  493. */
  494. // print the drop down menu for selecting the # of reslts
  495. if ( head[i+1] == 'D' ) {
  496. // skip over %D
  497. i += 1;
  498. // skip if not enough buffer
  499. //if ( p + 1000 >= pend ) continue;
  500. // # results
  501. //int32_t n = r->getLong("n",10);
  502. //bool printedDropDown;
  503. //p = printNumResultsDropDown(p,n,&printedDropDown);
  504. //printNumResultsDropDown(sb,n,&printedDropDown);
  505. continue;
  506. }
  507. if ( head[i+1] == 'H' ) {
  508. // . insert the secret key here, to stop seo bots
  509. // . TODO: randomize its position to make parsing more
  510. // difficult
  511. // . this secret key is for submitting a new query
  512. // int32_t key;
  513. // char kname[4];
  514. // g_httpServer.getKey (&key,kname,NULL,0,time(NULL),0,
  515. // 10);
  516. //sprintf (p , "<input type=hidden name=%s value=%"INT32">",
  517. // kname,key);
  518. //p += gbstrlen ( p );
  519. // sb.safePrintf( "<input type=hidden name=%s "
  520. //"value=%"INT32">",
  521. // kname,key);
  522. //adds param for default screen size
  523. //if(cr)
  524. // sb.safePrintf("<input type=hidden "
  525. //"id='screenWidth' name='ws' value=%"INT32">",
  526. //cr->m_screenWidth);
  527. // insert collection name too
  528. int32_t collLen;
  529. char *coll = r->getString ( "c" , &collLen );
  530. if ( collLen > 0 && collLen < MAX_COLL_LEN ) {
  531. //sprintf (p,"<input type=hidden name=c "
  532. // "value=\"");
  533. //p += gbstrlen ( p );
  534. sb.safePrintf("<input type=hidden name=c "
  535. "value=\"");
  536. //gbmemcpy ( p , coll , collLen );
  537. //p += collLen;
  538. sb.safeMemcpy(coll, collLen);
  539. //sprintf ( p , "\">\n");
  540. //p += gbstrlen ( p );
  541. sb.safePrintf("\">\n");
  542. }
  543. // pass this crap on so zak can do searches
  544. //char *username = g_users.getUsername(r);
  545. // this is null because not in the cookie and we are
  546. // logged in
  547. //char *pwd = r->getString ( "pwd" );
  548. //sb.safePrintf("<input type=hidden name=pwd "
  549. //"value=\"%s\">\n",
  550. //pwd);
  551. //sb.safePrintf("<input type=hidden name=username "
  552. // "value=\"%s\">\n",username);
  553. // skip over %H
  554. i += 1;
  555. continue;
  556. }
  557. // %t, print Top Directory section
  558. if ( head[i+1] == 't' ) {
  559. i += 1;
  560. //p = printTopDirectory ( p, pend );
  561. printTopDirectory ( sb , FORMAT_HTML );
  562. continue;
  563. }
  564. // MDW
  565. if ( head[i+1] == 'F' ) {
  566. i += 1;
  567. //p = printTopDirectory ( p, pend );
  568. if ( ! method ) method = "GET";
  569. sb.safePrintf("<form method=%s action=\"/search\" "
  570. "name=\"f\">\n",method);
  571. continue;
  572. }
  573. if ( head[i+1] == 'L' ) {
  574. i += 1;
  575. //p = printTopDirectory ( p, pend );
  576. printLogo ( sb , si );
  577. continue;
  578. }
  579. if ( head[i+1] == 'f' ) {
  580. i += 1;
  581. //p = printTopDirectory ( p, pend );
  582. printFamilyFilter ( sb , si->m_familyFilter );
  583. continue;
  584. }
  585. if ( head[i+1] == 'R' ) {
  586. i += 1;
  587. //p = printTopDirectory ( p, pend );
  588. printRadioButtons ( sb , si );
  589. continue;
  590. }
  591. // MDW
  592. // *p++ = head[i];
  593. sb.safeMemcpy((char*)&head[i], 1);
  594. continue;
  595. }
  596. //return p;
  597. return true;
  598. }
  599. bool printLeftColumnRocketAndTabs ( SafeBuf *sb ,
  600. bool isSearchResultsPage ,
  601. CollectionRec *cr ,
  602. char *tabName ) {
  603. class MenuItem {
  604. public:
  605. char *m_text;
  606. char *m_url;
  607. };
  608. static MenuItem mi[] = {
  609. {"SEARCH","/"},
  610. // {"DISCUSSIONS","/?searchtype=discussions"},
  611. // {"PRODUCTS","/?searchtype=products"},
  612. // {"ARTICLES","/?searchtype=articles"},
  613. // {"IMAGES","/?searchtype=images"},
  614. {"DIRECTORY","/Top"},
  615. {"ADVANCED","/adv.html"},
  616. {"ADD URL","/addurl"},
  617. {"WIDGETS","/widgets.html"},
  618. {"SYNTAX","/syntax.html"},
  619. {"USERS","/users.html"},
  620. {"ABOUT","/about.html"},
  621. {"BLOG","/blog.html"},
  622. // take this out for now
  623. //{"FEED","/searchfeed.html"},
  624. {"FAQ","/faq.html"},
  625. {"API","/api.html"}
  626. };
  627. char *coll = "";
  628. if ( cr ) coll = cr->m_coll;
  629. //
  630. // first the nav column
  631. //
  632. sb->safePrintf(
  633. "<TD bgcolor=#%s " // f3c714 " // yellow/gold
  634. "valign=top "
  635. "style=\"width:210px;"
  636. "border-right:3px solid blue;"
  637. "\">"
  638. "<br>"
  639. "<center>"
  640. "<a href=/?c=%s>"
  641. "<div style=\""
  642. "background-color:white;"
  643. "padding:10px;"
  644. "border-radius:100px;"
  645. "border-color:blue;"
  646. "border-width:3px;"
  647. "border-style:solid;"
  648. "width:100px;"
  649. "height:100px;"
  650. "\">"
  651. , GOLD
  652. , coll
  653. );
  654. if ( strcmp(tabName,"appliance") == 0 )
  655. sb->safePrintf("<img style=margin-top:21px; width=90 "
  656. "height=57 src=/computer2.png>");
  657. else
  658. sb->safePrintf("<br style=line-height:10px;>"
  659. "<img border=0 "
  660. "width=54 height=79 src=/rocket.jpg>"
  661. );
  662. sb->safePrintf ( "</div>"
  663. "</a>"
  664. "</center>"
  665. "<br>"
  666. "<br>"
  667. );
  668. int32_t n = sizeof(mi) / sizeof(MenuItem);
  669. for ( int32_t i = 0 ; i < n ; i++ ) {
  670. // just show search, directory and advanced tab in serps
  671. if ( isSearchResultsPage && i >= 3 ) break;
  672. // what was this for?
  673. // if ( i >= 1 && i <= 4 &&
  674. // cr->m_diffbotApiUrl.length() >= 0 )
  675. // continue;
  676. char delim = '?';
  677. if ( strstr ( mi[i].m_url,"?") ) delim = '&';
  678. sb->safePrintf(
  679. "<a href=%s%cc=%s>"
  680. "<div style=\""
  681. "padding:5px;"
  682. "position:relative;"
  683. "text-align:right;"
  684. "border-width:3px;"
  685. "border-right-width:0px;"
  686. "border-style:solid;"
  687. "margin-left:10px;"
  688. "border-top-left-radius:10px;"
  689. "border-bottom-left-radius:10px;"
  690. "font-size:14px;"
  691. "x-overflow:;"
  692. , mi[i].m_url
  693. , delim
  694. , coll
  695. );
  696. //if ( i == pageNum )
  697. bool matched = false;
  698. if ( strcasecmp(mi[i].m_text,tabName) == 0 )
  699. matched = true;
  700. if ( matched )
  701. sb->safePrintf(
  702. "border-color:blue;"
  703. "color:black;"
  704. "background-color:white;\" ");
  705. else
  706. sb->safePrintf("border-color:white;"
  707. "color:white;"
  708. "background-color:blue;\" "
  709. " onmouseover=\""
  710. "this.style.backgroundColor='lightblue';"
  711. "this.style.color='black';\""
  712. " onmouseout=\""
  713. "this.style.backgroundColor='blue';"
  714. "this.style.color='white';\""
  715. );
  716. sb->safePrintf(">"
  717. // make button wider
  718. "<nobr>"
  719. "&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; "
  720. "<b>%s</b> &nbsp; &nbsp;</nobr>"
  721. , mi[i].m_text
  722. );
  723. //
  724. // begin hack: white out the blue border line!!
  725. //
  726. if ( matched )
  727. sb->safePrintf(
  728. "<div style=padding:5px;top:0;"
  729. "background-color:white;"
  730. "display:inline-block;"
  731. "position:absolute;>"
  732. "&nbsp;"
  733. "</div>"
  734. );
  735. // end hack
  736. sb->safePrintf(
  737. "</div>"
  738. "</a>"
  739. "<br>"
  740. );
  741. }
  742. // admin link
  743. if ( isSearchResultsPage ) return true;
  744. sb->safePrintf(
  745. "<a href=/admin/settings?c=%s>"
  746. "<div style=\"background-color:green;"
  747. // for try it out bubble:
  748. //"position:relative;"
  749. "padding:5px;"
  750. "text-align:right;"
  751. "border-width:3px;"
  752. "border-right-width:0px;"
  753. "border-style:solid;"
  754. "margin-left:10px;"
  755. "border-color:white;"
  756. "border-top-left-radius:10px;"
  757. "border-bottom-left-radius:10px;"
  758. "font-size:14px;"
  759. "color:white;"
  760. "cursor:hand;"
  761. "cursor:pointer;\" "
  762. " onmouseover=\""
  763. "this.style.backgroundColor='lightgreen';"
  764. "this.style.color='black';\""
  765. " onmouseout=\""
  766. "this.style.backgroundColor='green';"
  767. "this.style.color='white';\""
  768. ">"
  769. /*
  770. // try it out bubble div
  771. "<div "
  772. " onmouseover=\""
  773. "this.style.box-shadow='10px 10px 5px #888888';"
  774. "\""
  775. " onmouseout=\""
  776. "this.style.box-shadow='';"
  777. "\""
  778. "style=\""
  779. "vertical-align:middle;"
  780. "text-align:left;"
  781. "cursor:pointer;"
  782. "cursor:hand;"
  783. //"border-color:black;"
  784. //"border-style:solid;"
  785. //"border-width:2px;"
  786. "padding:3px;"
  787. //"width:30px;"
  788. //"height:20px;"
  789. //"margin-top:-20px;"
  790. "margin-left:-120px;"
  791. "position:absolute;"
  792. //"top:-20px;"
  793. //"left:10px;"
  794. "display:inline-block;"
  795. "\""
  796. ">"
  797. "<b style=font-size:11px;>"
  798. "Click for demo"
  799. "</b>"
  800. "</div>"
  801. */
  802. // end try it out bubble div
  803. "<b>ADMIN</b> &nbsp; &nbsp;"
  804. "</div>"
  805. "</a>"
  806. "<br>"
  807. "</TD>"
  808. , coll
  809. );
  810. return true;
  811. }
  812. bool printFrontPageShell ( SafeBuf *sb , char *tabName , CollectionRec *cr ,
  813. bool printGigablast ) {
  814. sb->safePrintf("<html>\n");
  815. sb->safePrintf("<head>\n");
  816. //sb->safePrintf("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf8\">");
  817. sb->safePrintf("<meta name=\"description\" content=\"A powerful, new search engine that does real-time indexing!\">\n");
  818. sb->safePrintf("<meta name=\"keywords\" content=\"search, search engine, search engines, search the web, fresh index, green search engine, green search, clean search engine, clean search\">\n");
  819. //char *title = "An Alternative Open Source Search Engine";
  820. char *title = "An Alternative Open Source Search Engine";
  821. if ( strcasecmp(tabName,"search") ) title = tabName;
  822. // if ( pageNum == 1 ) title = "Directory";
  823. // if ( pageNum == 2 ) title = "Advanced";
  824. // if ( pageNum == 3 ) title = "Add Url";
  825. // if ( pageNum == 4 ) title = "About";
  826. // if ( pageNum == 5 ) title = "Help";
  827. // if ( pageNum == 6 ) title = "API";
  828. sb->safePrintf("<title>Gigablast - %s</title>\n",title);
  829. sb->safePrintf("<style><!--\n");
  830. sb->safePrintf("body {\n");
  831. sb->safePrintf("font-family:Arial, Helvetica, sans-serif;\n");
  832. sb->safePrintf("color: #000000;\n");
  833. sb->safePrintf("font-size: 12px;\n");
  834. sb->safePrintf("margin: 0px 0px;\n");
  835. sb->safePrintf("letter-spacing: 0.04em;\n");
  836. sb->safePrintf("}\n");
  837. sb->safePrintf("a {text-decoration:none;}\n");
  838. //sb->safePrintf("a:link {color:#00c}\n");
  839. //sb->safePrintf("a:visited {color:#551a8b}\n");
  840. //sb->safePrintf("a:active {color:#f00}\n");
  841. sb->safePrintf(".bold {font-weight: bold;}\n");
  842. sb->safePrintf(".bluetable {background:#d1e1ff;margin-bottom:15px;font-size:12px;}\n");
  843. sb->safePrintf(".url {color:#008000;}\n");
  844. sb->safePrintf(".cached, .cached a {font-size: 10px;color: #666666;\n");
  845. sb->safePrintf("}\n");
  846. sb->safePrintf("table {\n");
  847. sb->safePrintf("font-family:Arial, Helvetica, sans-serif;\n");
  848. sb->safePrintf("color: #000000;\n");
  849. sb->safePrintf("font-size: 12px;\n");
  850. sb->safePrintf("}\n");
  851. sb->safePrintf(".directory {font-size: 16px;}\n"
  852. ".nav {font-size:20px;align:right;}\n"
  853. );
  854. sb->safePrintf("-->\n");
  855. sb->safePrintf("</style>\n");
  856. sb->safePrintf("\n");
  857. sb->safePrintf("</head>\n");
  858. sb->safePrintf("<script>\n");
  859. sb->safePrintf("<!--\n");
  860. sb->safePrintf("function x(){document.f.q.focus();}\n");
  861. sb->safePrintf("// --></script>\n");
  862. sb->safePrintf("<body onload=\"x()\">\n");
  863. //sb->safePrintf("<body>\n");
  864. //g_proxy.insertLoginBarDirective ( &sb );
  865. //
  866. // DIVIDE INTO TWO PANES, LEFT COLUMN and MAIN COLUMN
  867. //
  868. sb->safePrintf("<TABLE border=0 height=100%% cellspacing=0 "
  869. "cellpadding=0>"
  870. "\n<TR>\n");
  871. // . also prints <TD>...</TD>
  872. // . false = isSearchResultsPage?
  873. printLeftColumnRocketAndTabs ( sb , false , cr , tabName );
  874. //
  875. // now the MAIN column
  876. //
  877. sb->safePrintf("\n<TD valign=top style=padding-left:30px;>\n");
  878. sb->safePrintf("<br><br>");
  879. if ( ! printGigablast )
  880. return true;
  881. sb->safePrintf("<a href=/><img border=0 width=470 "
  882. "height=44 src=/gigablast.jpg></a>\n");
  883. // sb->safePrintf("<br>"
  884. // "<img border=0 width=470 "
  885. // "height=15 src=/bar.jpg>\n");
  886. return true;
  887. }
  888. bool printWebHomePage ( SafeBuf &sb , HttpRequest *r , TcpSocket *sock ) {
  889. SearchInput si;
  890. si.set ( sock , r );
  891. // if there's a ton of sites use the post method otherwise
  892. // they won't fit into the http request, the browser will reject
  893. // sending such a large request with "GET"
  894. char *method = "GET";
  895. if ( si.m_sites && gbstrlen(si.m_sites)>800 ) method = "POST";
  896. // if the provided their own
  897. CollectionRec *cr = g_collectiondb.getRec ( r );
  898. if ( cr && cr->m_htmlRoot.length() ) {
  899. return expandHtml ( sb ,
  900. cr->m_htmlRoot.getBufStart(),
  901. cr->m_htmlRoot.length(),
  902. NULL,
  903. 0,
  904. r ,
  905. &si,
  906. //TcpSocket *s ,
  907. method , // "GET" or "POST"
  908. cr );//CollectionRec *cr ) {
  909. }
  910. // . search special types
  911. // . defaults to web which is "search"
  912. // . can be like "images" "products" "articles"
  913. char *searchType = r->getString("searchtype",NULL,"search",NULL);
  914. log("searchtype=%s",searchType);
  915. // pass searchType in as tabName
  916. printFrontPageShell ( &sb , searchType , cr , true );
  917. //sb.safePrintf("<br><br>\n");
  918. // try to avoid using https for images. it is like 10ms slower.
  919. // if ( g_conf.m_isMattWells )
  920. // sb.safePrintf("<center><a href=/><img border=0 width=500 "
  921. // "height=122 src=http://www.gigablast.com/logo-"
  922. // "med.jpg></a>\n");
  923. // else
  924. sb.safePrintf("<br><br>\n");
  925. sb.safePrintf("<br><br><br>\n");
  926. /*
  927. sb.safePrintf("<b>web</b> &nbsp;&nbsp;&nbsp;&nbsp; ");
  928. if ( g_conf.m_isMattWells )
  929. sb.safePrintf("<a href=http://www.gigablast.com/seo>seo</a> "
  930. "&nbsp;&nbsp;&nbsp;&nbsp; "
  931. );
  932. sb.safePrintf( "<a href=\"/Top\">directory</a> "
  933. "&nbsp;&nbsp;&nbsp;&nbsp; \n");
  934. sb.safePrintf("<a href=/adv.html>advanced search</a>");
  935. sb.safePrintf(" &nbsp;&nbsp;&nbsp;&nbsp; ");
  936. sb.safePrintf("<a href=/addurl title=\"Instantly add your url to "
  937. "Gigablast's index\">add url</a>");
  938. sb.safePrintf("\n");
  939. sb.safePrintf("<br><br>\n");
  940. */
  941. // submit to https now
  942. sb.safePrintf("<form method=%s "
  943. "action=/search name=f>\n", method);
  944. if ( cr )
  945. sb.safePrintf("<input type=hidden name=c value=\"%s\">",
  946. cr->m_coll);
  947. // put search box in a box
  948. sb.safePrintf("<div style="
  949. "background-color:#%s;"//fcc714;"
  950. "border-style:solid;"
  951. "border-width:3px;"
  952. "border-color:blue;"
  953. //"background-color:blue;"
  954. "padding:20px;"
  955. "border-radius:20px;"
  956. ">"
  957. ,GOLD
  958. );
  959. sb.safePrintf("<input name=q type=text "
  960. "style=\""
  961. //"width:%"INT32"px;"
  962. "height:26px;"
  963. "padding:0px;"
  964. "font-weight:bold;"
  965. "padding-left:5px;"
  966. //"border-radius:10px;"
  967. "margin:0px;"
  968. "border:1px inset lightgray;"
  969. "background-color:#ffffff;"
  970. "font-size:18px;"
  971. "\" "
  972. "size=40 value=\"\">&nbsp; &nbsp;"
  973. //"<input type=\"submit\" value=\"Search\">"
  974. "<div onclick=document.f.submit(); "
  975. " onmouseover=\""
  976. "this.style.backgroundColor='lightgreen';"
  977. "this.style.color='black';\""
  978. " onmouseout=\""
  979. "this.style.backgroundColor='green';"
  980. "this.style.color='white';\" "
  981. "style=border-radius:28px;"
  982. "cursor:pointer;"
  983. "cursor:hand;"
  984. "border-color:white;"
  985. "border-style:solid;"
  986. "border-width:3px;"
  987. "padding:12px;"
  988. "width:20px;"
  989. "height:20px;"
  990. "display:inline-block;"
  991. "background-color:green;color:white;>"
  992. "<b style=margin-left:-5px;font-size:18px;"
  993. ">GO</b>"
  994. "</div>"
  995. "\n"
  996. );
  997. sb.safePrintf("</div>\n");
  998. sb.safePrintf("\n");
  999. sb.safePrintf("</form>\n");
  1000. sb.safePrintf("<br>\n");
  1001. sb.safePrintf("\n");
  1002. if ( cr && cr->m_coll ) { // && strcmp(cr->m_coll,"main") ) {
  1003. sb.safePrintf("<center>"
  1004. "Searching the <b>%s</b> collection."
  1005. "</center>",
  1006. cr->m_coll);
  1007. sb.safePrintf("<br>\n");
  1008. sb.safePrintf("\n");
  1009. }
  1010. // take this out for now
  1011. /*
  1012. // always the option to add event guru to their list of
  1013. // search engine in their browser
  1014. sb.safePrintf("<br>"
  1015. //"<br>"
  1016. "<script>\n"
  1017. "function addEngine() {\n"
  1018. "if (window.external && "
  1019. "('AddSearchProvider' in window.external)) {\n"
  1020. // Firefox 2 and IE 7, OpenSearch
  1021. "window.external.AddSearchProvider('http://"
  1022. "www.gigablast.com/searchbar.xml');\n"
  1023. "}\n"
  1024. "else if (window.sidebar && ('addSearchEngine' "
  1025. "in window.sidebar)) {\n"
  1026. // Firefox <= 1.5, Sherlock
  1027. "window.sidebar.addSearchEngine('http://"
  1028. "www.gigablast.com/searchbar.xml',"
  1029. //"example.com/search-plugin.src',"
  1030. "'http://www.gigablast.com/rocket.jpg'," //guru.png
  1031. "'Search Plugin', '');\n"
  1032. "}\n"
  1033. "else {"
  1034. // No search engine support (IE 6, Opera, etc).
  1035. "alert('No search engine support');\n"
  1036. "}\n"
  1037. // do not ask again if they tried to add it
  1038. // meta cookie should store this
  1039. //"document.getElementById('addedse').value='1';\n"
  1040. // NEVER ask again! permanent cookie
  1041. "document.cookie = 'didse=3';"
  1042. // make it invisible again
  1043. //"var e = document.getElementById('addse');\n"
  1044. //"e.style.display = 'none';\n"
  1045. "}\n"
  1046. "</script>\n"
  1047. "<center>"
  1048. "<a onclick='addEngine();' style="
  1049. "cursor:pointer;"
  1050. "cursor:hand;"
  1051. "color:blue;"
  1052. ">"
  1053. "<img height=16 width=16 border=0 src=/rocket16.png>"
  1054. "<font color=#505050>"
  1055. "%c%c%c "
  1056. "</font>"
  1057. "&nbsp; "
  1058. "Add Gigablast to your browser's "
  1059. "search engines"
  1060. "</a>"
  1061. "</center>"
  1062. "<br>"
  1063. "<br>"
  1064. // print triangle
  1065. ,0xe2
  1066. ,0x96
  1067. ,0xbc
  1068. );
  1069. */
  1070. // print any red boxes we might need to
  1071. if ( printRedBox2 ( &sb , sock , r ) ) // true ) )
  1072. sb.safePrintf("<br>\n");
  1073. sb.safePrintf("<br><center><table cellpadding=3>\n");
  1074. sb.safePrintf("\n");
  1075. char *root = "";
  1076. if ( g_conf.m_isMattWells )
  1077. root = "http://www.gigablast.com";
  1078. sb.safePrintf("<tr valign=top>\n");
  1079. //sb.safePrintf("<td align=center><div style=width:50px;height:50px;display:inline-block;background-color:red;></div></td>\n");
  1080. sb.safePrintf("<td width=10%% "
  1081. "align=center><img style=padding-right:10px; "
  1082. "height=71px width=50px "
  1083. "src=%s/opensource.png></td>\n"
  1084. , root );
  1085. sb.safePrintf("<td width=45%%><font size=+1><b>Open Source!</b>"
  1086. "</font><br><br>\n");
  1087. sb.brify2("Gigablast is now available as an <a href=https://github.com/gigablast/open-source-search-engine>open source search engine</a> on github.com. Download it today. Finally a robust, scalable search solution in C/C++ that has been in development and used commercially since 2000. <a href=http://www.gigablast.com/faq.html#features>Features</a>."
  1088. ,40);
  1089. //sb.safePrintf("<br><br>");
  1090. sb.safePrintf("</td>");
  1091. sb.safePrintf("<td><font size=+1><b>ScreenShots</b>"
  1092. "</font><br><br>\n");
  1093. sb.safePrintf("<a href=/ss_settings.png><img width=150 height=81 src=ss_settings_thumb.png></a>");
  1094. sb.safePrintf("<br><br>");
  1095. sb.safePrintf("<a href=/ss_hosts.png><img width=150 height=81 src=ss_hosts_thumb.png></a>");
  1096. sb.safePrintf("<br><br>");
  1097. sb.safePrintf("<a href=/ss_filters.png><img width=150 height=81 src=ss_filters_thumb.png></a>");
  1098. sb.safePrintf("</td>");
  1099. sb.safePrintf("</tr>\n");
  1100. sb.safePrintf("</table></center>\n");
  1101. /*
  1102. do not show table for open source installs
  1103. // donate with paypal
  1104. sb.safePrintf("<tr valign=top>\n");
  1105. sb.safePrintf("<td align=center style=padding-right:20px;><center>"
  1106. // BEGIN PAYPAL DONATE BUTTON
  1107. "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_top\">"
  1108. "<input type=\"hidden\" name=\"cmd\" value=\"_donations\">"
  1109. "<input type=\"hidden\" name=\"business\" value=\"2SFSFLUY3KS9Y\">"
  1110. "<input type=\"hidden\" name=\"lc\" value=\"US\">"
  1111. "<input type=\"hidden\" name=\"item_name\" value=\"Gigablast, Inc.\">"
  1112. "<input type=\"hidden\" name=\"currency_code\" value=\"USD\">"
  1113. "<input type=\"hidden\" name=\"bn\" value=\"PP-DonationsBF:btn_donateCC_LG.gif:NonHosted\">"
  1114. "<input type=\"image\" src=\"https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\" height=47 width=147>"
  1115. "<img alt=\"\" border=\"0\" src=\"https://www.paypalobjects.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\">"
  1116. "</form>"
  1117. // END PAYPAY BUTTON
  1118. "</center></div></center></td>\n"
  1119. );
  1120. sb.safePrintf("<td><font size=+1><b>"
  1121. "Support Gigablast"
  1122. "</b></font><br>\n"
  1123. );
  1124. sb.brify2(
  1125. "Donations of $100 or more receive a black "
  1126. "Gigablast T-shirt "
  1127. "with embroidered logo while quantities last. "
  1128. "State your address and size "
  1129. "in an <a href=/contact.html>email</a>. "
  1130. "PayPal accepted. "
  1131. "Help Gigablast continue "
  1132. "to grow and add new features."
  1133. , 80
  1134. );
  1135. sb.safePrintf("</td></tr>\n");
  1136. */
  1137. /*
  1138. sb.safePrintf("<tr valign=top>\n");
  1139. // 204x143
  1140. sb.safePrintf("<td><img height=52px width=75px "
  1141. "src=%s/eventguru.png></td>\n"
  1142. , root );
  1143. sb.safePrintf("<td><font size=+1><b>Event Guru Returns</b></font><br>\n");
  1144. sb.brify2("<a href=http://www.eventguru.com/>Event Guru</a> datamines events from the web. It identifies events on a web page, or even plain text, using the same rules of deduction used by the human mind. It also has Facebook integration and lots of other cool things.",80);
  1145. sb.safePrintf("<br><br></td></tr>\n");
  1146. sb.safePrintf("\n");
  1147. sb.safePrintf("\n");
  1148. */
  1149. /*
  1150. sb.safePrintf("<tr valign=top>\n");
  1151. sb.safePrintf("<td align=center><div style=width:50px;height:50px;display:inline-block;background-color:green;></div></td>\n");
  1152. sb.safePrintf("<td><font size=+1><b>The Green Search Engine</b></font><br>\n");
  1153. sb.brify2("Gigablast is the only clean-powered web search engine. 90% of its power usage comes from wind energy. Astoundingly, Gigablast is one of ONLY four search engines in the United States indexing over a billion pages.",80);
  1154. sb.safePrintf("<br><br></td></tr>\n");
  1155. sb.safePrintf("\n");
  1156. sb.safePrintf("\n");
  1157. */
  1158. /*
  1159. sb.safePrintf("<tr valign=top>\n");
  1160. sb.safePrintf("<td align=center><img src=%s/gears.png "
  1161. "height=50 width=50></div></td>\n"
  1162. , root );
  1163. sb.safePrintf("<td><font size=+1><b>The Transparent Search Engine</b></font><br>\n");
  1164. sb.brify2("Gigablast is the first truly transparent search engine. It tells you exactly why the search results are ranked the way they are. There is nothing left to the imagination.",85);
  1165. sb.safePrintf("<br><br>");
  1166. sb.safePrintf("</td></tr>\n");
  1167. sb.safePrintf("\n");
  1168. sb.safePrintf("\n");
  1169. */
  1170. /*
  1171. if ( g_conf.m_isMattWells ) {
  1172. sb.safePrintf("<tr valign=top>\n");
  1173. sb.safePrintf("<td align=center><center><img src=%s/dollargear.png "
  1174. "height=50 width=50></center></div></center></td>\n"
  1175. , root );
  1176. sb.safePrintf("<td><font size=+1><b>The SEO Search Engine</b></font><br>\n");
  1177. sb.brify2("When it comes to search-engine based SEO, Gigablast is the place to be. With a frothy set of unique and effective <a href=http://www.gigablast.com/seo>SEO tools</a>, you will find all you need to execute a simple yet effective SEO strategy. Stop the guesswork, and let a search engine tell you how to SEO it.",85);
  1178. sb.safePrintf("</td></tr>\n");
  1179. }
  1180. */
  1181. /*
  1182. sb.safePrintf("<tr valign=top>\n");
  1183. sb.safePrintf("<td><div style=width:50px;height:50px;display:inline-block;background-color:ff3030;></td>\n");
  1184. sb.safePrintf("<td><font size=+1><b>Xml Search Feed</b></font><br>\n");
  1185. sb.brify2("Utilize Gigablast's results on your own site or product by connecting with Gigablast's <a href=/searchfeed.html>XML search feed</a>. It's now simpler than ever to setup and use. You can also add the web pages you want into the index in near real-time.",85);
  1186. sb.safePrintf("</td></tr>\n");
  1187. */
  1188. /*
  1189. sb.safePrintf("<tr valign=top>\n");
  1190. sb.safePrintf("<td><div style=width:50px;height:50px;display:inline-block;background-color:black;></td>\n");
  1191. sb.safePrintf("<td><font size=+1><b>The Private Search Engine</b>"
  1192. "</font><br>\n");
  1193. sb.brify2("Gigablast does not allow the NSA or any third party "
  1194. "to spy on the queries your IP address is doing, "
  1195. "unlike "
  1196. "<a href=http://www.guardian.co.uk/world/2013/jun/"
  1197. "06/us-tech-giants-nsa-data>"
  1198. "other large search engines</a>. "
  1199. "Gigablast is the only "
  1200. "<a href=/privacy.html>truly private search engine</a> "
  1201. "in the United States."
  1202. //" Everyone else has fundamental "
  1203. //"gaps in their "
  1204. //"security as explained by the above link."
  1205. //"Tell Congress "
  1206. //"to <a href=https://optin.stopwatching.us/>stop spying "
  1207. //"on you</a>."
  1208. ,85);
  1209. sb.safePrintf("</td></tr>\n");
  1210. */
  1211. /*
  1212. sb.safePrintf("<tr valign=top>\n");
  1213. sb.safePrintf("<td><div style=width:50px;height:50px;display:inline-block;background-color:black;></td>\n");
  1214. sb.safePrintf("<td><font size=+1><b>No Tax Dodging</b></font><br>\n");
  1215. sb.brify2("Gigablast pays its taxes when it makes a profit. "
  1216. "Google and Bing <a href=http://www.bloomberg.com/news/"
  1217. "2010-10-21/google-2-4-rate-shows-how-60-billion-u-s-"
  1218. "revenue-lost-to-tax-loopholes.html>do not</a>. They "
  1219. "stash their profits in "
  1220. "offshore tax havens to avoid paying taxes. "
  1221. //"The end result is that taxes are higher for you. "
  1222. "You may think Google and Bing are free to use, but in "
  1223. "reality, <u>you</u> pay for it in increased taxes."
  1224. ,85);
  1225. sb.safePrintf("</td></tr>\n");
  1226. */
  1227. //
  1228. // begin new stuff
  1229. //
  1230. /*
  1231. // gradients
  1232. sb.safePrintf("<style><!--\n");
  1233. sb.safePrintf(".grad {");
  1234. sb.safePrintf("background: rgb(190,201,247);");
  1235. sb.safePrintf("background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIxMDAlIiB5Mj0iMTAwJSI+CiAgICA8c3RvcCBvZmZzZXQ9IjAlIiBzdG9wLWNvbG9yPSIjYmVjOWY3IiBzdG9wLW9wYWNpdHk9IjEiLz4KICAgIDxzdG9wIG9mZnNldD0iMTAwJSIgc3RvcC1jb2xvcj0iIzBiM2NlZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgPC9saW5lYXJHcmFkaWVudD4KICA8cmVjdCB4PSIwIiB5PSIwIiB3aWR0aD0iMSIgaGVpZ2h0PSIxIiBmaWxsPSJ1cmwoI2dyYWQtdWNnZy1nZW5lcmF0ZWQpIiAvPgo8L3N2Zz4=);");
  1236. sb.safePrintf("background: -moz-linear-gradient(-45deg, rgba(190,201,247,1) 0%%, rgba(11,60,237,1) 100%%);");
  1237. sb.safePrintf("background: -webkit-gradient(linear, left top, right bottom, color-stop(0%%,rgba(190,201,247,1)), color-stop(100%%,rgba(11,60,237,1)));");
  1238. sb.safePrintf("background: -webkit-linear-gradient(-45deg, rgba(190,201,247,1) 0%%,rgba(11,60,237,1) 100%%);");
  1239. sb.safePrintf("background: -o-linear-gradient(-45deg, rgba(190,201,247,1) 0%%,rgba(11,60,237,1) 100%%);");
  1240. sb.safePrintf("background: -ms-linear-gradient(-45deg, rgba(190,201,247,1) 0%%,rgba(11,60,237,1) 100%%);");
  1241. sb.safePrintf("background: linear-gradient(135deg, rgba(190,201,247,1) 0%%,rgba(11,60,237,1) 100%%);");
  1242. sb.safePrintf("filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#bec9f7', endColorstr='#0b3ced',GradientType=1 );");
  1243. sb.safePrintf("}");
  1244. sb.safePrintf("-->");
  1245. sb.safePrintf("</style>\n");
  1246. sb.safePrintf("<br>");
  1247. sb.safePrintf("<div class=grad style=\"border-radius:200px;border-color:blue;border-style:solid;border-width:3px;padding:12px;width:320px;height:320px;display:inline-block;z-index:100;color:black;position:relative;background-color:lightgray;\">");
  1248. sb.safePrintf("<br>");
  1249. sb.safePrintf("<b>");
  1250. sb.safePrintf("<font style=font-size:18px;margin-left:80px;>");
  1251. sb.safePrintf("Build Your Own");
  1252. sb.safePrintf("</font>");
  1253. sb.safePrintf("<br>");
  1254. sb.safePrintf("<font style=font-size:18px;margin-left:80px;>");
  1255. sb.safePrintf("Search Engine in the");
  1256. sb.safePrintf("</font>");
  1257. sb.safePrintf("<br>");
  1258. sb.safePrintf("<font style=font-size:18px;margin-left:80px;>");
  1259. sb.safePrintf("Cloud");
  1260. sb.safePrintf("</font>");
  1261. sb.safePrintf("</b>");
  1262. sb.safePrintf("<br>");
  1263. sb.safePrintf("<br>");
  1264. sb.safePrintf("<div style=margin-left:20px;width:270px;>");
  1265. sb.safePrintf("<a href=/admin/addcoll><img style=float:left;padding-right:15px; height=188px width=101px src=/robot3.png></a>");
  1266. //sb.safePrintf("<br>");
  1267. sb.safePrintf("<b>STEP 1.</b> <a href=/admin/addcoll?guide=1>"
  1268. "Click here to");
  1269. sb.safePrintf("<br>");
  1270. sb.safePrintf("<b>name your engine</b></a>.");
  1271. sb.safePrintf("<br>");
  1272. sb.safePrintf("<br>");
  1273. sb.safePrintf("<b>STEP 2.</b> <a href=/admin/settings?guide=1>"
  1274. "Click here to ");
  1275. sb.safePrintf("<br>");
  1276. sb.safePrintf("<b>add websites to index</b></a>.");
  1277. sb.safePrintf("<br>");
  1278. sb.safePrintf("<br>");
  1279. sb.safePrintf("<b>STEP 3.</b> <a href=/widgets.html?guide=1>"
  1280. "Click here to");
  1281. sb.safePrintf("<br>");
  1282. sb.safePrintf("<b>insert search box</b></a>.");
  1283. sb.safePrintf("</div>");
  1284. sb.safePrintf("</div>");
  1285. */
  1286. /*
  1287. sb.safePrintf("<div class=grad style=\"border-radius:200px;border-color:blue;border-style:solid;border-width:3px;padding:12px;width:280px;height:280px;display:inline-block;z-index:105;color:black;margin-left:-50px;position:absolute;margin-top:50px;background-color:lightgray;\">");
  1288. sb.safePrintf("<br>");
  1289. sb.safePrintf("<br style=line-height:25px;>");
  1290. sb.safePrintf("<b>");
  1291. sb.safePrintf("<font style=font-size:18px;margin-left:40px;>");
  1292. sb.safePrintf("Web Search Appliance");
  1293. sb.safePrintf("</font>");
  1294. sb.safePrintf("<br>");
  1295. sb.safePrintf("<br>");
  1296. sb.safePrintf("<br>");
  1297. sb.safePrintf("</b>");
  1298. sb.safePrintf("<div style=margin-left:20px;width:270px;>");
  1299. sb.safePrintf("<a href=http://www.gigablast.com/appliance.html><img style=float:left;padding-bottom:20px;padding-right:10px; height=81px width=121px src=/computer2.png></a>");
  1300. sb.safePrintf("Put the web in your closet. ");
  1301. sb.safePrintf("Jump start your efforts with four 1U supermicro servers loaded with the top 2 billion pages from the web. <a href=http://www.gigablast.com/appliance.html>[learn more]</a>");
  1302. sb.safePrintf("</font>");
  1303. sb.safePrintf("</div>");
  1304. sb.safePrintf("</div>");
  1305. */
  1306. /*
  1307. sb.safePrintf("<div class=grad style=\"border-radius:300px;border-color:blue;border-style:solid;border-width:3px;padding:12px;width:240px;height:240px;display:inline-block;z-index:110;color:black;margin-left:-240px;position:absolute;margin-top:230px;background-color:lightgray;\">");
  1308. sb.safePrintf("<br>");
  1309. sb.safePrintf("<b>");
  1310. sb.safePrintf("<font style=font-size:18px;margin-left:60px;>");
  1311. sb.safePrintf("Open Source");
  1312. sb.safePrintf("</font>");
  1313. sb.safePrintf("<br>");
  1314. sb.safePrintf("<br>");
  1315. sb.safePrintf("</b>");
  1316. sb.safePrintf("<div style=margin-left:30px;margin-right:5px;>");
  1317. sb.safePrintf("<a href=http://www.gigablast.com/faq.html#features><img style=float:left;padding-right:10px height=71px width=71px src=/unlocked2.png></a>");
  1318. sb.safePrintf("Gigablast is now available as an <a href=https://github.com/gigablast/open-source-search-engine>open source search engine</a> on github.com. Download it today. Finally a robust, scalable search solution in C/C++ that has been in development and used commercially since 2000. <a href=http://www.gigablast.com/faq.html#features>Features</a>.");
  1319. sb.safePrintf("</div>");
  1320. sb.safePrintf("</div>");
  1321. //
  1322. // donate with paypal bubble
  1323. //
  1324. sb.safePrintf("<div class=grad style=\"border-radius:300px;border-color:blue;border-style:solid;border-width:3px;padding:12px;width:180px;height:180px;display:inline-block;z-index:120;color:black;margin-left:10px;position:absolute;margin-top:270px;background-color:lightgray;\">");
  1325. sb.safePrintf("<br>");
  1326. sb.safePrintf("<b>");
  1327. sb.safePrintf("<font style=font-size:18px;margin-left:40px;>");
  1328. sb.safePrintf("Contribute");
  1329. sb.safePrintf("</font>");
  1330. sb.safePrintf("<br>");
  1331. sb.safePrintf("<br>");
  1332. sb.safePrintf("</b>");
  1333. sb.safePrintf("<div style=margin-left:15px;margin-right:5px;>");
  1334. sb.safePrintf(
  1335. "Help Gigablast development with PayPal."
  1336. "<br>"
  1337. "<br>"
  1338. // BEGIN PAYPAL DONATE BUTTON
  1339. "<form action=\"https://www.paypal.com/cgi-bin/webscr\" method=\"post\" target=\"_top\">"
  1340. "<input type=\"hidden\" name=\"cmd\" value=\"_donations\">"
  1341. "<input type=\"hidden\" name=\"business\" value=\"2SFSFLUY3KS9Y\">"
  1342. "<input type=\"hidden\" name=\"lc\" value=\"US\">"
  1343. "<input type=\"hidden\" name=\"item_name\" value=\"Gigablast, Inc.\">"
  1344. "<input type=\"hidden\" name=\"currency_code\" value=\"USD\">"
  1345. "<input type=\"hidden\" name=\"bn\" value=\"PP-DonationsBF:btn_donateCC_LG.gif:NonHosted\">"
  1346. "<input type=\"image\" src=\"https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif\" border=\"0\" name=\"submit\" alt=\"PayPal - The safer, easier way to pay online!\" height=47 width=147>"
  1347. "<img alt=\"\" border=\"0\" src=\"https://www.paypalobjects.com/en_US/i/scr/pixel.gif\" width=\"1\" height=\"1\">"
  1348. "</form>"
  1349. // END PAYPAY BUTTON
  1350. "</center></div></center>"
  1351. //"</td>\n"
  1352. );
  1353. */
  1354. //
  1355. // end new stuff
  1356. //
  1357. sb.safePrintf("\n");
  1358. sb.safePrintf("\n");
  1359. //sb.safePrintf("</table>\n");
  1360. sb.safePrintf("<br><br>\n");
  1361. printNav ( sb , r );
  1362. return true;
  1363. }
  1364. bool printAddUrlHomePage ( SafeBuf &sb , char *url , HttpRequest *r ) {
  1365. CollectionRec *cr = g_collectiondb.getRec ( r );
  1366. printFrontPageShell ( &sb , "add url" , cr , true );
  1367. sb.safePrintf("<script type=\"text/javascript\">\n"
  1368. "function handler() {\n"
  1369. "if(this.readyState == 4 ) {\n"
  1370. "document.getElementById('msgbox').innerHTML="
  1371. "this.responseText;\n"
  1372. //"alert(this.status+this.statusText+"
  1373. //"this.responseXML+this.responseText);\n"
  1374. "}}\n"
  1375. "</script>\n");
  1376. sb.safePrintf("<br><br>\n");
  1377. sb.safePrintf("<br><br><br>\n");
  1378. /*
  1379. sb.safePrintf("<b>web</b> &nbsp;&nbsp;&nbsp;&nbsp; ");
  1380. if ( g_conf.m_isMattWells )
  1381. sb.safePrintf("<a href=http://www.gigablast.com/seo>seo</a> "
  1382. "&nbsp;&nbsp;&nbsp;&nbsp; "
  1383. );
  1384. sb.safePrintf( "<a href=\"/Top\">directory</a> "
  1385. "&nbsp;&nbsp;&nbsp;&nbsp; \n");
  1386. sb.safePrintf("<a href=/adv.html>advanced search</a>");
  1387. sb.safePrintf(" &nbsp;&nbsp;&nbsp;&nbsp; ");
  1388. sb.safePrintf("<a href=/addurl title=\"Instantly add your url to "
  1389. "Gigablast's index\">add url</a>");
  1390. sb.safePrintf("\n");
  1391. sb.safePrintf("<br><br>\n");
  1392. */
  1393. // submit to https now
  1394. sb.safePrintf("<form method=GET "
  1395. "action=/addurl name=f>\n" );
  1396. char *coll = "";
  1397. if ( cr ) coll = cr->m_coll;
  1398. if ( cr )
  1399. sb.safePrintf("<input type=hidden name=c value=\"%s\">",
  1400. cr->m_coll);
  1401. // put search box in a box
  1402. sb.safePrintf("<div style="
  1403. "background-color:#%s;" // fcc714;"
  1404. "border-style:solid;"
  1405. "border-width:3px;"
  1406. "border-color:blue;"
  1407. //"background-color:blue;"
  1408. "padding:20px;"
  1409. "border-radius:20px;"
  1410. ">"
  1411. , GOLD
  1412. );
  1413. sb.safePrintf("<input name=urls type=text "
  1414. "style=\""
  1415. //"width:%"INT32"px;"
  1416. "height:26px;"
  1417. "padding:0px;"
  1418. "…

Large files files are truncated, but you can click here to view the full file