likely the last commit had a serious vulnerability. this is just a sync
Deploy vintagecoding.net / deploy (push) Canceled after 0s

This commit is contained in:
2025-06-10 10:46:22 -06:00
parent becfbc3628
commit ae76b11a87
8 changed files with 304 additions and 324 deletions
+10 -16
View File
@@ -10,16 +10,15 @@ class Space
private string $name;
private string $description;
private int $visibility;
private ?array $members;
private ?array $posts;
private ?Space $parent;
public function __construct(int $id, string $name, string $description, int $visibility, ?array $members, ?array $posts, ?Space $parent = null, bool $favorited = false)
public function __construct(int $id, string $name, string $description, int $visibility, ?array $posts, ?Space $parent = null, bool $favorited = false)
{
error_log('Constructing a space with id: ' . $id);
$this->name = $name;
$this->description = $description;
$this->visibility = $visibility;
$this->members = $members;
$this->posts[] = $posts;
$this->parent = $parent;
@@ -57,7 +56,7 @@ class Space
public function getSubSpaces(): ?array
{
$stmt = 'SELECT id FROM space WHERE parentSpace = ?';
$stmt = 'SELECT id FROM space WHERE parent = ?';
$rawSubSpaces = exec_stmt($stmt, 'i', $this->id);
$subSpaces = [];
@@ -73,6 +72,11 @@ class Space
return $this->parent;
}
public function hasParent(): bool
{
return isset($this->parent);
}
public function getCardHTML(): string
{
$html = '
@@ -120,6 +124,7 @@ class Space
public static function retrieveFromDB(int $space, int $user = -1): ?Space
{
error_log('Retrieving a space from DB.');
if ($user != -1) {
$stmt = 'SELECT * FROM spaceMembers WHERE space = ? AND user = ?';
$isMember = exec_stmt($stmt, 'ii', $space, $user)->fetch_assoc();
@@ -141,28 +146,17 @@ class Space
else
$parent = null;
$stmt = 'SELECT user FROM spaceMembers WHERE space = ?';
$members = [];
$rawMembers = exec_stmt($stmt, 'i', $rawSpace['id']);
foreach ($rawMembers as $m)
$members[] = User::retrieveFromDB($m['user']);
$stmt = 'SELECT post FROM spacePosts INNER JOIN post ON spacePosts.post = post.id WHERE post.space = ? ORDER BY post.createdAt DESC';
$posts = [];
$rawPosts = exec_stmt($stmt, 'i', $rawSpace['id']);
while ($row = $rawPosts->fetch_assoc())
$posts[] = Post::retrieveFromDB($row['post']);
return new Space($rawSpace['id'], $rawSpace['name'], $rawSpace['description'], $rawSpace['visibility'], $members, $posts, $parent);
return new Space($rawSpace['id'], $rawSpace['name'], $rawSpace['description'], $rawSpace['visibility'], $posts, $parent);
} else
return null;
}
public function allowUser(User $user)
{
return in_array($user, $this->members);
}
public function getPosts()
{
return $this->posts;