diff --git a/endpoints/newsarticle.php b/endpoints/newsarticle.php deleted file mode 100644 index 099094b..0000000 --- a/endpoints/newsarticle.php +++ /dev/null @@ -1,16 +0,0 @@ - getNewsArticles(), - "addNewsArticle" => addNewsArticle( - $endpoint_data["title"], - $endpoint_data["body"] - ), - default => ["Status" => "Fail", "message" => "Invalid action"], - }; -} \ No newline at end of file diff --git a/endpoints/upload.php b/endpoints/upload.php deleted file mode 100644 index cf2d47a..0000000 --- a/endpoints/upload.php +++ /dev/null @@ -1,14 +0,0 @@ - listFiles(), - "getAllFiles" => listFiles(false), - "UploadFiles" => parseIncomingFiles(), - default => ["Status" => "Fail", "message" => "Invalid action"], - }; -} \ No newline at end of file diff --git a/lib/config.php b/lib/config.php index 0f49b25..c38a6a3 100644 --- a/lib/config.php +++ b/lib/config.php @@ -4,7 +4,7 @@ return [ 'inlining' => false, - 'domain' => 'adlerka', + 'domain' => 'stylehub.adlerka', 'tld' => 'top', 'default_page' => 'index', 'default_site' => 'home', @@ -12,7 +12,7 @@ 'endpoint_dir' => 'endpoints/', 'page_dir' => 'pages/', 'protocol' => 'https://', - 'site_prefix' => 'Adlerka', + 'site_prefix' => 'StyleHub', 'permissions' => [ 'logged_out' => 1, 'logged_in_default' => 2, @@ -31,9 +31,9 @@ 'default_permissions' => 255, ], 'seo' => [ - 'author' => 'Tím AdlerkaTop', - 'description' => 'Toto je neoficiánla študentská stránka pre Adlerku, kde môžete nájsť plno zaujímavostí.', - 'keywords' => 'adlerka, alderka, studenti, studentska stranka, web, dev, webdev, web dev, skola, zabava', + 'author' => 'Guvernér', + 'description' => 'Toto je stránka Malackého guvernéra.', + 'keywords' => 'moda, oblecenie, mesto, guverner', 'generator' => 'TurboRoute', 'robots' => 'follow, index, max-snippet:-1, max-video-preview:-1, max-image-preview:large' ] diff --git a/lib/newsarticle.php b/lib/newsarticle.php deleted file mode 100644 index 0f80108..0000000 --- a/lib/newsarticle.php +++ /dev/null @@ -1,64 +0,0 @@ - "Fail"]; // Default Status is "Fail" - - $articles = []; - $stmt = $mysqli->prepare("SELECT NewsArticles.ID, NewsArticles.WrittenAt, NewsArticles.WrittenBy, NewsArticles.Title, NewsArticles.Body, NewsArticles.FileList, Users.Nickname FROM NewsArticles INNER JOIN Users ON NewsArticles.WrittenBy = Users.ID WHERE NewsArticles.PrivilegeLevel <= ?;"); - $id = 0; - $writtenAt = ""; - $writtenBy = 0; - $title = ""; - $body = ""; - $filelist = 0; - $writtenByName = ""; - - $stmt->bind_param("i", $_SESSION["privilege_level"]); - $stmt->bind_result($id, $writtenAt, $writtenBy, $title, $body, $filelist, $writtenByName); - - $stmt->execute(); - - while ($stmt->fetch()) { - $articles[] = [ - 'ID' => $id, - 'WrittenAt' => $writtenAt, - 'Title' => $title, - 'Body' => $body, - 'WrittenByName' =>$writtenByName - ]; - } - - // Check if any results were fetched - if (!empty($articles)) { - $output["Status"] = "Success"; - $output["Articles"] = $articles; - } - - return $output; -} - -function addNewsArticle($title="Nazov", $body="Obsah", $privilegeLevel=0) :array -{ - global $mysqli; - global $routerConfig; - - - if ($privilegeLevel == 0){ - $privilegeLevel = $routerConfig['newsarticle']['default_permissions']; - } - - $output = ["Status" => "Fail"]; // Default Status is "Fail" - if (isLoggedIn() && $privilegeLevel <= $_SESSION["privilege_level"]) { - $query = $mysqli->prepare("INSERT INTO NewsArticles (WrittenBy, Title, Body, FileList, PrivilegeLevel) VALUES (?, ?, ?, 0, ?);"); - $minpriv = intval($privilegeLevel); - $query->bind_param("issi", $_SESSION["ID"], htmlspecialchars($title), htmlspecialchars($body), $minpriv); - $query->execute(); - if ($query->affected_rows > 0) { - $output["Status"] = "Success"; - } - $query->close(); - } - return $output; -} \ No newline at end of file diff --git a/lib/upload.php b/lib/upload.php deleted file mode 100644 index df125a4..0000000 --- a/lib/upload.php +++ /dev/null @@ -1,189 +0,0 @@ - $valueArr) { - if (is_array($valueArr)) { // file input "multiple" - foreach ($valueArr as $i => $value) { - $filesByInput[$i][$key] = $value; - } - } else { // -> string, normal file input - $filesByInput[] = $infoArr; - break; - } - } - $files2 = array_merge($files2, $filesByInput); - } - $files3 = []; - foreach ($files2 as $file) { // let's filter empty & errors - if (!$file['error']) $files3[] = $file; - } - return $files3; -} - -function saveUploadedFileInDatabase($filePath, $fileType):bool -{ - global $mysqli; - $stmt = $mysqli->prepare("INSERT INTO Files (Path, Type, UploadedBy, UploadedAt) VALUES (?, ?, ?, NOW())"); - $stmt->bind_param("ssi", $filePath, $fileType, $_SESSION["ID"]); - $stmt->execute(); - $stat = $stmt->affected_rows > 0; - $stmt->close(); - return $stat; -} - -function doImageUpload($inFile, $outFile): bool -{ - // Create Imagick object - try { - $imagick = new Imagick($inFile); - } catch (ImagickException $e) { - } - - // Set the desired format for reencoding (WebP) - try { - $imagick->setImageFormat('webp'); - } catch (ImagickException $e) { - } - - // Remove non-essential metadata - try { - $imagick->stripImage(); - } catch (ImagickException $e) { - } - - // Write the reencoded image to the output file - try { - $imagick->writeImage($outFile); - } catch (ImagickException $e) { - } - - // Destroy the Imagick object to free up resources - $imagick->destroy(); - - // Check if the reencoding was successful - if (file_exists($outFile)) { - return saveUploadedFileInDatabase($outFile, 'image/webp'); - } else { - return false; - } -} - -function listFiles($onlyMine = true):array -{ - $output = ["Status" => "Fail"]; - require_once "lib/account.php"; - if(($onlyMine && isLoggedIn()) || (!$onlyMine && isModerator())) { - global $mysqli; - $query = "SELECT ID, Path, Type, UploadedAt, UploadedBy FROM Files"; - - if($onlyMine){ - $query .= " WHERE UploadedBy = ?"; - } - - $stmt = $mysqli->prepare($query); - if($onlyMine) { - $stmt->bind_param("i", $_SESSION["ID"]); - } - - $id = 0; - $path = ""; - $type = ""; - $uploadedAt = ""; - $uploadedBy = 0; - - $stmt->bind_result($id, $path, $type, $uploadedAt, $uploadedBy); - - $stmt->execute(); - - // Fetch the results into the bound variables - while ($stmt->fetch()) { - $files[] = [ - 'ID' => $id, - 'Path' => $path, - 'Type' => $type, - 'UploadedAt' => $uploadedAt, - 'UploadedBy' => $uploadedBy, - ]; - } - - // Check if any results were fetched - if (!empty($files)) { - $output["Status"] = "Success"; - $output["Files"] = $files; - } - - $stmt->close(); - } - - return $output; - -} - -function parseIncomingFiles(): array -{ - $incomingFiles = getIncomingFiles(); - $success = true; - - foreach ($incomingFiles as $incomingFile) { - if ($incomingFile["error"] == 0 && is_file($incomingFile["tmp_name"])) { - $type = explode("/", $incomingFile["type"]); - if ($type == "image") { - $imgFname = pathinfo($incomingFile["name"], PATHINFO_FILENAME); - $uploadPath = getUploadPath("image", $imgFname); - if (!empty($uploadPath)) { - if (!doImageUpload($incomingFile["tmp_name"], $uploadPath)) { - $success = false; - } - } else { - $success = false; - } - } - } - } - $output = ["Status" => "Fail"]; - if($success){ - $output["Status"] = "Success"; - } - return $output; -} - -function getUploadPath($type = "unknown", $filename = "hehe"): string -{ - $type = makePathSafe($type); - $id = makePathSafe($_SESSION["ID"]); - $date = makePathSafe(date("Y/m/d")); - $filename = makePathSafe($filename); - $extension = match ($type) { - 'image' => 'webp', - default => 'dummy', - }; - if($extension != "dummy") { - return "uploads/$type/$id/$date/$filename.$extension"; - } - else { - return ""; - } -} \ No newline at end of file diff --git a/pages/memes/index.html b/pages/memes/index.html deleted file mode 100644 index 7e7387b..0000000 --- a/pages/memes/index.html +++ /dev/null @@ -1,7 +0,0 @@ - - -
-

