<commit_before><?php

namespace Kanboard\Controller;

use Kanboard\Core\ObjectStorage\ObjectStorageException;
use Kanboard\Core\Thumbnail;

/**
 * Avatar File Controller
 *
 * @package  Kanboard\Controller
 * @author   <NAME>
 */
class AvatarFileController extends BaseController
{
    /**
     * Display avatar page
     */
    public function show()
    {
        $user = $this->getUser();

        $this->response->html($this->helper->layout->user('avatar_file/show', array(
            'user' => $user,
        )));
    }

    /**
     * Upload Avatar
     */
    public function upload()
    {
        $this->checkCSRFParam();
        $user = $this->getUser();

        if (! $this->avatarFileModel->uploadImageFile($user['id'], $this->request->getFileInfo('avatar'))) {
            $this->flash->failure(t('Unable to upload files, check the permissions of your data folder.'));
        }

        $this->renderResponse($user['id']);
    }

    /**
     * Remove Avatar image
     */
    public function remove()
    {
        $this->checkCSRFParam();
        $user = $this->getUser();
        $this->avatarFileModel->remove($user['id']);
        $this->userSession->refresh($user['id']);
        $this->renderResponse($user['id']);
    }

    /**
     * Show Avatar image (public)
     */
    public function image()
    {
        $user_id = $this->request->getIntegerParam('user_id');
        $size = $this->request->getStringParam('size', 48);
        $filename = $this->avatarFileModel->getFilename($user_id);
        $etag = md5($filename.$size);

        $this->response->withCache(365 * 86400, $etag);<commit_msg>Limit avatar image size<commit_after><?php

namespace Kanboard\Controller;

use Kanboard\Core\ObjectStorage\ObjectStorageException;
use Kanboard\Core\Thumbnail;

/**
 * Avatar File Controller
 *
 * @package  Kanboard\Controller
 * @author   <NAME>
 */
class AvatarFileController extends BaseController
{
    /**
     * Display avatar page
     */
    public function show()
    {
        $user = $this->getUser();

        $this->response->html($this->helper->layout->user('avatar_file/show', array(
            'user' => $user,
        )));
    }

    /**
     * Upload Avatar
     */
    public function upload()
    {
        $this->checkCSRFParam();
        $user = $this->getUser();

        if (! $this->avatarFileModel->uploadImageFile($user['id'], $this->request->getFileInfo('avatar'))) {
            $this->flash->failure(t('Unable to upload files, check the permissions of your data folder.'));
        }

        $this->renderResponse($user['id']);
    }

    /**
     * Remove Avatar image
     */
    public function remove()
    {
        $this->checkCSRFParam();
        $user = $this->getUser();
        $this->avatarFileModel->remove($user['id']);
        $this->userSession->refresh($user['id']);
        $this->renderResponse($user['id']);
    }

    /**
     * Show Avatar image (public)
     */
    public function image()
    {
        $user_id = $this->request->getIntegerParam('user_id');
        $size = $this->request->getStringParam('size', 48);

        if ($size > 100) {
            $this->response->status(400);
            return;
        }

        $filename = $this->avatarFileModel->getFilename($user_id);
        $etag = md5($filename.$size);

        $this->response->withCache(365 * 86400, $etag);
{'fraction_non_alphanumeric': 0.17048497470990776, 'fraction_numerical': 0.008330853912526033, 'mean_word_length': 2.4588477366255144, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 70, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5649145', 'n_tokens_mistral': 1029, 'n_tokens_neox': 992, 'n_words': 175}