You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
234 lines
11 KiB
234 lines
11 KiB
<?php
|
|
/*
|
|
*
|
|
* @copyright (c) 2010 animegame.eu
|
|
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public Licence
|
|
*
|
|
*/
|
|
|
|
$test = date("H");
|
|
include_once('path.inc.php'); // get the path ;)
|
|
include "db.php";
|
|
include_once ('inclu/messagefunctions.inc.php');
|
|
include_once (ROOT_PATH.'/include/usergroup.inc.php');
|
|
|
|
if ($test == "02") {
|
|
$i = 0;
|
|
}
|
|
if ($test == "04") {
|
|
$i = 1;
|
|
}
|
|
if ($test == "06") {
|
|
$i = 2;
|
|
}
|
|
if ($test == "08") {
|
|
$i = 3;
|
|
}
|
|
if ($test == "10") {
|
|
$i = 4;
|
|
}
|
|
if ($test == "12") {
|
|
//Jeden Tag gibts es was für Wanted
|
|
// $rangliste1 = mysql_query("SELECT besitzer, name, preis FROM chars order by preis");
|
|
// while($row = mysql_fetch_array($rangliste1)) {
|
|
// insertUserTickerMessage($row['besitzer'], ' '.$row['preis'].' Geld durch deinen Wanted erhalten');
|
|
// mysql_query("UPDATE user SET geld= geld + '$row[preis]' WHERE id='$row[besitzer]'");
|
|
// if ($row['preis']>10000){
|
|
// $IP = $row['preis']/1000;
|
|
// mysql_query("UPDATE user SET pkt= pkt + '$IP' WHERE id='$row[besitzer]'");
|
|
// insertUserTickerMessage($row['besitzer'], ' '.$IP.' IP durch deinen Wanted erhalten, da du eine Grenze überschritten hast');
|
|
// }
|
|
// }
|
|
$i = 5;
|
|
}
|
|
if ($test == "14") {
|
|
$i = 6;
|
|
}
|
|
if ($test == "16") {
|
|
$i = 7;
|
|
}
|
|
if ($test == "18") {
|
|
$i = 8;
|
|
}
|
|
if ($test == "20") {
|
|
$i = 9;
|
|
}
|
|
if ($test == "22") {
|
|
$i = 10;
|
|
}
|
|
if ($test == "00" || $_GET['midnight'] == 1) {
|
|
$i = 11;
|
|
}
|
|
|
|
########################CLAN ITEMS BENUTZEN
|
|
if ($i == 11) {
|
|
// Erstmal Arena (auch wenns nix mit Training zu tun hat)
|
|
// select round(einnahmen*0.5/(1+EXP(2-einnahmen/100000))) from arena where einnahmen > 10000
|
|
|
|
// Kann erstmal bleiben!
|
|
mysql_query('Update arena set zustand = zustand - 1/4 where mietlasten >= 2 and einnahmen > 0');
|
|
mysql_query('Update arena set zustand = 0 where zustand < 0'); // No negatives any more
|
|
$freibetrag = 300000;
|
|
$steuersatz_start = 25;
|
|
$faktor_level = 3;
|
|
$faktor_finanz = 2;
|
|
$sql = 'Update arena set mietlasten = mietlasten + 1, steuerlasten = steuerlasten + ceil((einnahmen - '.$freibetrag.') * (('.$steuersatz_start.' + level * '.$faktor_level.' -hausmeister * '.$faktor_finanz.')/100)) where ceil((einnahmen - '.$freibetrag.') * (('.$steuersatz_start.' + level * '.$faktor_level.' -hausmeister * '.$faktor_finanz.')/100)) > 0';
|
|
// echo $sql.'<br>';
|
|
mysql_query($sql);
|
|
|
|
mysql_query('Update arena set einnahmen = 0');
|
|
|
|
// Inaktive Clans löschen (Clanräume werden automatisch gelöscht durch Fremdschlüssel)
|
|
$sql = 'delete from clan where id NOT IN(SELECT distinct(clan) from user where clan is not null)';
|
|
//echo $sql . '<br>';
|
|
mysql_query($sql);
|
|
// Räume die Ticker auf (Massivster Datenmüll!!)
|
|
mysql_query('DELETE FROM clan_ticker WHERE date < TIMESTAMPADD(day, -7, now())');
|
|
mysql_query('DELETE FROM user_ticker WHERE date < TIMESTAMPADD(day, -7, now())');
|
|
|
|
// Benutze Clan items!!
|
|
// Folgende SQL-Anweisung ermittelt mit einer kleinen Hilfsfunktion die Summe der Miete und das Geld des Clans
|
|
$mindestchar = 12; // War vorher 40;
|
|
$sql = 'SELECT cw.id as clan_train, if(count(ch.id)<'.$mindestchar.','.$mindestchar.',count(ch.id)) * miete as mietkosten, c.id as clan, c.geld as geld from clan_ware cw inner join clan_item ci on cw.item_id = ci.id inner join clan c on cw.clan = c.id inner join user u on u.clan = c.id left join chars ch on ch.clan_train = cw.id and ch.besitzer = u.id group by c.id, cw.id order by c.id';
|
|
// SQL-Anweisung, wenn Ungenutzte items nicht beruecksichtigt werden sollen -> 'SELECT ch.clan_train, if(count(ch.id)<40,40,count(ch.id)) * miete as mietkosten, c.id as clan, c.geld as geld from user u inner join clan c on u.clan = c.id inner join chars ch on u.id = ch.besitzer inner join clan_ware cw on cw.clan = c.id inner join clan_item ci on cw.item_id = ci.id and ch.clan_train = cw.id group by c.id, cw.id order by c.id'
|
|
// echo '<br>'.$sql.'<br>';
|
|
$clan_kosten = mysql_query($sql);
|
|
|
|
$clan_raum_array = array();
|
|
while ($row = mysql_fetch_assoc($clan_kosten)){
|
|
if($clan_raum_array[$row['clan']] === null){
|
|
$clan_raum_array[$row['clan']] = $row;
|
|
} else{
|
|
$clan_raum_array[$row['clan']]['mietkosten'] += $row['mietkosten'];
|
|
}
|
|
}
|
|
|
|
$clans = array ();
|
|
// while ($row = mysql_fetch_assoc($clan_kosten)) {
|
|
foreach($clan_raum_array as $row){
|
|
// print_r($row);
|
|
// Ermittle das Vermoegen und die Useranzahl des Clans!
|
|
if ($row['mietkosten'] > $row['geld']) {
|
|
// Clan is pleite!
|
|
// echo 'Clan '.$row['clan'].' is Pleite!';
|
|
insertClanTickerMessage($row['clan'], 'Die Miete für die Räume ('.displayMoney($row['mietkosten']).') konnte nicht bezahlt werden!');
|
|
} else {
|
|
// Clan kann miete bezahlen, also in Trainingsliste aufnehmen
|
|
$clans[] = $row['clan'];
|
|
// Clan die Miete abziehen
|
|
mysql_query('UPDATE clan SET geld = geld - ' . $row['mietkosten'] . ' WHERE id = ' . $row['clan']);
|
|
insertClanTickerMessage($row['clan'], 'Die Miete für die Räume ('.displayMoney($row['mietkosten']).') wurde bezahlt!');
|
|
}
|
|
}
|
|
// Ermittle die Kosten fuer die Nutzer (es werden nur Chars beruecksichtigt, die genug TP haben)
|
|
$sql = 'select besitzer, user.geld, sum(1/(1+exp(3-level/12)) * nutzung) as nutzkosten from user inner join chars on chars.besitzer = user.id inner join clan_ware on chars.clan_train = clan_ware.id inner join clan_item on clan_ware.item_id = clan_item.id where user.clan = clan_ware.clan and user.clan IN (' . join(',', $clans) . ') and clan_item.tp <= chars.training_points group by besitzer order by besitzer';
|
|
$user_kosten = mysql_query($sql);
|
|
// echo '<br>'.$sql.'<br>';
|
|
$users = array ();
|
|
if (count($clans) != 0) {
|
|
while ($row = mysql_fetch_assoc($user_kosten)) {
|
|
if ($row['nutzkosten'] > $row['geld']) {
|
|
// User is pleite!
|
|
insertUserTickerMessage($row['besitzer'], 'Die Nutzungsgebühren ('.displayMoney($row['nutzkosten']).') für die Räume konnte nicht bezahlt werden!');
|
|
} else {
|
|
// User kann Nutzkosten bezahlen, also in Trainingsliste aufnehmen
|
|
$users[] = $row['besitzer'];
|
|
// Clan die Miete abziehen
|
|
mysql_query('UPDATE user SET geld = geld - ' . $row['nutzkosten'] . ' WHERE id = ' . $row['besitzer']);
|
|
insertUserTickerMessage($row['besitzer'], 'Die Nutzungsgebühren ('.displayMoney($row['nutzkosten']).') für die Räume wurde bezahlt!');
|
|
}
|
|
}
|
|
|
|
$sql = 'Update chars inner join user on chars.besitzer = user.id inner join clan_ware on chars.clan_train = clan_ware.id inner join clan_item on clan_ware.item_id = clan_item.id SET chars.starke = clan_item.staerke + chars.starke, chars.speed = chars.speed + clan_item.geschwindigkeit, chars.verteidigung = chars.verteidigung + clan_item.verteidigung, chars.glueck = chars.glueck + clan_item.glueck, chars.ausdauer = chars.ausdauer + clan_item.ausdauer, chars.training_points = chars.training_points - clan_item.tp WHERE user.clan = clan_ware.clan and chars.besitzer IN(' . join(',', $users) . ') and chars.training_points >= clan_item.tp';
|
|
$check = mysql_query($sql);
|
|
|
|
}
|
|
// echo '<br>'.$sql.'<br>';
|
|
}
|
|
#########################EXIT
|
|
|
|
$char_info = mysql_query("SELECT training_points, id, training, starke, verteidigung, speed, ausdauer, glueck, mp, hp, level FROM chars");
|
|
$x = 0;
|
|
while ($row = mysql_fetch_array($char_info)) {
|
|
$hp = explode(",", $row['hp']);
|
|
$mp = explode(",", $row['mp']);
|
|
$trains = explode(",", $row['training']);
|
|
if (!$trains[$i] || $trains[$i] == 'ausruhen') {
|
|
mysql_query("UPDATE chars SET hp='$hp[1],$hp[1]', mp='$mp[1],$mp[1]' WHERE id='$row[id]' LIMIT 1");
|
|
} else {
|
|
|
|
if ($row[training_points] > 1) {
|
|
if ($trains[$i] == 'hp' OR $trains[$i] == 'mp') {
|
|
if ($trains[$i] == hp) {
|
|
$zu[$x] = $hp[1] + 20;
|
|
$zu[$x] = "$hp[0],$zu[$x]";
|
|
} else if ($trains[$i] == 'mp') {
|
|
$zu[$x] = $mp[1] + 10;
|
|
$zu[$x] = "$mp[0],$zu[$x]";
|
|
}
|
|
// echo "UPDATE chars SET $trains[$i]='$zu[$x]', training_points=training_points-2 WHERE id='$row[id]' LIMIT 1<br>";
|
|
mysql_query("UPDATE chars SET $trains[$i]='$zu[$x]', training_points=training_points-4 WHERE id='$row[id]' LIMIT 1");
|
|
} else {
|
|
$event = mysql_fetch_assoc(mysql_query('SELECT CURRENT_TIMESTAMP between TIMESTAMP(\'2009-04-25 00:00:00\') and TIMESTAMP(\'2009-05-02 23:59:59\') as betw'));
|
|
$step = 2 + ($event['betw']*3);
|
|
$news2 = $trains[$i];
|
|
$news[$x] = $row[$news2] + $step;
|
|
$step*=2;
|
|
$sql = "UPDATE chars SET $news2='$news[$x]', training_points=training_points-$step WHERE id='$row[id]' LIMIT 1";
|
|
// echo $sql.'<br>'."\n";
|
|
mysql_query($sql);
|
|
}
|
|
|
|
}
|
|
}
|
|
$x++;
|
|
}
|
|
|
|
mysql_query('DELETE FROM ag_chat where TIMESTAMPDIFF(Hour,zeit,now()) > 48');
|
|
mysql_query('DELETE FROM user_activation where TIMESTAMPDIFF(day, registerdate, now()) > 7');
|
|
// Loesche inaktive anons :)
|
|
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 and id not in (SELECT user_id FROM user_gruppe_zuordnung WHERE gruppen_id = '.AKTIV_LOESCHSCHUTZ.' AND user_id = id)';
|
|
|
|
|
|
//echo $sql;
|
|
$u_qry = mysql_query($sql);
|
|
if (mysql_num_rows($u_qry) != 0) {
|
|
$user = array ();
|
|
while ($row = mysql_fetch_assoc($u_qry)) {
|
|
$user[] = $row['id'];
|
|
}
|
|
$users = join(',', $user);
|
|
// echo 'Delete inactive Users ' . $users . '<br>';
|
|
mysql_query('Delete from user where id in (' . $users . ')');
|
|
mysql_query('Delete from arena where besitzer in (' . $users . ')');
|
|
mysql_query('Delete from ware where user in (' . $users . ')');
|
|
mysql_query('Delete from npc_ware where user in (' . $users . ')');
|
|
mysql_query('Delete from sp_ware where user in (' . $users . ')');
|
|
mysql_query('Delete from wochen_ware where user in (' . $users . ')');
|
|
mysql_query('Delete from user_ticker where userid in (' . $users . ')');
|
|
mysql_query('Delete from user_rename where userid in (' . $users . ')');
|
|
mysql_query('Delete from user_clan where userid in (' . $users . ')');
|
|
mysql_query('Delete from nachricht where besitzer in (' . $users . ')');
|
|
mysql_query('Delete from ignolist where user in (' . $users . ') or besitzer in (' . $users . ')');
|
|
|
|
$char = array ();
|
|
$c_qry = mysql_query('Select id from chars where besitzer IN (' . $users . ')');
|
|
while ($row = mysql_fetch_assoc($c_qry)) {
|
|
$char[] = $char['id'];
|
|
}
|
|
$chars = join(',', $char);
|
|
mysql_query('Delete from chars where id IN (' . $chars . ')');
|
|
mysql_query('Delete from lernen where besitzer IN (' . $chars . ')');
|
|
mysql_query('Delete from quests where charid IN (' . $chars . ')');
|
|
mysql_query('Delete from quests_fights where charid IN (' . $chars . ')');
|
|
mysql_query('Delete from quests_rounds where charid IN (' . $chars . ')');
|
|
mysql_query('Delete from kampf where dbsatz IN (' . $chars . ')');
|
|
mysql_query('Delete from kampf_list where charakter IN (' . $chars . ')');
|
|
mysql_query('Delete from char_abholcodes where charid IN (' . $chars . ')');
|
|
}
|
|
|
|
|