Рефакторинг

This commit is contained in:
2023-04-15 22:18:30 +03:00
parent bdda3d24a0
commit 6afdb1a1be
19 changed files with 3321 additions and 3683 deletions
+7 -35
View File
@@ -461,13 +461,8 @@ if (isset($_POST['msg']) && str_replace(' ', '', $_POST['msg']) != '') {
$cmsg = new ChatMessage();
if (preg_match("/анекдот/i", mb_convert_case($_POST['msg'], MB_CASE_LOWER))) {
$text_com = '';
$sp_all = mysql_fetch_array(
mysql_query(
'SELECT COUNT(`id`) FROM `a_com_act` WHERE `act` = "' . $com_act . '" AND `time` > "' . time(
) . '" LIMIT 5'
)
);
if ($sp_all[0] > 0) {
$sp_all = Db::getValue('select count(*) from a_com_act where act = ? and time > unix_timestamp() limit 5', [$com_act]);
if ($sp_all > 0) {
if (rand(0, 100) < 75) {
$text_com = [
'Отстань попрошайка! ... Ищу анекдоты, интернет не маленький!',
@@ -479,31 +474,24 @@ if (isset($_POST['msg']) && str_replace(' ', '', $_POST['msg']) != '') {
$text_com = $text_com[rand(0, (count($text_com) - 1))];
}
} else {
$sp_all = mysql_fetch_array(mysql_query('SELECT COUNT(`id`) FROM `a_com_anekdot`'));
$sp_all = rand(1, $sp_all[0]);
$sp_all = mysql_fetch_array(
mysql_query('SELECT * FROM `a_com_anekdot` WHERE `id` = "' . $sp_all . '" LIMIT 1')
);
$sp_all = Db::getRow('select * from a_com_anekdot order by rand() limit 1');
if (isset($sp_all['id'])) {
$text_com = $sp_all['text'];
$text_com = str_replace("<br>", "<br>&nbsp; &nbsp; ", $text_com);
$text_com = str_replace("<br />", "<br />&nbsp; &nbsp; ", $text_com);
$text_com = str_ireplace("\r\n", "", $text_com);
$text_com = str_replace("", "", $text_com);
$text_com = '<font color=red><b>Анекдот</b></font>:<br>&nbsp; &nbsp; ' . $text_com . '<br>';
$text_com = '<b style="color: red">Анекдот</b>:<br>&nbsp; &nbsp; ' . $text_com . '<br>';
} else {
$text_com = 'Анекдот из головы вылетел...';
}
mysql_query(
'INSERT INTO `a_com_act` (`act`,`time`,`uid`) VALUES ("0","' . (time(
) + 60) . '","' . $u->info['id'] . '")'
);
Db::sql('insert into a_com_act (act, time, uid) values (0, unix_timestamp() + 60, ?)', [$u->info['id']]);
}
if ($text_com != '') {
$cmsg->setText($text_com);
}
} else {
include('commentator.php');
include_once 'commentator.php';
if ($comment != '') {
$cmsg->setText($comment);
}
@@ -517,10 +505,7 @@ if (isset($_POST['msg']) && str_replace(' ', '', $_POST['msg']) != '') {
$chat->sendMsg($cmsg);
}
}
mysql_query(
'UPDATE `users` SET `afk` = "",`dnd` = "",`timeMain` = "' . time(
) . '" WHERE `id` = "' . $u->info['id'] . '" LIMIT 1'
);
Db::sql('update users set afk = default, dnd = default, timeMain = unix_timestamp() where id = ?', [$u->info['id']]);
}
}
@@ -1076,19 +1061,6 @@ if ($posts > 0) {
$r['js'] .= ' $("#postdiv").hide();';
}
//Предложения вступить в клан
$sp = mysql_query('SELECT * FROM `clan_add` WHERE `uid` = "' . $u->info['id'] . '" AND `yes` = 0 AND `no` = 0');
while ($pl = mysql_fetch_array($sp)) {
$clns = mysql_fetch_array(
mysql_query('SELECT `id`,`name`,`align` FROM `clan` WHERE `id` = "' . $pl['clan'] . '" LIMIT 1')
);
$usr = mysql_fetch_array(
mysql_query('SELECT `id`,`login`,`level` FROM `users` WHERE `id` = "' . $pl['uid_clan'] . '" LIMIT 1')
);
$r['js'] .= 'top.inclanNew(' . $pl['id'] . ',"' . $clns['align'] . '","' . $clns['id'] . '","' . $clns['name'] . '","' . $usr['login'] . '</b>[' . $usr['level'] . ']<b>");';
}
unset($clns);
//Предложение на обмен
$trf = mysql_fetch_array(
mysql_query(