mirror of
https://github.com/Shadowss/TravianZ.git
synced 2026-09-08 19:37:14 +00:00
Some important fixes
This commit is contained in:
@@ -244,8 +244,17 @@ trait DatabaseAllianceQueries {
|
|||||||
list($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) = $this->escape_input($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8);
|
list($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8) = $this->escape_input($uid, $aid, $rank, $opt1, $opt2, $opt3, $opt4, $opt5, $opt6, $opt7, $opt8);
|
||||||
|
|
||||||
|
|
||||||
$q = "INSERT into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')";
|
$q = "INSERT IGNORE into " . TB_PREFIX . "ali_permission values(0,'$uid','$aid','$rank','$opt1','$opt2','$opt3','$opt4','$opt5','$opt6','$opt7','$opt8')";
|
||||||
mysqli_query($this->dblink,$q);
|
// BUG FIXED (fatal, log 3 sep): acceptInvite() in Alliance.php checks
|
||||||
|
// $session->alliance == 0 before calling this, but a double-submitted request
|
||||||
|
// (double-click / two near-simultaneous requests) can pass that check twice
|
||||||
|
// before either commits - ali_permission has a UNIQUE KEY on (uid, alliance),
|
||||||
|
// so the second INSERT threw an uncaught "Duplicate entry" mysqli_sql_exception,
|
||||||
|
// killing the whole request. INSERT IGNORE makes the (rare) duplicate a silent
|
||||||
|
// no-op instead: the first request's row already has correct, freshly-created
|
||||||
|
// permissions, so there's nothing meaningful to overwrite. Routed through
|
||||||
|
// $this->query() too, for the deadlock/connection-loss retry already there.
|
||||||
|
$this->query($q);
|
||||||
|
|
||||||
// update cache
|
// update cache
|
||||||
$insertID = mysqli_insert_id($this->dblink);
|
$insertID = mysqli_insert_id($this->dblink);
|
||||||
@@ -294,7 +303,12 @@ trait DatabaseAllianceQueries {
|
|||||||
self::$alliancePermissionsCache[ $uid . $aid ]['opt5'] = $opt5;
|
self::$alliancePermissionsCache[ $uid . $aid ]['opt5'] = $opt5;
|
||||||
self::$alliancePermissionsCache[ $uid . $aid ]['opt6'] = $opt6;
|
self::$alliancePermissionsCache[ $uid . $aid ]['opt6'] = $opt6;
|
||||||
self::$alliancePermissionsCache[ $uid . $aid ]['opt7'] = $opt7;
|
self::$alliancePermissionsCache[ $uid . $aid ]['opt7'] = $opt7;
|
||||||
self::$alliancePermissionsCache[ $uid . $aid ]['opt8'] = $opt8;
|
// BUG FIXED: this function has no $opt8 parameter (only opt1..opt7 - see
|
||||||
|
// signature above and the UPDATE below, which also never touches the opt8
|
||||||
|
// column) - "self::...['opt8'] = $opt8" referenced an undefined variable on
|
||||||
|
// every call. Line removed entirely rather than inventing an opt8 param none
|
||||||
|
// of the 4 call sites pass: the DB column is untouched by this function, so
|
||||||
|
// leaving the cached opt8 value alone is what actually matches the DB.
|
||||||
}
|
}
|
||||||
$q = "UPDATE " . TB_PREFIX . "ali_permission SET `rank` = '$rank',opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' WHERE uid = $uid AND alliance = $aid LIMIT 1";
|
$q = "UPDATE " . TB_PREFIX . "ali_permission SET `rank` = '$rank',opt1 = '$opt1', opt2 = '$opt2', opt3 = '$opt3', opt4 = '$opt4', opt5 = '$opt5', opt6 = '$opt6', opt7 = '$opt7' WHERE uid = $uid AND alliance = $aid LIMIT 1";
|
||||||
$result = mysqli_query($this->dblink, $q);
|
$result = mysqli_query($this->dblink, $q);
|
||||||
|
|||||||
@@ -198,7 +198,12 @@ trait DatabaseStatisticsQueries {
|
|||||||
}
|
}
|
||||||
|
|
||||||
$q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5";
|
$q = "SELECT count(id) FROM " . TB_PREFIX . "users where id > 5";
|
||||||
$result = mysqli_query($this->dblink,$q);
|
// BUG FIXED (fatal, log 2 sep): raw mysqli_query() bypassed $this->query() (the
|
||||||
|
// only place with reconnect/retry). This is called on every automation tick via
|
||||||
|
// procNewClimbers() -> Ranking::procRankArray() -> countUser() - when the
|
||||||
|
// connection dropped between cron ticks, "MySQL server has gone away" (2006)
|
||||||
|
// killed the whole tick. Same fix already applied to getOasisEnforce().
|
||||||
|
$result = $this->query($q);
|
||||||
$row = mysqli_fetch_row($result);
|
$row = mysqli_fetch_row($result);
|
||||||
|
|
||||||
self::$usersCountCache[0] = $row[0];
|
self::$usersCountCache[0] = $row[0];
|
||||||
|
|||||||
@@ -137,8 +137,15 @@ for ($i = (1 + $s); $i <= (10 + $s); $i++) {
|
|||||||
|
|
||||||
if (
|
if (
|
||||||
!$support_messages ||
|
!$support_messages ||
|
||||||
($support_messages && $message->inbox1[$i - 1]['target'] != 1) ||
|
// BUG FIXED (warning only): $message->inbox1[$i - 1] intentionally kept as-is
|
||||||
($multihunter_messages && $message->inbox1[$i - 1]['target'] != 5)
|
// (see "IMPORTANT: păstrăm bug original inbox1" above) - inbox1 is a different,
|
||||||
|
// differently-sized array than sent1, so these indices commonly don't exist.
|
||||||
|
// Null-coalescing gives the exact same result as before (undefined key/null
|
||||||
|
// offset both evaluated to NULL, and NULL != 1 / NULL != 5 are both true) -
|
||||||
|
// just without the "Undefined array key" + "array offset on null" warning
|
||||||
|
// pair firing on every one of the up to 10 rows on this page.
|
||||||
|
($support_messages && ($message->inbox1[$i - 1]['target'] ?? null) != 1) ||
|
||||||
|
($multihunter_messages && ($message->inbox1[$i - 1]['target'] ?? null) != 5)
|
||||||
) {
|
) {
|
||||||
$sent_as_text =
|
$sent_as_text =
|
||||||
"<input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $msg['id'] . "\" />";
|
"<input class=\"check\" type=\"checkbox\" name=\"n" . $name . "\" value=\"" . $msg['id'] . "\" />";
|
||||||
|
|||||||
+1
-1
@@ -35,7 +35,7 @@ if(isset($_GET['newdid'])){
|
|||||||
if(isset($_GET['t'])){
|
if(isset($_GET['t'])){
|
||||||
header("Location: ".$_SERVER['PHP_SELF']."?t=".$_GET['t']);
|
header("Location: ".$_SERVER['PHP_SELF']."?t=".$_GET['t']);
|
||||||
exit();
|
exit();
|
||||||
}else if($_GET['id'] != 0){
|
}else if(isset($_GET['id']) && $_GET['id'] != 0){
|
||||||
header("Location: ".$_SERVER['PHP_SELF']."?id=".$_GET['id']);
|
header("Location: ".$_SERVER['PHP_SELF']."?id=".$_GET['id']);
|
||||||
exit();
|
exit();
|
||||||
}else{
|
}else{
|
||||||
|
|||||||
Reference in New Issue
Block a user