mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-14 18:48:21 -07:00
Реформат в PSR-2 + добавление заголовков лицензии MIT в файлы
This commit is contained in:
parent
a04df19607
commit
3730bed000
207 changed files with 44327 additions and 43119 deletions
|
@ -1,38 +1,58 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
bb_log(date('H:i:s - ') . getmypid() .' --x- SELECT jobs'. LOG_LF, CRON_LOG_DIR .'cron_check');
|
||||
bb_log(date('H:i:s - ') . getmypid() . ' --x- SELECT jobs' . LOG_LF, CRON_LOG_DIR . 'cron_check');
|
||||
|
||||
// Get cron jobs
|
||||
$cron_jobs = DB()->fetch_rowset("
|
||||
SELECT * FROM ". BB_CRON ."
|
||||
SELECT * FROM " . BB_CRON . "
|
||||
WHERE cron_active = 1
|
||||
AND next_run <= NOW()
|
||||
ORDER BY run_order
|
||||
");
|
||||
|
||||
// Run cron jobs
|
||||
if ($cron_jobs)
|
||||
{
|
||||
bb_log(date('H:i:s - ') . getmypid() .' --x- RUN jobs'. LOG_LF, CRON_LOG_DIR .'cron_check');
|
||||
if ($cron_jobs) {
|
||||
bb_log(date('H:i:s - ') . getmypid() . ' --x- RUN jobs' . LOG_LF, CRON_LOG_DIR . 'cron_check');
|
||||
|
||||
foreach ($cron_jobs as $job)
|
||||
{
|
||||
if ($job['disable_board'])
|
||||
{
|
||||
cron_disable_board();
|
||||
sleep(10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
foreach ($cron_jobs as $job) {
|
||||
if ($job['disable_board']) {
|
||||
cron_disable_board();
|
||||
sleep(10);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
require(CRON_DIR .'cron_run.php');
|
||||
require(CRON_DIR . 'cron_run.php');
|
||||
|
||||
// Update cron_last_check
|
||||
bb_update_config(array('cron_last_check' => (TIMENOW + 10)));
|
||||
// Update cron_last_check
|
||||
bb_update_config(array('cron_last_check' => (TIMENOW + 10)));
|
||||
} else {
|
||||
bb_log(date('H:i:s - ') . getmypid() . ' --x- no active jobs found ----------------------------------------------' . LOG_LF, CRON_LOG_DIR . 'cron_check');
|
||||
}
|
||||
else
|
||||
{
|
||||
bb_log(date('H:i:s - ') . getmypid() .' --x- no active jobs found ----------------------------------------------'. LOG_LF, CRON_LOG_DIR .'cron_check');
|
||||
}
|
|
@ -1,67 +1,82 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
//
|
||||
// Functions
|
||||
//
|
||||
function cron_get_file_lock ()
|
||||
function cron_get_file_lock()
|
||||
{
|
||||
$lock_obtained = false;
|
||||
$lock_obtained = false;
|
||||
|
||||
if (file_exists(CRON_ALLOWED))
|
||||
{
|
||||
# bb_log(date('H:i:s - ') . getmypid() .' -x-- FILE-LOCK try'. LOG_LF, CRON_LOG_DIR .'cron_check');
|
||||
if (file_exists(CRON_ALLOWED)) {
|
||||
# bb_log(date('H:i:s - ') . getmypid() .' -x-- FILE-LOCK try'. LOG_LF, CRON_LOG_DIR .'cron_check');
|
||||
|
||||
$lock_obtained = @rename(CRON_ALLOWED, CRON_RUNNING);
|
||||
}
|
||||
elseif (file_exists(CRON_RUNNING))
|
||||
{
|
||||
cron_release_deadlock();
|
||||
}
|
||||
elseif (!file_exists(CRON_ALLOWED) && !file_exists(CRON_RUNNING))
|
||||
{
|
||||
file_write('', CRON_ALLOWED);
|
||||
$lock_obtained = @rename(CRON_ALLOWED, CRON_RUNNING);
|
||||
}
|
||||
$lock_obtained = @rename(CRON_ALLOWED, CRON_RUNNING);
|
||||
} elseif (file_exists(CRON_RUNNING)) {
|
||||
cron_release_deadlock();
|
||||
} elseif (!file_exists(CRON_ALLOWED) && !file_exists(CRON_RUNNING)) {
|
||||
file_write('', CRON_ALLOWED);
|
||||
$lock_obtained = @rename(CRON_ALLOWED, CRON_RUNNING);
|
||||
}
|
||||
|
||||
return $lock_obtained;
|
||||
return $lock_obtained;
|
||||
}
|
||||
|
||||
function cron_track_running ($mode)
|
||||
function cron_track_running($mode)
|
||||
{
|
||||
@define('CRON_STARTMARK', TRIGGERS_DIR .'cron_started_at_'. date('Y-m-d_H-i-s') .'_by_pid_'. getmypid());
|
||||
@define('CRON_STARTMARK', TRIGGERS_DIR . 'cron_started_at_' . date('Y-m-d_H-i-s') . '_by_pid_' . getmypid());
|
||||
|
||||
if ($mode == 'start')
|
||||
{
|
||||
cron_touch_lock_file(CRON_RUNNING);
|
||||
file_write('', CRON_STARTMARK);
|
||||
}
|
||||
elseif ($mode == 'end')
|
||||
{
|
||||
@unlink(CRON_STARTMARK);
|
||||
}
|
||||
if ($mode == 'start') {
|
||||
cron_touch_lock_file(CRON_RUNNING);
|
||||
file_write('', CRON_STARTMARK);
|
||||
} elseif ($mode == 'end') {
|
||||
@unlink(CRON_STARTMARK);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// Run cron
|
||||
//
|
||||
if (cron_get_file_lock())
|
||||
{
|
||||
ignore_user_abort(true);
|
||||
register_shutdown_function('cron_release_file_lock');
|
||||
register_shutdown_function('cron_enable_board');
|
||||
if (cron_get_file_lock()) {
|
||||
ignore_user_abort(true);
|
||||
register_shutdown_function('cron_release_file_lock');
|
||||
register_shutdown_function('cron_enable_board');
|
||||
|
||||
# bb_log(date('H:i:s - ') . getmypid() .' --x- FILE-LOCK OBTAINED ###############'. LOG_LF, CRON_LOG_DIR .'cron_check');
|
||||
|
||||
cron_track_running('start');
|
||||
cron_track_running('start');
|
||||
|
||||
require(CRON_DIR .'cron_check.php');
|
||||
require(CRON_DIR . 'cron_check.php');
|
||||
|
||||
cron_track_running('end');
|
||||
cron_track_running('end');
|
||||
}
|
||||
|
||||
if (defined('IN_CRON'))
|
||||
{
|
||||
bb_log(date('H:i:s - ') . getmypid() .' --x- ALL jobs FINISHED *************************************************'. LOG_LF, CRON_LOG_DIR .'cron_check');
|
||||
}
|
||||
if (defined('IN_CRON')) {
|
||||
bb_log(date('H:i:s - ') . getmypid() . ' --x- ALL jobs FINISHED *************************************************' . LOG_LF, CRON_LOG_DIR . 'cron_check');
|
||||
}
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
define('IN_CRON', true);
|
||||
|
||||
|
@ -31,66 +56,59 @@ DB()->add_shutdown_query("
|
|||
");
|
||||
|
||||
// $cron_jobs obtained in cron_check.php
|
||||
foreach ($cron_jobs as $job)
|
||||
{
|
||||
$job_script = CRON_JOB_DIR . basename($job['cron_script']);
|
||||
foreach ($cron_jobs as $job) {
|
||||
$job_script = CRON_JOB_DIR . basename($job['cron_script']);
|
||||
|
||||
if (file_exists($job_script))
|
||||
{
|
||||
$cron_start_time = utime();
|
||||
$cron_runtime_log = '';
|
||||
$cron_write_log = (CRON_LOG_ENABLED && (CRON_FORCE_LOG || $job['log_enabled'] >= 1));
|
||||
$cron_sql_log_file = CRON_LOG_DIR .'SQL-'. basename($job['cron_script']);
|
||||
if (file_exists($job_script)) {
|
||||
$cron_start_time = utime();
|
||||
$cron_runtime_log = '';
|
||||
$cron_write_log = (CRON_LOG_ENABLED && (CRON_FORCE_LOG || $job['log_enabled'] >= 1));
|
||||
$cron_sql_log_file = CRON_LOG_DIR . 'SQL-' . basename($job['cron_script']);
|
||||
|
||||
if ($cron_write_log)
|
||||
{
|
||||
$msg = array();
|
||||
$msg[] = 'start';
|
||||
$msg[] = date('m-d');
|
||||
$msg[] = date('H:i:s');
|
||||
$msg[] = sprintf('%-4s', round(sys('la'), 1));
|
||||
$msg[] = sprintf('%05d', getmypid());
|
||||
$msg[] = $job['cron_title'];
|
||||
$msg = join(LOG_SEPR, $msg);
|
||||
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
|
||||
}
|
||||
if ($cron_write_log) {
|
||||
$msg = array();
|
||||
$msg[] = 'start';
|
||||
$msg[] = date('m-d');
|
||||
$msg[] = date('H:i:s');
|
||||
$msg[] = sprintf('%-4s', round(sys('la'), 1));
|
||||
$msg[] = sprintf('%05d', getmypid());
|
||||
$msg[] = $job['cron_title'];
|
||||
$msg = join(LOG_SEPR, $msg);
|
||||
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
|
||||
}
|
||||
|
||||
if ($job['log_sql_queries'])
|
||||
{
|
||||
DB()->log_next_query(100000, $cron_sql_log_file);
|
||||
}
|
||||
if ($job['log_sql_queries']) {
|
||||
DB()->log_next_query(100000, $cron_sql_log_file);
|
||||
}
|
||||
|
||||
set_time_limit(600);
|
||||
require($job_script);
|
||||
set_time_limit(600);
|
||||
require($job_script);
|
||||
|
||||
if ($job['log_sql_queries'])
|
||||
{
|
||||
DB()->log_next_query(0);
|
||||
bb_log(LOG_LF, $cron_sql_log_file);
|
||||
}
|
||||
if ($job['log_sql_queries']) {
|
||||
DB()->log_next_query(0);
|
||||
bb_log(LOG_LF, $cron_sql_log_file);
|
||||
}
|
||||
|
||||
if ($cron_write_log)
|
||||
{
|
||||
$msg = array();
|
||||
$msg[] = ' end';
|
||||
$msg[] = date('m-d');
|
||||
$msg[] = date('H:i:s');
|
||||
$msg[] = sprintf('%-4s', round(sys('la'), 1));
|
||||
$msg[] = sprintf('%05d', getmypid());
|
||||
$msg[] = round(utime() - $cron_start_time) .'/'. round(utime() - TIMESTART) . ' sec';
|
||||
$msg = join(LOG_SEPR, $msg);
|
||||
$msg .= LOG_LF .'------=-------=----------=------=-------=----------';
|
||||
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
|
||||
if ($cron_write_log) {
|
||||
$msg = array();
|
||||
$msg[] = ' end';
|
||||
$msg[] = date('m-d');
|
||||
$msg[] = date('H:i:s');
|
||||
$msg[] = sprintf('%-4s', round(sys('la'), 1));
|
||||
$msg[] = sprintf('%05d', getmypid());
|
||||
$msg[] = round(utime() - $cron_start_time) . '/' . round(utime() - TIMESTART) . ' sec';
|
||||
$msg = join(LOG_SEPR, $msg);
|
||||
$msg .= LOG_LF . '------=-------=----------=------=-------=----------';
|
||||
bb_log($msg . LOG_LF, CRON_LOG_DIR . CRON_LOG_FILE);
|
||||
|
||||
if ($cron_runtime_log)
|
||||
{
|
||||
$runtime_log_file = ($job['log_file']) ? $job['log_file'] : $job['cron_script'];
|
||||
bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . basename($runtime_log_file));
|
||||
}
|
||||
}
|
||||
if ($cron_runtime_log) {
|
||||
$runtime_log_file = ($job['log_file']) ? $job['log_file'] : $job['cron_script'];
|
||||
bb_log($cron_runtime_log . LOG_LF, CRON_LOG_DIR . basename($runtime_log_file));
|
||||
}
|
||||
}
|
||||
|
||||
DB()->query("
|
||||
UPDATE ". BB_CRON ." SET
|
||||
DB()->query("
|
||||
UPDATE " . BB_CRON . " SET
|
||||
last_run = NOW(),
|
||||
run_counter = run_counter + 1,
|
||||
next_run =
|
||||
|
@ -114,16 +132,13 @@ foreach ($cron_jobs as $job)
|
|||
LIMIT 1
|
||||
");
|
||||
|
||||
sleep(1);
|
||||
sleep(1);
|
||||
|
||||
if (utime() - TIMESTART > 600)
|
||||
{
|
||||
return; // чтобы daily скрипты не блокировали надолго interval'ные
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$cron_err_msg = "Can not run \"{$job['cron_title']}\" : file \"$job_script\" not found". LOG_LF;
|
||||
bb_log($cron_err_msg, 'cron_error');
|
||||
}
|
||||
}
|
||||
if (utime() - TIMESTART > 600) {
|
||||
return; // чтобы daily скрипты не блокировали надолго interval'ные
|
||||
}
|
||||
} else {
|
||||
$cron_err_msg = "Can not run \"{$job['cron_title']}\" : file \"$job_script\" not found" . LOG_LF;
|
||||
bb_log($cron_err_msg, 'cron_error');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
DB()->expect_slow_query(600);
|
||||
|
||||
|
@ -8,8 +33,8 @@ $fix_errors = true;
|
|||
$debug_mode = false;
|
||||
|
||||
$tmp_attach_tbl = 'tmp_attachments';
|
||||
$db_max_packet = 800000;
|
||||
$sql_limit = 3000;
|
||||
$db_max_packet = 800000;
|
||||
$sql_limit = 3000;
|
||||
|
||||
$check_attachments = false;
|
||||
$orphan_files = $orphan_db_attach = $orphan_tor = array();
|
||||
|
@ -27,44 +52,38 @@ DB()->add_shutdown_query("DROP TEMPORARY TABLE IF EXISTS $tmp_attach_tbl");
|
|||
$attach_dir = get_attachments_dir();
|
||||
|
||||
// Get all names of existed attachments and insert them into $tmp_attach_tbl
|
||||
if ($dir = @opendir($attach_dir))
|
||||
{
|
||||
$check_attachments = true;
|
||||
$files = array();
|
||||
$f_len = 0;
|
||||
if ($dir = @opendir($attach_dir)) {
|
||||
$check_attachments = true;
|
||||
$files = array();
|
||||
$f_len = 0;
|
||||
|
||||
while (false !== ($f = readdir($dir)))
|
||||
{
|
||||
if ($f == 'index.php' || $f == '.htaccess' || is_dir("$attach_dir/$f") || is_link("$attach_dir/$f"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$f = DB()->escape($f);
|
||||
$files[] = "('$f')";
|
||||
$f_len += strlen($f) + 5;
|
||||
while (false !== ($f = readdir($dir))) {
|
||||
if ($f == 'index.php' || $f == '.htaccess' || is_dir("$attach_dir/$f") || is_link("$attach_dir/$f")) {
|
||||
continue;
|
||||
}
|
||||
$f = DB()->escape($f);
|
||||
$files[] = "('$f')";
|
||||
$f_len += strlen($f) + 5;
|
||||
|
||||
if ($f_len > $db_max_packet)
|
||||
{
|
||||
$files = join(',', $files);
|
||||
DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
|
||||
$files = array();
|
||||
$f_len = 0;
|
||||
}
|
||||
}
|
||||
if ($files = join(',', $files))
|
||||
{
|
||||
DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
|
||||
}
|
||||
closedir($dir);
|
||||
if ($f_len > $db_max_packet) {
|
||||
$files = join(',', $files);
|
||||
DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
|
||||
$files = array();
|
||||
$f_len = 0;
|
||||
}
|
||||
}
|
||||
if ($files = join(',', $files)) {
|
||||
DB()->query("INSERT INTO $tmp_attach_tbl VALUES $files");
|
||||
}
|
||||
closedir($dir);
|
||||
}
|
||||
|
||||
if ($check_attachments)
|
||||
{
|
||||
// Delete bad records
|
||||
DB()->query("
|
||||
if ($check_attachments) {
|
||||
// Delete bad records
|
||||
DB()->query("
|
||||
DELETE a, d
|
||||
FROM ". BB_ATTACHMENTS_DESC ." d
|
||||
LEFT JOIN ". BB_ATTACHMENTS ." a USING(attach_id)
|
||||
FROM " . BB_ATTACHMENTS_DESC . " d
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a USING(attach_id)
|
||||
WHERE (
|
||||
d.physical_filename = ''
|
||||
OR d.real_filename = ''
|
||||
|
@ -76,149 +95,129 @@ if ($check_attachments)
|
|||
)
|
||||
");
|
||||
|
||||
// Delete attachments that exist in file system but not exist in DB
|
||||
$sql = "SELECT f.physical_filename
|
||||
// Delete attachments that exist in file system but not exist in DB
|
||||
$sql = "SELECT f.physical_filename
|
||||
FROM $tmp_attach_tbl f
|
||||
LEFT JOIN ". BB_ATTACHMENTS_DESC ." d USING(physical_filename)
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(physical_filename)
|
||||
WHERE d.physical_filename IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
if ($filename = basename($row['physical_filename']))
|
||||
{
|
||||
if ($fix_errors)
|
||||
{
|
||||
@unlink("$attach_dir/$filename");
|
||||
@unlink("$attach_dir/". THUMB_DIR .'/t_'. $filename);
|
||||
}
|
||||
if ($debug_mode)
|
||||
{
|
||||
$orphan_files[] = "$attach_dir/$filename";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Find DB records for attachments that exist in DB but not exist in file system
|
||||
$sql = "SELECT d.attach_id
|
||||
FROM ". BB_ATTACHMENTS_DESC ." d
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
if ($filename = basename($row['physical_filename'])) {
|
||||
if ($fix_errors) {
|
||||
@unlink("$attach_dir/$filename");
|
||||
@unlink("$attach_dir/" . THUMB_DIR . '/t_' . $filename);
|
||||
}
|
||||
if ($debug_mode) {
|
||||
$orphan_files[] = "$attach_dir/$filename";
|
||||
}
|
||||
}
|
||||
}
|
||||
// Find DB records for attachments that exist in DB but not exist in file system
|
||||
$sql = "SELECT d.attach_id
|
||||
FROM " . BB_ATTACHMENTS_DESC . " d
|
||||
LEFT JOIN $tmp_attach_tbl f USING(physical_filename)
|
||||
WHERE f.physical_filename IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachment exist in DESC_TABLE but not exist in ATTACH_TABLE
|
||||
$sql = "SELECT d.attach_id
|
||||
FROM ". BB_ATTACHMENTS_DESC ." d
|
||||
LEFT JOIN ". BB_ATTACHMENTS ." a USING(attach_id)
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachment exist in DESC_TABLE but not exist in ATTACH_TABLE
|
||||
$sql = "SELECT d.attach_id
|
||||
FROM " . BB_ATTACHMENTS_DESC . " d
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a USING(attach_id)
|
||||
WHERE a.attach_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachment exist in ATTACH_TABLE but not exist in DESC_TABLE
|
||||
$sql = "SELECT a.attach_id
|
||||
FROM ". BB_ATTACHMENTS ." a
|
||||
LEFT JOIN ". BB_ATTACHMENTS_DESC ." d USING(attach_id)
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachment exist in ATTACH_TABLE but not exist in DESC_TABLE
|
||||
$sql = "SELECT a.attach_id
|
||||
FROM " . BB_ATTACHMENTS . " a
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(attach_id)
|
||||
WHERE d.attach_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachments without post
|
||||
$sql = "SELECT a.attach_id
|
||||
FROM ". BB_ATTACHMENTS ." a
|
||||
LEFT JOIN ". BB_POSTS ." p USING(post_id)
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Attachments without post
|
||||
$sql = "SELECT a.attach_id
|
||||
FROM " . BB_ATTACHMENTS . " a
|
||||
LEFT JOIN " . BB_POSTS . " p USING(post_id)
|
||||
WHERE p.post_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Delete all orphan attachments
|
||||
if ($orphans_sql = join(',', $orphan_db_attach))
|
||||
{
|
||||
if ($fix_errors)
|
||||
{
|
||||
DB()->query("DELETE FROM ". BB_ATTACHMENTS_DESC ." WHERE attach_id IN($orphans_sql)");
|
||||
DB()->query("DELETE FROM ". BB_ATTACHMENTS ." WHERE attach_id IN($orphans_sql)");
|
||||
}
|
||||
}
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$orphan_db_attach[] = $row['attach_id'];
|
||||
}
|
||||
// Delete all orphan attachments
|
||||
if ($orphans_sql = join(',', $orphan_db_attach)) {
|
||||
if ($fix_errors) {
|
||||
DB()->query("DELETE FROM " . BB_ATTACHMENTS_DESC . " WHERE attach_id IN($orphans_sql)");
|
||||
DB()->query("DELETE FROM " . BB_ATTACHMENTS . " WHERE attach_id IN($orphans_sql)");
|
||||
}
|
||||
}
|
||||
|
||||
// Torrents without attachments
|
||||
$sql = "SELECT tor.topic_id
|
||||
FROM ". BB_BT_TORRENTS ." tor
|
||||
LEFT JOIN ". BB_ATTACHMENTS_DESC ." d USING(attach_id)
|
||||
// Torrents without attachments
|
||||
$sql = "SELECT tor.topic_id
|
||||
FROM " . BB_BT_TORRENTS . " tor
|
||||
LEFT JOIN " . BB_ATTACHMENTS_DESC . " d USING(attach_id)
|
||||
WHERE d.attach_id IS NULL
|
||||
LIMIT $sql_limit";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$orphan_tor[] = $row['topic_id'];
|
||||
}
|
||||
// Delete all orphan torrents
|
||||
if ($orphans_sql = join(',', $orphan_tor))
|
||||
{
|
||||
if ($fix_errors)
|
||||
{
|
||||
DB()->query("DELETE FROM ". BB_BT_TORRENTS ." WHERE topic_id IN($orphans_sql)");
|
||||
}
|
||||
}
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$orphan_tor[] = $row['topic_id'];
|
||||
}
|
||||
// Delete all orphan torrents
|
||||
if ($orphans_sql = join(',', $orphan_tor)) {
|
||||
if ($fix_errors) {
|
||||
DB()->query("DELETE FROM " . BB_BT_TORRENTS . " WHERE topic_id IN($orphans_sql)");
|
||||
}
|
||||
}
|
||||
|
||||
// Check post_attachment markers
|
||||
$sql = "SELECT p.post_id
|
||||
FROM ". BB_POSTS ." p
|
||||
LEFT JOIN ". BB_ATTACHMENTS ." a USING(post_id)
|
||||
// Check post_attachment markers
|
||||
$sql = "SELECT p.post_id
|
||||
FROM " . BB_POSTS . " p
|
||||
LEFT JOIN " . BB_ATTACHMENTS . " a USING(post_id)
|
||||
WHERE p.post_attachment = 1
|
||||
AND a.post_id IS NULL";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$posts_without_attach[] = $row['post_id'];
|
||||
}
|
||||
if ($posts_sql = join(',', $posts_without_attach))
|
||||
{
|
||||
if ($fix_errors)
|
||||
{
|
||||
DB()->query("UPDATE ". BB_POSTS ." SET post_attachment = 0 WHERE post_id IN($posts_sql)");
|
||||
}
|
||||
}
|
||||
// Check topic_attachment markers
|
||||
$sql = "SELECT t.topic_id
|
||||
FROM ". BB_POSTS ." p, ". BB_TOPICS ." t
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$posts_without_attach[] = $row['post_id'];
|
||||
}
|
||||
if ($posts_sql = join(',', $posts_without_attach)) {
|
||||
if ($fix_errors) {
|
||||
DB()->query("UPDATE " . BB_POSTS . " SET post_attachment = 0 WHERE post_id IN($posts_sql)");
|
||||
}
|
||||
}
|
||||
// Check topic_attachment markers
|
||||
$sql = "SELECT t.topic_id
|
||||
FROM " . BB_POSTS . " p, " . BB_TOPICS . " t
|
||||
WHERE t.topic_id = p.topic_id
|
||||
AND t.topic_attachment = 1
|
||||
GROUP BY p.topic_id
|
||||
HAVING SUM(p.post_attachment) = 0";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$topics_without_attach[] = $row['topic_id'];
|
||||
}
|
||||
if ($topics_sql = join(',', $topics_without_attach))
|
||||
{
|
||||
if ($fix_errors)
|
||||
{
|
||||
DB()->query("UPDATE ". BB_TOPICS ." SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
|
||||
}
|
||||
}
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$topics_without_attach[] = $row['topic_id'];
|
||||
}
|
||||
if ($topics_sql = join(',', $topics_without_attach)) {
|
||||
if ($fix_errors) {
|
||||
DB()->query("UPDATE " . BB_TOPICS . " SET topic_attachment = 0 WHERE topic_id IN($topics_sql)");
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($debug_mode)
|
||||
{
|
||||
prn_r($orphan_files, '$orphan_files');
|
||||
prn_r($orphan_db_attach, '$orphan_db_attach');
|
||||
prn_r($orphan_tor, '$orphan_tor');
|
||||
prn_r($posts_without_attach, '$posts_without_attach');
|
||||
prn_r($topics_without_attach, '$topics_without_attach');
|
||||
if ($debug_mode) {
|
||||
prn_r($orphan_files, '$orphan_files');
|
||||
prn_r($orphan_db_attach, '$orphan_db_attach');
|
||||
prn_r($orphan_tor, '$orphan_tor');
|
||||
prn_r($posts_without_attach, '$posts_without_attach');
|
||||
prn_r($topics_without_attach, '$topics_without_attach');
|
||||
}
|
||||
|
||||
DB()->query("DROP TEMPORARY TABLE $tmp_attach_tbl");
|
||||
|
||||
unset($fix_errors, $debug_mode);
|
||||
unset($fix_errors, $debug_mode);
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
require_once(INC_DIR .'functions_admin.php');
|
||||
require_once(INC_DIR . 'functions_admin.php');
|
||||
|
||||
// Синхронизация
|
||||
sync('topic', 'all');
|
||||
|
@ -10,40 +35,35 @@ sync('user_posts', 'all');
|
|||
sync_all_forums();
|
||||
|
||||
// Чистка bb_poll_users
|
||||
if ($poll_max_days = (int) $bb_cfg['poll_max_days'])
|
||||
{
|
||||
$per_cycle = 20000;
|
||||
$row = DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM ". BB_POLL_USERS);
|
||||
$start_id = (int) $row['start_id'];
|
||||
$finish_id = (int) $row['finish_id'];
|
||||
if ($poll_max_days = (int)$bb_cfg['poll_max_days']) {
|
||||
$per_cycle = 20000;
|
||||
$row = DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM " . BB_POLL_USERS);
|
||||
$start_id = (int)$row['start_id'];
|
||||
$finish_id = (int)$row['finish_id'];
|
||||
|
||||
while (true)
|
||||
{
|
||||
set_time_limit(600);
|
||||
$end_id = $start_id + $per_cycle - 1;
|
||||
while (true) {
|
||||
set_time_limit(600);
|
||||
$end_id = $start_id + $per_cycle - 1;
|
||||
|
||||
DB()->query("
|
||||
DELETE FROM ". BB_POLL_USERS ."
|
||||
DB()->query("
|
||||
DELETE FROM " . BB_POLL_USERS . "
|
||||
WHERE topic_id BETWEEN $start_id AND $end_id
|
||||
AND vote_dt < DATE_SUB(NOW(), INTERVAL $poll_max_days DAY)
|
||||
");
|
||||
if ($end_id > $finish_id)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (!($start_id % ($per_cycle*10)))
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
$start_id += $per_cycle;
|
||||
}
|
||||
if ($end_id > $finish_id) {
|
||||
break;
|
||||
}
|
||||
if (!($start_id % ($per_cycle * 10))) {
|
||||
sleep(1);
|
||||
}
|
||||
$start_id += $per_cycle;
|
||||
}
|
||||
}
|
||||
|
||||
// Чистка user_newpasswd
|
||||
DB()->query("UPDATE ". BB_USERS ." SET user_newpasswd = '' WHERE user_lastvisit < ". (TIMENOW - 7*86400));
|
||||
DB()->query("UPDATE " . BB_USERS . " SET user_newpasswd = '' WHERE user_lastvisit < " . (TIMENOW - 7 * 86400));
|
||||
|
||||
// Чистка кеша постов
|
||||
if ($posts_days = intval($bb_cfg['posts_cache_days_keep']))
|
||||
{
|
||||
DB()->query("DELETE FROM ". BB_POSTS_HTML ." WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)");
|
||||
}
|
||||
if ($posts_days = intval($bb_cfg['posts_cache_days_keep'])) {
|
||||
DB()->query("DELETE FROM " . BB_POSTS_HTML . " WHERE post_html_time < DATE_SUB(NOW(), INTERVAL $posts_days DAY)");
|
||||
}
|
||||
|
|
|
@ -1,14 +1,37 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $cron_runtime_log;
|
||||
|
||||
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val)
|
||||
{
|
||||
if (method_exists(CACHE($cache_name), 'gc'))
|
||||
{
|
||||
$changes = CACHE($cache_name)->gc();
|
||||
$cron_runtime_log = date('Y-m-d H:i:s') ." -- ". str_pad("$cache_name ", 25, '-', STR_PAD_RIGHT) ." del: $changes\n";
|
||||
}
|
||||
}
|
||||
foreach ($bb_cfg['cache']['engines'] as $cache_name => $cache_val) {
|
||||
if (method_exists(CACHE($cache_name), 'gc')) {
|
||||
$changes = CACHE($cache_name)->gc();
|
||||
$cron_runtime_log = date('Y-m-d H:i:s') . " -- " . str_pad("$cache_name ", 25, '-', STR_PAD_RIGHT) . " del: $changes\n";
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,65 +1,86 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// Delete staled dl-status records
|
||||
$keeping_dlstat = array(
|
||||
DL_STATUS_WILL => (int) $bb_cfg['dl_will_days_keep'],
|
||||
DL_STATUS_DOWN => (int) $bb_cfg['dl_down_days_keep'],
|
||||
DL_STATUS_COMPLETE => (int) $bb_cfg['dl_complete_days_keep'],
|
||||
DL_STATUS_CANCEL => (int) $bb_cfg['dl_cancel_days_keep'],
|
||||
DL_STATUS_WILL => (int)$bb_cfg['dl_will_days_keep'],
|
||||
DL_STATUS_DOWN => (int)$bb_cfg['dl_down_days_keep'],
|
||||
DL_STATUS_COMPLETE => (int)$bb_cfg['dl_complete_days_keep'],
|
||||
DL_STATUS_CANCEL => (int)$bb_cfg['dl_cancel_days_keep'],
|
||||
);
|
||||
|
||||
$delete_dlstat_sql = array();
|
||||
|
||||
foreach ($keeping_dlstat as $dl_status => $days_to_keep)
|
||||
{
|
||||
if ($days_to_keep)
|
||||
{
|
||||
$delete_dlstat_sql[] = "
|
||||
foreach ($keeping_dlstat as $dl_status => $days_to_keep) {
|
||||
if ($days_to_keep) {
|
||||
$delete_dlstat_sql[] = "
|
||||
user_status = $dl_status
|
||||
AND
|
||||
last_modified_dlstatus < DATE_SUB(NOW(), INTERVAL $days_to_keep DAY)
|
||||
";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($delete_dlstat_sql = join(') OR (', $delete_dlstat_sql))
|
||||
{
|
||||
DB()->query("DELETE QUICK FROM ". BB_BT_DLSTATUS ." WHERE ($delete_dlstat_sql)");
|
||||
if ($delete_dlstat_sql = join(') OR (', $delete_dlstat_sql)) {
|
||||
DB()->query("DELETE QUICK FROM " . BB_BT_DLSTATUS . " WHERE ($delete_dlstat_sql)");
|
||||
}
|
||||
|
||||
// Delete orphans
|
||||
DB()->query("
|
||||
DELETE QUICK dl
|
||||
FROM ". BB_BT_DLSTATUS ." dl
|
||||
LEFT JOIN ". BB_USERS ." u USING(user_id)
|
||||
FROM " . BB_BT_DLSTATUS . " dl
|
||||
LEFT JOIN " . BB_USERS . " u USING(user_id)
|
||||
WHERE u.user_id IS NULL
|
||||
");
|
||||
|
||||
DB()->query("
|
||||
DELETE QUICK dl
|
||||
FROM ". BB_BT_DLSTATUS ." dl
|
||||
LEFT JOIN ". BB_TOPICS ." t USING(topic_id)
|
||||
FROM " . BB_BT_DLSTATUS . " dl
|
||||
LEFT JOIN " . BB_TOPICS . " t USING(topic_id)
|
||||
WHERE t.topic_id IS NULL
|
||||
");
|
||||
|
||||
// Tor-Stats cleanup
|
||||
if ($torstat_days_keep = intval($bb_cfg['torstat_days_keep']))
|
||||
{
|
||||
DB()->query("DELETE QUICK FROM ". BB_BT_TORSTAT ." WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)");
|
||||
if ($torstat_days_keep = intval($bb_cfg['torstat_days_keep'])) {
|
||||
DB()->query("DELETE QUICK FROM " . BB_BT_TORSTAT . " WHERE last_modified_torstat < DATE_SUB(NOW(), INTERVAL $torstat_days_keep DAY)");
|
||||
}
|
||||
|
||||
DB()->query("
|
||||
DELETE QUICK tst
|
||||
FROM ". BB_BT_TORSTAT ." tst
|
||||
LEFT JOIN ". BB_BT_TORRENTS ." tor USING(topic_id)
|
||||
FROM " . BB_BT_TORSTAT . " tst
|
||||
LEFT JOIN " . BB_BT_TORRENTS . " tor USING(topic_id)
|
||||
WHERE tor.topic_id IS NULL
|
||||
");
|
||||
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_BT_USERS ."
|
||||
" . BB_BT_USERS . "
|
||||
SET
|
||||
up_yesterday = up_today,
|
||||
down_yesterday = down_today,
|
||||
|
@ -70,11 +91,11 @@ DB()->query("
|
|||
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_BT_USERS ."
|
||||
" . BB_BT_USERS . "
|
||||
SET
|
||||
up_today = 0,
|
||||
down_today = 0,
|
||||
up_release_today = 0,
|
||||
up_bonus_today = 0,
|
||||
points_today = 0
|
||||
");
|
||||
");
|
||||
|
|
|
@ -1,10 +1,35 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$log_days_keep = (int) $bb_cfg['log_days_keep'];
|
||||
$log_days_keep = (int)$bb_cfg['log_days_keep'];
|
||||
|
||||
DB()->query("
|
||||
DELETE FROM ". BB_LOG ."
|
||||
WHERE log_time < ". (TIMENOW - 86400*$log_days_keep) ."
|
||||
");
|
||||
DELETE FROM " . BB_LOG . "
|
||||
WHERE log_time < " . (TIMENOW - 86400 * $log_days_keep) . "
|
||||
");
|
||||
|
|
|
@ -1,10 +1,35 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$search_results_expire = TIMENOW - 3*3600;
|
||||
$search_results_expire = TIMENOW - 3 * 3600;
|
||||
|
||||
DB()->query("
|
||||
DELETE FROM ". BB_SEARCH ."
|
||||
DELETE FROM " . BB_SEARCH . "
|
||||
WHERE search_time < $search_results_expire
|
||||
");
|
||||
");
|
||||
|
|
|
@ -1,5 +1,30 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$datastore->update('cat_forums');
|
||||
$datastore->update('cat_forums');
|
||||
|
|
|
@ -1,5 +1,30 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$datastore->update('stats');
|
||||
$datastore->update('stats');
|
||||
|
|
|
@ -1,18 +1,43 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
// Lock tables
|
||||
DB()->lock(array(
|
||||
BB_TOPICS .' t',
|
||||
BUF_TOPIC_VIEW .' buf',
|
||||
BB_TOPICS . ' t',
|
||||
BUF_TOPIC_VIEW . ' buf',
|
||||
));
|
||||
|
||||
// Flash buffered records
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_TOPICS ." t,
|
||||
". BUF_TOPIC_VIEW ." buf
|
||||
" . BB_TOPICS . " t,
|
||||
" . BUF_TOPIC_VIEW . " buf
|
||||
SET
|
||||
t.topic_views = t.topic_views + buf.topic_views
|
||||
WHERE
|
||||
|
@ -20,7 +45,7 @@ DB()->query("
|
|||
");
|
||||
|
||||
// Delete buffered records
|
||||
DB()->query("DELETE buf FROM ". BUF_TOPIC_VIEW ." buf");
|
||||
DB()->query("DELETE buf FROM " . BUF_TOPIC_VIEW . " buf");
|
||||
|
||||
// Unlock tables
|
||||
DB()->unlock();
|
||||
DB()->unlock();
|
||||
|
|
|
@ -1,15 +1,38 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
require_once(INC_DIR .'functions_admin.php');
|
||||
require_once(INC_DIR . 'functions_admin.php');
|
||||
|
||||
if ($bb_cfg['prune_enable'])
|
||||
{
|
||||
$sql = "SELECT forum_id, prune_days FROM ". BB_FORUMS ." WHERE prune_days != 0";
|
||||
if ($bb_cfg['prune_enable']) {
|
||||
$sql = "SELECT forum_id, prune_days FROM " . BB_FORUMS . " WHERE prune_days != 0";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
topic_delete('prune', $row['forum_id'], (TIMENOW - 86400*$row['prune_days']));
|
||||
}
|
||||
}
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
topic_delete('prune', $row['forum_id'], (TIMENOW - 86400 * $row['prune_days']));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,57 +1,75 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
require_once(INC_DIR .'functions_admin.php');
|
||||
require_once(INC_DIR . 'functions_admin.php');
|
||||
|
||||
$users_per_cycle = 1000;
|
||||
|
||||
while (true)
|
||||
{
|
||||
@set_time_limit(600);
|
||||
while (true) {
|
||||
@set_time_limit(600);
|
||||
|
||||
$prune_users = $not_activated_users = $not_active_users = array();
|
||||
$prune_users = $not_activated_users = $not_active_users = array();
|
||||
|
||||
if ($not_activated_days = intval($bb_cfg['user_not_activated_days_keep']))
|
||||
{
|
||||
$sql = DB()->fetch_rowset("SELECT user_id FROM ". BB_USERS ."
|
||||
if ($not_activated_days = intval($bb_cfg['user_not_activated_days_keep'])) {
|
||||
$sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
|
||||
WHERE user_level = 0
|
||||
AND user_lastvisit = 0
|
||||
AND user_session_time = 0
|
||||
AND user_regdate <= ". (TIMENOW - 86400 * $not_activated_days) ."
|
||||
AND user_id NOT IN(". EXCLUDED_USERS_CSV .")
|
||||
AND user_regdate <= " . (TIMENOW - 86400 * $not_activated_days) . "
|
||||
AND user_id NOT IN(" . EXCLUDED_USERS_CSV . ")
|
||||
LIMIT $users_per_cycle");
|
||||
|
||||
foreach ($sql as $row)
|
||||
{
|
||||
$not_activated_users[] = $row['user_id'];
|
||||
}
|
||||
}
|
||||
foreach ($sql as $row) {
|
||||
$not_activated_users[] = $row['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($not_active_days = intval($bb_cfg['user_not_active_days_keep']))
|
||||
{
|
||||
$sql = DB()->fetch_rowset("SELECT user_id FROM ". BB_USERS ."
|
||||
if ($not_active_days = intval($bb_cfg['user_not_active_days_keep'])) {
|
||||
$sql = DB()->fetch_rowset("SELECT user_id FROM " . BB_USERS . "
|
||||
WHERE user_level = 0
|
||||
AND user_posts = 0
|
||||
AND user_lastvisit <= ". (TIMENOW - 86400 * $not_active_days) ."
|
||||
AND user_id NOT IN(". EXCLUDED_USERS_CSV .")
|
||||
AND user_lastvisit <= " . (TIMENOW - 86400 * $not_active_days) . "
|
||||
AND user_id NOT IN(" . EXCLUDED_USERS_CSV . ")
|
||||
LIMIT $users_per_cycle");
|
||||
|
||||
foreach ($sql as $row)
|
||||
{
|
||||
$not_active_users[] = $row['user_id'];
|
||||
}
|
||||
}
|
||||
foreach ($sql as $row) {
|
||||
$not_active_users[] = $row['user_id'];
|
||||
}
|
||||
}
|
||||
|
||||
if ($prune_users = $not_activated_users + $not_active_users)
|
||||
{
|
||||
user_delete($prune_users);
|
||||
}
|
||||
if ($prune_users = $not_activated_users + $not_active_users) {
|
||||
user_delete($prune_users);
|
||||
}
|
||||
|
||||
if (count($prune_users) < $users_per_cycle)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (count($prune_users) < $users_per_cycle) {
|
||||
break;
|
||||
}
|
||||
|
||||
sleep(3);
|
||||
}
|
||||
sleep(3);
|
||||
}
|
||||
|
|
|
@ -1,14 +1,38 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
if ($bb_cfg['topic_moved_days_keep'])
|
||||
{
|
||||
$prune_time = TIMENOW - 86400*$bb_cfg['topic_moved_days_keep'];
|
||||
if ($bb_cfg['topic_moved_days_keep']) {
|
||||
$prune_time = TIMENOW - 86400 * $bb_cfg['topic_moved_days_keep'];
|
||||
|
||||
DB()->query("
|
||||
DELETE FROM ". BB_TOPICS ."
|
||||
WHERE topic_status = ". TOPIC_MOVED ."
|
||||
DB()->query("
|
||||
DELETE FROM " . BB_TOPICS . "
|
||||
WHERE topic_status = " . TOPIC_MOVED . "
|
||||
AND topic_time < $prune_time
|
||||
");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,29 +1,54 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$user_session_expire_time = TIMENOW - intval($bb_cfg['user_session_duration']);
|
||||
$user_session_expire_time = TIMENOW - intval($bb_cfg['user_session_duration']);
|
||||
$admin_session_expire_time = TIMENOW - intval($bb_cfg['admin_session_duration']);
|
||||
|
||||
$user_session_gc_time = $user_session_expire_time - intval($bb_cfg['user_session_gc_ttl']);
|
||||
$user_session_gc_time = $user_session_expire_time - intval($bb_cfg['user_session_gc_ttl']);
|
||||
$admin_session_gc_time = $admin_session_expire_time;
|
||||
|
||||
// ############################ Tables LOCKED ################################
|
||||
DB()->lock(array(
|
||||
BB_USERS .' u',
|
||||
BB_SESSIONS .' s',
|
||||
BB_USERS . ' u',
|
||||
BB_SESSIONS . ' s',
|
||||
));
|
||||
|
||||
// Update user's session time
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_USERS ." u,
|
||||
". BB_SESSIONS ." s
|
||||
" . BB_USERS . " u,
|
||||
" . BB_SESSIONS . " s
|
||||
SET
|
||||
u.user_session_time = IF(u.user_session_time < s.session_time, s.session_time, u.user_session_time)
|
||||
WHERE
|
||||
u.user_id = s.session_user_id
|
||||
AND s.session_user_id != ". GUEST_UID ."
|
||||
AND s.session_user_id != " . GUEST_UID . "
|
||||
AND (
|
||||
(s.session_time < $user_session_expire_time AND s.session_admin = 0)
|
||||
OR
|
||||
|
@ -39,9 +64,9 @@ sleep(5);
|
|||
// Delete staled sessions
|
||||
DB()->query("
|
||||
DELETE s
|
||||
FROM ". BB_SESSIONS ." s
|
||||
FROM " . BB_SESSIONS . " s
|
||||
WHERE
|
||||
(s.session_time < $user_session_gc_time AND s.session_admin = 0)
|
||||
OR
|
||||
(s.session_time < $admin_session_gc_time AND s.session_admin != 0)
|
||||
");
|
||||
");
|
||||
|
|
|
@ -1,18 +1,42 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
require(CLASS_DIR .'sitemap.php');
|
||||
require(CLASS_DIR . 'sitemap.php');
|
||||
|
||||
$map = new sitemap();
|
||||
$map->create();
|
||||
|
||||
if (@file_exists(BB_ROOT. "/sitemap/sitemap.xml"))
|
||||
{
|
||||
$map_link = make_url('/sitemap/sitemap.xml');
|
||||
if (@file_exists(BB_ROOT . "/sitemap/sitemap.xml")) {
|
||||
$map_link = make_url('/sitemap/sitemap.xml');
|
||||
|
||||
$map->send_url("http://google.com/webmasters/sitemaps/ping?sitemap=", $map_link);
|
||||
$map->send_url("http://ping.blogs.yandex.ru/ping?sitemap=", $map_link);
|
||||
$map->send_url("http://www.bing.com/ping?sitemap=", $map_link);
|
||||
$map->send_url("http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=", $map_link);
|
||||
}
|
||||
$map->send_url("http://google.com/webmasters/sitemaps/ping?sitemap=", $map_link);
|
||||
$map->send_url("http://ping.blogs.yandex.ru/ping?sitemap=", $map_link);
|
||||
$map->send_url("http://www.bing.com/ping?sitemap=", $map_link);
|
||||
$map->send_url("http://rpc.weblogs.com/pingSiteForm?name=InfraBlog&url=", $map_link);
|
||||
}
|
||||
|
|
|
@ -1,102 +1,124 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$releaser = DL_STATUS_RELEASER;
|
||||
|
||||
define('NEW_BB_BT_LAST_TORSTAT', 'new_bt_last_torstat');
|
||||
define('OLD_BB_BT_LAST_TORSTAT', 'old_bt_last_torstat');
|
||||
define('NEW_BB_BT_LAST_TORSTAT', 'new_bt_last_torstat');
|
||||
define('OLD_BB_BT_LAST_TORSTAT', 'old_bt_last_torstat');
|
||||
define('NEW_BB_BT_LAST_USERSTAT', 'new_bt_last_userstat');
|
||||
define('OLD_BB_BT_LAST_USERSTAT', 'old_bt_last_userstat');
|
||||
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_LAST_TORSTAT .", ". NEW_BB_BT_LAST_USERSTAT);
|
||||
DB()->query("DROP TABLE IF EXISTS ". OLD_BB_BT_LAST_TORSTAT .", ". OLD_BB_BT_LAST_USERSTAT);
|
||||
DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_LAST_TORSTAT . ", " . NEW_BB_BT_LAST_USERSTAT);
|
||||
DB()->query("DROP TABLE IF EXISTS " . OLD_BB_BT_LAST_TORSTAT . ", " . OLD_BB_BT_LAST_USERSTAT);
|
||||
|
||||
DB()->query("CREATE TABLE ". NEW_BB_BT_LAST_TORSTAT ." LIKE ". BB_BT_LAST_TORSTAT);
|
||||
DB()->query("CREATE TABLE ". NEW_BB_BT_LAST_USERSTAT ." LIKE ". BB_BT_LAST_USERSTAT);
|
||||
DB()->query("CREATE TABLE " . NEW_BB_BT_LAST_TORSTAT . " LIKE " . BB_BT_LAST_TORSTAT);
|
||||
DB()->query("CREATE TABLE " . NEW_BB_BT_LAST_USERSTAT . " LIKE " . BB_BT_LAST_USERSTAT);
|
||||
|
||||
DB()->expect_slow_query(600);
|
||||
|
||||
// Update dlstat (part 1)
|
||||
if ($tr_cfg['update_dlstat'])
|
||||
{
|
||||
// ############################ Tables LOCKED ################################
|
||||
DB()->lock(array(
|
||||
BB_BT_TRACKER,
|
||||
NEW_BB_BT_LAST_TORSTAT,
|
||||
));
|
||||
if ($tr_cfg['update_dlstat']) {
|
||||
// ############################ Tables LOCKED ################################
|
||||
DB()->lock(array(
|
||||
BB_BT_TRACKER,
|
||||
NEW_BB_BT_LAST_TORSTAT,
|
||||
));
|
||||
|
||||
// Get PER TORRENT user's dlstat from tracker
|
||||
DB()->query("
|
||||
INSERT INTO ". NEW_BB_BT_LAST_TORSTAT ."
|
||||
// Get PER TORRENT user's dlstat from tracker
|
||||
DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
(topic_id, user_id, dl_status, up_add, down_add, release_add, speed_up, speed_down)
|
||||
SELECT
|
||||
topic_id, user_id, IF(releaser, $releaser, seeder), SUM(up_add), SUM(down_add), IF(releaser, SUM(up_add), 0), SUM(speed_up), SUM(speed_down)
|
||||
FROM ". BB_BT_TRACKER ."
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
WHERE (up_add != 0 OR down_add != 0)
|
||||
GROUP BY topic_id, user_id
|
||||
");
|
||||
|
||||
// Reset up/down additions in tracker
|
||||
DB()->query("UPDATE ". BB_BT_TRACKER ." SET up_add = 0, down_add = 0");
|
||||
// Reset up/down additions in tracker
|
||||
DB()->query("UPDATE " . BB_BT_TRACKER . " SET up_add = 0, down_add = 0");
|
||||
|
||||
DB()->unlock();
|
||||
// ############################ Tables UNLOCKED ##############################
|
||||
DB()->unlock();
|
||||
// ############################ Tables UNLOCKED ##############################
|
||||
}
|
||||
|
||||
// Update last seeder info in BUF
|
||||
DB()->query("
|
||||
REPLACE INTO ". BUF_LAST_SEEDER ."
|
||||
REPLACE INTO " . BUF_LAST_SEEDER . "
|
||||
(topic_id, seeder_last_seen)
|
||||
SELECT
|
||||
topic_id, ". TIMENOW ."
|
||||
FROM ". BB_BT_TRACKER ."
|
||||
topic_id, " . TIMENOW . "
|
||||
FROM " . BB_BT_TRACKER . "
|
||||
WHERE seeder = 1
|
||||
GROUP BY topic_id
|
||||
");
|
||||
|
||||
// Clean peers table
|
||||
if ($tr_cfg['autoclean'])
|
||||
{
|
||||
$announce_interval = max(intval($bb_cfg['announce_interval']), 60);
|
||||
$expire_factor = max(floatval($tr_cfg['expire_factor']), 1);
|
||||
$peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor);
|
||||
if ($tr_cfg['autoclean']) {
|
||||
$announce_interval = max(intval($bb_cfg['announce_interval']), 60);
|
||||
$expire_factor = max(floatval($tr_cfg['expire_factor']), 1);
|
||||
$peer_expire_time = TIMENOW - floor($announce_interval * $expire_factor);
|
||||
|
||||
DB()->query("DELETE FROM ". BB_BT_TRACKER ." WHERE update_time < $peer_expire_time");
|
||||
DB()->query("DELETE FROM " . BB_BT_TRACKER . " WHERE update_time < $peer_expire_time");
|
||||
}
|
||||
|
||||
// Update dlstat (part 2)
|
||||
if ($tr_cfg['update_dlstat'])
|
||||
{
|
||||
// Set "only 1 seeder" bonus
|
||||
DB()->query("
|
||||
if ($tr_cfg['update_dlstat']) {
|
||||
// Set "only 1 seeder" bonus
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". NEW_BB_BT_LAST_TORSTAT ." tb,
|
||||
". BB_BT_TRACKER_SNAP ." sn
|
||||
" . NEW_BB_BT_LAST_TORSTAT . " tb,
|
||||
" . BB_BT_TRACKER_SNAP . " sn
|
||||
SET
|
||||
tb.bonus_add = tb.up_add
|
||||
WHERE
|
||||
tb.topic_id = sn.topic_id
|
||||
AND sn.seeders = 1
|
||||
AND tb.up_add != 0
|
||||
AND tb.dl_status = ". DL_STATUS_COMPLETE ."
|
||||
AND tb.dl_status = " . DL_STATUS_COMPLETE . "
|
||||
");
|
||||
|
||||
// Get SUMMARIZED user's dlstat
|
||||
DB()->query("
|
||||
INSERT INTO ". NEW_BB_BT_LAST_USERSTAT ."
|
||||
// Get SUMMARIZED user's dlstat
|
||||
DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_LAST_USERSTAT . "
|
||||
(user_id, up_add, down_add, release_add, bonus_add, speed_up, speed_down)
|
||||
SELECT
|
||||
user_id, SUM(up_add), SUM(down_add), SUM(release_add), SUM(bonus_add), SUM(speed_up), SUM(speed_down)
|
||||
FROM ". NEW_BB_BT_LAST_TORSTAT ."
|
||||
FROM " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
GROUP BY user_id
|
||||
");
|
||||
|
||||
// Update TOTAL user's dlstat
|
||||
DB()->query("
|
||||
// Update TOTAL user's dlstat
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_BT_USERS ." u,
|
||||
". NEW_BB_BT_LAST_USERSTAT ." ub
|
||||
" . BB_BT_USERS . " u,
|
||||
" . NEW_BB_BT_LAST_USERSTAT . " ub
|
||||
SET
|
||||
u.u_up_total = u.u_up_total + ub.up_add,
|
||||
u.u_down_total = u.u_down_total + ub.down_add,
|
||||
|
@ -109,45 +131,45 @@ if ($tr_cfg['update_dlstat'])
|
|||
WHERE u.user_id = ub.user_id
|
||||
");
|
||||
|
||||
// Delete from dl_list what exists in BUF but not exsits in NEW
|
||||
DB()->query("
|
||||
// Delete from dl_list what exists in BUF but not exsits in NEW
|
||||
DB()->query("
|
||||
DELETE dl
|
||||
FROM ". BB_BT_DLSTATUS ." dl
|
||||
INNER JOIN ". NEW_BB_BT_LAST_TORSTAT ." buf USING(user_id, topic_id)
|
||||
FROM " . BB_BT_DLSTATUS . " dl
|
||||
INNER JOIN " . NEW_BB_BT_LAST_TORSTAT . " buf USING(user_id, topic_id)
|
||||
WHERE buf.user_id IS NULL
|
||||
AND buf.topic_id IS NULL
|
||||
");
|
||||
|
||||
// Update DL-Status
|
||||
DB()->query("
|
||||
REPLACE INTO ". BB_BT_DLSTATUS ."
|
||||
// Update DL-Status
|
||||
DB()->query("
|
||||
REPLACE INTO " . BB_BT_DLSTATUS . "
|
||||
(user_id, topic_id, user_status)
|
||||
SELECT
|
||||
user_id, topic_id, dl_status
|
||||
FROM ". NEW_BB_BT_LAST_TORSTAT ."
|
||||
FROM " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
");
|
||||
|
||||
// Update PER TORRENT DL-Status (for "completed" counter)
|
||||
DB()->query("
|
||||
INSERT IGNORE INTO ". BB_BT_TORSTAT ."
|
||||
// Update PER TORRENT DL-Status (for "completed" counter)
|
||||
DB()->query("
|
||||
INSERT IGNORE INTO " . BB_BT_TORSTAT . "
|
||||
(topic_id, user_id)
|
||||
SELECT
|
||||
topic_id, user_id
|
||||
FROM ". NEW_BB_BT_LAST_TORSTAT ."
|
||||
WHERE dl_status = ". DL_STATUS_COMPLETE ."
|
||||
FROM " . NEW_BB_BT_LAST_TORSTAT . "
|
||||
WHERE dl_status = " . DL_STATUS_COMPLETE . "
|
||||
");
|
||||
}
|
||||
|
||||
DB()->query("
|
||||
RENAME TABLE
|
||||
". BB_BT_LAST_TORSTAT ." TO ". OLD_BB_BT_LAST_TORSTAT .",
|
||||
". NEW_BB_BT_LAST_TORSTAT ." TO ". BB_BT_LAST_TORSTAT ."
|
||||
" . BB_BT_LAST_TORSTAT . " TO " . OLD_BB_BT_LAST_TORSTAT . ",
|
||||
" . NEW_BB_BT_LAST_TORSTAT . " TO " . BB_BT_LAST_TORSTAT . "
|
||||
");
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_LAST_TORSTAT .", ". OLD_BB_BT_LAST_TORSTAT);
|
||||
DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_LAST_TORSTAT . ", " . OLD_BB_BT_LAST_TORSTAT);
|
||||
|
||||
DB()->query("
|
||||
RENAME TABLE
|
||||
". BB_BT_LAST_USERSTAT ." TO ". OLD_BB_BT_LAST_USERSTAT .",
|
||||
". NEW_BB_BT_LAST_USERSTAT ." TO ". BB_BT_LAST_USERSTAT ."
|
||||
" . BB_BT_LAST_USERSTAT . " TO " . OLD_BB_BT_LAST_USERSTAT . ",
|
||||
" . NEW_BB_BT_LAST_USERSTAT . " TO " . BB_BT_LAST_USERSTAT . "
|
||||
");
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_LAST_USERSTAT .", ". OLD_BB_BT_LAST_USERSTAT);
|
||||
DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_LAST_USERSTAT . ", " . OLD_BB_BT_LAST_USERSTAT);
|
||||
|
|
|
@ -1,41 +1,63 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $bb_cfg;
|
||||
|
||||
if ($bb_cfg['ocelot']['enabled'])
|
||||
{
|
||||
// Update TORRENT "completed" counters
|
||||
DB()->query("
|
||||
if ($bb_cfg['ocelot']['enabled']) {
|
||||
// Update TORRENT "completed" counters
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_BT_TORRENTS ." tor,
|
||||
". BB_BT_TRACKER_SNAP. " snap
|
||||
" . 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("
|
||||
} else {
|
||||
// Get complete counts
|
||||
DB()->query("
|
||||
CREATE TEMPORARY TABLE tmp_complete_count
|
||||
SELECT
|
||||
topic_id, COUNT(*) AS compl_cnt
|
||||
FROM ". BB_BT_TORSTAT ."
|
||||
FROM " . BB_BT_TORSTAT . "
|
||||
WHERE completed = 0
|
||||
GROUP BY topic_id
|
||||
");
|
||||
|
||||
// Update USER "completed" counters
|
||||
DB()->query("UPDATE ". BB_BT_TORSTAT ." SET completed = 1");
|
||||
// Update USER "completed" counters
|
||||
DB()->query("UPDATE " . BB_BT_TORSTAT . " SET completed = 1");
|
||||
|
||||
// Update TORRENT "completed" counters
|
||||
DB()->query("
|
||||
// Update TORRENT "completed" counters
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_BT_TORRENTS ." tor,
|
||||
" . BB_BT_TORRENTS . " tor,
|
||||
tmp_complete_count tmp
|
||||
SET
|
||||
tor.complete_count = tor.complete_count + tmp.compl_cnt
|
||||
|
@ -43,6 +65,6 @@ else
|
|||
tor.topic_id = tmp.topic_id
|
||||
");
|
||||
|
||||
// Drop tmp table
|
||||
DB()->query("DROP TEMPORARY TABLE tmp_complete_count");
|
||||
}
|
||||
// Drop tmp table
|
||||
DB()->query("DROP TEMPORARY TABLE tmp_complete_count");
|
||||
}
|
||||
|
|
|
@ -1,45 +1,67 @@
|
|||
<?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__));
|
||||
|
||||
if (empty($bb_cfg['seeder_last_seen_days_keep']) || empty($bb_cfg['seeder_never_seen_days_keep']))
|
||||
{
|
||||
return;
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
$last_seen_time = TIMENOW - 86400*$bb_cfg['seeder_last_seen_days_keep'];
|
||||
$never_seen_time = TIMENOW - 86400*$bb_cfg['seeder_never_seen_days_keep'];
|
||||
if (empty($bb_cfg['seeder_last_seen_days_keep']) || empty($bb_cfg['seeder_never_seen_days_keep'])) {
|
||||
return;
|
||||
}
|
||||
|
||||
$last_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_last_seen_days_keep'];
|
||||
$never_seen_time = TIMENOW - 86400 * $bb_cfg['seeder_never_seen_days_keep'];
|
||||
$limit_sql = 3000;
|
||||
|
||||
$topics_sql = $attach_sql = array();
|
||||
|
||||
$sql = "SELECT topic_id, attach_id
|
||||
FROM ". BB_BT_TORRENTS ."
|
||||
FROM " . BB_BT_TORRENTS . "
|
||||
WHERE reg_time < $never_seen_time
|
||||
AND seeder_last_seen < $last_seen_time
|
||||
LIMIT $limit_sql";
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$topics_sql[] = $row['topic_id'];
|
||||
$attach_sql[] = $row['attach_id'];
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$topics_sql[] = $row['topic_id'];
|
||||
$attach_sql[] = $row['attach_id'];
|
||||
}
|
||||
$dead_tor_sql = join(',', $topics_sql);
|
||||
$attach_sql = join(',', $attach_sql);
|
||||
|
||||
if ($dead_tor_sql && $attach_sql)
|
||||
{
|
||||
// Delete torstat
|
||||
DB()->query("
|
||||
DELETE FROM ". BB_BT_TORSTAT ."
|
||||
if ($dead_tor_sql && $attach_sql) {
|
||||
// Delete torstat
|
||||
DB()->query("
|
||||
DELETE FROM " . BB_BT_TORSTAT . "
|
||||
WHERE topic_id IN($dead_tor_sql)
|
||||
");
|
||||
|
||||
// Update attach
|
||||
DB()->query("
|
||||
// Update attach
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BB_ATTACHMENTS_DESC ." a,
|
||||
". BB_BT_TORRENTS ." tor
|
||||
" . BB_ATTACHMENTS_DESC . " a,
|
||||
" . BB_BT_TORRENTS . " tor
|
||||
SET
|
||||
a.tracker_status = 0,
|
||||
a.download_count = tor.complete_count
|
||||
|
@ -48,9 +70,9 @@ if ($dead_tor_sql && $attach_sql)
|
|||
AND tor.attach_id IN($attach_sql)
|
||||
");
|
||||
|
||||
// Remove torrents
|
||||
DB()->query("
|
||||
DELETE FROM ". BB_BT_TORRENTS ."
|
||||
// Remove torrents
|
||||
DB()->query("
|
||||
DELETE FROM " . BB_BT_TORRENTS . "
|
||||
WHERE topic_id IN($dead_tor_sql)
|
||||
");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,31 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $bb_cfg;
|
||||
|
||||
|
@ -9,30 +34,27 @@ DB()->expect_slow_query(600);
|
|||
//
|
||||
// Make tracker snapshot
|
||||
//
|
||||
if (!$bb_cfg['ocelot']['enabled'])
|
||||
{
|
||||
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);
|
||||
$start_id = (int) $row['start_id'];
|
||||
$finish_id = (int) $row['finish_id'];
|
||||
$row = DB()->fetch_row("SELECT MIN(topic_id) AS start_id, MAX(topic_id) AS finish_id FROM " . BB_BT_TRACKER);
|
||||
$start_id = (int)$row['start_id'];
|
||||
$finish_id = (int)$row['finish_id'];
|
||||
|
||||
while (true)
|
||||
{
|
||||
set_time_limit(600);
|
||||
$end_id = $start_id + $per_cycle - 1;
|
||||
while (true) {
|
||||
set_time_limit(600);
|
||||
$end_id = $start_id + $per_cycle - 1;
|
||||
|
||||
$val = array();
|
||||
$val = array();
|
||||
|
||||
if (!$bb_cfg['ocelot']['enabled'])
|
||||
{
|
||||
$sql = "
|
||||
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
|
||||
|
@ -40,66 +62,56 @@ while (true)
|
|||
WHERE topic_id BETWEEN $start_id AND $end_id
|
||||
GROUP BY topic_id
|
||||
";
|
||||
}
|
||||
else
|
||||
{
|
||||
$sql = "
|
||||
} 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);
|
||||
}
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$val[] = join(',', $row);
|
||||
}
|
||||
|
||||
if ($val)
|
||||
{
|
||||
if (!$bb_cfg['ocelot']['enabled'])
|
||||
{
|
||||
DB()->query("
|
||||
if ($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("
|
||||
} else {
|
||||
DB()->query("
|
||||
INSERT INTO " . BB_BT_TRACKER_SNAP . "
|
||||
(topic_id, speed_up, speed_down)
|
||||
VALUES(". join('),(', $val) .")
|
||||
VALUES(" . join('),(', $val) . ")
|
||||
ON DUPLICATE KEY UPDATE speed_up = VALUES(speed_up), speed_down = VALUES(speed_down)
|
||||
");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($end_id > $finish_id)
|
||||
{
|
||||
break;
|
||||
}
|
||||
if ($end_id > $finish_id) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (!($start_id % ($per_cycle*10)))
|
||||
{
|
||||
sleep(1);
|
||||
}
|
||||
if (!($start_id % ($per_cycle * 10))) {
|
||||
sleep(1);
|
||||
}
|
||||
|
||||
$start_id += $per_cycle;
|
||||
$start_id += $per_cycle;
|
||||
}
|
||||
|
||||
if (!$bb_cfg['ocelot']['enabled'])
|
||||
{
|
||||
DB()->query("
|
||||
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 ."
|
||||
" . 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);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -108,98 +120,94 @@ if (!$bb_cfg['ocelot']['enabled'])
|
|||
define('NEW_BB_BT_DLSTATUS_SNAP', 'new_dlstatus_snap');
|
||||
define('OLD_BB_BT_DLSTATUS_SNAP', 'old_dlstatus_snap');
|
||||
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_DLSTATUS_SNAP .", ". OLD_BB_BT_DLSTATUS_SNAP);
|
||||
DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_DLSTATUS_SNAP . ", " . OLD_BB_BT_DLSTATUS_SNAP);
|
||||
|
||||
DB()->query("CREATE TABLE ". NEW_BB_BT_DLSTATUS_SNAP ." LIKE ". BB_BT_DLSTATUS_SNAP);
|
||||
DB()->query("CREATE TABLE " . NEW_BB_BT_DLSTATUS_SNAP . " LIKE " . BB_BT_DLSTATUS_SNAP);
|
||||
|
||||
if ($bb_cfg['bt_show_dl_list'] && $bb_cfg['bt_dl_list_only_count'])
|
||||
{
|
||||
DB()->query("
|
||||
INSERT INTO ". NEW_BB_BT_DLSTATUS_SNAP ."
|
||||
if ($bb_cfg['bt_show_dl_list'] && $bb_cfg['bt_dl_list_only_count']) {
|
||||
DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_DLSTATUS_SNAP . "
|
||||
(topic_id, dl_status, users_count)
|
||||
SELECT
|
||||
topic_id, user_status, COUNT(*)
|
||||
FROM ". BB_BT_DLSTATUS ."
|
||||
WHERE user_status != ". DL_STATUS_RELEASER ."
|
||||
FROM " . BB_BT_DLSTATUS . "
|
||||
WHERE user_status != " . DL_STATUS_RELEASER . "
|
||||
GROUP BY topic_id, user_status
|
||||
");
|
||||
}
|
||||
|
||||
DB()->query("
|
||||
RENAME TABLE
|
||||
". BB_BT_DLSTATUS_SNAP ." TO ". OLD_BB_BT_DLSTATUS_SNAP .",
|
||||
". NEW_BB_BT_DLSTATUS_SNAP ." TO ". BB_BT_DLSTATUS_SNAP ."
|
||||
" . BB_BT_DLSTATUS_SNAP . " TO " . OLD_BB_BT_DLSTATUS_SNAP . ",
|
||||
" . NEW_BB_BT_DLSTATUS_SNAP . " TO " . BB_BT_DLSTATUS_SNAP . "
|
||||
");
|
||||
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_DLSTATUS_SNAP .", ". OLD_BB_BT_DLSTATUS_SNAP);
|
||||
DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_DLSTATUS_SNAP . ", " . OLD_BB_BT_DLSTATUS_SNAP);
|
||||
|
||||
//
|
||||
// TORHELP
|
||||
//
|
||||
if ($bb_cfg['torhelp_enabled'])
|
||||
{
|
||||
$tor_min_seeders = 0; // "<="
|
||||
$tor_min_leechers = 2; // ">="
|
||||
$tor_min_completed = 10; // ">="
|
||||
$tor_seed_last_seen_days = 3; // "<="
|
||||
$tor_downloaded_days_ago = 60; // ">="
|
||||
$user_last_seen_online = 15; // minutes
|
||||
$users_limit = 3000;
|
||||
$dl_status_ary = array(DL_STATUS_COMPLETE);
|
||||
if ($bb_cfg['torhelp_enabled']) {
|
||||
$tor_min_seeders = 0; // "<="
|
||||
$tor_min_leechers = 2; // ">="
|
||||
$tor_min_completed = 10; // ">="
|
||||
$tor_seed_last_seen_days = 3; // "<="
|
||||
$tor_downloaded_days_ago = 60; // ">="
|
||||
$user_last_seen_online = 15; // minutes
|
||||
$users_limit = 3000;
|
||||
$dl_status_ary = array(DL_STATUS_COMPLETE);
|
||||
|
||||
define('NEW_BB_BT_TORHELP', 'new_torhelp');
|
||||
define('OLD_BB_BT_TORHELP', 'old_torhelp');
|
||||
define('NEW_BB_BT_TORHELP', 'new_torhelp');
|
||||
define('OLD_BB_BT_TORHELP', 'old_torhelp');
|
||||
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_TORHELP .", ". OLD_BB_BT_TORHELP);
|
||||
DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TORHELP . ", " . OLD_BB_BT_TORHELP);
|
||||
|
||||
DB()->query("CREATE TABLE ". NEW_BB_BT_TORHELP ." LIKE ". BB_BT_TORHELP);
|
||||
DB()->query("CREATE TABLE " . NEW_BB_BT_TORHELP . " LIKE " . BB_BT_TORHELP);
|
||||
|
||||
// Select users
|
||||
$sql = "
|
||||
// Select users
|
||||
$sql = "
|
||||
SELECT DISTINCT session_user_id AS uid
|
||||
FROM ". BB_SESSIONS ."
|
||||
FROM " . BB_SESSIONS . "
|
||||
WHERE session_time > (UNIX_TIMESTAMP() - $user_last_seen_online*60)
|
||||
AND session_user_id != ". GUEST_UID ."
|
||||
AND session_user_id != " . GUEST_UID . "
|
||||
ORDER BY session_time DESC
|
||||
LIMIT $users_limit
|
||||
";
|
||||
$online_users_ary = array();
|
||||
$online_users_ary = array();
|
||||
|
||||
foreach (DB()->fetch_rowset($sql) as $row)
|
||||
{
|
||||
$online_users_ary[] = $row['uid'];
|
||||
}
|
||||
foreach (DB()->fetch_rowset($sql) as $row) {
|
||||
$online_users_ary[] = $row['uid'];
|
||||
}
|
||||
|
||||
if ($online_users_csv = join(',', $online_users_ary))
|
||||
{
|
||||
DB()->query("
|
||||
INSERT INTO ". NEW_BB_BT_TORHELP ." (user_id, topic_id_csv)
|
||||
if ($online_users_csv = join(',', $online_users_ary)) {
|
||||
DB()->query("
|
||||
INSERT INTO " . NEW_BB_BT_TORHELP . " (user_id, topic_id_csv)
|
||||
SELECT
|
||||
dl.user_id, GROUP_CONCAT(dl.topic_id)
|
||||
FROM ". BB_BT_TRACKER_SNAP ." trsn
|
||||
INNER JOIN ". BB_BT_TORRENTS ." tor ON (tor.topic_id = trsn.topic_id)
|
||||
INNER JOIN ". BB_BT_DLSTATUS ." dl ON (dl.topic_id = tor.topic_id)
|
||||
FROM " . BB_BT_TRACKER_SNAP . " trsn
|
||||
INNER JOIN " . BB_BT_TORRENTS . " tor ON (tor.topic_id = trsn.topic_id)
|
||||
INNER JOIN " . BB_BT_DLSTATUS . " dl ON (dl.topic_id = tor.topic_id)
|
||||
WHERE
|
||||
trsn.seeders <= $tor_min_seeders
|
||||
AND trsn.leechers >= $tor_min_leechers
|
||||
AND tor.forum_id != ". (int) $bb_cfg['trash_forum_id'] ."
|
||||
AND tor.forum_id != " . (int)$bb_cfg['trash_forum_id'] . "
|
||||
AND tor.complete_count >= $tor_min_completed
|
||||
AND tor.seeder_last_seen <= (UNIX_TIMESTAMP() - $tor_seed_last_seen_days*86400)
|
||||
AND dl.user_id IN($online_users_csv)
|
||||
AND dl.user_status IN(". get_id_csv($dl_status_ary) .")
|
||||
AND dl.user_status IN(" . get_id_csv($dl_status_ary) . ")
|
||||
AND dl.last_modified_dlstatus > DATE_SUB(NOW(), INTERVAL $tor_downloaded_days_ago DAY)
|
||||
GROUP BY dl.user_id
|
||||
LIMIT 10000
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
DB()->query("
|
||||
DB()->query("
|
||||
RENAME TABLE
|
||||
". BB_BT_TORHELP ." TO ". OLD_BB_BT_TORHELP .",
|
||||
". NEW_BB_BT_TORHELP ." TO ". BB_BT_TORHELP ."
|
||||
" . BB_BT_TORHELP . " TO " . OLD_BB_BT_TORHELP . ",
|
||||
" . NEW_BB_BT_TORHELP . " TO " . BB_BT_TORHELP . "
|
||||
");
|
||||
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_TORHELP .", ". OLD_BB_BT_TORHELP);
|
||||
DB()->query("DROP TABLE IF EXISTS " . NEW_BB_BT_TORHELP . ", " . OLD_BB_BT_TORHELP);
|
||||
}
|
||||
|
||||
DB()->expect_slow_query(10);
|
||||
DB()->expect_slow_query(10);
|
||||
|
|
|
@ -1,42 +1,67 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
DB()->expect_slow_query(600);
|
||||
|
||||
if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['seed_bonus_release'])
|
||||
{
|
||||
DB()->query("
|
||||
if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['seed_bonus_release']) {
|
||||
DB()->query("
|
||||
CREATE TEMPORARY TABLE tmp_bonus (
|
||||
user_id INT UNSIGNED NOT NULL DEFAULT '0',
|
||||
release_count INT UNSIGNED NOT NULL DEFAULT '0'
|
||||
) ENGINE = MEMORY
|
||||
");
|
||||
|
||||
$tor_size = ($bb_cfg['seed_bonus_tor_size'] * 1073741824);
|
||||
$tor_size = ($bb_cfg['seed_bonus_tor_size'] * 1073741824);
|
||||
|
||||
DB()->query("INSERT INTO tmp_bonus
|
||||
DB()->query("INSERT INTO tmp_bonus
|
||||
SELECT bt.user_id, count(bt.seeder) AS release_count
|
||||
FROM ". BB_BT_TRACKER ." bt, ". BB_BT_TORRENTS ." tor
|
||||
FROM " . BB_BT_TRACKER . " bt, " . BB_BT_TORRENTS . " tor
|
||||
WHERE tor.topic_id = bt.topic_id
|
||||
AND tor.size > $tor_size
|
||||
AND bt.seeder > 0
|
||||
GROUP BY user_id
|
||||
");
|
||||
|
||||
$seed_bonus = unserialize($bb_cfg['seed_bonus_points']);
|
||||
$seed_release = unserialize($bb_cfg['seed_bonus_release']);
|
||||
$seed_bonus = unserialize($bb_cfg['seed_bonus_points']);
|
||||
$seed_release = unserialize($bb_cfg['seed_bonus_release']);
|
||||
|
||||
foreach($seed_bonus as $i => $points)
|
||||
{
|
||||
if (!$points || !$seed_release[$i]) continue;
|
||||
foreach ($seed_bonus as $i => $points) {
|
||||
if (!$points || !$seed_release[$i]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$user_points = ((float) $points / 4);
|
||||
$release = (int) $seed_release[$i];
|
||||
$user_regdate = (TIMENOW - $bb_cfg['seed_bonus_user_regdate'] * 86400);
|
||||
$user_points = ((float)$points / 4);
|
||||
$release = (int)$seed_release[$i];
|
||||
$user_regdate = (TIMENOW - $bb_cfg['seed_bonus_user_regdate'] * 86400);
|
||||
|
||||
DB()->query("
|
||||
UPDATE ". BB_USERS ." u, ". BB_BT_USERS ." bu, tmp_bonus b
|
||||
DB()->query("
|
||||
UPDATE " . BB_USERS . " u, " . BB_BT_USERS . " bu, tmp_bonus b
|
||||
SET
|
||||
u.user_points = u.user_points + '$user_points',
|
||||
bu.points_today = bu.points_today + '$user_points',
|
||||
|
@ -47,9 +72,9 @@ if ($bb_cfg['seed_bonus_enabled'] && $bb_cfg['seed_bonus_points'] && $bb_cfg['se
|
|||
AND b.release_count <= $release
|
||||
AND u.user_regdate < $user_regdate
|
||||
AND u.user_active = 1
|
||||
AND u.user_id not IN(". EXCLUDED_USERS_CSV .")
|
||||
AND u.user_id not IN(" . EXCLUDED_USERS_CSV . ")
|
||||
");
|
||||
}
|
||||
}
|
||||
|
||||
DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_bonus");
|
||||
}
|
||||
DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_bonus");
|
||||
}
|
||||
|
|
|
@ -1,15 +1,40 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
DB()->query("
|
||||
UPDATE
|
||||
". BUF_LAST_SEEDER ." b,
|
||||
". BB_BT_TORRENTS ." tor
|
||||
" . BUF_LAST_SEEDER . " b,
|
||||
" . BB_BT_TORRENTS . " tor
|
||||
SET
|
||||
tor.seeder_last_seen = b.seeder_last_seen
|
||||
WHERE
|
||||
tor.topic_id = b.topic_id
|
||||
");
|
||||
|
||||
DB()->query("TRUNCATE TABLE ". BUF_LAST_SEEDER);
|
||||
DB()->query("TRUNCATE TABLE " . BUF_LAST_SEEDER);
|
||||
|
|
|
@ -1,31 +1,53 @@
|
|||
<?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__));
|
||||
if (!defined('BB_ROOT')) {
|
||||
die(basename(__FILE__));
|
||||
}
|
||||
|
||||
global $bb_cfg;
|
||||
|
||||
require_once(INC_DIR .'functions_atom.php');
|
||||
require_once(INC_DIR . 'functions_atom.php');
|
||||
|
||||
$timecheck = TIMENOW - 600;
|
||||
$forums_data = DB()->fetch_rowset("SELECT forum_id, allow_reg_tracker, forum_name FROM ". BB_FORUMS);
|
||||
$forums_data = DB()->fetch_rowset("SELECT forum_id, allow_reg_tracker, forum_name FROM " . BB_FORUMS);
|
||||
|
||||
if (file_exists($bb_cfg['atom']['path'] .'/f/0.atom'))
|
||||
{
|
||||
if (filemtime($bb_cfg['atom']['path'] .'/f/0.atom') <= $timecheck) update_forum_feed(0, $forums_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_forum_feed(0, $forums_data);
|
||||
if (file_exists($bb_cfg['atom']['path'] . '/f/0.atom')) {
|
||||
if (filemtime($bb_cfg['atom']['path'] . '/f/0.atom') <= $timecheck) {
|
||||
update_forum_feed(0, $forums_data);
|
||||
}
|
||||
} else {
|
||||
update_forum_feed(0, $forums_data);
|
||||
}
|
||||
|
||||
foreach ($forums_data as $forum_data)
|
||||
{
|
||||
if (file_exists($bb_cfg['atom']['path'] .'/f/'. $forum_data['forum_id'] .'.atom'))
|
||||
{
|
||||
if (filemtime($bb_cfg['atom']['path'] .'/f/'. $forum_data['forum_id'] .'.atom') <= $timecheck) update_forum_feed($forum_data['forum_id'], $forum_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
update_forum_feed($forum_data['forum_id'], $forum_data);
|
||||
}
|
||||
}
|
||||
foreach ($forums_data as $forum_data) {
|
||||
if (file_exists($bb_cfg['atom']['path'] . '/f/' . $forum_data['forum_id'] . '.atom')) {
|
||||
if (filemtime($bb_cfg['atom']['path'] . '/f/' . $forum_data['forum_id'] . '.atom') <= $timecheck) {
|
||||
update_forum_feed($forum_data['forum_id'], $forum_data);
|
||||
}
|
||||
} else {
|
||||
update_forum_feed($forum_data['forum_id'], $forum_data);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue