-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtakeupload.php
521 lines (502 loc) · 23 KB
/
takeupload.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
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
<?php
/**
|--------------------------------------------------------------------------|
| https://github.com/Bigjoos/ |
|--------------------------------------------------------------------------|
| Licence Info: WTFPL |
|--------------------------------------------------------------------------|
| Copyright (C) 2010 U-232 V5 |
|--------------------------------------------------------------------------|
| A bittorrent tracker source based on TBDev.net/tbsource/bytemonsoon. |
|--------------------------------------------------------------------------|
| Project Leaders: Mindless, Autotron, whocares, Swizzles. |
|--------------------------------------------------------------------------|
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _
/ \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \
( U | - | 2 | 3 | 2 )-( S | o | u | r | c | e )-( C | o | d | e )
\_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/ \_/
*/
require_once(__DIR__ . DIRECTORY_SEPARATOR . 'include' . DIRECTORY_SEPARATOR . 'bittorrent.php');
require_once(INCL_DIR . 'user_functions.php');
require_once(CLASS_DIR . 'page_verify.php');
require_once(CLASS_DIR . 'class.bencdec.php');
require_once INCL_DIR . 'function_ircbot.php';
require_once INCL_DIR . 'function_memcache.php';
dbconn();
loggedinorreturn();
ini_set('upload_max_filesize', $INSTALLER09['max_torrent_size']);
ini_set('memory_limit', '64M');
//smth putyn
//print_r($_POST);
//print_r($_GET);
//exit();
$auth_key = array(
'2d257f64005d740db092a6b91170ab5f'
);
$gotkey = isset($_POST['key']) && strlen($_POST['key']) == 32 && in_array($_POST['key'], $auth_key) ? true : false;
$lang = array_merge(load_language('global'), load_language('takeupload'));
if (!$gotkey) {
$newpage = new page_verify();
$newpage->check('taud');
}
if ($CURUSER['class'] < UC_UPLOADER OR $CURUSER["uploadpos"] == 0 || $CURUSER["uploadpos"] > 1 || $CURUSER['suspended'] == 'yes') {
header("Location: {$INSTALLER09['baseurl']}/upload.php");
exit();
}
foreach (explode(":", "descr:type:name") as $v) {
if (!isset($_POST[$v]))
stderr($lang['takeupload_failed'], $lang['takeupload_no_formdata']);
}
if (!isset($_FILES["file"]))
stderr($lang['takeupload_failed'], $lang['takeupload_no_formdata']);
$f = $_FILES["file"];
$fname = unesc($f["name"]);
if (empty($fname))
stderr($lang['takeupload_failed'], $lang['takeupload_no_filename']);
if (isset($_POST['uplver']) && $_POST['uplver'] == 'yes') {
$anonymous = "yes";
$anon = "Anonymous";
} else {
$anonymous = "no";
$anon = $CURUSER["username"];
}
if (isset($_POST['allow_comments']) && $_POST['allow_comments'] == 'yes') {
$allow_comments = "no";
$disallow = "Yes";
} else {
$allow_comments = "yes";
$disallow = "No";
}
if (isset($_POST["music"])) {
$genre = implode(",", $_POST['music']);
} elseif (isset($_POST["movie"])) {
$genre = implode(",", $_POST['movie']);
} elseif (isset($_POST["game"])) {
$genre = implode(",", $_POST['game']);
} elseif (isset($_POST["apps"])) {
$genre = implode(",", $_POST['apps']);
} else {
$genre = '';
}
$nfo = sqlesc('');
/////////////////////// NFO FILE ////////////////////////
if (isset($_FILES['nfo']) && !empty($_FILES['nfo']['name'])) {
$nfofile = $_FILES['nfo'];
if ($nfofile['name'] == '')
stderr($lang['takeupload_failed'], $lang['takeupload_no_nfo']);
if ($nfofile['size'] == 0)
stderr($lang['takeupload_failed'], $lang['takeupload_0_byte']);
if ($nfofile['size'] > 65535)
stderr($lang['takeupload_failed'], $lang['takeupload_nfo_big']);
$nfofilename = $nfofile['tmp_name'];
if (@!is_uploaded_file($nfofilename))
stderr($lang['takeupload_failed'], $lang['takeupload_nfo_failed']);
$nfo = sqlesc(str_replace("\x0d\x0d\x0a", "\x0d\x0a", @file_get_contents($nfofilename)));
}
/////////////////////// NFO FILE END /////////////////////
/// Set Freeleech on Torrent Time Based
$free2 = 0;
if (isset($_POST['free_length']) && ($free_length = 0 + $_POST['free_length'])) {
if ($free_length == 255)
$free2 = 1;
elseif ($free_length == 42)
$free2 = (86400 + TIME_NOW);
else
$free2 = (TIME_NOW + $free_length * 604800);
}
/// end
/// Set Silver Torrent Time Based
$silver = 0;
if (isset($_POST['half_length']) && ($half_length = 0 + $_POST['half_length'])) {
if ($half_length == 255)
$silver = 1;
elseif ($half_length == 42)
$silver = (86400 + TIME_NOW);
else
$silver = (TIME_NOW + $half_length * 604800);
}
/// end
//==Xbt freetorrent
$freetorrent = (((isset($_POST['freetorrent']) && is_valid_id($_POST['freetorrent'])) ? intval($_POST['freetorrent']) : 0));
$descr = strip_tags(isset($_POST['descr']) ? trim($_POST['descr']) : '');
if (!$descr)
stderr($lang['takeupload_failed'], $lang['takeupload_no_descr']);
$description = strip_tags(isset($_POST['description']) ? trim($_POST['description']) : '');
if (isset($_POST['strip']) && $_POST['strip']) {
require_once(INCL_DIR . 'strip.php');
$descr = preg_replace("/[^\\x20-\\x7e\\x0a\\x0d]/", " ", $descr);
strip($descr);
//$descr = preg_replace("/\n+/","\n",$descr);
}
$catid = (0 + $_POST["type"]);
if (!is_valid_id($catid))
stderr($lang['takeupload_failed'], $lang['takeupload_no_cat']);
$request = (((isset($_POST['request']) && is_valid_id($_POST['request'])) ? intval($_POST['request']) : 0));
$offer = (((isset($_POST['offer']) && is_valid_id($_POST['offer'])) ? intval($_POST['offer']) : 0));
$subs = isset($_POST["subs"]) ? implode(",", $_POST['subs']) : "";
$release_group_array = array(
'scene' => 1,
'p2p' => 1,
'none' => 1
);
$release_group = isset($_POST['release_group']) && isset($release_group_array[$_POST['release_group']]) ? $_POST['release_group'] : 'none';
$youtube = '';
if (isset($_POST['youtube']) && preg_match($youtube_pattern, $_POST['youtube'], $temp_youtube))
$youtube = $temp_youtube[0];
$tags = strip_tags(isset($_POST['tags']) ? trim($_POST['tags']) : '');
if (!validfilename($fname))
stderr($lang['takeupload_failed'], $lang['takeupload_invalid']);
if (!preg_match('/^(.+)\.torrent$/si', $fname, $matches))
stderr($lang['takeupload_failed'], $lang['takeupload_not_torrent']);
$shortfname = $torrent = $matches[1];
if (!empty($_POST["name"]))
$torrent = unesc($_POST["name"]);
$tmpname = $f["tmp_name"];
if (!is_uploaded_file($tmpname))
stderr($lang['takeupload_failed'], $lang['takeupload_eek']);
if (!filesize($tmpname))
stderr($lang['takeupload_failed'], $lang['takeupload_no_file']);
// bencdec by djGrrr <3
$dict = bencdec::decode_file($tmpname, $INSTALLER09['max_torrent_size'], bencdec::OPTION_EXTENDED_VALIDATION);
if ($dict === false)
stderr('Error', 'What the hell did you upload? This is not a bencoded file!');
if (isset($dict['announce-list']))
unset($dict['announce-list']);
$dict['info']['private'] = 1;
if (!isset($dict['info']))
stderr('Error', 'invalid torrent, info dictionary does not exist');
$info =& $dict['info'];
$infohash = pack("H*", sha1(bencdec::encode($info)));
if (bencdec::get_type($info) != 'dictionary')
stderr('Error', 'invalid torrent, info is not a dictionary');
if (!isset($info['name']) || !isset($info['piece length']) || !isset($info['pieces']))
stderr('Error', 'invalid torrent, missing parts of the info dictionary');
if (bencdec::get_type($info['name']) != 'string' || bencdec::get_type($info['piece length']) != 'integer' || bencdec::get_type($info['pieces']) != 'string')
stderr('Error', 'invalid torrent, invalid types in info dictionary');
$dname = $info['name'];
$plen = $info['piece length'];
$pieces_len = strlen($info['pieces']);
if ($pieces_len % 20 != 0)
stderr('Error', 'invalid pieces');
if ($plen % 4096)
stderr('Error', 'piece size is not mod(4096), wtf kind of torrent is that?');
$filelist = array();
if (isset($info['length'])) {
if (bencdec::get_type($info['length']) != 'integer')
stderr('Error', 'length must be an integer');
$totallen = $info['length'];
$filelist[] = array(
$dname,
$totallen
);
$type = 'single';
} else {
if (!isset($info['files']))
stderr('Error', 'missing both length and files');
if (bencdec::get_type($info['files']) != 'list')
stderr('Error', 'invalid files, not a list');
$flist =& $info['files'];
if (!count($flist))
stderr('Error', 'no files');
$totallen = 0;
foreach ($flist as $fn) {
if (!isset($fn['length']) || !isset($fn['path']))
stderr('Error', 'file info not found');
if (bencdec::get_type($fn['length']) != 'integer' || bencdec::get_type($fn['path']) != 'list')
stderr('Error', 'invalid file info');
$ll = $fn['length'];
$ff = $fn['path'];
$totallen += $ll;
$ffa = array();
foreach ($ff as $ffe) {
if (bencdec::get_type($ffe) != 'string')
stderr('Error', 'filename type error');
$ffa[] = $ffe;
}
if (!count($ffa))
stderr('Error', 'filename error');
$ffe = implode('/', $ffa);
$filelist[] = array(
$ffe,
$ll
);
}
$type = 'multi';
}
$num_pieces = $pieces_len / 20;
$expected_pieces = (int) ceil($totallen / $plen);
if ($num_pieces != $expected_pieces)
stderr('Whoops', 'total file size and number of pieces do not match');
//==
$tmaker = (isset($dict['created by']) && !empty($dict['created by'])) ? sqlesc($dict['created by']) : sqlesc($lang['takeupload_unkown']);
$dict['comment'] = ("In using this torrent you are bound by the {$INSTALLER09['site_name']} Confidentiality Agreement By Law"); // change torrent comment
// Replace punctuation characters with spaces
$visible = (XBT_TRACKER == true ? "yes" : "no");
$torrent = str_replace("_", " ", $torrent);
$vip = (isset($_POST["vip"]) ? "1" : "0");
//IMDB if entered in the form
$url = strip_tags(isset($_POST['url']) ? trim($_POST['url']) : '');
//If no IMDB entered lets look in the description for one
if (empty($url)) {
$text = $descr;
preg_match_all('/((http|https|ftp):\/\/|www)([a-z0-9\-\._]+)\/?[a-z0-9_\.\-\?\+\/~=&;,]*/si', $text, $match);
for ($i = 0; $i < sizeof($match[0]); $i++) {
$requestnftest = $match[0][$i];
$testurl = "http://www.imdb.com/title/tt";
$testurl1 = "http://uk.imdb.com/title/tt";
$testurl2 = "http://imdb.com/title/tt";
$testurl3 = "http://us.imdb.com/title/tt";
$testurl4 = "http://us.imdb.com/Title?";
$test1 = (substr($testurl, 0, 28));
$test2 = (substr($testurl1, 0, 27));
$test3 = (substr($testurl2, 0, 24));
$test4 = (substr($testurl3, 0, 27));
$test5 = (substr($testurl4, 0, 25));
If (substr($requestnftest, 0, 25) == $test5) {
$requestnftest = str_replace("http://us.imdb.com/Title?", 'http://us.imdb.com/title/tt', $requestnftest);
}
if (substr($requestnftest, 0, 28) == $test1 or substr($requestnftest, 0, 27) == $test2 or substr($requestnftest, 0, 24) == $test3 or substr($requestnftest, 0, 27) == $test4) {
$url = trim($requestnftest);
$url = sqlesc($requestnftest);
$url = strip_tags($requestnftest);
}
}
}
//Last attempt at trying to find the IMDB link for this torrent. Lets see if we can find it with a search on IMDB using the torrent name
if (empty($url)) {
class IMDBSearch1
{
public static function _movieRedirect($movie, $year)
{
$movieName = str_replace(' ', '+', $movie);
$page = @file_get_contents('http://www.imdb.com/find?s=all&q=' . $movieName . ' (' . $year . ')');
if (@preg_match('~<p style="margin:0 0 0.5em 0;"><b>Media from .*?href="/title\/(.*?)".*?</p>~s', $page, $matches)) {
header('Location: http://www.imdb.com/title/' . $matches[1] . '');
exit();
} else if (@preg_match('~<td class="result_text">.*?href="/title\/(.*?)".*?</td>~s', $page, $matches)) {
$plorp = substr(strrchr($matches[1], '/'), 1);
$matches[1] = substr($matches[1], 0, -strlen($plorp));
return "http://www.imdb.com/title/$matches[1]";
exit();
} else {
return false;
exit();
}
}
}
//Try and the get name, find the name upto the year (2014) and split it into an array Name and Year. Lets avoid some stuff extra more 1080 and above values
preg_match("/(.*).((!720p|!1080p|!480p|!580p)|[1-2][0-9][0-9][0-9])/", "$fname", $movie_info, null, 0);
$url = IMDBSearch1::_movieRedirect("$movie_info[1]", "$movie_info[2]");
}
if (substr($url, -1) == '/') {
$url = substr($url, 0, -1);
}
//if (!$url)
//stderr($lang['takeupload_failed'], 'No IMDB Found');
$imdb_info = get_imdb($url);
$genre = $imdb_info['gen'];
if (!empty($imdb_info['poster'])) {
$poster = $imdb_info['poster'];
} else
$poster = strip_tags(isset($_POST['poster']) ? trim($_POST['poster']) : '');
//END IMDB
$ret = sql_query("INSERT INTO torrents (search_text, filename, owner, username, visible, vip, release_group, newgenre, poster, anonymous, allow_comments, info_hash, name, size, numfiles, type, offer, request, url, subs, descr, ori_descr, description, category, free, silver, save_as, youtube, tags, added, last_action, mtime, ctime, freetorrent, nfo, client_created_by) VALUES (" . implode(",", array_map("sqlesc", array(
searchfield("$shortfname $dname $torrent"),
$fname,
$CURUSER["id"],
$CURUSER["username"],
$visible,
$vip,
$release_group,
$genre,
$poster,
$anonymous,
$allow_comments,
$infohash,
$torrent,
$totallen,
count($filelist),
$type,
$offer,
$request,
$url,
$subs,
$descr,
$descr,
$description,
0 + $_POST["type"],
$free2,
$silver,
$dname,
$youtube,
$tags
))) . ", " . TIME_NOW . ", " . TIME_NOW . ", " . TIME_NOW . ", " . TIME_NOW . ", $freetorrent, $nfo, $tmaker)");
if (!$ret) {
if (((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_errno($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_errno()) ? $___mysqli_res : false)) == 1062)
stderr($lang['takeupload_failed'], $lang['takeupload_already']);
stderr($lang['takeupload_failed'], "mysql puked: " . ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)));
}
if (XBT_TRACKER == false) {
remove_torrent($infohash);
}
$id = ((is_null($___mysqli_res = mysqli_insert_id($GLOBALS["___mysqli_ston"]))) ? false : $___mysqli_res);
$mc1->delete_value('MyPeers_' . $CURUSER['id']);
//$mc1->delete_value('lastest_tor_'); //
$mc1->delete_value('last5_tor_');
$mc1->delete_value('scroll_tor_');
sql_query("DELETE FROM files WHERE torrent = " . sqlesc($id));
function file_list($arr, $id)
{
foreach ($arr as $v)
$new[] = "($id," . sqlesc($v[0]) . "," . $v[1] . ")";
return join(",", $new);
}
sql_query("INSERT INTO files (torrent, filename, size) VALUES " . file_list($filelist, $id));
//==
$dir = $INSTALLER09['torrent_dir'] . '/' . $id . '.torrent';
if (!bencdec::encode_file($dir, $dict))
stderr('Error', 'Could not properly encode file');
@unlink($tmpname);
chmod($dir, 0664);
//==
//=== if it was an offer notify the folks who liked it :D
if ($offer > 0) {
$res_offer = sql_query('SELECT user_id FROM offer_votes WHERE vote = \'yes\' AND user_id != ' . sqlesc($CURUSER['id']) . ' AND offer_id = ' . sqlesc($offer)) or sqlerr(__FILE__, __LINE__);
$subject = sqlesc('An offer you voted for has been uploaded!');
$message = sqlesc("Hi, \n An offer you were interested in has been uploaded!!! \n\n Click [url=" . $INSTALLER09['baseurl'] . "/details.php?id=" . $id . "]" . htmlsafechars($torrent, ENT_QUOTES) . "[/url] to see the torrent page!");
while ($arr_offer = mysqli_fetch_assoc($res_offer)) {
sql_query('INSERT INTO messages (sender, receiver, added, msg, subject, saved, location)
VALUES(0, ' . sqlesc($arr_offer['user_id']) . ', ' . TIME_NOW . ', ' . $message . ', ' . $subject . ', \'yes\', 1)') or sqlerr(__FILE__, __LINE__);
$mc1->delete_value('inbox_new_' . $arr_offer['user_id']);
$mc1->delete_value('inbox_new_sb_' . $arr_offer['user_id']);
}
write_log('Offered torrent ' . $id . ' (' . htmlsafechars($torrent) . ') was uploaded by ' . $CURUSER['username']);
$filled = 1;
}
$filled = 0;
//=== if it was a request notify the folks who voted :D
if ($request > 0) {
$res_req = sql_query('SELECT user_id FROM request_votes WHERE vote = \'yes\' AND request_id = ' . sqlesc($request)) or sqlerr(__FILE__, __LINE__);
$subject = sqlesc('A request you were interested in has been uploaded!');
$message = sqlesc("Hi :D \n A request you were interested in has been uploaded!!! \n\n Click [url=" . $INSTALLER09['baseurl'] . "/details.php?id=" . $id . "]" . htmlsafechars($torrent, ENT_QUOTES) . "[/url] to see the torrent page!");
while ($arr_req = mysqli_fetch_assoc($res_req)) {
sql_query('INSERT INTO messages (sender, receiver, added, msg, subject, saved, location)
VALUES(0, ' . sqlesc($arr_req['user_id']) . ', ' . TIME_NOW . ', ' . $message . ', ' . $subject . ', \'yes\', 1)') or sqlerr(__FILE__, __LINE__);
$mc1->delete_value('inbox_new_' . $arr_req['user_id']);
$mc1->delete_value('inbox_new_sb_' . $arr_req['user_id']);
}
sql_query('UPDATE requests SET filled_by_user_id = ' . sqlesc($CURUSER['id']) . ', filled_torrent_id = ' . sqlesc($id) . ' WHERE id = ' . sqlesc($request)) or sqlerr(__FILE__, __LINE__);
sql_query("UPDATE usersachiev SET reqfilled = reqfilled + 1 WHERE id =" . sqlesc($CURUSER['id'])) or sqlerr(__FILE__, __LINE__);
write_log('Request for torrent ' . $id . ' (' . htmlsafechars($torrent) . ') was filled by ' . $CURUSER['username']);
$filled = 1;
}
if ($filled == 0)
write_log(sprintf($lang['takeupload_log'], $id, $torrent, $CURUSER['username']));
/* RSS feeds */
if (($fd1 = @fopen("rss.xml", "w")) && ($fd2 = fopen("rssdd.xml", "w"))) {
$cats = "";
$res = sql_query("SELECT id, name FROM categories");
while ($arr = mysqli_fetch_assoc($res))
$cats[$arr["id"]] = htmlsafechars($arr["name"]);
$s = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>\n<rss version=\"0.91\">\n<channel>\n" . "<title>{$INSTALLER09['site_name']}</title>\n<description>Installer09 is the best!</description>\n<link>{$INSTALLER09['baseurl']}/</link>\n";
@fwrite($fd1, $s);
@fwrite($fd2, $s);
$r = sql_query("SELECT id,name,descr,filename,category FROM torrents ORDER BY added DESC LIMIT 15") or sqlerr(__FILE__, __LINE__);
while ($a = mysqli_fetch_assoc($r)) {
$cat = $cats[$a["category"]];
$s = "<item>\n<title>" . htmlsafechars($a["name"] . " ($cat)") . "</title>\n" . "<description>" . htmlsafechars($a["descr"]) . "</description>\n";
@fwrite($fd1, $s);
@fwrite($fd2, $s);
@fwrite($fd1, "<link>{$INSTALLER09['baseurl']}/details.php?id=" . (int) $a['id'] . "&hit=1</link>\n</item>\n");
$filename = htmlsafechars($a["filename"]);
@fwrite($fd2, "<link>{$INSTALLER09['baseurl']}/download.php?torrent=" . (int) $a['id'] . "/$filename</link>\n</item>\n");
}
$s = "</channel>\n</rss>\n";
@fwrite($fd1, $s);
@fwrite($fd2, $s);
@fclose($fd1);
@fclose($fd2);
}
/* end rss */
$categorie = genrelist();
foreach ($categorie as $key => $value) $change[$value['id']] = array(
'id' => $value['id'],
'name' => $value['name']
);
$Cat_Name['cat_name'] = htmlsafechars($change[$_POST['type']]['name']);
if ($INSTALLER09['seedbonus_on'] == 1) {
if (isset($_POST['uplver']) && $_POST['uplver'] == 'yes')
$message = "New Torrent : Category = ".htmlsafechars($Cat_Name['cat_name']).", [url={$INSTALLER09['baseurl']}/details.php?id=$id] " . htmlsafechars($torrent) . "[/url] Uploaded - Anonymous User";
else
$message = "New Torrent : Category = ".htmlsafechars($Cat_Name['cat_name']).", [url={$INSTALLER09['baseurl']}/details.php?id=$id] " . htmlsafechars($torrent) . "[/url] Uploaded by " . htmlsafechars($CURUSER["username"]) . "";
$messages = "{$INSTALLER09['site_name']} New Torrent : Category = ".htmlsafechars($Cat_Name['cat_name']).", $torrent Uploaded By: $anon " . mksize($totallen) . " {$INSTALLER09['baseurl']}/details.php?id=$id";
//===add karma
sql_query("UPDATE users SET seedbonus=seedbonus+" . sqlesc($INSTALLER09['bonus_per_upload']) . ", numuploads=numuploads+1 WHERE id = " . sqlesc($CURUSER["id"])) or sqlerr(__FILE__, __LINE__);
//===end
$update['seedbonus'] = ($CURUSER['seedbonus'] + $INSTALLER09['bonus_per_upload']);
$mc1->begin_transaction('userstats_' . $CURUSER["id"]);
$mc1->update_row(false, array(
'seedbonus' => $update['seedbonus']
));
$mc1->commit_transaction($INSTALLER09['expires']['u_stats']);
$mc1->begin_transaction('user_stats_' . $CURUSER["id"]);
$mc1->update_row(false, array(
'seedbonus' => $update['seedbonus']
));
$mc1->commit_transaction($INSTALLER09['expires']['user_stats']);
}
if ($INSTALLER09['autoshout_on'] == 1) {
autoshout($message);
ircbot($messages);
$mc1->delete_value('shoutbox_');
}
/* Email notifs */
/*******************
$res = sql_query("SELECT name FROM categories WHERE id=".sqlesc($catid)) or sqlerr(__FILE__, __LINE__);
$arr = mysqli_fetch_assoc($res);
$cat = htmlsafechars($arr["name"]);
$res = sql_query("SELECT email FROM users WHERE enabled='yes' AND notifs LIKE '%[cat$catid]%'") or sqlerr(__FILE__, __LINE__);
$uploader = $CURUSER['username'];
$size = mksize($totallen);
$description = ($html ? strip_tags($descr) : $descr);
$body = <<<EOD
A new torrent has been uploaded.
Name: $torrent
Size: $size
Category: $cat
Uploaded by: $uploader
Description
-------------------------------------------------------------------------------
$description
-------------------------------------------------------------------------------
You can use the URL below to download the torrent (you may have to login).
{$INSTALLER09['baseurl']}/details.php?id=$id&hit=1
--
{$INSTALLER09['site_name']}
EOD;
$to = "";
$nmax = 100; // Max recipients per message
$nthis = 0;
$ntotal = 0;
$total = mysqli_num_rows($res);
while ($arr = mysqli_fetch_row($res))
{
if ($nthis == 0)
$to = $arr[0];
else
$to .= "," . $arr[0];
++$nthis;
++$ntotal;
if ($nthis == $nmax || $ntotal == $total)
{
if (!mail("Multiple recipients <{$INSTALLER09['site_email']}>", "New torrent - $torrent", $body,
"From: {$INSTALLER09['site_email']}\r\nBcc: $to"))
stderr("Error", "Your torrent has been been uploaded. DO NOT RELOAD THE PAGE!\n" .
"There was however a problem delivering the e-mail notifcations.\n" .
"Please let an administrator know about this error!\n");
$nthis = 0;
}
}
*******************/
header("Location: {$INSTALLER09['baseurl']}/details.php?id=$id&uploaded=1");
?>