diff --git a/install/sql/mysql.sql b/install/sql/mysql.sql
index 41df08673..0937b060c 100644
--- a/install/sql/mysql.sql
+++ b/install/sql/mysql.sql
@@ -562,16 +562,13 @@ INSERT INTO `bb_config` VALUES ('birthday_max_age', '99');
INSERT INTO `bb_config` VALUES ('birthday_min_age', '10');
INSERT INTO `bb_config` VALUES ('birthday_check_day', '7');
INSERT INTO `bb_config` VALUES ('bt_add_auth_key', '1');
-INSERT INTO `bb_config` VALUES ('bt_add_comment', '');
-INSERT INTO `bb_config` VALUES ('bt_add_publisher', 'YourSiteName');
INSERT INTO `bb_config` VALUES ('bt_allow_spmode_change', '1');
-INSERT INTO `bb_config` VALUES ('bt_announce_url', 'http://yourdomain.com/bt/announce.php');
+INSERT INTO `bb_config` VALUES ('bt_announce_url', 'http://demo.torrentpier.me/bt/announce.php');
INSERT INTO `bb_config` VALUES ('bt_disable_dht', '0');
INSERT INTO `bb_config` VALUES ('bt_check_announce_url', '0');
INSERT INTO `bb_config` VALUES ('bt_del_addit_ann_urls', '1');
INSERT INTO `bb_config` VALUES ('bt_dl_list_only_1st_page', '1');
INSERT INTO `bb_config` VALUES ('bt_dl_list_only_count', '1');
-INSERT INTO `bb_config` VALUES ('bt_gen_passkey_on_reg', '1');
INSERT INTO `bb_config` VALUES ('bt_newtopic_auto_reg', '1');
INSERT INTO `bb_config` VALUES ('bt_replace_ann_url', '1');
INSERT INTO `bb_config` VALUES ('bt_search_bool_mode', '1');
@@ -615,7 +612,7 @@ INSERT INTO `bb_config` VALUES ('seed_bonus_release', '');
INSERT INTO `bb_config` VALUES ('seed_bonus_points', '');
INSERT INTO `bb_config` VALUES ('seed_bonus_tor_size', '0');
INSERT INTO `bb_config` VALUES ('seed_bonus_user_regdate', '0');
-INSERT INTO `bb_config` VALUES ('site_desc', 'A _little_ text to describe your forum');
+INSERT INTO `bb_config` VALUES ('site_desc', 'A little text to describe your forum');
INSERT INTO `bb_config` VALUES ('sitename', 'TorrentPier II - Torrent Tracker');
INSERT INTO `bb_config` VALUES ('smilies_path', 'images/smiles');
INSERT INTO `bb_config` VALUES ('topics_per_page', '50');
diff --git a/upload/admin/admin_bt_forum_cfg.php b/upload/admin/admin_bt_forum_cfg.php
index 5e01b6b60..b614b9b5e 100644
--- a/upload/admin/admin_bt_forum_cfg.php
+++ b/upload/admin/admin_bt_forum_cfg.php
@@ -22,9 +22,7 @@ $cfg = array();
// All config names with default values
$default_cfg_str = array(
- 'bt_announce_url' => 'http://yourdomain.com/bt/',
- 'bt_add_comment' => '',
- 'bt_add_publisher' => '',
+ 'bt_announce_url' => 'http://demo.torrentpier.me/bt/',
);
$default_cfg_bool = array(
@@ -34,7 +32,6 @@ $default_cfg_bool = array(
'bt_show_dl_list' => 0,
'bt_dl_list_only_1st_page' => 1,
'bt_dl_list_only_count' => 1,
- 'bt_gen_passkey_on_reg' => 1,
'bt_replace_ann_url' => 1,
'bt_show_ip_only_moder' => 1,
'bt_show_port_only_moder' => 1,
diff --git a/upload/config.php b/upload/config.php
index 271094fcf..d9e0602da 100644
--- a/upload/config.php
+++ b/upload/config.php
@@ -55,8 +55,8 @@ $domain_name = (!empty($_SERVER['SERVER_NAME'])) ? $_SERVER['SERVER_NAME'] : $do
// Increase number of revision after update
$bb_cfg['tp_version'] = '2.5 (unstable)';
-$bb_cfg['tp_release_date'] = '21-01-2014';
-$bb_cfg['tp_release_state'] = 'R564';
+$bb_cfg['tp_release_date'] = '23-01-2014';
+$bb_cfg['tp_release_state'] = 'R565';
// Database
$charset = 'utf8';
@@ -191,11 +191,6 @@ $rating_limits = array(
'0.6' => 3,
);
-// Seeding torrents limit
-$bb_cfg['max_seeding_torrents'] = 0; // 0 - unlimited
-$bb_cfg['min_up_speed_per_torrent'] = 500; // bytes
-$bb_cfg['too_many_seeding_redirect_url'] = 'viewtopic.php?t=TOPIC_ID';
-
// DL-Status
$bb_cfg['dl_will_days_keep'] = 60; // days to keep user's dlstatus records
$bb_cfg['dl_down_days_keep'] = 30;
diff --git a/upload/includes/bbcode.php b/upload/includes/bbcode.php
index 7757beffb..8afc01f56 100644
--- a/upload/includes/bbcode.php
+++ b/upload/includes/bbcode.php
@@ -117,7 +117,7 @@ function generate_smilies($mode)
{
if (empty($rowset[$row['smile_url']]))
{
- $rowset[$row['smile_url']]['code'] = str_replace("'", "\\'", str_replace('\\', '\\\\', $row['code']));
+ $rowset[$row['smile_url']]['code'] = addslashes($row['code']);
$rowset[$row['smile_url']]['emoticon'] = $row['emoticon'];
$num_smilies++;
}
@@ -142,8 +142,8 @@ function generate_smilies($mode)
$template->assign_block_vars('smilies_row.smilies_col', array(
'SMILEY_CODE' => $data['code'],
'SMILEY_IMG' => $bb_cfg['smilies_path'] . '/' . $smile_url,
- 'SMILEY_DESC' => $data['emoticon'])
- );
+ 'SMILEY_DESC' => $data['emoticon'],
+ ));
$s_colspan = max($s_colspan, $col + 1);
@@ -167,8 +167,8 @@ function generate_smilies($mode)
$template->assign_block_vars('switch_smilies_extra', array());
$template->assign_vars(array(
- 'U_MORE_SMILIES' => "posting.php?mode=smilies")
- );
+ 'U_MORE_SMILIES' => POSTING_URL ."?mode=smilies",
+ ));
}
$template->assign_vars(array(
@@ -292,14 +292,11 @@ function strip_quotes ($text)
/**
* Strips away bbcode from a given string, leaving plain text
*
- * @param string Text to be stripped of bbcode tags
- * @param bool $stripquotes
- * @param bool $fast_and_dirty
- * @param bool $showlinks
- * @internal param \If $boolean true, strip away quote tags AND their contents
- * @internal param \If $boolean true, use the fast-and-dirty method rather than the shiny and nice method
+ * @param string Text to be stripped of bbcode tags
+ * @param boolean If true, strip away quote tags AND their contents
+ * @param boolean If true, use the fast-and-dirty method rather than the shiny and nice method
*
- * @return string
+ * @return string
*/
function strip_bbcode ($message, $stripquotes = true, $fast_and_dirty = false, $showlinks = true)
{
@@ -420,9 +417,9 @@ function replace_synonyms ($text)
return ($syn_match && $syn_replace) ? str_replace($syn_match, $syn_replace, $text) : $text;
}
-function add_search_words ($post_id, $post_message, $post_title = '', $only_return_words = false)
+function add_search_words ($post_id, $post_message, $topic_title = '', $only_return_words = false)
{
- $text = $post_title .' '. $post_message;
+ $text = $topic_title .' '. $post_message;
$text = strip_bbcode_uid($text);
$words = ($text) ? extract_search_words($text) : array();
diff --git a/upload/includes/functions.php b/upload/includes/functions.php
index 87fcf76ec..df5aa8f67 100644
--- a/upload/includes/functions.php
+++ b/upload/includes/functions.php
@@ -1954,6 +1954,19 @@ function message_die ($msg_code, $msg_text = '', $msg_title = '', $err_line = ''
exit;
}
+function bb_simple_die ($txt)
+{
+ global $bb_cfg;
+
+ if (!empty($_COOKIE['explain']))
+ {
+ bb_die("bb_simple_die:
$txt");
+ }
+
+ header('Content-Type: text/plain; charset='. $bb_cfg['charset']);
+ die($txt);
+}
+
function phpbb_realpath($path)
{
return (!@function_exists('realpath') || !@realpath(INC_DIR . 'functions.php')) ? $path : @realpath($path);
diff --git a/upload/includes/functions_torrent.php b/upload/includes/functions_torrent.php
index d0e73756b..860e62546 100644
--- a/upload/includes/functions_torrent.php
+++ b/upload/includes/functions_torrent.php
@@ -228,49 +228,19 @@ function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVE
$forum_id = $torrent['forum_id'];
$poster_id = $torrent['poster_id'];
- if ($torrent['extension'] !== TORRENT_EXT)
- {
- torrent_error_exit($lang['NOT_TORRENT']);
- }
-
- if (!$torrent['allow_reg_tracker'])
- {
- torrent_error_exit($lang['REG_NOT_ALLOWED_IN_THIS_FORUM']);
- }
-
- if ($post_id != $torrent['topic_first_post_id'])
- {
- torrent_error_exit($lang['ALLOWED_ONLY_1ST_POST_REG']);
- }
-
- if ($torrent['tracker_status'])
- {
- torrent_error_exit($lang['ALREADY_REG']);
- }
-
- if ($this_topic_torrents = get_registered_torrents($topic_id, 'topic'))
- {
- torrent_error_exit($lang['ONLY_1_TOR_PER_TOPIC']);
- }
+ if ($torrent['extension'] !== TORRENT_EXT) return torrent_error_exit($lang['NOT_TORRENT']);
+ if (!$torrent['allow_reg_tracker']) return torrent_error_exit($lang['REG_NOT_ALLOWED_IN_THIS_FORUM']);
+ if ($post_id != $torrent['topic_first_post_id']) return torrent_error_exit($lang['ALLOWED_ONLY_1ST_POST_REG']);
+ if ($torrent['tracker_status']) return torrent_error_exit($lang['ALREADY_REG']);
+ if ($this_topic_torrents = get_registered_torrents($topic_id, 'topic')) return torrent_error_exit($lang['ONLY_1_TOR_PER_TOPIC']);
torrent_auth_check($forum_id, $torrent['poster_id']);
$filename = get_attachments_dir() .'/'. $torrent['physical_filename'];
- if (!is_file($filename))
- {
- torrent_error_exit('File name error');
- }
-
- if (!file_exists($filename))
- {
- torrent_error_exit('File not exists');
- }
-
- if (!$tor = bdecode_file($filename))
- {
- torrent_error_exit('This is not a bencoded file');
- }
+ if (!is_file($filename)) return torrent_error_exit('File name error');
+ if (!file_exists($filename)) return torrent_error_exit('File not exists');
+ if (!$tor = bdecode_file($filename)) return torrent_error_exit('This is not a bencoded file');
if ($bb_cfg['bt_disable_dht'])
{
@@ -290,43 +260,33 @@ function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVE
if (!$ann || !in_array($ann, $announce_urls))
{
$msg = sprintf($lang['INVALID_ANN_URL'], htmlspecialchars($ann), $announce_urls['main_url']);
- torrent_error_exit($msg);
+ return torrent_error_exit($msg);
}
}
$info = (@$tor['info']) ? $tor['info'] : array();
- if (!@$info['name'] || !@$info['piece length'] || !@$info['pieces'] || strlen($info['pieces']) % 20 != 0)
+ if (!isset($info['name']) || !isset($info['piece length']) || !isset($info['pieces']) || strlen($info['pieces']) % 20 != 0)
{
- torrent_error_exit($lang['TORFILE_INVALID']);
+ return torrent_error_exit($lang['TORFILE_INVALID']);
}
$info_hash = pack('H*', sha1(bencode($info)));
$info_hash_sql = rtrim(DB()->escape($info_hash), ' ');
$info_hash_md5 = md5($info_hash);
- $sql = "SELECT topic_id
- FROM ". BB_BT_TORRENTS ."
- WHERE info_hash = '$info_hash_sql'
- LIMIT 1";
-
- if (!$result = DB()->sql_query($sql))
+ if ($row = DB()->fetch_row("SELECT topic_id FROM ". BB_BT_TORRENTS ." WHERE info_hash = '$info_hash_sql' LIMIT 1"))
{
- message_die(GENERAL_ERROR, 'Could not obtain torrent info', '', __LINE__, __FILE__, $sql);
- }
- if ($row = DB()->sql_fetchrow($result))
- {
- $msg = sprintf($lang['BT_REG_FAIL_SAME_HASH'], TOPIC_URL . $row['topic_id']);
- torrent_error_exit($msg);
+ return torrent_error_exit(sprintf($lang['BT_REG_FAIL_SAME_HASH'], TOPIC_URL . $row['topic_id']));
}
$totallen = 0;
- if (@$info['length'])
+ if (isset($info['length']))
{
$totallen = (float) $info['length'];
}
- else if (@$info['files'] && is_array($info['files']))
+ else if (isset($info['files']) && is_array($info['files']))
{
foreach ($info['files'] as $fn => $f)
{
@@ -335,7 +295,7 @@ function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVE
}
else
{
- torrent_error_exit($lang['TORFILE_INVALID']);
+ return torrent_error_exit($lang['TORFILE_INVALID']);
}
$reg_time = TIMENOW;
@@ -352,7 +312,7 @@ function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVE
if ($sql_error['code'] == 1062) // Duplicate entry
{
- torrent_error_exit($lang['BT_REG_FAIL_SAME_HASH']);
+ return torrent_error_exit($lang['BT_REG_FAIL_SAME_HASH']);
}
message_die(GENERAL_ERROR, 'Could not register torrent on tracker', '', __LINE__, __FILE__, $sql);
}
@@ -445,17 +405,9 @@ function send_torrent_with_passkey ($filename)
if (!$passkey_val)
{
- if ($bb_cfg['bt_gen_passkey_on_reg'])
+ if (!$passkey_val = generate_passkey($user_id))
{
- if (!$passkey_val = generate_passkey($user_id))
- {
- message_die(GENERAL_ERROR, 'Could not insert passkey', '', __LINE__, __FILE__, $sql);
- }
- }
- else
- {
- $mess = sprintf($lang['PASSKEY_ERR_EMPTY'], "profile.php?mode=editprofile#bittorrent");
- message_die(GENERAL_ERROR, $mess);
+ bb_simple_die('Could not generate passkey');
}
}
@@ -482,35 +434,6 @@ function send_torrent_with_passkey ($filename)
}
}
- // Seeding torrents limit
- if ($bb_cfg['max_seeding_torrents'] && IS_USER)
- {
- $seeding = DB()->fetch_row("
- SELECT COUNT(DISTINCT topic_id) AS torrents, SUM(speed_up) AS sum_up
- FROM ". BB_BT_TRACKER ."
- WHERE user_id = $user_id
- AND seeder = 1
- ");
-
- if ($seeding && $seeding['torrents'] > $bb_cfg['max_seeding_torrents'] && $bt_userdata['u_up_total'] < 200*1024*1024*1024)
- {
- if ($seeding['sum_up'] < ($seeding['torrents'] * $bb_cfg['min_up_speed_per_torrent']))
- {
- $msg = array();
- $msg[] = date('m-d H:i:s');
- $msg[] = sprintf('%-30s', html_entity_decode($userdata['username'])." ($user_id)");
- $msg[] = sprintf('%-3s', $seeding['torrents']);
- $msg[] = sprintf('%.2f', @$user_ratio);
- $msg[] = sprintf('%-9s', humn_size($bt_userdata['u_up_total'], '', '', ' '));
- $msg[] = humn_size($seeding['sum_up'], '', '', ' ');
- $msg = join(LOG_SEPR, $msg) . LOG_LF;
- bb_log($msg, 'overseed/current');
-
- redirect($bb_cfg['too_many_seeding_redirect_url']);
- }
- }
- }
-
// Announce URL
$ann_url = $bb_cfg['bt_announce_url'];
@@ -538,59 +461,33 @@ function send_torrent_with_passkey ($filename)
}
// Add publisher & topic url
- $publisher = $bb_cfg['bt_add_publisher'];
- $publisher_url = ($post_id) ? make_url(POST_URL . $post_id) : '';
+ $publisher_name = $bb_cfg['server_name'];
+ $publisher_url = make_url(TOPIC_URL . $topic_id);
- if ($publisher)
- {
- $tor['publisher'] = strval($publisher);
- unset($tor['publisher.utf-8']);
+ $tor['publisher'] = strval($publisher_name);
+ unset($tor['publisher.utf-8']);
- if ($publisher_url)
- {
- $tor['publisher-url'] = strval($publisher_url);
- unset($tor['publisher-url.utf-8']);
- }
- }
+ $tor['publisher-url'] = strval($publisher_url);
+ unset($tor['publisher-url.utf-8']);
- // Add comment
- $comment = '';
- $orig_com = (@$tor['comment']) ? $tor['comment'] : '';
- if ($bb_cfg['bt_add_comment'])
- {
- $comment = $bb_cfg['bt_add_comment'];
- }
- else
- {
- $comment = ($publisher_url) ? $publisher_url : '';
- }
-
- if ($comment = trim($comment))
- {
- $tor['comment'] = strval($comment);
- unset($tor['comment.utf-8']);
- }
-
- //Azureus DHT disable
- $tor['azureus_properties'] = array('dht_backup_enable' => intval(0));
+ $tor['comment'] = strval($publisher_url);
+ unset($tor['comment.utf-8']);
// Send torrent
$output = bencode($tor);
- $filename = clean_filename(basename($attachment['real_filename']));
- $mimetype = 'application/x-bittorrent;';
- $charset = (strpos(USER_AGENT, 'pera') && @$lang['CONTENT_ENCODING']) ? "charset={$lang['CONTENT_ENCODING']};" : '';
+ $dl_fname = ($bb_cfg['torrent_name_style'] ? '['.$bb_cfg['server_name'].'].t' . $topic_id . '.torrent' : clean_filename(basename($attachment['real_filename'])));
- header("Content-Type: $mimetype $charset name=\"$filename\"");
- if ($bb_cfg['torrent_name_style'])
+ if (!empty($_COOKIE['explain']))
{
- $header_file_name = 'Content-Disposition: attachment; filename="['.$bb_cfg['server_name'].'].t' . $topic_id . '.torrent"';
- header($header_file_name);
- }
- else
- {
- header("Content-Disposition: attachment; filename=\"$filename\"");
+ $out = "attach path: $filename
";
+ $tor['info']['pieces'] = '[...] '. strlen($tor['info']['pieces']) .' bytes';
+ $out .= print_r($tor, true);
+ bb_die("
$out"); } + header("Content-Type: application/x-bittorrent; name=\"$dl_fname\""); + header("Content-Disposition: attachment; filename=\"$dl_fname\""); + bb_exit($output); } @@ -623,16 +520,16 @@ function generate_passkey ($user_id, $force_generate = false) $passkey_val = make_rand_str(BT_AUTH_KEY_LENGTH); // Insert new row - $sql = "INSERT IGNORE INTO ". BB_BT_USERS ." (user_id, auth_key) VALUES ($user_id, '$passkey_val')"; + DB()->query("INSERT IGNORE INTO ". BB_BT_USERS ." (user_id, auth_key) VALUES ($user_id, '$passkey_val')"); - if (DB()->sql_query($sql) && DB()->affected_rows() == 1) + if (DB()->affected_rows() == 1) { return $passkey_val; } // Update - $sql = "UPDATE IGNORE ". BB_BT_USERS ." SET auth_key = '$passkey_val' WHERE user_id = $user_id LIMIT 1"; + DB()->query("UPDATE IGNORE ". BB_BT_USERS ." SET auth_key = '$passkey_val' WHERE user_id = $user_id LIMIT 1"); - if (DB()->sql_query($sql) && DB()->affected_rows() == 1) + if (DB()->affected_rows() == 1) { return $passkey_val; } @@ -684,6 +581,7 @@ function torrent_error_exit ($message) global $reg_mode, $return_message, $lang; $msg = ''; + if (isset($reg_mode) && ($reg_mode == 'request' || $reg_mode == 'newtopic')) { if (isset($return_message)) @@ -692,9 +590,8 @@ function torrent_error_exit ($message) } $msg .= ''. $lang['BT_REG_FAIL'] .'