mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 03:57:22 +08:00
require redis and use reids to check ReAnnounce
This commit is contained in:
+30
-9
@@ -4,11 +4,27 @@ dbconn();
|
||||
loggedinorreturn();
|
||||
if (get_user_class() < UC_MODERATOR)
|
||||
stderr("Error", "Access denied.");
|
||||
$seedBonusAll = [
|
||||
1 => 100,
|
||||
2 => 1000,
|
||||
3 => 10000,
|
||||
];
|
||||
$selectName = 'seed_bonus_type';
|
||||
$select = '<select name="' . $selectName . '">';
|
||||
foreach ($seedBonusAll as $key => $value) {
|
||||
$select .= sprintf('<option value="%s">%s</option>', $key, $value);
|
||||
}
|
||||
$select .= '</select>';
|
||||
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST")
|
||||
{
|
||||
if ($_POST['doit'] == 'yes') {
|
||||
sql_query("UPDATE users SET seedbonus = seedbonus + 25.0 WHERE status='confirmed'");
|
||||
stderr("Bonus", "25.0 bonus point is sent to everyone...");
|
||||
if (isset($_POST['doit']) && $_POST['doit'] == 'yes') {
|
||||
if (empty($_POST[$selectName]) || !isset($seedBonusAll[$_POST[$selectName]])) {
|
||||
stderr("Error", "Invalid form data: $selectName.");
|
||||
}
|
||||
$seedBonusIncrease = $seedBonusAll[$_POST[$selectName]];
|
||||
sql_query("UPDATE users SET seedbonus = seedbonus + $seedBonusIncrease WHERE status='confirmed'");
|
||||
stderr("Bonus", "$seedBonusIncrease bonus point is sent to everyone...");
|
||||
die;
|
||||
}
|
||||
|
||||
@@ -40,14 +56,19 @@ print("<table width=100% border=1 cellspacing=0 cellpadding=5>\n");
|
||||
<?php end_table();?>
|
||||
</form>
|
||||
<?php end_main_frame();?>
|
||||
<?php begin_main_frame("Send 25.0 bonus point to everyone",false,30);?>
|
||||
<?php begin_main_frame("Send bonus point to everyone",false,30);?>
|
||||
<form action="amountbonus.php" method="post">
|
||||
<table width=100% border=1 cellspacing=0 cellpadding=5>
|
||||
<tr><td class="rowfollow" width="100%">
|
||||
Are you sure you want to give all confirmed users 25.0 extra bonus point?<br /><br /></td></tr>
|
||||
<tr><td class="toolbox" align="center"><input type = "hidden" name = "doit" value = "yes" />
|
||||
<input type="submit" class="btn" value="Yes" />
|
||||
</td></tr>
|
||||
<tr>
|
||||
<td class="rowhead">Bonus</td>
|
||||
<td class="rowfollow"><?php echo $select?></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="toolbox" align="center" colspan="2">
|
||||
<input type = "hidden" name = "doit" value = "yes" />
|
||||
<input type="submit" class="btn" value="Okay" />
|
||||
</td>
|
||||
</tr>
|
||||
<?php end_table();?>
|
||||
</form>
|
||||
<?php
|
||||
|
||||
+4
-9
@@ -147,7 +147,6 @@ $fields = "seeder, peer_id, ip, port, uploaded, downloaded, (".TIMENOW." - UNIX_
|
||||
* @since 1.6.0-beta12
|
||||
*/
|
||||
$peerlistsql = "SELECT ".$fields." FROM peers WHERE torrent = " . $torrentid . $only_leech_query . $limit;
|
||||
$res = sql_query($peerlistsql);
|
||||
|
||||
$real_annnounce_interval = $announce_interval;
|
||||
if ($anninterthreeage && ($anninterthree > $announce_wait) && (TIMENOW - $torrent['ts']) >= ($anninterthreeage * 86400))
|
||||
@@ -172,17 +171,16 @@ if ($compact == 1) {
|
||||
//check ReAnnounce
|
||||
$params = $_GET;
|
||||
unset($params['key']);
|
||||
$lockKey = implode('', $params);
|
||||
$fp = fopen($lockKey, 'w+');
|
||||
if (!fopen($fp, LOCK_EX|LOCK_NB)) {
|
||||
$lockKey = md5(http_build_query($params));
|
||||
$redis = $Cache->getRedis();
|
||||
if (!$redis->setnx($lockKey, $announce_wait, TIMENOW)) {
|
||||
do_log('ReAnnounce');
|
||||
benc_resp($rep_dict);
|
||||
fclose($fp);
|
||||
exit();
|
||||
}
|
||||
|
||||
unset($self);
|
||||
|
||||
$res = sql_query($peerlistsql);
|
||||
if (isset($event) && $event == "stopped") {
|
||||
// Don't fetch peers for stopped event
|
||||
} else {
|
||||
@@ -494,8 +492,5 @@ if(count($USERUPDATESET) && $userid)
|
||||
{
|
||||
sql_query("UPDATE users SET " . join(",", $USERUPDATESET) . " WHERE id = ".$userid);
|
||||
}
|
||||
|
||||
flock($fp, LOCK_UN);
|
||||
fclose($fp);
|
||||
benc_resp($rep_dict);
|
||||
?>
|
||||
|
||||
Reference in New Issue
Block a user