Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"@dev:lint:phpcs"
],
"dev:lint:php": "parallel-lint --exclude vendor .",
"dev:lint:phpcs": "phpcs -d memory_limit=256M src/ autoload.php all_db.php all_db_export.php alter_db.php alter_role.php browser.php create_db.php create_role.php drop_db.php drop_role.php history.php history_clear.php history_delete.php history_download.php index.php intro.php login.php logout.php roles.php server-logout.php servers.php servers-tree.php sqledit.php",
"dev:lint:phpcs": "phpcs -d memory_limit=256M src/ autoload.php all_db.php all_db_export.php alter_db.php alter_role.php browser.php create_db.php create_role.php dbexport.php drop_db.php drop_role.php history.php history_clear.php history_delete.php history_download.php index.php intro.php login.php logout.php roles.php server-logout.php servers.php servers-tree.php sqledit.php",
"dev:test": [
"@dev:test:acceptance"
],
Expand Down
160 changes: 80 additions & 80 deletions composer.lock

Large diffs are not rendered by default.

148 changes: 5 additions & 143 deletions dbexport.php
Original file line number Diff line number Diff line change
@@ -1,148 +1,10 @@
<?php

/**
* Does an export of a database, schema, or table (via pg_dump)
* to the screen or as a download.
*
* $Id: dbexport.php,v 1.22 2007/03/25 03:15:09 xzilla Exp $
*/
declare(strict_types=1);

// Prevent timeouts on large exports (non-safe mode only)
if (!ini_get('safe_mode')) {
set_time_limit(0);
}
use PhpPgAdmin\Website\DbExport;

// Include application functions
$_no_output = true;
$f_schema = $f_object = '';
include_once('./libraries/lib.inc.php');
require_once __DIR__ . DIRECTORY_SEPARATOR . 'autoload.php';

// Are we doing a cluster-wide dump or just a per-database dump
$dumpall = ($_REQUEST['subject'] == 'server');

// Check that database dumps are enabled.
if ($misc->isDumpEnabled($dumpall)) {
$server_info = $misc->getServerInfo();

// Get the path of the pg_dump/pg_dumpall executable
$exe = $misc->escapeShellCmd($server_info[$dumpall ? 'pg_dumpall_path' : 'pg_dump_path']);

// Obtain the pg_dump version number and check if the path is good
$version = array();
preg_match("/(\d+(?:\.\d+)?)(?:\.\d+)?.*$/", exec($exe . " --version"), $version);

if (empty($version)) {
if ($dumpall) {
printf($lang['strbadpgdumpallpath'], $server_info['pg_dumpall_path']);
} else {
printf($lang['strbadpgdumppath'], $server_info['pg_dump_path']);
}
exit;
}

// Make it do a download, if necessary
switch ($_REQUEST['output']) {
case 'show':
header('Content-Type: text/plain');
break;
case 'download':
// Set headers. MSIE is totally broken for SSL downloading, so
// we need to have it download in-place as plain text
if (strstr($_SERVER['HTTP_USER_AGENT'], 'MSIE') && isset($_SERVER['HTTPS'])) {
header('Content-Type: text/plain');
} else {
header('Content-Type: application/download');
header('Content-Disposition: attachment; filename=dump.sql');
}
break;
case 'gzipped':
// MSIE in SSL mode cannot do this - it should never get to this point
header('Content-Type: application/download');
header('Content-Disposition: attachment; filename=dump.sql.gz');
break;
}

// Set environmental variables that pg_dump uses
putenv('PGPASSWORD=' . $server_info['password']);
putenv('PGUSER=' . $server_info['username']);
$hostname = $server_info['host'];
if ($hostname !== null && $hostname != '') {
putenv('PGHOST=' . $hostname);
}
$port = $server_info['port'];
if ($port !== null && $port != '') {
putenv('PGPORT=' . $port);
}

// Build command for executing pg_dump.
$cmd = $exe;

// we are PG 7.4+, so we always have a schema
if (isset($_REQUEST['schema'])) {
$f_schema = $_REQUEST['schema'];
$f_schema = $data->fieldClean($f_schema);
}

// Check for a specified table/view
switch ($_REQUEST['subject']) {
case 'schema':
// This currently works for 8.2+ (due to the orthoganl -t -n issue introduced then)
$cmd .= " -n " . $misc->escapeShellArg("\"{$f_schema}\"");
break;
case 'table':
case 'view':
$f_object = $_REQUEST[$_REQUEST['subject']];
$f_object = $data->fieldClean($f_object);

// Starting in 8.2, -n and -t are orthogonal, so we now schema qualify
// the table name in the -t argument and quote both identifiers
if (((float) $version[1]) >= 8.2) {
$cmd .= " -t " . $misc->escapeShellArg("\"{$f_schema}\".\"{$f_object}\"");
} else {
// If we are 7.4 or higher, assume they are using 7.4 pg_dump and
// set dump schema as well. Also, mixed case dumping has been fixed
// then..
$cmd .= " -t " . $misc->escapeShellArg($f_object)
. " -n " . $misc->escapeShellArg($f_schema);
}
}

// Check for GZIP compression specified
if ($_REQUEST['output'] == 'gzipped' && !$dumpall) {
$cmd .= " -Z 9";
}

switch ($_REQUEST['what']) {
case 'dataonly':
$cmd .= ' -a';
if ($_REQUEST['d_format'] == 'sql') {
$cmd .= ' --inserts';
} elseif (isset($_REQUEST['d_oids'])) {
$cmd .= ' -o';
}
break;
case 'structureonly':
$cmd .= ' -s';
if (isset($_REQUEST['s_clean'])) {
$cmd .= ' -c';
}
break;
case 'structureanddata':
if ($_REQUEST['sd_format'] == 'sql') {
$cmd .= ' --inserts';
} elseif (isset($_REQUEST['sd_oids'])) {
$cmd .= ' -o';
}
if (isset($_REQUEST['sd_clean'])) {
$cmd .= ' -c';
}
break;
}

if (!$dumpall) {
putenv('PGDATABASE=' . $_REQUEST['database']);
}

// Execute command and return the output to the screen
passthru($cmd);
}
$website = new DbExport();
echo $website->buildHtmlString();
Binary file modified locale/ca_ES/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/ca_ES/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ msgstr "Intent de connexió amb un paràmetre del servidor invàlid, possiblemen
msgid "strnoserversupplied"
msgstr "No s'ha proporcionat cap servidor!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Error d'exportació: Fallada en l'execució de pg_dump (path definit a conf/config.inc.php : %s ). Sisplau, arregli el path en la configuració."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Error d'exportació: Fallada en l'execució de pg_dumpall (path definit a conf/config.inc.php : %s ). Sisplau, arregli el path en la configuració."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/cs_CZ/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/cs_CZ/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ msgstr "Pokus o připojení s neplatnými parametry serveru, možná se někdo s
msgid "strnoserversupplied"
msgstr "Není nabízen žádný server!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Chyba při exportu: Nezdařilo se spustit pg_dump (s cestou danou ve vašem conf/config.inc.php: %s). Opravte prosím cestu ve svém nastavení a zkuste to znovu."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Chyba při exportu: Nezdařilo se spustit pg_dumpall (s cestou danou ve vašem conf/config.inc.php: %s). Opravte prosím cestu ve svém nastavení a zkuste to znovu."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/en_US/LC_MESSAGES/messages.mo
Binary file not shown.
6 changes: 4 additions & 2 deletions locale/en_US/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,12 @@ msgstr "Attempt to connect with invalid server parameter, possibly someone is tr
msgid "strnoserversupplied"
msgstr "No server supplied!"