Adlerka Memes

-

Skoro ako r/adlerka - ale lepšie.

-
-
\ No newline at end of file diff --git a/pages/news/index.php b/pages/news/index.php deleted file mode 100644 index 1874828..0000000 --- a/pages/news/index.php +++ /dev/null @@ -1,45 +0,0 @@ - $output, - "parameters" => - [ - "minimal_permission_level" => 1, - "secret" => "no", - "page_title" => "Novinky" - ] -]; diff --git a/pages/notes/index.html b/pages/notes/index.html deleted file mode 100644 index 536def0..0000000 --- a/pages/notes/index.html +++ /dev/null @@ -1,6 +0,0 @@ - - -
-

Adlerka Zošit

-
-
\ No newline at end of file diff --git a/pages/rozvrh/index.html b/pages/rozvrh/index.html deleted file mode 100644 index 07877eb..0000000 --- a/pages/rozvrh/index.html +++ /dev/null @@ -1,4 +0,0 @@ - - -

Toto sú rozvrhy niektorých Adlerákov

-

Zatiaľ hardcoded, potom dorobíme funkcionalitu zbierania dát z Edupage

\ No newline at end of file diff --git a/pages/rozvrh/prvacdruhaskupina.html b/pages/rozvrh/prvacdruhaskupina.html deleted file mode 100644 index eb23ab3..0000000 --- a/pages/rozvrh/prvacdruhaskupina.html +++ /dev/null @@ -1,59 +0,0 @@ - - -

