diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..87694ddab --- /dev/null +++ b/.editorconfig @@ -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 diff --git a/.gitignore b/.gitignore index 49e80b6e8..ac8ce0648 100644 --- a/.gitignore +++ b/.gitignore @@ -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 \ No newline at end of file +*.rej diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md deleted file mode 100644 index f0b8bfcbd..000000000 --- a/CONTRIBUTORS.md +++ /dev/null @@ -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, -с указанием вашего ника на форуме и адреса вашего трекера, дабы мы могли вас добавить в этот список. \ No newline at end of file diff --git a/README.md b/README.md index 20abcc987..f8694443b 100644 --- a/README.md +++ b/README.md @@ -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** это также распространяется. ## Полезные ссылки diff --git a/common.php b/common.php index 6fd87d508..69a85b0bc 100644 --- a/common.php +++ b/common.php @@ -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'); diff --git a/composer.json b/composer.json new file mode 100644 index 000000000..71bb0fd77 --- /dev/null +++ b/composer.json @@ -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 +} diff --git a/library/config.php b/library/config.php index efc03b855..9ad13ece2 100644 --- a/library/config.php +++ b/library/config.php @@ -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', ), ); diff --git a/library/includes/classes/recaptcha.php b/library/includes/classes/recaptcha.php deleted file mode 100644 index fee71caae..000000000 --- a/library/includes/classes/recaptcha.php +++ /dev/null @@ -1,164 +0,0 @@ -" . self::$_signupUrl . ""); - } - $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; - } -} diff --git a/library/includes/functions.php b/library/includes/functions.php index cc18f3e55..2fe75fada 100644 --- a/library/includes/functions.php +++ b/library/includes/functions.php @@ -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 . "' }); };
- "; + "; 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; diff --git a/library/language/en/html/sidebar2.html b/library/language/en/html/sidebar2.html index d18cea2a2..1ba622327 100644 --- a/library/language/en/html/sidebar2.html +++ b/library/language/en/html/sidebar2.html @@ -9,10 +9,3 @@If you haven\'t already generated the keys, you can do it on https://www.google.com/recaptcha/admin.
After you generate the keys, you need to put them at the file library/config.php.
Если вы еще не сгенерировали ключи, вы можете это сделать на странице https://www.google.com/recaptcha/admin.
После того, как вы сгенерируете ключи, нужно прописать их в файл library/config.php.
Якщо ви ще не згенерували ключі, ви можете це зробити на сторінці https://www.google.com/recaptcha/admin.
Після того, як ви сгенеріруете ключі, потрібно прописати їх у файл library/config.php.