From db79561dc190df6a2c8befb326471c84c3fc7ecd Mon Sep 17 00:00:00 2001 From: radiskull Date: Thu, 25 Aug 2011 21:29:56 +0000 Subject: [PATCH] =?UTF-8?q?Code=20S=C3=A4uberung=20Der=20Gewinner=20bekomm?= =?UTF-8?q?t=20die=20M=C3=B6glichkeit,=20seinen=20Account=20vor=20der=20au?= =?UTF-8?q?tomatischen=20L=C3=B6schung=20zu=20sch=C3=BCtzen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cronjob/gross_Turnier2.php | 111 ++++++++++++++++-------------- cronjob/include/usergroup.inc.php | 79 +++++++++++++++++++++ cronjob/training.php | 2 +- 3 files changed, 139 insertions(+), 53 deletions(-) create mode 100644 cronjob/include/usergroup.inc.php diff --git a/cronjob/gross_Turnier2.php b/cronjob/gross_Turnier2.php index 7798170..78cc776 100644 --- a/cronjob/gross_Turnier2.php +++ b/cronjob/gross_Turnier2.php @@ -10,6 +10,7 @@ include_once ('inclu/messagefunctions.inc.php'); include_once ('inclu/halloffame.inc.php'); include_once ('inclu/fruitdistribution.inc.php'); include_once ('inclu/exp.inc.php'); +include_once ('include/usergroup.inc.php'); $sql1 = 'select distinct(char1) from turnier_kampf where art = \'gross\' order by char1'; $sql2 = 'select distinct(char2) from turnier_kampf where art = \'gross\' order by char1'; @@ -37,67 +38,67 @@ i1.id AS i1id, i2.id AS i2id FROM turnier_kampf u LEFT JOIN chars c1 ON(c1.id=u. $x=0; while($row = mysql_fetch_array($row2)) { -$new_hp = explode(",",$row[hp1]); -$or_hp1 = explode(",",$row[c1hp]); -$new_hp2 = count($new_hp) - 1; + $new_hp = explode(",",$row['hp1']); + $or_hp1 = explode(",",$row['c1hp']); + $new_hp2 = count($new_hp) - 1; -$new_mp = explode(",",$row[mp1]); -$or_mp1 = explode(",",$row[c1mp]); -$new_mp2 = count($new_mp) - 1; + $new_mp = explode(",",$row['mp1']); + $or_mp1 = explode(",",$row['c1mp']); + $new_mp2 = count($new_mp) - 1; -$or_exp1 = explode(",",$row[c1exp]); -$new_exp = $or_exp1[0] + ($row[round] * 10000); -$add_exp1 = ($row[round] * 10000); + $or_exp1 = explode(",",$row['c1exp']); + $new_exp = $or_exp1[0] + ($row['round'] * 10000); + $add_exp1 = ($row['round'] * 10000); -$new_lernpunkte1 = $row[c1lern] + (($row[round] * $row[round] / 2)); -$new_lernpunkte2 = $row[c2lern] + (($row[round] * $row[round] / 2)); + $new_lernpunkte1 = $row['c1lern'] + (($row['round'] * $row['round'] / 2)); + $new_lernpunkte2 = $row['c2lern'] + (($row['round'] * $row['round'] / 2)); -$new_geld1 = $row[i1geld] + ($row[round] * 10000); -$new_geld2 = $row[i2geld] + ($row[round] * 10000); + $new_geld1 = $row['i1geld'] + ($row['round'] * 10000); + $new_geld2 = $row['i2geld'] + ($row['round'] * 10000); -$trainings_points1 = $row[round] * 2; -$trainings_points2 = $row[round] * 2; + $trainings_points1 = $row['round'] * 2; + $trainings_points2 = $row['round'] * 2; -if($row[round] == 9 AND $row[win] == $row[c1id]) { -$new_exp += 250000; -$add_exp1 += 250000; -$new_lernpunkte1 += 30; -$trainings_points1 += 50; -$new_geld1 += 2000000; -} + if($row['round'] == 9 AND $row['win'] == $row['c1id']) { + $new_exp += 250000; + $add_exp1 += 250000; + $new_lernpunkte1 += 30; + $trainings_points1 += 50; + $new_geld1 += 2000000; + } -$new_hp_2 = explode(",",$row[hp2]); -$or_hp1_2 = explode(",",$row[c2hp]); -$new_hp2_2 = count($new_hp_2) - 1; + $new_hp_2 = explode(",",$row['hp2']); + $or_hp1_2 = explode(",",$row['c2hp']); + $new_hp2_2 = count($new_hp_2) - 1; -$new_mp_2 = explode(",",$row[mp2]); -$or_mp1_2 = explode(",",$row[c2mp]); -$new_mp2_2 = count($new_mp_2) - 1; + $new_mp_2 = explode(",",$row['mp2']); + $or_mp1_2 = explode(",",$row['c2mp']); + $new_mp2_2 = count($new_mp_2) - 1; -$or_exp1_2 = explode(",",$row[c2exp]); -$new_exp_2 = $or_exp1_2[0] + ($row[round] * 3000); -$add_exp2 = ($row[round] * 10000); + $or_exp1_2 = explode(",",$row['c2exp']); + $new_exp_2 = $or_exp1_2[0] + ($row['round'] * 3000); + $add_exp2 = ($row['round'] * 10000); -if($row[round] == 9 AND $row[win] == $row[c2id]) { -$new_exp_2 += 250000; -$add_exp2 += 250000; -$new_lernpunkte2 += 30; -$trainings_points2 += 50; -$new_geld2 += 2000000; -} -$old_win = $row[win]; + if($row['round'] == 9 AND $row['win'] == $row['c2id']) { + $new_exp_2 += 250000; + $add_exp2 += 250000; + $new_lernpunkte2 += 30; + $trainings_points2 += 50; + $new_geld2 += 2000000; + } + $old_win = $row['win']; -//mysql_query("UPDATE chars SET training_points=training_points+'$trainings_points1', lernpunkte='$new_lernpunkte1', hp='$new_hp[$new_hp2],$or_hp1[1]', mp='$new_mp[$new_mp2],$or_mp1[1]', exp='$new_exp,$or_exp1[1]' WHERE id='$row[c1id]'"); -//mysql_query("UPDATE chars SET training_points=training_points+'$trainings_points2',lernpunkte='$new_lernpunkte2', hp='$new_hp_2[$new_hp2_2],$or_hp1_2[1]', mp='$new_mp_2[$new_mp2_2],$or_mp1_2[1]', exp='$new_exp_2,$or_exp1_2[1]' WHERE id='$row[c2id]'"); -//mysql_query("UPDATE chars SET exp='$new_exp,$or_exp1[1]' WHERE id='$row[c1id]'"); -//mysql_query("UPDATE chars SET exp='$new_exp_2,$or_exp1_2[1]' WHERE id='$row[c2id]'"); + //mysql_query("UPDATE chars SET training_points=training_points+'$trainings_points1', lernpunkte='$new_lernpunkte1', hp='$new_hp[$new_hp2],$or_hp1[1]', mp='$new_mp[$new_mp2],$or_mp1[1]', exp='$new_exp,$or_exp1[1]' WHERE id='$row[c1id]'"); + //mysql_query("UPDATE chars SET training_points=training_points+'$trainings_points2',lernpunkte='$new_lernpunkte2', hp='$new_hp_2[$new_hp2_2],$or_hp1_2[1]', mp='$new_mp_2[$new_mp2_2],$or_mp1_2[1]', exp='$new_exp_2,$or_exp1_2[1]' WHERE id='$row[c2id]'"); + //mysql_query("UPDATE chars SET exp='$new_exp,$or_exp1[1]' WHERE id='$row[c1id]'"); + //mysql_query("UPDATE chars SET exp='$new_exp_2,$or_exp1_2[1]' WHERE id='$row[c2id]'"); -addExpToChar($row['c1id'],$add_exp1); -addExpToChar($row['c2id'],$add_exp2); + addExpToChar($row['c1id'],$add_exp1); + addExpToChar($row['c2id'],$add_exp2); -mysql_query("UPDATE user SET geld='$new_geld1' WHERE id='$row[i1id]' LIMIT 1"); -mysql_query("UPDATE user SET geld='$new_geld2' WHERE id='$row[i2id]' LIMIT 1"); + mysql_query("UPDATE user SET geld='$new_geld1' WHERE id='$row[i1id]' LIMIT 1"); + mysql_query("UPDATE user SET geld='$new_geld2' WHERE id='$row[i2id]' LIMIT 1"); } @@ -108,12 +109,18 @@ mysql_query("UPDATE online SET turnier_gross='$win_online[turnier_gross],$win_us // insertIntoHallOfFame($title, $charid, $userid); insertIntoHallOfFame('Weltturnier', $old_win, $win_user['besitzer']); -$natur_frucht = mysql_num_rows(mysql_query("SELECT id FROM wochen_markt WHERE art='natur'")); ///wieviel TF gibt es?. +//$natur_frucht = mysql_num_rows(mysql_query("SELECT id FROM wochen_markt WHERE art='natur'")); ///wieviel TF gibt es?. ////////////////FRUCHT ARRAY //include "array.php"; distributeFruit($win_user['besitzer']); +//Schutz vor automatischem löschen hinzufügen für den sieger :) +$usergroups = getUserGroups($win_user['besitzer']); +if(!isUserInGroup($usergroups, inaktiv_loeschschutz) && !isUserInGroup($usergroups, aktiv_loeschschutz)) { + addUserToGroup($win_user['besitzer'], inaktiv_loeschschutz); +} + // Durchschnittslevel $sql5 = 'Select count(win), win from turnier_kampf where art = \'gross\' group by win order by count(win) desc'; @@ -141,7 +148,7 @@ $rang16 = mysql_fetch_assoc($qry5); $summe = 20000000/(1+exp(5-$dlevel/14)); - + $sql = 'select u.clan, c.id, u.id as userid from chars c inner join user u on c.besitzer = u.id where c.id IN ('.$rang1['win'].','.$rang2['win'].','.$rang3['win'].','.$rang4['win'].','.$rang5['win'].','.$rang6['win'].','.$rang7['win'].','.$rang8['win'].','.$rang9['win'].','.$rang10['win'].','.$rang11['win'].','.$rang12['win'].','.$rang13['win'].','.$rang14['win'].','.$rang15['win'].','.$rang16['win'].')'; echo $sql.'
'; @@ -174,14 +181,14 @@ while($row = mysql_fetch_assoc($qry)){ insertClanTickerMessage($row['clan'], 'Das Preisgeld von '.ceil($summe/8).' für den 3-4. Platz im Welttunier erhalten!'); insertUserTickerMessage($row['userid'], '75 IP von Welttunier 3. oder 4. Platz erhalten!'); break; - case $rang5['win']: + case $rang5['win']: case $rang6['win']: case $rang7['win']: case $rang8['win']: mysql_query('UPDATE user set pkt = pkt + 50 WHERE id = '.$row['userid']); insertUserTickerMessage($row['userid'], '50 IP von Welttunier 5-8. Platz erhalten!'); break; - + case $rang9['win']: case $rang10['win']: case $rang11['win']: @@ -193,7 +200,7 @@ while($row = mysql_fetch_assoc($qry)){ mysql_query('UPDATE user set pkt = pkt + 25 WHERE id = '.$row['userid']); insertUserTickerMessage($row['userid'], '25 IP von Welttunier 9-16. Platz erhalten!'); break; - + default: break; } diff --git a/cronjob/include/usergroup.inc.php b/cronjob/include/usergroup.inc.php new file mode 100644 index 0000000..e3c0c81 --- /dev/null +++ b/cronjob/include/usergroup.inc.php @@ -0,0 +1,79 @@ + $result['gruppen_id'], "gruppen_name" => $result['gruppen_name']); + $i++; + } + + return $groups; +} + +function isUserInGroup($usergrouparray, $group) { + for($i = 0; $i < count($usergrouparray); $i++) { + if($usergrouparray[$i]['gruppen_id'] == $group) { + return true; + } + } + return false; +} + +function removeUserFromGroup($user, $group) { + if($user !== NULL) { + if ($group !== NULL && $group >= 0) { + $qry = 'DELETE FROM user_gruppe_zuordnung WHERE user_id in (SELECT id FROM user WHERE nickname = \''.$user. + '\') AND gruppen_id = '.$group.';'; + mysql_query($qry); + return true; + } + } + return false; +} + +function addUserToGroup($user, $group) { + if($user !== NULL) { + if ($group !== NULL && $group >= 0) { + $qry = 'INSERT INTO user_gruppe_zuordnung(user_id, gruppen_id) + VALUES((SELECT id FROM user WHERE nickname = \''.$user.'\'), '.$group.');'; + mysql_query($qry); + return true; + } + } + return false; +} +?> \ No newline at end of file diff --git a/cronjob/training.php b/cronjob/training.php index 38ecfba..4d9ddaf 100644 --- a/cronjob/training.php +++ b/cronjob/training.php @@ -187,7 +187,7 @@ mysql_query('DELETE FROM user_activation where TIMESTAMPDIFF(day, registerdate, mysql_query('DELETE FROM anon_chatter WHERE TIMESTAMPDIFF(day, online, now()) > 35'); // 5 Wochen // Loesche inaktive user! -$sql = 'Select * from user where TIMESTAMPDIFF(week, online_zeit, now()) > 10 and id > 2'; +$sql = 'Select * from user where TIMESTAMPDIFF(week, online_zeit, now()) > 10 and id > 2 and id not in (SELECT user_id FROM user_gruppe_zuordnung WHERE gruppen_id = 7 AND user_id = id)'; //echo $sql;