Rozvrh 1.C 2.Skupina

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 (7:10 - 7:55)1 (8:00 - 8:45)2 (8:50 - 9:35)3 (9:45 - 10:30)4 (10:50 - 11:35)5 (11:45 - 12:30)6 (12:40 - 13:25)7 (13:30 - 14:15)
MATELKSJLZERANJMAT
PRXSJLINFELK
PROSJLFYZANJMATELKTSV
PROANJTDKMATETV
TDKOBNTSVFYZPRODEJ
\ No newline at end of file diff --git a/pages/rozvrh/prvacprvaskupina.html b/pages/rozvrh/prvacprvaskupina.html deleted file mode 100644 index 3e58694..0000000 --- a/pages/rozvrh/prvacprvaskupina.html +++ /dev/null @@ -1,59 +0,0 @@ - - -

Rozvrh 1.C 1.Skupina

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 (7:10 - 7:55)1 (8:00 - 8:45)2 (8:50 - 9:35)3 (9:45 - 10:30)4 (10:50 - 11:35)5 (11:45 - 12:30)6 (12:40 - 13:25)7 (13:30 - 14:15)
MATELKSJLZERMATANJ
PRXSJLINFELK
PROSJLTSVFYZANJMATELK
PROTDKTSVMATETV
ANJOBNTDKFYZPRODEJ
\ No newline at end of file diff --git a/pages/rozvrh/prvadprvaskupina.html b/pages/rozvrh/prvadprvaskupina.html deleted file mode 100644 index 0858c1d..0000000 --- a/pages/rozvrh/prvadprvaskupina.html +++ /dev/null @@ -1,60 +0,0 @@ - - -

Rozvrh 1.D 1.Skupina

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
0 (7:10 - 7:55)1 (8:00 - 8:45)2 (8:50 - 9:35)3 (9:45 - 10:30)4 (10:50 - 11:35)5 (11:45 - 12:30)6 (12:40 - 13:25)7 (13:30 - 14:15)
TSVPROMATTDKPROSJL
FYZTDKMATELKOBNANJETV
ELKMATSJLANJELKINF
ZERMATFYZDEJTSV
SJLANJPROPRX
\ No newline at end of file diff --git a/pages/smp/index.html b/pages/smp/index.html deleted file mode 100644 index b2382d4..0000000 --- a/pages/smp/index.html +++ /dev/null @@ -1,36 +0,0 @@ - - -
-

Vitaj na oficiálnej AdlerkaSMP stránke

-

Najlepší Minecraft®™ server na Adlerke

-
-
-

Čo môžeš očakávať od AdlerkaSMP:

- - -
-
\ No newline at end of file diff --git a/pages/smp/info.html b/pages/smp/info.html deleted file mode 100644 index 70bee00..0000000 --- a/pages/smp/info.html +++ /dev/null @@ -1,3 +0,0 @@ - - -

Vitaj na oficiálnej stránke Informácii o AdlerkaSMP

\ No newline at end of file diff --git a/templates/newsArticle.html b/templates/newsArticle.html deleted file mode 100644 index 4aae648..0000000 --- a/templates/newsArticle.html +++ /dev/null @@ -1,11 +0,0 @@ -
-

__TEMPLATE_ARTICLE_TITLE__

-
-

__TEMPLATE_ARTICLE_AUTHOR__

-

__TEMPLATE_ARTICLE_DATE__

-
-
-
- __TEMPLATE_ARTICLE_BODY__ -
-
\ No newline at end of file diff --git a/templates/newsArticles.html b/templates/newsArticles.html deleted file mode 100644 index 4b74294..0000000 --- a/templates/newsArticles.html +++ /dev/null @@ -1,22 +0,0 @@ -
-

-

Adlerka študentské news

- -
- - - -
- __TEMPLATE__ARTICLES_HERE__ -
- -