From 2e96486cc16c0e6817c926b12ccd99972138604f Mon Sep 17 00:00:00 2001 From: hecht Date: Wed, 20 Sep 2017 19:58:26 +0000 Subject: [PATCH] added fixes of live cronjobs --- cronjob/clan_fight_auswertung.php | 14 ++++++-------- cronjob/inclu/turnier.inc.php | 16 ++++++++-------- cronjob/training.php | 20 +++++++++++--------- cronjob/viertelstunde.php | 4 ++-- 4 files changed, 27 insertions(+), 27 deletions(-) diff --git a/cronjob/clan_fight_auswertung.php b/cronjob/clan_fight_auswertung.php index 0b80d54..93aaf46 100755 --- a/cronjob/clan_fight_auswertung.php +++ b/cronjob/clan_fight_auswertung.php @@ -18,17 +18,15 @@ function getClanRanking() { function distributeClanPrices(array $prices, array $results) { $n = min(count($prices), count($results)); - echo "Resultate"; + echo "Resultate: "; print_r($results); for($i = 0; $i<$n; $i++) { $points = $prices[$i]; - foreach($results[$i] as $winner) { - $clan = getClan($winner); // buffered so will not cause in a sql statement all the time! - $sql = 'UPDATE clan SET elo = 1000, geld = geld + ' . $points . ' WHERE id = ' . $clan['id']; - echo $sql . '
'; - db_query($sql); - insertClanTickerMessage($clan['id'], 'Das Preisgeld von '.$points.' für den '.$i.' Platz in der Clanliga erhalten!'); - } + $winner = $results[$i][0]; // second index is the elo value! + $clan = getClan($winner); // buffered so will not cause in a sql statement all the time! + $sql = 'UPDATE clan SET elo = 1000, geld = geld + ' . $points . ' WHERE id = ' . $clan['id']; + db_query($sql); + insertClanTickerMessage($clan['id'], 'Das Preisgeld von '.$points.' für den '.$i.' Platz in der Clanliga erhalten!'); } db_query('UPDATE clan SET elo = 1000'); } diff --git a/cronjob/inclu/turnier.inc.php b/cronjob/inclu/turnier.inc.php index 5575ee6..fcce615 100644 --- a/cronjob/inclu/turnier.inc.php +++ b/cronjob/inclu/turnier.inc.php @@ -25,7 +25,7 @@ function generateTournamentResults($name, $additionalExpPerRound, $additionalMon $charids = array(); // First calculate the money and exp the char gets just for doing good at fights ;) - $qry = db_query('select char1, char2, exp1, exp2, geld1, geld2, round from turnier_kampf where art = \''.$name.'\' order by round asc'); + $qry = silent_query('select char1, char2, exp1, exp2, geld1, geld2, round from turnier_kampf where art = \''.$name.'\' order by round asc'); while($fight = mysqli_fetch_assoc($qry)) { if(!isset($charArray[$fight['char1']])) { @@ -46,7 +46,7 @@ function generateTournamentResults($name, $additionalExpPerRound, $additionalMon $returnArray = array(); // Now calculate the money and exp the char gets just for proceeding in the tournament (in this case ... order the chars right away ;)) - $qry = db_query('Select count(win) as anzahl, win from turnier_kampf where art = \''.$name.'\' group by win order by count(win) desc'); + $qry = silent_query('Select count(win) as anzahl, win from turnier_kampf where art = \''.$name.'\' group by win order by count(win) desc'); $maxRank = -1; while ($participant = mysqli_fetch_assoc($qry)) { $charids[$participant['win']] = 0; // okay we already proceeded this one :) @@ -63,7 +63,7 @@ function generateTournamentResults($name, $additionalExpPerRound, $additionalMon $char = getChar($participant['win']); $sql = 'UPDATE user set geld = geld + ' . $charArray[$participant['win']]['money'] . ' WHERE id = ' . $char['besitzer']; echo $sql . '
'; - db_query($sql); + silent_query($sql); } foreach ($charids as $key => $value) { @@ -75,7 +75,7 @@ function generateTournamentResults($name, $additionalExpPerRound, $additionalMon $char = getChar($key); $sql = 'UPDATE user set geld = geld + ' . $charArray[$key]['money'] . ' WHERE id = ' . $char['besitzer']; echo $sql . '
'; - db_query($sql); + silent_query($sql); } } @@ -111,7 +111,7 @@ function distributeShopPoints(array $prices, array $winners, $reason) { $userid = $char['besitzer']; $sql = 'UPDATE user set pkt = pkt + '.$points.' WHERE id = '. $userid; echo $sql . '
'; - db_query($sql); + silent_query($sql); insertUserTickerMessage($userid, $points .' IP durch den '.generateRanglistString($i).' Platz im '.$reason.' erhalten!'); } } @@ -127,7 +127,7 @@ function distributeUserPrices(array $prices, array $winners, $reason) { $userid = $char['besitzer']; $sql = 'UPDATE user set geld = geld + '.$points.' WHERE id = '. $userid; echo $sql . '
'; - db_query($sql); + silent_query($sql); insertUserTickerMessage($userid, $points .' Preisgeld durch den '.generateRanglistString($i).' Platz im '.$reason.' erhalten!'); } } @@ -142,11 +142,11 @@ function distributeClanPrices(array $prices, array $results, $reason) { foreach($results[$i] as $winner) { $char = getChar($winner); // buffered so will not cause in a sql statement all the time! $userid = $char['besitzer']; - $data = mysqli_fetch_assoc(db_query('Select clan from user where id = ' .$userid )); + $data = mysqli_fetch_assoc(silent_query('Select clan from user where id = ' .$userid )); if(is_numeric($data['clan'])) { $sql = 'UPDATE clan SET geld = geld + ' . $points . ' WHERE id = ' . $data['clan']; echo $sql . '
'; - db_query($sql); + silent_query($sql); insertClanTickerMessage($row['clan'], 'Das Preisgeld von '.$points.' für den '.generateRanglistString($i).' Platz im '.$reason.' erhalten!'); } } diff --git a/cronjob/training.php b/cronjob/training.php index cda00a5..972398c 100644 --- a/cronjob/training.php +++ b/cronjob/training.php @@ -237,15 +237,17 @@ if (mysqli_num_rows($u_qry) != 0) { while ($row = mysqli_fetch_assoc($c_qry)) { $char[] = $char['id']; } - $chars = join(',', $char); - db_query('Delete from chars where id IN (' . $chars . ')'); - db_query('Delete from lernen where besitzer IN (' . $chars . ')'); - db_query('Delete from quests where charid IN (' . $chars . ')'); - db_query('Delete from quests_fights where charid IN (' . $chars . ')'); - db_query('Delete from quests_rounds where charid IN (' . $chars . ')'); - db_query('Delete from kampf where dbsatz IN (' . $chars . ')'); - db_query('Delete from kampf_list where charakter IN (' . $chars . ')'); - db_query('Delete from char_abholcodes where charid IN (' . $chars . ')'); + if ( count($char) > 0 ) { + $chars = join(',', $char); + db_query('Delete from chars where id IN (' . $chars . ')'); + db_query('Delete from lernen where besitzer IN (' . $chars . ')'); + db_query('Delete from quests where charid IN (' . $chars . ')'); + db_query('Delete from quests_fights where charid IN (' . $chars . ')'); + db_query('Delete from quests_rounds where charid IN (' . $chars . ')'); + db_query('Delete from kampf where dbsatz IN (' . $chars . ')'); + db_query('Delete from kampf_list where charakter IN (' . $chars . ')'); + db_query('Delete from char_abholcodes where charid IN (' . $chars . ')'); + } } diff --git a/cronjob/viertelstunde.php b/cronjob/viertelstunde.php index daacc7c..3e33b1e 100644 --- a/cronjob/viertelstunde.php +++ b/cronjob/viertelstunde.php @@ -130,7 +130,7 @@ function bearbeiteAbgelaufeneAuktion($auktionsid){ if($anzahl > 1000 && $anzahl % 1000 == 0) { echo date("H:i:s").' Anzahl maxi Auktion '.$anzahl."\n"; } - database_query('INSERT INTO '.$result['tablename'].' ('.$item_row_name.', user) VALUES('.$result['itemid'].','.$itemreceiver.')'); + silent_query('INSERT INTO '.$result['tablename'].' ('.$item_row_name.', user) VALUES('.$result['itemid'].','.$itemreceiver.')'); } database_query('DELETE FROM auktion WHERE auktionsid = '.$auktionsid); @@ -230,7 +230,7 @@ function detectMultiAccounts(){ while($tmp = mysqli_fetch_assoc($qry)){ $otime = min($tmp['o2'], $tmp['o1']); $sql = 'INSERT INTO multiuser(user1, user2, occured, type) values(\'' . $tmp['uid1'] . '\', \''.$tmp['uid2'].'\',\''.$otime.'\', \'IP_'.$tmp['ip1'].'\')'; - db_query($sql); + silent_query($sql); } }