takeinvite add lock

This commit is contained in:
lgb
2024-05-20 11:59:12 +08:00
parent bc83be2985
commit b2f74bedaa
5 changed files with 13 additions and 4 deletions
+1 -1
View File
@@ -1,6 +1,6 @@
<?php <?php
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.12'); defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.12');
defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-05-10'); defined('RELEASE_DATE') || define('RELEASE_DATE', '2024-05-20');
defined('IN_TRACKER') || define('IN_TRACKER', false); defined('IN_TRACKER') || define('IN_TRACKER', false);
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP"); defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org"); defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
+9 -3
View File
@@ -2,6 +2,14 @@
require_once("../include/bittorrent.php"); require_once("../include/bittorrent.php");
dbconn(); dbconn();
require_once(get_langfile_path()); require_once(get_langfile_path());
loggedinorreturn();
$id = $CURUSER['id'];
$lockName = sprintf("takeinvite:%s", $id);
$lock = new \Nexus\Database\NexusLock($lockName, 10);
if (!$lock->get()) {
$errMsg = nexus_trans("nexus.do_not_repeat");
stderr($errMsg, $errMsg);
}
registration_check('invitesystem', true, false); registration_check('invitesystem', true, false);
$userRep = new \App\Repositories\UserRepository(); $userRep = new \App\Repositories\UserRepository();
try { try {
@@ -15,8 +23,6 @@ function bark($msg) {
stdfoot(); stdfoot();
exit; exit;
} }
$id = $CURUSER['id'];
$email = unesc(htmlspecialchars(trim($_POST["email"]))); $email = unesc(htmlspecialchars(trim($_POST["email"])));
$email = safe_email($email); $email = safe_email($email);
$preRegisterUsername = $_POST['pre_register_username'] ?? ''; $preRegisterUsername = $_POST['pre_register_username'] ?? '';
@@ -123,7 +129,7 @@ if ($sendResult === true) {
sql_query("UPDATE users SET invites = invites - 1 WHERE id = ".mysql_real_escape_string($id)) or sqlerr(__FILE__, __LINE__); sql_query("UPDATE users SET invites = invites - 1 WHERE id = ".mysql_real_escape_string($id)) or sqlerr(__FILE__, __LINE__);
} }
} }
$lock->release();
header("Refresh: 0; url=invite.php?id=".htmlspecialchars($id)."&sent=1"); header("Refresh: 0; url=invite.php?id=".htmlspecialchars($id)."&sent=1");
?> ?>
+1
View File
@@ -15,4 +15,5 @@ return [
'action' => 'Action', 'action' => 'Action',
'no_limit' => 'No limit', 'no_limit' => 'No limit',
'sum' => 'Sum', 'sum' => 'Sum',
'do_not_repeat' => 'Please do not repeat the operation!',
]; ];
+1
View File
@@ -15,4 +15,5 @@ return [
'action' => '操作', 'action' => '操作',
'no_limit' => '不限', 'no_limit' => '不限',
'sum' => '累计', 'sum' => '累计',
'do_not_repeat' => '请不要重复操作!',
]; ];
+1
View File
@@ -15,4 +15,5 @@ return [
'action' => '操作', 'action' => '操作',
'no_limit' => '不限', 'no_limit' => '不限',
'sum' => '累計', 'sum' => '累計',
'do_not_repeat' => '請不要重復操作!',
]; ];