msgid "strbadpgdumppath"
# original: "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."

msgid "strbadpgdumpallpath"
# original: "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/es_ES/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/es_ES/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -543,10 +543,10 @@ msgstr "Intento de conexión al servidor con un parámetro inválido. Posiblemen
msgid "strnoserversupplied"
msgstr "No se suministró un servidor"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Error de exportación: Falló la ejecución de execute pg_dump (según la ruta dada en conf/config.inc.php : %s). Por favor, arregla esta ruta en tu configuración y vuelve a iniciar sesión."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Error de exportación: Falló la ejecución de pg_dumpall (según la ruta dada en conf/config.inc.php : %s). Por favor, arregla esta ruta en tu configuración y vuelve a iniciar sesión."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/fr_FR/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/fr_FR/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,10 @@ msgstr "Tentative de connexion avec un serveur invalide, il est possible que que
msgid "strnoserversupplied"
msgstr "Aucun serveur fournis !"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Erreur d'export : n'a pu exécuter pg_dump (chemin indiqué dans votre conf/config.inc.php : %s). Merci de corriger le chemin dans votre configuration et de vous reconnecter."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Erreur d'export : n'a pu exécuter pg_dumpall (chemin indiqué dans votre conf/config.inc.php : %s). Merci de corriger le chemin dans votre configuration et de vous reconnecter."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/gl_ES/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/gl_ES/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ msgstr "Produciuse un intento de conexión cun servidor non permitido como pará
msgid "strnoserversupplied"
msgstr "Non se forneceu ningún servidor!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Produciuse un erro ao exportar: non se conseguiu executar pg_dump (a ruta indicada no seu ficheiro «conf/config.inc.php» é «%s»). Cambie a ruta no ficheiro de configuración e volva intentalo."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Produciuse un erro ao exportar: non se conseguiu executar pg_dumpall (a ruta indicada no seu ficheiro «conf/config.inc.php» é «%s»). Cambie a ruta no ficheiro de configuración e volva intentalo."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/hu_HU/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/hu_HU/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ msgstr "Érvénytelen kiszolgáló paraméterrel próbáltak csatlakozni. Lehet,
msgid "strnoserversupplied"
msgstr "Nincs megadva kiszolgáló!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Kiviteli hiba: Elbukott a pg_dump végrehajtása (conf/config.inc.php fájlban megadott ösvény: %s). Kérem, javítsa ki ezt a beállításban, és ismételjen."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Kiviteli hiba: Elbukott a pg_dumpall végrehajtása (conf/config.inc.php fájlban megadott ösvény: %s). Kérem, javítsa ki ezt a beállításban, és ismételjen."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/lt_LT/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/lt_LT/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -555,10 +555,10 @@ msgstr "Bandymas prisijungti su negaliojančiu serverio parametru, galbūt kas n
msgid "strnoserversupplied"
msgstr "Nenurodytas serveris!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Eksportavimo klaida: nepavyko įvykdyti pg_dump (pateiktas kelias Jūsų conf/config.inc.php : %s). Pataisykite šį kelią savo konfigūracijoje ir prisijunkite iš naujo."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Eksportavimo klaida: nepavyko įvykdyti pg_dumpall (pateiktas kelias Jūsų conf/config.inc.php : %s). Pataisykite šį kelią savo konfigūracijoje ir prisijunkite iš naujo."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/pt_BR/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/pt_BR/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,10 @@ msgstr "Tentativa de conectar com um parâmetro de servidor inválido, possivelm
msgid "strnoserversupplied"
msgstr "Nenhum servidor informado!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Erro de exportação: Falha ao executar pg_dump (caminho apontado no seu conf/config.inc.php : %s). Por favor, ajuste este diretório na sua configuração e relogue no sistema."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Erro de exportação: Falha ao executar pg_dumpall (caminho apontado no seu conf/config.inc.php : %s). Por favor, este diretório na sua configuração e relogue no sistema."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/ru_RU/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/ru_RU/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -537,10 +537,10 @@ msgstr "Попытка соединения с некорректным знач
msgid "strnoserversupplied"
msgstr "Значение параметра \"сервер\" не представлено!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Ошибка экспорта: Невозможно выполнить pg_dump (указанный в conf/config.inc.php путь: %s). Пожалуйста, исправте этот путь в конфигурации и заново войдите в систему."

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "Ошибка экспорта: Невозможно выполнить pg_dumpall (указанный в conf/config.inc.php путь: %s). Пожалуйста, исправте этот путь в конфигурации и заново войдите в систему."

