battles/_unused-files/fontan_luck.php

340 lines
18 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?
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."', 'Травма &quot;".$trv."&quot;', ".(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 .= '<ul class="pagination">Страницы: ';
$right_links = $current_page + 3;
$previous = $current_page - 3;
$next = $current_page + 1;
$first_link = true;
if($current_page > 1) {
$previous_link = ($previous == 0) ? 1 : $previous;
$pagination .= '<li class="first"><a href="javascript: void(0);" data-page="1">&laquo;</a></li>';
for($i = ($current_page-2); $i < $current_page; $i++) {
if($i > 0) {
$pagination .= '<li><a href="javascript: void(0);" data-page="'.$i.'">'.$i.'</a></li>';
}
}
$first_link = false;
}
if($first_link) {
$pagination .= '<li class="first active">'.$current_page.'</li>';
} elseif($current_page == $total_pages) {
$pagination .= '<li class="last active">'.$current_page.'</li>';
} else {
$pagination .= '<li class="active">'.$current_page.'</li>';
}
for($i = $current_page+1; $i < $right_links ; $i++) {
if($i <= $total_pages) {
$pagination .= '<li><a href="javascript: void(0);" data-page="'.$i.'">'.$i.'</a></li>';
}
}
if($current_page < $total_pages){
$next_link = ($i > $total_pages)? $total_pages : $i;
$pagination .= '<li class="last"><a href="javascript: void(0);" data-page="'.$total_pages.'">&raquo;</a></li>';
}
$pagination .= '</ul>';
}
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 = '<img src="i/align_'.($user['align']?$user['align']:0).'.gif" /> ';
if($user['klan'] != '') {
$clan = mysql_fetch_array(mysql_query('SELECT `id`, `name` FROM `clans` WHERE `id` = "'.$user['klan'].'" LIMIT 1'));
$clan_img = '<img title="'.$clan['name'].'" src="i/klan/'.$clan['name'].'.gif" /> ';
} else {
$clan_img = '';
}
$r = $align_img.$clan_img.' <b>'.$user['login'].' ['.$user['level'].']</b><a href="http://capitalcity.old-dark.ru/inf.php?id='.$user['id'].'" target="_blank"><img src="http://capitalcity.old-dark.ru/i/inf.gif" /></a>';
} else {
$r = 'Невидимка';
}
return $r;
}
function load_winers($sum, $hash) {
if($sum > 0) {
$limit = 'LIMIT '.(int)$sum;
} else {
$limit = '';
}
$r = '<center>Список, кому удалось достать монетки :';
$r .= '<table width="50%" border="1" style="border-collapse: collapse; border: 1px solid #b0b0b0;"><tbody><tr><td style="padding-left: 5px;">Кто</td><td style="text-align: center;">Раз</td><td style="text-align: center;">Когда</td><td style="text-align: center;">Всего кр.</td></tr>';
$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 .= '<tr bgcolor="'.$color.'"><td style="padding-left: 5px;">'.$user.'</td><td style="text-align: center;">'.$pl['count'].'</td><td style="text-align: center;">'.$tm.'</td><td style="text-align: center;">'.$pl['money'].'</td></tr>';
}
$r .= '</tbody></table>';
$r .= '<div id="fullwinnerslistlinkbox"><table><tbody><tr><td align="center" valign="middle"><font face="monospace" size="4">v</font><a href="javascript: void(0)" onclick="$(\'#monetWinnersBox\').load(\'/ajax/fontan_luck.php?do=load_winers&hash='.$hash.'&allList=1\', function(){ $(\'#fullwinnerslistlinkbox\').remove(); })">полный список</a><font face="monospace" size="4">v</font></td></tr></tbody></table></div></center>';
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 "<script>growl('Внимание', 'Red', 'Не менее 5 букв в Желании');</script>";
} elseif(strlen($text) > 50) {
echo "<script>growl('Внимание', 'Red', 'Не более 50 букв в Желании');</script>";
} 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 "<script>growl('Внимание', 'Red', 'Ваше желание записано!'); $('#wishFormBox').toggle(); load_wishs(1);</script>";
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
}
} else {
echo "<script>growl('Внимание', 'Red', 'Введите текст Желания');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
}
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 "<script>growl('Внимание', 'Red', 'Вы, Испили Водички.');</script>";
} elseif($us['hp'] == $us['maxhp']) {
echo "<script>growl('Внимание', 'Red', 'Ваши силы и так полны.');</script>";
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не можете Испить Водички, уровень слишком высок');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
}
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 "<script>growl('Внимание', 'Red', 'Вы бросили монетку в Фонтан.<br />Монет в фонтане : $f[value] шт.');</script>";
echo "<script>howMuch();</script>";
} else {
echo "<script>growl('Внимание', 'Red', 'Недостаточно средств');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
}
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 '<table border="0" style="border-collapse: collapse; border: 1px solid #b0b0b0;" width="100%"><tbody>';
$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 = '<img src="i/clear.gif" id="'.$pl['id'].'" class="deleted" /> ';
}
$user = login($pl['uid']);
echo '<tr bgcolor="'.$color.'"><td>'.$adimg.$user.'</td><td>'.$pl['wish'].'</td></tr>';
}
echo '</tbody></table>';
echo '<br />'.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 "<script>growl('Внимание', 'Red', 'Вы травмированы<br />Воздержитесь от попыток достать монетки.');</script>";
} 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 "<script>growl('Внимание', 'Red', 'Вы достали монетки со дна!');</script>";
echo "<script>howMuch(); load_winers();</script>";
echo mysql_error();
} else {
add_trv($user['id']);
echo "<script>growl('Внимание', 'Red', 'Вам не далось достать монетки. Вы были травмированы.');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Фонтан пуст.');</script>";
}
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
}
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 "<script>growl('Внимание', 'Red', 'Удаленно'); load_wishs(1);</script>";
} else {
echo "<script>growl('Внимание', 'Red', 'Что удаляем?');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Недостаточно прав');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Вы не авторизированы');</script>";
}
} else {
echo "<script>growl('Внимание', 'Red', 'Что удаляем?');</script>";
}
}
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 '<div id="wishFormBox" style="display: block;"><div style="overflow: hidden; margin: 6px 0;"><small>Не более 50 символов. Монетка тоже бросится</small><br />Я желаю : <input type="text" name="tekst" id="tekst" maxlength="50" size="50"><input type="button" onclick="if($(\'#tekst\').val()!=\'\'){wish($(\'#tekst\').val());}" value="Пусть сбудется!" /></div></div>';
} 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']);
}