include('../config.php');
function add_trv($id) {
$user = mysql_fetch_array(mysql_query("SELECT `align`, `level` FROM `users` WHERE `id` = '{$id}' LIMIT 1"));
$travmalist = array("пробитый череп","разрыв селезенки","смещение позвонков","открытый перелом руки","открытый перелом <вырезано цензурой>","излом носоглотки","непонятные, но множественные травмы","сильное внутреннее кровотечение","раздробленная коленная чашечка","перелом шеи","смещение позвонков","открытый перелом ключицы","перелом позвоночника","вывих позвоночника","сотрясение третьей степени");
$zz = mt_rand(1, 3); $s = 0; $l = 0; $i = 0;
switch($zz) {
case 1: $s = ($user['level'] + 3)*3; break;
case 2: $l = ($user['level'] + 3)*3; break;
case 3: $i = ($user['level'] + 3)*3; break;
}
$trv = $travmalist[mt_rand(0, count($travmalist)-1)];
$time = 60*15;
mysql_query("INSERT INTO `effects` (`owner`, `name`, `time`, `type`, `sila`, `lovk`, `inta`, `vinos`) values ('".$id."', 'Травма "".$trv.""', ".(time()+$time).", '14', '".$s."', '".$l."', '".$i."', '0')");
mysql_query("UPDATE `users` SET `sila` = (`sila`-'".$s."'), `lovk` = (`lovk`-'".$l."'), `inta` = (`inta`-'".$i."') WHERE `id` = '".$id."' LIMIT 1");
}
function paginate_function($item_per_page, $current_page, $total_records, $total_pages) {
$pagination = '';
if($total_pages > 0 && $total_pages != 1 && $current_page <= $total_pages) {
$pagination .= '
';
}
return $pagination;
}
function login($uid) {
$user = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `align`, `level`, `klan` FROM `users` WHERE `id` = "'.mysql_real_escape_string($uid).'" LIMIT 1'));
if(isset($user['id'])) {
$align_img = ' ';
if($user['klan'] != '') {
$clan = mysql_fetch_array(mysql_query('SELECT `id`, `name` FROM `clans` WHERE `id` = "'.$user['klan'].'" LIMIT 1'));
$clan_img = ' ';
} else {
$clan_img = '';
}
$r = $align_img.$clan_img.' '.$user['login'].' ['.$user['level'].']';
} else {
$r = 'Невидимка';
}
return $r;
}
function load_winers($sum, $hash) {
if($sum > 0) {
$limit = 'LIMIT '.(int)$sum;
} else {
$limit = '';
}
$r = 'Список, кому удалось достать монетки :';
$r .= 'Кто | Раз | Когда | Всего кр. |
';
$sp = mysql_query('SELECT `id`, `usid`, `money`, `time`, `count` FROM `fountain_game` ORDER BY `id` DESC '.$limit.'');
while($pl = mysql_fetch_array($sp)) {
$us = mysql_fetch_array(mysql_query('SELECT `id` FROM `users` WHERE `id` = "'.$pl['usid'].'" LIMIT 1'));
$tm = date('d.m.y h:i:s', $pl['time']);
if($i == 0) {
$i = 1; $color = '#eeeeee';
} else {
$i = 0; $color = '#e7e7e7';
}
$user = login($us['id']);
$r .= ''.$user.' | '.$pl['count'].' | '.$tm.' | '.$pl['money'].' |
';
}
$r .= '
';
$r .= '';
unset($pl, $us, $tm, $user);
return $r;
}
function send_wish($hash, $text, $uid) {
if(isset($uid) && $uid > 0) {
if(isset($text)) {
if(strlen($text) < 5) {
echo "";
} elseif(strlen($text) > 50) {
echo "";
} else {
$us = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `level`, `align` FROM `users` WHERE `id` = "'.(int)$uid.'" LIMIT 1'));
if(isset($us['id'])) {
if(md5($us['login'].'|'.$us['id']) == $hash) {
$txt = mysql_real_escape_string($text);
if(iconv("utf-8", "utf-8", $txt) != '') {
$addText = iconv("utf-8", "utf-8", $txt);
}
mysql_query('INSERT INTO `fontan_wish` (`uid`, `time`, `wish`) VALUES ("'.$us['id'].'", "'.time().'", "'.$addText.'")');
echo "";
} else {
echo "";
}
} else {
echo "";
}
}
} else {
echo "";
}
} else {
echo "";
}
}
function cureHps($hash, $uid) {
if(isset($uid) && $uid > 0) {
$us = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `align`, `level`, `hp`, `maxhp` FROM `users` WHERE `id` = "'.(int)$uid.'" LIMIT 1'));
if(isset($us['id'])) {
if(md5($us['login'].'|'.$us['id']) == $hash) {
if(($us['level'] <= 7 || $us['align'] == 2.99) && $us['hp'] < $us['maxhp']) {
$us['hp'] = $us['maxhp'];
mysql_query('UPDATE `users` SET `hp` = "'.$us['hp'].'" WHERE `id` = "'.$us['id'].'" LIMIT 1');
echo "";
} elseif($us['hp'] == $us['maxhp']) {
echo "";
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
}
function giveCoin($hash, $uid) {
if(isset($uid) && $uid > 0) {
$us = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `align`, `level`, `money` FROM `users` WHERE `id` = "'.(int)$uid.'" LIMIT 1'));
if(isset($us['id'])) {
if(md5($us['login'].'|'.$us['id']) == $hash) {
if($us['money'] >= 1) {
$us['money'] -= 1;
mysql_query('UPDATE `users` SET `money` = "'.$us['money'].'" WHERE `id` = "'.$us['id'].'" LIMIT 1');
$f = mysql_fetch_array(mysql_query('SELECT `value` FROM `variables` WHERE `var` = "fontan_jackpot" LIMIT 1'));
$f['value'] += 1;
mysql_query('UPDATE `variables` SET `value` = "'.$f['value'].'" WHERE `var` = "fontan_jackpot" LIMIT 1');
mysql_query("INSERT INTO `delo` (`author`, `pers`, `text`, `type`, `date`) VALUES ('0', '{$us['id']}', '\"".$us['login']."\" бросил монетку в фонтан.', 1, '".time()."')");
echo "";
echo "";
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
}
function loadWishs($p, $uid, $hash) {
$admin = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `align` FROM `users` WHERE `id` = "'.$uid.'" LIMIT 1'));
$acces = false; $adimg = '';
if(isset($admin['id'])) {
if($admin['align'] != 2.99) {
$acces = false;
} else {
if(md5($admin['login'].'|'.$admin['id']) == $hash) {
$acces = true;
} else {
$acces = false;
}
}
}
$pgs = mysql_fetch_array(mysql_query("SELECT COUNT(`id`) FROM `fontan_wish`"));
$item_per_page = 15;
$allPages = ceil($pgs[0]/$item_per_page);
$page_position = (($p-1) * $item_per_page);
echo '';
$w = mysql_query("SELECT `id`, `uid`, `time`, `wish` FROM `fontan_wish` ORDER BY `id` DESC LIMIT $page_position, $item_per_page");
while($pl = mysql_fetch_array($w)) {
if($i == 0) {
$i = 1; $color = '#eeeeee';
} else {
$i = 0; $color = '#e7e7e7';
}
if($acces == true) {
$adimg = ' ';
}
$user = login($pl['uid']);
echo ''.$adimg.$user.' | '.$pl['wish'].' |
';
}
echo '
';
echo '
'.paginate_function($item_per_page, $p, $pgs[0], $allPages);
unset($pl, $user);
}
function howMuch() {
$f = mysql_fetch_array(mysql_query('SELECT `value` FROM `variables` WHERE `var` = "fontan_jackpot" LIMIT 1'));
echo $f['value'];
}
function tryGet($hash, $uid) {
if(isset($hash)) {
if($uid > 0) {
$user = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `money` FROM `users` WHERE `id` = "'.(int)$uid.'" LIMIT 1'));
if(isset($user['id'])) {
if(md5($user['login'].'|'.$user['id']) == $hash) {
$travm = mysql_fetch_array(mysql_query('SELECT `id` FROM `effects` WHERE (`type` = "13" OR `type` = "14") AND `owner` = "'.$user['id'].'" LIMIT 1'));
if(isset($travm['id'])) {
echo "";
} else {
$rand = mt_rand(80, 100); $r = mt_rand(0, 100);
$jackpot = mysql_fetch_array(mysql_query('SELECT `value` FROM `variables` WHERE `var` = "fontan_jackpot" LIMIT 1'));
$last = mysql_fetch_array(mysql_query('SELECT `id`, `usid`, `money`, `time`, `count` FROM `fountain_game` WHERE `usid` = "'.$user['id'].'" LIMIT 1'));
if($jackpot['value'] > 0) {
if($r == $rand) {
$user['money'] += $jackpot['value'];
mysql_query('UPDATE `users` SET `money` = "'.$user['money'].'" WHERE `id` = "'.$user['id'].'" LIMIT 1');
mysql_query('UPDATE `variables` SET `value` = 0 WHERE `var` = "fontan_jackpot" LIMIT 1');
if(isset($last['id'])) {
$last['money'] += $jackpot['value']; $last['time'] = time(); $last['count'] += 1;
mysql_query('UPDATE `fountain_game` SET `money` = "'.$last['money'].'", `time` = "'.$last['time'].'", `count` = "'.$last['count'].'" WHERE `id` = "'.$user['id'].'" LIMIT 1');
} else {
mysql_query('INSERT INTO `fountain_game` (`usid`, `time`, `money`, `count`) VALUES ("'.$user['id'].'", "'.time().'", "'.$jackpot['value'].'", "1")');
}
mysql_query("INSERT INTO `delo` (`author`, `pers`, `text`, `type`, `date`) VALUES ('0', '{$user['id']}', '\"".$user['login']."\" достал монетки из фонтана [$jackpot[value]] кр.', 1, '".time()."')");
echo "";
echo "";
echo mysql_error();
} else {
add_trv($user['id']);
echo "";
}
} else {
echo "";
}
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
}
function deleteWishs($id, $uid, $hash) {
if($id > 0) {
if($uid > 0) {
if(isset($hash)) {
$user = mysql_fetch_array(mysql_query('SELECT `id`, `login`, `align` FROM `users` WHERE `id` = "'.(int)$uid.'" LIMIT 1'));
if(isset($user['id'])) {
if($user['align'] == 2.99) {
if(md5($user['login'].'|'.$user['id']) == $hash) {
$text = mysql_fetch_array(mysql_query('SELECT `id` FROM `fontan_wish` WHERE `id` = "'.(int)$id.'" LIMIT 1'));
if(isset($text['id'])) {
mysql_query('DELETE FROM `fontan_wish` WHERE `id` = "'.$text['id'].'" LIMIT 1');
echo "";
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
} else {
echo "";
}
}
if($_GET['do'] == 'load_winers' && $_GET['allList'] == 0) {
echo load_winers(5, $_GET['hash']);
} elseif($_GET['do'] == 'load_winers' && $_GET['allList'] == 1) {
echo load_winers(0, $_GET['hash']);
} elseif($_GET['do'] == 'showPanel') {
echo '';
} elseif($_GET['do'] == 'wish') {
echo send_wish($_GET['hash'], $_GET['tekst'], (int)$_GET['uid']);
} elseif($_GET['do'] == 'cureHps') {
echo cureHps($_GET['hash'], (int)$_GET['uid']);
} elseif($_GET['do'] == 'giveCoin') {
echo giveCoin($_GET['hash'], (int)$_GET['uid']);
} elseif($_GET['do'] == 'loadWishs') {
echo loadWishs((int)$_GET['page'], (int)$_GET['uid'], $_GET['hash']);
} elseif($_GET['do'] == 'howMuch') {
echo howMuch();
} elseif($_GET['do'] == 'tryGet') {
echo tryGet($_GET['hash'], (int)$_GET['uid']);
} elseif($_GET['do'] == 'deleteWishs') {
echo deleteWishs((int)$_GET['id'], (int)$_GET['uid'], $_GET['hash']);
}