<commit_before><?php

namespace Ffcms\Apps\Api\Ckeditor;

use Extend\Core\Arch\ApiController;
use Ffcms\Core\App;
use Ffcms\Core\Exception\NativeException;
use Ffcms\Core\Helper\Arr;
use Ffcms\Core\Helper\Date;
use Ffcms\Core\Helper\File;
use Ffcms\Core\Helper\Normalize;
use Ffcms\Core\Helper\Object;
use Ffcms\Core\Helper\String;

class Editor extends ApiController
{
    /**
     * Allowed request type and extensions for it
     * @var array
     */
    public $allowedExt = [
        'images' => ['.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg'],
        'files' => ['.zip', '.rar', '.gz', '.tar', '.bz2', '.bz', '.doc', '.docx', '.xls', '.xlsx', '.txt', '.csv', '.odt', '.pdf', '.djvu'],
        'flash' => ['.swf', '.fla', '.flv']
    ];

    /**
     * Append translation file ;)
     */
    public function before()
    {
        parent::before();
        App::$Translate->append(__DIR__ . '/Translation/' . App::$Request->getLanguage() . '.php');
    }

    /**
     * Browse files from ckeditor<commit_msg>Check permissions for files<commit_after><?php

namespace Ffcms\Apps\Api\Ckeditor;

use Extend\Core\Arch\ApiController;
use Ffcms\Core\App;
use Ffcms\Core\Exception\NativeException;
use Ffcms\Core\Helper\Arr;
use Ffcms\Core\Helper\Date;
use Ffcms\Core\Helper\File;
use Ffcms\Core\Helper\Normalize;
use Ffcms\Core\Helper\Object;
use Ffcms\Core\Helper\String;

class Editor extends ApiController
{
    /**
     * Allowed request type and extensions for it
     * @var array
     */
    public $allowedExt = [
        'images' => ['.jpg', '.jpeg', '.gif', '.png', '.bmp', '.svg'],
        'files' => ['.zip', '.rar', '.gz', '.tar', '.bz2', '.bz', '.doc', '.docx', '.xls', '.xlsx', '.txt', '.csv', '.odt', '.pdf', '.djvu'],
        'flash' => ['.swf', '.fla', '.flv']
    ];

    /**
     * Append translation file ;)
     * @throws NativeException
     */
    public function before()
    {
        parent::before();
        // check if user have permission to access there
        if (!App::$User->isAuth() || !App::$User->identity()->getRole()->can('global/file')) {
            throw new NativeException('Permission denied');
        }
        App::$Translate->append(__DIR__ . '/Translation/' . App::$Request->getLanguage() . '.php');
    }

    /**
     * Browse files from ckeditor
{'fraction_non_alphanumeric': 0.20686657974793568, 'fraction_numerical': 0.000869187309865276, 'mean_word_length': 2.7249190938511325, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 17, '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': '7376607', 'n_tokens_mistral': 784, 'n_tokens_neox': 779, 'n_words': 175}