game/cron/auction.php
2022-06-07 00:30:34 +03:00

51 lines
2.6 KiB
PHP

<?php
define('GAME',true);
setlocale(LC_CTYPE ,"ru_RU.CP1251");
include('/home/newcom1/public_html/_incl_data/__config.php');
include('/home/newcom1/public_html/_incl_data/class/__db_connect.php');
include('/home/newcom1/public_html/_incl_data/class/__user.php');
/*
CRON Êîìèññèîííîãî ìàãàçèíà
Äåéñòâèÿ:
1. Åñëè ïðåäìåò âèñèò óæå 2 è áîëåå íåäåëü, ïðîäàâàòü ïðåäìåò çà 50% îò åãî ñòîèìîñòè ñ ó÷åòîì èçíîñà
äåíüãè îòñûëàþòñÿ íà ïî÷òó.
*/
$time_last = 86400; //1 äåíü
$sp = mysql_query('SELECT * FROM `items_auc` WHERE `time_end` = 0 AND `time` < "'.(time()-$time_last).'" ORDER BY `user_buy` ASC');
while( $pl = mysql_fetch_array($sp) ) {
//
if( $pl['x'] > 0 ) {
$pl['name'] .= ' (x'.$pl['x'].')';
}
//
$user = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$pl['uid'].'" LIMIT 1'));
if( $pl['user_buy'] > 0 ) {
//Ïðåäìåò êóïèëè
$buyer = mysql_fetch_array(mysql_query('SELECT * FROM `users` WHERE `id` = "'.$pl['user_buy'].'" LIMIT 1'));
if(isset($buyer['id'])) {
mysql_query('UPDATE `items_users` SET `uid` = "'.$buyer['id'].'",`lastUPD` = "'.time().'" WHERE (`id` = "'.$pl['item_id'].'" OR `inGroup` = "'.$pl['item_id'].'") AND `uid` = 0');
$u->send('','','','<font color=#009966 >Ôèëèàë Àóêöèîíà</font>',$buyer['login'],'Âû âûèãðàëè òîðãè. Ïðåäìåò &quot;'.$pl['name'].'&quot; çà <b>'.$pl['price'].' êð.</b> áûë äîáàâëåí ê âàì â èíâåíòàðü.',time(),6,0,0,0,1,0);
}
if(isset($user['id'])) {
$u->send('','','','<font color=#009966 >Ôèëèàë Àóêöèîíà</font>',$user['login'],'Ïðåäìåò &quot;'.$pl['name'].'&quot; áûë ïðîäàí íà òîðãàõ, <b>'.$pl['price'].'</b> êð. çà òîâàð îòïðàâëåíû âàì ïî ïî÷òå.',time(),6,0,0,0,1,0);
//
mysql_query('INSERT INTO `items_users` (`delete`,`item_id`,`1price`,`uid`,`lastUPD`) VALUES ("0","1220","'.$pl['price'].'","-51'.$user['id'].'","'.time().'")');
mysql_query('INSERT INTO `post` (`uid`,`sender_id`,`time`,`money`,`text`) VALUES (
"'.$user['id'].'","0","'.time().'","'.$pl['price'].'","Ôèëèàë Àóêöèîíà: Ïðåäìåò &quot;'.$pl['name'].'&quot; áûë ïðîäàí çà <b>'.$pl['price'].' êð</b>."
)');
}
}else{
//Ïðåäìåò íå êóïèëè, âîçâðàùàåì åãî îáðàòíî
if(isset($user['id'])) {
mysql_query('UPDATE `items_users` SET `uid` = "'.$user['id'].'",`lastUPD` = "'.time().'" WHERE (`id` = "'.$pl['item_id'].'" OR `inGroup` = "'.$pl['item_id'].'") AND `uid` = 0');
$u->send('','','','<font color=#009966 >Ôèëèàë Àóêöèîíà</font>',$user['login'],'Ïðåäìåò &quot;'.$pl['name'].'&quot; íå áûë ïðîäàí, îí âîçâðàùåí âàì â èíâåíòàðü.',time(),6,0,0,0,1,0);
}
}
mysql_query('UPDATE `items_auc` SET `time_end` = "'.time().'" WHERE `id` = "'.$pl['id'].'" LIMIT 1');
}
?>