Progress on fixing shitty groups code?

This commit is contained in:
Michał Gdula 2022-09-24 16:47:34 +00:00
parent be80166795
commit 89bab971f3
8 changed files with 252 additions and 122 deletions

View file

@ -1,6 +1,8 @@
<?php
namespace App;
use Exception;
class Make {
/*
|-------------------------------------------------------------
@ -205,16 +207,20 @@ class Group {
$group_array = mysqli_fetch_assoc($query);
}
$image_list = explode(" ", $group_array['image_list']);
foreach ($image_list as $image) {
$image_request = mysqli_query($conn, "SELECT author FROM images WHERE id = ".$image);
while ($author = mysqli_fetch_column($image_request)) {
if (!in_array($author, $user_array)) {
array_push($user_array, $author);
try {
$image_list = explode(" ", $group_array['image_list']);
$user_array = array();
foreach ($image_list as $image) {
$image_request = mysqli_query($conn, "SELECT author FROM images WHERE id = ".$image);
while ($author = mysqli_fetch_column($image_request)) {
if (!in_array($author, $user_array)) {
$user_array[] = $author;
}
}
}
} catch (Exception) {
}
return($user_array);

View file

@ -141,3 +141,26 @@ if (isset($_POST['title_submit'])) {
}
}
}
if (isset($_POST['new_group_submit'])) {
if ($user_info->is_loggedin()) {
$group_name = $_SESSION['username']." new image group";
$sql = "INSERT INTO groups (group_name, author, image_list) VALUES('$group_name', '".$_SESSION['id']."', '')";
mysqli_query($conn, $sql);
$group_id = mysqli_insert_id($conn);
?>
<script>
window.location.href = "group.php?id=<?php echo $group_id; ?>";
</script>
<?php
} else {
?>
<script>
sniffleAdd('Denied', 'You must have an account to preform this action!', 'var(--red)', 'assets/icons/cross.svg');
</script>
<?php
}
}