From e5b3e048b8dc6731fa383778c26eba47186e5310 Mon Sep 17 00:00:00 2001 From: Josh Ashton Date: Mon, 7 Apr 2025 19:07:22 -0600 Subject: [PATCH] fixed cropping image --- components/foot.php | 5 +++- functions/account_functions.php | 39 +++++++++++++++++------------ functions/admin_functions.php | 6 ++--- functions/article_functions.php | 1 + functions/init.php | 1 + js/profile_picture_cropper_modal.js | 17 +++++++------ test.csv | 2 -- vintagecoding.net.md | 6 +++-- 8 files changed, 44 insertions(+), 33 deletions(-) delete mode 100644 test.csv diff --git a/components/foot.php b/components/foot.php index f11d756..76bbaa1 100644 --- a/components/foot.php +++ b/components/foot.php @@ -28,7 +28,10 @@ '; } else if ($args['action'] == 'view') { - echo ' + echo ' + + + '; } } diff --git a/functions/account_functions.php b/functions/account_functions.php index 8749a3d..3c33192 100644 --- a/functions/account_functions.php +++ b/functions/account_functions.php @@ -33,6 +33,10 @@ function logout() unset($_COOKIE[$key]); } + foreach (array_keys($_SESSION) as $key) { + unset($_SESSION[$key]); + } + header('Location: articles.php'); } @@ -125,8 +129,8 @@ function signup_form($error_msg = '') - - + + No file selected. ' . $result['user_id'] . ' - ' . $result['username'] . ' - ' . $result['email'] . ' + ' . htmlspecialchars($result['username']) . ' + ' . htmlspecialchars($result['email']) . ' ' . ucwords($result['role']) . ' ' . $result['created_at'] . ' ' . $result['last_active'] . ' diff --git a/functions/article_functions.php b/functions/article_functions.php index 4aedd18..12b2db0 100644 --- a/functions/article_functions.php +++ b/functions/article_functions.php @@ -90,6 +90,7 @@ function article_page_from_markdown($article_id) $markdown = read_file_one_string($_ENV['ARTICLES_FQ_PATH'] . $article_id . '/article.md'); $parsedown = new Parsedown(); + $parsedown->setSafeMode(true); $article_content = $parsedown->text($markdown); $article_toc = ''; diff --git a/functions/init.php b/functions/init.php index 4dbf3bc..1ae8234 100644 --- a/functions/init.php +++ b/functions/init.php @@ -1,5 +1,6 @@ img_bounds.left || box_bounds.right < img_bounds.right) selection.x = clientX; @@ -100,7 +101,6 @@ document.addEventListener('DOMContentLoaded', function() { corners.forEach((corner) => { corner.addEventListener('mousedown', (e) => { - console.log('resizing'); selection.resize_corner = corner.id; selection.is_resizing = true; e.stopPropagation(); // Prevent image click event @@ -112,8 +112,9 @@ document.addEventListener('DOMContentLoaded', function() { }); crop_button.addEventListener('click', () => { - document.getElementById('crop_x').value = selection.x + (selection.width / 1.5); - document.getElementById('crop_y').value = selection.y + (selection.width / 1.5); + var ratio = img_to_crop.naturalWidth / img_bounds.width; + document.getElementById('crop_x').value = (selection.x - img_bounds.left - (selection.width / 2)) * ratio; + document.getElementById('crop_y').value = (selection.y - img_bounds.top - (selection.width / 2)) * ratio; document.getElementById('crop_width').value = selection.width; closeModal(); diff --git a/test.csv b/test.csv deleted file mode 100644 index 36df611..0000000 --- a/test.csv +++ /dev/null @@ -1,2 +0,0 @@ -jashton,jashton@slcpl.org,changeme,2 -violet,violetash501@gmail.com,something,3 diff --git a/vintagecoding.net.md b/vintagecoding.net.md index 29cdf39..15b3ba2 100644 --- a/vintagecoding.net.md +++ b/vintagecoding.net.md @@ -8,7 +8,9 @@ - [x] Ensure a consistent design & UX aesthetic --- v0.1.0 - [ ] Sensible CSS class names for a modular styling approach --- v0.2.0 +#### Security - [x] Convert db_functions.php queries/statements into prepared SQL for protection against SQL injection --- v0.2.0 +- [ ] XSS prevention --- v0.2.0 - [ ] Email Handler: - [ ] Email users subscribed to author or tag whenever a new article is posted. --- v0.3.0 @@ -34,7 +36,7 @@ - [x] Get Users (requires auth) --- v0.2.0 - [x] Create Users (requires auth) --- v0.2.0 - [x] Delete Users --- v0.2.0 - - [ ] Get User (for public facing account page) --- v0.2.0 + - [x] Get User (for public facing account page) --- v0.2.0 #### Analytics on Accounts (requires auth) --- account_analytic_functions.php - [ ] Get Users by Creation --- v0.3.0 @@ -45,7 +47,7 @@ #### Account Systems Interfaces - [x] Sign Up & Login Form --- v0.1.0 - [x] Account Settings (requires login, self) --- v0.1.0 - - [ ] Account Page (of each user, hidden by default) --- v0.2.0 + - [x] Account Page (of each user, hidden by default) --- v0.2.0 - [ ] Allow for user customization of their account page (colors, layout, maybe even let them have their own CSS file to make changes) --- v0.2.0 - [ ] Articles: