Composer init, editor config, some cleanup and much more

This commit is contained in:
Yuriy Pikhtarev 2017-01-28 02:03:13 +03:00
commit 026401be4c
No known key found for this signature in database
GPG key ID: 3A9B5A757B48ECC6
15 changed files with 120 additions and 266 deletions

19
.editorconfig Normal file
View file

@ -0,0 +1,19 @@
# EditorConfig helps developers define and maintain consistent
# coding styles between different editors and IDEs
# editorconfig.org
root = true
[*]
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
indent_style = space
indent_size = 2
[*.{diff,md}]
trim_trailing_whitespace = false
[*.php]
indent_size = 4

28
.gitignore vendored
View file

@ -1,15 +1,21 @@
### TorrentPier ###
.idea/
data/avatars/
data/old_files/
data/torrent_files/
internal_data/ajax_html/*.html
internal_data/atom/
internal_data/cache/
internal_data/log/
internal_data/sitemap/*.xml
internal_data/triggers/
.idea
bower_components
composer.phar
composer.lock
configs/local.php
data/avatars
data/old_files
data/torrent_files
internal_data/ajax_html
internal_data/atom
internal_data/cache
internal_data/log
internal_data/sitemap
internal_data/triggers
library/config.local.php
node_modules
vendor
### Archives ###
*.log
@ -33,4 +39,4 @@ $RECYCLE.BIN/
.Spotlight-V100
.Trashes
*.orig
*.rej
*.rej

View file

@ -1,48 +0,0 @@
Уважаемые пользователи TorrentPier!
За помощь, оказанную в развитии нашего движка, выражаем особую благодарность нижеперечисленным участникам форума:
***************************
** Сборы 2013 года **
***************************
emilio13
UralSOFT
aik
Sarymian
eve
Алексей Письменский
qaqra
rserg99
leszav
Dr_Brown
Bullit
Triceratop (http://goldenshara.com/)
Ramzess
****************************
** Сборы 2014 года **
****************************
SamSeGo
alesel (http://sporttracker.kz/)
Bullit
igorsaevets
vasilich619
wint1000 (http://asmlocator.ru/)
Philstone (http://worldofminecraft.su/)
Nightwolf
nord51
Вася
Alexander.S (http://torrent.dchub.ws/)
sasha20072007
gerhanovn
*****************************
** Прочая информация **
*****************************
Отдельная благодарность выражается компании JetBrains за предоставление лицензии на PhpStorm (http://www.jetbrains.com/phpstorm/).
Если в данных списках кто-то не указан, либо если вы хотите указать дополнительно адрес своего трекера, отправьте письмо по адресу admin@torrentpier.me,
с указанием вашего ника на форуме и адреса вашего трекера, дабы мы могли вас добавить в этот список.

View file

@ -39,7 +39,7 @@ TorrentPier - движок торрент-трекера, написанный
## Необходимая версия php
Минимально поддерживаемой версией в настоящий момент является 5.3. Существует поддержка вплоть до версии 5.5 (в данной версии в логах будет уведомление об использовании устаревших функций). Версия php 5.6 в настоящее время движком не поддерживается и его работа на ней не гарантируется. Мы делаем все возможное чтобы в самое ближайшее время добавить его поддержку.
Минимально поддерживаемой версией в настоящий момент является 5.3. Существует поддержка вплоть до версии 7.1.
## Необходимые настройки php
@ -69,7 +69,7 @@ TorrentPier - движок торрент-трекера, написанный
## Папка install
В корне движка присутствует папка **install**, в которой находятся служебные файлы, необходимые для его установки (дамп базы, примеры конфигов) и обновления (дамперы, скрипты конвертации). Доступ к данной папке по-умолчанию закрыт, но если ее присутствие вам мешает - вы можете ее удалить. На файлы **README.md** и **CONTRIBUTORS.md** это также распространяется.
В корне движка присутствует папка **install**, в которой находятся служебные файлы, необходимые для его установки (дамп базы, примеры конфигов) и обновления (дамперы, скрипты конвертации). Доступ к данной папке по-умолчанию закрыт, но если ее присутствие вам мешает - вы можете ее удалить. На файл **README.md** это также распространяется.
## Полезные ссылки

View file

@ -53,6 +53,9 @@ if (!defined('IN_FORUM') && !defined('IN_TRACKER')) {
header('X-Frame-Options: SAMEORIGIN');
// Composer
require_once(BB_ROOT . 'vendor/autoload.php');
// Get initial config
require(BB_ROOT . 'library/config.php');

54
composer.json Normal file
View file

@ -0,0 +1,54 @@
{
"name": "torrentpier/torrentpier",
"description": "TorrentPier. Bittorrent-tracker engine",
"type": "project",
"keywords": [
"bittorrent",
"forum",
"torrent",
"tracker"
],
"homepage": "https://torrentpier.me/",
"license": "MIT",
"authors": [
{
"name": "Exile",
"email": "admin@torrentpier.me",
"homepage": "https://torrentpier.me/forum/members/exile.1/",
"role": "Developer"
},
{
"name": "Diolektor",
"homepage": "https://torrentpier.me/forum/members/diolektor.5765/",
"role": "Developer"
},
{
"name": "PheRum",
"homepage": "https://torrentpier.me/forum/members/pherum.23/",
"role": "Developer"
},
{
"name": "tpuser",
"homepage": "https://torrentpier.me/forum/members/tpuser.7560/",
"role": "Developer"
}
],
"support": {
"email": "support@torrentpier.me",
"issues": "https://github.com/torrentpier/torrentpier/issues",
"forum": "https://torrentpier.me/forum/",
"get": "https://get.torrentpier.me/",
"docs": "https://faq.torrentpier.me/"
},
"require": {
"php": "^5.3 || ^7.0",
"google/recaptcha": "^1.0"
},
"autoload": {
"psr-4": {
"TorrentPier\\": "src/"
}
},
"minimum-stability": "stable",
"prefer-stable": true
}

View file

@ -323,19 +323,16 @@ $bb_cfg['lang'] = array(
'name' => 'Русский',
'locale' => 'ru_RU.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'ru',
),
'uk' => array(
'name' => 'Український',
'locale' => 'uk_UA.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'uk',
),
'en' => array(
'name' => 'English',
'locale' => 'en_US.UTF-8',
'encoding' => 'UTF-8',
'captcha' => 'en',
),
);

View file

@ -1,164 +0,0 @@
<?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.
*/
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
/**
* This is a PHP library that handles calling reCAPTCHA.
* - Documentation and latest version
* https://developers.google.com/recaptcha/docs/php
* - Get a reCAPTCHA API Key
* https://www.google.com/recaptcha/admin/create
* - Discussion group
* http://groups.google.com/group/recaptcha
*
* @copyright Copyright (c) 2014, Google Inc.
* @link http://www.google.com/recaptcha
*
* 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.
*/
/**
* A ReCaptchaResponse is returned from checkAnswer().
*/
class ReCaptchaResponse
{
public $success;
public $errorCodes;
}
class ReCaptcha
{
private static $_signupUrl = "https://www.google.com/recaptcha/admin";
private static $_siteVerifyUrl = "https://www.google.com/recaptcha/api/siteverify?";
private $_secret;
private static $_version = "php_1.0";
/**
* Constructor.
*
* @param string $secret shared secret between site and ReCAPTCHA server.
*/
public function __construct($secret)
{
if ($secret == null || $secret == "") {
die("To use Google reCAPTCHA you must get an API key from <a href='" . self::$_signupUrl . "'>" . self::$_signupUrl . "</a>");
}
$this->_secret = $secret;
}
/**
* Encodes the given data into a query string format.
*
* @param array $data array of string elements to be encoded.
*
* @return string - encoded request.
*/
private function _encodeQS($data)
{
$req = "";
foreach ($data as $key => $value) {
$req .= $key . '=' . urlencode(stripslashes($value)) . '&';
}
// Cut the last '&'
$req = substr($req, 0, strlen($req) - 1);
return $req;
}
/**
* Submits an HTTP GET to a reCAPTCHA server.
*
* @param string $path url path to recaptcha server.
* @param array $data array of parameters to be sent.
*
* @return array response
*/
private function _submitHTTPGet($path, $data)
{
$req = $this->_encodeQS($data);
$response = file_get_contents($path . $req);
return $response;
}
/**
* Calls the reCAPTCHA siteverify API to verify whether the user passes
* CAPTCHA test.
*
* @param string $remoteIp IP address of end user.
* @param string $response response string from recaptcha verification.
*
* @return ReCaptchaResponse
*/
public function verifyResponse($remoteIp, $response)
{
// Discard empty solution submissions
if ($response == null || strlen($response) == 0) {
$recaptchaResponse = new ReCaptchaResponse();
$recaptchaResponse->success = false;
$recaptchaResponse->errorCodes = 'missing-input';
return $recaptchaResponse;
}
$getResponse = $this->_submitHttpGet(
self::$_siteVerifyUrl,
array(
'secret' => $this->_secret,
'remoteip' => $remoteIp,
'v' => self::$_version,
'response' => $response
)
);
$answers = json_decode($getResponse, true);
$recaptchaResponse = new ReCaptchaResponse();
if (trim($answers['success']) == true) {
$recaptchaResponse->success = true;
} else {
$recaptchaResponse->success = false;
$recaptchaResponse->errorCodes = $answers['error-codes'];
}
return $recaptchaResponse;
}
}

