diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
new file mode 100644
index 000000000..179dd4f62
--- /dev/null
+++ b/CONTRIBUTING.md
@@ -0,0 +1,92 @@
+# Contributing
+
+When contributing to this repository, please first discuss the change you wish to make via issue,
+email, or any other method with the owners of this repository before making a change.
+
+Please note we have a code of conduct, please follow it in all your interactions with the project.
+
+## Pull Request Process
+
+1. Ensure any install or build dependencies are removed before the end of the layer when doing a
+ build.
+2. Update the README.md with details of changes to the interface, this includes new environment
+ variables, exposed ports, useful file locations and container parameters.
+3. Increase the version numbers in any examples files and the README.md to the new version that this
+ Pull Request would represent. The versioning scheme we use is [SemVer](http://semver.org/).
+4. You may merge the Pull Request in once you have the sign-off of two other developers, or if you
+ do not have permission to do that, you may request the second reviewer to merge it for you.
+
+## Code of Conduct
+
+### Our Pledge
+
+In the interest of fostering an open and welcoming environment, we as
+contributors and maintainers pledge to making participation in our project and
+our community a harassment-free experience for everyone, regardless of age, body
+size, disability, ethnicity, gender identity and expression, level of experience,
+nationality, personal appearance, race, religion, or sexual identity and
+orientation.
+
+### Our Standards
+
+Examples of behavior that contributes to creating a positive environment
+include:
+
+* Using welcoming and inclusive language
+* Being respectful of differing viewpoints and experiences
+* Gracefully accepting constructive criticism
+* Focusing on what is best for the community
+* Showing empathy towards other community members
+
+Examples of unacceptable behavior by participants include:
+
+* The use of sexualized language or imagery and unwelcome sexual attention or
+advances
+* Trolling, insulting/derogatory comments, and personal or political attacks
+* Public or private harassment
+* Publishing others' private information, such as a physical or electronic
+ address, without explicit permission
+* Other conduct which could reasonably be considered inappropriate in a
+ professional setting
+
+### Our Responsibilities
+
+Project maintainers are responsible for clarifying the standards of acceptable
+behavior and are expected to take appropriate and fair corrective action in
+response to any instances of unacceptable behavior.
+
+Project maintainers have the right and responsibility to remove, edit, or
+reject comments, commits, code, wiki edits, issues, and other contributions
+that are not aligned to this Code of Conduct, or to ban temporarily or
+permanently any contributor for other behaviors that they deem inappropriate,
+threatening, offensive, or harmful.
+
+### Scope
+
+This Code of Conduct applies both within project spaces and in public spaces
+when an individual is representing the project or its community. Examples of
+representing a project or community include using an official project e-mail
+address, posting via an official social media account, or acting as an appointed
+representative at an online or offline event. Representation of a project may be
+further defined and clarified by project maintainers.
+
+### Enforcement
+
+Instances of abusive, harassing, or otherwise unacceptable behavior may be
+reported by contacting the project team at admin@torrentpier.me. All
+complaints will be reviewed and investigated and will result in a response that
+is deemed necessary and appropriate to the circumstances. The project team is
+obligated to maintain confidentiality with regard to the reporter of an incident.
+Further details of specific enforcement policies may be posted separately.
+
+Project maintainers who do not follow or enforce the Code of Conduct in good
+faith may face temporary or permanent repercussions as determined by other
+members of the project's leadership.
+
+### Attribution
+
+This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
+available at [http://contributor-covenant.org/version/1/4][version]
+
+[homepage]: http://contributor-covenant.org
+[version]: http://contributor-covenant.org/version/1/4/
diff --git a/README.md b/README.md
index baa8d6f74..b7e03478b 100644
--- a/README.md
+++ b/README.md
@@ -1,16 +1,21 @@

-
+
+
+
+
+
+
+
+
+
-TorrentPier
-======================
-
-
+# TorrentPier
TorrentPier - движок торрент-трекера, написанный на php. Высокая скорость работы, простота модификации, устойчивость к высоким нагрузкам, в том числе и поддержка альтернативных анонсеров (например, Ocelot). Помимо этого, крайне развитый официальный форум поддержки, где помимо прочего можно испытать движок в работе на демо-версии, не устанавливая его, а также получить любую другую интересующую вас информацию и скачать моды.
-## Установка
+## Installation
Для установки вам необходимо выполнить несколько простых шагов:
@@ -44,7 +49,7 @@ TorrentPier - движок торрент-трекера, написанный
## Необходимая версия php
-Минимально поддерживаемой версией в настоящий момент является 5.3. Существует поддержка вплоть до версии 7.1.
+Минимально поддерживаемой версией в настоящий момент является 5.5. Существует поддержка вплоть до версии 7.1.
## Необходимые настройки php
@@ -73,13 +78,18 @@ TorrentPier - движок торрент-трекера, написанный
Инструкция по сборке приведена на нашем форуме: https://torrentpier.me/threads/sborka-ocelot-pod-debian-7-1.26078/
Для работы анонсера требуется замена двух таблиц в базе данных - дамп в файле: **install/sql/ocelot.sql**
-## Папка install
+## Official Documentation
-В корне движка присутствует папка **install**, в которой находятся служебные файлы, необходимые для его установки (дамп базы, примеры конфигов) и обновления (дамперы, скрипты конвертации). Доступ к данной папке по-умолчанию закрыт, но если ее присутствие вам мешает - вы можете ее удалить. На файл **README.md** это также распространяется.
+Documentation for TorrentPier can be found on the [TorrentPier docs website](https://docs.torrentpier.me).
-## Полезные ссылки
+## Contributing
-+ Наш форум https://torrentpier.me/
-+ Центр загрузки https://get.torrentpier.me/
-+ Часто задаваемые вопросы https://faq.torrentpier.me/
-+ Где задать вопрос https://torrentpier.me/forums/10/
+Please read [CONTRIBUTING.md](CONTRIBUTING.md) for details on our code of conduct, and the process for submitting pull requests to us.
+
+## Versioning
+
+We use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/torrentpier/torrentpier/tags).
+
+## License
+
+This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
diff --git a/bt/announce.php b/bt/announce.php
index 1cc50abd6..99a03eef7 100644
--- a/bt/announce.php
+++ b/bt/announce.php
@@ -178,11 +178,11 @@ function msg_die($msg)
dbg_log(' ', '!die-' . clean_filename($msg));
}
- $output = bencode(array(
+ $output = \Rych\Bencode\Bencode::encode([
'min interval' => (int)1800,
'failure reason' => (string)$msg,
'warning message' => (string)$msg,
- ));
+ ]);
die($output);
}
@@ -473,7 +473,7 @@ if (!$output) {
}
// Return data to client
-echo bencode($output);
+echo \Rych\Bencode\Bencode::encode($output);
tracker_exit();
exit;
diff --git a/bt/includes/init_tr.php b/bt/includes/init_tr.php
index a73ff89c7..bca2b155d 100644
--- a/bt/includes/init_tr.php
+++ b/bt/includes/init_tr.php
@@ -75,7 +75,7 @@ function error_exit($msg = '')
silent_exit();
- echo bencode(array('failure reason' => str_compact($msg)));
+ echo \Rych\Bencode\Bencode::encode(['failure reason' => str_compact($msg)]);
tracker_exit();
}
diff --git a/bt/scrape.php b/bt/scrape.php
index 5d561d327..82705fe38 100644
--- a/bt/scrape.php
+++ b/bt/scrape.php
@@ -50,11 +50,11 @@ function msg_die($msg)
dbg_log(' ', '!die-' . clean_filename($msg));
}
- $output = bencode(array(
+ $output = \Rych\Bencode\Bencode::encode([
'min interval' => (int)1800,
'failure reason' => (string)$msg,
'warning message' => (string)$msg,
- ));
+ ]);
die($output);
}
@@ -77,7 +77,7 @@ $output['files'][$info_hash] = array(
'incomplete' => (int)$row['leechers'],
);
-echo bencode($output);
+echo \Rych\Bencode\Bencode::encode($output);
tracker_exit();
exit;
diff --git a/common.php b/common.php
index ab486e922..eafc2712b 100644
--- a/common.php
+++ b/common.php
@@ -70,7 +70,7 @@ if ($bb_cfg['bugsnag']['enabled'] && !empty($bb_cfg['bugsnag']['api_key'])) {
}
$server_protocol = $bb_cfg['cookie_secure'] ? 'https://' : 'http://';
-$server_port = in_array($bb_cfg['server_port'], array(80, 443), true) ? '' : ':' . $bb_cfg['server_port'];
+$server_port = in_array((int)$bb_cfg['server_port'], array(80, 443), true) ? '' : ':' . $bb_cfg['server_port'];
define('FORUM_PATH', $bb_cfg['script_path']);
define('FULL_URL', $server_protocol . $bb_cfg['server_name'] . $server_port . $bb_cfg['script_path']);
unset($server_protocol, $server_port);
@@ -311,52 +311,6 @@ function make_rand_str($len = 10)
return substr($str, 0, $len);
}
-// bencode: based on OpenTracker
-function bencode($var)
-{
- if (is_string($var)) {
- return strlen($var) . ':' . $var;
- }
-
- if (is_int($var)) {
- return 'i' . $var . 'e';
- } elseif (is_float($var)) {
- return 'i' . sprintf('%.0f', $var) . 'e';
- } elseif (is_array($var)) {
- if (count($var) == 0) {
- return 'de';
- }
-
- $assoc = false;
-
- foreach ($var as $key => $val) {
- if (!is_int($key)) {
- $assoc = true;
- break;
- }
- }
-
- if ($assoc) {
- ksort($var, SORT_REGULAR);
- $ret = 'd';
-
- foreach ($var as $key => $val) {
- $ret .= bencode($key) . bencode($val);
- }
- return $ret . 'e';
- }
-
- $ret = 'l';
-
- foreach ($var as $val) {
- $ret .= bencode($val);
- }
- return $ret . 'e';
- } else {
- trigger_error('bencode error: wrong data type', E_USER_ERROR);
- }
-}
-
function array_deep(&$var, $fn, $one_dimensional = false, $array_only = false)
{
if (is_array($var)) {
@@ -462,11 +416,11 @@ elseif (defined('IN_TRACKER')) {
function dummy_exit($interval = 1800)
{
- $output = bencode(array(
+ $output = \Rych\Bencode\Bencode::encode([
'interval' => (int)$interval,
'min interval' => (int)$interval,
'peers' => (string)DUMMY_PEER,
- ));
+ ]);
die($output);
}
diff --git a/composer.json b/composer.json
index a7a350d45..027a40233 100644
--- a/composer.json
+++ b/composer.json
@@ -26,11 +26,6 @@
"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": {
@@ -38,15 +33,16 @@
"issues": "https://github.com/torrentpier/torrentpier/issues",
"forum": "https://torrentpier.me/forum/",
"get": "https://get.torrentpier.me/",
- "docs": "https://faq.torrentpier.me/"
+ "docs": "https://docs.torrentpier.me/"
},
"require": {
- "php": "^5.3 || ^7.0",
+ "php": "^5.5 || ^7.0",
"bugsnag/bugsnag": "^3.0",
"gigablah/sphinxphp": "^2.0",
"google/recaptcha": "^1.0",
"roave/security-advisories": "dev-master",
- "swiftmailer/swiftmailer": "^6.0"
+ "rych/bencode": "^1.0",
+ "swiftmailer/swiftmailer": "^5.4"
},
"autoload": {
"psr-4": {
diff --git a/library/includes/bbcode.php b/library/includes/bbcode.php
index 99e62851f..61742f255 100644
--- a/library/includes/bbcode.php
+++ b/library/includes/bbcode.php
@@ -112,7 +112,7 @@ function bbcode_tpl_compact($text)
// prepare a posted message for entry into the database
function prepare_message($message)
{
- $message = bbcode::clean_up($message);
+ $message = \TorrentPier\Legacy\BBCode::clean_up($message);
$message = htmlCHR($message, false, ENT_NOQUOTES);
return $message;
}
diff --git a/library/includes/functions_torrent.php b/library/includes/functions_torrent.php
index c386c1916..cd4b92c91 100644
--- a/library/includes/functions_torrent.php
+++ b/library/includes/functions_torrent.php
@@ -287,7 +287,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
if ($bb_cfg['bt_disable_dht']) {
$tor['info']['private'] = (int)1;
$fp = fopen($filename, 'wb+');
- fwrite($fp, bencode($tor));
+ fwrite($fp, \Rych\Bencode\Bencode::encode($tor));
fclose($fp);
}
@@ -309,7 +309,7 @@ function tracker_register($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED
return torrent_error_exit($lang['TORFILE_INVALID']);
}
- $info_hash = pack('H*', sha1(bencode($info)));
+ $info_hash = pack('H*', sha1(\Rych\Bencode\Bencode::encode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$info_hash_md5 = md5($info_hash);
@@ -421,7 +421,7 @@ function send_torrent_with_passkey($filename)
}
if (bf($userdata['user_opt'], 'user_opt', 'dis_passkey') && !IS_GUEST) {
- bb_die('Could not add passkey');
+ bb_die($lang['DISALLOWED']);
}
if ($bt_userdata = get_bt_userdata($user_id)) {
@@ -504,7 +504,7 @@ function send_torrent_with_passkey($filename)
unset($tor['comment.utf-8']);
// Send torrent
- $output = bencode($tor);
+ $output = \Rych\Bencode\Bencode::encode($tor);
$dl_fname = ($bb_cfg['torrent_name_style'] ? '[' . $bb_cfg['server_name'] . '].t' . $topic_id . '.torrent' : clean_filename(basename($attachment['real_filename'])));
if (!empty($_COOKIE['explain'])) {
diff --git a/library/includes/init_bb.php b/library/includes/init_bb.php
index 5d4fd9061..499785efc 100644
--- a/library/includes/init_bb.php
+++ b/library/includes/init_bb.php
@@ -26,8 +26,8 @@
if (!defined('BB_ROOT')) {
die(basename(__FILE__));
}
-if (version_compare(PHP_VERSION, '5.3', '<')) {
- die('TorrentPier requires PHP version 5.3+. Your PHP version ' . PHP_VERSION);
+if (version_compare(PHP_VERSION, '5.5', '<')) {
+ die('TorrentPier requires PHP version 5.5+. Your PHP version ' . PHP_VERSION);
}
if (!defined('BB_SCRIPT')) {
define('BB_SCRIPT', 'undefined');