diff options
Diffstat (limited to 'srcs/phpmyadmin/libraries/classes/Config/Forms')
27 files changed, 1432 insertions, 0 deletions
diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/BaseForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/BaseForm.php new file mode 100644 index 0000000..2049070 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/BaseForm.php @@ -0,0 +1,89 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Base class for preferences. + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms; + +use PhpMyAdmin\Config\ConfigFile; +use PhpMyAdmin\Config\FormDisplay; + +/** + * Base form for user preferences + * + * @package PhpMyAdmin + */ +abstract class BaseForm extends FormDisplay +{ + /** + * Constructor + * + * @param ConfigFile $cf Config file instance + * @param int|null $serverId 0 if new server, validation; >= 1 if editing a server + */ + public function __construct(ConfigFile $cf, $serverId = null) + { + parent::__construct($cf); + foreach (static::getForms() as $formName => $form) { + $this->registerForm($formName, $form, $serverId); + } + } + + /** + * List of available forms, each form is described as an array of fields to display. + * Fields MUST have their counterparts in the $cfg array. + * + * To define form field, use the notation below: + * $forms['Form group']['Form name'] = array('Option/path'); + * + * You can assign default values set by special button ("set value: ..."), eg.: + * 'Servers/1/pmadb' => 'phpmyadmin' + * + * To group options, use: + * ':group:' . __('group name') // just define a group + * or + * 'option' => ':group' // group starting from this option + * End group blocks with: + * ':group:end' + * + * @todo This should be abstract, but that does not work in PHP 5 + * + * @return array + */ + public static function getForms() + { + return []; + } + + /** + * Returns list of fields used in the form. + * + * @return string[] + */ + public static function getFields() + { + $names = []; + foreach (static::getForms() as $form) { + foreach ($form as $k => $v) { + $names[] = is_int($k) ? $v : $k; + } + } + return $names; + } + + /** + * Returns name of the form + * + * @todo This should be abstract, but that does not work in PHP 5 + * + * @return string + */ + public static function getName() + { + return ''; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/BaseFormList.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/BaseFormList.php new file mode 100644 index 0000000..f4a5d32 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/BaseFormList.php @@ -0,0 +1,150 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms; + +use PhpMyAdmin\Config\ConfigFile; + +/** + * Class BaseFormList + * @package PhpMyAdmin\Config\Forms + */ +class BaseFormList +{ + /** + * List of all forms + */ + protected static $all = []; + + /** + * @var string + */ + protected static $ns = 'PhpMyAdmin\\Config\\Forms\\'; + + /** + * @var array + */ + private $_forms; + + /** + * @return array + */ + public static function getAll() + { + return static::$all; + } + + /** + * @param string $name Name + * @return bool + */ + public static function isValid($name) + { + return in_array($name, static::$all); + } + + /** + * @param string $name Name + * @return null|string + */ + public static function get($name) + { + if (static::isValid($name)) { + return static::$ns . $name . 'Form'; + } + return null; + } + + /** + * Constructor + * + * @param ConfigFile $cf Config file instance + */ + public function __construct(ConfigFile $cf) + { + $this->_forms = []; + foreach (static::$all as $form) { + $class = static::get($form); + $this->_forms[] = new $class($cf); + } + } + + /** + * Processes forms, returns true on successful save + * + * @param bool $allowPartialSave allows for partial form saving + * on failed validation + * @param bool $checkFormSubmit whether check for $_POST['submit_save'] + * + * @return boolean whether processing was successful + */ + public function process($allowPartialSave = true, $checkFormSubmit = true) + { + $ret = true; + foreach ($this->_forms as $form) { + $ret = $ret && $form->process($allowPartialSave, $checkFormSubmit); + } + return $ret; + } + + /** + * Displays errors + * + * @return string HTML for errors + */ + public function displayErrors() + { + $ret = ''; + foreach ($this->_forms as $form) { + $ret .= $form->displayErrors(); + } + return $ret; + } + + /** + * Reverts erroneous fields to their default values + * + * @return void + */ + public function fixErrors() + { + foreach ($this->_forms as $form) { + $form->fixErrors(); + } + } + + /** + * Tells whether form validation failed + * + * @return boolean + */ + public function hasErrors() + { + $ret = false; + foreach ($this->_forms as $form) { + $ret = $ret || $form->hasErrors(); + } + return $ret; + } + + /** + * Returns list of fields used in the form. + * + * @return string[] + */ + public static function getFields() + { + $names = []; + foreach (static::$all as $form) { + $class = static::get($form); + $names = array_merge($names, $class::getFields()); + } + return $names; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/BrowseForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/BrowseForm.php new file mode 100644 index 0000000..eee578a --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/BrowseForm.php @@ -0,0 +1,30 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\MainForm; + +/** + * Class BrowseForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class BrowseForm extends BaseForm +{ + /** + * @return array + */ + public static function getForms() + { + return [ + 'Browse' => MainForm::getForms()['Browse'], + ]; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/DbStructureForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/DbStructureForm.php new file mode 100644 index 0000000..4f9a8e4 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/DbStructureForm.php @@ -0,0 +1,30 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\MainForm; + +/** + * Class DbStructureForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class DbStructureForm extends BaseForm +{ + /** + * @return array + */ + public static function getForms() + { + return [ + 'DbStructure' => MainForm::getForms()['DbStructure'], + ]; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/EditForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/EditForm.php new file mode 100644 index 0000000..ad2fd46 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/EditForm.php @@ -0,0 +1,32 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\FeaturesForm; +use PhpMyAdmin\Config\Forms\User\MainForm; + +/** + * Class EditForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class EditForm extends BaseForm +{ + /** + * @return array + */ + public static function getForms() + { + return [ + 'Edit' => MainForm::getForms()['Edit'], + 'Text_fields' => FeaturesForm::getForms()['Text_fields'], + ]; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/ExportForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/ExportForm.php new file mode 100644 index 0000000..584b2fd --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/ExportForm.php @@ -0,0 +1,18 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +/** + * Class ExportForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class ExportForm extends \PhpMyAdmin\Config\Forms\User\ExportForm +{ +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/ImportForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/ImportForm.php new file mode 100644 index 0000000..78e429a --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/ImportForm.php @@ -0,0 +1,18 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +/** + * Class ImportForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class ImportForm extends \PhpMyAdmin\Config\Forms\User\ImportForm +{ +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/NaviForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/NaviForm.php new file mode 100644 index 0000000..02350eb --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/NaviForm.php @@ -0,0 +1,18 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +/** + * Class NaviForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class NaviForm extends \PhpMyAdmin\Config\Forms\User\NaviForm +{ +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/PageFormList.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/PageFormList.php new file mode 100644 index 0000000..f4cae3d --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/PageFormList.php @@ -0,0 +1,37 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * Page preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseFormList; + +/** + * Class PageFormList + * @package PhpMyAdmin\Config\Forms\Page + */ +class PageFormList extends BaseFormList +{ + /** + * @var array + */ + protected static $all = [ + 'Browse', + 'DbStructure', + 'Edit', + 'Export', + 'Import', + 'Navi', + 'Sql', + 'TableStructure', + ]; + /** + * @var string + */ + protected static $ns = '\\PhpMyAdmin\\Config\\Forms\\Page\\'; +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/SqlForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/SqlForm.php new file mode 100644 index 0000000..4ed85ff --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/SqlForm.php @@ -0,0 +1,18 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +/** + * Class SqlForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class SqlForm extends \PhpMyAdmin\Config\Forms\User\SqlForm +{ +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/TableStructureForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/TableStructureForm.php new file mode 100644 index 0000000..05af064 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Page/TableStructureForm.php @@ -0,0 +1,30 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Page; + +use PhpMyAdmin\Config\Forms\BaseForm; +use PhpMyAdmin\Config\Forms\User\MainForm; + +/** + * Class TableStructureForm + * @package PhpMyAdmin\Config\Forms\Page + */ +class TableStructureForm extends BaseForm +{ + /** + * @return array + */ + public static function getForms() + { + return [ + 'TableStructure' => MainForm::getForms()['TableStructure'], + ]; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ConfigForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ConfigForm.php new file mode 100644 index 0000000..6fd4515 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ConfigForm.php @@ -0,0 +1,32 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Setup; + +use PhpMyAdmin\Config\Forms\BaseForm; + +/** + * Class ConfigForm + * @package PhpMyAdmin\Config\Forms\Setup + */ +class ConfigForm extends BaseForm +{ + /** + * @return array + */ + public static function getForms() + { + return [ + 'Config' => [ + 'DefaultLang', + 'ServerDefault', + ], + ]; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ExportForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ExportForm.php new file mode 100644 index 0000000..adf7ce4 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ExportForm.php @@ -0,0 +1,18 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Setup; + +/** + * Class ExportForm + * @package PhpMyAdmin\Config\Forms\Setup + */ +class ExportForm extends \PhpMyAdmin\Config\Forms\User\ExportForm +{ +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/FeaturesForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/FeaturesForm.php new file mode 100644 index 0000000..54f6cf2 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/FeaturesForm.php @@ -0,0 +1,77 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Setup; + +/** + * Class FeaturesForm + * @package PhpMyAdmin\Config\Forms\Setup + */ +class FeaturesForm extends \PhpMyAdmin\Config\Forms\User\FeaturesForm +{ + /** + * @return array + */ + public static function getForms() + { + // phpcs:disable Squiz.Arrays.ArrayDeclaration.KeySpecified,Squiz.Arrays.ArrayDeclaration.NoKeySpecified + $result = parent::getForms(); + /* Remove only_db/hide_db, we have proper Server form in setup */ + $result['Databases'] = array_diff( + $result['Databases'], + [ + 'Servers/1/only_db', + 'Servers/1/hide_db', + ] + ); + /* Following are not available to user */ + $result['Import_export'] = [ + 'UploadDir', + 'SaveDir', + 'RecodingEngine' => ':group', + 'IconvExtraParams', + ':group:end', + 'ZipDump', + 'GZipDump', + 'BZipDump', + 'CompressOnFly', + ]; + $result['Security'] = [ + 'blowfish_secret', + 'CheckConfigurationPermissions', + 'TrustedProxies', + 'AllowUserDropDatabase', + 'AllowArbitraryServer', + 'ArbitraryServerRegexp', + 'LoginCookieRecall', + 'LoginCookieStore', + 'LoginCookieDeleteAll', + 'CaptchaLoginPublicKey', + 'CaptchaLoginPrivateKey', + ]; + $result['Developer'] = [ + 'UserprefsDeveloperTab', + 'DBG/sql', + ]; + $result['Other_core_settings'] = [ + 'OBGzip', + 'PersistentConnections', + 'ExecTimeLimit', + 'MemoryLimit', + 'UseDbSearch', + 'ProxyUrl', + 'ProxyUser', + 'ProxyPass', + 'AllowThirdPartyFraming', + 'ZeroConf', + ]; + return $result; + // phpcs:enable + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ImportForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ImportForm.php new file mode 100644 index 0000000..06adf35 --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ImportForm.php @@ -0,0 +1,18 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Setup; + +/** + * Class ImportForm + * @package PhpMyAdmin\Config\Forms\Setup + */ +class ImportForm extends \PhpMyAdmin\Config\Forms\User\ImportForm +{ +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/MainForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/MainForm.php new file mode 100644 index 0000000..ebdc1cd --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/MainForm.php @@ -0,0 +1,29 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Setup; + +/** + * Class MainForm + * @package PhpMyAdmin\Config\Forms\Setup + */ +class MainForm extends \PhpMyAdmin\Config\Forms\User\MainForm +{ + /** + * @return array + */ + public static function getForms() + { + $result = parent::getForms(); + /* Following are not available to user */ + $result['Startup'][] = 'ShowPhpInfo'; + $result['Startup'][] = 'ShowChgPassword'; + return $result; + } +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/NaviForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/NaviForm.php new file mode 100644 index 0000000..da1e9ed --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/NaviForm.php @@ -0,0 +1,18 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Setup; + +/** + * Class NaviForm + * @package PhpMyAdmin\Config\Forms\Setup + */ +class NaviForm extends \PhpMyAdmin\Config\Forms\User\NaviForm +{ +} diff --git a/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ServersForm.php b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ServersForm.php new file mode 100644 index 0000000..553447f --- /dev/null +++ b/srcs/phpmyadmin/libraries/classes/Config/Forms/Setup/ServersForm.php @@ -0,0 +1,116 @@ +<?php +/* vim: set expandtab sw=4 ts=4 sts=4: */ +/** + * User preferences form + * + * @package PhpMyAdmin + */ +declare(strict_types=1); + +namespace PhpMyAdmin\Config\Forms\Setup; + +use PhpMyAdmin\Config\Forms\BaseForm; + +/** + * Class ServersForm + * @package PhpMyAdmin\Config\Forms\Setup + */ +class ServersForm extends BaseForm +{ + /** + * @return array + */ + public static function getForms() + { + // phpcs:disable Squiz.Arrays.ArrayDeclaration.KeySpecified,Squiz.Arrays.ArrayDeclaration.NoKeySpecified + return [ + 'Server' => [ + 'Servers' => [ + 1 => [ + 'verbose', + 'host', + 'port', + 'socket', + 'ssl', + 'compress', + ], + ], + ], + 'Server_auth' => [ + 'Servers' => [ + 1 => [ + 'auth_type', + ':group:' . __('Config authentication'), + 'user', + 'password', + ':group:end', + ':group:' . __('HTTP authentication'), + 'auth_http_realm', + ':group:end', + ':group:' . __('Signon authentication'), + 'SignonSession', + 'SignonURL', + 'LogoutURL', + ], + ], + ], + 'Server_config' => [ + 'Servers' => [ + 1 => [ + 'only_db', + 'hide_db', + 'AllowRoot', + 'AllowNoPassword', + 'DisableIS', + 'AllowDeny/order', + 'AllowDeny/rules', + 'SessionTimeZone', + ], + ], + ], + 'Server_pmadb' => [ + 'Servers' => [ + 1 => [ + 'pmadb' => 'phpmyadmin', + 'controlhost', + 'controlport', + 'controluser', + 'controlpass', + 'bookmarktable' => 'pma__bookmark', + 'relation' => 'pma__relation', + 'userconfig' => 'pma__userconfig', + 'users' => 'pma__users', + 'usergroups' => 'pma__usergroups', + 'navigationhiding' => 'pma__navigationhiding', + 'table_info' => 'pma__table_info', + 'column_info' => 'pma__column_info', + 'history' => 'pma__history', + 'recent' => 'pma__recent', + 'favorite' => 'pma__favorite', + 'table_uiprefs' => 'pma__table_uiprefs', + 'tracking' => 'pma__tracking', + 'table_coords' => 'pma__table_coords', + 'pdf_pages' => 'pma__pdf_pages', + 'savedsearches' => 'pma__savedsearches', + 'central_columns' => 'pma__central_columns', + 'designer_settings' => 'pma__designer_settings', + 'export_templates' => 'pma__export_templates', + 'MaxTableUiprefs' => 100, + ], + ], + ], + 'Server_tracking' => [ + 'Servers' => [ + 1 => [ + 'tracking_version_auto_create', + 'tracking_default_statements', + 'tracking_add_drop_view', + 'tracking_add_drop_table', + 'tracking_add_drop_database', + ], + ], + ], |
