Удалён нигде не применявшийся крон.
This commit is contained in:
parent
9819971e7e
commit
905f017be6
1022
cronjobs/cron2.php
1022
cronjobs/cron2.php
File diff suppressed because it is too large
Load Diff
File diff suppressed because one or more lines are too long
@ -1,225 +0,0 @@
|
|||||||
<?php
|
|
||||||
#include('config.php');
|
|
||||||
#include('functions.php');
|
|
||||||
/*
|
|
||||||
$zay = mysql_query('SELECT * FROM `zayavka`');
|
|
||||||
while($z = mysql_fetch_array($zay)) {
|
|
||||||
if($z['start'] <= time()) {
|
|
||||||
if($z['level'] == 4 || (($z['t1c'] == count($z['team1'])) && ($z['t2c'] == count($z['team2'])))) {
|
|
||||||
startbattle("CHAOS", $z['id'], 4);
|
|
||||||
} elseif($z['level'] == 5) {
|
|
||||||
startbattle("CHAOS", $z['id'], 5);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function delzayavka($id, $zay, $r, $f = 1) {
|
|
||||||
$z = getlist($r, null, $zay);
|
|
||||||
if($f != 1) {
|
|
||||||
if($z[$zay]['level'] > 3) {
|
|
||||||
return 'Ай-ай-ай!';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(mysql_query("DELETE FROM `zayavka` WHERE `id` = {$zay} AND (`team1` LIKE '{$id};%' OR `team2` LIKE '{$id};%') LIMIT 1")) {
|
|
||||||
if(count($z[$zay]['team1']) > 0) {
|
|
||||||
foreach($z[$zay]['team1'] as $k => $v) {
|
|
||||||
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `id` = {$v}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($z[$zay]['team2']) > 0) {
|
|
||||||
foreach($z[$zay]['team2'] as $k => $v) {
|
|
||||||
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `id` = {$v}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 'Вы отозвали заявку.';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function fteam($team) {
|
|
||||||
$team = explode(";", $team);
|
|
||||||
unset($team[count($team)-1]);
|
|
||||||
return $team;
|
|
||||||
}
|
|
||||||
|
|
||||||
function getlist($razdel = 1, $level = null, $id = null ) {
|
|
||||||
$fict = mysql_query("SELECT * FROM `zayavka` WHERE ".(($level != null)? " ((`t1min` <= '{$level}' OR `t1min` = '99') AND (`t1max` >= '{$level}' OR `t1max` = '99') ".(($razdel == 4)?"AND (`t2min` <= '{$level}' OR `t2min` = '99') AND (`t2max` >= '{$level}' OR `t2max` = '99')":"").") AND " : "")." `level` = {$razdel} ".(($id != null)? " AND `id` = {$id} " : "")." ORDER BY `podan` DESC");
|
|
||||||
while($row = mysql_fetch_array($fict)) {
|
|
||||||
if(($row['start']+300) < time()) {
|
|
||||||
if(mysql_query("DELETE FROM `zayavka` WHERE `id` = '{$row['id']}' LIMIT 1")) {
|
|
||||||
$team1 = fteam($row['team1']);
|
|
||||||
foreach($team1 as $k => $v) {
|
|
||||||
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `id` = {$v}");
|
|
||||||
}
|
|
||||||
$team2 = fteam($row['team2']);
|
|
||||||
foreach($z[$zay]['team2'] as $k => $v) {
|
|
||||||
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `id` = {$v}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$zay[$row['id']] = array("team1" => fteam($row['team1']), "team2" => fteam($row['team2']), "coment" => $row['coment'], "type" => $row['type'], "timeout" => $row['timeout'], "start" => $row['start'], "t1min" => $row['t1min'], "t1max" => $row['t1max'], "t2min" => $row['t2min'], "t2max" => $row['t2max'], "t1c" => $row['t1c'], "t2c" => $row['t2c'], "podan" => $row['podan'], "id" => $row['id'], "level" => $row['level'], "blood" => $row['blood'], "bots" => $row['bots']);
|
|
||||||
}
|
|
||||||
return $zay;
|
|
||||||
}
|
|
||||||
|
|
||||||
function startbattle($id, $zay, $r) {
|
|
||||||
$z = getlist($r, null, $zay);
|
|
||||||
if($id == 'CHAOS') { $id = $z[$zay]['team1'][0]; }
|
|
||||||
delzayavka($id, $zay, $r);
|
|
||||||
$z = $z[$zay];
|
|
||||||
$count_users = count($z['team1']);
|
|
||||||
|
|
||||||
$bot = 0;
|
|
||||||
if($z['bots'] > 0) {
|
|
||||||
$bots_raw = array(7 => array(10962, 10964, 10965), 8 => array());
|
|
||||||
$i = 0;
|
|
||||||
while($i <= count($bots_raw[$z['bots']])) {
|
|
||||||
$bot_id = $bots_raw[$z['bots']][$i];
|
|
||||||
$bot = createbot($bot_id, '');
|
|
||||||
$z['team1'][] = $bot['id'];
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
$count_users += 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($z['type'] == 4 || $z['type'] == 5) {
|
|
||||||
foreach($z['team1'] as $k => $v) {
|
|
||||||
undressall($v);
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($z['team2'] as $k => $v) {
|
|
||||||
undressall($v);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if($z['type'] == 3 || $z['type'] == 5) {
|
|
||||||
if($count_users < 4) {
|
|
||||||
mysql_query("UPDATE `users` SET `zayavka` = '0' WHERE `zayavka` = '".$zay."'");
|
|
||||||
foreach($z['team1'] as $k => $v) {
|
|
||||||
if($v < _BOTSEPARATOR_) {
|
|
||||||
addchp('<font color=red>Внимание!</font> Ваш бой не может начаться по причине <b>Группа не набрана</b>.', '{[]}'.nick7($v).'{[]}');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
mysql_query("UPDATE `variables` SET `value` = '{$count_users}}' WHERE `var` = 'haos_match' LIMIT 1");
|
|
||||||
mysql_query("DELETE FROM `zayavka` WHERE `id` = '".$zay."' LIMIT 1");
|
|
||||||
}
|
|
||||||
|
|
||||||
$all = count($z['team1'])-1;
|
|
||||||
$power1 = 0; $power2 = 0;
|
|
||||||
|
|
||||||
for($i = 0; $i <= $all; $i++) {
|
|
||||||
if($z['team1'][$i] < _BOTSEPARATOR_) {
|
|
||||||
$gamer = mysql_fetch_array(mysql_query("SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = '".$z['team1'][$i]."' LIMIT 1"));
|
|
||||||
} else {
|
|
||||||
$bt = mysql_fetch_array(mysql_query('SELECT `id`, `prototype` FROM `bots` WHERE `id` = "'.$z['team1'][$i].'"'));
|
|
||||||
$gamer = mysql_fetch_array(mysql_query("SELECT (`level`*50)+`sila`+`lovk`+`inta`+`vinos`+`intel`+`stats`+IFNULL((SELECT SUM(`cost`) FROM `inventory` WHERE `owner` = `users`.`id` AND `dressed` = 1), 0) FROM `users` WHERE `id` = '".$bt['prototype']."' LIMIT 1"));
|
|
||||||
}
|
|
||||||
|
|
||||||
$cost[] = array($z['team1'][$i], $gamer[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
$z['team1'] = null;
|
|
||||||
$z['team2'] = null;
|
|
||||||
|
|
||||||
$flag = true;
|
|
||||||
while($flag) {
|
|
||||||
$flag = false;
|
|
||||||
for($ii = 0; $ii <= $all-1; $ii++) {
|
|
||||||
if($cost[$ii][1] < $cost[$ii+1][1]) {
|
|
||||||
$ctr = $cost[$ii+1];
|
|
||||||
$cost[$ii+1] = $cost[$ii];
|
|
||||||
$cost[$ii] = $ctr;
|
|
||||||
$flag = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
while(count($cost) > 0) {
|
|
||||||
if($power1 <= $power2) {
|
|
||||||
$tmp = array_shift($cost);
|
|
||||||
$power1 += $tmp[1];
|
|
||||||
$z['team1'][] = $tmp[0];
|
|
||||||
} else {
|
|
||||||
$tmp = array_shift($cost);
|
|
||||||
$power2 += $tmp[1];
|
|
||||||
$z['team2'][] = $tmp[0];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$teams = array();
|
|
||||||
|
|
||||||
foreach($z['team1'] as $k => $v) {
|
|
||||||
foreach($z['team2'] as $kk => $vv) {
|
|
||||||
$teams[$v][$vv] = array(0, 0, time());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($z['team2'] as $k => $v) {
|
|
||||||
foreach($z['team1'] as $kk => $vv) {
|
|
||||||
$teams[$v][$vv] = array(0, 0, time());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if(count($z['team2']) == 0) {
|
|
||||||
mysql_query("UPDATE `users` SET `zayavka` = 0 WHERE `zayavka` = '".$zay."'");
|
|
||||||
foreach($z['team1'] as $k => $v) {
|
|
||||||
addchp('<font color=red>Внимание!</font> Ваш бой не может начаться по причине "Группа не набрана".', '{[]}'.nick7($v).'{[]}');
|
|
||||||
}
|
|
||||||
mysql_query("DELETE FROM `zayavka` WHERE `id` = '".$zay."' LIMIT 1");
|
|
||||||
die();
|
|
||||||
}
|
|
||||||
|
|
||||||
$arr = array(3, 4, 5, 7, 10);
|
|
||||||
|
|
||||||
if(in_array($z['timeout'], $arr)) {
|
|
||||||
|
|
||||||
} else {
|
|
||||||
$z['timeout'] = 3;
|
|
||||||
}
|
|
||||||
|
|
||||||
if($z['type'] == 1 || $z['type'] == 4) {
|
|
||||||
$rs = ', `fiz`'; $rss = ', 1';
|
|
||||||
} else {
|
|
||||||
$rs = ''; $rss = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
mysql_query("INSERT INTO `battle` (`coment`, `teams`, `timeout`, `type`, `status`, `t1`, `t2`, `to1`, `to2`, `blood`$rs, `bots`) VALUES ('{$z['coment']}', '".serialize($teams)."', '{$z['timeout']}', '{$z['type']}', '0', '".implode(";", $z['team1'])."', '".implode(";", $z['team2'])."', '".time()."', '".time()."', '".$z['blood']."'$rss, '".$z['bots']."')");
|
|
||||||
$id = mysql_insert_id();
|
|
||||||
$rr = "<b>";
|
|
||||||
|
|
||||||
foreach($z['team1'] as $k => $v) {
|
|
||||||
if($k != 0) { $rr .= ", "; }
|
|
||||||
$rr .= nick3($v);
|
|
||||||
addchp('<font color=red>Внимание!</font> Ваш бой начался!<br />\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}'.nick7($v).'{[]}');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rr .= "</b> и <b>";
|
|
||||||
|
|
||||||
foreach($z['team2'] as $k => $v) {
|
|
||||||
if($k != 0) { $rr .= ", "; }
|
|
||||||
$rr .= nick3($v);
|
|
||||||
addchp('<font color=red>Внимание!</font> Ваш бой начался!<br />\'; top.frames[\'main\'].location=\'fbattle.php\'; var z = \' ', '{[]}'.nick7($v).'{[]}');
|
|
||||||
}
|
|
||||||
|
|
||||||
$rr .= "</b>";
|
|
||||||
addlog($id, "Часы показывали <span class=date>".date("Y.m.d H.i")."</span>, когда ".$rr." бросили вызов друг другу.<BR>");
|
|
||||||
|
|
||||||
foreach($z['team1'] as $k => $v) {
|
|
||||||
if($v < _BOTSEPARATOR_) {
|
|
||||||
mysql_query("UPDATE `users` SET `battle` = {$id}, `zayavka` = 0 WHERE `id` = {$v}");
|
|
||||||
} else {
|
|
||||||
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$v}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach($z['team2'] as $k => $v) {
|
|
||||||
if($v < _BOTSEPARATOR_) {
|
|
||||||
mysql_query("UPDATE `users` SET `battle` = {$id}, `zayavka` = 0 WHERE `id` = {$v}");
|
|
||||||
} else {
|
|
||||||
mysql_query("UPDATE `bots` SET `battle` = {$id} WHERE `id` = {$v}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
Loading…
Reference in New Issue
Block a user