From 229a343ebd7c878237220ed2d10dbb4c354d85d0 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Wed, 4 Apr 2018 16:13:55 +0530 Subject: [PATCH] Add if clause to send warning if more than one user points to a user. --- update_chain.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/update_chain.php b/update_chain.php index e48205c..2afb7d0 100644 --- a/update_chain.php +++ b/update_chain.php @@ -33,6 +33,16 @@ function get_chain_from_user($user) { while (true) { $query = "SELECT user_id, username from users where follows = $last_user_id ;"; $result = $conn->query($query); + if ($result->num_rows > 1) { + $text = "Chain is unstable. The following users are pointing to "; + $op = $conn->query("select username from users where user_id = $last_user_id;"); + $text .= $op->fetch_assoc()['username'] . "\n"; + while ($row = $result->fetch_assoc()) { + $text .= '@' . $row['username'] . "\n"; + } + send_text($text); + mysql_data_seek($result, 0); + } if ($result->num_rows > 0){ # Code executed if this isn't the last user $details = $result->fetch_assoc();