Файл: in4at/maf.php
Строк: 1329
<?php
##################################################################################################
## Script name : In4at ##
## Version : Final ##
## Made by : XPYCT(Сергей Мищенко) ##
## E-mail : bce-ok@bk.ru ##
## ICQ : 447-50-50-62 ##
## Site : http://vkontakte.ru/id31604521 ##
## Внимание! Скрипт распространяется бесплатно! Модификация W4at by XPYCT ##
##################################################################################################
define('REQ_2_chat', true);
require('4at_set.php');
require('db_con.php');
require('style.php');
if ($py !== spy_code) require('us_info.php');
function getmicrotime()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$chasy =4;
$us=$row['user'];
$smset = $row['smiles'];
$maf = mysql_query("Select user from users where id='5' LIMIT 1;");
$x = mysql_fetch_array($maf);
$mafiozi = $x['user'];
$qi=mysql_query("Select who from ignor where user= '".$id."'");
while($ia=mysql_fetch_array($qi)){
$ignor[]=$ia[0];}
if ($rm!=1&&$rm!=2&&$rm!=3) $rm = 1;
$rmaf = 'maf'.$rm;
$rmafaction = 'mafaction'.$rm;
$rscores = 'scores'.$rm;
$ringame = 'ingame'.$rm;
function role_to_tpadej($role){
switch ($role){
case "обыватель" : $trole = "обывателем";break;
case "комиссар катани" : $trole = "инспектором катани";break;
case "главарь мафии" : $trole = "главарем мафии";break;
case "доктор" : $trole = "доктором";break;
case "маньяк" : $trole = "маньяком";break;
case "путана" : $trole = "путаной";break;
case "бомж" : $trole = "бомжом";break;
case "мафиози" : $trole = "мафиози";break;
case "горец" : $trole = "горцем";break;
case "жена комиссара" : $trole = "женой комиссара";break;
case "клоун" : $trole = "клоуном";break;
default : $trole = $role;break;
}
return ($trole);
}
function role_to_rpadej($role){
switch ($role){
case "обыватель" : $rrole = "обывателя";break;
case "комиссар катани" : $rrole = "комиссара катани";break;
case "главарь мафии" : $rrole = "главаря мафии";break;
case "доктор" : $rrole = "доктора";break;
case "маньяк" : $rrole = "маньяка";break;
case "путана" : $rrole = "путану";break;
case "бомж" : $rrole = "бомжа";break;
case "мафиози" : $rrole = "мафиози";break;
case "горец" : $rrole = "горца";break;
case "жена комиссара" : $rrole = "жены комиссара";break;
case "клоун" : $rrole = "клоуна";break;
default: $rrole = $role;break;
}
return($rrole);
}
function get_name_by_id($id_in_game, $rm){
$ringame = 'ingame'.$rm;
$req = mysql_query("select * from $ringame WHERE id_in_game = '".$id_in_game."'");
$ms = mysql_fetch_array($req);
$gamer_id = $ms['gamer_id'];
$req = mysql_query("select * from users WHERE id = '".$gamer_id."'");
$ms = mysql_fetch_array($req);
$name = $ms['user'];
unset($gamer_id);
unset($ms);
unset($req);
return($name);
}
function get_role_by_id($id_in_game, $rm){
$ringame = 'ingame'.$rm;
$req = mysql_query("select * from $ringame WHERE id_in_game = '".$id_in_game."'");
$ms = mysql_fetch_array($req);
$role = $ms['role'];
unset($ms);
unset($req);
return($role);
}
function trun_to_rus($str){
$str=str_replace("ch","ч",$str);
$str=str_replace("sc","щ",$str);
$str=str_replace("sh","ш",$str);
$str=str_replace("ye","э",$str);
$str=str_replace("yu","ю",$str);
$str=str_replace("ya","я",$str);
$str=str_replace("CH","Ч",$str);
$str=str_replace("Ch","Ч",$str);
$str=str_replace("SC","Щ",$str);
$str=str_replace("Sc","Щ",$str);
$str=str_replace("SH","Ш",$str);
$str=str_replace("Sh","Ш",$str);
$str=str_replace("""","Ъ",$str);
$str=str_replace(""","ъ",$str);
$str=str_replace("‘‘","Ь",$str);
$str=str_replace("‘","ь",$str);
$str=str_replace("YE","Э",$str);
$str=str_replace("Ye","Э",$str);
$str=str_replace("YU","Ю",$str);
$str=str_replace("Yu","Ю",$str);
$str=str_replace("YA","Я",$str);
$str=str_replace("Ya","Я",$str);
$str=strtr($str,array("""=>"","a"=>"а","b"=>"б","v"=>"в","g"=>"г","d"=>"д","e"=>"е","j"=>"ж","z"=>"з","i"=>"и","y"=>"й","k"=>"к","l"=>"л","m"=>"м","n"=>"н","o"=>"о","p"=>"п","r"=>"р","s"=>"с","t"=>"т","u"=>"у","f"=>"ф","h"=>"х","c"=>"ц","w"=>"ш","x"=>"ы","A"=>"А","B"=>"Б","V"=>"В","G"=>"Г","D"=>"Д","E"=>"Е","J"=>"Ж","Z"=>"З","I"=>"И","Y"=>"Й","K"=>"К","L"=>"Л","M"=>"М","N"=>"Н","O"=>"О","P"=>"П","R"=>"Р","S"=>"С","T"=>"Т","U"=>"У","F"=>"Ф","H"=>"Х","C"=>"Ц","W"=>"Ш","X"=>"Ы"));
return $str;
}
function scores($rm){
$rscores = 'scores'.$rm;
$r = mysql_query("select * from $rscores");
$mmes = "";
while (($a = mysql_fetch_array($r))!==false){
$gamer_id = $a['gamer_id'];
$score = $a['score'];
$gamer_id=intval($gamer_id);
mysql_query("update users set mafcredits = mafcredits + creditsingame WHERE id = '".$gamer_id."'");
$re = mysql_query("select user from users WHERE id = '".$gamer_id."'");
$b = mysql_fetch_array($re);
$mmes = $mmes.$b['user']." - <b>$score</b>, ";
}
$mmes = substr($mmes,0,strlen($mmes)-2);
return($mmes);
}
$r = mysql_query("SELECT * FROM optim");
$a = mysql_fetch_array($r);
if ($a["go"]<time()){
$i = time() + 1800;
mysql_query("Update optim set go='".$i."' WHERE klu4 = '1'");
$i = time() - 3600;
for ($num = 1;$num <= 3;$num++){
$roptim = "maf".$num;
mysql_query("delete from $roptim WHERE id<'".$i."'");
mysql_query("OPTIMIZE TABLE $roptim");
}
}
mysql_query("select * from $ringame WHERE gamer_id = '".$id."'");
if (mysql_affected_rows()!=0) $gmes = 1;else $gmes = 0;
$tm = time()-300;
$r = mysql_query("select * from $ringame WHERE (onl<'".$tm."')");
if (mysql_affected_rows() != 0){
$mmsg = "";
while (($a = mysql_fetch_array($r))!==false){
$grole = get_role_by_id($a['id_in_game'], $rm);
$gname = get_name_by_id($a['id_in_game'], $rm);
$gid = $a['gamer_id'];
$mmsg = $mmsg."$grole $gname покидает игру (превышено время ожидания ответа)! ";
$gid=intval($gid);
mysql_query("update users set creditsingame = creditsingame - 100 WHERE id = '".$gid."'");
$r = mysql_query("select creditsingame from users WHERE id = '".$gid."'");
$a = mysql_fetch_array($r);
$cring = $a["creditsingame"];
mysql_query("insert into $rscores set gamer_id = '".$gid."', score = '".$cring."'");
mysql_query("delete from $ringame WHERE gamer_id = '".$gid."'");
}
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$vktr = false;
$r = mysql_query("select count(*) as sm from $ringame");
$a = mysql_fetch_array($r);
$sm = $a['sm'];
mysql_query("select * from $ringame WHERE role = 'главарь мафии'");
if (mysql_affected_rows()==0&&$sm!=0){
$r = mysql_query("select * from $ringame WHERE role = 'мафиози'");
if (mysql_affected_rows()==0){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select role, gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$role = $a['role'];
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
if ($role == "обыватель") mysql_query("update users set creditsingame = creditsingame + 100 WHERE id = '".$gamer_id."'");
else mysql_query("update users set creditsingame = creditsingame + 50 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Игра окончена, победа мирных жителей! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}else{
$a = mysql_fetch_array($r);
$id_in_game = $a['id_in_game'];
$gamer_id = $a['gamer_id'];
$id_in_game=intval($id_in_game);
mysql_query("update $ringame set role = 'главарь мафии' WHERE id_in_game = '".$id_in_game."'");
$mmsg = 'Теперь вы главарь мафии!';
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$gamer_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if ($vktr!==true){
$r = mysql_query("select count(*) as sm from $ringame");
$a = mysql_fetch_array($r);
if ($a['sm']==2){
mysql_query("select * from $ringame WHERE (role = 'главарь мафии')or(role = 'мафиози')");
if (mysql_affected_rows()==2) $vk = "maf";
if (mysql_affected_rows()==1){
mysql_query("select * from $ringame WHERE (role = 'доктор')or(role = 'комиссар катани')or(role = 'путана')or(role = 'маньяк')");
if (mysql_affected_rows() != 0) $vk = "ni4";else $vk = "maf";
}
}
if ($a['sm']==1){
mysql_query("select * from $ringame WHERE (role = 'главарь мафии')or(role = 'мафиози')");
if (mysql_affected_rows() != 0) $vk = "maf";
}
if ($a['sm']==0) $vk = "ni4";
mysql_query("select * from $ringame");
$nm = round(mysql_affected_rows()/2-0.5);
$r = mysql_query("Select count(*) as sm from $ringame WHERE (role='мафиози')or(role='главарь мафии')");
$a = mysql_fetch_array($r);
$sm = $a['sm'];
if ($sm>$nm) $vk = "maf";
if (isset($vk)){
$vktr = true;
if ($vk == "ni4"){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
mysql_query("update users set creditsingame = creditsingame + 25 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Силы Мафии и мирных жителей равны, ничья! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
if ($vk == 'maf'){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select role, gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$role = $a['role'];
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
if ($role == "мафиози"||$role == "главарь мафии") mysql_query("update users set creditsingame = creditsingame + 50 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Всем хана, победа Мафов! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
}
}
$tm = time();
mysql_query("update users set onl = '".$tm."' WHERE id = '".$id."'");
if ($gmes == 1) mysql_query("update $ringame set onl = '".$tm."' WHERE gamer_id = '".$id."'");
$r = mysql_query("select * from $rmafaction");
$a = mysql_fetch_array($r);
$action = $a['action'];
$nexttime = $a["nexttime"];
if (($action == "game_night"&&$tm>$nexttime)||($action == "dvote"&&$tm>$nexttime)){
$tm = time()+120;
mysql_query("update $rmafaction set action = 'game_day', nexttime = '".$tm."', kiked = '0', cround = cround + 1");
$kiked = $a["kiked"];
if ($kiked==1) $mmsg = 'Наступает ночь, все жители засыпают, кроме некоторых...';
else $mmsg = 'Жители, прогалдев целый день, так ничего и не решили. Наступает ночь...';
mysql_query("update $ringame set dvote = '0', wholin = '0'");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
mysql_query("select gamer_id from $ringame WHERE role = 'комиссар катани'");
if(mysql_affected_rows()==0){
$r = mysql_query("select state from $ringame WHERE role = 'жена комиссара'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
if ($a['state']==0) mysql_query("update $ringame set state = '1' WHERE role = 'жена комиссара'");
}
}
mysql_query("update $ringame set gamer_act = ''");
$r = mysql_query("select * from $ringame WHERE role = 'мафиози'");
if (mysql_affected_rows()!=0){
while (($a = mysql_fetch_array($r))!==false){
$thg = $a['gamer_id'];
$re = mysql_query("select * from $ringame WHERE ((role = 'мафиози')or(role = 'главарь мафии'))and(gamer_id != '".$thg."')");
$so = "";
while (($b = mysql_fetch_array($re))!==false){
$sname = get_name_by_id($b['id_in_game'], $rm);
if (get_role_by_id($b['id_in_game'], $rm)!="главарь мафии") $so = $so."$sname, ";else $so = $so."$sname(главарь), ";
}
$so = substr($so,0,strlen($so)-2);
$mmsg = "Сообщники: $so";
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$thg."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
$r = mysql_query("select * from $ringame WHERE role = 'главарь мафии'");
$a = mysql_fetch_array($r);
$glmaf_id = $a['gamer_id'];
$mmsg = "Выбирайте, кому сегодня не поздоровится(!номер, в приват Мафу): ";
$r = mysql_query("select * from $ringame");
$kol = mysql_affected_rows();
for ($i=1;$i<=$kol;$i++){
$a = mysql_fetch_array($r);
$gamer_id = $a['gamer_id'];
$r2 = mysql_query("select * from users where id = '".$gamer_id."'");
$b = mysql_fetch_array($r2);
$gname = $b['user'];
$id_in_game = $a['id_in_game'];
$s = $s."$id_in_game - $gname, ";
}
$mmsg = $mmsg.$s;
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
$r = mysql_query("select * from $ringame WHERE role = 'мафиози'");
if (mysql_affected_rows()!=0){
$sg = "";
while (($a = mysql_fetch_array($r))!==false){
$sname = get_name_by_id($a['id_in_game'], $rm);
$sg = $sg."$sname, ";
}
$sg = substr($sg,0,strlen($sg)-2);
$mmsg = $mmsg."<br/>"."(ваши сообщники: $sg)";
}
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='".$glmaf_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$r = mysql_query("select * from $ringame WHERE role = 'комиссар катани'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$kom_id = $a['gamer_id'];
$mmsg = 'Выбирайте, кого проверить (!номер, в приват Мафу) или убить (!!номер): '.$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$kom_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
$r = mysql_query("select * from $ringame WHERE role = 'маньяк'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$man_id = $a['gamer_id'];
$mmsg = 'Кто же будет жертвой маньяка? (!номер, в приват Мафу): '.$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='".$man_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
$r = mysql_query("select * from $ringame WHERE role = 'путана'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$put_id = $a['gamer_id'];
$mmsg = 'К кому же шлюха направится сегодня? (!номер, в приват Мафу): '.$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$put_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
$r = mysql_query("select * from $ringame WHERE role = 'бомж'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$bomj_id = $a['gamer_id'];
$mmsg = 'У кого роемся в карманах? (!номер, в приват Мафу): '.$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$bomj_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
$r = mysql_query("select * from $ringame WHERE role = 'доктор'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$dok_id = $a['gamer_id'];
$mmsg = 'Кого лечим? (!номер, в приват Мафу): '.$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$dok_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
$r = mysql_query("select * from $ringame WHERE role = 'клоун'");
$a = mysql_fetch_array($r);
$state = $a['state'];
if (mysql_affected_rows()!=0&&$state==0){
$kloun_id = $a['gamer_id'];
$mmsg = "Выберите, чьи роли поменять местами(''!номер !номер'', через пробел, в приват Мафу): ".$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$kloun_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
$r = mysql_query("select * from $ringame WHERE role = 'жена комиссара'");
$a = mysql_fetch_array($r);
$state = $a['state'];
if (mysql_affected_rows()!=0&&$state==1){
$jena_id = $a['gamer_id'];
$mmsg = 'На кого выпустим нашу месть? (!номер, в приват Мафу): '.$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$jena_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if (($action=="game_day"&&$tm>$nexttime)||$action == "allvoted"){
$tm = time()+180;
mysql_query("update $rmafaction set action = 'game_night', nexttime = '".$tm."'");
$kom_kil = 0;
$maf_kil = 0;
$man_kil = 0;
$jena_kil = 0;
$mmsg = 'Вот и день наступил. Но все ли дожили до него?';
$r = mysql_query("select * from $ringame WHERE role = 'путана'");
$a = mysql_fetch_array($r);
$put_act = 0;
$put_act = $a['gamer_act'];
$put_id = $a['gamer_id'];
$r = mysql_query("select * from $ringame WHERE role = 'горец'");
$a = mysql_fetch_array($r);
$gor_id_in_game = $a['id_in_game'];
$put_id=intval($put_id);
if ($put_act != 0) mysql_query("update users set creditsingame = creditsingame + 5 WHERE id = '".$put_id."'");
$r = mysql_query("select * from $ringame WHERE role = 'доктор'");
$a = mysql_fetch_array($r);
$doknotact = false;
$dok_act = 0;
if ($put_act != $a['id_in_game']) $dok_act = $a['gamer_act'];
$r = mysql_query("select * from $ringame WHERE role = 'комиссар катани'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$kom_id = $a['gamer_id'];
if ($a['gamer_act']!=""){
$wh = get_name_by_id($a['gamer_act'], $rm);
if ($put_act==$a['id_in_game']) $mmsg = $mmsg." Инспектор катани всю ночь был занят шлюхой, и не успел отловить бандитов.";else if (strpos($a['gamer_act'],"!")===false){
$kom_id=intval($kom_id);
mysql_query("update mafusers set creditsingame = creditsingame + 5 WHERE id = '".$kom_id."'");
$mmsg = $mmsg." Инспектор катани времени зря не терял. Проведя тщательное расследование, он наконец-то выяснил, кто такой $wh!";
if (get_role_by_id($a['gamer_act'], $rm)=="мафиози"||get_role_by_id($a['gamer_act'], $rm)=="главарь мафии")$tokom = "$wh - мафиози";else $tokom = "$wh - мирный житель";
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$tokom."', id='".$tm."', towhom='".$kom_id."', gamemes='1'");
mysql_query("Update mafusers set posts = posts + 1 WHERE id = '5'");
}else{
$a['gamer_act'] = str_replace("!","",$a['gamer_act']);
$wh = get_name_by_id($a['gamer_act'], $rm);
$kto = role_to_rpadej(get_role_by_id($a['gamer_act'], $rm));
if ($gor_id_in_game!=$a['gamer_act']){
if ($a['gamer_act'] != $dok_act){
$kom_id=intval($kom_id);
if (get_role_by_id($a['gamer_act'], $rm)=="мафиози"||get_role_by_id($a['gamer_act'], $rm)=="главарь мафии") {$mmsg = $mmsg." Проведя сложнейшую операцию, инспектор катани наконец-то вычислил и убил $kto $wh!!!";mysql_query("update mafusers set creditsingame = creditsingame + 20 WHERE id = '".$kom_id."'");}
else {$mmsg = $mmsg." Инспектор катани так спятил, что казнил ни в чем не повинного $kto $wh!";mysql_query("update mafusers set creditsingame = creditsingame - 20 WHERE id = '".$kom_id."'");}
$kom_kil = $a['gamer_act'];
}else {
$mmsg = $mmsg." Комиссар катани почти расстрелял $wh, но добрый доктор буквально достал того из гроба.";
$doknotact = true;
}
}else {
$mmsg = $mmsg.' Комиссар катани расстрелял ночью горца, и был очень удивлен, когда тот не умер.';
}
}
}else $mmsg = $mmsg.' Инспектор катани так набухался, что провалялся всю ночь дома, так ничего и не выяснив';
$tm = time();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into maf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom=''");
}
$r = mysql_query("select * from $ringame WHERE role = 'главарь мафии'");
$a = mysql_fetch_array($r);
$maf_id = $a['gamer_id'];
if ($a['gamer_act']!=""){
$wh = get_name_by_id($a['gamer_act'], $rm);
if ($put_act==$a['id_in_game']) $mmsg = $mmsg.' Шлюха направилась в логово к мафии и всю ночь пробыла с главарем мафии, отвлекая его от дел.';
else {
if ($gor_id_in_game != $a['gamer_act']){
$maf_id=intval($maf_id);
mysql_query("update users set creditsingame = creditsingame + 10 WHERE id = '".$maf_id."'");
$kto = role_to_tpadej(get_role_by_id($a['gamer_act'], $rm));
if ($dok_act != $a['gamer_act']){
$mmsg = $mmsg." Мафия сегодня зверски расправилась с $kto $wh!";
$maf_kil = $a['gamer_act'];
} else {
$mmsg = $mmsg." Мафы убили $wh, но доктор сгонял на кладбище и пришил ему все обратно";
$doknotact = true;
}
} else {
$mmsg = $mmsg.' Мафия ночью нарвалась на горца, он ей так накостылял, что мафы еле ноги унесли.';
}
}
}
$r = mysql_query("select * from $ringame WHERE role = 'маньяк'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$man_id = $a['gamer_id'];
$man_act = $a['gamer_act'];
if ($a['gamer_act']!=""){
$wh = get_name_by_id($a['gamer_act'], $rm);
if ($put_act==$a['id_in_game']) $mmsg = $mmsg." Маньяк так хотел намотать кишки на руку кому-нибудь этой ночью, но встретил шлюху и решил отложить это дело.";
else {
$kto = get_role_by_id($a['gamer_act'], $rm);
if ($dok_act != $a['gamer_act']){
mysql_query("select * from $ringame WHERE (id_in_game = '".$man_act."')and((role = 'мафиози')or(role = 'главарь мафии'))");
$man_id=intval($man_id);
if (mysql_affected_rows()!=0) mysql_query("update users set creditsingame = creditsingame + 20 WHERE id = '".$man_id."'");
else mysql_query("update users set creditsingame = creditsingame - 5 WHERE id = '".$man_id."'");
$mmsg = $mmsg." $kto $wh был наден утром в мусорном баке с топором в жопе. Похоже, тут не обошлось без маньяка...";
$man_kil = $a['gamer_act'];
}else{
$mmsg = $mmsg." Маньяк вставил топор в жопу $wh, но операция была успешной, док его вытащил";
$doknotact = true;
}
}
}
}
$r = mysql_query("select * from $ringame WHERE role = 'бомж'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$bomj_id = $a['gamer_id'];
if ($a['gamer_act']!=""){
$wh = get_name_by_id($a['gamer_act'], $rm);
if ($put_act==$a['id_in_game']) $mmsg = $mmsg.' Нахальный бомж поймал шлюху на улице и затащил к подвал. Там они и провели всю ночь.';
else {
$bomj_id=intval($bomj_id);
mysql_query("update users set creditsingame = creditsingame + 5 WHERE id = '".$bomj_id."'");
$mmsg = $mmsg." Бомж ночью рылся в карманах у $wh!";
$kto = get_role_by_id($a['gamer_act'], $rm);
$mmsgtob = "$wh это $kto!";
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsgtob."', id='".$tm."', towhom='".$bomj_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
}
$r = mysql_query("select * from $ringame WHERE role = 'жена комиссара'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$jena_id = $a['gamer_id'];
$state = $a['state'];
if ($a['gamer_act']!=""){
$wh = get_name_by_id($a['gamer_act'], $rm);
if ($put_act==$a['id_in_game']) $mmsg = $mmsg.' Шлюха сегодня направилась к жене комиссара. Камасутра отдыхает.';
else {
if ($gor_id_in_game != $a['gamer_act']){
$jena_id=intval($jena_id);
mysql_query("update users set creditsingame = creditsingame + 50 WHERE id = '".$jena_id."'");
$kto = role_to_rpadej(get_role_by_id($a['gamer_act'], $rm));
if ($dok_act != $a['gamer_act']){
$mmsg = $mmsg." Жена комиссара отравила ночью $kto $wh, отомстив за смерть мужа.!";
$jena_kil = $a['gamer_act'];
}else {
$mmsg = $mmsg." Жена комиссара почти зарезала $wh, но добрый док за небольшую плату все восстановил.";
$doknotact = true;
}
}else {
$mmsg = $mmsg.' Жена комиссара продырявила ножом горца, а он даже не заметил. Теперь ходит с ножом в жопе.';
}
}
}
}
$r = mysql_query("select * from $ringame WHERE role = 'доктор'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$dok_id = $a['gamer_id'];
$dok_id=intval($dok_id);
if ($doknoact==true) mysql_query("update users set creditsingame = creditsingame + 20 WHERE id = '".$dok_id."'");
else if ($put_act!=$a['id_in_game']) mysql_query("update users set creditsingame = creditsingame + 5 WHERE id = '".$dok_id."'");
if ($a['gamer_act']!=""&&$doknotact===false){
$wh = get_name_by_id($a['gamer_act'], $rm);
if ($put_act==$a['id_in_game']) $mmsg = $mmsg.' Доктор целую ночь прокувыркался с путаной, так никого и не вылечив';
else{
if ($a['gamer_id']==$a['gamer_act']) $mmsg = $mmsg.' Наш доктор эгоистично лечил сам себя.';
else $mmsg = $mmsg." Доктор накачал лекарствами $wh";
}
}
}
$r = mysql_query("select * from $ringame WHERE role = 'клоун'");
if (mysql_affected_rows()!=0){
$a = mysql_fetch_array($r);
$state = $a['state'];
$kloun_id = $a['gamer_id'];
if ($a['gamer_act']!=""){
list($g1,$g2) = explode (" ",$a['gamer_act']);
mysql_query("select gamer_id from $ringame WHERE (id_in_game = '".$g1."')or(id_in_game = '".$g2."')");
if (mysql_affected_rows()==2){
$r = mysql_query("select gamer_id, role, state from $ringame WHERE id_in_game = '".$g1."'");
$b = mysql_fetch_array($r);
$gid1 = $b['gamer_id'];
$role1 = $b['role'];
$state1 = $b['state'];
$r = mysql_query("select gamer_id, role, state from $ringame WHERE id_in_game = '".$g2."'");
$b = mysql_fetch_array($r);
$gid2 = $b['gamer_id'];
$role2 = $b['role'];
$state2 = $b['state'];
$mmsg1 = "Ваша новая роль: $role2!";
$mmsg2 = "Ваша новая роль: $role1!";
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg1."', id='".$tm."', towhom='".$gid1."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg2."', id='".$tm."', towhom='".$gid2."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
mysql_query("update $ringame set role = '".$role2."', state = '".$state2."' WHERE id_in_game = '".$g1."'");
mysql_query("update $ringame set role = '".$role1."', state = '".$state1."' WHERE id_in_game = '".$g2."'");
$mmsg = $mmsg.' Жители! В городе завелся клоун, и этой ночью он поменял роли двух игроков!!!';
$r = mysql_query("select cround from $rmafaction");
$a = mysql_fetch_array($r);
$sc = $a["cround"]*30;
$kloun_id=intval($kloun_id);
mysql_query("update users set creditsingame = creditsingame + '".$sc."' WHERE id = '".$kloun_id."'");
mysql_query("update $ringame set state = '1' WHERE role = 'клоун'");
}
}
}
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE ((id_in_game = '".$kom_kil."')or(id_in_game = '".$maf_kil."')or(id_in_game = '".$man_kil."')or(id_in_game = '".$jena_kil."'))and(users.id = $ringame.gamer_id)");
mysql_query("delete from $ringame WHERE (id_in_game = '".$kom_kil."')or(id_in_game = '".$maf_kil."')or(id_in_game = '".$man_kil."')or(id_in_game='".$jena_kil."')");
$vktr = false;
$r = mysql_query("select count(*) as sm from $ringame");
$a = mysql_fetch_array($r);
$sm = $a['sm'];
$r = mysql_query("select current,prev,prevprev from $rmafaction");
$a = mysql_fetch_array($r);
$current = $a['current'];
$prev = $a['prev'];
$prevprev = $prev;
$prev = $current;
$current = $sm;
mysql_query("update $rmafaction set prevprev = '".$prevprev."', prev = '".$prev."', current = '".$current."'");
if ($current == $prevprev){
mysql_query("update $rmafaction set action = 'nogame'");
$vktr = true;
$mmsg = 'Два раунда жители тормозят, и никто не умирает. Поэтому объявляется ничья! А роли были такие: ';
$r = mysql_query("select gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
mysql_query("update users set creditsingame = creditsingame + 25 WHERE id = '".$gamer_id."'");
}
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
mysql_query("select * from $ringame WHERE role = 'главарь мафии'");
if (mysql_affected_rows()==0&&$sm!=0&&$vktr!==true){
$r = mysql_query("select * from $ringame WHERE role = 'мафиози'");
if (mysql_affected_rows()==0){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select role, gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$role = $a['role'];
$gamer_id = $a['gamer_id'];
if ($role == "обыватель") mysql_query("update users set creditsingame = creditsingame + 100 WHERE id = '".$gamer_id."'");
else mysql_query("update users set creditsingame = creditsingame + 50 WHERE id = '".$gamer_id."'");
}
$mmsg = "Игра окончена, победа мирных жителей! А роли были такие: ";
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
} else{
$a = mysql_fetch_array($r);
$id_in_game = $a['id_in_game'];
$gamer_id = $a['gamer_id'];
mysql_query("update $ringame set role = 'главарь мафии' WHERE id_in_game = '".$id_in_game."'");
$mmsg = 'Теперь вы главарь мафии!';
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$gamer_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if ($vktr!==true){
$r = mysql_query("select count(*) as sm from $ringame");
$a = mysql_fetch_array($r);
if ($a['sm']==2){
mysql_query("select * from $ringame WHERE (role = 'главарь мафии')or(role = 'мафиози')");
if (mysql_affected_rows()==2) $vk = "maf";
if (mysql_affected_rows()==1){
mysql_query("select * from $ringame WHERE (role = 'доктор')or(role = 'комиссар катани')or(role = 'путана')or(role = 'маньяк')");
if (mysql_affected_rows() != 0) $vk = 'ni4';else $vk = 'maf';
}
}
if ($a['sm']==1){
mysql_query("select * from $ringame WHERE (role = 'главарь мафии')or(role = 'мафиози')");
if (mysql_affected_rows() != 0) $vk = 'maf';
}
if ($a['sm']==0) $vk = 'ni4';
mysql_query("select * from $ringame");
$nm = round(mysql_affected_rows()/2-0.5);
$r = mysql_query("Select count(*) as sm from $ringame WHERE (role='мафиози')or(role='главарь мафии')");
$a = mysql_fetch_array($r);
$sm = $a['sm'];
if ($sm>$nm) $vk = 'maf';
if (isset($vk)){
$vktr = true;
if ($vk == 'ni4'){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
mysql_query("update users set creditsingame = creditsingame + 25 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Силы Мафии и мирных жителей равны, ничья! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
if ($vk == 'maf'){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select role, gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$role = $a['role'];
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
if ($role == "мафиози"||$role == "главарь мафии") mysql_query("update users set creditsingame = creditsingame + 50 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Всем хана, победа Мафов! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
}
mysql_query("update $ringame set gamer_act=''");
if ($vktr===false){
$mmsg = 'Кого же залинчуем сегодня днем? День длится 3 минуты. Голосуем.(!номер) ';
$r = mysql_query("select * from $ringame");
$kol = mysql_affected_rows();
for ($i=1;$i<=$kol;$i++){
$a = mysql_fetch_array($r);
$gamer_id = $a['gamer_id'];
$r2 = mysql_query("select * from users where id = '".$gamer_id."'");
$b = mysql_fetch_array($r2);
$gname = $b['user'];
$id_in_game = $a['id_in_game'];
$s = $s."<b>$id_in_game</b> - $gname, ";
}
$mmsg = $mmsg.$s;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if ($action=='registration'&&$tm>$nexttime){
mysql_query("select * from $ringame");
if (mysql_affected_rows()<3){
mysql_query("update $rmafaction set action = 'nogame'");
$mmsg = 'Игра не начнется, пока не будет хотя бы 3 игроков!';
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
mysql_query("delete from $ringame");
}else{
mysql_query("delete from $rscores");
$tm = time()+25;
mysql_query("update $rmafaction set action = 'game_night', nexttime = '".$tm."', kiked = '1', cround = '0'");
$r = mysql_query("select * from $ringame");
$roles = array("обыватель","главарь мафии","комиссар катани");
if (mysql_affected_rows()>3) array_push ($roles,'доктор');
if (mysql_affected_rows()>4) array_push ($roles,'обыватель');
if (mysql_affected_rows()>5) array_push ($roles,'мафиози');
if (mysql_affected_rows()>6) array_push ($roles,'маньяк');
if (mysql_affected_rows()>7) array_push ($roles,'путана');
if (mysql_affected_rows()>8) array_push ($roles,'обыватель');
if (mysql_affected_rows()>9) array_push ($roles,'мафиози');
if (mysql_affected_rows()>10) array_push ($roles,'бомж');
if (mysql_affected_rows()>11) array_push ($roles,'мафиози');
if (mysql_affected_rows()>12) array_push ($roles,'горец');
if (mysql_affected_rows()>13) array_push ($roles,'клоун');
if (mysql_affected_rows()>14) array_push ($roles,'мафиози');
if (mysql_affected_rows()>15) array_push ($roles,'жена комиссара');
for ($i=1;$i<=((mysql_affected_rows()-15)/3);$i++) array_push ($roles,"мафиози");
$j = count ($roles);
for ($i=1;$i<=mysql_affected_rows()-$j;$i++) array_push ($roles,"обыватель");
mt_srand(time()*100000);
shuffle($roles);
$i = 0;
while (($a = mysql_fetch_array($r))!==false){
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
mysql_query("update users set creditsingame = '0' WHERE id = '".$gamer_id."'");
$id_in_game = $i+1;
$role = $roles[$i];
$mmsg = "Вы $role!";
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='".$gamer_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$gamer_id=intval($gamer_id);
mysql_query("update $ringame set role = '".$role."', id_in_game = '".$id_in_game."' WHERE gamer_id = '".$gamer_id."'");
$i++;
}
$mmsg = 'Раздача ролей окончена! Ночь начнется через 20 секунд!';
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
mysql_query("update $rmafaction set prevprev = '199', prev = '199', current = '200'");
}
}
$smthwr = 0;
$res = mysql_query("Select * from $rmaf order by id desc LIMIT 100");
$kol = mysql_affected_rows();
$lines = mysql_fetch_array($res);
@$topic = $lines["message"];
$topic = str_replace("n","",$topic);
@$msg = str_replace(chr("13"), " ", $msg);
@$msg = str_replace(chr("10"), " ", $msg);
@$msg = str_replace("\n", " ", $msg);
@$msg = trim(" $msg ");
if(@$msg){
$msg = iconv('utf-8', 'windows-1251', $msg);
$msg = substr($msg,0,400);
$msg = iconv('windows-1251', 'utf-8', $msg);
$msg = ereg_replace(" +"," ",$msg);
$msg = str_replace("", " ", $msg);
$msg = strtr($msg,array(chr("0")=>"",chr("1")=>"",chr("2")=>"",chr("3")=>"",chr("4")=>"",chr("5")=>"",chr("6")=>"",chr("7")=>"",chr("8")=>"",chr("9")=>"",chr("10")=>"",chr("11")=>"",chr("12")=>"",chr("13")=>"",chr("14")=>"",chr("15")=>"",chr("16")=>"",chr("17")=>"",chr("18")=>"",chr("19")=>"",chr("20")=>"",chr("21")=>"",chr("22")=>"",chr("23")=>"",chr("24")=>"",chr("25")=>"",chr("26")=>"",chr("27")=>"",chr("28")=>"",chr("29")=>"",chr("30")=>"",chr("31")=>""));
$msg = str_replace("�","ё",$msg);
$msg = htmlspecialchars($msg);
$msg = str_replace("')", "' )", $msg);
$msg = str_replace(" )", " )", $msg);
$msg = str_replace("")", "" )", $msg);
$msg = str_replace("©)", "© )", $msg);
$msg = str_replace("®)", "® )", $msg);
$msg = str_replace("™)", "™ )", $msg);
$msg = str_replace("€)", "€ )", $msg);
$msg = str_replace("£)", "£ )", $msg);
$msg = str_replace("„)", "„ )", $msg);
$msg = str_replace("“)", "“ )", $msg);
$msg = str_replace("«)", "« )", $msg);
$msg = str_replace("»)", "» )", $msg);
$msg = str_replace(">)", "> )", $msg);
$msg = str_replace("<)", "< )", $msg);
$msg = str_replace("≥)", "≥ )", $msg);
$msg = str_replace("≤)", "≤ )", $msg);
$msg = str_replace("≈)", "≈ )", $msg);
$msg = str_replace("≠)", "≠ )", $msg);
$msg = str_replace("≡)", "≡ )", $msg);
$msg = str_replace("§)", "§ )", $msg);
$msg = str_replace("&)", "& )", $msg);
$msg = str_replace("∞)", "∞ )", $msg);
$msg = str_replace(""", """, $msg);
$msg = str_replace("|", "¦", $msg);
$msg = str_replace("'", "‘", $msg);
$msg = str_replace("\", "", $msg);
$msg = addslashes($msg);
if (!isset($prvt)) $prvt = 0;
$str1="";
$str2=$msg;
if ($row['translit']==1){
$r = mysql_query("select * from users WHERE id = '".$towhom."'");
$a = mysql_fetch_array($r);
if (strpos($msg,$a['user'])===0){
$str1 = substr($msg,0,strlen($a['user']));
$str2 = substr($msg,strlen($a['user']),strlen($msg)-strlen($a['user']));
$msg = $str2;
}
}
if ($prvt == 0) $towhom = "";
if (!isset($towhom)) $towhom = "";
require("smile.php");
$minpos = 500;$nm = 500;
for ($j=0;$j<=count($smiles)-1;$j++){
$tmpp = strpos($msg,$smiles[$j]);
if (($tmpp < $minpos)&&($tmpp !== false)){
$minpos = $tmpp;$nm = $j;};
};
if ($minpos !=500){
if ($row['translit']!=1){
$st1 = substr($msg,0,$minpos+strlen($smiles[$nm]));
$st2 = substr($msg,$minpos+strlen($smiles[$nm]),strlen($msg)-strlen($st1));
$st1_wosm = $st1;
$st1 = str_replace($smiles[$nm],$replaces[$nm],$st1);
if (strpos($replaces[$nm],"smile/")!==false) $st1_woasm = $st1_wosm;else $st1_woasm = $st1;
$msg_woasm = $st1.$st2;
$msg_wosm = $st1_wosm.$st2;
$msg = $st1_woasm.$st2;
} else {
$st1 = substr($msg,0,$minpos);
$st2 = substr($msg,$minpos, strlen($smiles[$nm]));
$st3 = substr($msg,$minpos+strlen($smiles[$nm]),strlen($msg)-strlen($st1)-strlen($st2));
$st1 = trun_to_rus($st1);
$st2_wosm = $st2;
$st2 = $replaces[$nm];
if (strpos($replaces[$nm],"smile/")!==false) $st2_woasm = $st2_wosm;else $st2_woasm = $st2;
$st3 = trun_to_rus($st3);
$msg = $st1.$st2_woasm.$st3;
$msg_wosm = $st1.$st2_wosm.$st3;
$msg_woasm = $st1.$st2.$st3;
}
}
else if ($row['translit']==1) $msg = trun_to_rus($msg);
Unset($smiles);
unset($replaces);
if ($row['translit']==0) $msg = eregi_replace("((http://))((([a-z0-9-]+(.[a-z0-9-]+)*(.[a-z;]{2,3}))|(([0-9]{1,3}.){3}([0-9]{1,3})))((/|?)[a-z0-9~#%&'_+=:;?.-]*)*)", "<a href="\0">\3</a>", $msg);
$msg = $str1.$msg;
if ($msg_wosm!='') $msg_wosm = $str1.$msg_wosm;
if ($msg_woasm!='') $msg_woasm = $str1.$msg_woasm;
$msg = $str1.$msg;
if (@$msg_wosm!='') $msg_wosm = $str1.$msg_wosm;
if (@$msg_woasm!='') $msg_woasm = $str1.$msg_woasm;
if($vv!=0){
if(in_array('u', $atr)) $under=1;
if(in_array('b', $atr)) $bold=1;
if(in_array('i', $atr)) $nakl=1;
} else {
if(substr_count($atr, 'u') != 0) $under=1;
if(substr_count($atr, 'b') != 0) $bold=1;
if(substr_count($atr, 'i') != 0) $nakl=1;
}
if (($row['level']>=6) && $bold) $msg = '<b>'.$msg.'</b>';
if (($row['level']>=4) && $under) $msg = '<u>'.$msg.'</u>';
if (($row['level']>=4) && $nakl) $msg = '<i>'.$msg.'</i>';
if (@$msg_wosm!=''){
if (($row['level']>=6) && $bold) $msg_wosm = '<b>'.$msg_wosm.'</b>';
if (($row['level']>=4) && $under) $msg_wosm = '<u>'.$msg_wosm.'</u>';
if (($row['level']>=4) && $nakl) $msg_wosm = '<i>'.$msg_wosm.'</i>';
}
if (@$msg_woasm!=''){
if (($row['level']>=6) && $bold) $msg_woasm = '<b>'.$msg_woasm.'</b>';
if (($row['level']>=4) && $under) $msg_woasm = '<u>'.$msg_woasm.'</u>';
if (($row['level']>=4) && $nakl) $msg_woasm = '<i>'.$msg_woasm.'</i>';
}
$r = mysql_query("SELECT * FROM $rmaf WHERE usid = '".$id."' order by id desc LIMIT 1");
$a = mysql_fetch_array($r);
if ($a["message"] !== $msg){
$time = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$posts = $row['posts'];
$posts++;
mysql_query("Update users set posts='".$posts."', onl='".$time."' where id ='".$id."'");
$hid = $row['inv'];
$kol++;
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$us."', message='".$msg."', messagewosm = '".$msg_wosm."', messagewoasm = '".$msg_woasm."', id='".$time."', towhom='".$towhom."', hid='".$hid."', usid='".$id."', gamemes = '".$gmes."'");
$usmes['time'] = $today;
$usmes['who'] = $us;
$usmes['usid'] = $id;
$usmes['message'] = $msg;
$usmes['messagewosm'] = $msg_wosm;
$usmes['messagewoasm'] = $msg_woasm;
$usmes['id'] = $time;
$usmes['towhom'] = $towhom;
$usmes['gamemes'] = $gmes;
$smthwr = 1;
$r = mysql_query("select * from $rmafaction");
$a = mysql_fetch_array($r);
$action = $a['action'];
if ($action == 'game_night'&&$gmes==1){
$s = str_replace('!','',$msg);
$r = mysql_query("select * from $ringame WHERE id_in_game = '".$s."'");
if (mysql_affected_rows()!==0){
$a = mysql_fetch_array($r);
$id_in_game = $a['id_in_game'];
mysql_query("update $ringame set gamer_act = '".$s."' WHERE gamer_id = '".$id."'");
$wh = get_name_by_id($id_in_game, $rm);
mysql_query("select * from $ringame WHERE gamer_act = '".$s."'");
$sm = mysql_affected_rows();
$mmsg = "$us голосует за $wh!(<b>$sm</b>)";
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
mysql_query("select * from $ringame");
$nm = round(mysql_affected_rows()/3);
$r = mysql_query("select *,count(gamer_act) from $ringame WHERE gamer_act != '' group by gamer_act having count(gamer_act)>'".$nm."'");
$a = mysql_fetch_array($r);
if (mysql_affected_rows() != 0){
$w = $a['gamer_act'];
mysql_query("update $rmafaction set action = 'dvote'");
mysql_query("update $ringame set dvote = '1' WHERE id_in_game = '".$w."'");
$whk = get_name_by_id($w, $rm);
$mmsg = "Жители, вы уверены, что хотите казнить $whk?(!да или !нет) $whk, у вас есть время оправдаться.";
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if ($gmes==1&&$action == "dvote"&&($msg == "!da"||$msg == "!net"||$msg == "!да"||$msg == "!нет")){
$r = mysql_query("select * from $ringame WHERE dvote = '1'");
$a = mysql_fetch_array($r);
$w = $a['id_in_game'];
$whk = get_name_by_id($w, $rm);
if ($msg=='!da'||$msg == '!да'){
mysql_query("update $ringame set wholin = '1' WHERE gamer_id = '".$id."'");
$mmsg = "$us голосует за казнь $whk!";
} else {
mysql_query("update $ringame set wholin = '-1' WHERE gamer_id = '".$id."'");
$mmsg = "$us голосует против казни $whk!";
}
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
mysql_query("select * from $ringame");
$nm = round(mysql_affected_rows()/2-0.5);
mysql_query("select * from $ringame WHERE wholin = '1'");
if (mysql_affected_rows()>$nm){
$tm = time();
mysql_query("update $rmafaction set action = 'game_night', nexttime = '".$tm."', kiked = '1'");
$krole = get_role_by_id($w, $rm);
if ($krole=="мафиози"||$krole=="главарь мафии"){
$krole = role_to_tpadej($krole);
$mmsg = "Наконец-то мирные жители расправились с $krole $whk!!!";
} else {
$krole = role_to_rpadej($krole);
$mmsg = "Жители сами усложнили себе задачу, казнив ни в чем не повинного $krole $whk!";
}
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE (users.id = $ringame.gamer_id)and(id_in_game = '".$w."')");
mysql_query("delete from $ringame WHERE id_in_game = '".$w."'");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$vktr = false;
$r = mysql_query("select count(*) as sm from $ringame");
$a = mysql_fetch_array($r);
$sm = $a['sm'];
mysql_query("select * from $ringame WHERE role = 'главарь мафии'");
if (mysql_affected_rows()==0&&$sm!=0){
$r = mysql_query("select * from $ringame WHERE role = 'мафиози'");
if (mysql_affected_rows()==0){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select role, gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$role = $a['role'];
$gamer_id = $a['gamer_id'];
$gamer_id=intval($gamer_id);
if ($role == "обыватель") mysql_query("update users set creditsingame = creditsingame + 100 WHERE id = '".$gamer_id."'");
else mysql_query("update users set creditsingame = creditsingame + 50 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Игра окончена, победа мирных жителей! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$hourdiff = "".$chasy."";
$timeadjust = ($hourdiff * 60 * 60);
$today=gmdate("H:i",time() + $timeadjust);
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}else{
$a = mysql_fetch_array($r);
$id_in_game = $a['id_in_game'];
$gamer_id = $a['gamer_id'];
mysql_query("update $ringame set role = 'главарь мафии' WHERE id_in_game = '".$id_in_game."'");
$mmsg = 'Теперь вы главарь мафии!';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$gamer_id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if ($vktr!==true){
$r = mysql_query("select count(*) as sm from $ringame");
$a = mysql_fetch_array($r);
if ($a['sm']==2){
mysql_query("select * from $ringame WHERE (role = 'главарь мафии')or(role = 'мафиози')");
if (mysql_affected_rows()==2) $vk = "maf";
if (mysql_affected_rows()==1){
mysql_query("select * from $ringame WHERE (role = 'доктор')or(role = 'комиссар катани')or(role = 'путана')or(role = 'маньяк')");
if (mysql_affected_rows() != 0) $vk = "ni4";else $vk = "maf";
}
}
if ($a['sm']==1){
mysql_query("select * from $ringame WHERE (role = 'главарь мафии')or(role = 'мафиози')");
if (mysql_affected_rows() != 0) $vk = 'maf';
}
if ($a['sm']==0) $vk = 'ni4';
mysql_query("select * from $ringame");
$nm = round(mysql_affected_rows()/2-0.5);
$r = mysql_query("Select count(*) as sm from $ringame WHERE (role='мафиози')or(role='главарь мафии')");
$a = mysql_fetch_array($r);
$sm = $a['sm'];
if ($sm>$nm) $vk = 'maf';
if (isset($vk)){
if ($vk == 'ni4'){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gamer_id = $a['gamer_id'];
mysql_query("update users set creditsingame = creditsingame + 25 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Силы Мафии и мирных жителей равны, ничья! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
if ($vk == 'maf'){
$vktr = true;
mysql_query("update $rmafaction set action = 'nogame'");
$r = mysql_query("select role, gamer_id from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$role = $a['role'];
$gamer_id = $a['gamer_id'];
if ($role == "мафиози"||$role == "главарь мафии")
mysql_query("update users set creditsingame = creditsingame + 50 WHERE id = '".$gamer_id."'");
}
$mmsg = 'Всем хана, победа Мафов! А роли были такие: ';
$r = mysql_query("Select * from $ringame");
while (($a = mysql_fetch_array($r))!==false){
$gnick = get_name_by_id($a['id_in_game'], $rm);
$grole = get_role_by_id($a['id_in_game'], $rm);
$mmsg = $mmsg."<b>$gnick</b> - $grole, ";
}
$mmsg = substr($mmsg,0,strlen($mmsg)-2);
mysql_query("insert into $rscores select gamer_id, creditsingame from $ringame, users WHERE users.id = $ringame.gamer_id");
mysql_query("delete from $ringame");
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$mmsg = 'За эту игру заработали столько очков: ';
$mmes = scores($rm);
$mmsg = $mmsg.$mmes;
$tm = getmicrotime();
$today = date("H:i");
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
}
}
mysql_query("select * from $ringame WHERE wholin = '-1'");
if (mysql_affected_rows()>$nm){
mysql_query("update $rmafaction set action = 'game_night'");
mysql_query("update $ringame set dvote = '0', wholin = '0', gamer_act = ''");
$mmsg = "$whk оправдан!";
$tm = getmicrotime();
$today = date("H:i");
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid = '5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if ($gmes==1&&$action == "game_day"&&$towhom == "5"){
$r = mysql_query("select * from $ringame WHERE gamer_id = '".$id."'");
$a = mysql_fetch_array($r);
$role = $a ['role'];
$gamer_act = $a['gamer_act'];
$state = $a['state'];
if ($role!="обыватель"&&$role!="мафиози"&&$role!="клоун"&&$role!="жена комиссара"){
$s = str_replace("!","",$msg);
$r2 = mysql_query("select * from $ringame WHERE id_in_game = '".$s."'");
if (mysql_affected_rows()==0){
$mmsg = 'Что ж ты мне пишешь!?!?';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}else{
if ($gamer_act==""){
$b = mysql_fetch_array($r2);
$hid = $b['gamer_id'];
$r3 = mysql_query("select * from users WHERE id = '".$hid."'");
$c = mysql_fetch_array($r3);
$gname = $c ['user'];
unset ($c);
unset ($r3);
if ($role == "главарь мафии") {$mmsg = "Заказ на убийство $gname принят!";$rnd = rand(1,3);$re = mysql_query("select night_act from mafia WHERE klu4 = '".$rnd."'");$b = mysql_fetch_array($re);$mmsg1=$b["night_act"];}
if ($role == "комиссар катани"&&strpos($msg,"!!")!==false) {$mmsg = "Заказ на убийство $gname принят!";$s="!".$s;$rnd = rand(1,3);$re = mysql_query("select night_act from komissar WHERE klu4 = '".$rnd."'");$b = mysql_fetch_array($re);$mmsg1=$b["night_act"];}
if ($role == "комиссар катани"&&strpos($msg,"!!")===false) {$mmsg = "Заказ на проверку $gname принят!";$rnd = rand(1,3);$re = mysql_query("select night_act from komissar WHERE klu4 = '".$rnd."'");$b = mysql_fetch_array($re);$mmsg1=$b["night_act"];}
if ($role == "доктор") {$mmsg = "Заказ на лечение $gname принят!";$rnd = rand(1,3);$re = mysql_query("select night_act from doktor WHERE klu4 = '".$rnd."'");$b = mysql_fetch_array($re);$mmsg1=$b["night_act"];}
if ($role == "маньяк") {$mmsg = "Изнасилуем $gname =)";$rnd = rand(1,3);$re = mysql_query("select night_act from maniac WHERE klu4 = '".$rnd."'");$b = mysql_fetch_array($re);$mmsg1=$b["night_act"];}
if ($role == "путана") {$mmsg = "$gname сегодня ночью будет занят)";$rnd = rand(1,3);$re = mysql_query("select night_act from wluha WHERE klu4 = '".$rnd."'");$b = mysql_fetch_array($re);$mmsg1=$b["night_act"];}
if ($role == "бомж") {$mmsg = "Копаемся в карманах $gname";$rnd = rand(1,3);$re = mysql_query("select night_act from bomj WHERE klu4 = '".$rnd."'");$b = mysql_fetch_array($re);$mmsg1=$b["night_act"];}
mysql_query("update $ringame set gamer_act='".$s."' WHERE gamer_id = '".$id."'");
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg1."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}else {
$mmsg = 'Ты уже выбрал жертву!';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
}else if ($role=='клоун'&&$state==0){
$s = str_replace('!','',$msg);
list($g1,$g2) = explode(' ',$s);
mysql_query("select gamer_id from $ringame WHERE (id_in_game='".$g1."')or(id_in_game='".$g2."')");
if (mysql_affected_rows()==2){
mysql_query("update $ringame set gamer_act='".$s."' WHERE gamer_id = '".$id."'");
$r = mysql_query("select id_in_game from $ringame WHERE id_in_game = '".$g1."'");
$a = mysql_fetch_array($r);
$gn1 = get_name_by_id($a['id_in_game'], $rm);
$r = mysql_query("select id_in_game from $ringame WHERE id_in_game = '".$g2."'");
$a = mysql_fetch_array($r);
$gn2 = get_name_by_id($a['id_in_game'], $rm);
$mmsg = "Меняем ролями $gn1 и $gn2!";
$mmsg1 = 'Клоун ходит ночью по улицам и запутывает и без того сложное дело...';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg1."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}else {
$mmsg = 'Что ж ты мне пишешь!?!?!?';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}else if ($role=="жена комиссара"&&$state==1){
$s = str_replace("!","",$msg);
$r = mysql_query("select * from $ringame WHERE id_in_game = '".$s."'");
if (mysql_affected_rows()!=0){
mysql_query("update $ringame set state = '2', gamer_act = '".$s."' WHERE gamer_id = '".$id."'");
$a = mysql_fetch_array($r);
$gn = get_name_by_id($a['id_in_game'], $rm);
$mmsg = "$gn поплатится за смерть комиссара!";
$mmsg1 = 'Жена комиссара вышла из дома мстить за смерть мужа...';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg1."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}else{
$mmsg = 'Что ж ты мне пишешь!?!?!?';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='".$id."', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
$r = mysql_query("select count(*) as nv from $ringame WHERE (role != 'обыватель')and(gamer_act='')");
$a = mysql_fetch_array($r);
if ($a["nv"]==0){
mysql_query("update $rmafaction set action = 'allvoted'");
$mmsg = 'Все, что могло свершиться ночью, свершилось.';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
if ($action == "nogame"&&($msg=="!start"||$msg=="!старт")){
$tm = time()+180;
mysql_query("update $rmafaction set action = 'registration', nexttime = '".$tm."'");
$mmsg = 'Начинается игра "Мафия"! Набор игроков будет продолжаться 3 мин. Для участия введите !reg.';
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
if ($action == "registration"&&($msg=="!reg"||$msg=="!рег")){
mysql_query("select * from $ringame WHERE gamer_id = '".$id."'");
if (mysql_affected_rows()==0){
$mmsg = "$us присоединяется к игре!";
$rnd = rand(10000,99999999);
$tm = time();
mysql_query("insert into $ringame set gamer_id = '".$id."', onl = '".$tm."'");
}else{
$mmsg = "$us выходит из игры!";
mysql_query("delete from $ringame WHERE gamer_id = '".$id."'");
}
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='1'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
}
}
if ($msg == '!stats'||$msg == '!статс'){
$r = mysql_query("select mafcredits from users WHERE id = '".$id."'");
$a = mysql_fetch_array($r);
$cr = $a['mafcredits'];
$mmsg = "$us, у вас на счету $cr кредитов";
$tm = getmicrotime();
$today = date("H:i");
$rnd = rand(0,99999999);
mysql_query("Insert into $rmaf set klu4= '".$rnd."', time='".$today."', who='".$mafiozi."', usid='5', message='".$mmsg."', id='".$tm."', towhom='', gamemes='".$gmes."'");
mysql_query("Update users set posts = posts + 1 WHERE id = '5'");
}
$max = $row['max'];
$avr = $row['avr'];
$time = date("H:i");
$r = mysql_query("select count(readd) as num from zapiski WHERE (idtowhom = '".$id."')and(readd = '0')and(ininc = '1')");
$a = mysql_fetch_array($r);
$inb = $a['num'];
$bind1=$row['bind1'];
$bind2=$row['bind2'];
$bind3=$row['bind3'];
$bind4=$row['bind4'];
ob_start();
if ($vv!=0){
echo head;
echo '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><link rel="stylesheet" type="text/css" href="http://scripts/4at2/style/?s='.$row["style"].'"/>
<title>Чат '.chat_adr.'</title>';
if ($avr!=0) { $avr2=$avr/10;echo "<meta http-equiv="refresh" content="$avr2; url=maf.php?$wp&rm=$rm"/>";}
echo '<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
</head><body>
<div class="d1">
<div class="d0"><b>'.$topic.' ['.$time.']</b></div>';
echo $fsize1;
if ($row["kn_update"]==0) echo "<a href="maf.php?$wp&rm=$rm">Обновить</a>n";
if ($row["kn_say"]==0) echo "<a href="#add">Сказать</a>n";
echo "<a href="mafrules.php?$wp&rm=$rm&mod=1">Правила игры</a>n";
echo "<a href="help.php?$wp&rm=$rm">Помощь</a>n";
if ($row["kn_stats"]==0) echo "<a href="statistik.php?$wp&mod=10maf">TOP 10</a>n";
if ($row["kn_whochat"]==0) echo "<a href="who.php?$wp&rm=$rm">Кто где?</a>n";
$tm = time()-300;$inr=mysql_query("SELECT id FROM maf1 WHERE id >'".$tm."' group by who order by id desc");
$kola = mysql_affected_rows();
if ($row["kn_whoroom"]==0) echo "<a href="mafwho.php?$wp&rm=$rm">Кто тут?(".($kola-1).")</a>n";
if ($row["kn_cabinet"]==0) echo "<a href="cabinet.php?$wp&rm=$rm">Кабинет</a>n";
if ($row['level']>5) echo "<a href="maftopic.php?$wp&rm=$rm">Топик</a>n";
echo '<br/>'.divide;
} else {
echo head;
if ($avr!==0) echo "<card id="maf" title="$topic [$time]" ontimer="maf.php?$wp&rm=$rm"><timer value="$avr"/>n";
else echo "<card id="maf" title="$topic-$time" >n";
if ($row["kn_update"]==0) echo "<do type="options" name="refresh" label="Обновить"><go href="maf.php?$wp&rm=$rm"/></do>n";
if ($row["kn_say"]==0) echo "<do type="options" name="add" label="Сказать"><go href="#add"/></do>n";
echo "<do type="options" name="help" label="Правила игры"><go href="mafrules.php?$wp&rm=$rm&mod=1"/></do>n";
echo "<do type="options" name="help" label="Помощь"><go href="help.php?$wp&rm=$rm"/></do>n";
echo "<do type="options" name="help" label="TOP 10"><go href="statistik.php?$wp&mod=10maf"/></do>n";
if ($row["kn_whochat"]==0) echo "<do type="options" name="who" label="Кто где?"><go href="who.php?$wp&rm=$rm"/></do>n";
$tm = time()-300;$inr=mysql_query("SELECT id FROM maf1 WHERE id >'".$tm."' group by who order by id desc");
$kola = mysql_affected_rows();
if ($row["kn_whoroom"]==0) echo "<do type="options" name="who_room" label="Кто тут?(".($kola-1).")"><go href="mafwho.php?$wp&rm=$rm"/></do>n";
if ($row["kn_cabinet"]==0) echo "<do type="options" name="nastr" label="Кабинет"><go href="cabinet.php?$wp&rm=$rm"/></do>n";
if ($row['level']>5) echo "<do type="options" name="topic" label="Топик"><go href="maftopic.php?$wp&rm=$rm"/></do>n";
echo "<p>";
echo $fsize1;
}
if($inb != 0) echo "<b>Вам пришло письмо <a href="inbox.php?$wp">($inb)</a></b><br/>n";
echo "» <a href="#add" accesskey="$bind1">Сказать</a> ($bind1)<br/>";
echo "» <a href="maf.php?$wp&rm=$rm" accesskey="$bind2">Обновить</a> ($bind2)<br/>---n";
@$total=$kol-1;
$mread = 0;
$i = 0;
if ($smthwr != 0){
$time = time()-30;
mysql_query("select * from $rmaf WHERE (usid = '".$id."')and(id>'".$time."')");
if (mysql_affected_rows()>5&&$row['level']<4){
$kik = time()+60;
$whokik = '[Система]';
$whykik = 'Флуд';
mysql_query("update users set kik = '".$kik."', whokik = '".$whokik."', whykik = '".$whykik."' WHERE id = '".$id."'");
}
$i++;
$date = $usmes['time'];
$name = $usmes['who'];
$usid = $usmes['usid'];
$msg = $usmes['message'];
if ($smset==0&&$usmes['messagewosm']!='') $msg = $usmes['messagewosm'];
if ($smset==2&&$usmes['messagewoasm']!='') $msg = $usmes['messagewoasm'];
$time = $usmes['id'];
$th = $usmes['towhom'];
$gm = $usmes['gamemes'];
if ((!in_array($usid, $ignor))&&($gmes==0||($gmes==1&&$gm==1))){
if ($th == '') {
$msg = str_replace($us.',', '<b>'.$us.'</b>,', $msg);
echo "<br/><b><a href="mafinside.php?$wp&nk=$usid&rm=$rm">$name</a></b> [$date]>$msg";$mread++;
}
else if (($th == $id)||($id == $usid))
{
$msg = str_replace($us.',', '<b>'.$us.'</b>,', $msg);
echo "<br/><b><a href="mafinside.php?$wp&nk=$usid&rm=$rm">$name</a>[P!]</b> [$date]>$msg";$mread++;
}
}
}
while (($mread < $max)&&($i<$total)){
$lines = mysql_fetch_array($res);
$date = $lines['time'];
$name = $lines['who'];
$usid = $lines['usid'];
$msg = $lines['message'];
$gm = $lines['gamemes'];
if ($smset==0&&$lines['messagewosm']!='') $msg = $lines['messagewosm'];
if ($smset==2&&$lines['messagewoasm']!='') $msg = $lines['messagewoasm'];
$time = $lines['id'];
$th = $lines['towhom'];
$hid = $lines['hid'];
$i++;
if ((!in_array($usid, $ignor))&&(($hid != 2)||($id == $usid))&&($gmes==0||($gmes==1&&$gm==1)))
{
if ($th == ''){
$msg = str_replace($us, '<b>'.$us.'</b>', $msg);
echo "<br/><b><a href="mafinside.php?$wp&nk=$usid&rm=$rm">$name</a></b> [$date]>$msg";$mread++;
}
else if (($th == $id)||($id == $usid))
{
$msg = str_replace($us, '<b>'.$us.'</b>', $msg);
echo "<br/><b><a href="mafinside.php?$wp&nk=$usid&rm=$rm">$name</a>[P!]</b> [$date]>$msg";$mread++;
}
}
}
$page_next = $max;
echo '<br/>---';
if ($max < $total)
{
echo "<br/>» <a href="mafhist.php?$wp&rm=$rm&num=$page_next" accesskey="$bind3">История</a> ($bind3)n";
}
echo "<br/>» <a href="enter.php?$wp" accesskey="$bind4">Выйти</a> ($bind4)<br/>n";
echo $fsize2;
if ($vv!=1)echo '</p></card><card id="add" title="Написать"><p>';
else {
echo "<form action="maf.php?$wp&rm=$rm" method="post">";
echo $fsize1.divide.'<a name="add">Сказать:</a><br/>'.$fsize2;
}
echo "<input name="msg$ref" maxlength="200" title="Text"/><br/>n";
if ($row['level']>=4){
if ($vv!=0){
echo $fsize1;
if ($row['level']>=6) echo '<input name="atr[]" type="checkbox" value="b"/>Жирный<br/>';
echo '<input name="atr[]" type="checkbox" value="u"/>Подчеркнутый<br/>';
echo '<input name="atr[]" type="checkbox" value="i"/>Курсив<br/>';
echo $fsize2;
} else {
echo '<select name="atr" multiple="true">';
if ($row['level']>=6) echo '<option value="b">Жирный</option>';
echo '<option value="u">Подчеркнутый</option>';
echo '<option value="i">Курсив</option>';
echo '</select><br/>';
}
}
if ($vv!=0){
echo "<input class="ibutton" type="submit" accesskey="$bind1" value="Сказать ($bind1)"/><br/></form>";
echo $fsize1;
} else {
echo $fsize1;
echo "<anchor accesskey="$bind1" title="send">Сказать<go href="maf.php?$wp&rm=$rm" method="post">n";
echo "<postfield name="msg" value="$(msg$ref)"/>n";
if($level>=4) echo "<postfield name="atr" value="$(atr)"/>";
if ($row['translit']==1) {
echo "<postfield name="translit" value="1"/>n";
}else if ($row['translit']==0){
echo "<postfield name="translit" value="0"/>n";
}
echo '</go></anchor> ('.$bind1.')<br/>';
}
if ($vv==0) echo "» <a href="maf.php?$wp&rm=$rm">В игру</a>n";
echo $fsize2;
echo foot;
$alltraf=$row['alltraf'];
$alltraf=$alltraf+$pagesize;
mysql_query("Update users set alltraf='".$alltraf."', lasttraf='".$pagesize."' where id='".$id."'");
mysql_close ($link);
ob_end_flush();
?>