fix resource limit (#322)

This commit is contained in:
Roy Shum
2017-11-09 00:29:23 +08:00
committed by Martin Ambrus
parent b85abeaf78
commit aa570c1bcb
+39 -31
View File
@@ -166,6 +166,7 @@ class Automation {
} }
public function __construct() { public function __construct() {
$this->procNewClimbers(); $this->procNewClimbers();
$this->ClearUser(); $this->ClearUser();
$this->ClearInactive(); $this->ClearInactive();
@@ -4383,42 +4384,49 @@ class Automation {
// by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com > // by SlimShady95, aka Manuel Mannhardt < manuel_mannhardt@web.de > UPDATED FROM songeriux < haroldas.snei@gmail.com >
private function updateStore() { private function updateStore() {
global $bid10, $bid38, $bid11, $bid39; global $bid10, $bid38, $bid11, $bid39;
$result = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'fdata`');
$dataStore = [];
while ($row = mysqli_fetch_assoc($result)) { $result = mysqli_query($GLOBALS['link'],'SELECT * FROM `' . TB_PREFIX . 'fdata`');
mysqli_begin_transaction($GLOBALS['link']) or die(mysqli_error($database->dblink));;
while ($row = mysqli_fetch_assoc($result))
{
$ress = $crop = 0; $ress = $crop = 0;
for ($i = 19; $i < 40; ++$i) { for ($i = 19; $i < 40; ++$i)
$bidVar = 'bid'; {
switch ($row["f$i". 't']) { if ($row['f' . $i . 't'] == 10)
case 10: {
case 38: $ress += ((isset($bid10[$row['f' . $i]]) && isset($bid10[$row['f' . $i]]['attri'])) ? $bid10[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
$bidVar .= $row["f$i". 't']; }
if (isset($$bidVar[$row["f$i"]]) && isset($$bidVar[$row["f$i"]]['attri'])) {
$ress += $$bidVar[$row["f$i"]]['attri'] * STORAGE_MULTIPLIER; if ($row['f' . $i . 't'] == 38)
} {
break; $ress += ((isset($bid38[$row['f' . $i]]) && isset($bid38[$row['f' . $i]]['attri'])) ? $bid38[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
case 11: }
case 39:
$bidVar .= $row["f$i". 't'];
if (isset($$bidVar[$row["f$i"]]) && isset($$bidVar[$row["f$i"]]['attri'])) {
$crop += $$bidVar[$row["f$i"]]['attri'] * STORAGE_MULTIPLIER; if ($row['f' . $i . 't'] == 11)
} {
break; $crop += ((isset($bid11[$row['f' . $i]]) && isset($bid11[$row['f' . $i]]['attri'])) ? $bid11[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
}
if ($row['f' . $i . 't'] == 39)
{
$crop += ((isset($bid39[$row['f' . $i]]) && isset($bid39[$row['f' . $i]]['attri'])) ? $bid39[$row['f' . $i]]['attri'] * STORAGE_MULTIPLIER : 0);
} }
} }
$ress = $ress?: 800 * STORAGE_MULTIPLIER; if ($ress == 0)
$crop = $crop?: 800 * STORAGE_MULTIPLIER; {
$dataStore[] = [$ress, $crop, $row['vref']]; $ress = 800 * STORAGE_MULTIPLIER;
} }
mysqli_begin_transaction($GLOBALS['link']) or die(mysqli_error($database->dblink)); if ($crop == 0)
$sql = 'UPDATE ' .TB_PREFIX. 'vdata SET maxstore = ?, maxcrop = ? WHERE `wref` = ?'; {
$stmt = mysqli_prepare($GLOBALS['link'], $sql); $crop = 800 * STORAGE_MULTIPLIER;
foreach ($dataStore as $data) { }
$stmt->bind_param('iii', $data[0], $data[1], $data[2]);
$stmt->execute() or die(mysqli_error($database->dblink)); mysqli_query($GLOBALS['link'],'UPDATE `' . TB_PREFIX . 'vdata` SET `maxstore` = ' . (int) $ress . ', `maxcrop` = ' . (int) $crop . ' WHERE `wref` = ' . (int) $row['vref']) or die(mysqli_error($database->dblink));
} }
mysqli_commit($GLOBALS['link']) or die(mysqli_error($database->dblink)); mysqli_commit($GLOBALS['link']) or die(mysqli_error($database->dblink));
} }