game/cron_turnir.php

86 lines
2.8 KiB
PHP

<?php
function getIP()
{
return isset($_SERVER['HTTP_X_REAL_IP']) ? $_SERVER['HTTP_X_REAL_IP'] : $_SERVER['REMOTE_ADDR'];
}
if (!isset($_GET['test']) && getIP() != $_SERVER['SERVER_ADDR'] && getIP() != '127.0.0.1' && getIP() != '' && getIP(
) != '31.131.97.206') {
die(getIP() . '<br>' . $_SERVER['SERVER_ADDR']);
}
const GAME = true;
setlocale(LC_CTYPE, "ru_RU.CP1251");
include('_incl_data/__config.php');
include('_incl_data/class/__db_connect.php');
$u = User::start();
//
$sp = mysql_query('SELECT * FROM `battle` WHERE `otmorozok` = 1 AND `team_win` = -1 AND `otmorozok_use` = 0');
while ($pl = mysql_fetch_array($sp)) {
if (rand(0, 100) < 11) {
//
mysql_query('UPDATE `battle` SET `otmorozok_use` = 1 WHERE `id` = "' . $pl['id'] . '" LIMIT 1');
//
$usr = mysql_fetch_array(
mysql_query(
'SELECT `level`,`city` FROM `users` WHERE `battle` = "' . $pl['id'] . '" ORDER BY `level` DESC LIMIT 1'
)
);
$bot = mysql_fetch_array(
mysql_query('SELECT * FROM `test_bot` WHERE `login` LIKE "%Îòìîðîçîê [%' . $usr['level'] . '%]%" LIMIT 1')
);
//
$tmr = rand(1, 2);
//
$logins_bot = [];
$bot = $u->addNewbot($bot['id'], null, null, $logins_bot, null);
$otmz = mysql_fetch_array(
mysql_query(
'SELECT COUNT(*) FROM `users` WHERE `login` LIKE "%Îòìîðîçîê (%" AND `battle` = "' . $pl['id'] . '" LIMIT 1'
)
);
//
$otmz[0]++;
//
mysql_query(
'UPDATE `users` SET `city` = "' . $usr['city'] . '",`login` = "Îòìîðîçîê (' . $otmz[0] . ')",`battle` = "' . $pl['id'] . '" WHERE `id` = "' . $bot['id'] . '" LIMIT 1'
);
//
mysql_query('UPDATE `stats` SET `team` = "' . $tmr . '" WHERE `id` = "' . $bot['id'] . '" LIMIT 1');
//
$vtvl = '{tm1} {u1} âìåøàëñÿ â ïîåäèíîê. Õî! õî! õî!';
$last_hod = mysql_fetch_array(
mysql_query(
'SELECT `id_hod` FROM `battle_logs` WHERE `battle` = "' . $pl['id'] . '" ORDER BY `id_hod` DESC LIMIT 1'
)
);
$last_hod = $last_hod['id_hod'];
//
$mass = [
'time' => time(),
'battle' => $pl['id'],
'id_hod' => ($last_hod + 1),
'vars' => '||time1=' . time() . '||time2=0||s1=0||t1=' . $tmr . '||login1=Îòìîðîçîê (' . $otmz[0] . ')',
'type' => 1,
];
//
$ins = mysql_query(
'INSERT INTO `battle_logs` (
`time`,`battle`,`id_hod`,`text`,`vars`,`zona1`,`zonb1`,`zona2`,`zonb2`,`type`
) VALUES (
"' . $mass['time'] . '",
"' . $mass['battle'] . '",
"' . $mass['id_hod'] . '",
"' . $vtvl . '",
"' . $mass['vars'] . '",
"",
"",
"",
"",
"' . $mass['type'] . '"
)'
);
}
}