diff options
| -rw-r--r-- | .gitignore | 3 | ||||
| -rw-r--r-- | public/404.php | 3 | ||||
| -rw-r--r-- | public/account/index.php | 2 | ||||
| -rw-r--r-- | public/account/login/index.php | 22 | ||||
| -rw-r--r-- | public/account/login/twitch.php | 12 | ||||
| -rw-r--r-- | public/captcha.php | 11 | ||||
| -rw-r--r-- | public/emotes/index.php | 62 | ||||
| -rw-r--r-- | public/emotes/rate.php | 5 | ||||
| -rw-r--r-- | public/emotes/upload.php | 30 | ||||
| -rw-r--r-- | public/emotesets.php | 6 | ||||
| -rw-r--r-- | public/inbox.php | 2 | ||||
| -rw-r--r-- | public/index.php | 6 | ||||
| -rw-r--r-- | public/report/index.php | 8 | ||||
| -rw-r--r-- | public/report/list.php | 7 | ||||
| -rw-r--r-- | public/report/send.php | 5 | ||||
| -rw-r--r-- | public/system/emotes/index.php | 2 | ||||
| -rw-r--r-- | public/system/index.php | 2 | ||||
| -rw-r--r-- | public/users.php | 4 | ||||
| -rw-r--r-- | src/config.php | 32 | ||||
| -rw-r--r-- | src/config.sample.php | 57 | ||||
| -rw-r--r-- | src/partials.php | 6 |
21 files changed, 180 insertions, 107 deletions
@@ -1,3 +1,4 @@ /.vscode userdata/ -*.db
\ No newline at end of file +*.db +config.php
\ No newline at end of file diff --git a/public/404.php b/public/404.php index 5646c46..8a4106d 100644 --- a/public/404.php +++ b/public/404.php @@ -1,10 +1,11 @@ <?php +include "../src/config.php"; http_response_code(404); ?> <html> <head> - <title>Not found - alright.party</title> + <title>Not found - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/account/index.php b/public/account/index.php index a216eea..6b1385f 100644 --- a/public/account/index.php +++ b/public/account/index.php @@ -70,7 +70,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { <html> <head> - <title>Account management - alright.party</title> + <title>Account management - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/account/login/index.php b/public/account/login/index.php index e104a88..954ccc9 100644 --- a/public/account/login/index.php +++ b/public/account/login/index.php @@ -3,12 +3,20 @@ include "../../../src/accounts.php"; authorize_user(); include "../../../src/partials.php"; +include_once "../../../src/config.php"; +include_once "../../../src/alert.php"; + +if (!ACCOUNT_REGISTRATION_ENABLE) { + generate_alert("/404.php", "Account registration is disabled", 403); + exit; +} + ?> <html> <head> - <title>Log in to alright.party</title> + <title>Login - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> @@ -20,13 +28,15 @@ include "../../../src/partials.php"; <section class="content"> <section class="box" style="width: 400px;"> <div class="box navtab"> - <p>Log in to alright.party</p> + <p>Log in to <?php echo INSTANCE_NAME ?></p> </div> <div class="box content"> - <form action="/account/login/twitch.php" method="GET"> - <button type="submit" class="purple" style="padding:8px 24px; font-size: 18px;">Login with - Twitch</button> - </form> + <?php if (TWITCH_REGISTRATION_ENABLE): ?> + <form action="/account/login/twitch.php" method="GET"> + <button type="submit" class="purple" style="padding:8px 24px; font-size: 18px;">Login with + Twitch</button> + </form> + <?php endif; ?> </div> </section> </section> diff --git a/public/account/login/twitch.php b/public/account/login/twitch.php index 1c72bc3..dfd319f 100644 --- a/public/account/login/twitch.php +++ b/public/account/login/twitch.php @@ -1,10 +1,16 @@ <?php include "../../../src/utils.php"; include_once "../../../src/config.php"; +include_once "../../../src/utils.php"; -$client_id = "472prq7kqn0a21l5um2lz7374471pp"; -$client_secret = "koho369mw8p51di4fx34jm2ogdmbj2"; -$redirect_uri = "http://localhost:8000/account/login/twitch.php"; +if (!TWITCH_REGISTRATION_ENABLE) { + generate_alert("/404.php", "Registration via Twitch is disabled", 405); + exit; +} + +$client_id = TWITCH_CLIENT_ID; +$client_secret = TWITCH_SECRET_KEY; +$redirect_uri = TWITCH_REDIRECT_URI; if (isset($_GET["error"])) { header("Location: /account/login"); diff --git a/public/captcha.php b/public/captcha.php index d6e53e8..c872672 100644 --- a/public/captcha.php +++ b/public/captcha.php @@ -2,13 +2,14 @@ include_once "../src/config.php"; include_once "../src/alert.php"; +session_start(); + if (!HCAPTCHA_ENABLE) { - generate_alert("/404.php", "Captcha is not enabled on this instance", 404); + $_SESSION["captcha_solved"] = true; + header("Location: /"); exit; } -session_start(); - if (isset($_SESSION["captcha_solved"]) && $_SESSION["captcha_solved"]) { header("Location: /"); exit; @@ -18,7 +19,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["h-captcha-response"])) // sending a request to captcha api $request = curl_init("https://hcaptcha.com/siteverify"); curl_setopt($request, CURLOPT_POST, 1); - curl_setopt($request, CURLOPT_HTTPHEADER, ['User-Agent: alright.party/1.0']); + curl_setopt($request, CURLOPT_HTTPHEADER, [sprintf("User-Agent: %s/1.0", INSTANCE_NAME)]); curl_setopt( $request, CURLOPT_POSTFIELDS, @@ -42,7 +43,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST" && isset($_POST["h-captcha-response"])) <html> <head> - <title>Resolving a hCaptcha for alright.party</title> + <title>Resolving a hCaptcha - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> <script src='https://www.hCaptcha.com/1/api.js' async defer></script> </head> diff --git a/public/emotes/index.php b/public/emotes/index.php index 2102aba..3c165be 100644 --- a/public/emotes/index.php +++ b/public/emotes/index.php @@ -154,8 +154,8 @@ if (CLIENT_REQUIRES_JSON) { <head> <title><?php - echo empty($emotes) ? "Emote " . $emote->get_code() : "Emotes" - ?> - alright.party</title> + echo (empty($emotes) ? "Emote " . $emote->get_code() : "Emotes") . ' - ' . INSTANCE_NAME + ?></title> <link rel="stylesheet" href="/static/style.css"> </head> @@ -309,33 +309,34 @@ if (CLIENT_REQUIRES_JSON) { echo ' UTC">about ' . format_timestamp(time() - $emote->get_created_at()) . " ago</span>"; ?></td> </tr> - <tr> - <th>Rating</th> - <?php - if ($emote->get_rating()["total"] < 10) { - echo '<td>Not rated (' . $emote->get_rating()["total"] . ')</td>'; - } else { + <?php if (RATING_ENABLE): ?> + <tr> + <th>Rating</th> + <?php + if ($emote->get_rating()["total"] < 10) { + echo '<td>Not rated (' . $emote->get_rating()["total"] . ')</td>'; + } else { - $rating = $emote->get_rating()["average"]; + $rating = $emote->get_rating()["average"]; - // TODO: make it customizable - list($rating_classname, $rating_name) = match (true) { - in_range($rating, 0.75, 1.0) => [ - "gemerald", - "<img src='/static/img/icons/ratings/1.png'> + // TODO: make it customizable + list($rating_classname, $rating_name) = match (true) { + in_range($rating, 0.75, 1.0) => [ + "gemerald", + "<img src='/static/img/icons/ratings/1.png'> <img src='/static/img/icons/ratings/1.png'> <img src='/static/img/icons/ratings/1.png'> Shiny Gemerald! <img src='/static/img/icons/ratings/1.png'> <img src='/static/img/icons/ratings/1.png'> <img src='/static/img/icons/ratings/1.png'> " - ], - in_range($rating, 0.25, 0.75) => ["gem", "<img src='/static/img/icons/ratings/1.png'> Gem <img src='/static/img/icons/ratings/1.png'>"], - in_range($rating, -0.25, 0.25) => ["iron", "Iron"], - in_range($rating, -0.75, -0.25) => ["coal", "<img src='/static/img/icons/ratings/-1.png'> Coal <img src='/static/img/icons/ratings/-1.png'>"], - in_range($rating, -1.0, -0.75) => [ - "brimstone", - " + ], + in_range($rating, 0.25, 0.75) => ["gem", "<img src='/static/img/icons/ratings/1.png'> Gem <img src='/static/img/icons/ratings/1.png'>"], + in_range($rating, -0.25, 0.25) => ["iron", "Iron"], + in_range($rating, -0.75, -0.25) => ["coal", "<img src='/static/img/icons/ratings/-1.png'> Coal <img src='/static/img/icons/ratings/-1.png'>"], + in_range($rating, -1.0, -0.75) => [ + "brimstone", + " <img src='/static/img/icons/ratings/brimstone.webp'> <img src='/static/img/icons/ratings/-1.png'> <img src='/static/img/icons/ratings/brimstone.webp'> @@ -344,16 +345,17 @@ if (CLIENT_REQUIRES_JSON) { <img src='/static/img/icons/ratings/-1.png'> <img src='/static/img/icons/ratings/brimstone.webp'> " - ] - }; + ] + }; - echo '<td>'; - echo "<span class=\"rating $rating_classname\">$rating_name</span>"; - echo ' (' . $emote->get_rating()["total"] . ')'; - echo '</td>'; - } - ?> - </tr> + echo '<td>'; + echo "<span class=\"rating $rating_classname\">$rating_name</span>"; + echo ' (' . $emote->get_rating()["total"] . ')'; + echo '</td>'; + } + ?> + </tr> + <?php endif; ?> <tr> <th>Visibility</th> <td><?php diff --git a/public/emotes/rate.php b/public/emotes/rate.php index bf26bcd..2f63d7c 100644 --- a/public/emotes/rate.php +++ b/public/emotes/rate.php @@ -4,6 +4,11 @@ include_once "../../src/utils.php"; include_once "../../src/config.php"; include_once "../../src/accounts.php"; +if (!RATING_ENABLE) { + generate_alert("/404.php", "Emote ratings are disabled", 403); + exit; +} + if (!authorize_user(true)) { exit; } diff --git a/public/emotes/upload.php b/public/emotes/upload.php index 50a8d15..fc8de71 100644 --- a/public/emotes/upload.php +++ b/public/emotes/upload.php @@ -3,6 +3,11 @@ include "../../src/accounts.php"; include_once "../../src/config.php"; include_once "../../src/alert.php"; +if (!EMOTE_UPLOAD) { + generate_alert("/404.php", "Emote upload is disabled", 403); + exit; +} + authorize_user(); if (!ANONYMOUS_UPLOAD && isset($_SESSION["user_role"]) && !$_SESSION["user_role"]["permission_upload"]) { @@ -33,9 +38,8 @@ function abort_upload(string $path, PDO $db, string $id, string $response_text, include "../../src/utils.php"; include "../../src/images.php"; -// TODO: make it configurable later -$max_width = max(128, 1); -$max_height = max(128, 1); +$max_width = EMOTE_MAX_SIZE[0]; +$max_height = EMOTE_MAX_SIZE[1]; if ($_SERVER['REQUEST_METHOD'] != "POST") { include "../../src/partials.php"; @@ -44,7 +48,7 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { <html> <head> - <title>Upload an emote at alright.party</title> + <title>Upload an emote - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> @@ -58,14 +62,14 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { <div class="box navtab"> <div> <b>Upload a new emote</b> - <p style="font-size:8px;">Btw, you can upload anything. Anything you want.</p> + <p style="font-size:8px;">You can just upload, btw. Anything you want.</p> </div> </div> <div class="box content"> <form action="/emotes/upload.php" method="POST" enctype="multipart/form-data"> <h3>Emote name</h3> <input type="text" name="code" id="code" required> - <h3>Image </h3> + <h3>Image</h3> <input type="file" name="file" id="file" accept=".gif,.jpg,.jpeg,.png,.webp" required> <div> @@ -123,8 +127,8 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { image.src = e.target.result; image.onload = () => { let m = 1; - let max_width = 128; - let max_height = 128; + let max_width = <?php echo EMOTE_MAX_SIZE[0] ?>; + let max_height = <?php echo EMOTE_MAX_SIZE[1] ?>; isImage = true; for (let i = 3; i > 0; i--) { @@ -153,9 +157,9 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { let validCode = ""; code.addEventListener("input", (e) => { - const regex = /^[a-zA-Z0-9]*$/; + const regex = <?php echo EMOTE_NAME_REGEX ?>; - if (regex.test(e.target.value) && e.target.value.length <= 100) { + if (regex.test(e.target.value) && e.target.value.length <= <?php echo EMOTE_NAME_MAX_LENGTH ?>) { validCode = e.target.value; } else { e.target.value = validCode; @@ -196,9 +200,9 @@ if (!isset($_FILES["file"])) { exit; } -$code = str_safe($_POST["code"] ?? "", 500); +$code = str_safe($_POST["code"] ?? "", EMOTE_NAME_MAX_LENGTH); -if ($code == "") { +if ($code == "" || !preg_match(EMOTE_NAME_REGEX, $code)) { http_response_code(400); echo json_encode([ "status_code" => 400, @@ -273,7 +277,7 @@ if ($resized_image) { $db = null; -if (isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json") { +if (CLIENT_REQUIRES_JSON) { http_response_code(201); echo json_encode([ "status_code" => 201, diff --git a/public/emotesets.php b/public/emotesets.php index 8dfdab0..cacdae4 100644 --- a/public/emotesets.php +++ b/public/emotesets.php @@ -185,8 +185,10 @@ if (CLIENT_REQUIRES_JSON) { <head> <title> - <?php echo $emote_sets != null ? (count($emote_sets) . " emotesets") : ('"' . $emote_set["name"] . '" emoteset') ?> - - alright.party + <?php + echo $emote_sets != null ? (count($emote_sets) . " emotesets") : ('"' . $emote_set["name"] . '" emoteset'); + echo ' - ' . INSTANCE_NAME; + ?> </title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/inbox.php b/public/inbox.php index 878bfe4..7d632b6 100644 --- a/public/inbox.php +++ b/public/inbox.php @@ -23,7 +23,7 @@ $stmt->execute([$_SESSION["user_id"]]); <html> <head> - <title>Inbox - alright.party</title> + <title>Inbox - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/index.php b/public/index.php index 8f1d7dd..1b1c33b 100644 --- a/public/index.php +++ b/public/index.php @@ -7,20 +7,20 @@ authorize_user(); <html> <head> - <title>alright.party</title> + <title><?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> <body> <div class="container"> <div class="wrapper center big-gap"> - <h1><img src="/static/img/brand/big.webp" alt="<?php echo $_SERVER['HTTP_HOST']; ?>"></h1> + <h1><img src="/static/img/brand/big.webp" alt="<?php echo INSTANCE_NAME; ?>"></h1> <div class="items row" style="gap:32px;"> <a href="/emotes">Emotes</a> <a href="/emotesets.php">Emotesets</a> <a href="/users.php">Users</a> - <?php if (ANONYMOUS_UPLOAD || (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_upload"])) { + <?php if (EMOTE_UPLOAD && (ANONYMOUS_UPLOAD || (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_upload"]))) { echo '<a href="/emotes/upload.php">Upload</a>'; } ?> <a href="/account">Account</a> diff --git a/public/report/index.php b/public/report/index.php index 179c2bd..aef571e 100644 --- a/public/report/index.php +++ b/public/report/index.php @@ -5,6 +5,11 @@ include_once "../../src/partials.php"; include_once "../../src/utils.php"; include_once "../../src/alert.php"; +if (!REPORTS_ENABLE) { + generate_alert("/404.php", "Reports are disabled", 403); + exit; +} + if (!authorize_user(true)) { exit; } @@ -53,7 +58,8 @@ if ($contents == "") { <html> <head> - <title><?php echo $report == null ? "Send a message to MODS" : "A message to MODS" ?> - alright.party</title> + <title><?php echo ($report == null ? "Send a message to MODS" : "A message to MODS") . ' - ' . INSTANCE_NAME ?> + </title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/report/list.php b/public/report/list.php index 087eb55..34ddceb 100644 --- a/public/report/list.php +++ b/public/report/list.php @@ -5,6 +5,11 @@ include_once "../../src/partials.php"; include_once "../../src/utils.php"; include_once "../../src/alert.php"; +if (!REPORTS_ENABLE) { + generate_alert("/404.php", "Reports are disabled", 403); + exit; +} + if (!authorize_user(true)) { exit; } @@ -25,7 +30,7 @@ $reports = $stmt->fetchAll(PDO::FETCH_ASSOC); <html> <head> - <title>Report list - alright.party</title> + <title>Report list - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/report/send.php b/public/report/send.php index e5a77be..ab136e1 100644 --- a/public/report/send.php +++ b/public/report/send.php @@ -4,6 +4,11 @@ include_once "../../src/config.php"; include_once "../../src/utils.php"; include_once "../../src/alert.php"; +if (!REPORTS_ENABLE) { + generate_alert("/404.php", "Reports are disabled", 403); + exit; +} + if (!authorize_user(true)) { exit; } diff --git a/public/system/emotes/index.php b/public/system/emotes/index.php index f49ff97..1c16152 100644 --- a/public/system/emotes/index.php +++ b/public/system/emotes/index.php @@ -43,7 +43,7 @@ if ($emote_id > 0) { <html> <head> - <title>System panel - alright.party</title> + <title>System panel - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/system/index.php b/public/system/index.php index aa959c0..601339b 100644 --- a/public/system/index.php +++ b/public/system/index.php @@ -21,7 +21,7 @@ $db = new PDO(DB_URL, DB_USER, DB_PASS); <html> <head> - <title>System panel - alright.party</title> + <title>System panel - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/public/users.php b/public/users.php index 8b62a8a..fbedb4d 100644 --- a/public/users.php +++ b/public/users.php @@ -52,7 +52,7 @@ if ($id == "" && $alias_id == "") { <html> <head> - <title>User list - alright.party</title> + <title>User list - <?php echo INSTANCE_NAME ?></title> <link rel="stylesheet" href="/static/style.css"> </head> @@ -307,7 +307,7 @@ if ($is_json) { <html> <head> - <title><?php echo $user->username() ?> - alright.party</title> + <title><?php echo sprintf("%s - %s", $user->username(), INSTANCE_NAME) ?></title> <link rel="stylesheet" href="/static/style.css"> </head> diff --git a/src/config.php b/src/config.php deleted file mode 100644 index f5056ce..0000000 --- a/src/config.php +++ /dev/null @@ -1,32 +0,0 @@ -<?php -define("CLIENT_REQUIRES_JSON", isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json"); - -// DATABASE -define("DB_USER", "kochan"); -define("DB_PASS", "kochan"); -define("DB_URL", "mysql:host=localhost;dbname=tinyemotes;port=3306"); - -// RATINGS -define("RATING_NAMES", [ - "-1" => "COAL", - "1" => "GEM", -]); - -// UPLOADS -define("ANONYMOUS_UPLOAD", false); -define("ANONYMOUS_DEFAULT_NAME", "chud"); - -// EMOTES -define("EMOTE_NAME_MAX_LENGTH", 100); -define("EMOTE_COMMENT_MAX_LENGTH", 100); -define("EMOTE_VISIBILITY_DEFAULT", 2); - -// MODERATION -define("MOD_SYSTEM_DASHBOARD", true); -define("MOD_EMOTES_APPROVE", true); - -// ACCOUNTS -define("ACCOUNT_USERNAME_REGEX", "/^[A-Za-z0-9_]+$/"); -define("ACCOUNT_USERNAME_MAX_LENGTH", 20); -define("ACCOUNT_PFP_MAX_SIZE", [128, 128]); -define("ACCOUNT_BANNER_MAX_SIZE", [1920, 1080]);
\ No newline at end of file diff --git a/src/config.sample.php b/src/config.sample.php new file mode 100644 index 0000000..5962a20 --- /dev/null +++ b/src/config.sample.php @@ -0,0 +1,57 @@ +<?php +// INSTANCE +define("INSTANCE_NAME", "TinyEmotes"); + +// DATABASE +define("DB_USER", "ENTER_DATABASE_USER"); // Database user. MANDATORY! +define("DB_PASS", "ENTER_DATABASE_PASSWORD"); // Database password. MANDATORY! +define("DB_HOST", "ENTER_DATABASE_HOST"); // Database host. Can be 'localhost' if it's on the same machine as Tinyemotes. +define("DB_NAME", "ENTER_DATABASE_NAME"); // Database name. +define("DB_URL", 'mysql:host=' . DB_HOST . ';dbname=' . DB_NAME . ';port=3306'); // Database URL. Change it if you don't use MySQL/MariaDB. + +// RATINGS +define("RATING_ENABLE", true); // Enable ratings for emotes. +define("RATING_NAMES", [ + "-1" => "COAL", + "1" => "GEM", +]); // Rating names. The schema is [ "id/rating_point" => "name" ]. + +// UPLOADS +define("ANONYMOUS_UPLOAD", false); // Allow anonymous upload for emotes. +define("ANONYMOUS_DEFAULT_NAME", "Anonymous"); // Default uploader name for anonymous emotes. It's also used when original uploader has been deleted. + +// EMOTES +define("EMOTE_UPLOAD", true); // Enable emote upload. +define("EMOTE_NAME_MAX_LENGTH", 100); // Max length for emote name. +define("EMOTE_COMMENT_MAX_LENGTH", 100); // Max length for emote comment. +define("EMOTE_VISIBILITY_DEFAULT", 2); // Default visibility for emotes. 0 - unlisted, 1 - public, 2 - pending approval (same as unlisted). +define("EMOTE_MAX_SIZE", [128, 128]); // Max size of emote. +define("EMOTE_NAME_REGEX", "/^[A-Za-z0-9_]+$/"); // RegEx filter for emote names. + +// MODERATION +define("MOD_SYSTEM_DASHBOARD", true); // Enable system dashboard for moderators (/system). +define("MOD_EMOTES_APPROVE", true); // Enable manual emote approval (/system/emotes). + +// REPORTS +define("REPORTS_ENABLE", true); // Enable emote, user reports. + +// ACCOUNTS +define("ACCOUNT_REGISTRATION_ENABLE", true); // Enable account registration. +define("ACCOUNT_USERNAME_REGEX", "/^[A-Za-z0-9_]+$/"); // RegEx filter for account usernames. +define("ACCOUNT_USERNAME_MAX_LENGTH", 20); // Max length for account usernames. +define("ACCOUNT_PFP_MAX_SIZE", [128, 128]); // Max dimensions for account pictures. +define("ACCOUNT_BANNER_MAX_SIZE", [1920, 1080]); // Max dimensions for account banners. + +// TWITCH +define("TWITCH_REGISTRATION_ENABLE", false); // Enable account registration via Twitch. +define("TWITCH_CLIENT_ID", "AAAAAAAAA"); // Client ID of your Twitch application. +define("TWITCH_SECRET_KEY", "BBBBBBBBB"); // Secret key of your Twitch application. +define("TWITCH_REDIRECT_URI", ((isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off') ? "https" : "http") . "://$_SERVER[HTTP_HOST]/account/login/twitch.php"); // Redirect URI of your Twitch application. + +// HCAPTCHA +define("HCAPTCHA_ENABLE", true); // Enable hCaptcha. +define("HCAPTCHA_SECRETKEY", "ES_XXXXXX"); // hCaptcha's secret key. +define("HCAPTCHA_SITEKEY", "YYYYYYY"); // hCaptcha's site key. + +// FOR DEVELOPERS +define("CLIENT_REQUIRES_JSON", isset($_SERVER["HTTP_ACCEPT"]) && $_SERVER["HTTP_ACCEPT"] == "application/json");
\ No newline at end of file diff --git a/src/partials.php b/src/partials.php index 2a560df..2314810 100644 --- a/src/partials.php +++ b/src/partials.php @@ -5,13 +5,13 @@ function html_navigation_bar() <section class="navbar"> <a href="/" class="brand" style="color:black;text-decoration:none;"> <img src="/static/img/brand/mini.webp" alt=""> - <h2 style="margin-left:8px;font-size:24px;"><b><?php echo "alright.party" ?></b></h2> + <h2 style="margin-left:8px;font-size:24px;"><b><?php echo INSTANCE_NAME ?></b></h2> </a> <div class="links"> <a href="/emotes" class="button">Emotes</a> <a href="/emotesets.php" class="button">Emotesets</a> <a href="/users.php" class="button">Users</a> - <?php if (ANONYMOUS_UPLOAD || (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_upload"])) { + <?php if (EMOTE_UPLOAD && (ANONYMOUS_UPLOAD || (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_upload"]))) { echo '<a href="/emotes/upload.php" class="button">Upload</a>'; } ?> <a href="/account" class="button">Account</a> @@ -31,7 +31,7 @@ function html_navigation_bar() $stmt = null; if (isset($_SESSION["user_role"])) { - if ($_SESSION["user_role"]["permission_report"]) { + if (REPORTS_ENABLE && $_SESSION["user_role"]["permission_report"]) { // getting reports $stmt = $db->prepare("SELECT COUNT(*) FROM reports WHERE sender_id = ? AND resolved_by IS NULL"); $stmt->execute([$_SESSION["user_id"]]); |
