aboutsummaryrefslogtreecommitdiffhomepage
path: root/sundry/spine_search_cgi/src/spine_search.d_
diff options
context:
space:
mode:
Diffstat (limited to 'sundry/spine_search_cgi/src/spine_search.d_')
-rwxr-xr-xsundry/spine_search_cgi/src/spine_search.d_48
1 files changed, 26 insertions, 22 deletions
diff --git a/sundry/spine_search_cgi/src/spine_search.d_ b/sundry/spine_search_cgi/src/spine_search.d_
index 5907b73..fca2b2b 100755
--- a/sundry/spine_search_cgi/src/spine_search.d_
+++ b/sundry/spine_search_cgi/src/spine_search.d_
@@ -72,26 +72,27 @@ void cgi_function_intro(Cgi cgi) {
string web_doc_root_path;
string doc_collection_sub_root;
string cgi_root;
- string cgi_script;
+ string cgi_script_name;
string data_path_html;
- string db_path;
- string query_string;
string http_url;
+ string query_base_url;
+ string query_string;
string request_method;
- string query_base;
+ string db_path;
}
auto conf = Config();
conf.http_request_type = environment.get("REQUEST_SCHEME", _cfg.http_request_type);
- conf.http_host = environment.get("HTTP_HOST", _cfg.http_host);
- conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", _cfg.doc_root_www);
+ conf.http_host = environment.get("SERVER_NAME", _cfg.http_host);
+ // conf.http_host = environment.get("HTTP_HOST", _cfg.http_host);
+ conf.web_doc_root_path = environment.get("DOCUMENT_ROOT", _cfg.www_doc_root);
conf.doc_collection_sub_root = "/spine/static"; // (output_path - web_doc_root_path)
- conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", _cfg.host_cgi_subpath);
- conf.cgi_script = environment.get("SCRIPT_NAME", _cfg.filename_cgi);
+ conf.cgi_root = environment.get("CONTEXT_DOCUMENT_ROOT", _cfg.cgi_bin_subpath);
+ conf.cgi_script_name = environment.get("SCRIPT_NAME", _cfg.cgi_filename);
+ conf.query_base_url = conf.http_request_type ~ "://" ~ conf.http_host ~ "/" ~ conf.cgi_script_name ~ "?";
conf.query_string = environment.get("QUERY_STRING", "");
- conf.db_path = _cfg.doc_root_db;
+ conf.http_url = environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string);
conf.request_method = environment.get("REQUEST_METHOD", "POST");
- conf.query_base = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ "?";
- conf.http_url = environment.get("HTTP_REFERER", conf.query_base ~ conf.query_string);
+ conf.db_path = _cfg.db_sqlite_path;
struct CGI_val {
string db_selected = "";
string sql_match_limit = ""; // radio: ( 1000 | 2500 )
@@ -106,7 +107,7 @@ void cgi_function_intro(Cgi cgi) {
bool checked_sql = false;
}
auto cv = CGI_val();
- cv.db_selected = _cfg.filename_db;
+ cv.db_selected = _cfg.db_sqlite_filename;
auto text_fields() {
string canned_query_str = environment.get("QUERY_STRING", "");
if ("query_string" in cgi.post) {
@@ -445,9 +446,9 @@ void cgi_function_intro(Cgi cgi) {
string canned_url () {
string _url = "";
if (environment.get("REQUEST_METHOD", "POST") == "POST") {
- _url = conf.query_base ~ tf.canned_query;
+ _url = conf.query_base_url ~ tf.canned_query;
} else if (environment.get("REQUEST_METHOD", "POST") == "GET") {
- _url = conf.query_base ~ environment.get("QUERY_STRING", "");
+ _url = conf.query_base_url ~ environment.get("QUERY_STRING", "");
}
return _url;
}
@@ -517,7 +518,7 @@ void cgi_function_intro(Cgi cgi) {
_set_offset_previous = m.captures["offset_key"] ~ ((m.captures["offset_val"]).to!int - cv.sql_match_limit.to!int).to!string;
_url_previous = _url.replace(rgx.track_offset, _set_offset_previous);
}
- } else {// _current_offset_value = 0;
+ } else { // _current_offset_value = 0;
_url_next = _url ~= "&smo=" ~ cv.sql_match_limit.to!string;
}
if (_url_previous.empty) {
@@ -1413,9 +1414,9 @@ void cgi_function_intro(Cgi cgi) {
string _the_can = "";
if (show_the_can == "checked") {
tf = text_fields;
- string method_get_url = conf.query_base ~ environment.get("QUERY_STRING", "");
- string method_post_url_construct = conf.query_base ~ tf.canned_query;
- // assert(method_get_url == environment.get("HTTP_REFERER", conf.query_base ~ conf.query_string));
+ string method_get_url = conf.query_base_url ~ environment.get("QUERY_STRING", "");
+ string method_post_url_construct = conf.query_base_url ~ tf.canned_query;
+ // assert(method_get_url == environment.get("HTTP_REFERER", conf.query_base_url ~ conf.query_string));
if (conf.request_method == "POST") {
_the_can =
"<font size=\"2\" color=\"#666666\">"
@@ -1436,7 +1437,7 @@ void cgi_function_intro(Cgi cgi) {
~ method_get_url
~ "</a></font>";
}
- conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script ~ tf.canned_query;
+ conf.http_url = conf.http_request_type ~ "://" ~ conf.http_host ~ conf.cgi_script_name ~ tf.canned_query;
}
return _the_can;
}
@@ -1502,7 +1503,7 @@ void cgi_function_intro(Cgi cgi) {
</table>
</form>
┃",
- _cfg.filename_cgi,
+ _cfg.cgi_filename,
(post_value("ec") == "checked") ? post_value("sf", "field") : "",
provide_tip,
search_note,
@@ -1538,7 +1539,7 @@ void cgi_function_intro(Cgi cgi) {
} else { val = false; }
return val;
}
- cv.db_selected = set_value("selected_db", _cfg.filename_db); // selected_db_name == db (spine.search.db or whatever)
+ cv.db_selected = set_value("selected_db", _cfg.db_sqlite_filename); // selected_db_name == db (spine.search.db or whatever)
cv.sql_match_limit = set_value("sml", "1000");
cv.sql_match_offset = set_value("smo", "0");
cv.search_text = set_value("sf", "");
@@ -1563,6 +1564,9 @@ void cgi_function_intro(Cgi cgi) {
// }
}
{ // debug cgi info:
+ // cgi.write("db with path: " ~ conf.db_path ~ "/" ~ cv.db_selected ~ "<br>\n");
+ // cgi.write("http url: " ~ conf.http_url ~ "<br>\n");
+ // cgi.write("query base url: " ~ conf.query_base_url ~ "<br>\n");
// cgi.write("db_selected: " ~ cv.db_selected ~ "<br>\n");
// cgi.write("search_text: " ~ cv.search_text ~ "<br>\n");
// cgi.write("sql_match_limit: " ~ cv.sql_match_limit ~ ";\n");
@@ -1576,7 +1580,7 @@ void cgi_function_intro(Cgi cgi) {
// cgi.write("cv.checked_sql: " ~ (cv.checked_sql ? "checked" : "off") ~ "<br>\n");
}
}
- auto db = Database(conf.db_path ~ cv.db_selected);
+ auto db = Database(conf.db_path ~ "/" ~ cv.db_selected);
{
uint sql_match_offset_counter(T)(T cv) {
sql_match_offset_count += cv.sql_match_limit.to!uint;