X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=actions%2Favatar.php;h=9f397e93c3e0148248955ae8746308a489631f02;hb=661202be3e28eeffeacb8cbfbec88a7352bcce55;hp=b1697f97bbb734a3e09d1f5d1bd6bc91de95cfd9;hpb=038f762bce95323ac929b0635cceb7f9425527ec;p=quix0rs-gnu-social.git diff --git a/actions/avatar.php b/actions/avatar.php index b1697f97bb..9f397e93c3 100644 --- a/actions/avatar.php +++ b/actions/avatar.php @@ -23,10 +23,6 @@ require_once(INSTALLDIR.'/lib/settingsaction.php'); class AvatarAction extends SettingsAction { - function is_readonly() { - return false; - } - function get_instructions() { return _('Upload a new "avatar" (user image) here. You can\'t edit the picture after you upload it, so make sure it\'s more or less square. It must be under the site license, also. Use a picture that belongs to you and that you want to share.'); } @@ -62,6 +58,7 @@ class AvatarAction extends SettingsAction { 'id' => 'avatar', 'action' => common_local_url('avatar'))); + common_hidden('token', common_session_token()); common_element('input', array('name' => 'MAX_FILE_SIZE', 'type' => 'hidden', 'id' => 'MAX_FILE_SIZE', @@ -76,6 +73,14 @@ class AvatarAction extends SettingsAction { function handle_post() { + # CSRF protection + + $token = $this->trimmed('token'); + if (!$token || $token != common_session_token()) { + $this->show_form(_('There was a problem with your session token. Try again, please.')); + return; + } + switch ($_FILES['avatarfile']['error']) { case UPLOAD_ERR_OK: # success, jump out break;