diff --git a/.gitignore b/.gitignore index 1f20d36..2c74cbb 100644 --- a/.gitignore +++ b/.gitignore @@ -64,3 +64,4 @@ vendor/canary/logs/* .env components/* mailhog.log +uploads/* diff --git a/app/classes/forms.php b/app/classes/forms.php index 7fb11b2..d4402e7 100644 --- a/app/classes/forms.php +++ b/app/classes/forms.php @@ -214,6 +214,10 @@ class Forms extends Check { * @return {bool} */ public static function passwordResetCode() { + if ( !Input::exists( 'resetCode' ) ) { + self::addUserError( 'Invalid resetCode.' ); + return false; + } if ( !self::token() ) { return false; } diff --git a/app/classes/preferences.php b/app/classes/preferences.php index 4f86d0c..b059ffa 100644 --- a/app/classes/preferences.php +++ b/app/classes/preferences.php @@ -212,12 +212,13 @@ class Preferences { } if ( 'file' == $details['type'] ) { if ( Input::exists( $name ) ) { - $folder = IMAGE_UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR; - if ( !Upload::image( $name, $folder ) ) { - Issues::add( 'error', [ 'There was an error with your upload.' => Check::systemErrors() ] ); - } else { + $folder = UPLOAD_DIRECTORY . App::$activeUser->username . DIRECTORY_SEPARATOR . 'images' . DIRECTORY_SEPARATOR; + $upload = Upload::image( $name, $folder ); + if ( $upload ) { $route = str_replace( APP_ROOT_DIRECTORY, '', $folder ); $prefsArray[$name] = $route . Upload::last(); + } else { + Issues::add( 'error', [ 'There was an error with your upload.' => Check::userErrors() ] ); } } } diff --git a/app/controllers/register.php b/app/controllers/register.php index 9f5f41b..f07cb19 100644 --- a/app/controllers/register.php +++ b/app/controllers/register.php @@ -29,14 +29,14 @@ class Register extends Controller { public function confirm( $code = null ) { self::$title = 'Confirm Email'; if ( !isset( $code ) && !Input::exists( 'confirmationCode' ) ) { - return Views::view( 'email.confirmation' ); + return Views::view( 'confirmation' ); } if ( Forms::check( 'emailConfirmation' ) ) { $code = Input::post( 'confirmationCode' ); } if ( !self::$user->confirm( $code ) ) { Issues::add( 'error', 'There was an error confirming your account, please try again.' ); - return Views::view( 'email.confirmation' ); + return Views::view( 'confirmation' ); } Session::flash( 'success', 'You have successfully confirmed your email address.' ); Redirect::to( 'home/index' ); @@ -97,13 +97,13 @@ class Register extends Controller { if ( !App::$isLoggedIn ) { return Issues::add( 'notice', 'Please log in to resend your confirmation email.' ); } - if ( App::$activeUser->data()->confirmed == '1' ) { + if ( App::$activeUser->confirmed == '1' ) { return Issues::add( 'notice', 'Your account has already been confirmed.' ); } if ( !Forms::check( 'confirmationResend' ) ) { - return Views::view( 'email.confirmation_resend' ); + return Views::view( 'confirmation_resend' ); } - Email::send( App::$activeUser->data()->email, 'confirmation', App::$activeUser->data()->confirmationCode, [ 'template' => true ] ); + Email::send( App::$activeUser->email, 'confirmation', App::$activeUser->confirmationCode, [ 'template' => true ] ); Session::flash( 'success', 'Your confirmation email has been sent to the email for your account.' ); Redirect::to( 'home/index' ); } @@ -111,26 +111,26 @@ class Register extends Controller { public function reset( $code = null ) { self::$title = 'Password Reset'; if ( !isset( $code ) && !Input::exists( 'resetCode' ) ) { - Issues::add( 'error', 'No reset code provided.' ); + Issues::add( 'info', 'Please provide a reset code.' ); return Views::view( 'password_reset_code' ); } if ( Input::exists( 'resetCode' ) ) { - if ( Forms::check( 'password_reset_code' ) ) { + if ( Forms::check( 'passwordResetCode' ) ) { $code = Input::post( 'resetCode' ); } } - if ( !self::$user->checkCode( $code ) ) { + if ( ! self::$user->checkCode( $code ) ) { Issues::add( 'error', 'There was an error with your reset code. Please try again.' ); return Views::view( 'password_reset_code' ); } - if ( !Input::exists() ) { + Components::set( 'resetCode', $code ); + if ( ! Input::exists('password') ) { return Views::view( 'password_reset' ); } - if ( !Forms::check( 'passwordReset' ) ) { + if ( ! Forms::check( 'passwordReset' ) ) { Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); return Views::view( 'password_reset' ); } - Components::set( 'resetCode', $code ); self::$user->changePassword( $code, Input::post( 'password' ) ); Email::send( self::$user->data()->email, 'passwordChange', null, [ 'template' => true ] ); Session::flash( 'success', 'Your Password has been changed, please use your new password to log in.' ); diff --git a/app/controllers/usercp.php b/app/controllers/usercp.php index 3991aed..55f7c58 100644 --- a/app/controllers/usercp.php +++ b/app/controllers/usercp.php @@ -43,7 +43,7 @@ class Usercp extends Controller { public function email() { self::$title = 'Email Settings'; if ( App::$activeUser->confirmed != '1' ) { - return Issues::add( 'notice', 'You need to confirm your email address before you can make modifications. If you would like to resend that confirmation link, please click here', true ); + return Issues::add( 'notice', 'You need to confirm your email address before you can make modifications. If you would like to resend that confirmation link, please click here', true ); } if ( !Input::exists() ) { return Views::view( 'user_cp.email_change' ); @@ -98,6 +98,7 @@ class Usercp extends Controller { $fields = App::$activePrefs; if ( Input::exists( 'submit' ) ) { $fields = $prefs->convertFormToArray( true, false ); + // dv( $fields ); // @TODO now i may need to rework the form checker to work with this.... // if (!Forms::check('userPrefs')) { // Issues::add( 'error', [ 'There was an error with your request.' => Check::userErrors() ] ); diff --git a/app/functions/common.php b/app/functions/common.php index 28b2ff7..24e982d 100644 --- a/app/functions/common.php +++ b/app/functions/common.php @@ -102,4 +102,18 @@ function generateRandomString( $length = 10 ) { $randomString .= $characters[random_int(0, $charactersLength - 1)]; } return $randomString; +} + +function generateUuidV4(): string { + // Generate 16 random bytes + $data = random_bytes(16); + + // Set the version to 4 -> random (bits 12-15 of time_hi_and_version) + $data[6] = chr((ord($data[6]) & 0x0f) | 0x40); + + // Set the variant to RFC 4122 -> (bits 6-7 of clock_seq_hi_and_reserved) + $data[8] = chr((ord($data[8]) & 0x3f) | 0x80); + + // Convert to hexadecimal and format as a UUID + return vsprintf('%s%s-%s-%s-%s-%s%s%s', str_split(bin2hex($data), 4)); } \ No newline at end of file diff --git a/app/plugins/blog/views/admin/dashboard.html b/app/plugins/blog/views/admin/dashboard.html index e7984f2..3b442a3 100644 --- a/app/plugins/blog/views/admin/dashboard.html +++ b/app/plugins/blog/views/admin/dashboard.html @@ -1,5 +1,5 @@ New Posts - +
diff --git a/app/plugins/bugreport/plugin.php b/app/plugins/bugreport/plugin.php index 0ed29b0..c509440 100644 --- a/app/plugins/bugreport/plugin.php +++ b/app/plugins/bugreport/plugin.php @@ -53,6 +53,7 @@ class Bugreport extends Plugin { [ 'text' => 'Bug Report', 'url' => '{ROOT_URL}bugreport', + 'filter' => 'loggedin', ], ]; public $admin_links = [ diff --git a/app/plugins/comments/views/admin/dashboard.html b/app/plugins/comments/views/admin/dashboard.html index f0c27b1..5034c50 100644 --- a/app/plugins/comments/views/admin/dashboard.html +++ b/app/plugins/comments/views/admin/dashboard.html @@ -1,5 +1,5 @@ New Comments -
+
diff --git a/app/plugins/comments/views/create.html b/app/plugins/comments/views/create.html index 0cc13a5..af241f5 100644 --- a/app/plugins/comments/views/create.html +++ b/app/plugins/comments/views/create.html @@ -8,7 +8,7 @@ id="comment" placeholder="Write your comment here..."> - + diff --git a/app/plugins/contact/plugin.php b/app/plugins/contact/plugin.php index 21883a0..98cf81b 100644 --- a/app/plugins/contact/plugin.php +++ b/app/plugins/contact/plugin.php @@ -53,7 +53,7 @@ class Contact extends Plugin { ]; public $admin_links = [ [ - 'text' => ' Contact', + 'text' => ' Contact', 'url' => '{ROOT_URL}admin/contact', ], ]; diff --git a/app/templates/admin/admin.tpl b/app/templates/admin/admin.tpl index a05d18d..862e51d 100644 --- a/app/templates/admin/admin.tpl +++ b/app/templates/admin/admin.tpl @@ -67,9 +67,9 @@ -
+
diff --git a/app/views/confirmation.html b/app/views/confirmation.html new file mode 100644 index 0000000..e1426c8 --- /dev/null +++ b/app/views/confirmation.html @@ -0,0 +1,15 @@ + +
+

Email Confirmation

+
+

Please enter the confirmation code you received in your email.

+
+
+
+ +
+
+ +
+ +
\ No newline at end of file diff --git a/app/views/confirmation_resend.html b/app/views/confirmation_resend.html new file mode 100644 index 0000000..d5e3d5f --- /dev/null +++ b/app/views/confirmation_resend.html @@ -0,0 +1,10 @@ +
+

Re-Send Confirmation

+
+

Please click the resend button to resend your email confirmation. Don't forget to check the spam folder!

+
+ + +
+ +
\ No newline at end of file diff --git a/app/views/faq.html b/app/views/faq.html index 42c18f0..72063a5 100644 --- a/app/views/faq.html +++ b/app/views/faq.html @@ -1,4 +1,3 @@ -

Frequently Asked Questions


diff --git a/app/views/footer/copy.html b/app/views/footer/copy.html index 77642e3..750c8a2 100644 --- a/app/views/footer/copy.html +++ b/app/views/footer/copy.html @@ -1 +1 @@ -

© 2024 AllTheBookmarks, Powered by The Tempus Project.

\ No newline at end of file +© 2024 AllTheBookmarks, Powered by The Tempus Project. \ No newline at end of file diff --git a/app/views/footer/social.html b/app/views/footer/social.html index 7a13992..a833fde 100644 --- a/app/views/footer/social.html +++ b/app/views/footer/social.html @@ -1,4 +1,4 @@ -
\ No newline at end of file diff --git a/app/views/login.html b/app/views/login.html index ea01670..a715db2 100644 --- a/app/views/login.html +++ b/app/views/login.html @@ -1,56 +1,48 @@ -
-
-
\ No newline at end of file + \ No newline at end of file diff --git a/app/views/nav/statusLoggedIn.html b/app/views/nav/statusLoggedIn.html index f70ed40..a1b30e8 100644 --- a/app/views/nav/statusLoggedIn.html +++ b/app/views/nav/statusLoggedIn.html @@ -9,7 +9,7 @@ aria-expanded="false"> {USERNAME} -