msgid "strconnectionfail"
Expand Down
Binary file modified locale/zh_CN/LC_MESSAGES/messages.mo
Binary file not shown.
4 changes: 2 additions & 2 deletions locale/zh_CN/LC_MESSAGES/messages.po
Original file line number Diff line number Diff line change
Expand Up @@ -540,10 +540,10 @@ msgstr "尝试用无效的服务器参数连接,可能有人正尝试攻击你
msgid "strnoserversupplied"
msgstr "没有选择数据库!"

msgid "strbadpgdumppath"
msgid "Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "导出错误:在 conf/config.inc.php 中指定的路径 %s 下执行pg_dump失败。请在配置中修改路径并重新登录。"

msgid "strbadpgdumpallpath"
msgid "Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog."
msgstr "导出错误:在 conf/config.inc.php 中指定的路径 %s 下执行pg_dumpall失败。请在配置中修改路径并重新登录。"

msgid "strconnectionfail"
Expand Down
11 changes: 9 additions & 2 deletions phpcs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
<rule ref="SlevomatCodingStandard.Classes.RequireSingleLineMethodSignature"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>
<!--<rule ref="SlevomatCodingStandard.Classes.SuperfluousExceptionNaming"/>-->
<rule ref="SlevomatCodingStandard.Classes.SuperfluousErrorNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousTraitNaming"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
Expand Down Expand Up @@ -81,7 +81,14 @@
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowNullSafeObjectOperator"/>-->
<!--<rule ref="SlevomatCodingStandard.ControlStructures.DisallowShortTernaryOperator"/>-->
<rule ref="SlevomatCodingStandard.ControlStructures.DisallowTrailingMultiLineTernaryOperator"/>
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing"/>
<rule ref="SlevomatCodingStandard.ControlStructures.JumpStatementsSpacing">
<properties>
<property name="jumpStatements" type="array">
<element value="continue"/>
<element value="return"/>
</property>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.ControlStructures.LanguageConstructWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.NewWithParentheses"/>
<rule ref="SlevomatCodingStandard.ControlStructures.RequireMultiLineCondition"/>
Expand Down
1 change: 1 addition & 0 deletions phpstan.neon.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ parameters:
- browser.php
- create_db.php
- create_role.php
- dbexport.php
- drop_db.php
- drop_role.php
- history.php
Expand Down
9 changes: 9 additions & 0 deletions src/Application/Exceptions/FileNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpPgAdmin\Application\Exceptions;

class FileNotFoundException extends \Exception
{
}
9 changes: 9 additions & 0 deletions src/Application/Exceptions/ServerNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpPgAdmin\Application\Exceptions;

class ServerNotFoundException extends \Exception
{
}
9 changes: 9 additions & 0 deletions src/Application/Exceptions/ServerSessionNotFoundException.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

declare(strict_types=1);

namespace PhpPgAdmin\Application\Exceptions;

class ServerSessionNotFoundException extends \Exception
{
}
Loading