View file

@ -2551,18 +2551,27 @@ function hash_search($hash)
}
}
/**
* Функция для получения и проверки правильности ответа от Google ReCaptcha.
*
* @param $mode
* @param string $callback
*
* @return bool|string
*/
function bb_captcha($mode, $callback = '')
{
global $bb_cfg, $userdata;
require_once(CLASS_DIR . 'recaptcha.php');
global $bb_cfg, $lang;
$secret = $bb_cfg['captcha']['secret_key'];
$public = $bb_cfg['captcha']['public_key'];
$theme = $bb_cfg['captcha']['theme'];
$lang = $bb_cfg['lang'][$userdata['user_lang']]['captcha'];
$cp_theme = $bb_cfg['captcha']['theme'];
$reCaptcha = new ReCaptcha($secret);
if (!$public && !$secret) {
bb_die($lang['CAPTCHA_SETTINGS']);
}
$reCaptcha = new \ReCaptcha\ReCaptcha($secret);
switch ($mode) {
case 'get':
@ -2571,26 +2580,22 @@ function bb_captcha($mode, $callback = '')
var onloadCallback = function() {
grecaptcha.render('tp-captcha', {
'sitekey' : '" . $public . "',
'theme' : '" . $theme . "',
'theme' : '" . $cp_theme . "',
'callback' : '" . $callback . "'
});
};
</script>
<div id=\"tp-captcha\"></div>
<script src=\"https://www.google.com/recaptcha/api.js?onload=onloadCallback&hl=" . $lang . "&render=explicit\" async defer></script>";
<script src=\"https://www.google.com/recaptcha/api.js?onload=onloadCallback&render=explicit\" async defer></script>";
break;
case 'check':
$resp = null;
$error = null;
$g_resp = request_var('g-recaptcha-response', '');
if ($g_resp) {
$resp = $reCaptcha->verifyResponse($_SERVER["REMOTE_ADDR"], $g_resp);
}
if ($resp != null && $resp->success) {
$resp = $reCaptcha->verify(
request_var('g-recaptcha-response', ''),
$_SERVER["REMOTE_ADDR"]
);
if ($resp->isSuccess()) {
return true;
} else {
return false;
}
break;

View file

@ -9,10 +9,3 @@
<br />
To disable this sidebar, set the variable $page_cfg['show_sidebar2'] in file config.php to false.
</div>
<br />
<div>
<h3>Partners</h3>
We are grateful to all people who have made material assistance to the development of TorrentPier, specified in the file contributors.txt.
</div>

View file

@ -2817,3 +2817,4 @@ $lang['UPLOAD_ERRORS'] = array(
// Captcha
$lang['CAPTCHA'] = 'Check that you are not a robot';
$lang['CAPTCHA_WRONG'] = 'You could not confirm that you are not a robot';
$lang['CAPTCHA_SETTINGS'] = '<h2>ReCaptcha not being fully configured</h2><p>If you haven\'t already generated the keys, you can do it on <a href="https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a>.<br />After you generate the keys, you need to put them at the file library/config.php.</p>';

View file

@ -9,10 +9,3 @@
<br />
Для отключения данной боковой панели, установите значение переменной $page_cfg['show_sidebar2'] в файле config.php в положение false.
</div>
<br />
<div>
<h3>Партнеры</h3>
Выражаем благодарность всем людям, внесшим материальную помощь в развитие TorrentPier, указанным в файле contributors.txt.
</div>

View file

@ -2817,3 +2817,4 @@ $lang['UPLOAD_ERRORS'] = array(
// Captcha
$lang['CAPTCHA'] = 'Проверка, что вы не робот';
$lang['CAPTCHA_WRONG'] = 'Вы не смогли подтвердить, что вы не робот';
$lang['CAPTCHA_SETTINGS'] = '<h2>ReCaptcha настроена не полностью</h2><p>Если вы еще не сгенерировали ключи, вы можете это сделать на странице <a href="https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a>.<br />После того, как вы сгенерируете ключи, нужно прописать их в файл library/config.php.</p>';

View file

@ -9,10 +9,3 @@
<br />
Для відключення даної бічній панелі, встановіть значення змінної $page_cfg['show_sidebar2'] у файлі config.php в положення false.
</div>
<br />
<div>
<h3>Партнери</h3>
Висловлюємо подяку всім людям, які зробили матеріальну допомогу в розвиток TorrentPier, вказаним у файлі contributors.txt.
</div>

View file

@ -2817,3 +2817,4 @@ $lang['UPLOAD_ERRORS'] = array(
// Captcha
$lang['CAPTCHA'] = 'Перевірка, що ви не робот';
$lang['CAPTCHA_WRONG'] = 'Ви не змогли підтвердити, що ви не робот';
$lang['CAPTCHA_SETTINGS'] = '<h2>ReCaptcha налаштована не повністю</h2><p>Якщо ви ще не згенерували ключі, ви можете це зробити на сторінці <a href="https://www.google.com/recaptcha/admin">https://www.google.com/recaptcha/admin</a>.<br />Після того, як ви сгенеріруете ключі, потрібно прописати їх у файл library/config.php.</p>';