mirror of
https://github.com/torrentpier/torrentpier
synced 2025-08-21 13:54:02 -07:00
Отделение крон-задачи начисления сидбонусов
Отделение задачи из-за проблем с ее выполнением; исправление с присовением значений переменных массивам в задаче начисления сидбонусов; исправление ошибкис кодировкой админки после изменения конфига языков; исправление ошибки с отправкой почты из-за неверного email-адреса.
This commit is contained in:
parent
5745161a54
commit
7d2dc28fbe
6 changed files with 64 additions and 58 deletions
|
@ -150,56 +150,4 @@ DB()->query("
|
|||
". 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()->expect_slow_query(10);
|
||||
|
||||
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);
|
||||
|
||||
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
|
||||
WHERE tor.topic_id = bt.topic_id
|
||||
AND tor.size > $tor_size
|
||||
AND bt.seeder > 0
|
||||
GROUP BY user_id
|
||||
");
|
||||
|
||||
$seed_bonus = (float) unserialize($bb_cfg['seed_bonus_points']);
|
||||
$seed_release = (int) unserialize($bb_cfg['seed_bonus_release']);
|
||||
|
||||
foreach($seed_bonus as $i => $points)
|
||||
{
|
||||
if (!$points || !$seed_release[$i]) continue;
|
||||
|
||||
$user_points = ($points / 4);
|
||||
$release = $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
|
||||
SET
|
||||
u.user_points = u.user_points + $user_points,
|
||||
bu.points_today = bu.points_today + $user_points,
|
||||
b.user_id = 0
|
||||
WHERE
|
||||
b.user_id = u.user_id
|
||||
AND bu.user_id = u.user_id
|
||||
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 .")
|
||||
");
|
||||
}
|
||||
|
||||
DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_bonus");
|
||||
}
|
||||
DB()->query("DROP TABLE IF EXISTS ". NEW_BB_BT_LAST_USERSTAT .", ". OLD_BB_BT_LAST_USERSTAT);
|
55
library/includes/cron/jobs/tr_seed_bonus.php
Normal file
55
library/includes/cron/jobs/tr_seed_bonus.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
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("
|
||||
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);
|
||||
|
||||
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
|
||||
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']);
|
||||
|
||||
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);
|
||||
|
||||
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,
|
||||
b.user_id = 0
|
||||
WHERE
|
||||
b.user_id = u.user_id
|
||||
AND bu.user_id = u.user_id
|
||||
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 .")
|
||||
");
|
||||
}
|
||||
|
||||
DB()->query("DROP TEMPORARY TABLE IF EXISTS tmp_bonus");
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue