Рефакторинг.
This commit is contained in:
parent
b064cb349c
commit
6185c43e00
@ -1,7 +1,10 @@
|
||||
<?php
|
||||
|
||||
/* @var $u User */
|
||||
|
||||
use Core\Config;
|
||||
use Core\Db;
|
||||
use User\UserIp;
|
||||
|
||||
if (!defined('GAME')) {
|
||||
die();
|
||||
@ -64,12 +67,11 @@ if (!defined('GAME')) {
|
||||
|
||||
<?php
|
||||
$pl = Db::getRow('select * from bank_table order by time desc limit 1');
|
||||
$ba = mysql_fetch_array(
|
||||
mysql_query("SELECT * FROM `bank_alh` WHERE `uid` = '" . mysql_real_escape_string($u->info['id']) . "' LIMIT 1")
|
||||
);
|
||||
$ba = Db::getRow('select * from bank_alh where uid = ?', [$u->info['id']]);
|
||||
|
||||
if (isset($ba['id'])) {
|
||||
?>
|
||||
<table width=320>
|
||||
<table style="width: 320px;">
|
||||
<tr>
|
||||
<td>
|
||||
<h4>На алхимических счетах:</h4>
|
||||
@ -83,18 +85,12 @@ if (isset($ba['id'])) {
|
||||
<form method="post" action="main.php?alhp=1">
|
||||
<?php
|
||||
if (isset($_POST['buy_ekr'])) {
|
||||
$uba = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT * FROM `users` WHERE `login` = "' . mysql_real_escape_string(
|
||||
$_POST['buy_ekr']
|
||||
) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$uba = Db::getRow('select * from users where login = ? and banned = 0', [$_POST['buy_ekr']]);
|
||||
$uba['uid'] = $uba['id'];
|
||||
if (isset($uba['id'])) {
|
||||
echo 'Покупатель: ' . $u->microLogin($uba['uid']) . '<br>';
|
||||
} else {
|
||||
echo '<font color=red>Персонаж заблокирован, либо не найден.</font><hr>';
|
||||
echo '<span style="color: red;">Персонаж заблокирован, либо не найден.</span><hr>';
|
||||
unset($_POST['buy_ekr']);
|
||||
}
|
||||
echo '<hr>';
|
||||
@ -140,12 +136,7 @@ if (isset($ba['id'])) {
|
||||
[100, 20],
|
||||
];
|
||||
|
||||
$ball = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT SUM(`ekr`) FROM `pay_operation` WHERE `uid` = "' . $uba['id'] . '" AND `good` > 0 LIMIT 1'
|
||||
)
|
||||
);
|
||||
$ball = 0 + $ball[0];
|
||||
$ball = Db::getValue('select sum(ekr) from pay_operation where uid = ? and good > 0', [$uba['id']]);
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($bns)) {
|
||||
@ -181,47 +172,27 @@ if (isset($ba['id'])) {
|
||||
}
|
||||
|
||||
if (isset($_POST['buy4ekr']) && $_POST['buy4ekr'] < 0.01) {
|
||||
echo '<font color=red>Минимальная сумма продажи: 0.01 екр.</font><hr>';
|
||||
echo '<span style="color: red;">Минимальная сумма продажи: 0.01 екр.</span><hr>';
|
||||
unset($_POST['buy4ekr']);
|
||||
} elseif ($_POST['buy4ekr'] > $ba['ekr']) {
|
||||
echo '<font color=red>Недостаточно средств на счете</font><hr>';
|
||||
echo '<span style="color: red;">Недостаточно средств на счете</span><hr>';
|
||||
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);
|
||||
mysql_query(
|
||||
'UPDATE `bank_alh` SET `ekr` = "' . mysql_real_escape_string(
|
||||
$ba['ekr']
|
||||
) . '",`USD` = "' . mysql_real_escape_string(
|
||||
$ba['USD']
|
||||
) . '" WHERE `id` = "' . $ba['id'] . '" LIMIT 1'
|
||||
);
|
||||
|
||||
mysql_query(
|
||||
'UPDATE `users` SET `money2` = `money2` + ' . mysql_real_escape_string(
|
||||
$out_ekr
|
||||
) . ' WHERE `id` = "' . $uba['id'] . '" LIMIT 1'
|
||||
);
|
||||
|
||||
Db::sql('update bank_alh set ekr = ?, USD = ? where id = ?', [$ba['ekr'], $ba['USD'], $ba['id']]);
|
||||
$u->addEkr($out_ekr, $uba['id']);
|
||||
|
||||
$money = round($_POST['buy4ekr'] * $pl['cur'], 2);
|
||||
$money = round($money / 100 * (100 - $ba['procent']), 2);
|
||||
|
||||
$user = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT `id`,`login`,`city`,`sex`,`room`,`host_reg` FROM `users` WHERE `id` = "' . mysql_real_escape_string(
|
||||
$uba['uid']
|
||||
) . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
|
||||
mysql_query(
|
||||
'INSERT INTO `pay_operation` (`uid`,`ekr`,`time`,`good`,`var`,`ref`,`ref2`) VALUES (
|
||||
"' . $uba['id'] . '","' . mysql_real_escape_string($_POST['buy4ekr']) . '","' . time() . '","' . time() . '","buy_ekr_alh' . $u->info['id'] . '","' . $uba['host_reg'] . '","0"
|
||||
)'
|
||||
);
|
||||
$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']]);
|
||||
|
||||
|
||||
$r = '<span class=date>' . date(
|
||||
'd.m.Y H:i'
|
||||
@ -239,7 +210,7 @@ if (isset($ba['id'])) {
|
||||
$bnss = ' (+' . ($out_ekr - round((int)$_POST['buy4ekr'], 2)) . ' ЕКР бонус!)';
|
||||
}
|
||||
|
||||
$r .= ' <b>' . $user['login'] . '</b>, на Ваш счет зачислено ' . $_POST['buy4ekr'] . ' ЕКР' . $bnsss . '. Благодарим Вас за покупку!';
|
||||
$r .= ' <b>' . $user['login'] . '</b>, вам зачислено ' . $_POST['buy4ekr'] . ' ЕКР' . $bnss . '. Благодарим Вас за покупку!';
|
||||
|
||||
$cmsg = new ChatMessage();
|
||||
$cmsg->setCity($user['city']);
|
||||
@ -249,33 +220,31 @@ if (isset($ba['id'])) {
|
||||
$cmsg->setText($r);
|
||||
(new Chat())->sendMsg($cmsg);
|
||||
|
||||
$text_msg = 'Алхимик <b>' . $u->info['login'] . '</b> совершил продажу <b>' . $_POST['buy4ekr'] . '</b> ЕКР. (скидка ' . $ba['procent'] . '% , задолжность ' . $ba['USD'] . '$). Покупатель: ' . $u->microLogin(
|
||||
$uba['uid'], 1
|
||||
) . '.</b>.';
|
||||
$text_msg = 'Алхимик <b>' . $u->info['login'] . '</b> совершил продажу <b>' .
|
||||
$_POST['buy4ekr'] . '</b> ЕКР. (скидка ' . $ba['procent'] . '% , задолжность ' . $ba['USD'] . '$). Покупатель: ' . $u->microLogin($uba['uid'], 1) . '.</b>.';
|
||||
|
||||
$balance = mysql_fetch_array(
|
||||
mysql_query('SELECT SUM(`money`) FROM `balance_money` WHERE `cancel` = 0')
|
||||
);
|
||||
$balance = $balance[0] + $money;
|
||||
mysql_query(
|
||||
'INSERT INTO `balance_money` (`time`,`ip`,`money`,`comment2`,`balance`,`cancel`) VALUES ("' . time() . '","' . $u->info['ip'] . '","' . mysql_real_escape_string(
|
||||
(int)$money
|
||||
) . '","' . mysql_real_escape_string($text_msg) . '","' . $balance . '","' . time() . '")'
|
||||
);
|
||||
$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]);
|
||||
|
||||
//Рейтинг по вкладам
|
||||
$ub = [];
|
||||
$ui = [];
|
||||
$sp = mysql_query('SELECT * FROM `pay_operation` WHERE `good` > 0 ORDER BY `id` DESC');
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
if (!isset($ub[$pl['uid']])) {
|
||||
$sp = Db::getRows('select * from pay_operation where good > 0 order by id desc');
|
||||
foreach ($sp as $pl) {
|
||||
if (empty($ub[$pl['uid']])) {
|
||||
$ui[] = $pl['uid'];
|
||||
}
|
||||
$ub[$pl['uid']][date('d.m.Y', $pl['good'])] = $pl['ekr'];
|
||||
}
|
||||
|
||||
$i = 0;
|
||||
while ($i < count($ui)) {
|
||||
if (isset($ui[$i])) {
|
||||
if (!isset($ui[$i])) {
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
$j = 1;
|
||||
$k = 0;
|
||||
$nj = 0;
|
||||
@ -291,39 +260,30 @@ if (isset($ba['id'])) {
|
||||
}
|
||||
$j++;
|
||||
}
|
||||
mysql_query(
|
||||
'DELETE FROM `users_paybonus` WHERE `id` = "' . $ui[$i] . '" LIMIT 1'
|
||||
);
|
||||
mysql_query(
|
||||
'INSERT INTO `users_paybonus` (`id`,`level`) VALUES (
|
||||
"' . $ui[$i] . '","' . $k . '"
|
||||
)'
|
||||
);
|
||||
}
|
||||
Db::sql('replace into users_paybonus (id, level) values (?,?)', [$ui[$i], $k]);
|
||||
$i++;
|
||||
}
|
||||
//
|
||||
|
||||
} else {
|
||||
echo 'Сумма екр.:';
|
||||
if (!isset($_POST['buy4ekr'])) {
|
||||
echo ' <input name="buy4ekr" style="width:50px;" value="0.00" /> <input class="btn btn-danger" value="Далее" type="submit" /><br>';
|
||||
echo ' <input name="buy4ekr" style="width:50px;" value="0.00" />
|
||||
<input class="btn btn-danger" value="Далее" type="submit"><br>';
|
||||
} else {
|
||||
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'] . '" />';
|
||||
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'] . '">';
|
||||
echo ' <br><br><input type="submit" name="buygoodluck" class="btn btn-success" value="Совершить продажу">';
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
<?php 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 } ?>
|
||||
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 } ?>
|
||||
</form>
|
||||
</td>
|
||||
</tr>
|
||||
@ -342,7 +302,6 @@ if (isset($_GET['usemod']) && isset($_POST['usem1'])) {
|
||||
if (isset($_POST['tologin'], $_POST['message'])) {
|
||||
$cmsg = new ChatMessage();
|
||||
$cmsg->setRoom(1);
|
||||
$cmsg->setCity($infcity);
|
||||
$cmsg->setTo($_POST['tologin']);
|
||||
$cmsg->setText(
|
||||
'<span style="color: darkblue; ">Сообщение телеграфом от </span> <b>' . $u->info['login'] . '</b>: ' . $_POST['message']
|
||||
@ -353,7 +312,7 @@ if (isset($_POST['tologin'], $_POST['message'])) {
|
||||
?>
|
||||
<table>
|
||||
<a href="#"
|
||||
onClick="openMod('<b>Заклятие молчания</b>','<form action=\'main.php?<?= 'alhp&usemod=' . $code; ?>\' method=\'post\'>Логин персонажа: <input type=\'text\' style=\'width:144px;\' id=\'logingo\' name=\'logingo\'><br>Время заклятия: <select style=\'margin-left:2px;\' name=\'time\'><option value=\'1440\'>Сутки</option></select> <input type=\'submit\' name=\'usem1\' value=\'Исп-ть\'></form>');"><img
|
||||
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>Время заклятия: <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>
|
||||
|
||||
<br><h4>Телеграф</h4>
|
||||
@ -364,31 +323,22 @@ if (isset($_POST['tologin'], $_POST['message'])) {
|
||||
</form>
|
||||
<?php
|
||||
echo '<br><h2>Список реальщиков:</h2><br>';
|
||||
$sp = mysql_query('SELECT * FROM `pay_operation` WHERE `good` > 0 GROUP BY `uid`');
|
||||
while ($pl = mysql_fetch_array($sp)) {
|
||||
$onl = mysql_fetch_array(
|
||||
mysql_query('SELECT `id`,`online` FROM `users` WHERE `id` = "' . $pl['uid'] . '" LIMIT 1')
|
||||
);
|
||||
$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->microLogin($pl['uid'], 1);
|
||||
|
||||
if (!stristr($u->microLogin($pl['uid']), 'Невидимка')) {
|
||||
if ($onl['online'] > time() - 240) {
|
||||
if ($online > time() - 240) {
|
||||
$lg = '<span style="color: green;">' . $lg . '</span>';
|
||||
} else {
|
||||
$lg .= ' (был тут ' . date('d.m.Y H:i', $onl['online']) . ')';
|
||||
$lg .= ' (был тут ' . date('d.m.Y H:i', $online) . ')';
|
||||
}
|
||||
if ($u->info['admin'] > 0) {
|
||||
$sum = mysql_fetch_array(
|
||||
mysql_query(
|
||||
'SELECT SUM(`ekr`) FROM `pay_operation` WHERE `good` > 0 AND `uid` = "' . $pl['uid'] . '" LIMIT 1'
|
||||
)
|
||||
);
|
||||
$sum = 0 + $sum[0];
|
||||
echo $lg . ' - ' . $sum . ' ЕКР.<br>';
|
||||
$sum = Db::getValue('select sum(ekr) from pay_operation where good > 0 and uid = ?', [$pl['uid']]);
|
||||
echo $lg . ' - ' . $sum . ' екр.<br>';
|
||||
} else {
|
||||
echo $lg . '<br>';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user