game/modules_data/_alhp.php

344 lines
17 KiB
PHP
Raw Normal View History

2023-01-28 02:24:37 +00:00
<?php
2023-07-31 17:06:51 +00:00
/* @var $u User */
2023-07-11 16:28:47 +00:00
use Core\Config;
2023-06-23 14:44:24 +00:00
use Core\Db;
use Model\EkrExchangeRates;
2023-07-11 16:28:47 +00:00
use User\UserIp;
2023-01-28 02:24:37 +00:00
if (!defined('GAME')) {
die();
2022-06-06 21:30:34 +00:00
}
?>
2023-01-28 02:24:37 +00:00
<script>
let elem = document.getElementById('se-pre-con');
elem.parentNode.removeChild(elem);
2022-06-06 21:30:34 +00:00
2023-01-28 02:24:37 +00:00
function openMod(title, dat) {
2023-06-11 11:51:42 +00:00
const d = document.getElementById('useMagic');
if (!d) {
return;
2023-01-28 02:24:37 +00:00
}
2023-06-11 11:51:42 +00:00
document.getElementById('modtitle').innerHTML = '<table width="100%" border="0" cellspacing="0" cellpadding="0"><tr><td valign="top">' + title + '</td><td width="30" valign="top"><div align="right"><a title="Закрыть окно" onClick="closeMod(); return false;" href="#">x</a></div></td></tr></table>';
document.getElementById('moddata').innerHTML = dat;
d.style.display = '';
2023-01-28 02:24:37 +00:00
}
function closeMod() {
2023-06-11 11:51:42 +00:00
const d = document.getElementById('useMagic');
if (!d) {
return;
2023-01-28 02:24:37 +00:00
}
2023-06-11 11:51:42 +00:00
document.getElementById('modtitle').innerHTML = '';
document.getElementById('moddata').innerHTML = '';
d.style.display = 'none';
2023-01-28 02:24:37 +00:00
}
</script>
<script src='<?= Config::img() ?>/js/commoninf.js'></script>
2023-01-28 02:24:37 +00:00
<style>
.modpow {
background-color: #ddd5bf;
2023-06-23 14:44:24 +00:00
border: solid 1px #776f59;
position: absolute;
left: 50px;
top: 186px;
2023-01-28 02:24:37 +00:00
}
.mt {
background-color: #b1a993;
padding: 5px 10px;
}
.md {
padding: 10px;
}
</style>
2023-06-23 14:44:24 +00:00
<div id="useMagic" style="display:none;" class="modpow">
2023-01-28 02:24:37 +00:00
<div class="mt" id="modtitle"></div>
<div class="md" id="moddata"></div>
</div>
2023-06-23 14:44:24 +00:00
<div style="text-align: right;">
<INPUT TYPE="button" onclick="location.href='main.php?alhp=1';" class="btn" value="Обновить" title="Обновить">
<INPUT TYPE="button" onclick="location.href='main.php';" class="btn" value="Вернуться" title="Вернуться">
</div>
2023-01-28 02:24:37 +00:00
<?php
$exchangeToday = new EkrExchangeRates();
2023-07-11 16:28:47 +00:00
$ba = Db::getRow('select * from bank_alh where uid = ?', [$u->info['id']]);
2023-01-28 02:24:37 +00:00
if (isset($ba['id'])) {
?>
2023-07-11 16:28:47 +00:00
<table style="width: 320px;">
2023-01-28 02:24:37 +00:00
<tr>
<td>
<h4>На алхимических счетах:</h4>
<b><?= $ba['ekr'] ?></b> ЕКР
<hr/>
<?php
$ucur = round($exchangeToday->oneEkrInUSD() / 100 * (100 - $ba['procent']), 2);
2023-01-28 02:24:37 +00:00
?>
Персональный курс: <b><?= $ucur ?></b> $ = 1 Еврокредит.
<hr/>
<form method="post" action="/main.php?alhp=1">
2023-01-28 02:24:37 +00:00
<?php
if (isset($_POST['buy_ekr'])) {
2023-07-11 16:28:47 +00:00
$uba = Db::getRow('select * from users where login = ? and banned = 0', [$_POST['buy_ekr']]);
2023-01-28 02:24:37 +00:00
$uba['uid'] = $uba['id'];
if (isset($uba['id'])) {
echo 'Покупатель: ' . $u->getLogin($uba['uid']) . '<br>';
2023-01-28 02:24:37 +00:00
} else {
2023-07-11 16:28:47 +00:00
echo '<span style="color: red;">Персонаж заблокирован, либо не найден.</span><hr>';
2023-01-28 02:24:37 +00:00
unset($_POST['buy_ekr']);
}
echo '<hr>';
if (isset($uba['id'])) {
$_POST['buy4ekr'] = round($_POST['buy4ekr'], 2);
$bns = [
[0, 0, 0],
[10, 1, 0],
[50, 2, 0],
[100, 3, 0],
[200, 4, 0],
[300, 5, 0],
[400, 6, 0],
[500, 7, 0],
[600, 8, 0],
[700, 9, 0],
[800, 10, 0],
[900, 11, 0],
[1000, 13, 1],
[1100, 15, 2],
[1200, 17, 3],
[1300, 19, 4],
[1500, 21, 5],
[1700, 23, 6],
[2000, 25, 7],
[2500, 27, 8],
[3000, 30, 9],
];
$bns2 = [
[0, 0],
[10, 10],
[20, 10],
[30, 10],
[40, 10],
[50, 10],
[60, 10],
[70, 10],
[80, 10],
[90, 10],
[100, 20],
];
2023-07-11 16:28:47 +00:00
$ball = Db::getValue('select sum(ekr) from pay_operation where uid = ? and good > 0', [$uba['id']]);
2023-01-28 02:24:37 +00:00
$i = 0;
while ($i < count($bns)) {
if (isset($bns[$i][0]) && $ball > $bns[$i][0]) {
$b1 = $i;
}
$i++;
}
$i = 0;
while ($i < count($bns2)) {
if (isset($bns2[$i][0]) && $_POST['buy4ekr'] >= $bns2[$i][0]) {
$b2 = $i;
}
$i++;
}
//Бонус опытовый, первичный и накопительный
$out_ekr = $_POST['buy4ekr'];
$out_ekr0 = $_POST['buy4ekr'];
//
$out_ekr += round($out_ekr0 / 100 * $bns[$b1][1], 2);
$i = 0;
while ($i < count($bns2)) {
if (isset($bns2[$i][0]) && $out_ekr >= $bns2[$i][0]) {
$b2_2 = $i;
}
$i++;
}
$out_ekr += round($out_ekr0 / 100 * $bns2[$b2_2][1], 2);
if ($ball == 0) {
$out_ekr += round($out_ekr0 / 100 * 20, 2);
}
if (isset($_POST['buy4ekr']) && $_POST['buy4ekr'] < 0.01) {
2023-07-11 16:28:47 +00:00
echo '<span style="color: red;">Минимальная сумма продажи: 0.01 екр.</span><hr>';
2023-01-28 02:24:37 +00:00
unset($_POST['buy4ekr']);
} elseif ($_POST['buy4ekr'] > $ba['ekr']) {
2023-07-11 16:28:47 +00:00
echo '<span style="color: red;">Недостаточно средств на счете</span><hr>';
2023-01-28 02:24:37 +00:00
unset($_POST['buy4ekr']);
}
if (isset($_POST['buygoodluck'])) {
echo '<script>alert("Продажа на сумму ' . $_POST['buy4ekr'] . ' екр. была совершена успешно!");location.href="main.php?alhp=1";</script>';
$ba['ekr'] -= $_POST['buy4ekr'];
$ba['USD'] += round($_POST['buy4ekr'] * $ucur, 2);
2023-07-11 16:28:47 +00:00
Db::sql('update bank_alh set ekr = ?, USD = ? where id = ?', [$ba['ekr'], $ba['USD'], $ba['id']]);
$u->addEkr($out_ekr, $uba['id']);
2023-01-28 02:24:37 +00:00
$money = round($_POST['buy4ekr'] * $exchangeToday->oneEkrInRUB(), 2);
2023-01-28 02:24:37 +00:00
$money = round($money / 100 * (100 - $ba['procent']), 2);
2023-07-11 16:28:47 +00:00
$user = Db::getRow('select id, login, city, sex, room, host_reg from users where id = ?', [$uba['uid']]);
Db::sql('insert into pay_operation (uid, ekr, time, good, var, ref, ref2) values (?,?,unix_timestamp(),unix_timestamp(),?,?,0)',
[$uba['id'], $_POST['buy4ekr'], 'buy_ekr_alh' . $u->info['id'], $uba['host_reg']]);
2023-01-28 02:24:37 +00:00
$r = '<span class=date>' . date(
'd.m.Y H:i'
2023-06-23 14:44:24 +00:00
) . '</span> <img src="' . Config::img() . '/i/align/align50.gif" alt="Алхимик"><u> Алхимик <b>' . $u->info['login'] . '</b></u> сообщает: ';
2023-01-28 02:24:37 +00:00
if ($user['sex'] == 1) {
$r .= 'Уважаемая';
} else {
$r .= 'Уважаемый';
}
$bnss = '';
if (($out_ekr - round((int)$_POST['buy4ekr'], 2)) > 0) {
$bnss = ' (+' . ($out_ekr - round((int)$_POST['buy4ekr'], 2)) . ' ЕКР бонус!)';
}
2023-07-11 16:28:47 +00:00
$r .= ' <b>' . $user['login'] . '</b>, вам зачислено ' . $_POST['buy4ekr'] . ' ЕКР' . $bnss . '. Благодарим Вас за покупку!';
2023-01-28 02:24:37 +00:00
$cmsg = new ChatMessage();
$cmsg->setCity($user['city']);
$cmsg->setRoom($user['room']);
$cmsg->setTo($user['login']);
$cmsg->setType(5);
$cmsg->setText($r);
(new Chat())->sendMsg($cmsg);
2023-07-11 16:28:47 +00:00
$text_msg = 'Алхимик <b>' . $u->info['login'] . '</b> совершил продажу <b>' .
$_POST['buy4ekr'] . '</b> ЕКР. (скидка ' . $ba['procent'] . '% , задолжность ' . $ba['USD'] . '$). Покупатель: ' . $u->getLogin($uba['uid']) . '.</b>.';
2023-01-28 02:24:37 +00:00
2023-07-11 16:28:47 +00:00
$balance = Db::getValue('select sum(money) from balance_money where cancel = 0');
$balance += $money;
Db::sql('insert into balance_money (time, money, ip, comment2, balance, cancel) values (unix_timestamp(),?,?,?,?,unix_timestamp())',
[$money, UserIp::get(), $text_msg, $balance]);
2023-01-28 02:24:37 +00:00
//Рейтинг по вкладам
$ub = [];
$ui = [];
2023-07-11 16:28:47 +00:00
$sp = Db::getRows('select * from pay_operation where good > 0 order by id desc');
foreach ($sp as $pl) {
if (empty($ub[$pl['uid']])) {
2023-01-28 02:24:37 +00:00
$ui[] = $pl['uid'];
}
$ub[$pl['uid']][date('d.m.Y', $pl['good'])] = $pl['ekr'];
}
2023-07-11 16:28:47 +00:00
2023-01-28 02:24:37 +00:00
$i = 0;
while ($i < count($ui)) {
2023-07-11 16:28:47 +00:00
if (!isset($ui[$i])) {
$i++;
continue;
}
$j = 1;
$k = 0;
$nj = 0;
while ($j <= 1000) {
$dt = date('d.m.Y', time() - (86400 * $j));
if (isset($ub[$ui[$i]][$dt])) {
$k++;
$nj = 0;
} elseif ($j > 0 && $nj >= 6) {
$j = 1000;
} else {
$nj++;
2023-01-28 02:24:37 +00:00
}
2023-07-11 16:28:47 +00:00
$j++;
2023-01-28 02:24:37 +00:00
}
2023-07-11 16:28:47 +00:00
Db::sql('replace into users_paybonus (id, level) values (?,?)', [$ui[$i], $k]);
2023-01-28 02:24:37 +00:00
$i++;
}
} else {
echo 'Сумма екр.:';
if (!isset($_POST['buy4ekr'])) {
2023-07-11 16:28:47 +00:00
echo '&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; <input name="buy4ekr" style="width:50px;" value="0.00" />
<input class="btn btn-danger" value="Далее" type="submit"><br>';
2023-01-28 02:24:37 +00:00
} else {
2023-07-11 16:28:47 +00:00
echo ' <b>' . round((int)$_POST['buy4ekr'], 2) . '</b> ЕКР +
<b>' . ($out_ekr - round((int)$_POST['buy4ekr'], 2)) . '</b> ЕКР бонус.
<input name="buy4ekr" type="hidden" value="' . $_POST['buy4ekr'] . '">';
2023-01-28 02:24:37 +00:00
echo ' &nbsp; <br><br><input type="submit" name="buygoodluck" class="btn btn-success" value="Совершить продажу">';
}
}
}
}
2023-07-11 16:28:47 +00:00
if (isset($_POST['buy_ekr'])) { ?>
<input name="buy_ekr" type="hidden" value="<?= $_POST['buy_ekr'] ?>"/>
<?php } else { ?>Перести екр. персонажу:
<input name="buy_ekr" style="width:50px;" value="<?= $_POST['buy_ekr'] ?>"/>
<input class="btn btn-danger" value="Далее" type="submit"/>
<?php } ?>
2023-01-28 02:24:37 +00:00
</form>
</td>
</tr>
</table>
<?php
2022-06-06 21:30:34 +00:00
}
2023-01-10 16:29:32 +00:00
echo "<br><h4><div align=left>Необходимые средства в работе алхимика</div></h4>";
2022-06-06 21:30:34 +00:00
$p['m1'] = 1;
2023-01-28 02:24:37 +00:00
$srok = [15 => '15 минут', 30 => '30 минут', 60 => 'один час', 180 => 'три часа', 360 => 'шесть часов', 720 => 'двенадцать часов', 1440 => 'одни сутки', 4320 => 'трое суток'];
2023-06-11 11:51:42 +00:00
if (isset($_GET['usemod']) && isset($_POST['usem1'])) {
require_once('moder/usem1.php');
2023-01-28 02:24:37 +00:00
}
if (isset($_POST['tologin'], $_POST['message'])) {
$cmsg = new ChatMessage();
$cmsg->setRoom(1);
$cmsg->setTo($_POST['tologin']);
2023-06-11 11:51:42 +00:00
$cmsg->setText(
'<span style="color: darkblue; ">Сообщение телеграфом от </span> <b>' . $u->info['login'] . '</b>: ' . $_POST['message']
);
$cmsg->setType(6);
(new Chat())->sendMsg($cmsg);
2022-06-06 21:30:34 +00:00
}
?>
2023-01-28 02:24:37 +00:00
<table>
<a href="#"
2023-07-11 16:28:47 +00:00
onClick="openMod('<b>Заклятие молчания</b>','<form action=\'main.php?<?= 'alhp&usemod=' . PassGen::intCode(); ?>\' method=\'post\'>Логин персонажа: <input type=\'text\' style=\'width:144px;\' id=\'logingo\' name=\'logingo\'><br>Время заклятия: &nbsp; <select style=\'margin-left:2px;\' name=\'time\'><option value=\'1440\'>Сутки</option></select> <input type=\'submit\' name=\'usem1\' value=\'Исп-ть\'></form>');"><img
src="<?= Config::img() ?>/i/items/sleep.gif" title="Заклятие молчания"/></a>
2023-01-28 02:24:37 +00:00
&nbsp;
<br><h4>Телеграф</h4>
2023-06-11 11:51:42 +00:00
<form method=post style="margin:5px;">
Логин персонажа <input type=text size=20 name="tologin">
сообщение <input type=text size=80 name="message">
&nbsp; <input type=submit class="btn btn-success" value="отправить">
</form>
2023-01-28 02:24:37 +00:00
<?php
2023-01-10 16:29:32 +00:00
echo '<br><h2>Список реальщиков:</h2><br>';
2023-07-11 16:28:47 +00:00
$sp = Db::getRows('select * from pay_operation where good > 0 group by uid');
foreach ($sp as $pl) {
$online = Db::getValue('select online from users where id = ?', [$pl['uid']]);
$lg = $u->getLogin($pl['uid']);
2023-06-23 14:44:24 +00:00
if ($online > time() - 240) {
$lg = '<span style="color: green;">' . $lg . '</span>';
} else {
$lg .= ' (был тут ' . date('d.m.Y H:i', $online) . ')';
}
if ($u->info['admin'] > 0) {
$sum = Db::getValue('select sum(ekr) from pay_operation where good > 0 and uid = ?', [$pl['uid']]);
echo $lg . ' - ' . $sum . ' екр.<br>';
} else {
echo $lg . '<br>';
2023-01-28 02:24:37 +00:00
}
2022-06-06 21:30:34 +00:00
}