HEX
Server: Apache
System: Linux server1.ariadata.co 4.18.0-553.120.1.el8_10.x86_64 #1 SMP Mon Apr 20 18:04:27 EDT 2026 x86_64
User: nepi (1051)
PHP: 7.4.33
Disabled: exec,passthru,shell_exec,system,show_source,popen,proc_open
Upload Files
File: /home/nepi/www/migrations/upgrades/20191216175050_remove_file_max_size.php
<?php


use Phinx\Migration\AbstractMigration;

class RemoveFileMaxSize extends AbstractMigration
{

    public function change()
    {
        // -------------------------------------------------------------------------
        // Remove file_max_size setting field
        // -------------------------------------------------------------------------
        if ($this->checkFieldExist('directus_settings', 'file_max_size')) {
            $this->removeField('directus_settings', 'file_max_size');
        }

        $this->removeSetting('file_max_size');

        // -------------------------------------------------------------------------
        // Update the sorting order
        // -------------------------------------------------------------------------
        if ($this->checkFieldExist('directus_settings', 'file_mimetype_whitelist')) {
            $this->execute(\Directus\phinx_update(
                $this->getAdapter(),
                'directus_fields',
                [
                    'sort' => 32,
                    'width' => 'half'
                ],
                ['collection' => 'directus_settings', 'field' => 'file_mimetype_whitelist']
            ));
        }

        if ($this->checkFieldExist('directus_settings', 'asset_whitelist')) {
            $this->execute(\Directus\phinx_update(
                $this->getAdapter(),
                'directus_fields',
                [
                    'sort' => 33
                ],
                ['collection' => 'directus_settings', 'field' => 'asset_whitelist']
            ));
        }

        if ($this->checkFieldExist('directus_settings', 'asset_whitelist_system')) {
            $this->execute(\Directus\phinx_update(
                $this->getAdapter(),
                'directus_fields',
                [
                    'sort' => 34
                ],
                ['collection' => 'directus_settings', 'field' => 'asset_whitelist_system']
            ));
        }

        if ($this->checkFieldExist('directus_settings', 'youtube_api_key')) {
            $this->execute(\Directus\phinx_update(
                $this->getAdapter(),
                'directus_fields',
                [
                    'sort' => 35
                ],
                ['collection' => 'directus_settings', 'field' => 'youtube_api_key']
            ));
        }
    }


    public function checkFieldExist($collection, $field)
    {
        $checkSql = sprintf('SELECT 1 FROM `directus_fields` WHERE `collection` = "%s" AND `field` = "%s";', $collection, $field);
        return $this->query($checkSql)->fetch();
    }

    public function removeField($collection, $field)
    {
        $this->execute('DELETE FROM `directus_fields` WHERE `collection` = "' . $collection . '" and `field` = "' . $field . '";');
    }

    public function hasSetting($field)
    {
        $checkSql = sprintf('SELECT 1 FROM `directus_settings` WHERE `key` = "%s"', $field);
        return $this->query($checkSql)->fetch();
    }

    public function removeSetting($field)
    {
        if ($this->hasSetting($field)) {
            $this->execute('DELETE FROM `directus_settings` where `key` = "' . $field . '";');
        }
    }
}