From 2811fd20334f9545930ce3dcd24e305fde8f217e Mon Sep 17 00:00:00 2001 From: lopar Date: Sat, 16 Feb 2019 00:03:02 +0200 Subject: [PATCH] telegraph fixed --- functions.php | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/functions.php b/functions.php index a1cb26c..378c729 100644 --- a/functions.php +++ b/functions.php @@ -2346,22 +2346,15 @@ function deltravma($id) } } -// telegrafick -function telegraph($to, $text) -{ //todo переписать, под логику, когда телеграф ВСЕГДА приходит на почту. - global $user; - $ur = mysql_fetch_array(mysql_query("select `id` from `users` WHERE `login` = '{$to}' LIMIT 1;")); - $us = mysql_fetch_array(mysql_query("select `id` from `online` WHERE `date` >= " . (time() - 60) . " AND `id` = '{$ur['id']}' LIMIT 1;")); - if (!$ur) { - echo "Персонаж не найден."; - } elseif ($us[0]) { - addchp(' (' . date("Y.m.d H:i") . ') Сообщение телеграфом от ' . nick::id($user['id'])->short() . ': ' . $text . ' ', '{[]}' . $to . '{[]}'); - echo "Персонаж получил ваше сообщение"; - } else { - // если в офе - echo "Сообщение будет доставлено, как только персонаж будет on-line."; - mysql_query("INSERT INTO `telegraph` (`receiver`,`text`) VALUES ('" . $ur['id'] . "','" . '[' . date("d.m.Y H:i") . '] Сообщение по телеграфу от ' . nick::id($user['id'])->short() . ': ' . $text . ' ' . "');"); - } +/** + * @param $name + * @param $text + * @throws \Krugozor\Database\Mysql\Exception + */ +function telegraph($userId, $text) +{ + db::c()->query('SELECT 1 FROM `users` WHERE `id` = ?i', $userId)->fetch_assoc(); + if (db::c()->getAffectedRows()) db::c()->query('INSERT INTO `telegraph` (receiver, text) VALUES (?i,"?s")', $userId, $text); } function get_meshok() @@ -2518,6 +2511,8 @@ function addToDelo($message, $user_id = 0, $type = 1) return true; } + + /** * Апаем стат или мастерство на единицу. *