diff options
| -rw-r--r-- | 404.php | 4 | ||||
| -rw-r--r-- | account/index.php | 8 | ||||
| -rw-r--r-- | account/login/index.php | 6 | ||||
| -rw-r--r-- | account/register.php | 6 | ||||
| -rw-r--r-- | emotes/index.php | 23 | ||||
| -rw-r--r-- | emotes/upload.php | 560 | ||||
| -rw-r--r-- | emotesets.php | 2 | ||||
| -rw-r--r-- | inbox.php | 2 | ||||
| -rw-r--r-- | index.php | 4 | ||||
| -rw-r--r-- | lib/alert.php | 6 | ||||
| -rw-r--r-- | lib/emote.php | 10 | ||||
| -rw-r--r-- | lib/partials.php | 26 | ||||
| -rw-r--r-- | report/index.php | 14 | ||||
| -rw-r--r-- | report/list.php | 2 | ||||
| -rw-r--r-- | rules.php | 4 | ||||
| -rw-r--r-- | software.php | 2 | ||||
| -rw-r--r-- | system/emotes/index.php | 9 | ||||
| -rw-r--r-- | system/index.php | 2 | ||||
| -rw-r--r-- | users.php | 26 |
19 files changed, 354 insertions, 362 deletions
@@ -15,7 +15,7 @@ $reason = str_safe($_GET["error_reason"] ?? "Not found", 200); <html> <head> - <title>(Error) <?php echo sprintf("%s - %s", $reason, CONFIG['instance']['name']) ?></title> + <title>(Error) <?= sprintf("%s - %s", $reason, CONFIG['instance']['name']) ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -25,7 +25,7 @@ $reason = str_safe($_GET["error_reason"] ?? "Not found", 200); <div class="wrapper"> <?php html_navigation_bar() ?> <section class="content"> - <h1 style="color: red;"><?php echo $reason ?></h1> + <h1 style="color: red;"><?= $reason ?></h1> <a href="/">[ Back to home ]</a> </section> diff --git a/account/index.php b/account/index.php index bb4bff6..86bf659 100644 --- a/account/index.php +++ b/account/index.php @@ -104,7 +104,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { <html> <head> - <title>Account management - <?php echo CONFIG['instance']['name'] ?></title> + <title>Account management - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -186,7 +186,7 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { </div> <h3>Username</h3> - <input type="text" name="username" id="username" value="<?php echo $_SESSION["user_name"] ?>"> + <input type="text" name="username" id="username" value="<?= $_SESSION["user_name"] ?>"> <button type="submit">Save</button> </form> @@ -293,9 +293,9 @@ if ($_SERVER['REQUEST_METHOD'] == "POST") { let validUsername = ""; username.addEventListener("input", (e) => { - const regex = <?php echo CONFIG['account']['regex'] ?>; + const regex = <?= CONFIG['account']['regex'] ?>; - if (regex.test(e.target.value) && e.target.value.length <= <?php echo CONFIG['account']['maxusernamelength'] ?>) { + if (regex.test(e.target.value) && e.target.value.length <= <?= CONFIG['account']['maxusernamelength'] ?>) { validUsername = e.target.value; } else { e.target.value = validUsername; diff --git a/account/login/index.php b/account/login/index.php index b4223f2..14f7c4e 100644 --- a/account/login/index.php +++ b/account/login/index.php @@ -44,7 +44,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { <html> <head> - <title>Login - <?php echo CONFIG['instance']['name'] ?></title> + <title>Login - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -57,7 +57,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { <?php display_alert() ?> <section class="box"> <div class="box navtab"> - <p>Log in to <?php echo CONFIG['instance']['name'] ?></p> + <p>Log in to <?= CONFIG['instance']['name'] ?></p> </div> <div class="box content"> <form action="/account/login/" method="post"> @@ -87,7 +87,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { <section class="box column"> <a href="/account/login/twitch.php" class="button purple big">Login with Twitch</a> <p style="font-size: 12px;">Logging in via Twitch gives you the ability to use - <?php echo CONFIG['instance']['name'] ?> emotes in your Twitch chat. + <?= CONFIG['instance']['name'] ?> emotes in your Twitch chat. </p> </section> <?php endif; ?> diff --git a/account/register.php b/account/register.php index 59ea886..292684d 100644 --- a/account/register.php +++ b/account/register.php @@ -67,7 +67,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { <html> <head> - <title>Register an account - <?php echo CONFIG['instance']['name'] ?></title> + <title>Register an account - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -81,7 +81,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { <?php display_alert() ?> <section class="box"> <div class="box navtab"> - <p>Register an account in <?php echo CONFIG['instance']['name'] ?></p> + <p>Register an account in <?= CONFIG['instance']['name'] ?></p> </div> <div class="box content"> <form action="/account/register.php" method="post"> @@ -98,7 +98,7 @@ if ($_SERVER["REQUEST_METHOD"] == "POST") { </div> </form> <p style="font-size: 12px;"> - Since <?php echo CONFIG['instance']['name'] ?> doesn't require email and password reset via + Since <?= CONFIG['instance']['name'] ?> doesn't require email and password reset via email is not supported, please remember your passwords! </p> diff --git a/emotes/index.php b/emotes/index.php index 3999d8e..06d9e43 100644 --- a/emotes/index.php +++ b/emotes/index.php @@ -240,10 +240,9 @@ if (CLIENT_REQUIRES_JSON) { if (isset($_SESSION["user_role"]) && $_SESSION["user_role"]["permission_emoteset_own"]) { echo '' ?> <form action="/emotes/setmanip.php" method="POST"> - <input type="text" name="id" value="<?php echo $emote->get_id() ?>" - style="display: none;"> + <input type="text" name="id" value="<?= $emote->get_id() ?>" style="display: none;"> <input type="text" name="emote_set_id" - value="<?php echo $_SESSION["user_active_emote_set_id"] ?>" style="display: none;"> + value="<?= $_SESSION["user_active_emote_set_id"] ?>" style="display: none;"> <?php if ($added) { ?> @@ -251,13 +250,11 @@ if (CLIENT_REQUIRES_JSON) { <button type="submit" class="red">Remove from my channel</button> </form> <form action="/emotes/setmanip.php" method="POST" class="row"> - <input type="text" name="id" value="<?php echo $emote->get_id() ?>" - style="display: none;"> + <input type="text" name="id" value="<?= $emote->get_id() ?>" style="display: none;"> <input type="text" name="emote_set_id" - value="<?php echo $_SESSION["user_active_emote_set_id"] ?>" style="display: none;"> + value="<?= $_SESSION["user_active_emote_set_id"] ?>" style="display: none;"> <input type="text" name="value" id="emote-alias-input" - value="<?php echo $emote_current_name ?>" - placeholder="<?php echo $emote->get_code() ?>"> + value="<?= $emote_current_name ?>" placeholder="<?= $emote->get_code() ?>"> <input type="text" name="action" value="alias" style="display: none;"> <button type="submit" class="transparent"><img src="/static/img/icons/pencil.png" alt="Rename" title="Rename"></button> @@ -276,15 +273,13 @@ if (CLIENT_REQUIRES_JSON) { <?php if ($emote->get_uploaded_by() === $_SESSION["user_id"]): ?> <form action="/emotes/delete.php" method="post"> - <input type="text" name="id" value="<?php echo $emote->get_id() ?>" - style="display: none;"> + <input type="text" name="id" value="<?= $emote->get_id() ?>" style="display: none;"> <button type="submit" class="transparent"> <img src="/static/img/icons/bin.png" alt="Delete emote" title="Delete emote"> </button> </form> <form action="/emotes/delete.php" method="post"> - <input type="text" name="id" value="<?php echo $emote->get_id() ?>" - style="display: none;"> + <input type="text" name="id" value="<?= $emote->get_id() ?>" style="display: none;"> <input type="text" name="unlink" value="1" style="display:none"> <button type="submit" class="transparent"> <img src="/static/img/icons/link_break.png" alt="Remove your authorship" @@ -481,8 +476,8 @@ if (CLIENT_REQUIRES_JSON) { <tr> <th>Source</th> <td> - <a href="<?php echo $emote->get_source() ?>" - target="_blank"><?php echo $emote->get_source() ?></a> + <a href="<?= $emote->get_source() ?>" + target="_blank"><?= $emote->get_source() ?></a> </td> </tr> <?php endif; ?> diff --git a/emotes/upload.php b/emotes/upload.php index e509345..d931c05 100644 --- a/emotes/upload.php +++ b/emotes/upload.php @@ -46,145 +46,145 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { include "{$_SERVER['DOCUMENT_ROOT']}/lib/partials.php"; echo '' ?> - <html> - - <head> - <title>Upload an emote - <?php echo CONFIG['instance']['name'] ?></title> - <link rel="stylesheet" href="/static/style.css"> - <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> - </head> - - <body> - <div class="container"> - <div class="wrapper"> - <?php html_navigation_bar() ?> - <?php display_alert() ?> - - <section class="content row"> - <div class="column small-gap"> - <section class="box"> - <div class="box navtab"> - <div> - <b>Upload a new emote</b> - <p style="font-size:8px;">You can just upload, btw. Anything you want.</p> - </div> + <html> + + <head> + <title>Upload an emote - <?= CONFIG['instance']['name'] ?></title> + <link rel="stylesheet" href="/static/style.css"> + <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> + </head> + + <body> + <div class="container"> + <div class="wrapper"> + <?php html_navigation_bar() ?> + <?php display_alert() ?> + + <section class="content row"> + <div class="column small-gap"> + <section class="box"> + <div class="box navtab"> + <div> + <b>Upload a new emote</b> + <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>Image<span style="color:red;">*</span></h3> + + <input type="file" name="file" id="form-file" accept=".gif,.jpg,.jpeg,.png,.webp" + required> + + <div id="form-manual-files" style="display:none;"> + <input type="file" name="file-1x" id="form-file-1x" + accept=".gif,.jpg,.jpeg,.png,.webp"> + <label class="inline" + for="file-1x"><?= sprintf("%dx%d", CONFIG['emote']['maxsizex'] / 4, CONFIG['emote']['maxsizey'] / 4) ?></label> + <input type="file" name="file-2x" id="form-file-2x" + accept=".gif,.jpg,.jpeg,.png,.webp"> + <label class="inline" + for="file-2x"><?= sprintf("%dx%d", CONFIG['emote']['maxsizex'] / 2, CONFIG['emote']['maxsizey'] / 2) ?></label> + <input type="file" name="file-3x" id="form-file-3x" + accept=".gif,.jpg,.jpeg,.png,.webp"> + <label class="inline" + for="file-3x"><?= sprintf("%dx%d", CONFIG['emote']['maxsizex'], CONFIG['emote']['maxsizey']) ?></label> </div> - <div class="box content"> - <form action="/emotes/upload.php" method="POST" enctype="multipart/form-data"> - <h3>Image<span style="color:red;">*</span></h3> - - <input type="file" name="file" id="form-file" accept=".gif,.jpg,.jpeg,.png,.webp" - required> - - <div id="form-manual-files" style="display:none;"> - <input type="file" name="file-1x" id="form-file-1x" - accept=".gif,.jpg,.jpeg,.png,.webp"> - <label class="inline" - for="file-1x"><?php echo sprintf("%dx%d", CONFIG['emote']['maxsizex'] / 4, CONFIG['emote']['maxsizey'] / 4) ?></label> - <input type="file" name="file-2x" id="form-file-2x" - accept=".gif,.jpg,.jpeg,.png,.webp"> - <label class="inline" - for="file-2x"><?php echo sprintf("%dx%d", CONFIG['emote']['maxsizex'] / 2, CONFIG['emote']['maxsizey'] / 2) ?></label> - <input type="file" name="file-3x" id="form-file-3x" - accept=".gif,.jpg,.jpeg,.png,.webp"> - <label class="inline" - for="file-3x"><?php echo sprintf("%dx%d", CONFIG['emote']['maxsizex'], CONFIG['emote']['maxsizey']) ?></label> - </div> - - <div> - <label for="manual" class="inline">Manual resize</label> - <input type="checkbox" name="manual" value="1" onchange="display_manual_resize()"> - </div> - - <h3>Emote name<span style="color:red;">*</span></h3> - <input type="text" name="code" id="code" required> - - <div> - <label for="visibility" class="inline">Emote visibility: </label> - <select name="visibility" id="form-visibility"> - <option value="1">Public</option> - <option value="0">Unlisted</option> - </select><br> - <p id="form-visibility-description" style="font-size: 10px;">test</p> - </div> - - <label for="notes">Approval notes</label> - <textarea name="notes" id="form-notes"></textarea> - - <table class="vertical left font-weight-normal"> - <tr> - <th>Emote source:</th> - <td class="flex"><input class="grow" name="source" id="form-source"></input> - </td> - </tr> - <?php if (CONFIG['tags']['enable'] && CONFIG['tags']['maxcount'] != 0): ?> - <tr> - <th>Tags <span class="font-small" style="cursor: help;" title="<?php - echo 'Tags are used for fast search. '; - if (CONFIG['tags']['maxcount'] > 0) { - echo 'You can use ' . CONFIG['tags']['maxcount'] . ' tags. '; - } - echo 'They are space-separated o algo.'; - ?>">[?]</span>: - </th> - <td class="flex"><input class="grow" name="tags" id="form-tags"></input></td> - </tr> - <?php endif; ?> - </table> - - <div> - <label for="tos" class="inline">Do you accept <a href="/rules.php" - target="_BLANK">the - rules</a>?<span style="color:red;">*</span></label> - <input type="checkbox" name="tos" value="1" required> - </div> - - <button type="submit" id="upload-button">Upload as - <?php echo $uploader_name ?></button> - </form> + + <div> + <label for="manual" class="inline">Manual resize</label> + <input type="checkbox" name="manual" value="1" onchange="display_manual_resize()"> </div> - </section> - <?php - if (CONFIG['captcha']['enable'] && (CONFIG['captcha']['force'] || !isset($_SESSION["user_id"]))) { - html_captcha_form(); - } - ?> - </div> + <h3>Emote name<span style="color:red;">*</span></h3> + <input type="text" name="code" id="code" required> - <div class="column small-gap grow" id="emote-showcase" style="display: none;"> - <!-- Emote Preview --> - <section class="box"> - <div class="box navtab"> - Emote Preview - <span id="emote-name"><i>Empty</i></span> + <div> + <label for="visibility" class="inline">Emote visibility: </label> + <select name="visibility" id="form-visibility"> + <option value="1">Public</option> + <option value="0">Unlisted</option> + </select><br> + <p id="form-visibility-description" style="font-size: 10px;">test</p> </div> - <div class="box content"> - <div class="emote-showcase items-bottom"> - <div class="emote-image column items-center small-gap"> - <img src="" alt="" class="emote-image-1x"> - <p class="size font-small"></p> - </div> - <div class="emote-image column items-center small-gap"> - <img src="" alt="" class="emote-image-2x"> - <p class="size font-small"></p> - </div> - <div class="emote-image column items-center small-gap"> - <img src="" alt="" class="emote-image-3x"> - <p class="size font-small"></p> - </div> - </div> - <p style="font-size: 12px;">The result may differ.</p> + + <label for="notes">Approval notes</label> + <textarea name="notes" id="form-notes"></textarea> + + <table class="vertical left font-weight-normal"> + <tr> + <th>Emote source:</th> + <td class="flex"><input class="grow" name="source" id="form-source"></input> + </td> + </tr> + <?php if (CONFIG['tags']['enable'] && CONFIG['tags']['maxcount'] != 0): ?> + <tr> + <th>Tags <span class="font-small" style="cursor: help;" title="<?php + echo 'Tags are used for fast search. '; + if (CONFIG['tags']['maxcount'] > 0) { + echo 'You can use ' . CONFIG['tags']['maxcount'] . ' tags. '; + } + echo 'They are space-separated o algo.'; + ?>">[?]</span>: + </th> + <td class="flex"><input class="grow" name="tags" id="form-tags"></input></td> + </tr> + <?php endif; ?> + </table> + + <div> + <label for="tos" class="inline">Do you accept <a href="/rules.php" + target="_BLANK">the + rules</a>?<span style="color:red;">*</span></label> + <input type="checkbox" name="tos" value="1" required> </div> - </section> - <!-- Chat Preview --> - <section class="box"> - <div class="box navtab"> - Chat Preview + <button type="submit" id="upload-button">Upload as + <?= $uploader_name ?></button> + </form> + </div> + </section> + + <?php + if (CONFIG['captcha']['enable'] && (CONFIG['captcha']['force'] || !isset($_SESSION["user_id"]))) { + html_captcha_form(); + } + ?> + </div> + + <div class="column small-gap grow" id="emote-showcase" style="display: none;"> + <!-- Emote Preview --> + <section class="box"> + <div class="box navtab"> + Emote Preview - <span id="emote-name"><i>Empty</i></span> + </div> + <div class="box content"> + <div class="emote-showcase items-bottom"> + <div class="emote-image column items-center small-gap"> + <img src="" alt="" class="emote-image-1x"> + <p class="size font-small"></p> + </div> + <div class="emote-image column items-center small-gap"> + <img src="" alt="" class="emote-image-2x"> + <p class="size font-small"></p> </div> - <div class="box content no-gap column chat rounded"> - <?php - $stmt = $db->query("SELECT u.username, + <div class="emote-image column items-center small-gap"> + <img src="" alt="" class="emote-image-3x"> + <p class="size font-small"></p> + </div> + </div> + <p style="font-size: 12px;">The result may differ.</p> + </div> + </section> + + <!-- Chat Preview --> + <section class="box"> + <div class="box navtab"> + Chat Preview + </div> + <div class="box content no-gap column chat rounded"> + <?php + $stmt = $db->query("SELECT u.username, CASE WHEN ub.badge_id IS NOT NULL THEN ub.badge_id WHEN r.badge_id IS NOT NULL THEN r.badge_id @@ -197,191 +197,191 @@ if ($_SERVER['REQUEST_METHOD'] != "POST") { ORDER BY RAND() LIMIT 3 "); - while ($row = $stmt->fetch()) { - echo '<div class="row small-gap items-center chat-message">'; + while ($row = $stmt->fetch()) { + echo '<div class="row small-gap items-center chat-message">'; - if ($row["badge_id"]) { - echo '<img src="/static/userdata/badges/' . $row["badge_id"] . '/1x.webp" alt="" title="" /> '; - } + if ($row["badge_id"]) { + echo '<img src="/static/userdata/badges/' . $row["badge_id"] . '/1x.webp" alt="" title="" /> '; + } - echo '<span style="color: rgb(' . random_int(128, 255) . ', ' . random_int(128, 255) . ', ' . random_int(128, 255) . ')">'; - echo $row["username"]; - echo ': </span>'; + echo '<span style="color: rgb(' . random_int(128, 255) . ', ' . random_int(128, 255) . ', ' . random_int(128, 255) . ')">'; + echo $row["username"]; + echo ': </span>'; - echo '<img src="" alt="" class="emote-image-1x">'; + echo '<img src="" alt="" class="emote-image-1x">'; - echo '</div>'; - } - ?> - </div> - </section> + echo '</div>'; + } + ?> </div> </section> </div> - </div> - </body> - - <script> - const max_width = <?php echo CONFIG['emote']['maxsizex'] ?>; - const max_height = <?php echo CONFIG['emote']['maxsizey'] ?>; - - const fileInput = document.getElementById("form-file"); - const showcase = document.getElementById("emote-showcase"); - const reader = new FileReader(); - - let manual = false; - - fileInput.addEventListener("change", (e) => { - if (manual) return; - - showcase.style.display = "flex"; - reader.readAsDataURL(e.target.files[0]); - reader.onload = (e) => { - const image = new Image(); - image.src = e.target.result; - image.onload = () => { - let m = 1; - - for (let i = 3; i > 0; i--) { - place_image(i, m, e, image); - m *= 2; - } - }; - }; - }); + </section> + </div> + </div> + </body> + + <script> + const max_width = <?= CONFIG['emote']['maxsizex'] ?>; + const max_height = <?= CONFIG['emote']['maxsizey'] ?>; + + const fileInput = document.getElementById("form-file"); + const showcase = document.getElementById("emote-showcase"); + const reader = new FileReader(); + + let manual = false; + + fileInput.addEventListener("change", (e) => { + if (manual) return; + + showcase.style.display = "flex"; + reader.readAsDataURL(e.target.files[0]); + reader.onload = (e) => { + const image = new Image(); + image.src = e.target.result; + image.onload = () => { + let m = 1; + + for (let i = 3; i > 0; i--) { + place_image(i, m, e, image); + m *= 2; + } + }; + }; + }); - const code = document.getElementById("code"); + const code = document.getElementById("code"); - code.addEventListener("input", (e) => { - const regex = <?php echo CONFIG['emote']['nameregex'] ?>; + code.addEventListener("input", (e) => { + const regex = <?= CONFIG['emote']['nameregex'] ?>; - if (regex.test(e.target.value) && e.target.value.length <= <?php echo CONFIG['emote']['maxnamelength'] ?>) { - validCode = e.target.value; - } else { - e.target.value = validCode; - } + if (regex.test(e.target.value) && e.target.value.length <= <?= CONFIG['emote']['maxnamelength'] ?>) { + validCode = e.target.value; + } else { + e.target.value = validCode; + } - document.getElementById("emote-name").innerHTML = e.target.value ? e.target.value : "<i>Empty</i>"; - }); + document.getElementById("emote-name").innerHTML = e.target.value ? e.target.value : "<i>Empty</i>"; + }); - const visibility = document.getElementById("form-visibility"); - visibility.addEventListener("change", (e) => { - set_form_visibility_description(visibility.value); - }); + const visibility = document.getElementById("form-visibility"); + visibility.addEventListener("change", (e) => { + set_form_visibility_description(visibility.value); + }); - function set_form_visibility_description(visibility) { - const p = document.getElementById("form-visibility-description"); + function set_form_visibility_description(visibility) { + const p = document.getElementById("form-visibility-description"); - if (visibility == 1) { - p.innerHTML = "Emote won't appear on the public list until it passes a moderator's review. It still can be added to chats."; - } else { - p.innerHTML = "Emote doesn't appear on the public list and won't be subject to moderation checks. It still can be added to chats."; - } - } + if (visibility == 1) { + p.innerHTML = "Emote won't appear on the public list until it passes a moderator's review. It still can be added to chats."; + } else { + p.innerHTML = "Emote doesn't appear on the public list and won't be subject to moderation checks. It still can be added to chats."; + } + } - set_form_visibility_description(visibility.value); + set_form_visibility_description(visibility.value); - // Manual resize - function display_manual_resize() { - const manual_files = document.getElementById("form-manual-files"); + // Manual resize + function display_manual_resize() { + const manual_files = document.getElementById("form-manual-files"); - // resetting previous values - const files = document.querySelectorAll("input[type=file]"); + // resetting previous values + const files = document.querySelectorAll("input[type=file]"); - for (let file of files) { - file.value = null; - file.removeAttribute("required"); - } + for (let file of files) { + file.value = null; + file.removeAttribute("required"); + } - const fileImages = document.querySelectorAll(".emote-image img"); + const fileImages = document.querySelectorAll(".emote-image img"); - for (let file of fileImages) { - file.setAttribute("src", ""); - file.setAttribute("width", "0"); - file.setAttribute("height", "0"); - } + for (let file of fileImages) { + file.setAttribute("src", ""); + file.setAttribute("width", "0"); + file.setAttribute("height", "0"); + } - const fileSizes = document.querySelectorAll(".emote-image .size"); + const fileSizes = document.querySelectorAll(".emote-image .size"); - for (let file of fileImages) { - file.innerHTML = ""; - } + for (let file of fileImages) { + file.innerHTML = ""; + } - manual = !manual; + manual = !manual; - if (manual) { - manual_files.style.display = "block"; - fileInput.style.display = "none"; - const elements = document.querySelectorAll("#form-manual-files input[type=file]"); - for (let elem of elements) { - elem.setAttribute("required", "true"); - } - } else { - manual_files.style.display = "none"; - fileInput.style.display = "block"; - fileInput.setAttribute("required", "true"); - } - - showcase.style.display = "none"; + if (manual) { + manual_files.style.display = "block"; + fileInput.style.display = "none"; + const elements = document.querySelectorAll("#form-manual-files input[type=file]"); + for (let elem of elements) { + elem.setAttribute("required", "true"); } + } else { + manual_files.style.display = "none"; + fileInput.style.display = "block"; + fileInput.setAttribute("required", "true"); + } - document.getElementById("form-file-1x").addEventListener("change", (e) => { - showcase.style.display = "flex"; - place_image(1, 4, e, null); - }); - - document.getElementById("form-file-2x").addEventListener("change", (e) => { - showcase.style.display = "flex"; - place_image(2, 2, e, null); - }); - - document.getElementById("form-file-3x").addEventListener("change", (e) => { - showcase.style.display = "flex"; - place_image(3, 1, e, null); - }); - - function place_image(image_index, multiplier, e, image) { - let ee = e; - - if (image == null) { - reader.readAsDataURL(e.target.files[0]); - reader.onload = (e) => { - const image = new Image(); - image.src = e.target.result; - image.onload = () => { - insert_image(image_index, multiplier, e, image); - }; - } - } else { + showcase.style.display = "none"; + } + + document.getElementById("form-file-1x").addEventListener("change", (e) => { + showcase.style.display = "flex"; + place_image(1, 4, e, null); + }); + + document.getElementById("form-file-2x").addEventListener("change", (e) => { + showcase.style.display = "flex"; + place_image(2, 2, e, null); + }); + + document.getElementById("form-file-3x").addEventListener("change", (e) => { + showcase.style.display = "flex"; + place_image(3, 1, e, null); + }); + + function place_image(image_index, multiplier, e, image) { + let ee = e; + + if (image == null) { + reader.readAsDataURL(e.target.files[0]); + reader.onload = (e) => { + const image = new Image(); + image.src = e.target.result; + image.onload = () => { insert_image(image_index, multiplier, e, image); - } + }; + } + } else { + insert_image(image_index, multiplier, e, image); + } - function insert_image(i, m, e, image) { - const max_w = max_width / multiplier; - const max_h = max_height / multiplier; + function insert_image(i, m, e, image) { + const max_w = max_width / multiplier; + const max_h = max_height / multiplier; - const parentId = `.emote-image-${image_index}x`; - const imgs = document.querySelectorAll(parentId); + const parentId = `.emote-image-${image_index}x`; + const imgs = document.querySelectorAll(parentId); - for (const img of imgs) { - img.setAttribute("src", e.target.result); + for (const img of imgs) { + img.setAttribute("src", e.target.result); - let ratio = Math.min(max_w / image.width, max_h / image.height); + let ratio = Math.min(max_w / image.width, max_h / image.height); - img.setAttribute("width", Math.floor(image.width * ratio)); - img.setAttribute("height", Math.floor(image.height * ratio)); + img.setAttribute("width", Math.floor(image.width * ratio)); + img.setAttribute("height", Math.floor(image.height * ratio)); - const sizeElement = document.querySelector(`.emote-image:has(${parentId}) .size`); - sizeElement.innerHTML = `${img.getAttribute("width")}x${img.getAttribute("height")}`; - } - } + const sizeElement = document.querySelector(`.emote-image:has(${parentId}) .size`); + sizeElement.innerHTML = `${img.getAttribute("width")}x${img.getAttribute("height")}`; } - </script> + } + } + </script> - </html> + </html> - <?php - exit; + <?php + exit; } if (!CLIENT_REQUIRES_JSON && CONFIG['captcha']['enable'] && !isset($_SESSION["captcha_solved"])) { diff --git a/emotesets.php b/emotesets.php index e2dae57..35675ce 100644 --- a/emotesets.php +++ b/emotesets.php @@ -136,7 +136,7 @@ if (CLIENT_REQUIRES_JSON) { <section class="box"> <div class="box navtab row"> <div class="grow"> - <?php echo $title ?> + <?= $title ?> </div> <?php if (!empty($emote_set)) { @@ -23,7 +23,7 @@ $stmt->execute([$_SESSION["user_id"]]); <html> <head> - <title>Inbox - <?php echo CONFIG['instance']['name'] ?></title> + <title>Inbox - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -15,7 +15,7 @@ authorize_user(); <html> <head> - <title><?php echo CONFIG['instance']['name'] ?></title> + <title><?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -23,7 +23,7 @@ authorize_user(); <body> <div class="container"> <div class="wrapper center big-gap"> - <h1><img src="/static/img/brand/big.webp" alt="<?php echo CONFIG['instance']['name']; ?>"></h1> + <h1><img src="/static/img/brand/big.webp" alt="<?= CONFIG['instance']['name']; ?>"></h1> <div class="items row" style="gap:32px;"> <a href="/emotes">Emotes</a> diff --git a/lib/alert.php b/lib/alert.php index 823a97a..2983378 100644 --- a/lib/alert.php +++ b/lib/alert.php @@ -26,9 +26,9 @@ function display_alert() $ok = substr($status, 0, 1) == '2'; echo '' ?> - <div class="box row alert <?php echo $ok ? '' : 'red' ?>" style="gap:8px;" id="alert-box"> - <img src="/static/img/icons/<?php echo $ok ? 'yes' : 'no' ?>.png" alt=""> - <p><b><?php echo $reason ?></b></p> + <div class="box row alert <?= $ok ? '' : 'red' ?>" style="gap:8px;" id="alert-box"> + <img src="/static/img/icons/<?= $ok ? 'yes' : 'no' ?>.png" alt=""> + <p><b><?= $reason ?></b></p> </div> <script> setTimeout(() => { diff --git a/lib/emote.php b/lib/emote.php index ce39c09..a724914 100644 --- a/lib/emote.php +++ b/lib/emote.php @@ -209,9 +209,8 @@ function html_random_emote(PDO &$db) <p>Random emote</p> </div> <div class="box content center"> - <a href="/emotes?id=<?php echo $row["id"] ?>"> - <img src="/static/userdata/emotes/<?php echo $row["id"] ?>/3x.webp" alt="<?php echo $row["code"] ?>" - width="192"> + <a href="/emotes?id=<?= $row["id"] ?>"> + <img src="/static/userdata/emotes/<?= $row["id"] ?>/3x.webp" alt="<?= $row["code"] ?>" width="192"> </a> </div> </section> @@ -236,9 +235,8 @@ function html_featured_emote(PDO &$db) <p>Featured emote</p> </div> <div class="box content center"> - <a href="/emotes?id=<?php echo $row["id"] ?>"> - <img src="/static/userdata/emotes/<?php echo $row["id"] ?>/3x.webp" alt="<?php echo $row["code"] ?>" - width="192"> + <a href="/emotes?id=<?= $row["id"] ?>"> + <img src="/static/userdata/emotes/<?= $row["id"] ?>/3x.webp" alt="<?= $row["code"] ?>" width="192"> </a> </div> </section> diff --git a/lib/partials.php b/lib/partials.php index 979621d..60d1325 100644 --- a/lib/partials.php +++ b/lib/partials.php @@ -34,7 +34,7 @@ function html_navigation_bar() $unread_count = intval($stmt->fetch()[0]); echo '' ?> <a href="/inbox.php" class="button"> - Inbox <?php echo $unread_count > 0 ? "($unread_count)" : "" ?> + Inbox <?= $unread_count > 0 ? "($unread_count)" : "" ?> </a> <?php ; $stmt = null; @@ -48,7 +48,7 @@ function html_navigation_bar() echo '' ?> <a href="/report/list.php" class="button"> - Reports <?php echo $unread_count > 0 ? "($unread_count)" : "" ?> + Reports <?= $unread_count > 0 ? "($unread_count)" : "" ?> </a> <?php ; } @@ -81,7 +81,7 @@ function html_navigation_bar() <div class="flex items-bottom small-gap" style="margin-left: auto;"> <?php if (isset($_SESSION["user_emote_sets"])): ?> <form action="/account/change_emoteset.php" method="POST" id="form-change-emoteset"> - <input type="text" name="redirect" value="<?php echo $_SERVER["REQUEST_URI"] ?>" style="display: none;"> + <input type="text" name="redirect" value="<?= $_SERVER["REQUEST_URI"] ?>" style="display: none;"> <div class="row small-gap"> <label for="id">Current emote set: </label> <select name="id" onchange="send_change_emoteset(event)"> @@ -100,8 +100,8 @@ function html_navigation_bar() </script> <?php endif; ?> - <a href="/users.php?id=<?php echo $_SESSION["user_id"] ?>" class="flex items-bottom small-gap"> - Signed in as <?php echo $_SESSION["user_name"] ?> + <a href="/users.php?id=<?= $_SESSION["user_id"] ?>" class="flex items-bottom small-gap"> + Signed in as <?= $_SESSION["user_name"] ?> <?php echo '<img src="/static/'; if (is_dir($_SERVER['DOCUMENT_ROOT'] . "/static/userdata/avatars/" . $_SESSION["user_id"])) { @@ -129,20 +129,20 @@ function html_navigation_search() Search... </div> <div class="box content"> - <form action="<?php echo $_SERVER["REQUEST_URI"] ?>" method="GET"> - <input type="text" name="q" style="padding:4px;" value="<?php echo $_GET["q"] ?? "" ?>"><br> + <form action="<?= $_SERVER["REQUEST_URI"] ?>" method="GET"> + <input type="text" name="q" style="padding:4px;" value="<?= $_GET["q"] ?? "" ?>"><br> <?php if (str_starts_with($_SERVER["REQUEST_URI"], "/emotes")) { ?> <label for="sort_by">Sort by</label> <select name="sort_by"> - <option value="high_ratings" <?php echo ($_GET["sort_by"] ?? "") == "high_ratings" ? "selected" : "" ?>> + <option value="high_ratings" <?= ($_GET["sort_by"] ?? "") == "high_ratings" ? "selected" : "" ?>> High ratings</option> - <option value="low_ratings" <?php echo ($_GET["sort_by"] ?? "") == "low_ratings" ? "selected" : "" ?>>Low + <option value="low_ratings" <?= ($_GET["sort_by"] ?? "") == "low_ratings" ? "selected" : "" ?>>Low ratings</option> - <option value="recent" <?php echo ($_GET["sort_by"] ?? "") == "recent" ? "selected" : "" ?>>Recent + <option value="recent" <?= ($_GET["sort_by"] ?? "") == "recent" ? "selected" : "" ?>>Recent </option> - <option value="oldest" <?php echo ($_GET["sort_by"] ?? "") == "oldest" ? "selected" : "" ?>>Oldest + <option value="oldest" <?= ($_GET["sort_by"] ?? "") == "oldest" ? "selected" : "" ?>>Oldest </option> </select> <?php @@ -167,10 +167,10 @@ function html_pagination(int $total_pages, int $current_page, string $redirect) echo '' ?> <div class="pagination"> <?php if ($current_page > 1): ?> - <a href="<?php echo $redirect . ($current_page - 1) ?>">[ prev ]</a> + <a href="<?= $redirect . ($current_page - 1) ?>">[ prev ]</a> <?php endif; ?> <?php if ($current_page < $total_pages): ?> - <a href="<?php echo $redirect . ($current_page + 1) ?>">[ next ]</a> + <a href="<?= $redirect . ($current_page + 1) ?>">[ next ]</a> <?php endif; ?> </div> diff --git a/report/index.php b/report/index.php index fe83855..f60e38c 100644 --- a/report/index.php +++ b/report/index.php @@ -59,7 +59,7 @@ if ($contents == "") { <head> <title> - <?php echo ($report == null ? "Send a message to MODS" : "A message to MODS") . ' - ' . CONFIG['instance']['name'] ?> + <?= ($report == null ? "Send a message to MODS" : "A message to MODS") . ' - ' . CONFIG['instance']['name'] ?> </title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> @@ -74,14 +74,14 @@ if ($contents == "") { <?php display_alert() ?> <section class="box"> <div class="box navtab"> - <?php echo $report == null ? "Send a message to MODS" : "A message to MODS" ?> + <?= $report == null ? "Send a message to MODS" : "A message to MODS" ?> </div> <?php if ($report == null) { echo '' ?> <div class="box content"> <form action="/report/send.php" method="POST"> <textarea name="contents" style="resize: none;height:250px;" autofocus - required><?php echo $contents; ?></textarea> + required><?= $contents; ?></textarea> <button type="submit">Send</button> </form> </div> <?php ; @@ -89,13 +89,13 @@ if ($contents == "") { echo '' ?> <div class="box content"> <textarea name="contents" style="resize: none;height:250px;" - disabled><?php echo $report["contents"]; ?></textarea> + disabled><?= $report["contents"]; ?></textarea> </div> </section> <section class="box"> - <p>Reported <?php echo format_timestamp(time() - strtotime($report["sent_at"])) ?> ago</p> + <p>Reported <?= format_timestamp(time() - strtotime($report["sent_at"])) ?> ago</p> <p>Status: - <?php echo $report["resolved_by"] == null ? "<b style='color:red;'>Unresolved</b>" : "<b style='color:green;'>Resolved</b>" ?> + <?= $report["resolved_by"] == null ? "<b style='color:red;'>Unresolved</b>" : "<b style='color:green;'>Resolved</b>" ?> </p> </section> <?php @@ -107,7 +107,7 @@ if ($contents == "") { </div> <div class="box content"> <textarea name="contents" style="resize: none;height:250px;" - disabled><?php echo $report["response_message"]; ?></textarea> + disabled><?= $report["response_message"]; ?></textarea> </div> </section> <?php diff --git a/report/list.php b/report/list.php index 94154fe..ed7a14d 100644 --- a/report/list.php +++ b/report/list.php @@ -30,7 +30,7 @@ $reports = $stmt->fetchAll(PDO::FETCH_ASSOC); <html> <head> - <title>Report list - <?php echo CONFIG['instance']['name'] ?></title> + <title>Report list - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -18,7 +18,7 @@ if (is_file($path)) { <html> <head> - <title>The Rules of <?php echo CONFIG['instance']['name'] ?></title> + <title>The Rules of <?= CONFIG['instance']['name'] ?></title> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> <link rel="stylesheet" href="/static/style.css"> </head> @@ -30,7 +30,7 @@ if (is_file($path)) { <div class="content row"> <div class="sidebar" style="min-width: 300px;"></div> <div class="content"> - <h1>The Rules of <?php echo CONFIG['instance']['name'] ?></h1> + <h1>The Rules of <?= CONFIG['instance']['name'] ?></h1> <ol> <?php foreach ($contents as $line) { diff --git a/software.php b/software.php index db9e4af..4650e25 100644 --- a/software.php +++ b/software.php @@ -22,7 +22,7 @@ $software = [ <html> <head> - <title>Software - <?php echo CONFIG['instance']['name'] ?></title> + <title>Software - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> diff --git a/system/emotes/index.php b/system/emotes/index.php index 79be71f..d2ac1f8 100644 --- a/system/emotes/index.php +++ b/system/emotes/index.php @@ -65,7 +65,7 @@ if (isset($_GET["id"])) { <html> <head> - <title>System panel - <?php echo CONFIG['instance']['name'] ?></title> + <title>System panel - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -201,14 +201,13 @@ if (isset($_GET["id"])) { </tr> <tr> <th>Notes</th> - <td><?php echo isset($emote["notes"]) == true ? $emote["notes"] : '<i>Empty</i>' ?></td> + <td><?= isset($emote["notes"]) == true ? $emote["notes"] : '<i>Empty</i>' ?></td> </tr> <?php if ($emote["source"]): ?> <tr> <th>Source</th> <td> - <a href="<?php echo $emote["source"] ?>" - target="_blank"><?php echo $emote["source"] ?></a> + <a href="<?= $emote["source"] ?>" target="_blank"><?= $emote["source"] ?></a> </td> </tr> <?php endif; ?> @@ -216,7 +215,7 @@ if (isset($_GET["id"])) { </section> <!-- Emote actions --> <form action="/system/emotes/verdict.php" method="post"> - <input type="text" name="id" value="<?php echo $emote["id"] ?>" style="display: none;"> + <input type="text" name="id" value="<?= $emote["id"] ?>" style="display: none;"> <input type="text" name="action" value="none" id="form-action" style="display: none;"> <div class="column small-gap"> <noscript>JavaScript is required!!!</noscript> diff --git a/system/index.php b/system/index.php index 31291be..59dedfa 100644 --- a/system/index.php +++ b/system/index.php @@ -21,7 +21,7 @@ $db = new PDO(CONFIG['database']['url'], CONFIG['database']['user'], CONFIG['dat <html> <head> - <title>System panel - <?php echo CONFIG['instance']['name'] ?></title> + <title>System panel - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -58,7 +58,7 @@ if ($id == "" && $alias_id == "") { <html> <head> - <title>User list - <?php echo CONFIG['instance']['name'] ?></title> + <title>User list - <?= CONFIG['instance']['name'] ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> @@ -74,7 +74,7 @@ if ($id == "" && $alias_id == "") { <section class="content"> <section class="box"> <div class="box navtab"> - <p><?php echo $total_users ?> Users - <?php echo "Page $page/$total_pages" ?></p> + <p><?= $total_users ?> Users - <?= "Page $page/$total_pages" ?></p> </div> <div class="box content"> <?php @@ -272,19 +272,19 @@ if ($is_json) { <html> <head> - <title><?php echo sprintf("%s - %s", $user->username, CONFIG['instance']['name']) ?></title> + <title><?= sprintf("%s - %s", $user->username, CONFIG['instance']['name']) ?></title> <link rel="stylesheet" href="/static/style.css"> <link rel="shortcut icon" href="/static/favicon.ico" type="image/x-icon"> </head> <body> - <div class="background" style="background-image: url('/static/userdata/banners/<?php echo $user->id ?>/3x.webp');"> + <div class="background" style="background-image: url('/static/userdata/banners/<?= $user->id ?>/3x.webp');"> <div class="background-layer"></div> </div> <div class="container"> <div class="wrapper"> - <?php echo html_navigation_bar() ?> + <?= html_navigation_bar() ?> <section class="content row"> <section class="sidebar flex column small-gap"> <!-- User --> @@ -322,13 +322,13 @@ if ($is_json) { }; if ($role["badge_id"]): ?> - <div class="box row small-gap items-center" style="<?php echo $bg_color; ?>"> + <div class="box row small-gap items-center" style="<?= $bg_color; ?>"> <div> - <img src="/static/userdata/badges/<?php echo $role["badge_id"] ?>/3x.webp" - alt="<?php echo $role["name"] ?>" width="54" height="54"> + <img src="/static/userdata/badges/<?= $role["badge_id"] ?>/3x.webp" + alt="<?= $role["name"] ?>" width="54" height="54"> </div> <div class="column"> - <p><?php echo $role["name"] ?></p> + <p><?= $role["name"] ?></p> <i style="color: gray">Role</i> </div> </div> @@ -360,7 +360,7 @@ if ($is_json) { </tr> <tr> <th><img src="/static/img/icons/star.png"> Contributions</th> - <td><?php echo $contributions ?></td> + <td><?= $contributions ?></td> </tr> <?php if ($fav_reactions != null) { ?> @@ -412,7 +412,7 @@ if ($is_json) { <section class="box grow user-tab" id="user-emotes"> <div class="box navtab row"> <div class="grow"> - <?php echo !empty($active_emote_set) ? $active_emote_set->name : "Emotes" ?> + <?= !empty($active_emote_set) ? $active_emote_set->name : "Emotes" ?> </div> <?php html_emotelist_mode() ?> </div> @@ -449,7 +449,7 @@ if ($is_json) { <section class="box grow user-tab" id="user-actions"> <div class="box navtab"> Actions - <?php echo $user_preferences["private_profile"] ? " <img src='/static/img/icons/eye.png' alt='(Private)' title='You are the only one who sees this' />" : "" ?> + <?= $user_preferences["private_profile"] ? " <img src='/static/img/icons/eye.png' alt='(Private)' title='You are the only one who sees this' />" : "" ?> </div> <div class="box content"> <?php @@ -555,7 +555,7 @@ if ($is_json) { <div class="box navtab row"> <div class="grow"> Uploaded emotes - <?php echo $user_preferences["private_profile"] ? " <img src='/static/img/icons/eye.png' alt='(Private)' title='You are the only one who sees this' />" : "" ?> + <?= $user_preferences["private_profile"] ? " <img src='/static/img/icons/eye.png' alt='(Private)' title='You are the only one who sees this' />" : "" ?> </div> </div> <div class="box content items"> |
