révision
304b71d253
2 fichiers modifiés avec 32 ajouts et 10 suppressions
17
index.html
17
index.html
|
@ -18,6 +18,17 @@
|
|||
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
|
||||
<![endif]-->
|
||||
</head>
|
||||
<style>
|
||||
.remake {
|
||||
background-color: #f0b0b0;
|
||||
}
|
||||
.trusted {
|
||||
background-color: #98d9a8;
|
||||
}
|
||||
.aplus {
|
||||
background-color: #60b0f0;
|
||||
}
|
||||
</style>
|
||||
<body>
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container">
|
||||
|
@ -71,8 +82,10 @@
|
|||
<th>Links</th>
|
||||
</tr>
|
||||
{{ range .Records}}
|
||||
<tr>
|
||||
<td>{{.Name}}</td>
|
||||
<tr {{if eq .Status 2}}class="remake"{{end}}
|
||||
{{if eq .Status 3}}class="trusted"{{end}}
|
||||
{{if eq .Status 4}}class="aplus"{{end}}>
|
||||
<td>{{.Name}}</td>
|
||||
<td>{{.Hash}}</td>
|
||||
<td><a href="{{.Magnet}}" target="_blank" title="Magnet link" ><span class="glyphicon glyphicon-magnet" aria-hidden="true"></span></a>
|
||||
<a href="http://torcache.net/torrent/{{.Hash}}.torrent"><span class="glyphicon glyphicon-floppy-save" aria-hidden="true"></span></a>
|
||||
|
|
25
main.go
25
main.go
|
@ -30,6 +30,7 @@ type Record struct {
|
|||
type Records struct {
|
||||
Id string `json: "id"`
|
||||
Name string `json: "name"`
|
||||
Status int `json: "status"`
|
||||
Hash string `json: "hash"`
|
||||
Magnet template.URL `json: "magnet"`
|
||||
}
|
||||
|
@ -52,14 +53,16 @@ func apiHandler(w http.ResponseWriter, r *http.Request) {
|
|||
page := vars["page"]
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
b := Record{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)
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
var status int
|
||||
rows.Scan(&id, &name, &status, &hash)
|
||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||
res := Records{
|
||||
Id: id,
|
||||
Name: name,
|
||||
Status: status,
|
||||
Hash: hash,
|
||||
Magnet: safe(magnet)}
|
||||
|
||||
|
@ -82,14 +85,16 @@ func singleapiHandler(w http.ResponseWriter, r *http.Request) {
|
|||
vars := mux.Vars(r)
|
||||
id := vars["id"]
|
||||
b := Record{Records: []Records{}}
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, torrent_hash from torrents where torrent_id = ? ORDER BY torrent_id DESC", html.EscapeString(id))
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, torrent_hash from torrents where torrent_id = ? ORDER BY torrent_id DESC", html.EscapeString(id))
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
var status int
|
||||
rows.Scan(&id, &name, &status, &hash)
|
||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||
res := Records{
|
||||
Id: id,
|
||||
Name: name,
|
||||
Status: status,
|
||||
Hash: hash,
|
||||
Magnet: safe(magnet)}
|
||||
|
||||
|
@ -117,17 +122,19 @@ func searchHandler(w http.ResponseWriter, r *http.Request) {
|
|||
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 "+
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, 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)
|
||||
var status int
|
||||
rows.Scan(&id, &name, &status, &hash)
|
||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||
res := Records{
|
||||
Id: id,
|
||||
Name: name,
|
||||
Status: status,
|
||||
Hash: hash,
|
||||
Magnet: safe(magnet)}
|
||||
|
||||
|
@ -150,14 +157,16 @@ func rootHandler(w http.ResponseWriter, r *http.Request) {
|
|||
page := vars["page"]
|
||||
pagenum, _ := strconv.Atoi(html.EscapeString(page))
|
||||
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)
|
||||
rows, err := dbHandle.Query("select torrent_id, torrent_name, status_id, torrent_hash from torrents ORDER BY torrent_id DESC LIMIT 50 offset ?", 50*pagenum-1)
|
||||
for rows.Next() {
|
||||
var id, name, hash, magnet string
|
||||
rows.Scan(&id, &name, &hash)
|
||||
var status int
|
||||
rows.Scan(&id, &name, &status, &hash)
|
||||
magnet = "magnet:?xt=urn:btih:" + hash + "&dn=" + url.QueryEscape(name) + trackers
|
||||
res := Records{
|
||||
Id: id,
|
||||
Name: name,
|
||||
Status: status,
|
||||
Hash: hash,
|
||||
Magnet: safe(magnet)}
|
||||
|
||||
|
|
Référencer dans un nouveau ticket