// (C) 2000-2015 Lavtech.Com Corp
//
// Copy this file to "search.htm" and edit as desired.
// See doc/msearch-templates.html for detailed information.
// You may want to keep the original file for future reference.
//
// WARNING: Use proper chmod to protect your database passwords!
// Number of result page links in the page navigator
int PagesPerScreen= 10;
// How to highlight query words in snippets
string HlBeg= "";
string HlEnd= "";
// Browser and local character sets.
// Default charset is iso-8859-1 (latin1)
// which is suitable for the majority of West European languages
string BrowserCharset= "iso-8859-1";
string LocalCharset= "iso-8859-1";
// Database parameters
// Examples:
// mysql://root@localhost/test/
// pgsql://user:password@localhost/test/
// sqlite3:///$(VarDir)/mnogosearch.sqlite3/
string DBAddr= "mysql://root@localhost/test/";
ENV env;
RESULT res;
int errcode, found, searched= 0;
string errmsg;
string request_method= getenv("REQUEST_METHOD");
string query_string= getenv("QUERY_STRING");
string get_fmt, get_cc, get_form;
string get_q;
string get_q_urldecoded;
string get_q_htmlencoded;
string get_q_urlencoded;
// Check if executed from the command line rather than from a HTTP server
if (!request_method.length() &&
!query_string.length() &&
_argc() == 2)
{
string arg= _argv(1);
query_string= "q=";
query_string.append(arg);
}
get_fmt= query_string.regex_substr("(^|&)fmt=([^&]*)", "$2");
get_cc= query_string.regex_substr("(^|&)cc=([^&]*)", "$2");
get_form= query_string.regex_substr("(^|&)form=([^&]*)", "$2");
get_q= query_string.regex_substr("(^|&)q=([^&]*)", "$2");
get_q_urldecoded= get_q.urldecode();
get_q_htmlencoded= get_q_urldecoded.htmlencode();
get_q_urlencoded= get_q_urldecoded.urlencode();
if (!get_q_urlencoded.compare(""))
{
string get_qprev= query_string.regex_substr("(^|&)qprev=([^&]*)", "$2");
string get_qprev_text= get_qprev.urldecode();
string get_qprev_urlencoded= get_qprev_text.urlencode();
get_q_urlencoded= get_qprev_urlencoded;
get_q_htmlencoded= get_qprev_text.htmlencode();
}
if (get_cc.compare("") || get_q.compare(""))
{
// The code with DBAddr0 is required for msearch-test/test-sample
string qmark;
string cmddbaddr= "DBAddr ";
string cmdlcs= "LocalCharset ";
string cmdbcs= "BrowserCharset ";
cmddbaddr.append(DBAddr);
// Append "SetNames" or "?SetNames" or "&SetNames"
qmark= cmddbaddr.regex_substr("([?].*)", "$1");
if (qmark.length() == 0)
cmddbaddr.append("?");
else if (qmark.length() > 1)
cmddbaddr.append("&");
cmddbaddr.append("SetNames=");
cmddbaddr.append(LocalCharset);
cmdbcs.append(BrowserCharset);
cmdlcs.append(LocalCharset);
if (env.addline(cmddbaddr) ||
env.addline(cmdbcs) ||
env.addline(cmdlcs))
{
cout << "Content-type: text/plain\r\n\r\n";
cout << "ERROR: " << env.errmsg() << '\n';
exit(0);
}
// Uncomment this line if you want misspelled word suggestions
env.addline("Suggest yes");
// Uncomment this line to change the default excerpt size (256).
//env.addline("ExcerptSize 1024");
// Uncomment this line to change the default number (40)
// of characters padded to snippets (the before and after context size).
//env.addline("ExcerptPadding 64");
// Uncomment this if you want non-default minimum and maximum word lengths
//env.addline("MinWordLength 1");
//env.addline("MaxWordLength 32");
// Uncomment this if you want synonyms. File names are either absolute
// or relative to /etc directory of the mnoGoSearch installation.
// env.addline("Synonym synonym/english.syn");
// env.addline("Synonym synonym/russian.syn");
// Uncomment this if you want stopwords. File names are either absolute
// or relative to /etc directory of mnoGoSearch installation.
//env.addline("StopwordFile stopwords/en.sl");
//env.addline("StopwordFile stopwords/ru.sl");
// Uncomment this for stemming using ispell affix and dictionary files
//env.addline("Affix en ascii ispell/english.aff");
//env.addline("Spell en ascii ispell/american.med+");
// Uncomment this line if you want to detect and eliminate clones
//env.addline("DetectClones yes");
// Uncomment this line to enable error logging to stderr
//env.addline("Log2Stderr yes");
// Uncomment this line to enable error logging to systlog
//env.addline("SyslogFacility local7");
// Uncomment this line for more verbosity
//env.addline("LogLevel 6");
// Uncomment this line to change Last-Modified format output
//env.addline("DateFormat '%d %b %Y %X %Z'");
env.addline("StrictModeThreshold 4");
}
if (get_cc.compare("")) // Cached copy
{
DOCUMENT doc;
string URL;
string DocCharset;
doc.cached(env, query_string);
DocCharset= doc.property("cached.charset");
if (!DocCharset.compare(""))
DocCharset= "iso-8859-1";
cout << "Content-type: text/html; charset=" << DocCharset << "\r\n\r\n";
URL= doc.property("URL");
?>
mnoGoSearch:
0) {
?>
|
Too few () results were found in strict mode.
|
|
|
|
Displaying results in a less strict mode.
|
|
|
0)
cout << ", ";
cout << "" << word.htmlencode() << " : " << tcount;
}
}?>
|
|
|
Your search - - did not match any documents.
Did you mean
?
Suggestions:
|
|
|
[
" << x << "" << '\n';
}
}
?>
]
...
- bytes
-
" << word << " ";
}
}
}
?>
1)
{
string sitename, sitelimit;
// Using non-aliased URL, for use in "More results from xxx" link
sitelimit= res.document_property(i, "url");
sitelimit= sitelimit.regex_cut("^[a-z]*://[^/]*/(.*)");
// Using aliased URL, for use in "More results from xxx" text
sitename= url_htmlencoded.regex_cut("^[a-z]*://[^/]*/(.*)");
?>
|
|
|
|
|
Result pages: |
0 ? 1 : 0);
int ppp= PagesPerScreen > npages ? npages : PagesPerScreen;
int ppp2= ppp / 2;
int page_number_plus_ppp2= page_number + ppp2;
int page1= page_number - ppp2;
int page2= page1 + ppp;
if (page_number <= ppp2)
{
page1= 0;
page2= ppp;
}
else
{
if (page_number_plus_ppp2 >= npages)
{
page1= npages - ppp;
page2= npages;
}
}
?>
|
|
|
| Sort by:
|
score |
date |
popularity
score |
date |
popularity
score |
date |
popularity
|
|
|
|
|