Ver Fonte

Strong verification of the data obtained from the form back to output into the form

Visman há 2 anos atrás
pai
commit
1a1614c30d

+ 13 - 13
app/Models/Pages/Admin/Install.php

@@ -255,27 +255,27 @@ class Install extends Admin
                         'dbtype' => [
                             'type'     => 'select',
                             'options'  => $this->dbTypes,
-                            'value'    => $v ? $v->dbtype : 'mysql_innodb',
+                            'value'    => $v->dbtype ?? 'mysql_innodb',
                             'caption'  => 'Database type',
                             'help'     => 'Info 2',
                         ],
                         'dbhost' => [
                             'type'     => 'text',
-                            'value'    => $v ? $v->dbhost : 'localhost',
+                            'value'    => $v->dbhost ?? 'localhost',
                             'caption'  => 'Database server hostname',
                             'help'     => 'Info 3',
                             'required' => true,
                         ],
                         'dbname' => [
                             'type'     => 'text',
-                            'value'    => $v ? $v->dbname : '',
+                            'value'    => $v->dbname ?? '',
                             'caption'  => 'Database name',
                             'help'     => 'Info 4',
                             'required' => true,
                         ],
                         'dbuser' => [
                             'type'    => 'text',
-                            'value'   => $v ? $v->dbuser : '',
+                            'value'   => $v->dbuser ?? '',
                             'caption' => 'Database username',
                         ],
                         'dbpass' => [
@@ -287,7 +287,7 @@ class Install extends Admin
                         'dbprefix' => [
                             'type'      => 'text',
                             'maxlength' => '40',
-                            'value'     => $v ? $v->dbprefix : '',
+                            'value'     => $v->dbprefix ?? '',
                             'caption'   => 'Table prefix',
                             'help'      => 'Info 6',
                             'required' => true,
@@ -311,7 +311,7 @@ class Install extends Admin
                             'type'      => 'text',
                             'maxlength' => '25',
                             'pattern'   => '^.{2,25}$',
-                            'value'     => $v ? $v->username : '',
+                            'value'     => $v->username ?? '',
                             'caption'   => 'Administrator username',
                             'help'      => 'Info 8',
                             'required'  => true,
@@ -328,7 +328,7 @@ class Install extends Admin
                             'type'      => 'text',
                             'maxlength' => '80',
                             'pattern'   => '.+@.+',
-                            'value'     => $v ? $v->email : '',
+                            'value'     => $v->email ?? '',
                             'caption'   => 'Administrator email',
                             'help'      => 'Info 10',
                             'required'  => true,
@@ -352,33 +352,33 @@ class Install extends Admin
                         'title' => [
                             'type'      => 'text',
                             'maxlength' => '255',
-                            'value'     => $v ? $v->title : __('My ForkBB Forum'),
+                            'value'     => $v->title ?? __('My ForkBB Forum'),
                             'caption'   => 'Board title',
                             'required'  => true,
                         ],
                         'descr' => [
                             'type'      => 'text',
                             'maxlength' => '16000',
-                            'value'     => $v ? $v->descr : __('Description'),
+                            'value'     => $v->descr ?? __('Description'),
                             'caption'   => 'Board description',
                         ],
                         'baseurl' => [
                             'type'      => 'text',
                             'maxlength' => '128',
-                            'value'     => $v ? $v->baseurl : $this->c->BASE_URL,
+                            'value'     => $v->baseurl ?? $this->c->BASE_URL,
                             'caption'   => 'Base URL',
                             'required'  => true,
                         ],
                         'defaultlang' => [
                             'type'      => 'select',
                             'options'   => $langs,
-                            'value'     => $v ? $v->defaultlang : $this->user->language,
+                            'value'     => $v->defaultlang ?? $this->user->language,
                             'caption'   => 'Default language',
                         ],
                         'defaultstyle' => [
                             'type'      => 'select',
                             'options'   => $styles,
-                            'value'     => $v ? $v->defaultstyle : $this->user->style,
+                            'value'     => $v->defaultstyle ?? $this->user->style,
                             'caption'   => 'Default style',
                         ],
                     ],
@@ -399,7 +399,7 @@ class Install extends Admin
                         'cookie_domain' => [
                             'type'      => 'text',
                             'maxlength' => '128',
-                            'value'     => $v ? $v->cookie_domain : '',
+                            'value'     => $v->cookie_domain ?? '',
                             'caption'   => 'Cookie Domain',
                             'help'      => 'Cookie Domain info',
                         ],

+ 1 - 1
app/Models/Pages/Admin/Update.php

@@ -321,7 +321,7 @@ class Update extends Admin
                         ],
                         'o_maintenance_message' => [
                             'type'     => 'textarea',
-                            'value'    => $v ? $v->o_maintenance_message : $this->c->config->o_maintenance_message,
+                            'value'    => $v->o_maintenance_message ?? $this->c->config->o_maintenance_message,
                             'caption'  => 'Maintenance message',
                             'help'     => 'Maintenance message info',
                             'required' => true,

+ 4 - 4
app/Models/Pages/Auth.php

@@ -99,9 +99,9 @@ class Auth extends Page
         $this->titles       = 'Login';
         $this->regLink      = 1 === $this->c->config->b_regs_allow ? $this->c->Router->link('Register') : null;
 
-        $username           = $v ? $v->username : $username;
-        $save               = $v ? $v->save : 1;
-        $redirect           = $v ? $v->redirect : $this->c->Router->validate($ref, 'Index');
+        $username           = $v->username ?? $username;
+        $save               = $v->save ?? 1;
+        $redirect           = $v->redirect ?? $this->c->Router->validate($ref, 'Index');
         $this->form         = $this->formLogin($username, $save, $redirect);
 
         return $this;
@@ -317,7 +317,7 @@ class Auth extends Page
         $this->onlineDetail = null;
         $this->robots       = 'noindex';
         $this->titles       = 'Passphrase reset';
-        $this->form         = $this->formForget($v ? $v->email : $email);
+        $this->form         = $this->formForget($v->email ?? $email);
 
         return $this;
     }

