révision
a0f448890d
2 fichiers modifiés avec 30 ajouts et 3 suppressions
19
index.html
19
index.html
|
@ -36,6 +36,25 @@
|
|||
</ul>
|
||||
<form class="navbar-form navbar-left" role="search" action="/search" method="get">
|
||||
<div class="form-group">
|
||||
<select name="c" class="form-control" value>
|
||||
<option value="_">All categories</option>
|
||||
<option value="1_" {{if eq .Category "1_"}}selected{{end}}>Software</option>
|
||||
<option value="1_1" {{if eq .Category "1_1"}}selected{{end}}>Software - Applications</option>
|
||||
<option value="1_2" {{if eq .Category "1_2"}}selected{{end}}>Software - Games</option>
|
||||
<option value="2_" {{if eq .Category "2_"}}selected{{end}}>Audio</option>
|
||||
<option value="2_3" {{if eq .Category "2_3"}}selected{{end}}>Audio - Lossless</option>
|
||||
<option value="2_4" {{if eq .Category "2_4"}}selected{{end}}>Audio - Lossy</option>
|
||||
<option value="3_" {{if eq .Category "3_"}}selected{{end}}>Anime</option>
|
||||
<option value="3_5" {{if eq .Category "3_5"}}selected{{end}}>Anime - English-translated</option>
|
||||
<option value="3_6" {{if eq .Category "3_6"}}selected{{end}}>Anime - Raw</option>
|
||||
<option value="4_" {{if eq .Category "4_"}}selected{{end}}>Literature</option>
|
||||
<option value="4_7" {{if eq .Category "4_7"}}selected{{end}}>Literature - English-translated</option>
|
||||
<option value="4_8" {{if eq .Category "4_8"}}selected{{end}}>Literature - Raw</option>
|
||||
<option value="5_" {{if eq .Category "5_"}}selected{{end}}>Live Action</option>
|
||||
<option value="5_9" {{if eq .Category "5_9"}}selected{{end}}>Live Action - English-translated</option>
|
||||
<option value="5_10" {{if eq .Category "5_10"}}selected{{end}}>Live Action - Idol/Promotional Video</option>
|
||||
<option value="5_11" {{if eq .Category "5_11"}}selected{{end}}>Live Action - Raw</option>
|
||||
</select>
|
||||
<input name="q" class="form-control" placeholder="Search" type="text">
|
||||
</div>
|
||||
<button type="submit" class="btn btn-default">Search for Torrents</button>
|
||||
|
|
14
main.go
14
main.go
|
@ -12,6 +12,7 @@ import (
|
|||
"net/url"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"time"
|
||||
)
|
||||
|
||||
|
@ -21,6 +22,7 @@ var debugLogger *log.Logger
|
|||
var trackers = "&tr=udp://zer0day.to:1337/announce&tr=udp://tracker.leechers-paradise.org:6969&tr=udp://explodie.org:6969&tr=udp://tracker.opentrackr.org:1337&tr=udp://tracker.coppersurfer.tk:6969"
|
||||
|
||||
type Record struct {
|
||||
Category string `json: "category"`
|
||||
Records []Records `json: "records"`
|
||||
QueryRecordCount int `json: "queryRecordCount"`
|
||||
TotalRecordCount int `json: "totalRecordCount"`
|
||||
|
@ -113,8 +115,14 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
page := vars["page"]
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
param1 := r.URL.Query().Get("q")
|
||||
b := Record{Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_name LIKE ? ORDER BY torrent_id DESC LIMIT 50 offset ?", "%"+html.EscapeString(param1)+"%", 50*pagenum-1)
|
||||
cat := r.URL.Query().Get("c")
|
||||
param2 := strings.Split(cat, "_")[0]
|
||||
param3 := strings.Split(cat, "_")[1]
|
||||
b := Record{Category: cat, Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents "+
|
||||
"where torrent_name LIKE ? AND category_id LIKE ? AND sub_category_id LIKE ? "+
|
||||
"ORDER BY torrent_id DESC LIMIT 50 offset ?",
|
||||
"%"+html.EscapeString(param1)+"%", html.EscapeString(param2)+"%", html.EscapeString(param3)+"%", 50*pagenum-1)
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
|
@ -143,7 +151,7 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||
vars := mux.Vars(r)
|
||||
page := vars["page"]
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
b := Record{Records: []Records{}}
|
||||
b := Record{Category: "_", Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
|
|
Référencer dans un nouveau ticket