"Fossies" - the Fresh Open Source Software Archive

Member "phpMyAdmin-5.1.0-english/libraries/classes/Setup/FormProcessing.php" (24 Feb 2021, 2062 Bytes) of package /linux/www/phpMyAdmin-5.1.0-english.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) PHP source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file. For more information about "FormProcessing.php" see the Fossies "Dox" file reference documentation and the latest Fossies "Diffs" side-by-side code changes report: 5.0.4-english_vs_5.1.0-english.

    1 <?php
    2 /**
    3  * Formset processing library
    4  */
    5 
    6 declare(strict_types=1);
    7 
    8 namespace PhpMyAdmin\Setup;
    9 
   10 use PhpMyAdmin\Config\FormDisplay;
   11 use PhpMyAdmin\Core;
   12 use PhpMyAdmin\Response;
   13 use PhpMyAdmin\Template;
   14 use PhpMyAdmin\Url;
   15 
   16 /**
   17  * PhpMyAdmin\Setup\FormProcessing class
   18  */
   19 class FormProcessing
   20 {
   21     /**
   22      * Processes forms registered in $form_display, handles error correction
   23      *
   24      * @param FormDisplay $form_display Form to display
   25      *
   26      * @return void
   27      */
   28     public static function process(FormDisplay $form_display)
   29     {
   30         if (isset($_GET['mode']) && $_GET['mode'] === 'revert') {
   31             // revert erroneous fields to their default values
   32             $form_display->fixErrors();
   33             $response = Response::getInstance();
   34             $response->disable();
   35             $response->generateHeader303('index.php' . Url::getCommonRaw());
   36         }
   37 
   38         if (! $form_display->process(false)) {
   39             // handle form view and failed POST
   40             echo $form_display->getDisplay(true, true);
   41 
   42             return;
   43         }
   44 
   45         // check for form errors
   46         if (! $form_display->hasErrors()) {
   47             $response = Response::getInstance();
   48             $response->disable();
   49             $response->generateHeader303('index.php' . Url::getCommonRaw());
   50 
   51             return;
   52         }
   53 
   54         // form has errors, show warning
   55         $page = $_GET['page'] ?? '';
   56         $formset = $_GET['formset'] ?? '';
   57         $formId = Core::isValid($_GET['id'], 'numeric') ? $_GET['id'] : '';
   58         if ($formId === null && $page === 'servers') {
   59             // we've just added a new server, get its id
   60             $formId = $form_display->getConfigFile()->getServerCount();
   61         }
   62 
   63         $urlParams = [
   64             'page' => $page,
   65             'formset' => $formset,
   66             'id' => $formId,
   67         ];
   68 
   69         $template = new Template();
   70         echo $template->render('setup/error', [
   71             'url_params' => $urlParams,
   72             'errors' => $form_display->displayErrors(),
   73         ]);
   74     }
   75 }