publicfunction__toString() { $comments = $this->comments; // comments are bugged for now, but in future it might be re-implemented // when it is, just append $comments_fallback to $out if ($comments !== null) { $comments_fallback = $this->$comments; }
$conn = newConn; $conn->queries = array(newQuery( "select id from posts where title = :title and content = :content", array(":title" => $this->title, ":content" => $this->content) )); $result = $conn(); if ($result[0] === false) { return""; } else { return" <div class='card'> <h3 class='card-header'>{$this->title}</h3> <div class='card-body'> <p class='card-text'>{$this->content}</p> </div> <div class='card-footer'> <input class='input-group-text' style='font-size: 12px;' disabled value='Commenting is disabled.' /> </div> </div> "; } } }
// get user profile publicfunctionget_profile() { // some dev apparently mixed up user and profile... // so this check prevents any more errors if ($this->profile instanceof User) { return"@i_use_vscode please fix your code"; } else { // quite unnecessary to assign to a variable imho $profile_string = " <div>{$this->profile}</div> "; return$profile_string; } }
publicfunctionget_posts() { // check if we've already fetched posts before to save some overhead // (our poor sqlite db is dying) if (sizeof($this->posts) !== 0) { return"Please reload the page to fetch your posts from the database"; }
// get all user posts $conn = newConn; $conn->queries = array(newQuery( "select title, content from posts where user = :user", array(":user" => $this->profile->username) ));
// get posts from database $result = $conn(); if ($result[0] !== false) { while ($row = $result[0]->fetchArray(1)) { $this->posts[] = newPost($row["title"], $row["content"]); } }
// who put this?? git blame moment (edit: i checked, it's @i_use_vscode as usual) publicfunction__toString() { $profile = $this->profile; return$profile(); } }
// hotfix for @i_use_vscode (see line 97) // when removed, please remove this as well publicfunction__invoke() { if (gettype($this->picture_path) !== "string") { return"<script>window.location = '/login.php'</script>"; }