From 8fbb9f08cadd108a58156ad193eff8347cd76d6d Mon Sep 17 00:00:00 2001
From: ffflabs ' . \PHP_EOL;
- echo $this->misc->form;
+ echo $this->view->form;
echo "lang['strcreate']}\" />" . \PHP_EOL;
echo "lang['strcancel']}\" /> ' . \PHP_EOL;
- echo $this->misc->form;
+ echo $this->view->form;
echo '' . \PHP_EOL;
echo '' . \PHP_EOL;
echo '' . \PHP_EOL;
@@ -413,7 +413,7 @@ class AggregatesController extends BaseController
echo ' ' . \PHP_EOL;
echo '' . \PHP_EOL;
echo '' . \PHP_EOL;
- echo $this->misc->form;
+ echo $this->view->form;
echo "lang['strdrop']}\" />" . \PHP_EOL;
echo "lang['strcancel']}\" /> ' . \PHP_EOL;
- echo $this->misc->form;
+ echo $this->view->form;
echo "lang['strcreate']}\" />" . \PHP_EOL;
echo "lang['strcancel']}\" /> ' . \PHP_EOL;
echo '' . \PHP_EOL;
- echo $this->misc->form;
+ echo $this->view->form;
echo '' . \PHP_EOL;
echo '' . \PHP_EOL;
echo '' . \PHP_EOL;
diff --git a/src/controllers/DatabaseController.php b/src/controllers/DatabaseController.php
index 0f61acf9..02a30949 100644
--- a/src/controllers/DatabaseController.php
+++ b/src/controllers/DatabaseController.php
@@ -214,7 +214,7 @@ class DatabaseController extends BaseController
echo '' . \PHP_EOL;
echo "lang['strfind']}\" />" . \PHP_EOL;
- echo $this->misc->form;
+ echo $this->view->form;
echo '
lang['strexecute']}\" />" . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strreset']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/DataexportController.php b/src/controllers/DataexportController.php index 93f40eaf..ff314475 100644 --- a/src/controllers/DataexportController.php +++ b/src/controllers/DataexportController.php @@ -144,7 +144,7 @@ class DataexportController extends BaseController if (isset($_REQUEST['search_path'])) { echo '' . \PHP_EOL; } - echo $this->misc->form; + echo $this->view->form; echo "lang['strexport']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/DisplayController.php b/src/controllers/DisplayController.php index d8b6ec6f..19a7dc1b 100644 --- a/src/controllers/DisplayController.php +++ b/src/controllers/DisplayController.php @@ -240,7 +240,7 @@ class DisplayController extends BaseController //die(htmlspecialchars($query)); echo '' . \PHP_EOL; @@ -350,7 +350,7 @@ class DomainsController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stradd']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -397,7 +397,7 @@ class DomainsController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "" . \PHP_EOL; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; @@ -564,7 +564,7 @@ class DomainsController extends BaseController echo "" . \PHP_EOL; echo '
' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -647,7 +647,7 @@ class DomainsController extends BaseController } echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/FulltextController.php b/src/controllers/FulltextController.php index 157f98bb..3399d97b 100644 --- a/src/controllers/FulltextController.php +++ b/src/controllers/FulltextController.php @@ -313,7 +313,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -346,7 +346,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; //echo "".PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; @@ -454,7 +454,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '
' . \PHP_EOL; @@ -550,7 +550,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -880,7 +880,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '
' . \PHP_EOL; @@ -986,7 +986,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '
' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; @@ -1053,7 +1053,7 @@ class FulltextController extends BaseController echo "" . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; @@ -1149,7 +1149,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; @@ -1236,7 +1236,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '
' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stradd']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/FunctionsController.php b/src/controllers/FunctionsController.php index 891ad444..9be53647 100644 --- a/src/controllers/FunctionsController.php +++ b/src/controllers/FunctionsController.php @@ -467,7 +467,7 @@ class FunctionsController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -661,7 +661,7 @@ class FunctionsController extends BaseController echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "" . \PHP_EOL; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; @@ -964,7 +964,7 @@ class FunctionsController extends BaseController echo '' . \PHP_EOL; echo $szJSTRArg; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/GroupsController.php b/src/controllers/GroupsController.php index b389aece..dbfe116e 100644 --- a/src/controllers/GroupsController.php +++ b/src/controllers/GroupsController.php @@ -181,7 +181,7 @@ class GroupsController extends BaseController echo '', \sprintf($this->lang['strconfdropmember'], $this->misc->printVal($_REQUEST['user']), $this->misc->printVal($_REQUEST['group'])), '
' . \PHP_EOL; echo '' . \PHP_EOL; @@ -293,7 +293,7 @@ class GroupsController extends BaseController echo '', \sprintf($this->lang['strconfdropgroup'], $this->misc->printVal($_REQUEST['group'])), '
' . \PHP_EOL; echo '' . \PHP_EOL; @@ -214,7 +214,7 @@ class MaterializedviewpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; @@ -329,7 +329,7 @@ class MaterializedviewpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "
lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/MaterializedviewsController.php b/src/controllers/MaterializedviewsController.php index f63c231f..3cbb7ffd 100644 --- a/src/controllers/MaterializedviewsController.php +++ b/src/controllers/MaterializedviewsController.php @@ -297,7 +297,7 @@ class MaterializedviewsController extends BaseController echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "" . \PHP_EOL; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; @@ -416,7 +416,7 @@ class MaterializedviewsController extends BaseController \htmlspecialchars($_REQUEST['formComment']), "\n\t" . \PHP_EOL; echo '' . \PHP_EOL; echo '
' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/OperatorsController.php b/src/controllers/OperatorsController.php index ab5a546f..0ce1a773 100644 --- a/src/controllers/OperatorsController.php +++ b/src/controllers/OperatorsController.php @@ -261,7 +261,7 @@ class OperatorsController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/PrivilegesController.php b/src/controllers/PrivilegesController.php index 8ae7814d..b2831d33 100644 --- a/src/controllers/PrivilegesController.php +++ b/src/controllers/PrivilegesController.php @@ -388,7 +388,7 @@ class PrivilegesController extends BaseController \htmlspecialchars($_REQUEST['table']), '" />' . \PHP_EOL; } - echo $this->misc->form; + echo $this->view->form; echo \sprintf('%s', $mode, $this->lang['str' . $mode], \PHP_EOL); echo "lang['strcancel']}\" />"; diff --git a/src/controllers/RolesController.php b/src/controllers/RolesController.php index 583a2e91..64ce51ab 100644 --- a/src/controllers/RolesController.php +++ b/src/controllers/RolesController.php @@ -315,7 +315,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -481,7 +481,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; @@ -538,7 +538,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strok']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '
' . \PHP_EOL; diff --git a/src/controllers/RulesController.php b/src/controllers/RulesController.php index c1f21758..c43abd83 100644 --- a/src/controllers/RulesController.php +++ b/src/controllers/RulesController.php @@ -202,7 +202,7 @@ class RulesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -254,7 +254,7 @@ class RulesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "" . \PHP_EOL; echo "lang['stryes']}\" />" . \PHP_EOL; echo "lang['strno']}\" />" . \PHP_EOL; diff --git a/src/controllers/SchemasController.php b/src/controllers/SchemasController.php index dd3a45a6..4268f088 100644 --- a/src/controllers/SchemasController.php +++ b/src/controllers/SchemasController.php @@ -304,7 +304,7 @@ class SchemasController extends BaseController echo '
' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '
' . \PHP_EOL; @@ -392,7 +392,7 @@ class SchemasController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -453,7 +453,7 @@ class SchemasController extends BaseController echo "" . \PHP_EOL; echo '
' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/SequencesController.php b/src/controllers/SequencesController.php index e6b48773..ce59c87c 100644 --- a/src/controllers/SequencesController.php +++ b/src/controllers/SequencesController.php @@ -125,17 +125,17 @@ class SequencesController extends BaseController 'sequence' => [ 'title' => $this->lang['strsequence'], 'field' => Decorator::field('seqname'), - 'url' => "sequences?action=properties&{$this->misc->href}&", - 'vars' => ['sequence' => 'seqname'], + 'url' => "sequences?action=properties&{$this->misc->href}&", + 'vars' => ['sequence' => 'seqname'], ], - 'owner' => [ + 'owner' => [ 'title' => $this->lang['strowner'], 'field' => Decorator::field('seqowner'), ], - 'actions' => [ + 'actions' => [ 'title' => $this->lang['stractions'], ], - 'comment' => [ + 'comment' => [ 'title' => $this->lang['strcomment'], 'field' => Decorator::field('seqcomment'), ], @@ -144,41 +144,41 @@ class SequencesController extends BaseController $actions = [ 'multiactions' => [ 'keycols' => ['sequence' => 'seqname'], - 'url' => 'sequences', + 'url' => 'sequences', ], - 'alter' => [ + 'alter' => [ 'content' => $this->lang['stralter'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'confirm_alter', - 'subject' => 'sequence', + 'action' => 'confirm_alter', + 'subject' => 'sequence', 'sequence' => Decorator::field('seqname'), ], ], ], ], - 'drop' => [ - 'content' => $this->lang['strdrop'], - 'attr' => [ + 'drop' => [ + 'content' => $this->lang['strdrop'], + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'confirm_drop', + 'action' => 'confirm_drop', 'sequence' => Decorator::field('seqname'), ], ], ], 'multiaction' => 'confirm_drop', ], - 'privileges' => [ + 'privileges' => [ 'content' => $this->lang['strprivileges'], - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'privileges', + 'url' => 'privileges', 'urlvars' => [ - 'subject' => 'sequence', + 'subject' => 'sequence', 'sequence' => Decorator::field('seqname'), ], ], @@ -189,14 +189,14 @@ class SequencesController extends BaseController echo $this->printTable($sequences, $columns, $actions, 'sequences-sequences', $this->lang['strnosequences']); $this->printNavLinks(['create' => [ - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'create', - 'server' => $_REQUEST['server'], + 'action' => 'create', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], ], ], ], @@ -212,21 +212,22 @@ class SequencesController extends BaseController $data = $this->misc->getDatabaseAccessor(); $sequences = $data->getSequences(); - - $reqvars = $this->misc->getRequestVars('sequence'); - + $reqvars = $this->misc->getRequestVars('sequence'); + + $actionURL = Decorator::actionurl( + 'sequences', + $reqvars, + [ + 'action' => 'properties', + 'sequence' => Decorator::field('seqname'), + ] + ); + dump($sequences, $actionURL); $attrs = [ - 'text' => Decorator::field('seqname'), - 'icon' => 'Sequence', + 'text' => Decorator::field('seqname'), + 'icon' => 'Sequence', 'toolTip' => Decorator::field('seqcomment'), - 'action' => Decorator::actionurl( - 'sequences', - $reqvars, - [ - 'action' => 'properties', - 'sequence' => Decorator::field('seqname'), - ] - ), + 'action' => $actionURL, ]; return $this->printTree($sequences, $attrs, 'sequences'); @@ -288,30 +289,30 @@ class SequencesController extends BaseController echo ''; $navlinks = [ - 'alter' => [ - 'attr' => [ + 'alter' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'confirm_alter', - 'server' => $_REQUEST['server'], + 'action' => 'confirm_alter', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], 'sequence' => $sequence->fields['seqname'], ], ], ], 'content' => $this->lang['stralter'], ], - 'setval' => [ - 'attr' => [ + 'setval' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'confirm_setval', - 'server' => $_REQUEST['server'], + 'action' => 'confirm_setval', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], 'sequence' => $sequence->fields['seqname'], ], ], @@ -319,14 +320,14 @@ class SequencesController extends BaseController 'content' => $this->lang['strsetval'], ], 'nextval' => [ - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'nextval', - 'server' => $_REQUEST['server'], + 'action' => 'nextval', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], 'sequence' => $sequence->fields['seqname'], ], ], @@ -334,29 +335,29 @@ class SequencesController extends BaseController 'content' => $this->lang['strnextval'], ], 'restart' => [ - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'restart', - 'server' => $_REQUEST['server'], + 'action' => 'restart', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], 'sequence' => $sequence->fields['seqname'], ], ], ], 'content' => $this->lang['strrestart'], ], - 'reset' => [ - 'attr' => [ + 'reset' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'action' => 'reset', - 'server' => $_REQUEST['server'], + 'action' => 'reset', + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], 'sequence' => $sequence->fields['seqname'], ], ], @@ -364,13 +365,13 @@ class SequencesController extends BaseController 'content' => $this->lang['strreset'], ], 'showall' => [ - 'attr' => [ + 'attr' => [ 'href' => [ - 'url' => 'sequences', + 'url' => 'sequences', 'urlvars' => [ - 'server' => $_REQUEST['server'], + 'server' => $_REQUEST['server'], 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], + 'schema' => $_REQUEST['schema'], ], ], ], @@ -423,13 +424,13 @@ class SequencesController extends BaseController echo "" . \PHP_EOL; echo '
' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; } else { if (\is_array($_POST['sequence'])) { - $msg = ''; + $msg = ''; $status = $data->beginTransaction(); if (0 === $status) { @@ -525,7 +526,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -650,7 +651,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strsetval']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -825,7 +826,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; diff --git a/src/controllers/TablesController.php b/src/controllers/TablesController.php index 247bd238..e0054d8c 100644 --- a/src/controllers/TablesController.php +++ b/src/controllers/TablesController.php @@ -342,7 +342,7 @@ class TablesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strnext']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -457,7 +457,7 @@ class TablesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; echo '' . \PHP_EOL; @@ -630,7 +630,7 @@ class TablesController extends BaseController echo ''; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "
lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -756,7 +756,7 @@ class TablesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strselect']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -944,7 +944,7 @@ class TablesController extends BaseController echo "{$this->lang['strnofieldsforinsert']}
" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; } - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; echo ''; } @@ -1021,7 +1021,7 @@ class TablesController extends BaseController } echo " "; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strempty']}\" /> lang['strcancel']}\" />" . \PHP_EOL; echo "\n"; // END if confirm } else { @@ -1097,7 +1097,7 @@ class TablesController extends BaseController } echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "" . \PHP_EOL; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; diff --git a/src/controllers/TablespacesController.php b/src/controllers/TablespacesController.php index c1721492..532669bf 100644 --- a/src/controllers/TablespacesController.php +++ b/src/controllers/TablespacesController.php @@ -189,7 +189,7 @@ class TablespacesController extends BaseController $this->coalesceArr($_POST, 'comment', ($data->hasSharedComments()) ? $tablespace->fields['spccomment'] : ''); echo '
{$this->lang['strname']} | " . \PHP_EOL; echo '';
@@ -265,7 +265,7 @@ class TablespacesController extends BaseController
echo ' ', \sprintf($this->lang['strconfdroptablespace'], $this->misc->printVal($_REQUEST['tablespace'])), ' ' . \PHP_EOL; echo '
' . \PHP_EOL; echo '' . \PHP_EOL; - echo $misc->form; + echo $view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" /> " . \PHP_EOL; echo ' | \n\t
---|
' . \PHP_EOL; - echo $misc->form; + echo $view->form; echo '' . \PHP_EOL; echo "lang['strimport']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $misc->form; + echo $view->form; echo '' . \PHP_EOL; if (!$data->hasCreateFieldWithConstraints()) { @@ -653,7 +653,7 @@ class TblpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $misc->form; + echo $view->form; echo "
" . \PHP_EOL; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; diff --git a/src/controllers/TriggersController.php b/src/controllers/TriggersController.php index 9a9c3145..abcbfc28 100644 --- a/src/controllers/TriggersController.php +++ b/src/controllers/TriggersController.php @@ -283,7 +283,7 @@ class TriggersController extends BaseController echo '
' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strok']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -315,7 +315,7 @@ class TriggersController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "" . \PHP_EOL; echo "lang['stryes']}\" />" . \PHP_EOL; echo "lang['strno']}\" />" . \PHP_EOL; @@ -354,7 +354,7 @@ class TriggersController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stryes']}\" />" . \PHP_EOL; echo "lang['strno']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; @@ -392,7 +392,7 @@ class TriggersController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stryes']}\" />" . \PHP_EOL; echo "lang['strno']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; @@ -476,7 +476,7 @@ class TriggersController extends BaseController echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; } diff --git a/src/controllers/TypesController.php b/src/controllers/TypesController.php index 43ddda75..dcf18ae1 100644 --- a/src/controllers/TypesController.php +++ b/src/controllers/TypesController.php @@ -348,7 +348,7 @@ class TypesController extends BaseController echo "
" . \PHP_EOL; echo '
' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -402,7 +402,7 @@ class TypesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strnext']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -481,7 +481,7 @@ class TypesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; @@ -579,7 +579,7 @@ class TypesController extends BaseController echo '' . \PHP_EOL; echo '
' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strnext']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -625,7 +625,7 @@ class TypesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; @@ -777,7 +777,7 @@ class TypesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '
' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/UsersController.php b/src/controllers/UsersController.php index 5ce1db89..de9852c8 100644 --- a/src/controllers/UsersController.php +++ b/src/controllers/UsersController.php @@ -266,7 +266,7 @@ class UsersController extends BaseController echo "\t\t' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strok']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '
' . \PHP_EOL; @@ -349,7 +349,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -403,7 +403,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/ViewpropertiesController.php b/src/controllers/ViewpropertiesController.php index d0ce462a..609919fc 100644 --- a/src/controllers/ViewpropertiesController.php +++ b/src/controllers/ViewpropertiesController.php @@ -172,7 +172,7 @@ class ViewpropertiesController extends BaseController- {$this->misc->form} + {$this->view->form}
@@ -228,7 +228,7 @@ EOT; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; @@ -343,7 +343,7 @@ EOT; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "
lang['stralter']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; diff --git a/src/controllers/ViewsController.php b/src/controllers/ViewsController.php index c658f858..a78a0cbf 100644 --- a/src/controllers/ViewsController.php +++ b/src/controllers/ViewsController.php @@ -297,7 +297,7 @@ class ViewsController extends BaseController echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "" . \PHP_EOL; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; @@ -416,7 +416,7 @@ class ViewsController extends BaseController \htmlspecialchars($_REQUEST['formComment']), "\n\t" . \PHP_EOL; echo '' . \PHP_EOL; echo '
' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; -- cgit v1.2.3 From 221d5cb3d6338e1da859a2c80e6a518917d04c9e Mon Sep 17 00:00:00 2001 From: ffflabs" . \PHP_EOL; echo "
" . \PHP_EOL; echo "
" . \PHP_EOL; @@ -287,7 +287,7 @@ trait AdminTrait } echo '
' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo $table_hidden_inputs; echo "lang['strvacuum']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo $table_hidden_inputs; echo "lang['stranalyze']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo $table_hidden_inputs; echo "lang['strreindex']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; - $content .= $this->misc->form; + $content .= $this->view->form; $content .= \sprintf( '%s', $subject, diff --git a/src/traits/FormTrait.php b/src/traits/FormTrait.php index dfcd12b1..b6089083 100644 --- a/src/traits/FormTrait.php +++ b/src/traits/FormTrait.php @@ -23,7 +23,7 @@ trait FormTrait */ public function getActionTableAndButtons($action, $table, $add, $cancel) { - $content = $this->misc->form; + $content = $this->view->form; $content .= \sprintf('%s', $action, \PHP_EOL); $content .= \sprintf('%s', $table, \PHP_EOL); $content .= \sprintf('%s', $add, \PHP_EOL); @@ -41,7 +41,7 @@ trait FormTrait */ public function getFormInputsAndButtons($inputs, $buttons, $cheboxes = []) { - $content = $this->misc->form; + $content = $this->view->form; foreach ($cheboxes as $checkbox) { $content .= \sprintf('
%s', \PHP_EOL); diff --git a/src/traits/ViewsMatviewsTrait.php b/src/traits/ViewsMatviewsTrait.php index ca93a1d5..df5e36a1 100644 --- a/src/traits/ViewsMatviewsTrait.php +++ b/src/traits/ViewsMatviewsTrait.php @@ -137,7 +137,7 @@ trait ViewsMatviewsTrait echo '
' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strselect']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; - echo $this->misc->form; + echo $this->view->form; echo "lang['strnext']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; @@ -460,7 +460,7 @@ trait ViewsMatviewsTrait echo '' . \PHP_EOL; } - echo $this->misc->form; + echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; echo '' . \PHP_EOL; -- cgit v1.2.3 From 6acec792e066cfac909650d26246c7c6dd46a0df Mon Sep 17 00:00:00 2001 From: ffflabsThe application could not run because of the following error:
'; -- cgit v1.2.3 From 02b488ee1cc1e3aabdb5625ad4ea10f11086424f Mon Sep 17 00:00:00 2001 From: ffflabsThe application could not run because of the following error:
'; diff --git a/src/router.php b/src/router.php index 20d9909a..18fd870c 100644 --- a/src/router.php +++ b/src/router.php @@ -32,8 +32,8 @@ $app->post('/redirect/server', function ( $body = $response->getBody(); $misc = $this->misc; - $loginShared = $request->getParsedBodyParam('loginShared'); - $loginServer = $request->getParsedBodyParam('loginServer'); + $loginShared = $request->getParsedBodyParam('loginShared'); + $loginServer = $request->getParsedBodyParam('loginServer'); $loginUsername = $request->getParsedBodyParam('loginUsername'); $loginPassword = $request->getParsedBodyParam('loginPassword_' . \md5($loginServer)); @@ -83,7 +83,7 @@ $app->get('/redirect[/{subject}]', function ( /* @scrutinizer ignore-unused */ array $args ) { - $subject = (isset($args['subject'])) ? $args['subject'] : 'root'; + $subject = (isset($args['subject'])) ? $args['subject'] : 'root'; $destinationurl = $this->utils->getDestinationWithLastTab($subject); return $response->withStatus(302)->withHeader('Location', $destinationurl); @@ -116,7 +116,7 @@ $app->map(['GET', 'POST'], '/src/views/{subject}', function ( return $response->withStatus(302)->withHeader('Location', $destinationurl); } - $className = '\PHPPgAdmin\Controller\\' . \ucfirst($subject) . 'Controller'; + $className = '\PHPPgAdmin\Controller\\' . \ucfirst($subject) . 'Controller'; $controller = new $className($this); return $controller->render(); @@ -174,12 +174,13 @@ $app->get('[/{path:.*}]', function ( /* @scrutinizer ignore-unused */ array $args ) { - $filepath = \dirname(__DIR__) . '/' . $args['path']; + $filepath = \dirname(__DIR__) . '/' . $args['path']; $query_string = $request->getUri()->getQuery(); //d($this->subfolder, $args, $query_string, $filepath); - //$this->utils->prtrace($request->getAttribute('route')); + $this->utils->prtrace($request->getAttribute('route')); + return $response->write($args['path'] ? $args['path'] : 'index'); }); diff --git a/src/translations/AbstractLang.php b/src/translations/AbstractLang.php index 0b20fc0c..84a6ee92 100644 --- a/src/translations/AbstractLang.php +++ b/src/translations/AbstractLang.php @@ -11,13 +11,15 @@ namespace PHPPgAdmin\Translations; */ abstract class AbstractLang { - /** @var array */ + /** + * @var array + */ protected $lang = []; - + /** * @return array */ - public function getLang():array + public function getLang(): array { return $this->lang; } diff --git a/src/translations/Afrikaans.php b/src/translations/Afrikaans.php index ff9307da..54633668 100644 --- a/src/translations/Afrikaans.php +++ b/src/translations/Afrikaans.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Afrikaans language. */ -class Afrikaans extends AbstractLang +class Afrikaans extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Afrikaans'; diff --git a/src/translations/Arabic.php b/src/translations/Arabic.php index 5dd76ab2..c1adb2c2 100644 --- a/src/translations/Arabic.php +++ b/src/translations/Arabic.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Arabic language. */ -class Arabic extends AbstractLang +class Arabic extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'عربي'; diff --git a/src/translations/Catalan.php b/src/translations/Catalan.php index f23ebab1..f8f7697b 100644 --- a/src/translations/Catalan.php +++ b/src/translations/Catalan.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Catalan language. */ -class Catalan extends AbstractLang +class Catalan extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Català'; diff --git a/src/translations/ChineseSim.php b/src/translations/ChineseSim.php index a10966b1..3d45e39a 100644 --- a/src/translations/ChineseSim.php +++ b/src/translations/ChineseSim.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for ChineseSim language. */ -class ChineseSim extends AbstractLang +class ChineseSim extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = '简体中文(统一码)'; diff --git a/src/translations/ChineseTr.php b/src/translations/ChineseTr.php index 07030fdd..0f52b9b7 100644 --- a/src/translations/ChineseTr.php +++ b/src/translations/ChineseTr.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for ChineseTr language. */ -class ChineseTr extends AbstractLang +class ChineseTr extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = '正體中文(big5)'; diff --git a/src/translations/ChineseUtf8ZhCn.php b/src/translations/ChineseUtf8ZhCn.php index dc2b9824..4bc315f3 100644 --- a/src/translations/ChineseUtf8ZhCn.php +++ b/src/translations/ChineseUtf8ZhCn.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for ChineseUtf8ZhCn language. */ -class ChineseUtf8ZhCn extends AbstractLang +class ChineseUtf8ZhCn extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = '简体中文(统一码)'; diff --git a/src/translations/ChineseUtf8ZhTw.php b/src/translations/ChineseUtf8ZhTw.php index 2e4510e2..dc4c5fa3 100644 --- a/src/translations/ChineseUtf8ZhTw.php +++ b/src/translations/ChineseUtf8ZhTw.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for ChineseUtf8ZhTw language. */ -class ChineseUtf8ZhTw extends AbstractLang +class ChineseUtf8ZhTw extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = '正體中文(UTF-8)'; diff --git a/src/translations/Czech.php b/src/translations/Czech.php index f10a8de4..a331f8f3 100644 --- a/src/translations/Czech.php +++ b/src/translations/Czech.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Czech language. */ -class Czech extends AbstractLang +class Czech extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Česky'; diff --git a/src/translations/Danish.php b/src/translations/Danish.php index 00ef93a4..084b475f 100644 --- a/src/translations/Danish.php +++ b/src/translations/Danish.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Danish language. */ -class Danish extends AbstractLang +class Danish extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Danish'; diff --git a/src/translations/Dutch.php b/src/translations/Dutch.php index 93ab1e2b..c66ef240 100644 --- a/src/translations/Dutch.php +++ b/src/translations/Dutch.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Dutch language. */ -class Dutch extends AbstractLang +class Dutch extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Nederlands'; diff --git a/src/translations/English.php b/src/translations/English.php index 8d74a9ff..c1782fd0 100644 --- a/src/translations/English.php +++ b/src/translations/English.php @@ -11,7 +11,6 @@ namespace PHPPgAdmin\Translations; */ class English extends AbstractLang { - public function __construct() { $lang = $this->lang; // Language and character set @@ -874,6 +873,4 @@ class English extends AbstractLang $this->lang = $lang; } - - } diff --git a/src/translations/French.php b/src/translations/French.php index 70b1df2a..603b5337 100644 --- a/src/translations/French.php +++ b/src/translations/French.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for French language. */ -class French extends AbstractLang +class French extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Français'; diff --git a/src/translations/Galician.php b/src/translations/Galician.php index ce20a82e..08c1fc41 100644 --- a/src/translations/Galician.php +++ b/src/translations/Galician.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Galician language. */ -class Galician extends AbstractLang +class Galician extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Galego'; diff --git a/src/translations/German.php b/src/translations/German.php index 3a35f53e..0b0c6e04 100644 --- a/src/translations/German.php +++ b/src/translations/German.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for German language. */ -class German extends AbstractLang +class German extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Deutsch'; diff --git a/src/translations/Greek.php b/src/translations/Greek.php index b12c32ce..34348a6a 100644 --- a/src/translations/Greek.php +++ b/src/translations/Greek.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Greek language. */ -class Greek extends AbstractLang +class Greek extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Ελληνικά'; diff --git a/src/translations/Hebrew.php b/src/translations/Hebrew.php index b5f33c40..b2d5f4c0 100644 --- a/src/translations/Hebrew.php +++ b/src/translations/Hebrew.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Hebrew language. */ -class Hebrew extends AbstractLang +class Hebrew extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Hebrew'; diff --git a/src/translations/Hungarian.php b/src/translations/Hungarian.php index 56a22470..7b9ff72b 100644 --- a/src/translations/Hungarian.php +++ b/src/translations/Hungarian.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Hungarian language. */ -class Hungarian extends AbstractLang +class Hungarian extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Magyar'; diff --git a/src/translations/Italian.php b/src/translations/Italian.php index 20557082..f024c63d 100644 --- a/src/translations/Italian.php +++ b/src/translations/Italian.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Italian language. */ -class Italian extends AbstractLang +class Italian extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Italiano'; diff --git a/src/translations/Japanese.php b/src/translations/Japanese.php index 9fcf17c9..b25d1e75 100644 --- a/src/translations/Japanese.php +++ b/src/translations/Japanese.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Japanese language. */ -class Japanese extends AbstractLang +class Japanese extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = '日本語(EUC-JP)'; diff --git a/src/translations/Lithuanian.php b/src/translations/Lithuanian.php index 92249028..727d266f 100644 --- a/src/translations/Lithuanian.php +++ b/src/translations/Lithuanian.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Lithuanian language. */ -class Lithuanian extends AbstractLang +class Lithuanian extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Lietuvių'; diff --git a/src/translations/Mongol.php b/src/translations/Mongol.php index 7fe9f319..6129cffe 100644 --- a/src/translations/Mongol.php +++ b/src/translations/Mongol.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Mongol language. */ -class Mongol extends AbstractLang +class Mongol extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Mongolian'; diff --git a/src/translations/Polish.php b/src/translations/Polish.php index 21aeed42..ce12d448 100644 --- a/src/translations/Polish.php +++ b/src/translations/Polish.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Polish language. */ -class Polish extends AbstractLang +class Polish extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Polski'; diff --git a/src/translations/PortugueseBr.php b/src/translations/PortugueseBr.php index 5dc77f40..40b219bd 100644 --- a/src/translations/PortugueseBr.php +++ b/src/translations/PortugueseBr.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for PortugueseBr language. */ -class PortugueseBr extends AbstractLang +class PortugueseBr extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Português-Brasileiro'; diff --git a/src/translations/PortuguesePt.php b/src/translations/PortuguesePt.php index 5921d455..395b3fe4 100644 --- a/src/translations/PortuguesePt.php +++ b/src/translations/PortuguesePt.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for PortuguesePt language. */ -class PortuguesePt extends AbstractLang +class PortuguesePt extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Português-Português'; diff --git a/src/translations/Romanian.php b/src/translations/Romanian.php index 98866d67..184eba41 100644 --- a/src/translations/Romanian.php +++ b/src/translations/Romanian.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Romanian language. */ -class Romanian extends AbstractLang +class Romanian extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Română'; diff --git a/src/translations/Russian.php b/src/translations/Russian.php index c7e67c38..03c37111 100644 --- a/src/translations/Russian.php +++ b/src/translations/Russian.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Russian language. */ -class Russian extends AbstractLang +class Russian extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Русский КОИ8'; diff --git a/src/translations/RussianUtf8.php b/src/translations/RussianUtf8.php index 0372150b..bbe96e70 100644 --- a/src/translations/RussianUtf8.php +++ b/src/translations/RussianUtf8.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for RussianUtf8 language. */ -class RussianUtf8 extends AbstractLang +class RussianUtf8 extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Русский (UTF-8)'; diff --git a/src/translations/Slovak.php b/src/translations/Slovak.php index 09171f4d..e3834a5e 100644 --- a/src/translations/Slovak.php +++ b/src/translations/Slovak.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Slovak language. */ -class Slovak extends AbstractLang +class Slovak extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Slovensky'; diff --git a/src/translations/Spanish.php b/src/translations/Spanish.php index 1fef78b2..9f6d6a77 100644 --- a/src/translations/Spanish.php +++ b/src/translations/Spanish.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Spanish language. */ -class Spanish extends AbstractLang +class Spanish extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Spanish'; diff --git a/src/translations/Swedish.php b/src/translations/Swedish.php index df887225..6eaa8791 100644 --- a/src/translations/Swedish.php +++ b/src/translations/Swedish.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Swedish language. */ -class Swedish extends AbstractLang +class Swedish extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Swedish'; diff --git a/src/translations/Turkish.php b/src/translations/Turkish.php index 10edbb24..897a1da6 100644 --- a/src/translations/Turkish.php +++ b/src/translations/Turkish.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Turkish language. */ -class Turkish extends AbstractLang +class Turkish extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Türkçe'; diff --git a/src/translations/Ukrainian.php b/src/translations/Ukrainian.php index 98a769fd..d73366d9 100644 --- a/src/translations/Ukrainian.php +++ b/src/translations/Ukrainian.php @@ -9,9 +9,9 @@ namespace PHPPgAdmin\Translations; /** * Class providing translation for Ukrainian language. */ -class Ukrainian extends AbstractLang +class Ukrainian extends AbstractLang { - public function getLang():array + public function getLang(): array { $lang = $this->lang; // Language and character set $lang['applang'] = 'Укра╖нська'; -- cgit v1.2.3 From db6e69bb8f672f0f3d122e8f4039f72c23e2c7c7 Mon Sep 17 00:00:00 2001 From: ffflabs' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -385,7 +385,7 @@ class AggregatesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; echo "lang['strback']}\" />" . \PHP_EOL; @@ -415,7 +415,7 @@ class AggregatesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $this->data->dropAggregate($_POST['aggrname'], $_POST['aggrtype'], isset($_POST['cascade'])); diff --git a/src/controllers/AlldbController.php b/src/controllers/AlldbController.php index d5431215..105aa7a6 100644 --- a/src/controllers/AlldbController.php +++ b/src/controllers/AlldbController.php @@ -515,7 +515,7 @@ class AlldbController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/BaseController.php b/src/controllers/BaseController.php index c10431f4..f4c00971 100644 --- a/src/controllers/BaseController.php +++ b/src/controllers/BaseController.php @@ -67,7 +67,9 @@ class BaseController * @var \PHPPgAdmin\ViewManager */ public $view; - + /** + * @var \PHPPgAdmin\Misc + */ public $misc; public $conf; @@ -75,11 +77,9 @@ class BaseController public $phpMinVer; protected $script; - + /** @var \Slim\Container */ protected $container; - protected $app; - protected $data; protected $database; @@ -88,26 +88,31 @@ class BaseController /** * @var XHtml\HTMLTableController + * @psalm-suppress PropertyNotSetInConstructor */ protected $_table_controller; /** * @var XHtml\HTMLFooterController + * @psalm-suppress PropertyNotSetInConstructor */ protected $_footer_controller; /** * @var XHtml\HTMLHeaderController + * @psalm-suppress PropertyNotSetInConstructor */ protected $_header_controller; /** * @var XHtml\HTMLNavbarController + * @psalm-suppress PropertyNotSetInConstructor */ protected $_trail_controller; /** * @var TreeController + * @psalm-suppress PropertyNotSetInConstructor */ protected $_tree_controller; @@ -432,8 +437,9 @@ class BaseController } /** - * @param null|string $default + * * @param string $key + * @param null|string $default */ public function getRequestParam(string $key, ?string $default = null) { @@ -441,15 +447,24 @@ class BaseController } /** - * @param null|array|string $default + * * @param string $key + * @param bool|null|array|string|int|float $default + * + * @return bool| null|array|string|int|float */ public function getPostParam(string $key, $default = null) { return $this->container->requestobj->getParsedBodyParam($key, $default); } - - public function getQueryParam($key, $default = null) + /** + * + * @param string $key + * @param null|array|string|int|float $default + * + * @return null|array|string|int|float + */ + public function getQueryParamstring ($key, $default = null) { return $this->container->requestobj->getQueryParam($key, $default); } diff --git a/src/controllers/ColpropertiesController.php b/src/controllers/ColpropertiesController.php index ff052147..796798e3 100644 --- a/src/controllers/ColpropertiesController.php +++ b/src/controllers/ColpropertiesController.php @@ -337,7 +337,7 @@ class ColpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo $this->view->form; - echo '' . \PHP_EOL; + echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo '' . \PHP_EOL; echo '' . \PHP_EOL; @@ -353,7 +353,7 @@ class ColpropertiesController extends BaseController echo '' . \PHP_EOL; } echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; echo '" . \PHP_EOL; diff --git a/src/controllers/DataexportController.php b/src/controllers/DataexportController.php index ff314475..f890531e 100644 --- a/src/controllers/DataexportController.php +++ b/src/controllers/DataexportController.php @@ -133,7 +133,7 @@ class DataexportController extends BaseController if (isset($_REQUEST['table'])) { echo '' . \PHP_EOL; - echo '' . \PHP_EOL; + echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); } else { echo '' . \PHP_EOL; } diff --git a/src/controllers/DisplayController.php b/src/controllers/DisplayController.php index 19a7dc1b..c07ebca3 100644 --- a/src/controllers/DisplayController.php +++ b/src/controllers/DisplayController.php @@ -825,7 +825,7 @@ class DisplayController extends BaseController } if (isset($_REQUEST['table'])) { - echo '' . \PHP_EOL; + echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); } if (isset($_REQUEST['subject'])) { diff --git a/src/controllers/DomainsController.php b/src/controllers/DomainsController.php index 42f13898..db93107f 100644 --- a/src/controllers/DomainsController.php +++ b/src/controllers/DomainsController.php @@ -310,7 +310,7 @@ class DomainsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -352,7 +352,7 @@ class DomainsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stradd']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if ('' === \trim($_POST['definition'])) { @@ -566,7 +566,7 @@ class DomainsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropDomain($_POST['domain'], isset($_POST['cascade'])); @@ -649,7 +649,7 @@ class DomainsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/FulltextController.php b/src/controllers/FulltextController.php index 3399d97b..24b40568 100644 --- a/src/controllers/FulltextController.php +++ b/src/controllers/FulltextController.php @@ -315,7 +315,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropFtsConfiguration($_POST['ftscfg'], isset($_POST['cascade'])); @@ -348,7 +348,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropFtsDictionary($_POST['ftsdict'], isset($_POST['cascade'])); @@ -552,7 +552,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -988,7 +988,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -1151,7 +1151,7 @@ class FulltextController extends BaseController echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strftsnodictionaries']}
" . \PHP_EOL; @@ -1238,7 +1238,7 @@ class FulltextController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stradd']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strftsnodictionaries']}
" . \PHP_EOL; diff --git a/src/controllers/FunctionsController.php b/src/controllers/FunctionsController.php index 9be53647..726b714c 100644 --- a/src/controllers/FunctionsController.php +++ b/src/controllers/FunctionsController.php @@ -469,7 +469,7 @@ class FunctionsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -966,7 +966,7 @@ class FunctionsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; echo $szJS; } diff --git a/src/controllers/GroupsController.php b/src/controllers/GroupsController.php index dbfe116e..c5750ce8 100644 --- a/src/controllers/GroupsController.php +++ b/src/controllers/GroupsController.php @@ -353,7 +353,7 @@ class GroupsController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/IndexesController.php b/src/controllers/IndexesController.php index b65b6d16..85a1eacd 100644 --- a/src/controllers/IndexesController.php +++ b/src/controllers/IndexesController.php @@ -438,7 +438,7 @@ class IndexesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/MaterializedviewpropertiesController.php b/src/controllers/MaterializedviewpropertiesController.php index 6e2ff20c..ef7cbe11 100644 --- a/src/controllers/MaterializedviewpropertiesController.php +++ b/src/controllers/MaterializedviewpropertiesController.php @@ -163,7 +163,7 @@ class MaterializedviewpropertiesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -219,7 +219,7 @@ class MaterializedviewpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; break; @@ -331,7 +331,7 @@ class MaterializedviewpropertiesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; diff --git a/src/controllers/MaterializedviewsController.php b/src/controllers/MaterializedviewsController.php index 3cbb7ffd..3d58327b 100644 --- a/src/controllers/MaterializedviewsController.php +++ b/src/controllers/MaterializedviewsController.php @@ -418,7 +418,7 @@ class MaterializedviewsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/OperatorsController.php b/src/controllers/OperatorsController.php index 0ce1a773..d1bf39ec 100644 --- a/src/controllers/OperatorsController.php +++ b/src/controllers/OperatorsController.php @@ -263,7 +263,7 @@ class OperatorsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropOperator($_POST['operator_oid'], isset($_POST['cascade'])); diff --git a/src/controllers/RolesController.php b/src/controllers/RolesController.php index 64ce51ab..9dd3d1ce 100644 --- a/src/controllers/RolesController.php +++ b/src/controllers/RolesController.php @@ -317,7 +317,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -483,7 +483,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -540,7 +540,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropRole($_REQUEST['rolename']); diff --git a/src/controllers/RulesController.php b/src/controllers/RulesController.php index c43abd83..33fed67a 100644 --- a/src/controllers/RulesController.php +++ b/src/controllers/RulesController.php @@ -204,7 +204,7 @@ class RulesController extends BaseController '" value="', \htmlspecialchars($_REQUEST[$_REQUEST['subject']]), '" />' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if ('' === \trim($_POST['name'])) { diff --git a/src/controllers/SchemasController.php b/src/controllers/SchemasController.php index 4268f088..dbf2b93a 100644 --- a/src/controllers/SchemasController.php +++ b/src/controllers/SchemasController.php @@ -394,7 +394,7 @@ class SchemasController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -455,7 +455,7 @@ class SchemasController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if (\is_array($_POST['nsp'])) { diff --git a/src/controllers/SequencesController.php b/src/controllers/SequencesController.php index 3c9d7d0b..617c956c 100644 --- a/src/controllers/SequencesController.php +++ b/src/controllers/SequencesController.php @@ -426,7 +426,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if (\is_array($_POST['sequence'])) { @@ -528,7 +528,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -653,7 +653,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strsetval']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -829,7 +829,7 @@ class SequencesController extends BaseController echo $this->view->form; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; diff --git a/src/controllers/TablesController.php b/src/controllers/TablesController.php index e0054d8c..a4e766cb 100644 --- a/src/controllers/TablesController.php +++ b/src/controllers/TablesController.php @@ -344,7 +344,7 @@ class TablesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strnext']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; break; @@ -470,7 +470,7 @@ class TablesController extends BaseController echo '' . \PHP_EOL; } echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; break; @@ -632,7 +632,7 @@ class TablesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if ('' === \trim($_REQUEST['name'])) { @@ -754,11 +754,11 @@ class TablesController extends BaseController } echo '' . \PHP_EOL; - echo '' . \PHP_EOL; + echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strselect']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; return; @@ -927,7 +927,7 @@ class TablesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo '' . \PHP_EOL; + echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo "lang['strinsert']}\" />" . \PHP_EOL; echo "lang['strinsertandrepeat']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; @@ -1016,7 +1016,7 @@ class TablesController extends BaseController echo '
', \sprintf($this->lang['strconfdroptable'], $this->misc->printVal($_REQUEST['table'])), '
' . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '{$this->lang['strnodata']}
" . \PHP_EOL; @@ -334,7 +334,7 @@ class TablespacesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/TblpropertiesController.php b/src/controllers/TblpropertiesController.php index 919807bb..ab84dd62 100644 --- a/src/controllers/TblpropertiesController.php +++ b/src/controllers/TblpropertiesController.php @@ -287,8 +287,17 @@ class TblpropertiesController extends BaseController $this->coalesceArr($_POST, 'tablespace', null); $this->coalesceArr($_POST, 'newschema', null); - - $status = $data->alterTable($_POST['table'], $_POST['name'], $_POST['owner'], $_POST['newschema'], $_POST['comment'], $_POST['tablespace']); + $with_oids = boolval($this->getPostParam('with_oids', false)); + + $status = $data->alterTable( + $this->getPostParam('table'), + $this->getPostParam('name'), + $this->getPostParam('owner'), + $this->getPostParam('newschema'), + $this->getPostParam('comment'), + $this->getPostParam('tablespace'), + $with_oids + ); if (0 === $status) { // If table has been renamed, need to change to the new name and @@ -307,6 +316,7 @@ class TblpropertiesController extends BaseController } $this->doDefault($this->lang['strtablealtered']); } else { + $this->doAlter($this->lang['strtablealteredbad']); } } @@ -353,7 +363,8 @@ class TblpropertiesController extends BaseController echo "' . \PHP_EOL; - echo '' . \PHP_EOL; - echo $view->form; + echo sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); + + echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -480,8 +504,8 @@ class TblpropertiesController extends BaseController echo "\n\t" . \PHP_EOL; echo '' . \PHP_EOL; echo '' . \PHP_EOL; - echo $view->form; - echo '' . \PHP_EOL; + echo $this->view->form; + echo sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo "lang['strimport']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; } @@ -537,15 +561,18 @@ class TblpropertiesController extends BaseController echo "' . \PHP_EOL; echo '' . \PHP_EOL; - echo $view->form; - echo '' . \PHP_EOL; + echo $this->view->form; + echo sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); if (!$data->hasCreateFieldWithConstraints()) { echo '' . \PHP_EOL; } echo "lang['stradd']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; echo '" . \PHP_EOL; @@ -651,9 +683,9 @@ class TblpropertiesController extends BaseController echo '" . \PHP_EOL; echo "lang['strdrop']}\" />" . \PHP_EOL; echo "lang['strcancel']}\" />" . \PHP_EOL; diff --git a/src/controllers/TriggersController.php b/src/controllers/TriggersController.php index abcbfc28..d7c3d34f 100644 --- a/src/controllers/TriggersController.php +++ b/src/controllers/TriggersController.php @@ -281,11 +281,11 @@ class TriggersController extends BaseController \htmlspecialchars($_POST['name']), '" />' . \PHP_EOL; echo '' . \PHP_EOL; echo '
' . \PHP_EOL; - echo '' . \PHP_EOL; + echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strok']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '{$this->lang['strnodata']}
" . \PHP_EOL; @@ -313,7 +313,7 @@ class TriggersController extends BaseController echo '" . \PHP_EOL; @@ -352,7 +352,7 @@ class TriggersController extends BaseController echo '
lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; - echo '' . \PHP_EOL; + echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo $this->view->form; echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/UsersController.php b/src/controllers/UsersController.php index de9852c8..bffe2104 100644 --- a/src/controllers/UsersController.php +++ b/src/controllers/UsersController.php @@ -351,7 +351,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -405,7 +405,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropUser($_REQUEST['username']); @@ -459,7 +459,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/ViewpropertiesController.php b/src/controllers/ViewpropertiesController.php index 609919fc..237b0664 100644 --- a/src/controllers/ViewpropertiesController.php +++ b/src/controllers/ViewpropertiesController.php @@ -233,7 +233,7 @@ EOT; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; break; @@ -345,7 +345,7 @@ EOT; echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; diff --git a/src/controllers/ViewsController.php b/src/controllers/ViewsController.php index a78a0cbf..c8212af6 100644 --- a/src/controllers/ViewsController.php +++ b/src/controllers/ViewsController.php @@ -418,7 +418,7 @@ class ViewsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo "lang['strcancel']}\" />
" . \PHP_EOL; + echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/database/ADOdbBase.php b/src/database/ADOdbBase.php index bae800af..1b23f47e 100644 --- a/src/database/ADOdbBase.php +++ b/src/database/ADOdbBase.php @@ -18,23 +18,24 @@ class ADOdbBase { use \PHPPgAdmin\Traits\HelperTrait; use \PHPPgAdmin\Database\Traits\HasTrait; - +/** @var array */ public $lang; - +/** @var array */ public $conf; - +/** @var \Slim\Container */ protected $container; - +/** @var array */ protected $server_info; - + /** @var string */ + protected $lastExecutedSql; /** * Base constructor. * - * @param ADONewConnection $conn The connection object + * @param \ADODB_postgres9|\ADODB_pdo $conn The connection object * @param mixed $container * @param mixed $server_info */ - public function __construct(&$conn, $container, $server_info) + public function __construct( &$conn, $container, $server_info) { $this->container = $container; $this->server_info = $server_info; @@ -43,8 +44,9 @@ class ADOdbBase $this->conf = $container->get('conf'); $this->prtrace('instanced connection class'); + $this->lastExecutedSql=''; $this->conn = $conn; - } + } /** * Sets the comment for an object in the database. @@ -118,10 +120,14 @@ class ADOdbBase } else { $sql .= 'NULL;'; } - +$this->lastExecutedSql=$sql; return $this->execute($sql); } - +public function getLastExecutedSQL():string { + $lastExecutedSql=$this->lastExecutedSql; + $this->lastExecutedSql=''; + return $lastExecutedSql; +} /** * Turns on or off query debugging. * @@ -470,31 +476,31 @@ class ADOdbBase /** * Begin a transaction. * - * @return bool 0 success + * @return int 0 success */ public function beginTransaction() { - return !$this->conn->BeginTrans(); + return intval(!$this->conn->BeginTrans()); } /** * End a transaction. * - * @return bool 0 success + * @return int 0 success */ public function endTransaction() { - return !$this->conn->CommitTrans(); + return intval(!$this->conn->CommitTrans()); } /** * Roll back a transaction. * - * @return bool 0 success + * @return int 0 success */ public function rollbackTransaction() { - return !$this->conn->RollbackTrans(); + return intval( !$this->conn->RollbackTrans()); } /** diff --git a/src/database/Connection.php b/src/database/Connection.php deleted file mode 100644 index 53d87802..00000000 --- a/src/database/Connection.php +++ /dev/null @@ -1,183 +0,0 @@ - 'Postgres13', - '12' => 'Postgres12', - '11' => 'Postgres11', - '10' => 'Postgres10', - '9.7' => 'Postgres96', - '9.6' => 'Postgres96', - '9.5' => 'Postgres95', - '9.4' => 'Postgres94', - '9.3' => 'Postgres93', - '9.2' => 'Postgres92', - '9.1' => 'Postgres91', - '9.0' => 'Postgres90', - ]; - - // The backend platform. Set to UNKNOWN by default. - private $_connection_result; - - /** - * Creates a new connection. Will actually make a database connection. - * - * @param array $server_info - * @param string $database database name - * @param \Slim\Container $container - * @param int $fetchMode Defaults to associative. Override for different behaviour - */ - public function __construct($server_info, $database, $container, $fetchMode = ADODB_FETCH_ASSOC) - { - $host = $server_info['host']; - $port = $server_info['port']; - $sslmode = $server_info['sslmode']; - $user = $server_info['username']; - $password = $server_info['password']; - - $this->server_info = $server_info; - - $this->container = $container; - - $this->conn = \ADONewConnection('postgres9'); - //$this->conn->debug = true; - $this->conn->setFetchMode($fetchMode); - - // Ignore host if null - if (null === $host || '' === $host) { - if (null !== $port && '' !== $port) { - $pghost = ':' . $port; - } else { - $pghost = ''; - } - } else { - $pghost = "{$host}:{$port}"; - } - - // Add sslmode to $pghost as needed - if (('disable' === $sslmode) || ('allow' === $sslmode) || ('prefer' === $sslmode) || ('require' === $sslmode)) { - $pghost .= ':' . $sslmode; - } elseif ('legacy' === $sslmode) { - $pghost .= ' requiressl=1'; - } - - /*try { - $this->_connection_result = $this->conn->connect($pghost, $user, $password, $database); - $this->prtrace(['_connection_result' => $this->_connection_result, 'conn' => $this->conn]); - } catch (\PHPPgAdmin\ADOdbException $e) { - $this->prtrace(['message' => $e->getMessage(), 'trace' => $e->getTraceAsString()]); - */ - try { - $this->conn->connect($pghost, $user, $password, $database); - //$this->prtrace($this->conn); - } catch (\Exception $e) { - dump($e); - $this->prtrace($e->getMessage(), $e->getTrace()); - } - } - - public function getConnectionResult() - { - return $this->_connection_result; - } - - /** - * Gets the name of the correct database driver to use. As a side effect, - * sets the platform. - * - * @param string $description A description of the database and version (returns by reference) - * - * @return string The driver. e.g. Postgres96 - */ - public function getDriver(&$description) - { - $version = null; - - if ($this->conn->_connectionID) { - $v = \pg_version($this->conn->_connectionID); - - //\PhpConsole\Handler::getInstance()->debug($v, 'pg_version'); - - if (isset($v['server'])) { - $version = $v['server']; - } - } - // If we didn't manage to get the version without a query, query... - if (!isset($version)) { - $adodb = new ADOdbBase($this->conn, $this->container, $this->server_info); - - $sql = 'SELECT VERSION() AS version'; - $field = $adodb->selectField($sql, 'version'); - - // Check the platform, if it's mingw, set it - if (\preg_match('/ mingw /i', $field)) { - $this->platform = 'MINGW'; - } - - $params = \explode(' ', $field); - - if (!isset($params[1])) { - return null; - } - - $version = $params[1]; // eg. 8.4.4 - } - - $description = "PostgreSQL {$version}"; - - $version_parts = \explode('.', $version); - - if ((int) (10 <= $version_parts[0])) { - $major_version = $version_parts[0]; - } else { - $major_version = \implode('.', [$version_parts[0], $version_parts[1]]); - } - - //$this->prtrace(['pg_version' => pg_version($this->conn->_connectionID), 'version' => $version, 'major_version' => $major_version]); - // Detect version and choose appropriate database driver - if (\array_key_exists($major_version, $this->version_dictionary)) { - return $this->version_dictionary[$major_version]; - } - - // if major version is less than 9 return null, we don't support it - if (9 > (int) \mb_substr($version, 0, 1)) { - return null; - } - - // If unknown version, then default to latest driver - return 'Postgres'; - } - - /** - * Get the last error in the connection. - * - * @return string Error string - */ - public function getLastError() - { - return \pg_last_error($this->conn->_connectionID); - } -} diff --git a/src/database/databasetraits/TableTrait.php b/src/database/databasetraits/TableTrait.php index 7cffce4e..6a27be9c 100644 --- a/src/database/databasetraits/TableTrait.php +++ b/src/database/databasetraits/TableTrait.php @@ -187,32 +187,7 @@ trait TableTrait $sql .= ')'; - // @@@@ DUMP CLUSTERING INFORMATION - - // Inherits - /** - * XXX: This is currently commented out as handling inheritance isn't this simple. - * You also need to make sure you don't dump inherited columns and defaults, as well - * as inherited NOT NULL and CHECK constraints. So for the time being, we just do - * not claim to support inheritance. - * $parents = $this->getTableParents($table); - * if ($parents->recordCount() > 0) { - * $sql .= " INHERITS ("; - * while (!$parents->EOF) { - * $this->fieldClean($parents->fields['relname']); - * // Qualify the parent table if it's in another schema - * if ($parents->fields['schemaname'] != $this->_schema) { - * $this->fieldClean($parents->fields['schemaname']); - * $sql .= "\"{$parents->fields['schemaname']}\"."; - * } - * $sql .= "\"{$parents->fields['relname']}\"";. - * - * $parents->moveNext(); - * if (!$parents->EOF) $sql .= ', '; - * } - * $sql .= ")"; - * } - */ + // Handle WITHOUT OIDS if ($this->hasObjectID($table)) { @@ -622,8 +597,8 @@ trait TableTrait } switch ($type[$i]) { - // Have to account for weird placing of length for with/without - // time zone types + // Have to account for weird placing of length for with/without + // time zone types case 'timestamp with time zone': case 'timestamp without time zone': $qual = \mb_substr($type[$i], 9); @@ -818,26 +793,28 @@ trait TableTrait * @param string $schema The new schema for the table * @param string $comment The comment on the table * @param string $tablespace The new tablespace for the table ('' means leave as is) - * + * @param bool $with_oids If set to FALSE, will drop oids column * @return bool|int 0 success */ - public function alterTable($table, $name, $owner, $schema, $comment, $tablespace) + public function alterTable($table, $name, $owner, $schema, $comment, $tablespace, bool $with_oids = true) { - $data = $this->getTable($table); + $tblrs = $this->getTable($table); - if (1 !== $data->recordCount()) { + if (1 !== $tblrs->recordCount()) { return -2; } $status = $this->beginTransaction(); + dump(['beginTransaction' => $status]); if (0 !== $status) { $this->rollbackTransaction(); return -1; } - - $status = $this->_alterTable($data, $name, $owner, $schema, $comment, $tablespace); + $sql_sentence="ALTER TABLE \"{$this->_schema}\".\"{$tblrs->fields['relname']}\" "; + $status = $this->_alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace, !$with_oids,$sql_sentence); + dump(['_alterTable' => [$status, $sql_sentence.$this->getLastExecutedSQL()]]); if (0 !== $status) { $this->rollbackTransaction(); @@ -847,7 +824,117 @@ trait TableTrait return $this->endTransaction(); } + /** + * Protected method which alter a table + * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. + * + * @param \PHPPgAdmin\ADORecordSet $tblrs The table recordSet returned by getTable() + * @param string $name The new name for the table + * @param string $owner The new owner for the table + * @param string $schema The new schema for the table + * @param string $comment The comment on the table + * @param string $tablespace The new tablespace for the table ('' means leave as is) + * @param bool $withoutoids If set to TRUE, will drop oids column + * @return int 0 success + */ + protected function _alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace, bool $withoutoids = false ) + { + $this->fieldArrayClean($tblrs->fields); + + // Comment + $status = $this->setComment('TABLE', '', $tblrs->fields['relname'], $comment); + dump(['setComment' => $this->getLastExecutedSQL()]); + + $this->lastExecutedSql=$this->getLastExecutedSQL(); + if (0 !== $status) { + return -4; + } + + // Owner + $this->fieldClean($owner); + [$TableOwnerStatus,$TableOwnerSQL] = $this->alterTableOwner($tblrs, $owner); + $this->lastExecutedSql.=$TableOwnerSQL?sprintf('%s%s',\PHP_EOL,$TableOwnerSQL):''; + //dump(['alterTableOwner' => [$TableOwnerStatus,$TableOwnerSQL]]); + + if (0 !== $TableOwnerStatus) { + return -5; + } + + // Tablespace + $this->fieldClean($tablespace); + [$TableTablespaceStatus,$TableTablespaceSQL] = $this->alterTableTablespace($tblrs, $tablespace); + $this->lastExecutedSql.=$TableTablespaceSQL?sprintf('%s%s',\PHP_EOL,$TableTablespaceSQL):''; + //dump(['alterTableTablespace' => [$TableTablespaceStatus,$TableTablespaceSQL]]); + + if (0 !== $TableTablespaceStatus) { + return -6; + } + + // Rename + $this->fieldClean($name); + [$TableNameStatus,$TableNameSQL] = $this->alterTableName($tblrs, $name); + $this->lastExecutedSql.=$TableNameSQL?sprintf('%s%s',\PHP_EOL,$TableNameSQL):''; + //dump(['alterTableName' => [$TableNameStatus,$TableNameSQL]]); + + if (0 !== $TableNameStatus) { + return -3; + } + + // Schema + $this->fieldClean($schema); + [$TableSchemaStatus,$TableSchemaSQL] = $this->alterTableSchema($tblrs, $schema); + $this->lastExecutedSql.=$TableSchemaSQL?sprintf('%s%s',\PHP_EOL,$TableSchemaSQL):''; + //dump(['alterTableSchema' => [$TableSchemaStatus,$TableSchemaSQL]]); + + if (0 !== $TableSchemaStatus) { + return -7; + } + [$TableOidsStatus,$TableOidsSQL] = $this->alterTableOids($tblrs, $withoutoids); + $this->lastExecutedSql.=$TableOidsSQL?sprintf('%s%s',\PHP_EOL,$TableOidsSQL):''; + //dump(['alterTableOids' => [$TableOidsStatus,$TableOidsSQL]]); + if (0 !== $TableOidsStatus) { + return -7; + } + + + return 0; + } + /** + * Enables or disables the oid system column to a table a table's owner + * /!\ this function is called from _alterTable which take care of escaping fields. + * + * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() + * @param null|string $owner + * + * @return array{0:int,1:string} [status:0 if successful, change_sql: changed attribute] + */ + public function alterTableOids($tblrs, bool $withoutoids = false): array + { + $status = 0; + $change_sql = ''; + // no changes. Return 0 + if (boolval($this->hasObjectID($tblrs->fields['relname'])) !== !$withoutoids) { + + + /* vars cleaned in _alterTable */ + $f_schema = $this->_schema; + $this->fieldClean($f_schema); + + $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; + $change_sql = " SET "; + if ($withoutoids) { + $change_sql .= ' WITHOUT OIDS'; + } else { + $change_sql .= ' WITH OIDS'; + } + $sql = implode(' ', [$alter_sql, $change_sql]); + + $status = $this->execute($sql); + } + + return [$status, $change_sql]; + } /** * Alter a table's owner * /!\ this function is called from _alterTable which take care of escaping fields. @@ -855,10 +942,12 @@ trait TableTrait * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() * @param null|string $owner * - * @return int|\PHPPgAdmin\ADORecordSet + * @return array{0:int,1:string} [status:0 if successful, change_sql: changed attribute] */ - public function alterTableOwner($tblrs, $owner = null) + public function alterTableOwner($tblrs, $owner = null): array { + $status = 0; + $change_sql = ''; /* vars cleaned in _alterTable */ if (!empty($owner) && ($tblrs->fields['relowner'] !== $owner)) { $f_schema = $this->_schema; @@ -866,14 +955,17 @@ trait TableTrait // If owner has been changed, then do the alteration. We are // careful to avoid this generally as changing owner is a // superuser only function. - $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" OWNER TO \"{$owner}\""; + $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; + $change_sql = " OWNER TO \"{$owner}\""; + $sql = implode(' ', [$alter_sql, $change_sql]); - return $this->execute($sql); + $status = $this->execute($sql); } - return 0; + return [$status, $change_sql]; } + /** * Alter a table's tablespace * /!\ this function is called from _alterTable which take care of escaping fields. @@ -881,10 +973,12 @@ trait TableTrait * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() * @param null|string $tablespace * - * @return int|\PHPPgAdmin\ADORecordSet + * @return array{0:int,1:string} [status:0 if successful, change_sql: changed attribute] */ - public function alterTableTablespace($tblrs, $tablespace = null) + public function alterTableTablespace($tblrs, $tablespace = null): array { + $status = 0; + $change_sql = ''; /* vars cleaned in _alterTable */ if (!empty($tablespace) && ($tblrs->fields['tablespace'] !== $tablespace)) { $f_schema = $this->_schema; @@ -892,12 +986,14 @@ trait TableTrait // If tablespace has been changed, then do the alteration. We // don't want to do this unnecessarily. - $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" SET TABLESPACE \"{$tablespace}\""; + $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; + $change_sql = " SET TABLESPACE \"{$tablespace}\""; + $sql = implode(' ', [$alter_sql, $change_sql]); - return $this->execute($sql); + $status = $this->execute($sql); } - return 0; + return [$status, $change_sql]; } /** @@ -907,27 +1003,29 @@ trait TableTrait * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() * @param string $name The new table's name * - * @return int|\PHPPgAdmin\ADORecordSet + * @return array{0:int,1:string} [status:0 if successful, change_sql: changed attribute] */ - public function alterTableName($tblrs, $name = null) + public function alterTableName($tblrs, $name = null): array { + $status = 0; + $change_sql = ''; /* vars cleaned in _alterTable */ // Rename (only if name has changed) if (!empty($name) && ($name !== $tblrs->fields['relname'])) { $f_schema = $this->_schema; $this->fieldClean($f_schema); - $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" RENAME TO \"{$name}\""; + $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; + $change_sql = " RENAME TO \"{$name}\""; + $sql = implode(' ', [$alter_sql, $change_sql]); $status = $this->execute($sql); if (0 === $status) { $tblrs->fields['relname'] = $name; - } else { - return $status; } } - return 0; + return [$status, $change_sql]; } // Row functions @@ -939,22 +1037,26 @@ trait TableTrait * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() * @param null|string $schema * - * @return int|\PHPPgAdmin\ADORecordSet + * @return array{0:int,1:string} [status:0 if successful, change_sql: changed attribute] */ - public function alterTableSchema($tblrs, $schema = null) + public function alterTableSchema($tblrs, $schema = null): array { + $status = 0; + $change_sql = ''; /* vars cleaned in _alterTable */ if (!empty($schema) && ($tblrs->fields['nspname'] !== $schema)) { $f_schema = $this->_schema; $this->fieldClean($f_schema); // If tablespace has been changed, then do the alteration. We // don't want to do this unnecessarily. - $sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" SET SCHEMA \"{$schema}\""; + $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; + $change_sql = " SET SCHEMA \"{$schema}\""; + $sql = implode(' ', [$alter_sql, $change_sql]); - return $this->execute($sql); + $status = $this->execute($sql); } - return 0; + return [$status, $change_sql]; } /** @@ -1294,64 +1396,6 @@ trait TableTrait abstract public function getAttributeNames($table, $atts); - /** - * Protected method which alter a table - * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. - * - * @param \PHPPgAdmin\ADORecordSet $tblrs The table recordSet returned by getTable() - * @param string $name The new name for the table - * @param string $owner The new owner for the table - * @param string $schema The new schema for the table - * @param string $comment The comment on the table - * @param string $tablespace The new tablespace for the table ('' means leave as is) - * - * @return int 0 success - */ - protected function _alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace) - { - $this->fieldArrayClean($tblrs->fields); - - // Comment - $status = $this->setComment('TABLE', '', $tblrs->fields['relname'], $comment); - - if (0 !== $status) { - return -4; - } - - // Owner - $this->fieldClean($owner); - $status = $this->alterTableOwner($tblrs, $owner); - - if (0 !== $status) { - return -5; - } - - // Tablespace - $this->fieldClean($tablespace); - $status = $this->alterTableTablespace($tblrs, $tablespace); - - if (0 !== $status) { - return -6; - } - - // Rename - $this->fieldClean($name); - $status = $this->alterTableName($tblrs, $name); - - if (0 !== $status) { - return -3; - } - - // Schema - $this->fieldClean($schema); - $status = $this->alterTableSchema($tblrs, $schema); - - if (0 !== $status) { - return -7; - } - - return 0; - } /** * Dumps serial-like columns in the table. @@ -1378,8 +1422,10 @@ trait TableTrait $this->fieldClean($atts->fields['attname']); $sql .= " \"{$atts->fields['attname']}\""; // Dump SERIAL and BIGSERIAL columns correctly - if ($this->phpBool($atts->fields['attisserial']) && - ('integer' === $atts->fields['type'] || 'bigint' === $atts->fields['type'])) { + if ( + $this->phpBool($atts->fields['attisserial']) && + ('integer' === $atts->fields['type'] || 'bigint' === $atts->fields['type']) + ) { if ('integer' === $atts->fields['type']) { $sql .= ' SERIAL'; } else { diff --git a/src/lib.inc.php b/src/lib.inc.php index 7a2dfad0..4dd06496 100644 --- a/src/lib.inc.php +++ b/src/lib.inc.php @@ -69,7 +69,7 @@ if (DEBUGMODE) { $conf['register_debuggers'](); } } - +define('ADODB_ASSOC_CASE',ADODB_ASSOC_CASE_NATIVE); // Fetch App and DI Container $app = \PHPPgAdmin\ContainerUtils::createApp($conf); $container = $app->getContainer(); @@ -77,7 +77,19 @@ $container = $app->getContainer(); if (!$container instanceof \Slim\Container) { \trigger_error('App Container must be an instance of \\Slim\\Container', \E_USER_ERROR); } +function container():\Slim\Container { +return \PHPPgAdmin\ContainerUtils::getContainerInstance(); +} + +function request():\Slim\Http\Request { + return container()->request; + } + + function response():\Slim\Http\Response { + return container()->response; + } + // This should be deprecated once we're sure no php scripts are required directly $container->offsetSet('server', $_REQUEST['server'] ?? null); $container->offsetSet('database', $_REQUEST['database'] ?? null); diff --git a/src/router.php b/src/router.php index 18fd870c..144c7248 100644 --- a/src/router.php +++ b/src/router.php @@ -13,6 +13,8 @@ $app->get('/status', function ( /* @scrutinizer ignore-unused */ array $args ) { + phpinfo(); + return; //dump($this->get('settings')->all()); return $response ->withHeader('Content-type', 'application/json') @@ -128,14 +130,14 @@ $app->get('/{subject:\w+}[/{server_id}]', function ( /* @scrutinizer ignore-unused */ \Slim\Http\Response $response, /* @scrutinizer ignore-unused */ - $subject, - $server_id = null + array $args + ) { - $subject = (isset($args['subject'])) ? $args['subject'] : 'intro'; - //ddd($subject, $server_id); + $subject=$args['subject']??'intro'; + $server_id=$args['server_id']??$request->getQueryParam('server'); + //ddd($subject, $server_id); $_server_info = $this->misc->getServerInfo(); - - $server_id = $request->getQueryParam('server'); + //$this->utils->prtrace($_server_info); diff --git a/src/traits/AdminTrait.php b/src/traits/AdminTrait.php index 9fb02cfb..034ee177 100644 --- a/src/traits/AdminTrait.php +++ b/src/traits/AdminTrait.php @@ -289,7 +289,7 @@ trait AdminTrait echo '" . \PHP_EOL; @@ -321,7 +321,7 @@ trait AdminTrait echo ' |
' . \PHP_EOL; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '{$this->lang['strnodata']}
" . \PHP_EOL; @@ -219,7 +219,7 @@ class MaterializedviewpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; break; @@ -331,7 +331,7 @@ class MaterializedviewpropertiesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; diff --git a/src/controllers/MaterializedviewsController.php b/src/controllers/MaterializedviewsController.php index 3d58327b..2d765e4e 100644 --- a/src/controllers/MaterializedviewsController.php +++ b/src/controllers/MaterializedviewsController.php @@ -64,7 +64,7 @@ class MaterializedviewsController extends BaseController break; case 'set_params_create': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefault(); } else { $this->doSetParamsCreate(); @@ -84,7 +84,7 @@ class MaterializedviewsController extends BaseController break; case 'drop': - if (isset($_POST['drop'])) { + if (null !== $this->getPostParam('drop')) { $this->doDrop(false); } else { $this->doDefault(); @@ -418,7 +418,7 @@ class MaterializedviewsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/OperatorsController.php b/src/controllers/OperatorsController.php index d1bf39ec..baa78c46 100644 --- a/src/controllers/OperatorsController.php +++ b/src/controllers/OperatorsController.php @@ -29,7 +29,7 @@ class OperatorsController extends BaseController switch ($this->action) { /*case 'save_create': - if (isset($_POST['cancel'])) { + if($this->getPostParam('cancel')!==null){ $this->doDefault(); } else { $this->doSaveCreate(); @@ -41,7 +41,7 @@ class OperatorsController extends BaseController break;*/ case 'drop': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefault(); } else { $this->doDrop(false); @@ -263,7 +263,7 @@ class OperatorsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropOperator($_POST['operator_oid'], isset($_POST['cascade'])); diff --git a/src/controllers/RolesController.php b/src/controllers/RolesController.php index 9dd3d1ce..2fea45c9 100644 --- a/src/controllers/RolesController.php +++ b/src/controllers/RolesController.php @@ -29,7 +29,7 @@ class RolesController extends BaseController break; case 'save_create': - if (isset($_POST['create'])) { + if (null !== $this->getPostParam('create')) { $this->doSaveCreate(); } else { $this->doDefault(); @@ -41,7 +41,7 @@ class RolesController extends BaseController break; case 'save_alter': - if (isset($_POST['alter'])) { + if (null !== $this->getPostParam('alter')) { $this->doSaveAlter(); } else { $this->doDefault(); @@ -53,7 +53,7 @@ class RolesController extends BaseController break; case 'drop': - if (isset($_POST['drop'])) { + if (null !== $this->getPostParam('drop')) { $this->doDrop(false); } else { $this->doDefault(); @@ -317,7 +317,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -483,7 +483,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -540,7 +540,7 @@ class RolesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropRole($_REQUEST['rolename']); diff --git a/src/controllers/RulesController.php b/src/controllers/RulesController.php index 33fed67a..41515c60 100644 --- a/src/controllers/RulesController.php +++ b/src/controllers/RulesController.php @@ -32,7 +32,7 @@ class RulesController extends BaseController break; case 'save_create_rule': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefault(); } else { $this->createRule(false); @@ -204,7 +204,7 @@ class RulesController extends BaseController '" value="', \htmlspecialchars($_REQUEST[$_REQUEST['subject']]), '" />' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if ('' === \trim($_POST['name'])) { diff --git a/src/controllers/SchemasController.php b/src/controllers/SchemasController.php index dbf2b93a..c45a065c 100644 --- a/src/controllers/SchemasController.php +++ b/src/controllers/SchemasController.php @@ -30,7 +30,7 @@ class SchemasController extends BaseController return $this->doSubTree(); } - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->action = ''; } @@ -40,7 +40,7 @@ class SchemasController extends BaseController switch ($this->action) { case 'create': - if (isset($_POST['create'])) { + if (null !== $this->getPostParam('create')) { $this->doSaveCreate(); } else { $this->doCreate(); @@ -48,7 +48,7 @@ class SchemasController extends BaseController break; case 'alter': - if (isset($_POST['alter'])) { + if (null !== $this->getPostParam('alter')) { $this->doSaveAlter(); } else { $this->doAlter(); @@ -56,7 +56,7 @@ class SchemasController extends BaseController break; case 'drop': - if (isset($_POST['drop'])) { + if (null !== $this->getPostParam('drop')) { $this->doDrop(false); } else { $this->doDrop(true); @@ -394,7 +394,7 @@ class SchemasController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -455,7 +455,7 @@ class SchemasController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if (\is_array($_POST['nsp'])) { diff --git a/src/controllers/SequencesController.php b/src/controllers/SequencesController.php index 617c956c..f4dd6ecb 100644 --- a/src/controllers/SequencesController.php +++ b/src/controllers/SequencesController.php @@ -35,7 +35,7 @@ class SequencesController extends BaseController break; case 'save_create_sequence': - if (isset($_POST['create'])) { + if (null !== $this->getPostParam('create')) { $this->doSaveCreateSequence(); } else { $this->doDefault(); @@ -47,7 +47,7 @@ class SequencesController extends BaseController break; case 'drop': - if (isset($_POST['drop'])) { + if (null !== $this->getPostParam('drop')) { $this->doDrop(false); } else { $this->doDefault(); @@ -83,7 +83,7 @@ class SequencesController extends BaseController break; case 'alter': - if (isset($_POST['alter'])) { + if (null !== $this->getPostParam('alter')) { $this->doSaveAlter(); } else { $this->doDefault(); @@ -426,7 +426,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if (\is_array($_POST['sequence'])) { @@ -528,7 +528,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } @@ -653,7 +653,7 @@ class SequencesController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strsetval']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -829,7 +829,7 @@ class SequencesController extends BaseController echo $this->view->form; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; diff --git a/src/controllers/ServersController.php b/src/controllers/ServersController.php index ade0da25..a2f32301 100644 --- a/src/controllers/ServersController.php +++ b/src/controllers/ServersController.php @@ -64,13 +64,13 @@ class ServersController extends BaseController $server_html .= $this->printFooter(false); - if (null === $this->container->requestobj->getAttribute('route')) { + if (null === \requestInstance()->getAttribute('route')) { echo $server_html; } else { - $body = $this->container->responseobj->getBody(); + $body = \responseInstance()->getBody(); $body->write($server_html); - return $this->container->responseobj; + return \responseInstance(); } } diff --git a/src/controllers/TablesController.php b/src/controllers/TablesController.php index a4e766cb..7888b709 100644 --- a/src/controllers/TablesController.php +++ b/src/controllers/TablesController.php @@ -43,7 +43,7 @@ class TablesController extends BaseController switch ($this->action) { case 'create': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefault(); } else { $header_template = 'header_select2.twig'; @@ -57,7 +57,7 @@ class TablesController extends BaseController break; case 'confcreatelike': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $header_template = 'header_datatables.twig'; $this->doDefault(); } else { @@ -106,7 +106,7 @@ class TablesController extends BaseController break; case 'drop': - if (isset($_POST['drop'])) { + if (null !== $this->getPostParam('drop')) { $this->doDrop(false); } else { $header_template = 'header_datatables.twig'; @@ -160,37 +160,27 @@ class TablesController extends BaseController //\Kint::dump($tables); echo $this->printTable($tables, $columns, $actions, $this->table_place, $this->lang['strnotables']); - + $attr = [ + 'href' => [ + 'url' => 'tables', + 'urlvars' => [ + 'action' => 'createlike', + 'server' => $this->getRequestParam('server'), + 'database' => $this->getRequestParam('database'), + 'schema' => $this->getRequestParam('schema'), + ], + ], + ]; $navlinks = [ 'create' => [ - 'attr' => [ - 'href' => [ - 'url' => 'tables', - 'urlvars' => [ - 'action' => 'create', - 'server' => $_REQUEST['server'], - 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], - ], - ], - ], + 'attr' => $attr, 'content' => $this->lang['strcreatetable'], ], ]; if ((0 < $tables->recordCount()) && $data->hasCreateTableLike()) { $navlinks['createlike'] = [ - 'attr' => [ - 'href' => [ - 'url' => 'tables', - 'urlvars' => [ - 'action' => 'createlike', - 'server' => $_REQUEST['server'], - 'database' => $_REQUEST['database'], - 'schema' => $_REQUEST['schema'], - ], - ], - ], + 'attr' => $attr, 'content' => $this->lang['strcreatetablelike'], ]; } @@ -311,10 +301,12 @@ class TablesController extends BaseController echo '{$this->lang['strname']} | " . \PHP_EOL; echo "\t\t_maxNameLen}\" value=\"", - \htmlspecialchars($_REQUEST['name']), "\" /> | \n\t
---|---|
{$this->lang['strnumcols']} | " . \PHP_EOL; echo "\t\t_maxNameLen}\" value=\"", - \htmlspecialchars($_REQUEST['fields']), "\" /> | \n\t
{$this->lang['stroptions']} | " . \PHP_EOL; echo "\t\t\n\t | \n\t\t\t\n\t\t | \n\t" . \PHP_EOL; @@ -337,14 +331,15 @@ class TablesController extends BaseController echo "\t
{$this->lang['strcomment']} | " . \PHP_EOL; echo "\t\t\n\t |
' . \PHP_EOL; echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strnext']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; break; @@ -402,14 +397,17 @@ class TablesController extends BaseController echo "\tlang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { if ('' === \trim($_REQUEST['name'])) { @@ -726,7 +729,8 @@ class TablesController extends BaseController echo "' . \PHP_EOL; - echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); + echo \sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strselect']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; return; @@ -865,7 +871,8 @@ class TablesController extends BaseController ) ); echo "fields['attnum']}]\" value=\"", - \htmlspecialchars($attrs->fields['type']), '" />' . \PHP_EOL; - echo sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); + echo \sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('
%s', $this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -505,7 +504,7 @@ class TblpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo $this->view->form; - echo sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); + echo \sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo "lang['strimport']}\" />
" . \PHP_EOL; echo '' . \PHP_EOL; } @@ -616,13 +615,13 @@ class TblpropertiesController extends BaseController echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo $this->view->form; - echo sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); + echo \sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); if (!$data->hasCreateFieldWithConstraints()) { echo '' . \PHP_EOL; } echo "lang['stradd']}\" />" . \PHP_EOL; - echo sprintf('
%s', $this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; echo '" . \PHP_EOL; @@ -683,7 +682,7 @@ class TblpropertiesController extends BaseController echo '" . \PHP_EOL; diff --git a/src/controllers/TriggersController.php b/src/controllers/TriggersController.php index d7c3d34f..83faeb49 100644 --- a/src/controllers/TriggersController.php +++ b/src/controllers/TriggersController.php @@ -29,7 +29,7 @@ class TriggersController extends BaseController switch ($this->action) { case 'alter': - if (isset($_POST['alter'])) { + if (null !== $this->getPostParam('alter')) { $this->doSaveAlter(); } else { $this->doDefault(); @@ -49,7 +49,7 @@ class TriggersController extends BaseController break; case 'save_create': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefault(); } else { $this->doSaveCreate(); @@ -281,11 +281,11 @@ class TriggersController extends BaseController \htmlspecialchars($_POST['name']), '" />' . \PHP_EOL; echo '' . \PHP_EOL; echo '
' . \PHP_EOL; - echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); + echo \sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strok']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '{$this->lang['strnodata']}
" . \PHP_EOL; @@ -313,7 +313,7 @@ class TriggersController extends BaseController echo '" . \PHP_EOL; @@ -352,7 +352,7 @@ class TriggersController extends BaseController echo '
lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; - echo sprintf('%s',\htmlspecialchars($_REQUEST['table']), \PHP_EOL); + echo \sprintf('%s', \htmlspecialchars($_REQUEST['table']), \PHP_EOL); echo $this->view->form; echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/UsersController.php b/src/controllers/UsersController.php index bffe2104..54034dfe 100644 --- a/src/controllers/UsersController.php +++ b/src/controllers/UsersController.php @@ -351,7 +351,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; @@ -405,7 +405,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strdrop']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { $status = $data->dropUser($_REQUEST['username']); @@ -459,7 +459,7 @@ class UsersController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/controllers/ViewpropertiesController.php b/src/controllers/ViewpropertiesController.php index 237b0664..523d5c47 100644 --- a/src/controllers/ViewpropertiesController.php +++ b/src/controllers/ViewpropertiesController.php @@ -35,7 +35,7 @@ class ViewpropertiesController extends BaseController switch ($this->action) { case 'save_edit': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefinition(); } else { $this->doSaveEdit(); @@ -57,7 +57,7 @@ class ViewpropertiesController extends BaseController break; case 'properties': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefault(); } else { $this->doProperties(); @@ -65,7 +65,7 @@ class ViewpropertiesController extends BaseController break; case 'alter': - if (isset($_POST['alter'])) { + if (null !== $this->getPostParam('alter')) { $this->doAlter(false); } else { $this->doDefault(); @@ -77,7 +77,7 @@ class ViewpropertiesController extends BaseController break; /*case 'drop': - if (isset($_POST['drop'])) { + if($this->getPostParam('drop')!==null){ $this->doDrop(false); } else { $this->doDefault(); @@ -233,7 +233,7 @@ EOT; echo '' . \PHP_EOL; echo '' . \PHP_EOL; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; break; @@ -345,7 +345,7 @@ EOT; echo '' . \PHP_EOL; echo $this->view->form; echo "lang['stralter']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } else { echo "{$this->lang['strnodata']}
" . \PHP_EOL; diff --git a/src/controllers/ViewsController.php b/src/controllers/ViewsController.php index c8212af6..84feea4d 100644 --- a/src/controllers/ViewsController.php +++ b/src/controllers/ViewsController.php @@ -64,7 +64,7 @@ class ViewsController extends BaseController break; case 'set_params_create': - if (isset($_POST['cancel'])) { + if (null !== $this->getPostParam('cancel')) { $this->doDefault(); } else { $this->doSetParamsCreate(); @@ -84,7 +84,7 @@ class ViewsController extends BaseController break; case 'drop': - if (isset($_POST['drop'])) { + if (null !== $this->getPostParam('drop')) { $this->doDrop(false); } else { $this->doDefault(); @@ -418,7 +418,7 @@ class ViewsController extends BaseController echo '' . \PHP_EOL; echo $this->view->form; echo "lang['strcreate']}\" />" . \PHP_EOL; - echo sprintf('
%s',$this->lang['strcancel'], \PHP_EOL); + echo \sprintf('%s', $this->lang['strcancel'], \PHP_EOL); echo '' . \PHP_EOL; } diff --git a/src/database/ADOdbBase.php b/src/database/ADOdbBase.php index 1b23f47e..abd225b6 100644 --- a/src/database/ADOdbBase.php +++ b/src/database/ADOdbBase.php @@ -6,8 +6,6 @@ namespace PHPPgAdmin\Database; -use PHPPgAdmin\ADONewConnection; - /** * @file * Parent class of all ADODB objects. @@ -18,24 +16,45 @@ class ADOdbBase { use \PHPPgAdmin\Traits\HelperTrait; use \PHPPgAdmin\Database\Traits\HasTrait; -/** @var array */ + + /** + * @var array + */ public $lang; -/** @var array */ + + /** + * @var array + */ public $conf; -/** @var \Slim\Container */ + + /** + * @var \ADODB_postgres9 + */ + public $conn; + + /** + * @var \Slim\Container + */ protected $container; -/** @var array */ + + /** + * @var array + */ protected $server_info; - /** @var string */ + + /** + * @var string + */ protected $lastExecutedSql; + /** * Base constructor. * - * @param \ADODB_postgres9|\ADODB_pdo $conn The connection object + * @param \ADODB_postgres9 $conn The connection object * @param mixed $container * @param mixed $server_info */ - public function __construct( &$conn, $container, $server_info) + public function __construct(&$conn, $container, $server_info) { $this->container = $container; $this->server_info = $server_info; @@ -44,9 +63,9 @@ class ADOdbBase $this->conf = $container->get('conf'); $this->prtrace('instanced connection class'); - $this->lastExecutedSql=''; + $this->lastExecutedSql = ''; $this->conn = $conn; - } + } /** * Sets the comment for an object in the database. @@ -120,14 +139,19 @@ class ADOdbBase } else { $sql .= 'NULL;'; } -$this->lastExecutedSql=$sql; + $this->lastExecutedSql = $sql; + return $this->execute($sql); } -public function getLastExecutedSQL():string { - $lastExecutedSql=$this->lastExecutedSql; - $this->lastExecutedSql=''; - return $lastExecutedSql; -} + + public function getLastExecutedSQL(): string + { + $lastExecutedSql = $this->lastExecutedSql; + $this->lastExecutedSql = ''; + + return $lastExecutedSql; + } + /** * Turns on or off query debugging. * @@ -190,7 +214,7 @@ public function getLastExecutedSQL():string { try { $rs = $this->conn->Execute($sql); - return $this->conn->ErrorNo(); + return $this->ErrorNo(); } catch (\Exception $e) { return $e->getCode(); } @@ -222,6 +246,16 @@ public function getLastExecutedSQL():string { } } + public function ErrorNo(): int + { + return $this->conn->ErrorNo(); + } + + public function ErrorMsg(): string + { + return $this->conn->ErrorMsg(); + } + /** * Retrieves a single value from a query. * @@ -239,7 +273,7 @@ public function getLastExecutedSQL():string { // If failure, or no rows returned, return error value if (!$rs) { - return $this->conn->ErrorNo(); + return $this->ErrorNo(); } if (0 === $rs->recordCount()) { @@ -286,7 +320,7 @@ public function getLastExecutedSQL():string { // Check for failures if (!$this->conn->Execute($sql)) { // Check for referential integrity failure - if (\mb_stristr($this->conn->ErrorMsg(), 'referential')) { + if (\mb_stristr($this->ErrorMsg(), 'referential')) { return -1; } } @@ -296,7 +330,7 @@ public function getLastExecutedSQL():string { return -2; } - return $this->conn->ErrorNo(); + return $this->ErrorNo(); } /** @@ -385,16 +419,16 @@ public function getLastExecutedSQL():string { // Check for failures if (!$this->conn->Execute($sql)) { // Check for unique constraint failure - if (\mb_stristr($this->conn->ErrorMsg(), 'unique')) { + if (\mb_stristr($this->ErrorMsg(), 'unique')) { return -1; } - if (\mb_stristr($this->conn->ErrorMsg(), 'referential')) { + if (\mb_stristr($this->ErrorMsg(), 'referential')) { return -2; } // Check for referential integrity failure } - return $this->conn->ErrorNo(); + return $this->ErrorNo(); } /** @@ -456,11 +490,11 @@ public function getLastExecutedSQL():string { // Check for failures if (!$this->conn->Execute($setClause . $whereClause)) { // Check for unique constraint failure - if (\mb_stristr($this->conn->ErrorMsg(), 'unique')) { + if (\mb_stristr($this->ErrorMsg(), 'unique')) { return -1; } - if (\mb_stristr($this->conn->ErrorMsg(), 'referential')) { + if (\mb_stristr($this->ErrorMsg(), 'referential')) { return -2; } // Check for referential integrity failure } @@ -470,7 +504,7 @@ public function getLastExecutedSQL():string { return -3; } - return $this->conn->ErrorNo(); + return $this->ErrorNo(); } /** @@ -480,7 +514,7 @@ public function getLastExecutedSQL():string { */ public function beginTransaction() { - return intval(!$this->conn->BeginTrans()); + return (int) (!$this->conn->BeginTrans()); } /** @@ -490,7 +524,7 @@ public function getLastExecutedSQL():string { */ public function endTransaction() { - return intval(!$this->conn->CommitTrans()); + return (int) (!$this->conn->CommitTrans()); } /** @@ -500,7 +534,7 @@ public function getLastExecutedSQL():string { */ public function rollbackTransaction() { - return intval( !$this->conn->RollbackTrans()); + return (int) (!$this->conn->RollbackTrans()); } /** diff --git a/src/database/Connection.php b/src/database/Connection.php new file mode 100644 index 00000000..db541416 --- /dev/null +++ b/src/database/Connection.php @@ -0,0 +1,177 @@ + 'Postgres13', + '12' => 'Postgres12', + '11' => 'Postgres11', + '10' => 'Postgres10', + '9.7' => 'Postgres96', + '9.6' => 'Postgres96', + '9.5' => 'Postgres95', + '9.4' => 'Postgres94', + '9.3' => 'Postgres93', + '9.2' => 'Postgres92', + '9.1' => 'Postgres91', + '9.0' => 'Postgres90', + ]; + + // The backend platform. Set to UNKNOWN by default. + private $_connection_result; + + /** + * Creates a new connection. Will actually make a database connection. + * + * @param array $server_info + * @param string $database database name + * @param \Slim\Container $container + * @param int $fetchMode Defaults to associative. Override for different behaviour + */ + public function __construct($server_info, $database, $container, $fetchMode = \ADODB_FETCH_ASSOC) + { + $host = $server_info['host']; + $port = $server_info['port']; + $sslmode = $server_info['sslmode']; + $user = $server_info['username']; + $password = $server_info['password']; + + $this->server_info = $server_info; + + $this->container = $container; + + $this->conn = \ADONewConnection('postgres9'); + //$this->conn->debug = true; + $this->conn->setFetchMode($fetchMode); + + // Ignore host if null + if (null === $host || '' === $host) { + if (null !== $port && '' !== $port) { + $pghost = ':' . $port; + } else { + $pghost = ''; + } + } else { + $pghost = "{$host}:{$port}"; + } + + // Add sslmode to $pghost as needed + if (('disable' === $sslmode) || ('allow' === $sslmode) || ('prefer' === $sslmode) || ('require' === $sslmode)) { + $pghost .= ':' . $sslmode; + } elseif ('legacy' === $sslmode) { + $pghost .= ' requiressl=1'; + } + + try { + $this->conn->connect($pghost, $user, $password, $database); + //$this->prtrace($this->conn); + } catch (\Exception $e) { + dump($e); + $this->prtrace($e->getMessage(), $e->getTrace()); + } + } + + public function getConnectionResult() + { + return $this->_connection_result; + } + + /** + * Gets the name of the correct database driver to use. As a side effect, + * sets the platform. + * + * @param string $description A description of the database and version (returns by reference) + * + * @return string The driver. e.g. Postgres96 + */ + public function getDriver(&$description) + { + $version = null; + + if ($this->conn->_connectionID) { + $v = \pg_version($this->conn->_connectionID); + + //\PhpConsole\Handler::getInstance()->debug($v, 'pg_version'); + + if (isset($v['server'])) { + $version = $v['server']; + } + } + // If we didn't manage to get the version without a query, query... + if (!isset($version)) { + $adodb = new ADOdbBase($this->conn, $this->container, $this->server_info); + + $sql = 'SELECT VERSION() AS version'; + $field = $adodb->selectField($sql, 'version'); + + // Check the platform, if it's mingw, set it + if (\preg_match('/ mingw /i', $field)) { + $this->platform = 'MINGW'; + } + + $params = \explode(' ', $field); + + if (!isset($params[1])) { + return null; + } + + $version = $params[1]; // eg. 8.4.4 + } + + $description = "PostgreSQL {$version}"; + + $version_parts = \explode('.', $version); + + if ((int) (10 <= $version_parts[0])) { + $major_version = $version_parts[0]; + } else { + $major_version = \implode('.', [$version_parts[0], $version_parts[1]]); + } + + //$this->prtrace(['pg_version' => pg_version($this->conn->_connectionID), 'version' => $version, 'major_version' => $major_version]); + // Detect version and choose appropriate database driver + if (\array_key_exists($major_version, $this->version_dictionary)) { + return $this->version_dictionary[$major_version]; + } + + // if major version is less than 9 return null, we don't support it + if (9 > (int) \mb_substr($version, 0, 1)) { + return null; + } + + // If unknown version, then default to latest driver + return 'Postgres'; + } + + /** + * Get the last error in the connection. + * + * @return string Error string + */ + public function getLastError() + { + return \pg_last_error($this->conn->_connectionID); + } +} diff --git a/src/database/Postgres.php b/src/database/Postgres.php index d2c31f8a..3d2d8449 100644 --- a/src/database/Postgres.php +++ b/src/database/Postgres.php @@ -36,6 +36,21 @@ class Postgres extends ADOdbBase public $conf; + /** + * @var float + */ + public $major_version = 9.6; + + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc::class; + + /** + * @var \PHPPgAdmin\Help\PostgresDoc + */ + public $help_class; + protected $container; protected $server_info; @@ -49,6 +64,8 @@ class Postgres extends ADOdbBase $this->lang = $container->get('lang'); $this->conf = $container->get('conf'); $this->server_info = $server_info; + $this->help_class = new $this->help_classname($this->conf, $this->major_version); + $this->lastExecutedSql = ''; } /** @@ -60,23 +77,24 @@ class Postgres extends ADOdbBase */ public function getHelp($help) { - $this->getHelpPages(); + $this->help_page = $this->help_class->getHelpTopics(); + $this->help_base = $this->help_class->getHelpBase(); - if (isset($this->help_page[$help])) { - if (\is_array($this->help_page[$help])) { - $urls = []; + if (!$topicResult = $this->help_class->getHelpTopic($help)) { + return null; + } - foreach ($this->help_page[$help] as $link) { - $urls[] = $this->help_base . $link; - } + if (\is_array($topicResult)) { + $urls = []; - return $urls; + foreach ($topicResult as $link) { + $urls[] = $this->help_base . $link; } - return $this->help_base . $this->help_page[$help]; + return $urls; } - return null; + return $this->help_base . $topicResult; } /** @@ -84,15 +102,9 @@ class Postgres extends ADOdbBase * get help page by instancing the corresponding help class * if $this->help_page and $this->help_base are set, this function is a noop. */ - public function getHelpPages(): void + public function getHelpPages(): array { - if (null === $this->help_page || null === $this->help_base) { - $help_classname = '\PHPPgAdmin\Help\PostgresDoc' . \str_replace('.', '', $this->major_version); - - $help_class = new $help_classname($this->conf, $this->major_version); - $this->help_page = $help_class->getHelpPage(); - $this->help_base = $help_class->getHelpBase(); - } + return $this->help_class->getHelpTopics(); } // Formatting functions @@ -144,7 +156,7 @@ class Postgres extends ADOdbBase if (null !== $value) { $value = $this->escapeBytea($value); } - // no break + // no break case 'text': case 'text[]': case 'json': @@ -493,7 +505,8 @@ class Postgres extends ADOdbBase * end of quote if matching non-backslashed character. * backslashes don't count for double quotes, though. */ - if (\mb_substr($line, $i, 1) === $in_quote && + if ( + \mb_substr($line, $i, 1) === $in_quote && (0 === $bslash_count % 2 || '"' === $in_quote) ) { $in_quote = 0; diff --git a/src/database/Postgres10.php b/src/database/Postgres10.php index c14ba493..a076d824 100644 --- a/src/database/Postgres10.php +++ b/src/database/Postgres10.php @@ -20,8 +20,16 @@ namespace PHPPgAdmin\Database; */ class Postgres10 extends Postgres96 { + /** + * @var float + */ public $major_version = 10; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc10::class; + /** * Return all tables in current database (and schema). * diff --git a/src/database/Postgres11.php b/src/database/Postgres11.php index 850ae822..9dfce029 100644 --- a/src/database/Postgres11.php +++ b/src/database/Postgres11.php @@ -15,8 +15,16 @@ namespace PHPPgAdmin\Database; */ class Postgres11 extends Postgres10 { + /** + * @var float + */ public $major_version = 11; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc11::class; + /** * Returns a list of all functions in the database. * In PG 11 proagg was replaced with prokind. diff --git a/src/database/Postgres12.php b/src/database/Postgres12.php index d2b63461..aa8495e1 100644 --- a/src/database/Postgres12.php +++ b/src/database/Postgres12.php @@ -15,8 +15,16 @@ namespace PHPPgAdmin\Database; */ class Postgres12 extends Postgres11 { + /** + * @var float + */ public $major_version = 12; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc12::class; + /** * Checks to see whether or not a table has a unique id column. * diff --git a/src/database/Postgres13.php b/src/database/Postgres13.php index d3528398..853d5b8c 100644 --- a/src/database/Postgres13.php +++ b/src/database/Postgres13.php @@ -16,5 +16,13 @@ namespace PHPPgAdmin\Database; */ class Postgres13 extends Postgres12 { + /** + * @var float + */ public $major_version = 13; + + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc12::class; } diff --git a/src/database/Postgres90.php b/src/database/Postgres90.php index 6315aa6e..2b06faf0 100644 --- a/src/database/Postgres90.php +++ b/src/database/Postgres90.php @@ -14,5 +14,13 @@ namespace PHPPgAdmin\Database; */ class Postgres90 extends Postgres91 { + /** + * @var float + */ public $major_version = 9.0; + + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc90::class; } diff --git a/src/database/Postgres91.php b/src/database/Postgres91.php index e981f240..43fec0ca 100644 --- a/src/database/Postgres91.php +++ b/src/database/Postgres91.php @@ -16,8 +16,16 @@ namespace PHPPgAdmin\Database; */ class Postgres91 extends Postgres92 { + /** + * @var float + */ public $major_version = 9.1; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc91::class; + // Administration functions /** diff --git a/src/database/Postgres92.php b/src/database/Postgres92.php index cb2ff754..4e78d22c 100644 --- a/src/database/Postgres92.php +++ b/src/database/Postgres92.php @@ -14,8 +14,16 @@ class Postgres92 extends Postgres93 { public $typIndexes = ['BTREE', 'RTREE', 'GIST', 'GIN', 'HASH']; + /** + * @var float + */ public $major_version = 9.2; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc92::class; + /** * Returns all available process information. * diff --git a/src/database/Postgres93.php b/src/database/Postgres93.php index b2a0747f..f39a3842 100644 --- a/src/database/Postgres93.php +++ b/src/database/Postgres93.php @@ -12,8 +12,16 @@ namespace PHPPgAdmin\Database; */ class Postgres93 extends Postgres94 { + /** + * @var float + */ public $major_version = 9.3; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc93::class; + /** * Returns a list of all functions in the database. * diff --git a/src/database/Postgres94.php b/src/database/Postgres94.php index 7fe10201..0f23d0a0 100644 --- a/src/database/Postgres94.php +++ b/src/database/Postgres94.php @@ -14,5 +14,13 @@ class Postgres94 extends Postgres95 { public $typIndexes = ['BTREE', 'RTREE', 'GIST', 'GIN', 'HASH', 'SP-GIST']; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc94::class; + + /** + * @var float + */ public $major_version = 9.4; } diff --git a/src/database/Postgres95.php b/src/database/Postgres95.php index d6f1f93b..023b24d8 100644 --- a/src/database/Postgres95.php +++ b/src/database/Postgres95.php @@ -14,5 +14,13 @@ class Postgres95 extends Postgres96 { public $typIndexes = ['BTREE', 'BRIN', 'RTREE', 'GIST', 'GIN', 'HASH']; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc95::class; + + /** + * @var float + */ public $major_version = 9.5; } diff --git a/src/database/Postgres96.php b/src/database/Postgres96.php index ef2ad7e5..2f74c9cf 100644 --- a/src/database/Postgres96.php +++ b/src/database/Postgres96.php @@ -14,8 +14,16 @@ class Postgres96 extends Postgres { public $typIndexes = ['BTREE', 'BRIN', 'RTREE', 'GIST', 'GIN', 'HASH', 'SP-GIST']; + /** + * @var float + */ public $major_version = 9.6; + /** + * @var class-string + */ + public $help_classname = \PHPPgAdmin\Help\PostgresDoc96::class; + // Administration functions /** diff --git a/src/database/databasetraits/HasTrait.php b/src/database/databasetraits/HasTrait.php index aabaa1e9..895449e5 100644 --- a/src/database/databasetraits/HasTrait.php +++ b/src/database/databasetraits/HasTrait.php @@ -16,6 +16,11 @@ trait HasTrait // The backend platform. Set to UNKNOWN by default. public $platform = 'UNKNOWN'; + /** @var string */ + + /** + * @var float + */ public $major_version = 9.6; // Max object name length diff --git a/src/database/databasetraits/TableTrait.php b/src/database/databasetraits/TableTrait.php index 6a27be9c..6df728fe 100644 --- a/src/database/databasetraits/TableTrait.php +++ b/src/database/databasetraits/TableTrait.php @@ -187,8 +187,6 @@ trait TableTrait $sql .= ')'; - - // Handle WITHOUT OIDS if ($this->hasObjectID($table)) { $sql .= ' WITH OIDS'; @@ -793,7 +791,8 @@ trait TableTrait * @param string $schema The new schema for the table * @param string $comment The comment on the table * @param string $tablespace The new tablespace for the table ('' means leave as is) - * @param bool $with_oids If set to FALSE, will drop oids column + * @param bool $with_oids If set to FALSE, will drop oids column + * * @return bool|int 0 success */ public function alterTable($table, $name, $owner, $schema, $comment, $tablespace, bool $with_oids = true) @@ -805,16 +804,16 @@ trait TableTrait } $status = $this->beginTransaction(); - dump(['beginTransaction' => $status]); + //dump(['beginTransaction' => $status]); if (0 !== $status) { $this->rollbackTransaction(); return -1; } - $sql_sentence="ALTER TABLE \"{$this->_schema}\".\"{$tblrs->fields['relname']}\" "; - $status = $this->_alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace, !$with_oids,$sql_sentence); - dump(['_alterTable' => [$status, $sql_sentence.$this->getLastExecutedSQL()]]); + $sql_sentence = "ALTER TABLE \"{$this->_schema}\".\"{$tblrs->fields['relname']}\" "; + $status = $this->_alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace, !$with_oids, $sql_sentence); + //dump(['_alterTable' => [$status, $sql_sentence.$this->getLastExecutedSQL()]]); if (0 !== $status) { $this->rollbackTransaction(); @@ -824,88 +823,14 @@ trait TableTrait return $this->endTransaction(); } - /** - * Protected method which alter a table - * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. - * - * @param \PHPPgAdmin\ADORecordSet $tblrs The table recordSet returned by getTable() - * @param string $name The new name for the table - * @param string $owner The new owner for the table - * @param string $schema The new schema for the table - * @param string $comment The comment on the table - * @param string $tablespace The new tablespace for the table ('' means leave as is) - * @param bool $withoutoids If set to TRUE, will drop oids column - * @return int 0 success - */ - protected function _alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace, bool $withoutoids = false ) - { - $this->fieldArrayClean($tblrs->fields); - - // Comment - $status = $this->setComment('TABLE', '', $tblrs->fields['relname'], $comment); - dump(['setComment' => $this->getLastExecutedSQL()]); - - $this->lastExecutedSql=$this->getLastExecutedSQL(); - if (0 !== $status) { - return -4; - } - - // Owner - $this->fieldClean($owner); - [$TableOwnerStatus,$TableOwnerSQL] = $this->alterTableOwner($tblrs, $owner); - $this->lastExecutedSql.=$TableOwnerSQL?sprintf('%s%s',\PHP_EOL,$TableOwnerSQL):''; - //dump(['alterTableOwner' => [$TableOwnerStatus,$TableOwnerSQL]]); - - if (0 !== $TableOwnerStatus) { - return -5; - } - - // Tablespace - $this->fieldClean($tablespace); - [$TableTablespaceStatus,$TableTablespaceSQL] = $this->alterTableTablespace($tblrs, $tablespace); - $this->lastExecutedSql.=$TableTablespaceSQL?sprintf('%s%s',\PHP_EOL,$TableTablespaceSQL):''; - //dump(['alterTableTablespace' => [$TableTablespaceStatus,$TableTablespaceSQL]]); - - if (0 !== $TableTablespaceStatus) { - return -6; - } - - // Rename - $this->fieldClean($name); - [$TableNameStatus,$TableNameSQL] = $this->alterTableName($tblrs, $name); - $this->lastExecutedSql.=$TableNameSQL?sprintf('%s%s',\PHP_EOL,$TableNameSQL):''; - //dump(['alterTableName' => [$TableNameStatus,$TableNameSQL]]); - - if (0 !== $TableNameStatus) { - return -3; - } - - // Schema - $this->fieldClean($schema); - [$TableSchemaStatus,$TableSchemaSQL] = $this->alterTableSchema($tblrs, $schema); - $this->lastExecutedSql.=$TableSchemaSQL?sprintf('%s%s',\PHP_EOL,$TableSchemaSQL):''; - //dump(['alterTableSchema' => [$TableSchemaStatus,$TableSchemaSQL]]); - - if (0 !== $TableSchemaStatus) { - return -7; - } - [$TableOidsStatus,$TableOidsSQL] = $this->alterTableOids($tblrs, $withoutoids); - $this->lastExecutedSql.=$TableOidsSQL?sprintf('%s%s',\PHP_EOL,$TableOidsSQL):''; - //dump(['alterTableOids' => [$TableOidsStatus,$TableOidsSQL]]); - if (0 !== $TableOidsStatus) { - return -7; - } - - - return 0; - } /** * Enables or disables the oid system column to a table a table's owner * /!\ this function is called from _alterTable which take care of escaping fields. * - * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() + * @param \PHPPgAdmin\ADORecordSet $tblrs The table RecordSet returned by getTable() * @param null|string $owner + * @param bool $withoutoids * * @return array{0:int,1:string} [status:0 if successful, change_sql: changed attribute] */ @@ -914,27 +839,27 @@ trait TableTrait $status = 0; $change_sql = ''; // no changes. Return 0 - if (boolval($this->hasObjectID($tblrs->fields['relname'])) !== !$withoutoids) { - - + if ((bool) ($this->hasObjectID($tblrs->fields['relname'])) !== !$withoutoids) { /* vars cleaned in _alterTable */ $f_schema = $this->_schema; $this->fieldClean($f_schema); $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; - $change_sql = " SET "; + $change_sql = ' SET '; + if ($withoutoids) { $change_sql .= ' WITHOUT OIDS'; } else { $change_sql .= ' WITH OIDS'; } - $sql = implode(' ', [$alter_sql, $change_sql]); + $sql = \implode(' ', [$alter_sql, $change_sql]); $status = $this->execute($sql); } return [$status, $change_sql]; } + /** * Alter a table's owner * /!\ this function is called from _alterTable which take care of escaping fields. @@ -957,7 +882,7 @@ trait TableTrait // superuser only function. $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; $change_sql = " OWNER TO \"{$owner}\""; - $sql = implode(' ', [$alter_sql, $change_sql]); + $sql = \implode(' ', [$alter_sql, $change_sql]); $status = $this->execute($sql); } @@ -965,7 +890,6 @@ trait TableTrait return [$status, $change_sql]; } - /** * Alter a table's tablespace * /!\ this function is called from _alterTable which take care of escaping fields. @@ -988,7 +912,7 @@ trait TableTrait // don't want to do this unnecessarily. $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; $change_sql = " SET TABLESPACE \"{$tablespace}\""; - $sql = implode(' ', [$alter_sql, $change_sql]); + $sql = \implode(' ', [$alter_sql, $change_sql]); $status = $this->execute($sql); } @@ -1017,7 +941,7 @@ trait TableTrait $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; $change_sql = " RENAME TO \"{$name}\""; - $sql = implode(' ', [$alter_sql, $change_sql]); + $sql = \implode(' ', [$alter_sql, $change_sql]); $status = $this->execute($sql); if (0 === $status) { @@ -1051,7 +975,7 @@ trait TableTrait // don't want to do this unnecessarily. $alter_sql = "ALTER TABLE \"{$f_schema}\".\"{$tblrs->fields['relname']}\" "; $change_sql = " SET SCHEMA \"{$schema}\""; - $sql = implode(' ', [$alter_sql, $change_sql]); + $sql = \implode(' ', [$alter_sql, $change_sql]); $status = $this->execute($sql); } @@ -1396,6 +1320,82 @@ trait TableTrait abstract public function getAttributeNames($table, $atts); + /** + * Protected method which alter a table + * SHOULDN'T BE CALLED OUTSIDE OF A TRANSACTION. + * + * @param \PHPPgAdmin\ADORecordSet $tblrs The table recordSet returned by getTable() + * @param string $name The new name for the table + * @param string $owner The new owner for the table + * @param string $schema The new schema for the table + * @param string $comment The comment on the table + * @param string $tablespace The new tablespace for the table ('' means leave as is) + * @param bool $withoutoids If set to TRUE, will drop oids column + * + * @return int 0 success + */ + protected function _alterTable($tblrs, $name, $owner, $schema, $comment, $tablespace, bool $withoutoids = false) + { + $this->fieldArrayClean($tblrs->fields); + + // Comment + $status = $this->setComment('TABLE', '', $tblrs->fields['relname'], $comment); + //dump(['setComment' => $this->getLastExecutedSQL()]); + + $this->lastExecutedSql = $this->getLastExecutedSQL(); + + if (0 !== $status) { + return -4; + } + + // Owner + $this->fieldClean($owner); + [$TableOwnerStatus,$TableOwnerSQL] = $this->alterTableOwner($tblrs, $owner); + $this->lastExecutedSql .= $TableOwnerSQL ? \sprintf('%s%s', \PHP_EOL, $TableOwnerSQL) : ''; + //dump(['alterTableOwner' => [$TableOwnerStatus,$TableOwnerSQL]]); + + if (0 !== $TableOwnerStatus) { + return -5; + } + + // Tablespace + $this->fieldClean($tablespace); + [$TableTablespaceStatus,$TableTablespaceSQL] = $this->alterTableTablespace($tblrs, $tablespace); + $this->lastExecutedSql .= $TableTablespaceSQL ? \sprintf('%s%s', \PHP_EOL, $TableTablespaceSQL) : ''; + //dump(['alterTableTablespace' => [$TableTablespaceStatus,$TableTablespaceSQL]]); + + if (0 !== $TableTablespaceStatus) { + return -6; + } + + // Rename + $this->fieldClean($name); + [$TableNameStatus,$TableNameSQL] = $this->alterTableName($tblrs, $name); + $this->lastExecutedSql .= $TableNameSQL ? \sprintf('%s%s', \PHP_EOL, $TableNameSQL) : ''; + //dump(['alterTableName' => [$TableNameStatus,$TableNameSQL]]); + + if (0 !== $TableNameStatus) { + return -3; + } + + // Schema + $this->fieldClean($schema); + [$TableSchemaStatus,$TableSchemaSQL] = $this->alterTableSchema($tblrs, $schema); + $this->lastExecutedSql .= $TableSchemaSQL ? \sprintf('%s%s', \PHP_EOL, $TableSchemaSQL) : ''; + //dump(['alterTableSchema' => [$TableSchemaStatus,$TableSchemaSQL]]); + + if (0 !== $TableSchemaStatus) { + return -7; + } + [$TableOidsStatus,$TableOidsSQL] = $this->alterTableOids($tblrs, $withoutoids); + $this->lastExecutedSql .= $TableOidsSQL ? \sprintf('%s%s', \PHP_EOL, $TableOidsSQL) : ''; + //dump(['alterTableOids' => [$TableOidsStatus,$TableOidsSQL]]); + if (0 !== $TableOidsStatus) { + return -7; + } + + return 0; + } /** * Dumps serial-like columns in the table. diff --git a/src/decorators/CallbackDecorator.php b/src/decorators/CallbackDecorator.php index 57b4b3e4..970370c6 100644 --- a/src/decorators/CallbackDecorator.php +++ b/src/decorators/CallbackDecorator.php @@ -8,7 +8,7 @@ namespace PHPPgAdmin\Decorators; class CallbackDecorator extends Decorator { - public function __construct($callback, $param = null) + public function __construct(\Closure $callback, $param = null) { $this->fn = $callback; $this->p = $param; diff --git a/src/decorators/Decorator.php b/src/decorators/Decorator.php index 73e9324c..07947bdc 100644 --- a/src/decorators/Decorator.php +++ b/src/decorators/Decorator.php @@ -44,7 +44,7 @@ class Decorator */ public static function get_sanitized_value(&$var, array &$fields, ?string $esc = null) { - if (\is_a($var, 'PHPPgAdmin\Decorators\Decorator')) { + if ($var instanceof self) { $val = $var->value($fields); } else { $val = &$var; @@ -71,12 +71,12 @@ class Decorator } /** - * @param \Closure|\Closure|\Closure $callback - * @param (mixed|string)[]|null $params + * @param \Closure $callback + * @param (mixed|string)[]|null $params */ - public static function callback($callback, ?array $params = null) + public static function callback(\Closure $callback, ?array $params = null) { - return new \PHPPgAdmin\Decorators\CallbackDecorator($callback, $params); + return new CallbackDecorator($callback, $params); } /** diff --git a/src/help/PostgresDoc.php b/src/help/PostgresDoc.php new file mode 100644 index 00000000..c25c3938 --- /dev/null +++ b/src/help/PostgresDoc.php @@ -0,0 +1,207 @@ +major_version = $major_version; + $this->conf = $conf; + + // TODO: Check and fix links + $this->help_topics = [ + 'pg.database' => 'managing-databases.html', + 'pg.database.create' => ['sql-createdatabase.html', 'manage-ag-createdb.html'], + 'pg.database.alter' => 'sql-alterdatabase.html', + 'pg.database.drop' => ['sql-dropdatabase.html', 'manage-ag-dropdb.html'], + 'pg.admin.analyze' => 'sql-analyze.html', + 'pg.admin.vacuum' => 'sql-vacuum.html', + 'pg.cast' => ['sql-expressions.html#SQL-SYNTAX-TYPE-CASTS', 'sql-createcast.html'], + 'pg.cast.create' => 'sql-createcast.html', + 'pg.cast.drop' => 'sql-dropcast.html', + 'pg.column.add' => ['ddl-alter.html#AEN2115', 'sql-altertable.html'], + 'pg.column.alter' => ['ddl-alter.html', 'sql-altertable.html'], + 'pg.column.drop' => ['ddl-alter.html#AEN2124', 'sql-altertable.html'], + 'pg.constraint' => 'ddl-constraints.html', + 'pg.constraint.add' => 'ddl-alter.html#AEN2131', + 'pg.constraint.check' => 'ddl-constraints.html#AEN1895', + 'pg.constraint.drop' => 'ddl-alter.html#AEN2140', + 'pg.constraint.foreign_key' => 'ddl-constraints.html#DDL-CONSTRAINTS-FK', + 'pg.constraint.primary_key' => 'ddl-constraints.html#AEN1972', + 'pg.constraint.unique_key' => 'ddl-constraints.html#AEN1950', + + 'pg.conversion' => 'multibyte.html', + 'pg.conversion.alter' => 'sql-alterconversion.html', + 'pg.conversion.create' => 'sql-createconversion.html', + 'pg.conversion.drop' => 'sql-dropconversion.html', + + 'pg.domain' => 'extend-type-system.html#AEN28657', + 'pg.domain.alter' => 'sql-alterdomain.html', + 'pg.domain.create' => 'sql-createdomain.html', + 'pg.domain.drop' => 'sql-dropdomain.html', + + 'pg.function' => ['xfunc.html', 'functions.html', 'sql-expressions.html#AEN1599'], + 'pg.function.alter' => 'sql-alterfunction.html', + 'pg.function.create' => 'sql-createfunction.html', + 'pg.function.create.c' => ['xfunc-c.html', 'sql-createfunction.html'], + 'pg.function.create.internal' => ['xfunc-internal.html', 'sql-createfunction.html'], + 'pg.function.create.pl' => ['xfunc-sql.html', 'xfunc-pl.html', 'sql-createfunction.html'], + 'pg.function.drop' => 'sql-dropfunction.html', + + 'pg.group' => 'groups.html', + 'pg.group.alter' => ['sql-altergroup.html', 'groups.html'], + 'pg.group.create' => 'sql-creategroup.html', + 'pg.group.drop' => 'sql-dropgroup.html', + + 'pg.index' => 'indexes.html', + 'pg.index.cluster' => 'sql-cluster.html', + 'pg.index.drop' => 'sql-dropindex.html', + 'pg.index.create' => 'sql-createindex.html', + 'pg.index.reindex' => 'sql-reindex.html', + + 'pg.language' => 'xplang.html', + 'pg.language.alter' => 'sql-alterlanguage.html', + 'pg.language.create' => 'sql-createlanguage.html', + 'pg.language.drop' => 'sql-droplanguage.html', + + 'pg.opclass' => 'indexes-opclass.html', + 'pg.opclass.alter' => 'sql-alteropclass.html', + 'pg.opclass.create' => 'sql-createopclass.html', + 'pg.opclass.drop' => 'sql-dropopclass.html', + + 'pg.operator' => ['xoper.html', 'functions.html', 'sql-expressions.html#AEN1570'], + 'pg.operator.alter' => 'sql-alteroperator.html', + 'pg.operator.create' => 'sql-createoperator.html', + 'pg.operator.drop' => 'sql-dropoperator.html', + + 'pg.pl' => 'xplang.html', + 'pg.pl.plperl' => 'plperl.html', + 'pg.pl.plpgsql' => 'plpgsql.html', + 'pg.pl.plpython' => 'plpython.html', + 'pg.pl.pltcl' => 'pltcl.html', + + 'pg.privilege' => ['privileges.html', 'ddl-priv.html'], + 'pg.privilege.grant' => 'sql-grant.html', + 'pg.privilege.revoke' => 'sql-revoke.html', + + 'pg.process' => 'monitoring.html', + + 'pg.rule' => 'rules.html', + 'pg.rule.create' => 'sql-createrule.html', + 'pg.rule.drop' => 'sql-droprule.html', + + 'pg.schema' => 'ddl-schemas.html', + 'pg.schema.alter' => 'sql-alterschema.html', + 'pg.schema.create' => ['sql-createschema.html', 'ddl-schemas.html#DDL-SCHEMAS-CREATE'], + 'pg.schema.drop' => 'sql-dropschema.html', + 'pg.schema.search_path' => 'ddl-schemas.html#DDL-SCHEMAS-PATH', + + 'pg.sequence' => 'functions-sequence.html', + 'pg.sequence.alter' => 'sql-altersequence.html', + 'pg.sequence.create' => 'sql-createsequence.html', + 'pg.sequence.drop' => 'sql-dropsequence.html', + + 'pg.sql' => ['sql.html', 'sql-commands.html'], + 'pg.sql.insert' => 'sql-insert.html', + 'pg.sql.select' => 'sql-select.html', + 'pg.sql.update' => 'sql-update.html', + + 'pg.table' => 'ddl.html#DDL-BASICS', + 'pg.table.alter' => 'sql-altertable.html', + 'pg.table.create' => 'sql-createtable.html', + 'pg.table.drop' => 'sql-droptable.html', + 'pg.table.empty' => 'sql-truncate.html', + + 'pg.tablespace' => 'manage-ag-tablespaces.html', + 'pg.tablespace.alter' => 'sql-altertablespace.html', + 'pg.tablespace.create' => 'sql-createtablespace.html', + 'pg.tablespace.drop' => 'sql-droptablespace.html', + + 'pg.trigger' => 'triggers.html', + 'pg.trigger.alter' => 'sql-altertrigger.html', + 'pg.trigger.create' => 'sql-createtrigger.html', + 'pg.trigger.drop' => 'sql-droptrigger.html', + + 'pg.type' => ['xtypes.html', 'datatype.html', 'extend-type-system.html'], + 'pg.type.alter' => 'sql-altertype.html', + 'pg.type.create' => 'sql-createtype.html', + 'pg.type.drop' => 'sql-droptype.html', + + 'pg.user.alter' => ['sql-alteruser.html', 'user-attributes.html'], + 'pg.user.create' => ['sql-createuser.html', 'user-manag.html#DATABASE-USERS'], + 'pg.user.drop' => ['sql-dropuser.html', 'user-manag.html#DATABASE-USERS'], + + 'pg.variable' => 'runtime-config.html', + + 'pg.view' => 'tutorial-views.html', + 'pg.view.alter' => ['sql-createview.html', 'sql-altertable.html'], + 'pg.view.create' => 'sql-createview.html', + 'pg.view.drop' => 'sql-dropview.html', + + 'pg.aggregate' => ['xaggr.html', 'tutorial-agg.html', 'functions-aggregate.html', 'sql-expressions.html#SYNTAX-AGGREGATES'], + 'pg.aggregate.create' => 'sql-createaggregate.html', + 'pg.aggregate.drop' => 'sql-dropaggregate.html', + 'pg.aggregate.alter' => 'sql-alteraggregate.html', + + 'pg.server' => 'admin.html', + + 'pg.user' => 'user-manag.html', + + 'pg.locks' => 'view-pg-locks.html', + ]; + } + + public function getHelpBase() + { + return \sprintf(\str_replace('http://', 'https://', $this->conf['help_base']), (string) ($this->major_version)); + } + + /** + * Undocumented function. + * + * @param null|string $topic + * + * @return null|string|string[] + */ + public function getHelpTopics(?string $topic = null): array + { + return $topic ? $this->help_topics[$topic] ?? null : $this->help_topics; + } + + /** + * Undocumented function. + * + * @param string $topic + * + * @return null|string|string[] + */ + public function getHelpTopic(string $topic) + { + return $this->help_topics[$topic] ?? null; + } +} diff --git a/src/help/PostgresDoc74.php b/src/help/PostgresDoc74.php deleted file mode 100644 index b606df36..00000000 --- a/src/help/PostgresDoc74.php +++ /dev/null @@ -1,179 +0,0 @@ -major_version = $major_version; - $this->conf = $conf; - - // TODO: Check and fix links - $this->help_page = [ - 'pg.database' => 'managing-databases.html', - 'pg.database.create' => ['sql-createdatabase.html', 'manage-ag-createdb.html'], - 'pg.database.alter' => 'sql-alterdatabase.html', - 'pg.database.drop' => ['sql-dropdatabase.html', 'manage-ag-dropdb.html'], - 'pg.admin.analyze' => 'sql-analyze.html', - 'pg.admin.vacuum' => 'sql-vacuum.html', - 'pg.cast' => ['sql-expressions.html#SQL-SYNTAX-TYPE-CASTS', 'sql-createcast.html'], - 'pg.cast.create' => 'sql-createcast.html', - 'pg.cast.drop' => 'sql-dropcast.html', - 'pg.column.add' => ['ddl-alter.html#AEN2115', 'sql-altertable.html'], - 'pg.column.alter' => ['ddl-alter.html', 'sql-altertable.html'], - 'pg.column.drop' => ['ddl-alter.html#AEN2124', 'sql-altertable.html'], - 'pg.constraint' => 'ddl-constraints.html', - 'pg.constraint.add' => 'ddl-alter.html#AEN2131', - 'pg.constraint.check' => 'ddl-constraints.html#AEN1895', - 'pg.constraint.drop' => 'ddl-alter.html#AEN2140', - 'pg.constraint.foreign_key' => 'ddl-constraints.html#DDL-CONSTRAINTS-FK', - 'pg.constraint.primary_key' => 'ddl-constraints.html#AEN1972', - 'pg.constraint.unique_key' => 'ddl-constraints.html#AEN1950', - - 'pg.conversion' => 'multibyte.html', - 'pg.conversion.alter' => 'sql-alterconversion.html', - 'pg.conversion.create' => 'sql-createconversion.html', - 'pg.conversion.drop' => 'sql-dropconversion.html', - - 'pg.domain' => 'extend-type-system.html#AEN28657', - 'pg.domain.alter' => 'sql-alterdomain.html', - 'pg.domain.create' => 'sql-createdomain.html', - 'pg.domain.drop' => 'sql-dropdomain.html', - - 'pg.function' => ['xfunc.html', 'functions.html', 'sql-expressions.html#AEN1599'], - 'pg.function.alter' => 'sql-alterfunction.html', - 'pg.function.create' => 'sql-createfunction.html', - 'pg.function.create.c' => ['xfunc-c.html', 'sql-createfunction.html'], - 'pg.function.create.internal' => ['xfunc-internal.html', 'sql-createfunction.html'], - 'pg.function.create.pl' => ['xfunc-sql.html', 'xfunc-pl.html', 'sql-createfunction.html'], - 'pg.function.drop' => 'sql-dropfunction.html', - - 'pg.group' => 'groups.html', - 'pg.group.alter' => ['sql-altergroup.html', 'groups.html'], - 'pg.group.create' => 'sql-creategroup.html', - 'pg.group.drop' => 'sql-dropgroup.html', - - 'pg.index' => 'indexes.html', - 'pg.index.cluster' => 'sql-cluster.html', - 'pg.index.drop' => 'sql-dropindex.html', - 'pg.index.create' => 'sql-createindex.html', - 'pg.index.reindex' => 'sql-reindex.html', - - 'pg.language' => 'xplang.html', - 'pg.language.alter' => 'sql-alterlanguage.html', - 'pg.language.create' => 'sql-createlanguage.html', - 'pg.language.drop' => 'sql-droplanguage.html', - - 'pg.opclass' => 'indexes-opclass.html', - 'pg.opclass.alter' => 'sql-alteropclass.html', - 'pg.opclass.create' => 'sql-createopclass.html', - 'pg.opclass.drop' => 'sql-dropopclass.html', - - 'pg.operator' => ['xoper.html', 'functions.html', 'sql-expressions.html#AEN1570'], - 'pg.operator.alter' => 'sql-alteroperator.html', - 'pg.operator.create' => 'sql-createoperator.html', - 'pg.operator.drop' => 'sql-dropoperator.html', - - 'pg.pl' => 'xplang.html', - 'pg.pl.plperl' => 'plperl.html', - 'pg.pl.plpgsql' => 'plpgsql.html', - 'pg.pl.plpython' => 'plpython.html', - 'pg.pl.pltcl' => 'pltcl.html', - - 'pg.privilege' => ['privileges.html', 'ddl-priv.html'], - 'pg.privilege.grant' => 'sql-grant.html', - 'pg.privilege.revoke' => 'sql-revoke.html', - - 'pg.process' => 'monitoring.html', - - 'pg.rule' => 'rules.html', - 'pg.rule.create' => 'sql-createrule.html', - 'pg.rule.drop' => 'sql-droprule.html', - - 'pg.schema' => 'ddl-schemas.html', - 'pg.schema.alter' => 'sql-alterschema.html', - 'pg.schema.create' => ['sql-createschema.html', 'ddl-schemas.html#DDL-SCHEMAS-CREATE'], - 'pg.schema.drop' => 'sql-dropschema.html', - 'pg.schema.search_path' => 'ddl-schemas.html#DDL-SCHEMAS-PATH', - - 'pg.sequence' => 'functions-sequence.html', - 'pg.sequence.alter' => 'sql-altersequence.html', - 'pg.sequence.create' => 'sql-createsequence.html', - 'pg.sequence.drop' => 'sql-dropsequence.html', - - 'pg.sql' => ['sql.html', 'sql-commands.html'], - 'pg.sql.insert' => 'sql-insert.html', - 'pg.sql.select' => 'sql-select.html', - 'pg.sql.update' => 'sql-update.html', - - 'pg.table' => 'ddl.html#DDL-BASICS', - 'pg.table.alter' => 'sql-altertable.html', - 'pg.table.create' => 'sql-createtable.html', - 'pg.table.drop' => 'sql-droptable.html', - 'pg.table.empty' => 'sql-truncate.html', - - 'pg.tablespace' => 'manage-ag-tablespaces.html', - 'pg.tablespace.alter' => 'sql-altertablespace.html', - 'pg.tablespace.create' => 'sql-createtablespace.html', - 'pg.tablespace.drop' => 'sql-droptablespace.html', - - 'pg.trigger' => 'triggers.html', - 'pg.trigger.alter' => 'sql-altertrigger.html', - 'pg.trigger.create' => 'sql-createtrigger.html', - 'pg.trigger.drop' => 'sql-droptrigger.html', - - 'pg.type' => ['xtypes.html', 'datatype.html', 'extend-type-system.html'], - 'pg.type.alter' => 'sql-altertype.html', - 'pg.type.create' => 'sql-createtype.html', - 'pg.type.drop' => 'sql-droptype.html', - - 'pg.user.alter' => ['sql-alteruser.html', 'user-attributes.html'], - 'pg.user.create' => ['sql-createuser.html', 'user-manag.html#DATABASE-USERS'], - 'pg.user.drop' => ['sql-dropuser.html', 'user-manag.html#DATABASE-USERS'], - - 'pg.variable' => 'runtime-config.html', - - 'pg.view' => 'tutorial-views.html', - 'pg.view.alter' => ['sql-createview.html', 'sql-altertable.html'], - 'pg.view.create' => 'sql-createview.html', - 'pg.view.drop' => 'sql-dropview.html', - - 'pg.aggregate' => ['xaggr.html', 'tutorial-agg.html', 'functions-aggregate.html', 'sql-expressions.html#SYNTAX-AGGREGATES'], - 'pg.aggregate.create' => 'sql-createaggregate.html', - 'pg.aggregate.drop' => 'sql-dropaggregate.html', - 'pg.aggregate.alter' => 'sql-alteraggregate.html', - - 'pg.server' => 'admin.html', - - 'pg.user' => 'user-manag.html', - - 'pg.locks' => 'view-pg-locks.html', - ]; - } - - public function getHelpBase() - { - return \sprintf(\str_replace('http://', 'https://', $this->conf['help_base']), (string) ($this->major_version)); - } - - public function getHelpPage() - { - return $this->help_page; - } -} diff --git a/src/help/PostgresDoc80.php b/src/help/PostgresDoc80.php deleted file mode 100644 index cbf7f87f..00000000 --- a/src/help/PostgresDoc80.php +++ /dev/null @@ -1,35 +0,0 @@ -help_page['pg.column.add'][0] = 'ddl-alter.html#AEN2217'; - $this->help_page['pg.column.drop'][0] = 'ddl-alter.html#AEN2226'; - - $this->help_page['pg.constraint.add'] = 'ddl-alter.html#AEN2217'; - $this->help_page['pg.constraint.check'] = 'ddl-constraints.html#AEN1978'; - $this->help_page['pg.constraint.drop'] = 'ddl-alter.html#AEN2226'; - $this->help_page['pg.constraint.primary_key'] = 'ddl-constraints.html#AEN2055'; - $this->help_page['pg.constraint.unique_key'] = 'ddl-constraints.html#AEN2033'; - - $this->help_page['pg.domain'] = 'extend-type-system.html#AEN27940'; - - $this->help_page['pg.function'][2] = 'sql-expressions.html#AEN1652'; - - $this->help_page['pg.operator'][2] = 'sql-expressions.html#AEN1623'; - } -} diff --git a/src/help/PostgresDoc81.php b/src/help/PostgresDoc81.php deleted file mode 100644 index b5fe8916..00000000 --- a/src/help/PostgresDoc81.php +++ /dev/null @@ -1,25 +0,0 @@ -help_page['pg.role'] = 'user-manag.html'; - $this->help_page['pg.role.create'] = ['sql-createrole.html', 'user-manag.html#DATABASE-ROLES']; - $this->help_page['pg.role.alter'] = ['sql-alterrole.html', 'role-attributes.html']; - $this->help_page['pg.role.drop'] = ['sql-droprole.html', 'user-manag.html#DATABASE-ROLES']; - } -} diff --git a/src/help/PostgresDoc82.php b/src/help/PostgresDoc82.php deleted file mode 100644 index b5abc90a..00000000 --- a/src/help/PostgresDoc82.php +++ /dev/null @@ -1,20 +0,0 @@ -help_page['pg.fts'] = 'textsearch.html'; - - $this->help_page['pg.ftscfg'] = 'textsearch-intro.html#TEXTSEARCH-INTRO-CONFIGURATIONS'; - $this->help_page['pg.ftscfg.example'] = 'textsearch-configuration.html'; - $this->help_page['pg.ftscfg.drop'] = 'sql-droptsconfig.html'; - $this->help_page['pg.ftscfg.create'] = 'sql-createtsconfig.html'; - $this->help_page['pg.ftscfg.alter'] = 'sql-altertsconfig.html'; - - $this->help_page['pg.ftsdict'] = 'textsearch-dictionaries.html'; - $this->help_page['pg.ftsdict.drop'] = 'sql-droptsdictionary.html'; - $this->help_page['pg.ftsdict.create'] = ['sql-createtsdictionary.html', 'sql-createtstemplate.html']; - $this->help_page['pg.ftsdict.alter'] = 'sql-altertsdictionary.html'; - - $this->help_page['pg.ftsparser'] = 'textsearch-parsers.html'; - } -} diff --git a/src/help/PostgresDoc84.php b/src/help/PostgresDoc84.php deleted file mode 100644 index a9ece52b..00000000 --- a/src/help/PostgresDoc84.php +++ /dev/null @@ -1,20 +0,0 @@ -help_page['pg.rule.view'] = 'rules-views.html'; + $this->help_topics['pg.rule.view'] = 'rules-views.html'; } } diff --git a/src/help/PostgresDoc93.php b/src/help/PostgresDoc93.php index 8fef2fdb..cad85288 100644 --- a/src/help/PostgresDoc93.php +++ b/src/help/PostgresDoc93.php @@ -17,13 +17,13 @@ class PostgresDoc93 extends PostgresDoc92 { parent::__construct($conf, $major_version); - $this->help_page['pg.matview'] = 'sql-creatematerializedview.html'; + $this->help_topics['pg.matview'] = 'sql-creatematerializedview.html'; - $this->help_page['pg.matview.create'] = 'sql-creatematerializedview.html'; - $this->help_page['pg.matview.drop'] = 'sql-dropmaterializedview.html'; - $this->help_page['pg.matview.alter'] = 'sql-altermaterializedview.html'; - $this->help_page['pg.matview.refresh'] = 'sql-refreshmaterializedview.html'; + $this->help_topics['pg.matview.create'] = 'sql-creatematerializedview.html'; + $this->help_topics['pg.matview.drop'] = 'sql-dropmaterializedview.html'; + $this->help_topics['pg.matview.alter'] = 'sql-altermaterializedview.html'; + $this->help_topics['pg.matview.refresh'] = 'sql-refreshmaterializedview.html'; - $this->help_page['pg.rule.matview'] = 'rules-materializedviews.html'; + $this->help_topics['pg.rule.matview'] = 'rules-materializedviews.html'; } } diff --git a/src/lib.inc.php b/src/lib.inc.php index 4dd06496..a2417192 100644 --- a/src/lib.inc.php +++ b/src/lib.inc.php @@ -69,7 +69,7 @@ if (DEBUGMODE) { $conf['register_debuggers'](); } } -define('ADODB_ASSOC_CASE',ADODB_ASSOC_CASE_NATIVE); +\define('ADODB_ASSOC_CASE', ADODB_ASSOC_CASE_NATIVE); // Fetch App and DI Container $app = \PHPPgAdmin\ContainerUtils::createApp($conf); $container = $app->getContainer(); @@ -77,19 +77,21 @@ $container = $app->getContainer(); if (!$container instanceof \Slim\Container) { \trigger_error('App Container must be an instance of \\Slim\\Container', \E_USER_ERROR); } -function container():\Slim\Container { -return \PHPPgAdmin\ContainerUtils::getContainerInstance(); +function containerInstance(): \Slim\Container +{ + return \PHPPgAdmin\ContainerUtils::getContainerInstance(); +} + +function requestInstance(): \Slim\Http\Request +{ + return containerInstance()->request; } - -function request():\Slim\Http\Request { - return container()->request; - } - function response():\Slim\Http\Response { - return container()->response; - } + function responseInstance(): \Slim\Http\Response + { + return containerInstance()->response; + } - // This should be deprecated once we're sure no php scripts are required directly $container->offsetSet('server', $_REQUEST['server'] ?? null); $container->offsetSet('database', $_REQUEST['database'] ?? null); diff --git a/src/router.php b/src/router.php index 144c7248..c3d707c1 100644 --- a/src/router.php +++ b/src/router.php @@ -13,7 +13,8 @@ $app->get('/status', function ( /* @scrutinizer ignore-unused */ array $args ) { - phpinfo(); + \phpinfo(); + return; //dump($this->get('settings')->all()); return $response @@ -131,13 +132,11 @@ $app->get('/{subject:\w+}[/{server_id}]', function ( \Slim\Http\Response $response, /* @scrutinizer ignore-unused */ array $args - ) { - $subject=$args['subject']??'intro'; - $server_id=$args['server_id']??$request->getQueryParam('server'); - //ddd($subject, $server_id); + $subject = $args['subject'] ?? 'intro'; + $server_id = $args['server_id'] ?? $request->getQueryParam('server'); + //ddd($subject, $server_id); $_server_info = $this->misc->getServerInfo(); - //$this->utils->prtrace($_server_info); diff --git a/src/traits/AdminTrait.php b/src/traits/AdminTrait.php index 034ee177..8460eaa3 100644 --- a/src/traits/AdminTrait.php +++ b/src/traits/AdminTrait.php @@ -289,7 +289,7 @@ trait AdminTrait echo '" . \PHP_EOL; @@ -321,7 +321,7 @@ trait AdminTrait echo ' |