|
| 1 | +<?php |
| 2 | +include_once 'db_credentials.php'; |
| 3 | +include_once 'sendEmail.php'; |
| 4 | +include_once 'utilityFunctions.php'; |
| 5 | +include_once 'classes.php'; |
| 6 | + |
| 7 | +function followUser($user, $follow) { |
| 8 | + $connection = connectAccount(); |
| 9 | + $query = "INSERT INTO FriendTest (followerID, followedID) VALUES ('$user', '$follow')"; |
| 10 | + if(mysqli_query($connection, $query)) { |
| 11 | + $message = "SUCCUser $follow has been successfully followed!\n\n"; |
| 12 | + sendMessage($message, $sock); |
| 13 | + } |
| 14 | + else { |
| 15 | + $message = "FAILSomething went wrong.\n\n"; |
| 16 | + sendMessage($message, $sock); |
| 17 | + } |
| 18 | + disconnect($connection); |
| 19 | +} |
| 20 | + |
| 21 | +function searchUser($user, $sock) { |
| 22 | + $connection = connectAccount(); |
| 23 | + $query = "SELECT Username FROM UserInfo WHERE Username LIKE '%$user%' ORDER BY Username ASC LIMIT 20"; |
| 24 | + if(mysqli_query($connection, $query)) { |
| 25 | + echo "Yeeeeeeeee buddy it worked!\n\n"; |
| 26 | + $result = mysqli_query($connection, $query); |
| 27 | + $searchResults = ""; |
| 28 | + while ($rows = mysqli_fetch_array($result, MYSQLI_ASSOC)) { |
| 29 | + $searchResults .= $rows["Username"] . " "; |
| 30 | + } |
| 31 | + $message = "RSLT$searchResults"; |
| 32 | + sendMessage($message, $sock); |
| 33 | + } |
| 34 | + else { |
| 35 | + echo "Damn it didn't work son :/ ... Error: " . mysqli_error($connection); |
| 36 | + $message = "FAIL"; |
| 37 | + } |
| 38 | + |
| 39 | + disconnect($connection); |
| 40 | +} |
| 41 | + |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +?> |
0 commit comments