diff --git a/README.md b/README.md index 0e55470e3..03597f610 100644 --- a/README.md +++ b/README.md @@ -53,15 +53,22 @@ TorrentPier II - движок торрент-трекера, написанны ## Рекомендуемый способ запуска cron.php -Для значительного ускорения работы трекера может потребоваться отвязка встроенного форумного крона. С более подробной информацией об отвязке крона, вы можете ознакомиться в данной теме http://torrentpier.me/threads/52/ на нашем форуме поддержки. +Для значительного ускорения работы трекера может потребоваться отвязка встроенного форумного крона. С более подробной информацией об отвязке крона, вы можете ознакомиться в данной теме https://torrentpier.me/threads/52/ на нашем форуме поддержки. ## Локальный файл конфигурации Начиная с ревизии 599 была добавлена поддерка автоматического подключения файла config.local.php, при создании его вами. В данном файле вы можете переопределять настройки файла config.php для конкретного сервера, на котором запущен трекер или в целом менять стандартные значения файла config.php, для более простого обновления файлов движка в дальнейшем. +## Установка Ocelot + +В движок встроена по-умолчанию поддержка альтернативного компилируемого анонсера - Ocelot. Настройка производится в файле **library/config.php**, сам анонсер находится в репозитории https://github.com/torrentpier/ocelot + +Инструкция по сборке приведена на нашем форуме: https://torrentpier.me/threads/sborka-ocelot-pod-debian-7-1.26078/ +Для работы анонсера требуется замена двух таблиц в базе данных - дамп в файле: **install/sql/ocelot.sql** + ## Полезные ссылки -+ Наш форум http://torrentpier.me/ -+ Центр загрузки http://get.torrentpier.me/ -+ Часто задаваемые вопросы http://faq.torrentpier.me/ -+ Где задать вопрос http://torrentpier.me/forums/10/ ++ Наш форум https://torrentpier.me/ ++ Центр загрузки https://get.torrentpier.me/ ++ Часто задаваемые вопросы https://faq.torrentpier.me/ ++ Где задать вопрос https://torrentpier.me/forums/10/ diff --git a/contributors.txt b/contributors.txt index d659e2e15..c88224b24 100644 --- a/contributors.txt +++ b/contributors.txt @@ -16,7 +16,7 @@ qaqra rserg99 leszav Dr_Brown -Bullit (http://bestrip.org/) +Bullit Triceratop (http://goldenshara.com/) Ramzess @@ -26,7 +26,7 @@ Ramzess SamSeGo alesel (http://sporttracker.kz/) -Bullit (http://bestrip.org/) +Bullit igorsaevets vasilich619 wint1000 (http://asmlocator.ru/) diff --git a/install/sql/ocelot.sql b/install/sql/ocelot.sql new file mode 100644 index 000000000..cff9c322c --- /dev/null +++ b/install/sql/ocelot.sql @@ -0,0 +1,54 @@ +SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; + +-- +-- Удаление старых таблиц +-- + +DROP TABLE IF EXISTS `bb_bt_tracker`; +DROP TABLE IF EXISTS `bb_bt_tracker_snap`; + +-- +-- Структура таблицы `bb_bt_tracker` +-- + +CREATE TABLE IF NOT EXISTS `bb_bt_tracker` ( + `peer_hash` varchar(32) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL DEFAULT '', + `topic_id` mediumint(8) unsigned NOT NULL DEFAULT '0', + `peer_id` varchar(20) NOT NULL, + `user_id` mediumint(9) NOT NULL DEFAULT '0', + `ip` varchar(15) NOT NULL DEFAULT '0', + `client` varchar(51) NOT NULL DEFAULT 'Unknown', + `ipv6` varchar(32) DEFAULT NULL, + `port` smallint(5) unsigned NOT NULL DEFAULT '0', + `seeder` tinyint(1) NOT NULL DEFAULT '0', + `releaser` tinyint(1) NOT NULL DEFAULT '0', + `tor_type` tinyint(1) NOT NULL DEFAULT '0', + `uploaded` bigint(20) unsigned NOT NULL DEFAULT '0', + `downloaded` bigint(20) unsigned NOT NULL DEFAULT '0', + `remain` bigint(20) unsigned NOT NULL DEFAULT '0', + `speed_up` mediumint(8) unsigned NOT NULL DEFAULT '0', + `speed_down` mediumint(8) unsigned NOT NULL DEFAULT '0', + `up_add` bigint(20) unsigned NOT NULL DEFAULT '0', + `down_add` bigint(20) unsigned NOT NULL DEFAULT '0', + `update_time` int(11) NOT NULL DEFAULT '0', + `complete_percent` bigint(20) NOT NULL DEFAULT '0', + PRIMARY KEY (`peer_hash`), + KEY `topic_id` (`topic_id`), + KEY `user_id` (`user_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; + +-- -------------------------------------------------------- + +-- +-- Структура таблицы `bb_bt_tracker_snap` +-- + +CREATE TABLE IF NOT EXISTS `bb_bt_tracker_snap` ( + `topic_id` mediumint(8) unsigned NOT NULL DEFAULT '0', + `seeders` mediumint(8) unsigned NOT NULL DEFAULT '0', + `leechers` mediumint(8) unsigned NOT NULL DEFAULT '0', + `speed_up` int(10) unsigned NOT NULL DEFAULT '0', + `speed_down` int(10) unsigned NOT NULL DEFAULT '0', + `complete` int(11) NOT NULL, + PRIMARY KEY (`topic_id`) +) ENGINE=MyISAM DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/upload/admin/admin_cron.php b/upload/admin/admin_cron.php index 2f45987c6..7999137c4 100644 --- a/upload/admin/admin_cron.php +++ b/upload/admin/admin_cron.php @@ -58,7 +58,7 @@ switch ($mode) 'ROW_CLASS' => !($i % 2) ? 'row2' : 'row1', 'JOB_ID' => $i + 1, 'CRON_ID' => $row['cron_id'], - 'CRON_ACTIVE' => $row['cron_active'] ? '' : '', + 'CRON_ACTIVE' => $row['cron_active'] ? '' : '', 'CRON_TITLE' => $row['cron_title'], 'CRON_SCRIPT' => $row['cron_script'], 'SCHEDULE' => $row['schedule'] ? $lang['SCHEDULE'][$row['schedule']] : ''. $lang['NOSELECT'] .'', diff --git a/upload/library/attach_mod/posting_attachments.php b/upload/library/attach_mod/posting_attachments.php index f01bc0cd9..df5091e0d 100644 --- a/upload/library/attach_mod/posting_attachments.php +++ b/upload/library/attach_mod/posting_attachments.php @@ -7,7 +7,6 @@ define('FILENAME_PREFIX_LENGTH', 6); define('FILENAME_MAX_LENGTH', 180); define('FILENAME_CRYPTIC', false); define('FILENAME_CRYPTIC_LENGTH', 64); -define('FILENAME_TRANSLITERATE', true); class attach_parent { @@ -964,10 +963,6 @@ class attach_parent { $this->attach_filename = make_rand_str(FILENAME_CRYPTIC_LENGTH); } - else if (FILENAME_TRANSLITERATE) - { - $this->attach_filename = transliterate($this->attach_filename); - } else { // original $this->attach_filename = html_entity_decode(trim(stripslashes($this->attach_filename))); diff --git a/upload/library/config.php b/upload/library/config.php index bd4b2704a..ff89baf9d 100644 --- a/upload/library/config.php +++ b/upload/library/config.php @@ -1,6 +1,7 @@ '127.0.0.1', 'port' => 11211, @@ -144,9 +148,6 @@ if (isset($_SERVER['HTTP_CF_CONNECTING_IP'])) $_SERVER['REMOTE_ADDR'] = $_SERVER['HTTP_CF_CONNECTING_IP']; } -// Increase number after changing js or css -$bb_cfg['js_ver'] = $bb_cfg['css_ver'] = 1; - // GZip $bb_cfg['gzip_compress'] = true; // compress output @@ -157,6 +158,16 @@ $bb_cfg['ignore_reported_ip'] = false; // Ignore IP reported by clie $bb_cfg['verify_reported_ip'] = true; // Verify IP reported by client against $_SERVER['HTTP_X_FORWARDED_FOR'] $bb_cfg['allow_internal_ip'] = false; // Allow internal IP (10.xx.. etc.) +// Ocelot +$bb_cfg['ocelot'] = array( + 'enabled' => false, + 'host' => $domain_name, + 'port' => 34000, + 'url' => "http://$domain_name:34000/", // with '/' + 'secret' => 'some_10_chars', // 10 chars + 'stats' => 'some_10_chars', // 10 chars +); + // FAQ url help link $bb_cfg['how_to_download_url_help'] = 'viewtopic.php?t=1'; // Как скачивать? $bb_cfg['what_is_torrent_url_help'] = 'viewtopic.php?t=2'; // Что такое торрент? @@ -254,6 +265,7 @@ define('INC_DIR', BB_PATH .'/library/includes/' ); define('CLASS_DIR', BB_PATH .'/library/includes/classes/'); define('UCP_DIR', BB_PATH .'/library/includes/ucp/' ); define('LANG_ROOT_DIR', BB_PATH .'/library/language/' ); +define('IMAGES_DIR', BB_PATH .'/styles/images/' ); define('TEMPLATES_DIR', BB_PATH .'/styles/templates/' ); // URL's @@ -346,12 +358,14 @@ $bb_cfg['reg_email_activation'] = false; // Требовать акт // Email $bb_cfg['emailer_disabled'] = false; -$bb_cfg['smtp_delivery'] = false; // set true if you want or have to send email via a named server instead of the local mail function +$bb_cfg['smtp_delivery'] = false; // send email via a named server instead of the local mail function +$bb_cfg['smtp_ssl'] = false; // use ssl connect $bb_cfg['smtp_host'] = ''; // SMTP server host -$bb_cfg['smtp_password'] = ''; // enter a password if your SMTP server requires it +$bb_cfg['smtp_port'] = 25; // SMTP server port $bb_cfg['smtp_username'] = ''; // enter a username if your SMTP server requires it +$bb_cfg['smtp_password'] = ''; // enter a password if your SMTP server requires it -$bb_cfg['board_email'] = 'noreply@' . $domain_name; // admin email address +$bb_cfg['board_email'] = "noreply@$domain_name"; // admin email address $bb_cfg['board_email_form'] = false; // can users send email to each other via board $bb_cfg['board_email_sig'] = ''; // this text will be attached to all emails the board sends $bb_cfg['board_email_sitename'] = $domain_name; // sitename used in all emails header @@ -361,9 +375,9 @@ $bb_cfg['pm_notify_enabled'] = true; $bb_cfg['group_send_email'] = true; $bb_cfg['email_change_disabled'] = false; // disable changing email by user -$bb_cfg['tech_admin_email'] = 'admin@' . $domain_name; // email for sending error reports -$bb_cfg['abuse_email'] = 'abuse@' . $domain_name; -$bb_cfg['adv_email'] = 'adv@' . $domain_name; +$bb_cfg['tech_admin_email'] = "admin@$domain_name"; // email for sending error reports +$bb_cfg['abuse_email'] = "abuse@$domain_name"; +$bb_cfg['adv_email'] = "adv@$domain_name"; // Debug define('DBG_LOG', false); // enable forum debug (off on production) @@ -560,7 +574,7 @@ $bb_cfg['avatars'] = array( // Group avatars $bb_cfg['group_avatars'] = array( 'allowed_ext' => array('gif','jpg','jpeg','png'), // разрешенные форматы файлов - 'max_size' => 100*1024, // размер аватары в байтах + 'max_size' => 300*1024, // размер аватары в байтах 'max_height' => 300, // высота аватара в px 'max_width' => 300, // ширина аватара в px 'no_avatar' => 'gallery/noavatar.png', // дефолтная аватара diff --git a/upload/library/includes/cron/jobs/tr_complete_count.php b/upload/library/includes/cron/jobs/tr_complete_count.php index fee5ff427..66230187e 100644 --- a/upload/library/includes/cron/jobs/tr_complete_count.php +++ b/upload/library/includes/cron/jobs/tr_complete_count.php @@ -2,29 +2,47 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); -// Get complete counts -DB()->query(" - CREATE TEMPORARY TABLE tmp_complete_count - SELECT - topic_id, COUNT(*) AS compl_cnt - FROM ". BB_BT_TORSTAT ." - WHERE completed = 0 - GROUP BY topic_id -"); +global $bb_cfg; -// Update USER "completed" counters -DB()->query("UPDATE ". BB_BT_TORSTAT ." SET completed = 1"); +if ($bb_cfg['ocelot']['enabled']) +{ + // Update TORRENT "completed" counters + DB()->query(" + UPDATE + ". BB_BT_TORRENTS ." tor, + ". BB_BT_TRACKER_SNAP. " snap + SET + tor.complete_count = snap.complete + WHERE + tor.topic_id = snap.topic_id + "); +} +else +{ + // Get complete counts + DB()->query(" + CREATE TEMPORARY TABLE tmp_complete_count + SELECT + topic_id, COUNT(*) AS compl_cnt + FROM ". BB_BT_TORSTAT ." + WHERE completed = 0 + GROUP BY topic_id + "); -// Update TORRENT "completed" counters -DB()->query(" - UPDATE - ". BB_BT_TORRENTS ." tor, - tmp_complete_count tmp - SET - tor.complete_count = tor.complete_count + tmp.compl_cnt - WHERE - tor.topic_id = tmp.topic_id -"); + // Update USER "completed" counters + DB()->query("UPDATE ". BB_BT_TORSTAT ." SET completed = 1"); -// Drop tmp table -DB()->query("DROP TEMPORARY TABLE tmp_complete_count"); \ No newline at end of file + // Update TORRENT "completed" counters + DB()->query(" + UPDATE + ". BB_BT_TORRENTS ." tor, + tmp_complete_count tmp + SET + tor.complete_count = tor.complete_count + tmp.compl_cnt + WHERE + tor.topic_id = tmp.topic_id + "); + + // Drop tmp table + DB()->query("DROP TEMPORARY TABLE tmp_complete_count"); +} \ No newline at end of file diff --git a/upload/library/includes/cron/jobs/tr_make_snapshot.php b/upload/library/includes/cron/jobs/tr_make_snapshot.php index 83fdbd1dc..7f5041188 100644 --- a/upload/library/includes/cron/jobs/tr_make_snapshot.php +++ b/upload/library/includes/cron/jobs/tr_make_snapshot.php @@ -2,17 +2,21 @@ if (!defined('BB_ROOT')) die(basename(__FILE__)); +global $bb_cfg; + DB()->expect_slow_query(600); // // Make tracker snapshot // -define('NEW_BB_BT_TRACKER_SNAP', 'new_tracker_snap'); -define('OLD_BB_BT_TRACKER_SNAP', 'old_tracker_snap'); +if (!$bb_cfg['ocelot']['enabled']) +{ + define('NEW_BB_BT_TRACKER_SNAP', 'new_tracker_snap'); + define('OLD_BB_BT_TRACKER_SNAP', 'old_tracker_snap'); -DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_TRACKER_SNAP .", ". OLD_BB_BT_TRACKER_SNAP); - -DB()->query("CREATE TABLE ". NEW_BB_BT_TRACKER_SNAP ." LIKE ". BB_BT_TRACKER_SNAP); + DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TRACKER_SNAP . ", " . OLD_BB_BT_TRACKER_SNAP); + DB()->query("CREATE TABLE " . NEW_BB_BT_TRACKER_SNAP . " LIKE " . BB_BT_TRACKER_SNAP); +} $per_cycle = 50000; $row = DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM ". BB_BT_TRACKER); @@ -25,44 +29,78 @@ while (true) $end_id = $start_id + $per_cycle - 1; $val = array(); - $sql = " - SELECT - topic_id, SUM(seeder) AS seeders, (COUNT(*) - SUM(seeder)) AS leechers, - SUM(speed_up) AS speed_up, SUM(speed_down) AS speed_down - FROM ". BB_BT_TRACKER ." - WHERE topic_id BETWEEN $start_id AND $end_id - GROUP BY topic_id - "; + + if (!$bb_cfg['ocelot']['enabled']) + { + $sql = " + SELECT + topic_id, SUM(seeder) AS seeders, (COUNT(*) - SUM(seeder)) AS leechers, + SUM(speed_up) AS speed_up, SUM(speed_down) AS speed_down + FROM " . BB_BT_TRACKER . " + WHERE topic_id BETWEEN $start_id AND $end_id + GROUP BY topic_id + "; + } + else + { + $sql = " + SELECT + topic_id, SUM(speed_up) AS speed_up, SUM(speed_down) AS speed_down + FROM " . BB_BT_TRACKER . " + WHERE topic_id BETWEEN $start_id AND $end_id + GROUP BY topic_id + "; + } + foreach (DB()->fetch_rowset($sql) as $row) { $val[] = join(',', $row); } + if ($val) { - DB()->query(" - REPLACE INTO ". NEW_BB_BT_TRACKER_SNAP ." - (topic_id, seeders, leechers, speed_up, speed_down) - VALUES(". join('),(', $val) .") - "); + if (!$bb_cfg['ocelot']['enabled']) + { + DB()->query(" + REPLACE INTO " . NEW_BB_BT_TRACKER_SNAP . " + (topic_id, seeders, leechers, speed_up, speed_down) + VALUES(" . join('),(', $val) . ") + "); + } + else + { + DB()->query(" + INSERT INTO " . BB_BT_TRACKER_SNAP . " + (topic_id, speed_up, speed_down) + VALUES(". join('),(', $val) .") + ON DUPLICATE KEY UPDATE speed_up = VALUES(speed_up), speed_down = VALUES(speed_down) + "); + } } + if ($end_id > $finish_id) { break; } + if (!($start_id % ($per_cycle*10))) { sleep(1); } + $start_id += $per_cycle; } -DB()->query(" - RENAME TABLE - ". BB_BT_TRACKER_SNAP ." TO ". OLD_BB_BT_TRACKER_SNAP .", - ". NEW_BB_BT_TRACKER_SNAP ." TO ". BB_BT_TRACKER_SNAP ." -"); +if (!$bb_cfg['ocelot']['enabled']) +{ + DB()->query(" + RENAME TABLE + ". BB_BT_TRACKER_SNAP ." TO ". OLD_BB_BT_TRACKER_SNAP .", + ". NEW_BB_BT_TRACKER_SNAP ." TO ". BB_BT_TRACKER_SNAP ." + "); -DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_TRACKER_SNAP .", ". OLD_BB_BT_TRACKER_SNAP); + DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_TRACKER_SNAP .", ". OLD_BB_BT_TRACKER_SNAP); +} // // Make dl-list snapshot diff --git a/upload/library/includes/functions.php b/upload/library/includes/functions.php index f151c9cfe..ff885e61c 100644 --- a/upload/library/includes/functions.php +++ b/upload/library/includes/functions.php @@ -1963,18 +1963,7 @@ function topic_attachment_image($switch_attachment) { return ''; } - return ' '; -} - -function transliterate ($str) -{ - static $translit_table; - - if (!isset($translit_table)) - { - require(DEFAULT_LANG_DIR .'translit_table.php'); - } - return strtr($str, $translit_table); + return ' '; } /** @@ -2825,10 +2814,10 @@ function is_gold ($type) switch ($type) { case TOR_TYPE_GOLD: - $is_gold = ' '; + $is_gold = ' '; break; case TOR_TYPE_SILVER: - $is_gold = ' '; + $is_gold = ' '; break; default: $is_gold = ''; diff --git a/upload/library/includes/functions_torrent.php b/upload/library/includes/functions_torrent.php index d3f676a51..6c0472196 100644 --- a/upload/library/includes/functions_torrent.php +++ b/upload/library/includes/functions_torrent.php @@ -61,7 +61,7 @@ function tracker_unregister ($attach_id, $mode = '') global $lang, $bb_cfg; $attach_id = (int) $attach_id; - $post_id = $topic_id = $forum_id = null; + $post_id = $topic_id = $forum_id = $info_hash = null; // Get torrent info if ($torrent = get_torrent_info($attach_id)) @@ -117,6 +117,16 @@ function tracker_unregister ($attach_id, $mode = '') bb_die('Could not delete peers'); } + // Ocelot + if ($bb_cfg['ocelot']['enabled']) + { + if ($row = DB()->fetch_row("SELECT info_hash FROM ". BB_BT_TORRENTS ." WHERE attach_id = $attach_id LIMIT 1")) + { + $info_hash = $row['info_hash']; + } + ocelot_update_tracker('delete_torrent', array('info_hash' => rawurlencode($info_hash), 'id' => $topic_id)); + } + // Delete torrent $sql = "DELETE FROM ". BB_BT_TORRENTS ." WHERE attach_id = $attach_id"; @@ -206,9 +216,21 @@ function change_tor_type ($attach_id, $tor_status_gold) if (!IS_AM) bb_die($lang['ONLY_FOR_MOD']); - $topic_id = $torrent['topic_id']; + $topic_id = $torrent['topic_id']; $tor_status_gold = intval($tor_status_gold); + $info_hash = null; + DB()->query("UPDATE ". BB_BT_TORRENTS ." SET tor_type = $tor_status_gold WHERE topic_id = $topic_id LIMIT 1"); + + // Ocelot + if ($bb_cfg['ocelot']['enabled']) + { + if ($row = DB()->fetch_row("SELECT info_hash FROM ". BB_BT_TORRENTS ." WHERE topic_id = $topic_id LIMIT 1")) + { + $info_hash = $row['info_hash']; + } + ocelot_update_tracker('update_torrent', array('info_hash' => rawurlencode($info_hash), 'freetorrent' => $tor_status_gold)); + } } function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVED, $reg_time = TIMENOW) @@ -227,6 +249,7 @@ function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVE $topic_id = $torrent['topic_id']; $forum_id = $torrent['forum_id']; $poster_id = $torrent['poster_id']; + $info_hash = null; 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']); @@ -275,6 +298,12 @@ function tracker_register ($attach_id, $mode = '', $tor_status = TOR_NOT_APPROVE $info_hash_sql = rtrim(DB()->escape($info_hash), ' '); $info_hash_md5 = md5($info_hash); + // Ocelot + if ($bb_cfg['ocelot']['enabled']) + { + ocelot_update_tracker('add_torrent', array('info_hash' => rawurlencode($info_hash), 'id' => $topic_id, 'freetorrent' => 0)); + } + if ($row = DB()->fetch_row("SELECT topic_id FROM ". BB_BT_TORRENTS ." WHERE info_hash = '$info_hash_sql' LIMIT 1")) { $msg = sprintf($lang['BT_REG_FAIL_SAME_HASH'], TOPIC_URL . $row['topic_id']); @@ -411,6 +440,10 @@ function send_torrent_with_passkey ($filename) { bb_simple_die('Could not generate passkey'); } + elseif ($bb_cfg['ocelot']['enabled']) + { + ocelot_update_tracker('add_user', array('id' => $user_id ,'passkey' => $passkey_val)); + } } // Ratio limits @@ -443,7 +476,7 @@ function send_torrent_with_passkey ($filename) bb_die('This is not a bencoded file'); } - $announce = strval($ann_url . "?$passkey_key=$passkey_val"); + $announce = $bb_cfg['ocelot']['enabled'] ? strval($bb_cfg['ocelot']['url'] .$passkey_val. "/announce") : strval($ann_url . "?$passkey_key=$passkey_val"); // Replace original announce url with tracker default if ($bb_cfg['bt_replace_ann_url'] || !isset($tor['announce'])) @@ -464,7 +497,7 @@ function send_torrent_with_passkey ($filename) // Add retracker if (isset($tr_cfg['retracker']) && $tr_cfg['retracker']) { - if (bf($userdata['user_opt'], 'user_opt', 'user_retracker')) + if (bf($userdata['user_opt'], 'user_opt', 'user_retracker') || IS_GUEST) { if (!isset($tor['announce-list'])) { @@ -513,7 +546,7 @@ function send_torrent_with_passkey ($filename) function generate_passkey ($user_id, $force_generate = false) { - global $lang, $sql; + global $bb_cfg, $lang, $sql; $user_id = (int) $user_id; @@ -538,6 +571,12 @@ function generate_passkey ($user_id, $force_generate = false) for ($i=0; $i < 20; $i++) { $passkey_val = make_rand_str(BT_AUTH_KEY_LENGTH); + $old_passkey = null; + + if ($row = DB()->fetch_row("SELECT auth_key FROM ". BB_BT_USERS ." WHERE user_id = $user_id LIMIT 1")) + { + $old_passkey = $row['auth_key']; + } // Insert new row DB()->query("INSERT IGNORE INTO ". BB_BT_USERS ." (user_id, auth_key) VALUES ($user_id, '$passkey_val')"); @@ -551,6 +590,11 @@ function generate_passkey ($user_id, $force_generate = false) if (DB()->affected_rows() == 1) { + // Ocelot + if ($bb_cfg['ocelot']['enabled']) + { + ocelot_update_tracker('change_passkey', array('oldpasskey' => $old_passkey,'newpasskey' => $passkey_val)); + } return $passkey_val; } } @@ -606,6 +650,86 @@ function torrent_error_exit ($message) bb_die($msg . $message); } +function ocelot_update_tracker ($action, $updates) +{ + global $bb_cfg; + + $get = $bb_cfg['ocelot']['secret'] . "/update?action=$action"; + + foreach ($updates as $key => $value) + { + $get .= "&$key=$value"; + } + + $max_attempts = 3; + $err = false; + + if (ocelot_send_request($get, $max_attempts, $err) === false) + { + return false; + } + + return true; +} + +function ocelot_send_request ($get, $max_attempts = 1, &$err = false) +{ + global $bb_cfg; + + $header = "GET /$get HTTP/1.1\r\nConnection: Close\r\n\r\n"; + $attempts = $sleep = $success = $response = 0; + $start_time = microtime(true); + + while (!$success && $attempts++ < $max_attempts) + { + if ($sleep) + { + sleep($sleep); + } + + // Send request + $file = fsockopen($bb_cfg['ocelot']['host'], $bb_cfg['ocelot']['port'], $error_num, $error_string); + if ($file) + { + if (fwrite($file, $header) === false) + { + $err = "Failed to fwrite()"; + $sleep = 3; + continue; + } + } + else + { + $err = "Failed to fsockopen() - $error_num - $error_string"; + $sleep = 6; + continue; + } + + // Check for response + while (!feof($file)) + { + $response .= fread($file, 1024); + } + $data_start = strpos($response, "\r\n\r\n") + 4; + $data_end = strrpos($response, "\n"); + if ($data_end > $data_start) + { + $data = substr($response, $data_start, $data_end - $data_start); + } + else + { + $data = ""; + } + $status = substr($response, $data_end + 1); + if ($status == "success") + { + $success = true; + } + } + + return $success; +} + // bdecode: based on OpenTracker function bdecode_file ($filename) { diff --git a/upload/library/includes/functions_upload.php b/upload/library/includes/functions_upload.php index a6900f00d..cd335b294 100644 --- a/upload/library/includes/functions_upload.php +++ b/upload/library/includes/functions_upload.php @@ -104,7 +104,7 @@ class upload_common } } // check ext - if (!isset($this->ext_ids[$this->file_ext]) || !in_array($this->file_ext, $this->cfg['allowed_ext'], true)) + if ($uploaded_only && (!isset($this->ext_ids[$this->file_ext]) || !in_array($this->file_ext, $this->cfg['allowed_ext'], true))) { $this->errors[] = sprintf($lang['UPLOAD_ERROR_NOT_ALLOWED'], htmlCHR($this->file_ext)); return false; diff --git a/upload/library/includes/smtp.php b/upload/library/includes/smtp.php index 23afafdbc..175e6685f 100644 --- a/upload/library/includes/smtp.php +++ b/upload/library/includes/smtp.php @@ -83,9 +83,9 @@ function smtpmail($mail_to, $subject, $message, $headers = '') bb_die('Email message was blank'); } - // Ok we have error checked as much as we can to this point let's get on - // it already. - if( !$socket = @fsockopen($bb_cfg['smtp_host'], 25, $errno, $errstr, 20) ) + // Ok we have error checked as much as we can to this point let's get on it already + $ssl = ($bb_cfg['smtp_ssl']) ? 'ssl://' : ''; + if( !$socket = @fsockopen($ssl . $bb_cfg['smtp_host'], $bb_cfg['smtp_port'], $errno, $errstr, 20) ) { bb_die('Could not connect to smtp host : '. $errno .' : '. $errstr); } diff --git a/upload/library/language/en/main.php b/upload/library/language/en/main.php index 039ea430a..c4bf20e7e 100644 --- a/upload/library/language/en/main.php +++ b/upload/library/language/en/main.php @@ -1325,7 +1325,6 @@ $lang['BOT_AFTER_SPLIT_TO_NEW'] = 'Add bot-message about split to new topic $lang['QUICK_REPLY'] = 'Quick Reply'; $lang['INS_NAME_TIP'] = 'Insert name or selected text.'; $lang['QUOTE_SELECTED'] = 'Quote selected'; -$lang['TRANSLIT_RULES'] = 'Translit rules'; $lang['QR_ATTACHSIG'] = 'Attach signature'; $lang['QR_NOTIFY'] = 'Notify on reply'; $lang['QR_DISABLE'] = 'Disable'; @@ -1517,8 +1516,6 @@ $lang['LIST'] = 'List'; $lang['LIST_TITLE'] = 'List: [list]text[/list] (Ctrl+l)'; $lang['LIST_ITEM'] = 'Ordered list: [list=]text[/list] (Ctrl+O)'; $lang['QUOTE_SEL'] = 'Quote selected'; -$lang['TRANSLIT'] = 'Translit'; -$lang['TRANSLIT_TITLE'] = 'Translit selected to russian'; $lang['JAVASCRIPT_ON'] = 'Heads necessary to send messages to enable JavaScript'; $lang['NEW'] = 'New'; diff --git a/upload/library/language/en/translit_table.php b/upload/library/language/en/translit_table.php deleted file mode 100644 index 408a71e0b..000000000 --- a/upload/library/language/en/translit_table.php +++ /dev/null @@ -1,5 +0,0 @@ - 'to', -); \ No newline at end of file diff --git a/upload/library/language/ru/main.php b/upload/library/language/ru/main.php index c7aeda26a..e021e08a2 100644 --- a/upload/library/language/ru/main.php +++ b/upload/library/language/ru/main.php @@ -1325,7 +1325,6 @@ $lang['BOT_AFTER_SPLIT_TO_NEW'] = 'Добавить сообщение о раз $lang['QUICK_REPLY'] = 'Быстрый ответ'; $lang['INS_NAME_TIP'] = 'Вставить имя или выделенный кусок сообщения.'; $lang['QUOTE_SELECTED'] = 'Цитировать выделенный текст'; -$lang['TRANSLIT_RULES'] = 'Правила транслита'; $lang['QR_ATTACHSIG'] = 'Присоединить подпись'; $lang['QR_NOTIFY'] = 'Уведомлять об ответах'; $lang['QR_DISABLE'] = 'Отключить'; @@ -1517,8 +1516,6 @@ $lang['LIST'] = 'Список'; $lang['LIST_TITLE'] = 'Список: [list]текст[/list] (Ctrl+L)'; $lang['LIST_ITEM'] = 'Нумерованный список: [list=]текст[/list] (Ctrl+O)'; $lang['QUOTE_SEL'] = 'Цит.выдел'; -$lang['TRANSLIT'] = 'Транслит'; -$lang['TRANSLIT_TITLE'] = 'Перевести выделение из транслита на русский'; $lang['JAVASCRIPT_ON'] = 'Для отправки сообщений необходимо включить JavaScript'; $lang['NEW'] = 'Новое'; diff --git a/upload/library/language/ru/translit_table.php b/upload/library/language/ru/translit_table.php deleted file mode 100644 index 13273d5fa..000000000 --- a/upload/library/language/ru/translit_table.php +++ /dev/null @@ -1,37 +0,0 @@ - 'e', 'Ё' => 'E', - 'а' => 'a', 'А' => 'A', - 'б' => 'b', 'Б' => 'B', - 'в' => 'v', 'В' => 'V', - 'г' => 'g', 'Г' => 'G', - 'д' => 'd', 'Д' => 'D', - 'е' => 'e', 'Е' => 'E', - 'ж' => 'zh', 'Ж' => 'ZH', - 'з' => 'z', 'З' => 'Z', - 'и' => 'i', 'И' => 'I', - 'й' => 'y', 'Й' => 'Y', - 'к' => 'k', 'К' => 'K', - 'л' => 'l', 'Л' => 'L', - 'м' => 'm', 'М' => 'M', - 'н' => 'n', 'Н' => 'N', - 'о' => 'o', 'О' => 'O', - 'п' => 'p', 'П' => 'P', - 'р' => 'r', 'Р' => 'R', - 'с' => 's', 'С' => 'S', - 'т' => 't', 'Т' => 'T', - 'у' => 'u', 'У' => 'U', - 'ф' => 'f', 'Ф' => 'F', - 'х' => 'h', 'Х' => 'H', - 'ц' => 'c', 'Ц' => 'C', - 'ч' => 'ch', 'Ч' => 'CH', - 'ш' => 'sh', 'Ш' => 'SH', - 'щ' => 'sh', 'Щ' => 'SH', - 'ъ' => "'", 'Ъ' => "'", - 'ы' => 'y', 'Ы' => 'Y', - 'ь' => "'", 'Ь' => "'", - 'э' => 'e', 'Э' => 'E', - 'ю' => 'yu', 'Ю' => 'YU', - 'я' => 'ya', 'Я' => 'YA', -); \ No newline at end of file diff --git a/upload/library/language/uk/main.php b/upload/library/language/uk/main.php index 6ab1a2551..6abd28883 100644 --- a/upload/library/language/uk/main.php +++ b/upload/library/language/uk/main.php @@ -1325,7 +1325,6 @@ $lang['BOT_AFTER_SPLIT_TO_NEW'] = 'Додати повідомлення про $lang['QUICK_REPLY'] = 'Швидка відповідь'; $lang['INS_NAME_TIP'] = "Вставити ім'я або виділений шматок повідомлення."; $lang['QUOTE_SELECTED'] = 'Цитувати виділений текст'; -$lang['TRANSLIT_RULES'] = 'Правила трансліту'; $lang['QR_ATTACHSIG'] = 'Приєднати підпис'; $lang['QR_NOTIFY'] = 'Повідомляти про відповіді'; $lang['QR_DISABLE'] = 'Відключити'; @@ -1517,8 +1516,6 @@ $lang['LIST'] = 'Список'; $lang['LIST_TITLE'] = 'Список: [list]текст[/list] (Ctrl+L)'; $lang['LIST_ITEM'] = 'Нумерований список: [list=]текст[/list] (Ctrl+O)'; $lang['QUOTE_SEL'] = 'Цит.виділ'; -$lang['TRANSLIT'] = 'Трансліт'; -$lang['TRANSLIT_TITLE'] = 'Перевести виділення з трансліту на українську'; $lang['JAVASCRIPT_ON'] = 'Для надсилання повідомлень необхідно включити JavaScript'; $lang['NEW'] = 'Нове'; diff --git a/upload/library/language/uk/translit_table.php b/upload/library/language/uk/translit_table.php deleted file mode 100644 index f787ad5a7..000000000 --- a/upload/library/language/uk/translit_table.php +++ /dev/null @@ -1,37 +0,0 @@ - 'ye', 'Є' => 'YE', - 'а' => 'a', 'А' => 'A', - 'б' => 'b', 'Б' => 'B', - 'в' => 'v', 'В' => 'V', - 'г' => 'g', 'Г' => 'G', - 'д' => 'd', 'Д' => 'D', - 'е' => 'e', 'Е' => 'E', - 'ж' => 'zh', 'Ж' => 'ZH', - 'з' => 'z', 'З' => 'Z', - 'и' => 'y', 'И' => 'Y', - 'i' => 'i', 'I' => 'I', - 'ї' => 'yi', 'Ї' => 'YI', - 'й' => 'y', 'Й' => 'Y', - 'к' => 'k', 'К' => 'K', - 'л' => 'l', 'Л' => 'L', - 'м' => 'm', 'М' => 'M', - 'н' => 'n', 'Н' => 'N', - 'о' => 'o', 'О' => 'O', - 'п' => 'p', 'П' => 'P', - 'р' => 'r', 'Р' => 'R', - 'с' => 's', 'С' => 'S', - 'т' => 't', 'Т' => 'T', - 'у' => 'u', 'У' => 'U', - 'ф' => 'f', 'Ф' => 'F', - 'х' => 'h', 'Х' => 'H', - 'ц' => 'c', 'Ц' => 'C', - 'ч' => 'ch', 'Ч' => 'CH', - 'ш' => 'sh', 'Ш' => 'SH', - 'щ' => 'sh', 'Щ' => 'SH', - 'ь' => "'", 'Ь' => "'", - 'ю' => 'yu', 'Ю' => 'YU', - 'я' => 'ya', 'Я' => 'YA', - "'" => "'", -); \ No newline at end of file diff --git a/upload/styles/js/bbcode.js b/upload/styles/js/bbcode.js index 4ade8fcb6..9b8ddcb4c 100644 --- a/upload/styles/js/bbcode.js +++ b/upload/styles/js/bbcode.js @@ -453,119 +453,4 @@ function initMedia(context) $(document).ready(function(){ $('div.post_wrap, div.signature').each(function(){ initPostBBCode( $(this) ) }); -}); - -// One character letters -var t_table1 = "ABVGDEZIJKLMNOPRSTUFXHCYWabvgdezijklmnoprstufxhcyw'#"; -var w_table1 = "АБВГДЕЗИЙКЛМНОПРСТУФХХЦЫЩабвгдезийклмнопрстуфххцыщьъ"; - -// Two character letters -var t_table2 = "EHSZYOJOZHCHSHYUJUYAJAehszyojozhchshyujuyajaEhSzYoJoZhChShYuJuYaJa"; -var w_table2 = "ЭЩЁЁЖЧШЮЮЯЯэщёёжчшююяяЭЩЁЁЖЧШЮЮЯЯ"; - -var tagArray = [ - 'code', '', - 'img', '', - 'quote', "(=[\"']?[^"+String.fromCharCode(92,93)+"]+)?", - 'email', "(=[\"']?[a-zA-Z0-9_.-]+@?[a-zA-Z0-9_.-]+[\"']?)?", - 'url', "(=[\"']?[^ \"'"+String.fromCharCode(92,93)+"]*[\"']?)?" -]; - -function translit2win (str) -{ - var len = str.length; - var new_str = ""; - - for (i = 0; i < len; i++) - { - /* non-translatable text must be in ^ */ - if(str.substr(i).indexOf("^")==0){ - end_len=str.substr(i+1).indexOf("^")+2; - if (end_len>1){ - new_str+=str.substr(i,end_len); - i += end_len - 1; - continue; - } - } - - /* Skipping emoticons */ - if(str.substr(i).indexOf(":")==0){ - iEnd = str.substr(i+1).indexOf(":")+2; - if (iEnd > 1 && str.substr(i,iEnd).match("^:[a-zA-Z0-9]+:$")){ - new_str += str.substr(i,iEnd); - i += iEnd - 1; - continue; - } - } - - /* Skipping http|news|ftp:/.../ links */ - rExp = new RegExp("^((http|https|news|ftp|ed2k):\\/\\/[\\/a-zA-Z0-9%_?.:;|\(\)+=@-]+)","i"); - if (newArr = str.substr(i).match(rExp)){ - new_str += newArr[1]; - i += newArr[1].length - 1; - continue; - } - - /* Skipping FONT, COLOR, SIZE tags */ - rExp = new RegExp("^(\\[\\/?(b|i|u|s|font(=[a-z0-9]+)?|size(=[0-9]+)?|color(=#?[a-z0-9]+)?)\\])","i"); - if (newArr = str.substr(i).match(rExp)){ - new_str += newArr[1]; - i += newArr[1].length - 1; - continue; - } - - /* Skipping [QUOTE]..[/QUOTE], [IMG]..[/IMG], [CODE]..[/CODE], [SQL]..[/SQL], [EMAIL]..[/EMAIL] tags */ - bSkip = false; - for(j = 0; j < tagArray.length; j += 2){ - rExp = new RegExp("^(\\["+tagArray[j]+tagArray[j+1]+"\\])","i"); - if (newArr = str.substr(i).match(rExp)){ - rExp = new RegExp("\\[\\/" + tagArray[j] + "\\]", "i"); - if (iEnd = str.substr(i + newArr[1].length + 2).search(rExp)){ - end_len = iEnd + newArr[1].length + tagArray[j].length + 4; - new_str += str.substr(i,end_len); - i += end_len - 1; - bSkip = true; - } - } - if(bSkip)break; - } - if(bSkip)continue; - - // Check for 2-character letters - is2char=false; - if (i < len-1) { - for(j = 0; j < w_table2.length; j++) - { - if(str.substr(i, 2) == t_table2.substr(j*2,2)) { - new_str+= w_table2.substr(j, 1); - i++; - is2char=true; - break; - } - } - } - - if(!is2char) { - // Convert one-character letter - var c = str.substr(i, 1); - var pos = t_table1.indexOf(c); - if (pos < 0) - new_str+= c; - else - new_str+= w_table1.substr(pos, 1); - } - } - - return new_str; -} - -function transliterate (msg, e) -{ - if (e) e.disabled = true; - setTimeout(function() { - if (!bbcode.surround('', '', translit2win)) { - msg.value = translit2win(msg.value); - } - if (e) e.disabled = false; - }, 1); -} \ No newline at end of file +}); \ No newline at end of file diff --git a/upload/styles/templates/default/css/main.css b/upload/styles/templates/default/css/main.css index 5ca5875eb..81dc725e4 100644 --- a/upload/styles/templates/default/css/main.css +++ b/upload/styles/templates/default/css/main.css @@ -465,16 +465,11 @@ table.pm_box_size { width: 175px; margin: 8px 2px; } .pm_box_size b { font-size: 10px; } .pm_nav td { padding: 4px; font-size: 14px; font-weight: bold; } -table.translit_expl th { - width: 30px; padding-right: 8px; font-weight: bold; text-align: right; -} -table.translit_expl td { width: 14px; } - table.user_contacts th { text-align: right; white-space: nowrap; } - .user_contacts td { text-align: left; padding: 2px 6px; white-space: nowrap; } + .user_contacts td { text-align: left; padding: 2px 6px; white-space: nowrap; } table.user_details th { padding: 2px 6px; text-align: right; vertical-align: top; } - .user_details td { width: 70%; } + .user_details td { width: 70%; } table.usercp_register h6 { margin: 0.3em 0.4em; color: #444444; line-height: 100%; diff --git a/upload/styles/templates/default/posting.tpl b/upload/styles/templates/default/posting.tpl index 2ab4fd600..6711d588b 100644 --- a/upload/styles/templates/default/posting.tpl +++ b/upload/styles/templates/default/posting.tpl @@ -136,7 +136,8 @@ - + + {L_POST_RELEASE_FROM_GROUP} @@ -147,7 +148,8 @@ checked/> {L_ATTACH_RG_SIG} - + + diff --git a/upload/styles/templates/default/posting_editor.tpl b/upload/styles/templates/default/posting_editor.tpl index 7d5d8838b..78a88d1f3 100644 --- a/upload/styles/templates/default/posting_editor.tpl +++ b/upload/styles/templates/default/posting_editor.tpl @@ -85,63 +85,16 @@ ajax.callback.posts = function(data) { - - - ? - + - {MESSAGE} - - - - - - А-a - Д-d - И-i - М-m - Р-r - Ф-f - Ш-sh - Ы-y - - Б-b - Е-e - Й-j - Н-n - С-s - Х-h,x - Щ-sz,w - Э-eh - - В-v - Ж-zh - К-k - О-o - Т-t - Ц-c - Ь-' - Ю-ju - - Г-g - З-z - Л-l - П-p - У-u - Ч-ch - Ъ-# - Я-ja - - - - +{MESSAGE} @@ -157,7 +110,6 @@ ajax.callback.posts = function(data) { function dis_submit_btn () { $('#post-submit-btn').attr('disabled', 1); - //debounce('post-submit-btn', 3000); } function debounce (el_id, time_ms)