Реформат в PSR-2 + добавление заголовков лицензии MIT в файлы

This commit is contained in:
Yuriy Pikhtarev 2017-01-13 01:20:43 +03:00
commit 3730bed000
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
207 changed files with 44327 additions and 43119 deletions

View file

@ -1,35 +1,60 @@
<?php
/**
* MIT License
*
* Copyright (c) 2005-2017 TorrentPier
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
define('IN_TRACKER', true);
define('BB_ROOT', './../');
require(BB_ROOT .'common.php');
require(BB_ROOT . 'common.php');
if (!$tr_cfg['scrape']) msg_die('Please disable SCRAPE!');
// Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash']))
{
$_GET['info_hash'] = $_GET['?info_hash'];
if (!$tr_cfg['scrape']) {
msg_die('Please disable SCRAPE!');
}
if (!isset($_GET['info_hash']) || strlen($_GET['info_hash']) != 20)
{
msg_die('Invalid info_hash');
// Recover info_hash
if (isset($_GET['?info_hash']) && !isset($_GET['info_hash'])) {
$_GET['info_hash'] = $_GET['?info_hash'];
}
if (!isset($_GET['info_hash']) || strlen($_GET['info_hash']) != 20) {
msg_die('Invalid info_hash');
}
$info_hash = $_GET['info_hash'];
function msg_die ($msg)
function msg_die($msg)
{
if (DBG_LOG) dbg_log(' ', '!die-'. clean_filename($msg));
if (DBG_LOG) {
dbg_log(' ', '!die-' . clean_filename($msg));
}
$output = bencode(array(
'min interval' => (int) 1800,
'failure reason' => (string) $msg,
'warning message' => (string) $msg,
));
$output = bencode(array(
'min interval' => (int)1800,
'failure reason' => (string)$msg,
'warning message' => (string)$msg,
));
die($output);
die($output);
}
define('TR_ROOT', './');
@ -39,19 +64,19 @@ $info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$row = DB()->fetch_row("
SELECT tor.complete_count, snap.seeders, snap.leechers
FROM ". BB_BT_TORRENTS ." tor
LEFT JOIN ". BB_BT_TRACKER_SNAP ." snap ON (snap.topic_id = tor.topic_id)
FROM " . BB_BT_TORRENTS . " tor
LEFT JOIN " . BB_BT_TRACKER_SNAP . " snap ON (snap.topic_id = tor.topic_id)
WHERE tor.info_hash = '$info_hash_sql'
LIMIT 1
");
$output['files'][$info_hash] = array(
'complete' => (int) $row['seeders'],
'downloaded' => (int) $row['complete_count'],
'incomplete' => (int) $row['leechers'],
'complete' => (int)$row['seeders'],
'downloaded' => (int)$row['complete_count'],
'incomplete' => (int)$row['leechers'],
);
echo bencode($output);
tracker_exit();
exit;
exit;