+ 8 - 8
app/Models/Pages/Search.php

@@ -172,7 +172,7 @@ class Search extends Page
                             'type'      => 'text',
                             'maxlength' => '100',
                             'caption'   => 'Keyword search',
-                            'value'     => $v ? $v->keywords : '',
+                            'value'     => $v->keywords ?? '',
                             'required'  => true,
                             'autofocus' => true,
                         ],
@@ -211,7 +211,7 @@ class Search extends Page
                             'type'      => 'text',
                             'maxlength' => '100',
                             'caption'   => 'Keyword search',
-                            'value'     => $v ? $v->keywords : '',
+                            'value'     => $v->keywords ?? '',
                             'required'  => true,
                             'autofocus' => true,
                         ],
@@ -220,7 +220,7 @@ class Search extends Page
                             'type'      => 'text',
                             'maxlength' => '25',
                             'caption'   => 'Author search',
-                            'value'     => $v ? $v->author : '*',
+                            'value'     => $v->author ?? '*',
                             'required'  => true,
                         ],
                         [
@@ -236,7 +236,7 @@ class Search extends Page
                             'class'   => ['w3'],
                             'type'    => 'multiselect',
                             'options' => $this->listForOptions,
-                            'value'   => $v ? \explode('.', $v->forums) : null,
+                            'value'   => isset($v->forums) ? \explode('.', $v->forums) : null,
                             'caption' => 'Forum search',
                             'size'    => \min(\count($this->listForOptions), 10),
                         ],
@@ -248,7 +248,7 @@ class Search extends Page
                                 1 => __('Message only'),
                                 2 => __('Topic only'),
                             ],
-                            'value'   => $v ? $v->serch_in : 0,
+                            'value'   => $v->serch_in ?? 0,
                             'caption' => 'Search in',
                         ],
                         [
@@ -274,7 +274,7 @@ class Search extends Page
                                 2 => __('Sort by subject'),
                                 3 => __('Sort by forum'),
                             ],
-                            'value'   => $v ? $v->sort_by : 0,
+                            'value'   => $v->sort_by ?? 0,
                             'caption' => 'Sort by',
                         ],
                         'sort_dir' => [
@@ -284,7 +284,7 @@ class Search extends Page
                                 0 => __('Descending'),
                                 1 => __('Ascending'),
                             ],
-                            'value'   => $v ? $v->sort_dir : 0,
+                            'value'   => $v->sort_dir ?? 0,
                             'caption' => 'Sort order',
                         ],
                         'show_as' => [
@@ -294,7 +294,7 @@ class Search extends Page
                                 0 => __('Show as posts'),
                                 1 => __('Show as topics'),
                             ],
-                            'value'   => $v ? $v->show_as : 0,
+                            'value'   => $v->show_as ?? 0,
                             'caption' => 'Show as',
                         ],
                         [