112 lines
4.2 KiB
PHP
112 lines
4.2 KiB
PHP
<?php
|
|
# Ñêðèïò îòâå÷àåò çà
|
|
# ÷èñòêó ïåùåð êîòîðûå íå èñïîëüçóþòñÿ èãðîêîì â òå÷åíèè 3 ÷àñîâ
|
|
# ïðè ó÷åòå ÷òî ïåùåðå áîëüøå 5 ÷àñîâ îò âðåìåíè ñîçäàíèÿ.
|
|
|
|
# Ïîëó÷àåì IP
|
|
function getIPblock() {
|
|
if(isset($_SERVER['HTTP_X_REAL_IP'])) return $_SERVER['HTTP_X_REAL_IP'];
|
|
return $_SERVER['REMOTE_ADDR'];
|
|
}
|
|
|
|
# Âûïîëíÿåì ïðîâåðêó áåçîïàñíîñòè.
|
|
|
|
/*if(!isset($_GET['test'])) {
|
|
if( $_SERVER['HTTP_CF_CONNECTING_IP'] != $_SERVER['SERVER_ADDR'] && $_SERVER['HTTP_CF_CONNECTING_IP'] != '127.0.0.1' && getIPblock() != '5.187.7.71' ) { die('Hello pussy!'); }
|
|
if(getIPblock() != $_SERVER['SERVER_ADDR'] && getIPblock() != '127.0.0.1' && getIPblock() != '' && getIPblock() != '5.187.7.71') {
|
|
die(getIPblock().'<br>'.$_SERVER['SERVER_ADDR']);
|
|
}
|
|
}*/
|
|
|
|
|
|
define('GAME', true);
|
|
setlocale(LC_CTYPE ,"ru_RU.CP1251");
|
|
|
|
include('_incl_data/__config.php');
|
|
include('_incl_data/class/__db_connect.php');
|
|
|
|
# çàïóñê ñêðèïòà.
|
|
function start() {
|
|
# Ñòðàíèöà ñîçäàíà 0.0000
|
|
$mtime = microtime();$mtime = explode(" ",$mtime);$tstart = $mtime[1] + $mtime[0];
|
|
|
|
# Âûáèðàåì âñåõ áîòîâ.
|
|
#  âûáîðêó âêëþ÷åíî: Ïîçèöèÿ áîòà, Íàïðàâëåíèå êóäà îí ìîæåò èäòè, Ñóùåñòâóåò ëè ðÿäîì Èãðîê, åãî êîîðäèíàòû è â ïîåäèíêå ëè îí.
|
|
$query = mysql_query(
|
|
"SELECT
|
|
`dn`.time_start as dn_start,
|
|
`dn`.city as city,
|
|
`dn`.id as dn_id,
|
|
`uc`.countUsers as u_count
|
|
FROM `dungeon_now` as `dn`
|
|
LEFT JOIN `stats` as `st` ON `st`.id = `dn`.uid
|
|
LEFT JOIN `users` as `u` ON `u`.id = `dn`.uid
|
|
LEFT JOIN (SELECT dnow, count(id) as countUsers FROM `stats` group by dnow ) as `uc` ON `uc`.dnow = `dn`.id
|
|
|
|
WHERE
|
|
`st`.dnow > 0 AND
|
|
`st`.dnow != '' AND
|
|
`u`.online < ".(time()-10800)." AND
|
|
`dn`.time_start < ".(time()-18000)." AND
|
|
`dn`.time_finish = '0' AND `dn`.`bsid` = '0'
|
|
GROUP BY `dn`.id
|
|
ORDER BY `dn`.id DESC;"
|
|
);
|
|
|
|
while( $dungeon = mysql_fetch_array( $query ) ) {
|
|
if(isset($dungeon['dn_id']) && $dungeon['dn_id'] != 15) {
|
|
# [1] Âûêèäûâàåì èãðîêîâ ñ ïîäçåìåëüÿ è ïåðåìåùàåì åãî `382` Ïîäâàëüíîå ïîìåùåíèå(Ìàã.ïîðòàëà)
|
|
$users = mysql_query('SELECT `id` FROM `stats` WHERE `dnow` = "'.$dungeon['dn_id'].'" LIMIT 10');
|
|
while( $cur = mysql_fetch_array($users) ) {
|
|
mysql_query('UPDATE `stats` SET `dnow` = "0" WHERE `id` = "'.$cur['id'].'" LIMIT 1');
|
|
//
|
|
$podval_room = 382;
|
|
//
|
|
print_r($dungeon);
|
|
if( $dungeon['city'] == 'capitalcity' ) {
|
|
//$podval_room = 372;
|
|
$podval_room = 321;
|
|
}elseif( $dungeon['city'] == 'angelscity' ) {
|
|
$podval_room = 242;
|
|
}
|
|
|
|
mysql_query('UPDATE `users` SET `room` = "'.$podval_room.'" WHERE `id` = "'.$cur['id'].'" LIMIT 1');
|
|
#echo 'Âûáðîñèëè èãðîêà ¹'.$cur['id'].' ñ ïîäçåìåëüÿ '.$dungeon['dn_id'].' è ïåðåìåñòèëè â <strong>Ïîäâàëüíîå ïîìåùåíèå</strong><br/>';
|
|
mysql_query('UPDATE `items_users` SET `delete` = "'.time().'" WHERE `uid` = "'.$cur['id'].'" AND `dn_delete` = "1"');
|
|
# echo 'Âûáðàñûâàåì ïåùåðíûå ïðåäìåòû ó èãðîêà ¹'.$cur['id'].' <br/>';
|
|
}
|
|
unset( $cur );
|
|
# [2] Óäàëÿåì Îáúåêòû.
|
|
mysql_query('DELETE FROM `dungeon_obj` WHERE `dn` = "'.$dungeon['dn_id'].'" AND `for_dn` = "0"');
|
|
# echo 'Óäàëÿåì îáúåêòû â ïåùåðå ¹'.$dungeon['dn_id'].'<br/>';
|
|
|
|
# [3] Óäàëÿåì Ìîíñòðîâ.
|
|
mysql_query('DELETE FROM `dungeon_bots` WHERE `dn` = "'.$dungeon['dn_id'].'" AND `for_dn` = "0"');
|
|
# echo 'Óäàëÿåì ìîíñòðîâ â ïåùåðå ¹'.$dungeon['dn_id'].'<br/>';
|
|
|
|
# [4] Óäàëÿåì Ïðåäìåòû.
|
|
mysql_query('DELETE FROM `dungeon_items` WHERE `dn` = "'.$dungeon['dn_id'].'" AND `for_dn` = "0"');
|
|
# echo 'Óäàëÿåì ïðåäìåòû â ïåùåðå ¹'.$dungeon['dn_id'].'<br/>';
|
|
|
|
# [5] Óäàëÿåì Äåéñòâèÿ (actions)
|
|
mysql_query('DELETE FROM `dungeon_actions` WHERE `dn` = "'.$dungeon['dn_id'].'"');
|
|
# echo 'Óäàëÿåì äåéñòâèÿ â ïåùåðå ¹'.$dungeon['dn_id'].'<br/>';
|
|
|
|
# [6] Çàêðûâàåì Ïîäçåìåëüå Dungeon_Now - time_finish = time();
|
|
mysql_query('UPDATE `dungeon_now` SET `time_finish` = "'.time().'" WHERE `id` = "'.$dungeon['dn_id'].'" LIMIT 1');
|
|
|
|
echo 'Çàêðûëè ïåùåðó ¹'.$dungeon['dn_id'].'<br/><br/>';
|
|
} else {
|
|
echo 'Íåò äàííûõ äëÿ îáðàáîòêè.<br/><br/>';
|
|
}
|
|
}
|
|
unset($query,$dungeon,$users);
|
|
|
|
$mtime = microtime();
|
|
$mtime = explode(" ",$mtime);$mtime = $mtime[1] + $mtime[0];$totaltime = ($mtime - $tstart);
|
|
printf ("Ñòðàíèöà ñãåíåðèðîâàíà çà %f ñåêóíä !", $totaltime);
|
|
}
|
|
|
|
# Çàïóñêàåì âûïîëíåíèå ïðîöåññà.
|
|
start();
|