Add files via upload

This commit is contained in:
wibyweb 2023-03-31 23:47:01 -04:00 committed by GitHub
parent 0e4a885f5a
commit 13006a199e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 3 deletions

View file

@ -154,7 +154,12 @@ func handler(w http.ResponseWriter, r *http.Request) {
query = query[:querylen-1]
queryNoQuotes = queryNoQuotes[:len(queryNoQuotes)-1]
querylen = len(query)
}
}
if querylen > 1 && query[0] == ' '{
query = query[1:querylen]
queryNoQuotes = queryNoQuotes[1:len(queryNoQuotes)]
querylen = len(query)
}
//check if user wants to limit search to a specific website
sitePos := -1
@ -378,9 +383,13 @@ func handler(w http.ResponseWriter, r *http.Request) {
}else{
sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE MATCH(tags, body, description, title, url) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 20 END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""
}
/*sqlQuery = "SELECT id, url, title, description, body FROM windex WHERE Match(tags, body, description, title, url) Against('" + query + "' IN BOOLEAN MODE) AND enable = '1' " + additions + "ORDER BY CASE WHEN MATCH(tags) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 30 " + isURL + " WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) AND Match(title) AGAINST('" + query + "' IN BOOLEAN MODE) THEN 20 WHEN MATCH(title) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 16 WHEN Match(body) AGAINST('" + queryWithQuotesAndFlags + "' IN BOOLEAN MODE) THEN 15 WHEN Match(title) AGAINST('" + query + "' IN BOOLEAN MODE) THEN Match(title) AGAINST('" + query + "' IN BOOLEAN MODE) END DESC, id DESC LIMIT " + lim + " OFFSET " + offset + ""*/
rows, err := db.Query(sqlQuery)
// fmt.Printf("\n%s\n",sqlQuery)
//fmt.Printf("\n%s\n",sqlQuery)
if err != nil {
res.Page = strconv.Itoa(0)
res.Query = m["q"][0] //get original unsafe query

View file

@ -159,6 +159,11 @@ func handler(w http.ResponseWriter, r *http.Request) {
query = query[:querylen-1]
queryNoQuotes = queryNoQuotes[:len(queryNoQuotes)-1]
querylen = len(query)
}
if querylen > 1 && query[0] == ' '{
query = query[1:querylen]
queryNoQuotes = queryNoQuotes[1:len(queryNoQuotes)]
querylen = len(query)
}
//check if user wants to limit search to a specific website
@ -1210,4 +1215,3 @@ func distributedQuery(con string, sqlQuery string, startID string, endID string,
//fmt.Printf("%s - %s\n", idList,con)
idListChan <- idList
}