Файл: moduls/duel/inc.php
Строк: 87
<?
/**
* @package Prime Social
* @link http://primesocial.ru
* @copyright Copyright (C) 2016 Prime Social
* @author BoB | http://primesocial.ru/about
*/
$time = time();
$ql = mysql_query("SELECT * FROM `duel` WHERE `act` = '1' AND `time` < '".$time."' ORDER BY time");
while ($finish = mysql_fetch_array($ql)) {
$vote=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$finish[id]' AND `id_opponent` = '$finish[user]'"),0);
$vote2=mysql_result(mysql_query("SELECT COUNT(*) FROM `duel_vote` WHERE `id_duel` = '$finish[id]' AND `id_opponent` = '$finish[opponent]'"),0);
if($vote > $vote2) {
mysql_query("UPDATE ".USERS." SET `rating` = `rating`+'$vote' WHERE `id`='".$finish['user']."'");
mysql_query("UPDATE `duel` SET `finish` = '".$finish['user']."', `act`='2' WHERE `id`='".$finish['id']."'");
$msg = 'Tabliklaymiz! Siz duelda g`olib bo`ldingiz va sizning reytingiz '.$vote.' ga ortdi!';
lenta($msg, $finish['user']);
$msgs = 'Afsuski, siz duelda yutqazdingiz!';
lenta($msg, $finish['opponent']);
} else if(($vote + $vote2) == 0){
$msg = 'Afsuski duelda sizga hech kim ovoz bermadi!';
mysql_query("UPDATE `duel` SET `act`='2' WHERE `id`='".$finish['id']."'");
lenta($msg, $finish['user']);
lenta($msg, $finish['opponent']);
} else if($vote == $vote2) {
$rat = ($vote/2);
mysql_query("UPDATE ".USERS." SET `rating`=`rating`+'$rat' WHERE `id`='".$finish['user']."'");
mysql_query("UPDATE ".USERS." SET `rating`=`rating`+'$rat' WHERE `id`='".$finish['opponent']."'");
mysql_query("UPDATE `duel` SET `act`='2' WHERE `id`='".$finish['id']."'");
$msg = 'Tabriklaymiz! Olishuv durrang bo`ldi va sizning reytingiz '.$rat.' ga ortdi!';
lenta($msg, $finish['user']);
lenta($msg, $finish['opponent']);
} else if($vote < $vote2) {
mysql_query("UPDATE ".USERS." SET `rating`=`rating`+'$vote2' WHERE `id`='".$finish['opponent']."'");
mysql_query("UPDATE `duel` SET `finish` = '".$finish['opponent']."', `act`='2' WHERE `id`='".$finish['id']."'");
$msg = 'Tabliklaymiz! Siz duelda g`olib bo`ldingiz va sizning reytingiz '.$vote2.' ga ortdi!';
lenta($msg, $finish['opponent']);
$msg = 'Afsuski, siz duelda yutqazdingiz!';
lenta($msg, $finish['user']);
}
}
$qld=mysql_query("SELECT * FROM `duel` WHERE `act` = '0' AND `time` < '".$time."' ORDER BY time");
while ($exit = mysql_fetch_array($qld)) {
$ald = mysql_fetch_array(mysql_query("SELECT * FROM ".USERS." WHERE `id` = '".$exit['user']."' LIMIT 1"));
$msg = 'Afsuski '.$ald['nick'].' sizning duelga chaqirishingizni u qabul qilmadi!';
lenta($msg, $exit['user']);
mysql_query("DELETE FROM `duel` WHERE `id` = '$exit[id]' LIMIT 1");
}
$cat = array(
'Kim chiroyli?',
'Kim kuchli?',
'Kim modni?',
'Kim yosh ko`rinadi?',
'Kim kulguli?',
'Kim qaddi qomati chiroyli?',
'Kim jinni?',
'Kim glamurli?',
'Kim yoqimtoy?'
);
?>