forked from sir55/xbtit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit.php
128 lines (110 loc) · 5.46 KB
/
edit.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
<?php
/////////////////////////////////////////////////////////////////////////////////////
// xbtit - Bittorrent tracker/frontend
//
// Copyright (C) 2004 - 2019 Btiteam
//
// This file is part of xbtit.
//
// Redistribution and use in source and binary forms, with or without modification,
// are permitted provided that the following conditions are met:
//
// 1. Redistributions of source code must retain the above copyright notice,
// this list of conditions and the following disclaimer.
// 2. Redistributions in binary form must reproduce the above copyright notice,
// this list of conditions and the following disclaimer in the documentation
// and/or other materials provided with the distribution.
// 3. The name of the author may not be used to endorse or promote products
// derived from this software without specific prior written permission.
//
// THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
// IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
// TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
// EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
//
////////////////////////////////////////////////////////////////////////////////////
if (!defined('IN_BTIT')) {
die('non direct access!');
}
$link = urldecode($_GET['returnto']);
if ($link == '') {
$link = 'index.php?page=torrents';
}
// save editing and got back from where i come
if ((isset($_POST['comment'])) && (isset($_POST['name']))) {
if ($_POST['action'] == $language['FRM_CONFIRM']) {
if ($_POST['name'] == '') {
stderr('Error!', 'You must specify torrent name.');
}
if ($_POST['comment'] == '') {
stderr('Error!', 'You must specify description.');
}
$fname = htmlspecialchars(addslashes(unesc($_POST['name'])));
$torhash = addslashes($_POST['info_hash']);
write_log("Modified torrent $fname ($torhash)", 'modify');
do_sqlquery("UPDATE {$TABLE_PREFIX}files SET filename='$fname', comment='".addslashes($_POST['comment'])."', category=".((int) $_POST['category'])." WHERE info_hash='".$torhash."'", true);
redirect($link);
exit();
} else {
redirect($link);
exit();
}
}
// view torrent's details
if (isset($_GET['info_hash'])) {
if ($XBTT_USE) {
$tseeds = 'f.seeds+ifnull(x.seeders,0) as seeds';
$tleechs = 'f.leechers+ifnull(x.leechers,0) as leechers';
$tcompletes = 'f.finished+ifnull(x.completed,0) as finished';
$ttables = "{$TABLE_PREFIX}files f LEFT JOIN xbt_files x ON x.info_hash=f.bin_hash";
} else {
$tseeds = 'f.seeds as seeds';
$tleechs = 'f.leechers as leechers';
$tcompletes = 'f.finished as finished';
$ttables = "{$TABLE_PREFIX}files f";
}
$query = "SELECT f.info_hash, f.filename, f.url, UNIX_TIMESTAMP(f.data) as data, f.size, f.comment, f.category as cat_name, $tseeds, $tleechs, $tcompletes, f.speed, f.uploader FROM $ttables WHERE f.info_hash ='".addslashes($_GET['info_hash'])."'";
$res = do_sqlquery($query, true);
$results = mysqli_fetch_assoc($res);
if (!$results || mysqli_num_rows($res) == 0) {
err_msg($language['ERROR'], $language['TORRENT_EDIT_ERROR']);
} else {
if (!$CURUSER || $CURUSER['uid'] < 2 || ($CURUSER['edit_torrents'] == 'no' && $CURUSER['uid'] != $results['uploader'])) {
stderr($language['ERROR'], $language['CANT_EDIT_TORR']);
}
$torrenttpl = new bTemplate();
$torrenttpl->set('language', $language);
/*
$s = "<select name=\"type\">\n<option value=\"0\">(".$language["CHOOSE_ONE"].")</option>\n";
$cats = genrelist();
foreach ($cats as $row) {
$s .= "<option value=\"" . $row["id"] . "\"";
if ($row["id"] == $results["cat_name"])
$s .= " \"selected\"";
$s .= ">" . unesc($row["name"]) . "</option>\n";
}
$s .= "</select>\n";
*/
$torrent = [];
$torrent['link'] = 'index.php?page=edit&info_hash='.$results['info_hash'].'&returnto='.urlencode($link);
$torrent['filename'] = $results['filename'];
$torrent['info_hash'] = $results['info_hash'];
$torrent['description'] = textbbcode('edit', 'comment', unesc($results['comment']));
$torrent['size'] = makesize($results['size']);
include __DIR__.'/include/offset.php';
$torrent['date'] = date('d/m/Y', $results['data'] - $offset);
$torrent['complete'] = $results['finished'].' '.$language['X_TIMES'];
$torrent['peers'] = $language['SEEDERS'].': '.$results['seeds'].','.$language['LEECHERS'].': '.$results['leechers'].'='.($results['leechers'] + $results['seeds']).' '.$language['PEERS'];
$torrent['cat_combo'] = categories($results['cat_name']); //$s;
$torrenttpl->set('torrent', $torrent);
unset($results);
((mysqli_free_result($res) || (is_object($res) && (get_class($res) == 'mysqli_result'))) ? true : false);
}
}
?>