Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/HuasoFoundries/phpPgAdmin6.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmenadiel <amenadiel@gmail.com>2016-09-08 00:25:07 +0300
committerAmenadiel <amenadiel@gmail.com>2016-09-08 00:25:07 +0300
commit9f7b6047aa870a7b74684e1f5502b208843975b2 (patch)
tree595612fbb06f178f2ef60a93c792a853a38d9792
parentb44050b160c0986ee7f8e69e4c08d41daf5ffcde (diff)
parent032292ce4b812f993dcb21ef7ed74d76b04ecfdf (diff)
Merge branch 'release/v6.0.0-beta1'vv6.0.0-beta1v6.0.0-beta1
-rw-r--r--README.md1
-rw-r--r--composer.json4
-rw-r--r--composer.lock4
-rw-r--r--src/classes/Misc.php213
-rw-r--r--src/classes/PluginManager.php27
-rw-r--r--src/controllers/BaseController.php15
-rw-r--r--src/controllers/ServerController.php11
-rw-r--r--src/database/ADODB_base.php16
-rwxr-xr-xsrc/database/Connection.php52
-rwxr-xr-xsrc/database/Postgres.php22
-rw-r--r--src/database/Postgres74.php33
-rw-r--r--src/database/Postgres80.php11
-rw-r--r--src/database/Postgres81.php33
-rw-r--r--src/database/Postgres82.php10
-rw-r--r--src/database/Postgres83.php31
-rwxr-xr-xsrc/database/Postgres84.php28
-rwxr-xr-xsrc/database/Postgres91.php2
-rw-r--r--src/database/Postgres94.php19
-rw-r--r--src/database/Postgres95.php19
-rw-r--r--src/lib.inc.php210
-rw-r--r--src/plugins/GuiControl/plugin.php162
-rw-r--r--src/plugins/Report/plugin.php568
-rw-r--r--src/plugins/instaGIS/plugin.php147
-rw-r--r--src/themes.php68
-rw-r--r--src/themes/bootstrap/global.css2
-rw-r--r--src/themes/cappuccino/global.css208
-rw-r--r--src/themes/default/global.css2
-rw-r--r--src/xhtml/HTMLController.php7
-rw-r--r--src/xhtml/HTMLNavbarController.php5
-rw-r--r--templates/browser.twig4
30 files changed, 1078 insertions, 856 deletions
diff --git a/README.md b/README.md
index aba09df3..241cd451 100644
--- a/README.md
+++ b/README.md
@@ -24,4 +24,3 @@ This is a fork of [phpPgAdmin](https://github.com/phppgadmin/phppgadmin) that im
- usage of global functions is being replaced by anonymous fuctions
- usage of explicit includes/requires is being replaced by composer's autoloader (except for `src/lib.inc.php`)
- global decorator functions are being replaced by static methods of the Decorator class.
-- `doTree` and `doSubtree` functions of each entrypoint are now at `src/tree` mostly because they are a different, self contained family of routes that reference each other \ No newline at end of file
diff --git a/composer.json b/composer.json
index c161868c..ad02f27e 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "huasofoundries/phppgadmin",
- "version": "6.0.0-alpha3",
+ "version": "6.0.0-beta1",
"description": "Like phpmyadmin but for postgres",
"type": "project",
"license": "MIT",
@@ -13,7 +13,7 @@
"psr-4": {
"PHPPgAdmin\\": "src/classes",
"PHPPgAdmin\\Controller\\": "src/controllers",
-
+ "PHPPgAdmin\\Middleware\\": "src/middleware",
"PHPPgAdmin\\Database\\": "src/database",
"PHPPgAdmin\\XHtml\\": "src/xhtml",
"PHPPgAdmin\\Decorators\\": "src/decorators"
diff --git a/composer.lock b/composer.lock
index 744b7315..3b4abcad 100644
--- a/composer.lock
+++ b/composer.lock
@@ -4,8 +4,8 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically"
],
- "hash": "b5caa7fbaa65851bbec4d8d6bfc0dc9e",
- "content-hash": "a561ee70b411e722ceb6ff4a20b9d564",
+ "hash": "a66b20638f20367d735f96e91543fbe1",
+ "content-hash": "c3200f466096538066f42dd2087d5a04",
"packages": [
{
"name": "adodb/adodb-php",
diff --git a/src/classes/Misc.php b/src/classes/Misc.php
index 17d1cc49..2e3307b0 100644
--- a/src/classes/Misc.php
+++ b/src/classes/Misc.php
@@ -30,12 +30,12 @@ class Misc {
public $lang = [];
private $server_info = null;
private $_no_output = false;
+ private $container = null;
/* Constructor */
- function __construct(\Slim\App $app) {
- $this->app = $app;
+ function __construct(\Slim\Container $container) {
- $container = $app->getContainer();
+ $this->container = $container;
$this->lang = $container->get('lang');
$this->conf = $container->get('conf');
@@ -48,6 +48,19 @@ class Misc {
$this->postgresqlMinVer = $container->get('settings')['postgresqlMinVer'];
$this->phpMinVer = $container->get('settings')['phpMinVer'];
+ $base_version = $container->get('settings')['base_version'];
+ // Check for config file version mismatch
+ if (!isset($this->conf['version']) || $base_version > $this->conf['version']) {
+ die($this->lang['strbadconfig']);
+
+ }
+
+ // Check database support is properly compiled in
+ if (!function_exists('pg_connect')) {
+ die($this->lang['strnotloaded']);
+
+ }
+
// Check the version of PHP
if (version_compare(phpversion(), $this->phpMinVer, '<')) {
exit(sprintf('Version of PHP not supported. Please upgrade to version %s or later.', $this->phpMinVer));
@@ -61,17 +74,102 @@ class Misc {
} else if (isset($_SESSION['webdbLogin']) && count($_SESSION['webdbLogin']) > 0) {
$this->server_id = array_keys($_SESSION['webdbLogin'])[0];
}
+ }
- $_server_info = $this->getServerInfo();
- /* starting with PostgreSQL 9.0, we can set the application name */
- if (isset($_server_info['pgVersion']) && $_server_info['pgVersion'] >= 9) {
- putenv("PGAPPNAME=" . $this->appName . '_' . $this->appVersion);
- }
+ public function getContainer() {
+ return $this->container;
+ }
- //\PC::debug($this->conf, 'conf');
- //\PC::debug($this->server_id, 'server_id');
+ /**
+ * sets $_no_bottom_link boolean value
+ * @param boolean $flag [description]
+ */
+ function setNoBottomLink($flag) {
+ $this->_no_bottom_link = boolval($flag);
+ return $this;
}
+ /**
+ * sets $_no_db_connection boolean value, allows to render scripts that do not need an active session
+ * @param boolean $flag [description]
+ */
+ function setNoDBConnection($flag) {
+ $this->_no_db_connection = boolval($flag);
+ return $this;
+ }
+
+ function setNoOutput($flag) {
+ $this->_no_output = boolval($flag);
+ return $this;
+ }
+
+ function getNoDBConnection() {
+ return $this->_no_db_connection;
+ }
+
+ /**
+ * Creates a database accessor
+ */
+ function getDatabaseAccessor($database = '', $server_id = null) {
+ $lang = $this->lang;
+
+ if ($server_id !== null) {
+ $this->server_id = $server_id;
+ }
+
+ $server_info = $this->getServerInfo($this->server_id);
+
+ if ($this->_no_db_connection || !isset($server_info['username'])) {
+ return null;
+ }
+
+ if ($this->data === null) {
+ $_connection = $this->getConnection($database, $this->server_id);
+
+ // Get the name of the database driver we need to use.
+ // The description of the server is returned in $platform.
+ $_type = $_connection->getDriver($platform);
+
+ //\PC::debug(['type' => $_type, 'platform' => $platform], 'driver type');
+
+ if ($_type === null) {
+ die(sprintf($lang['strpostgresqlversionnotsupported'], $this->postgresqlMinVer));
+ }
+ $_type = '\PHPPgAdmin\Database\\' . $_type;
+
+ $this->setServerInfo('platform', $platform, $this->server_id);
+ $this->setServerInfo('pgVersion', $_connection->conn->pgVersion, $this->server_id);
+
+ // Create a database wrapper class for easy manipulation of the
+ // connection.
+
+ $this->data = new $_type($_connection->conn);
+ $this->data->platform = $_connection->platform;
+ $this->data->server_info = $server_info;
+ $this->data->conf = $this->conf;
+ $this->data->lang = $this->lang;
+
+ /* we work on UTF-8 only encoding */
+ $this->data->execute("SET client_encoding TO 'UTF-8'");
+
+ if ($this->data->hasByteaHexDefault()) {
+ $this->data->execute("SET bytea_output TO escape");
+ }
+
+ }
+
+ if ($this->_no_db_connection === false && $this->getDatabase() !== null && isset($_REQUEST['schema'])) {
+ $status = $this->data->setSchema($_REQUEST['schema']);
+
+ if ($status != 0) {
+ \Kint::dump($status);
+ echo $this->lang['strbadschema'];
+ exit;
+ }
+ }
+
+ return $this->data;
+ }
function getConnection($database = '', $server_id = null) {
$lang = $this->lang;
@@ -79,8 +177,7 @@ class Misc {
if ($server_id !== null) {
$this->server_id = $server_id;
}
- $server_info = $this->getServerInfo($this->server_id);
-
+ $server_info = $this->getServerInfo($this->server_id);
$database_to_use = $this->getDatabase($database);
// Perform extra security checks if this config option is set
if ($this->conf['extra_login_security']) {
@@ -121,33 +218,6 @@ class Misc {
return $this->_connection;
}
- /**
- * sets $_no_bottom_link boolean value
- * @param boolean $flag [description]
- */
- function setNoBottomLink($flag) {
- $this->_no_bottom_link = boolval($flag);
- return $this;
- }
-
- /**
- * sets $_no_db_connection boolean value, allows to render scripts that do not need an active session
- * @param boolean $flag [description]
- */
- function setNoDBConnection($flag) {
- $this->_no_db_connection = boolval($flag);
- return $this;
- }
-
- function setNoOutput($flag) {
- $this->_no_output = boolval($flag);
- return $this;
- }
-
- function getNoDBConnection() {
- return $this->_no_db_connection;
- }
-
function getDatabase($database = '') {
if ($this->server_id === null && !isset($_REQUEST['database'])) {
@@ -189,65 +259,6 @@ class Misc {
return $this;
}
- /**
- * Creates a database accessor
- */
- function getDatabaseAccessor($database = '', $server_id = null) {
- $lang = $this->lang;
-
- if ($server_id !== null) {
- $this->server_id = $server_id;
- }
-
- $server_info = $this->getServerInfo($this->server_id);
-
- if ($this->_no_db_connection || !isset($server_info['username'])) {
- return null;
- }
-
- if ($this->data === null) {
- $_connection = $this->getConnection($database, $this->server_id);
-
- // Get the name of the database driver we need to use.
- // The description of the server is returned in $platform.
- $_type = $_connection->getDriver($platform);
- if ($_type === null) {
- printf($lang['strpostgresqlversionnotsupported'], $this->postgresqlMinVer);
- exit;
- }
- $_type = '\PHPPgAdmin\Database\\' . $_type;
-
- $this->setServerInfo('platform', $platform, $this->server_id);
- $this->setServerInfo('pgVersion', $_connection->conn->pgVersion, $this->server_id);
-
- // Create a database wrapper class for easy manipulation of the
- // connection.
-
- $this->data = new $_type($_connection->conn);
- $this->data->platform = $_connection->platform;
-
- /* we work on UTF-8 only encoding */
- $this->data->execute("SET client_encoding TO 'UTF-8'");
-
- if ($this->data->hasByteaHexDefault()) {
- $this->data->execute("SET bytea_output TO escape");
- }
-
- }
-
- if ($this->_no_db_connection === false && $this->getDatabase() !== null && isset($_REQUEST['schema'])) {
- $status = $this->data->setSchema($_REQUEST['schema']);
-
- if ($status != 0) {
- \Kint::dump($status);
- echo $this->lang['strbadschema'];
- exit;
- }
- }
-
- return $this->data;
- }
-
public static function _cmp_desc($a, $b) {
return strcmp($a['desc'], $b['desc']);
}
@@ -263,10 +274,16 @@ class Misc {
}
function setThemeConf($theme_conf) {
+
$this->conf['theme'] = $theme_conf;
+ //\PC::debug(['theme_conf' => $theme_conf, 'this->theme' => $this->conf['theme']], 'setThemeConf');
$this->view->offsetSet('theme', $this->conf['theme']);
return $this;
}
+
+ function getConf() {
+ return $this->conf;
+ }
/**
* Sets the href tracking variable
*/
diff --git a/src/classes/PluginManager.php b/src/classes/PluginManager.php
index bc8b76d9..4965c823 100644
--- a/src/classes/PluginManager.php
+++ b/src/classes/PluginManager.php
@@ -10,8 +10,8 @@ class PluginManager {
/**
* Attributes
*/
- private $plugins_list = array();
- private $available_hooks = array(
+ private $plugins_list = [];
+ private $available_hooks = [
'head',
'toplinks',
'tabs',
@@ -20,22 +20,19 @@ class PluginManager {
'actionbuttons',
'tree',
'logout',
- );
- private $actions = array();
- private $hooks = array();
+ ];
+ private $actions = [];
+ private $hooks = [];
/**
* Register the plugins
* @param $this->language - Language that have been used.
*/
- function __construct(\Slim\App $app) {
- $this->app = $app;
-
- $container = $app->getContainer();
+ function __construct(\Slim\Container $container) {
$this->language = $container->get('language');
- $this->lang = $container->get('lang');
- $this->conf = $container->get('conf');
+ $this->lang = $container->get('lang');
+ $this->conf = $container->get('conf');
if (!isset($this->conf['plugins'])) {
return;
@@ -72,7 +69,7 @@ class PluginManager {
//The $plugin_name is the identification of the plugin.
//Example: PluginExample is the identification for PluginExample
//It will be used to get a specific plugin from the plugins_list.
- $plugin_name = $plugin->get_name();
+ $plugin_name = $plugin->get_name();
$this->plugins_list[$plugin_name] = $plugin;
//Register the plugin's functions
@@ -86,7 +83,7 @@ class PluginManager {
}
//Register the plugin's actions
- $actions = $plugin->get_actions();
+ $actions = $plugin->get_actions();
$this->actions[$plugin_name] = $actions;
}
@@ -109,7 +106,7 @@ class PluginManager {
$plugin = $this->plugins_list[$plugin_name];
foreach ($functions as $function) {
if (method_exists($plugin, $function)) {
- call_user_func(array($plugin, $function), $function_args);
+ call_user_func([$plugin, $function], $function_args);
}
}
}
@@ -132,7 +129,7 @@ class PluginManager {
// Check if the plugin's method exists and if this method is an declared action.
if (method_exists($plugin, $action) and in_array($action, $this->actions[$plugin_name])) {
- call_user_func(array($plugin, $action));
+ call_user_func([$plugin, $action]);
} else {
// Show an error and stop the application
printf($this->lang['stractionnotfound'] . "\t\n", $action, $plugin_name);
diff --git a/src/controllers/BaseController.php b/src/controllers/BaseController.php
index 7326fd7f..788a17b9 100644
--- a/src/controllers/BaseController.php
+++ b/src/controllers/BaseController.php
@@ -28,16 +28,19 @@ class BaseController {
/* Constructor */
function __construct(\Slim\Container $container) {
- $this->container = $container;
- $this->lang = $container->get('lang');
- $this->conf = $container->get('conf');
+ $this->container = $container;
+ $this->lang = $container->get('lang');
+
$this->view = $container->get('view');
$this->plugin_manager = $container->get('plugin_manager');
$this->msg = $container->get('msg');
$this->appLangFiles = $container->get('appLangFiles');
- $this->misc = $container->get('misc');
- $this->appThemes = $container->get('appThemes');
- $this->action = $container->get('action');
+
+ $this->misc = $container->get('misc');
+ $this->conf = $this->misc->getConf();
+
+ $this->appThemes = $container->get('appThemes');
+ $this->action = $container->get('action');
$msg = $container->get('msg');
if ($this->misc->getNoDBConnection() === false) {
diff --git a/src/controllers/ServerController.php b/src/controllers/ServerController.php
index 994fe602..9a25d908 100644
--- a/src/controllers/ServerController.php
+++ b/src/controllers/ServerController.php
@@ -16,12 +16,11 @@ class ServerController extends BaseController {
/* Constructor */
function __construct(\Slim\Container $container) {
- parent::__construct($container);
+ $this->misc = $container->get('misc');
- // Prevent timeouts on large exports (non-safe mode only)
- if (!ini_get('safe_mode')) {
- set_time_limit(0);
- }
+ $this->misc->setNoDBConnection(true);
+
+ parent::__construct($container);
}
function doLogout() {
@@ -165,7 +164,7 @@ class ServerController extends BaseController {
// logged into the server.
'branch' => Decorator::field('branch'),
];
- \PC::debug(['attrs' => $attrs, 'nodes' => $nodes], __CLASS__ . '::' . __METHOD__);
+
return $misc->printTree($nodes, $attrs, 'servers');
}
diff --git a/src/database/ADODB_base.php b/src/database/ADODB_base.php
index fe052a75..9a10ec6e 100644
--- a/src/database/ADODB_base.php
+++ b/src/database/ADODB_base.php
@@ -236,10 +236,10 @@ class ADODB_base {
* @return -2 if a referential constraint is violated
* @return -3 on no rows deleted
*/
- function update($table, $vars, $where, $nulls = array()) {
+ function update($table, $vars, $where, $nulls = []) {
$this->fieldClean($table);
- $setClause = '';
+ $setClause = '';
$whereClause = '';
// Populate the syntax arrays
@@ -362,8 +362,8 @@ class ADODB_base {
// Pick out array entries by carefully parsing. This is necessary in order
// to cope with double quotes and commas, etc.
- $elements = array();
- $i = $j = 0;
+ $elements = [];
+ $i = $j = 0;
$in_quotes = false;
while ($i < strlen($arr)) {
// If current char is a double quote and it's not escaped, then
@@ -374,7 +374,7 @@ class ADODB_base {
} elseif ($char == ',' && !$in_quotes) {
// Add text so far to the array
$elements[] = substr($arr, $j, $i - $j);
- $j = $i + 1;
+ $j = $i + 1;
}
$i++;
}
@@ -386,9 +386,9 @@ class ADODB_base {
for ($i = 0; $i < sizeof($elements); $i++) {
$v = $elements[$i];
if (strpos($v, '"') === 0) {
- $v = substr($v, 1, strlen($v) - 2);
- $v = str_replace('\\"', '"', $v);
- $v = str_replace('\\\\', '\\', $v);
+ $v = substr($v, 1, strlen($v) - 2);
+ $v = str_replace('\\"', '"', $v);
+ $v = str_replace('\\\\', '\\', $v);
$elements[$i] = $v;
}
}
diff --git a/src/database/Connection.php b/src/database/Connection.php
index 93a61df0..dcb3eb4b 100755
--- a/src/database/Connection.php
+++ b/src/database/Connection.php
@@ -63,7 +63,7 @@ class Connection {
if (!isset($version)) {
$adodb = new ADODB_base($this->conn);
- $sql = "SELECT VERSION() AS version";
+ $sql = "SELECT VERSION() AS version";
$field = $adodb->selectField($sql, 'version');
// Check the platform, if it's mingw, set it
@@ -83,29 +83,33 @@ class Connection {
// Detect version and choose appropriate database driver
switch (substr($version, 0, 3)) {
- case '9.4':return 'Postgres';
- break;
- case '9.3':return 'Postgres93';
- break;
- case '9.2':return 'Postgres92';
- break;
- case '9.1':return 'Postgres91';
- break;
- case '9.0':return 'Postgres90';
- break;
- case '8.4':return 'Postgres84';
- break;
- case '8.3':return 'Postgres83';
- break;
- case '8.2':return 'Postgres82';
- break;
- case '8.1':return 'Postgres81';
- break;
- case '8.0':
- case '7.5':return 'Postgres80';
- break;
- case '7.4':return 'Postgres74';
- break;
+ case '9.6':return 'Postgres';
+ break;
+ case '9.5':return 'Postgres95';
+ break;
+ case '9.4':return 'Postgres94';
+ break;
+ case '9.3':return 'Postgres93';
+ break;
+ case '9.2':return 'Postgres92';
+ break;
+ case '9.1':return 'Postgres91';
+ break;
+ case '9.0':return 'Postgres90';
+ break;
+ case '8.4':return 'Postgres84';
+ break;
+ case '8.3':return 'Postgres83';
+ break;
+ case '8.2':return 'Postgres82';
+ break;
+ case '8.1':return 'Postgres81';
+ break;
+ case '8.0':
+ case '7.5':return 'Postgres80';
+ break;
+ case '7.4':return 'Postgres74';
+ break;
}
/* All <7.4 versions are not supported */
diff --git a/src/database/Postgres.php b/src/database/Postgres.php
index c6df059a..e30af18a 100755
--- a/src/database/Postgres.php
+++ b/src/database/Postgres.php
@@ -243,7 +243,7 @@ class Postgres extends ADODB_base {
* @param $extras An array of attributes name as key and attributes' values as value
*/
function printField($name, $value, $type, $extras = []) {
- global $lang;
+ $lang = $this->lang;
// Determine actions string
$extra_str = '';
@@ -458,9 +458,8 @@ class Postgres extends ADODB_base {
* @return A list of databases, sorted alphabetically
*/
function getDatabases($currentdatabase = NULL) {
- global $conf, $misc;
-
- $server_info = $misc->getServerInfo();
+ $conf = $this->conf;
+ $server_info = $this->server_info;
if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) {
$username = $server_info['username'];
@@ -715,7 +714,7 @@ class Postgres extends ADODB_base {
* @return A recordset
*/
function findObject($term, $filter) {
- global $conf;
+ $conf = $this->conf;
/*about escaping:
* SET standard_conforming_string is not available before 8.2
@@ -874,7 +873,7 @@ class Postgres extends ADODB_base {
* @return All schemas, sorted alphabetically
*/
function getSchemas() {
- global $conf;
+ $conf = $this->conf;
if (!$conf['show_system']) {
$where = "WHERE nspname NOT LIKE 'pg@_%' ESCAPE '@' AND nspname != 'information_schema'";
@@ -5082,7 +5081,7 @@ class Postgres extends ADODB_base {
* @return All casts
*/
function getCasts() {
- global $conf;
+ $conf = $this->conf;
if ($conf['show_system']) {
$where = '';
@@ -6234,7 +6233,7 @@ class Postgres extends ADODB_base {
* @return A recordset
*/
function getLanguages($all = false) {
- global $conf;
+ $conf = $this->conf;
if ($conf['show_system'] || $all) {
$where = '';
@@ -7520,7 +7519,7 @@ class Postgres extends ADODB_base {
* @return A recordset
*/
function getTablespaces($all = false) {
- global $conf;
+ $conf = $this->conf;
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, pg_catalog.pg_tablespace_location(oid) as spclocation,
(SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment
@@ -7822,7 +7821,7 @@ class Postgres extends ADODB_base {
*/
function getLocks() {
- global $conf;
+ $conf = $this->conf;
if (!$conf['show_system']) {
$where = 'AND pn.nspname NOT LIKE $$pg\_%$$';
@@ -7983,10 +7982,9 @@ class Postgres extends ADODB_base {
* @return True for general success, false on any failure.
*/
function executeScript($name, $callback = null) {
- global $data;
// This whole function isn't very encapsulated, but hey...
- $conn = $data->conn->_connectionID;
+ $conn = $this->conn->_connectionID;
if (!is_uploaded_file($_FILES[$name]['tmp_name'])) {
return false;
}
diff --git a/src/database/Postgres74.php b/src/database/Postgres74.php
index 0af4d449..38cccef1 100644
--- a/src/database/Postgres74.php
+++ b/src/database/Postgres74.php
@@ -12,15 +12,15 @@ class Postgres74 extends Postgres80 {
var $major_version = 7.4;
// List of all legal privileges that can be applied to different types
// of objects.
- var $privlist = array(
- 'table' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'view' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'sequence' => array('SELECT', 'UPDATE', 'ALL PRIVILEGES'),
- 'database' => array('CREATE', 'TEMPORARY', 'ALL PRIVILEGES'),
- 'function' => array('EXECUTE', 'ALL PRIVILEGES'),
- 'language' => array('USAGE', 'ALL PRIVILEGES'),
- 'schema' => array('CREATE', 'USAGE', 'ALL PRIVILEGES'),
- );
+ var $privlist = [
+ 'table' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'],
+ 'database' => ['CREATE', 'TEMPORARY', 'ALL PRIVILEGES'],
+ 'function' => ['EXECUTE', 'ALL PRIVILEGES'],
+ 'language' => ['USAGE', 'ALL PRIVILEGES'],
+ 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'],
+ ];
// Help functions
@@ -62,9 +62,8 @@ class Postgres74 extends Postgres80 {
* @return A list of databases, sorted alphabetically
*/
function getDatabases($currentdatabase = NULL) {
- global $conf, $misc;
-
- $server_info = $misc->getServerInfo();
+ $conf = $this->conf;
+ $server_info = $this->server_info;
if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) {
$username = $server_info['username'];
@@ -105,7 +104,7 @@ class Postgres74 extends Postgres80 {
* @return A recordset
*/
function findObject($term, $filter) {
- global $conf;
+ $conf = $this->conf;
/*about escaping:
* SET standard_conforming_string is not available before 8.2
@@ -125,10 +124,10 @@ class Postgres74 extends Postgres80 {
if (!$conf['show_system']) {
// XXX: The mention of information_schema here is in the wrong place, but
// it's the quickest fix to exclude the info schema from 7.4
- $where = " AND pn.nspname NOT LIKE 'pg\\\\_%' AND pn.nspname != 'information_schema'";
+ $where = " AND pn.nspname NOT LIKE 'pg\\\\_%' AND pn.nspname != 'information_schema'";
$lan_where = "AND pl.lanispl";
} else {
- $where = '';
+ $where = '';
$lan_where = '';
}
@@ -250,7 +249,7 @@ class Postgres74 extends Postgres80 {
* @return A recordset
*/
function getLocks() {
- global $conf;
+ $conf = $this->conf;
if (!$conf['show_system']) {
$where = "AND pn.nspname NOT LIKE 'pg\\\\_%'";
@@ -590,7 +589,7 @@ class Postgres74 extends Postgres80 {
* @return All casts
*/
function getCasts() {
- global $conf;
+ $conf = $this->conf;
if ($conf['show_system']) {
$where = '';
diff --git a/src/database/Postgres80.php b/src/database/Postgres80.php
index 37451b11..3ac709bf 100644
--- a/src/database/Postgres80.php
+++ b/src/database/Postgres80.php
@@ -12,7 +12,7 @@ class Postgres80 extends Postgres81 {
// Map of database encoding names to HTTP encoding names. If a
// database encoding does not appear in this list, then its HTTP
// encoding name is the same as its database encoding name.
- var $codemap = array(
+ var $codemap = [
'ALT' => 'CP866',
'EUC_CN' => 'GB2312',
'EUC_JP' => 'EUC-JP',
@@ -42,7 +42,7 @@ class Postgres80 extends Postgres81 {
'WIN' => 'CP1251',
'WIN874' => 'CP874',
'WIN1256' => 'CP1256',
- );
+ ];
// Help functions
@@ -58,9 +58,8 @@ class Postgres80 extends Postgres81 {
* @return A list of databases, sorted alphabetically
*/
function getDatabases($currentdatabase = NULL) {
- global $conf, $misc;
-
- $server_info = $misc->getServerInfo();
+ $conf = $this->conf;
+ $server_info = $this->server_info;
if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) {
$username = $server_info['username'];
@@ -102,7 +101,7 @@ class Postgres80 extends Postgres81 {
* @return All schemas, sorted alphabetically
*/
function getSchemas() {
- global $conf;
+ $conf = $this->conf;
if (!$conf['show_system']) {
$where = "WHERE nspname NOT LIKE 'pg@_%' ESCAPE '@' AND nspname != 'information_schema'";
diff --git a/src/database/Postgres81.php b/src/database/Postgres81.php
index ddc81730..ba7c6650 100644
--- a/src/database/Postgres81.php
+++ b/src/database/Postgres81.php
@@ -11,19 +11,19 @@ class Postgres81 extends Postgres82 {
var $major_version = 8.1;
// List of all legal privileges that can be applied to different types
// of objects.
- var $privlist = array(
- 'table' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'view' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'sequence' => array('SELECT', 'UPDATE', 'ALL PRIVILEGES'),
- 'database' => array('CREATE', 'TEMPORARY', 'ALL PRIVILEGES'),
- 'function' => array('EXECUTE', 'ALL PRIVILEGES'),
- 'language' => array('USAGE', 'ALL PRIVILEGES'),
- 'schema' => array('CREATE', 'USAGE', 'ALL PRIVILEGES'),
- 'tablespace' => array('CREATE', 'ALL PRIVILEGES'),
- );
+ var $privlist = [
+ 'table' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'RULE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'],
+ 'database' => ['CREATE', 'TEMPORARY', 'ALL PRIVILEGES'],
+ 'function' => ['EXECUTE', 'ALL PRIVILEGES'],
+ 'language' => ['USAGE', 'ALL PRIVILEGES'],
+ 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'],
+ 'tablespace' => ['CREATE', 'ALL PRIVILEGES'],
+ ];
// List of characters in acl lists and the privileges they
// refer to.
- var $privmap = array(
+ var $privmap = [
'r' => 'SELECT',
'w' => 'UPDATE',
'a' => 'INSERT',
@@ -35,9 +35,9 @@ class Postgres81 extends Postgres82 {
'U' => 'USAGE',
'C' => 'CREATE',
'T' => 'TEMPORARY',
- );
+ ];
// Array of allowed index types
- var $typIndexes = array('BTREE', 'RTREE', 'GIST', 'HASH');
+ var $typIndexes = ['BTREE', 'RTREE', 'GIST', 'HASH'];
// Help functions
@@ -53,9 +53,8 @@ class Postgres81 extends Postgres82 {
* @return A list of databases, sorted alphabetically
*/
function getDatabases($currentdatabase = NULL) {
- global $conf, $misc;
-
- $server_info = $misc->getServerInfo();
+ $conf = $this->conf;
+ $server_info = $this->server_info;
if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) {
$username = $server_info['username'];
@@ -269,7 +268,7 @@ class Postgres81 extends Postgres82 {
* @return A recordset
*/
function getTablespaces($all = false) {
- global $conf;
+ $conf = $this->conf;
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation
FROM pg_catalog.pg_tablespace";
diff --git a/src/database/Postgres82.php b/src/database/Postgres82.php
index a0a93c53..e458ed20 100644
--- a/src/database/Postgres82.php
+++ b/src/database/Postgres82.php
@@ -11,10 +11,10 @@ class Postgres82 extends Postgres83 {
var $major_version = 8.2;
// Select operators
- var $selectOps = array('=' => 'i', '!=' => 'i', '<' => 'i', '>' => 'i', '<=' => 'i', '>=' => 'i', '<<' => 'i', '>>' => 'i', '<<=' => 'i', '>>=' => 'i',
+ var $selectOps = ['=' => 'i', '!=' => 'i', '<' => 'i', '>' => 'i', '<=' => 'i', '>=' => 'i', '<<' => 'i', '>>' => 'i', '<<=' => 'i', '>>=' => 'i',
'LIKE' => 'i', 'NOT LIKE' => 'i', 'ILIKE' => 'i', 'NOT ILIKE' => 'i', 'SIMILAR TO' => 'i',
'NOT SIMILAR TO' => 'i', '~' => 'i', '!~' => 'i', '~*' => 'i', '!~*' => 'i',
- 'IS NULL' => 'p', 'IS NOT NULL' => 'p', 'IN' => 'x', 'NOT IN' => 'x');
+ 'IS NULL' => 'p', 'IS NOT NULL' => 'p', 'IN' => 'x', 'NOT IN' => 'x'];
// Help functions
@@ -30,7 +30,7 @@ class Postgres82 extends Postgres83 {
* @return A recordset
*/
function getLocks() {
- global $conf;
+ $conf = $this->conf;
if (!$conf['show_system']) {
$where = 'AND pn.nspname NOT LIKE $$pg\_%$$';
@@ -59,7 +59,7 @@ class Postgres82 extends Postgres83 {
if (!empty($name) && ($seqrs->fields['seqname'] != $name)) {
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
- $sql = "ALTER TABLE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" RENAME TO \"{$name}\"";
+ $sql = "ALTER TABLE \"{$f_schema}\".\"{$seqrs->fields['seqname']}\" RENAME TO \"{$name}\"";
$status = $this->execute($sql);
if ($status == 0) {
$seqrs->fields['seqname'] = $name;
@@ -86,7 +86,7 @@ class Postgres82 extends Postgres83 {
if (!empty($name) && ($name != $vwrs->fields['relname'])) {
$f_schema = $this->_schema;
$this->fieldClean($f_schema);
- $sql = "ALTER TABLE \"{$f_schema}\".\"{$vwrs->fields['relname']}\" RENAME TO \"{$name}\"";
+ $sql = "ALTER TABLE \"{$f_schema}\".\"{$vwrs->fields['relname']}\" RENAME TO \"{$name}\"";
$status = $this->execute($sql);
if ($status == 0) {
$vwrs->fields['relname'] = $name;
diff --git a/src/database/Postgres83.php b/src/database/Postgres83.php
index 63b22fb0..12dfd02f 100644
--- a/src/database/Postgres83.php
+++ b/src/database/Postgres83.php
@@ -12,19 +12,19 @@ class Postgres83 extends Postgres84 {
// List of all legal privileges that can be applied to different types
// of objects.
- var $privlist = array(
- 'table' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'view' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'sequence' => array('SELECT', 'UPDATE', 'ALL PRIVILEGES'),
- 'database' => array('CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'),
- 'function' => array('EXECUTE', 'ALL PRIVILEGES'),
- 'language' => array('USAGE', 'ALL PRIVILEGES'),
- 'schema' => array('CREATE', 'USAGE', 'ALL PRIVILEGES'),
- 'tablespace' => array('CREATE', 'ALL PRIVILEGES'),
- );
+ var $privlist = [
+ 'table' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'],
+ 'database' => ['CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'],
+ 'function' => ['EXECUTE', 'ALL PRIVILEGES'],
+ 'language' => ['USAGE', 'ALL PRIVILEGES'],
+ 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'],
+ 'tablespace' => ['CREATE', 'ALL PRIVILEGES'],
+ ];
// List of characters in acl lists and the privileges they
// refer to.
- var $privmap = array(
+ var $privmap = [
'r' => 'SELECT',
'w' => 'UPDATE',
'a' => 'INSERT',
@@ -37,7 +37,7 @@ class Postgres83 extends Postgres84 {
'C' => 'CREATE',
'T' => 'TEMPORARY',
'c' => 'CONNECT',
- );
+ ];
// Help functions
@@ -55,9 +55,8 @@ class Postgres83 extends Postgres84 {
* @return A list of databases, sorted alphabetically
*/
function getDatabases($currentdatabase = NULL) {
- global $conf, $misc;
-
- $server_info = $misc->getServerInfo();
+ $conf = $this->conf;
+ $server_info = $this->server_info;
if (isset($conf['owned_only']) && $conf['owned_only'] && !$this->isSuperUser()) {
$username = $server_info['username'];
@@ -261,7 +260,7 @@ class Postgres83 extends Postgres84 {
c.relname = '{$table}' AND n.nspname = '{$c_schema}'
");
- return $this->deleteRow('pg_autovacuum', array('vacrelid' => $rs->fields['oid']), 'pg_catalog');
+ return $this->deleteRow('pg_autovacuum', ['vacrelid' => $rs->fields['oid']], 'pg_catalog');
}
// Sequence functions
diff --git a/src/database/Postgres84.php b/src/database/Postgres84.php
index bbdb3a09..4241bb45 100755
--- a/src/database/Postgres84.php
+++ b/src/database/Postgres84.php
@@ -12,17 +12,17 @@ class Postgres84 extends Postgres90 {
// List of all legal privileges that can be applied to different types
// of objects.
- var $privlist = array(
- 'table' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'view' => array('SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'),
- 'sequence' => array('SELECT', 'UPDATE', 'ALL PRIVILEGES'),
- 'database' => array('CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'),
- 'function' => array('EXECUTE', 'ALL PRIVILEGES'),
- 'language' => array('USAGE', 'ALL PRIVILEGES'),
- 'schema' => array('CREATE', 'USAGE', 'ALL PRIVILEGES'),
- 'tablespace' => array('CREATE', 'ALL PRIVILEGES'),
- 'column' => array('SELECT', 'INSERT', 'UPDATE', 'REFERENCES', 'ALL PRIVILEGES'),
- );
+ var $privlist = [
+ 'table' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'view' => ['SELECT', 'INSERT', 'UPDATE', 'DELETE', 'REFERENCES', 'TRIGGER', 'ALL PRIVILEGES'],
+ 'sequence' => ['SELECT', 'UPDATE', 'ALL PRIVILEGES'],
+ 'database' => ['CREATE', 'TEMPORARY', 'CONNECT', 'ALL PRIVILEGES'],
+ 'function' => ['EXECUTE', 'ALL PRIVILEGES'],
+ 'language' => ['USAGE', 'ALL PRIVILEGES'],
+ 'schema' => ['CREATE', 'USAGE', 'ALL PRIVILEGES'],
+ 'tablespace' => ['CREATE', 'ALL PRIVILEGES'],
+ 'column' => ['SELECT', 'INSERT', 'UPDATE', 'REFERENCES', 'ALL PRIVILEGES'],
+ ];
// Help functions
@@ -68,7 +68,7 @@ class Postgres84 extends Postgres90 {
* @return A recordset
*/
function findObject($term, $filter) {
- global $conf;
+ $conf = $this->conf;
/*about escaping:
* SET standard_conforming_string is not available before 8.2
@@ -88,10 +88,10 @@ class Postgres84 extends Postgres90 {
if (!$conf['show_system']) {
// XXX: The mention of information_schema here is in the wrong place, but
// it's the quickest fix to exclude the info schema from 7.4
- $where = " AND pn.nspname NOT LIKE \$_PATERN_\$pg\_%\$_PATERN_\$ AND pn.nspname != 'information_schema'";
+ $where = " AND pn.nspname NOT LIKE \$_PATERN_\$pg\_%\$_PATERN_\$ AND pn.nspname != 'information_schema'";
$lan_where = "AND pl.lanispl";
} else {
- $where = '';
+ $where = '';
$lan_where = '';
}
diff --git a/src/database/Postgres91.php b/src/database/Postgres91.php
index e4b48114..93abd11b 100755
--- a/src/database/Postgres91.php
+++ b/src/database/Postgres91.php
@@ -49,7 +49,7 @@ class Postgres91 extends Postgres92 {
* @return A recordset
*/
function getTablespaces($all = false) {
- global $conf;
+ $conf = $this->conf;
$sql = "SELECT spcname, pg_catalog.pg_get_userbyid(spcowner) AS spcowner, spclocation,
(SELECT description FROM pg_catalog.pg_shdescription pd WHERE pg_tablespace.oid=pd.objoid AND pd.classoid='pg_tablespace'::regclass) AS spccomment
diff --git a/src/database/Postgres94.php b/src/database/Postgres94.php
new file mode 100644
index 00000000..1a6b0c91
--- /dev/null
+++ b/src/database/Postgres94.php
@@ -0,0 +1,19 @@
+<?php
+namespace PHPPgAdmin\Database;
+/**
+ * PostgreSQL 9.4 support
+ *
+ */
+
+class Postgres94 extends Postgres {
+
+ var $major_version = 9.4;
+
+ // Help functions
+
+ function getHelpPages() {
+ include_once './help/PostgresDoc94.php';
+ return $this->help_page;
+ }
+
+}
diff --git a/src/database/Postgres95.php b/src/database/Postgres95.php
new file mode 100644
index 00000000..f7317fae
--- /dev/null
+++ b/src/database/Postgres95.php
@@ -0,0 +1,19 @@
+<?php
+namespace PHPPgAdmin\Database;
+/**
+ * PostgreSQL 9.5 support
+ *
+ */
+
+class Postgres95 extends Postgres {
+
+ var $major_version = 9.5;
+
+ // Help functions
+
+ function getHelpPages() {
+ include_once './help/PostgresDoc95.php';
+ return $this->help_page;
+ }
+
+}
diff --git a/src/lib.inc.php b/src/lib.inc.php
index eefef9c0..32734b5b 100644
--- a/src/lib.inc.php
+++ b/src/lib.inc.php
@@ -7,6 +7,10 @@
*/
DEFINE('BASE_PATH', dirname(__DIR__));
+DEFINE('THEME_PATH', BASE_PATH . "/src/themes");
+// Enforce PHP environment
+ini_set('arg_separator.output', '&amp;');
+
ini_set('error_log', BASE_PATH . '/temp/logs/phppga.php_error.log');
$debugmode = true;
@@ -16,68 +20,33 @@ if ($debugmode) {
error_reporting(E_ALL);
}
-require_once BASE_PATH . '/src/errorhandler.inc.php';
-
-if (!defined('ADODB_ERROR_HANDLER_TYPE')) {
- define('ADODB_ERROR_HANDLER_TYPE', E_USER_ERROR);
-}
-if (!defined('ADODB_ERROR_HANDLER')) {
- define('ADODB_ERROR_HANDLER', 'Error_Handler');
-}
-
require_once BASE_PATH . '/vendor/autoload.php';
-Kint::enabled(true);
-
-$handler = PhpConsole\Handler::getInstance();
-$handler->start(); // initialize handlers*/
-PhpConsole\Helper::register(); // it will register global PC class
-
-// Check to see if the configuration file exists, if not, explain
-if (file_exists(BASE_PATH . '/config.inc.php')) {
- $conf = [];
- include BASE_PATH . '/config.inc.php';
-} else {
- die('Configuration error: Copy config.inc.php-dist to config.inc.php and edit appropriately.');
-
-}
-
-// Check if a given server is "greedy" in which case the $_REQUEST['server'] parameter is ignored
-$serverstoshow = [];
-foreach ($conf['servers'] as $server) {
- if (isset($server['forcehost']) && $server['forcehost'] === true) {
- $serverstoshow = [$server];
- break;
- } else {
- $serverstoshow[] = $server;
- }
-}
-$conf['servers'] = $serverstoshow;
-// Configuration file version. If this is greater than that in config.inc.php, then
-// the app will refuse to run. This and $conf['version'] should be incremented whenever
-// backwards incompatible changes are made to config.inc.php-dist.
-$conf['base_version'] = 60;
-
-include_once BASE_PATH . '/src/translations.php';
-
-// Create Misc class references
-
// Start session (if not auto-started)
if (!ini_get('session.auto_start')) {
session_name('PPA_ID');
session_start();
}
+$handler = PhpConsole\Handler::getInstance();
+$handler->start(); // initialize handlers*/
+PhpConsole\Helper::register(); // it will register global PC class
$config = [
'msg' => '',
- 'appLangFiles' => $appLangFiles,
- 'conf' => $conf,
- 'lang' => $lang,
- 'language' => $_language,
-
+ 'appThemes' => [
+ 'default' => 'Default',
+ 'cappuccino' => 'Cappuccino',
+ 'gotar' => 'Blue/Green',
+ 'bootstrap' => 'Bootstrap3',
+ ],
'settings' => [
'base_path' => BASE_PATH,
'debug' => $debugmode,
+
+ // Configuration file version. If this is greater than that in config.inc.php, then
+ // the app will refuse to run. This and $conf['version'] should be incremented whenever
+ // backwards incompatible changes are made to config.inc.php-dist.
+ 'base_version' => 60,
// Application version
'appVersion' => '6.0.0-alpha',
// Application name
@@ -96,7 +65,33 @@ $app = new \Slim\App($config);
// Fetch DI Container
$container = $app->getContainer();
-$container['plugin_manager'] = new \PHPPgAdmin\PluginManager($app);
+Kint::enabled(true);
+
+$container['conf'] = function ($c) {
+// Check to see if the configuration file exists, if not, explain
+ if (file_exists(BASE_PATH . '/config.inc.php')) {
+ $conf = [];
+ include BASE_PATH . '/config.inc.php';
+ } else {
+ die('Configuration error: Copy config.inc.php-dist to config.inc.php and edit appropriately.');
+
+ }
+
+ return $conf;
+};
+
+$container['lang'] = function ($c) {
+ include_once BASE_PATH . '/src/translations.php';
+
+ $c['appLangFiles'] = $appLangFiles;
+ $c['language'] = $_language;
+ return $lang;
+};
+
+$container['plugin_manager'] = function ($c) {
+ $plugin_manager = new \PHPPgAdmin\PluginManager($c);
+ return $plugin_manager;
+};
$container['serializer'] = function ($c) {
$serializerbuilder = \JMS\Serializer\SerializerBuilder::create();
@@ -123,36 +118,107 @@ $container['view'] = function ($c) {
return $view;
};
-$misc = new \PHPPgAdmin\Misc($app);
-$container['misc'] = $misc;
+// Create Misc class references
+$container['misc'] = function ($c) {
+
+ include_once BASE_PATH . '/src/errorhandler.inc.php';
-// 4. Check for theme by server/db/user
-$_server_info = $misc->getServerInfo();
+ if (!defined('ADODB_ERROR_HANDLER_TYPE')) {
+ define('ADODB_ERROR_HANDLER_TYPE', E_USER_ERROR);
+ }
+ if (!defined('ADODB_ERROR_HANDLER')) {
+ define('ADODB_ERROR_HANDLER', 'Error_Handler');
+ }
-include_once BASE_PATH . '/src/themes.php';
+ $misc = new \PHPPgAdmin\Misc($c);
+ $conf = $c->get('conf');
-$container['appThemes'] = $appThemes;
+ // 4. Check for theme by server/db/user
+ $_server_info = $misc->getServerInfo();
-$misc->setThemeConf($conf['theme']);
+ /* starting with PostgreSQL 9.0, we can set the application name */
+ if (isset($_server_info['pgVersion']) && $_server_info['pgVersion'] >= 9) {
+ putenv("PGAPPNAME=" . $c->get('settings')['appName'] . '_' . $c->get('settings')['appVersion']);
+ }
-// This has to be deferred until after stripVar above
-$misc->setHREF();
-$misc->setForm();
+ $themefolders = [];
+ if ($gestor = opendir(THEME_PATH)) {
-// Enforce PHP environment
-ini_set('arg_separator.output', '&amp;');
+ /* Esta es la forma correcta de iterar sobre el directorio. */
+ while (false !== ($file = readdir($gestor))) {
+ if ($file == '.' || $file == '..') {
+ continue;
+ }
-// Check for config file version mismatch
-if (!isset($conf['version']) || $conf['base_version'] > $conf['version']) {
- echo $lang['strbadconfig'];
- exit;
-}
+ $folder = THEME_PATH . DIRECTORY_SEPARATOR . $file;
+ if (is_dir($folder) && is_file($folder . DIRECTORY_SEPARATOR . 'global.css')) {
+ $themefolders[$file] = $folder;
-// Check database support is properly compiled in
-if (!function_exists('pg_connect')) {
- echo $lang['strnotloaded'];
- exit;
-}
+ }
+ }
+ closedir($gestor);
+ }
+
+ //\PC::debug($themefolders, 'themefolders');
+ /* select the theme */
+ unset($_theme);
+
+ // List of themes
+ if (!isset($conf['theme'])) {
+ $conf['theme'] = 'default';
+ }
+ // 1. Check for the theme from a request var
+ if (isset($_REQUEST['theme']) && array_key_exists($_REQUEST['theme'], $themefolders)) {
+ $_theme = $_REQUEST['theme'];
+
+ } else if (!isset($_theme) && isset($_SESSION['ppaTheme']) && array_key_exists($_SESSION['ppaTheme'], $themefolders)) {
+ // 2. Check for theme session var
+ $_theme = $_SESSION['ppaTheme'];
+ } else if (!isset($_theme) && isset($_COOKIE['ppaTheme']) && array_key_exists($_COOKIE['ppaTheme'], $themefolders)) {
+ // 3. Check for theme in cookie var
+ $_theme = $_COOKIE['ppaTheme'];
+ }
+
+ if (!isset($_theme) && !is_null($_server_info) && array_key_exists('theme', $_server_info)) {
+
+ $server_theme = $_server_info['theme'];
+
+ if (isset($server_theme['default']) && array_key_exists($server_theme['default'], $themefolders)) {
+ $_theme = $server_theme['default'];
+ }
+
+ if (isset($_REQUEST['database'])
+ && isset($server_theme['db'][$_REQUEST['database']])
+ && array_key_exists($server_theme['db'][$_REQUEST['database']], $themefolders)
+
+ ) {
+ $_theme = $server_theme['db'][$_REQUEST['database']];
+ }
+
+ if (isset($_server_info['username'])
+ && isset($server_theme['user'][$_server_info['username']])
+ && array_key_exists($server_theme['user'][$_server_info['username']], $themefolders)
+ ) {
+ $_theme = $server_theme['user'][$_server_info['username']];
+ }
+
+ }
+ if (isset($_theme)) {
+ /* save the selected theme in cookie for a year */
+ setcookie('ppaTheme', $_theme, time() + 31536000, '/');
+ $_SESSION['ppaTheme'] = $_theme;
+ $conf['theme'] = $_theme;
+ }
+ //\PC::debug($conf['theme'], 'conf.theme');
+
+ $misc->setThemeConf($conf['theme']);
+
+ // This has to be deferred until after stripVar above
+ $misc->setHREF();
+ $misc->setForm();
+
+ return $misc;
+};
$container['action'] = (isset($_REQUEST['action'])) ? $_REQUEST['action'] : '';
diff --git a/src/plugins/GuiControl/plugin.php b/src/plugins/GuiControl/plugin.php
index 44669362..aacb52da 100644
--- a/src/plugins/GuiControl/plugin.php
+++ b/src/plugins/GuiControl/plugin.php
@@ -1,7 +1,6 @@
<?php
-require_once('classes/Plugin.php');
-class GuiControl extends Plugin {
+class GuiControl extends \PHPPgAdmin\Plugin {
/**
* Attributes
@@ -34,14 +33,14 @@ class GuiControl extends Plugin {
* @return $hooks
*/
function get_hooks() {
- $hooks = array(
- 'toplinks' => array('filer_toplinks'),
- 'tabs' => array('filter_tabs'),
- 'trail' => array('filter_trail'),
- 'navlinks' => array('filter_navlinks'),
- 'actionbuttons' => array('filter_actionbuttons'),
- 'tree' => array('filter_tree')
- );
+ $hooks = [
+ 'toplinks' => ['filer_toplinks'],
+ 'tabs' => ['filter_tabs'],
+ 'trail' => ['filter_trail'],
+ 'navlinks' => ['filter_navlinks'],
+ 'actionbuttons' => ['filter_actionbuttons'],
+ 'tree' => ['filter_tree'],
+ ];
return $hooks;
}
@@ -57,89 +56,106 @@ class GuiControl extends Plugin {
* @return $actions
*/
function get_actions() {
- $actions = array(
+ $actions = [
'filer_toplinks',
'filter_tabs',
'filter_trail',
'filter_navlinks',
'filter_actionbuttons',
'filter_tree',
- );
+ ];
return $actions;
}
- function filer_toplinks(&$f_params) {
- if (!isset($this->conf['top_links']))
- return;
+ function filer_toplinks(&$f_params) {
+ if (!isset($this->conf['top_links'])) {
+ return;
+ }
- $top_links = &$f_params['toplinks'];
+ $top_links = &$f_params['toplinks'];
- foreach ($this->conf['top_links'] as $link => $enabled)
- if (isset ($top_links[$link])
- && ($enabled === false)
- )
- unset($top_links[$link]);
+ foreach ($this->conf['top_links'] as $link => $enabled) {
+ if (isset($top_links[$link])
+ && ($enabled === false)
+ ) {
+ unset($top_links[$link]);
+ }
+ }
- return;
- }
+ return;
+ }
function filter_tabs(&$f_params) {
- $section = $f_params['section'];
- $tabs = &$f_params['tabs'];
-
- if (!isset($this->conf['tab_links'][$section]))
- return;
-
- foreach ($this->conf['tab_links'][$section] as $link => $enabled)
- if (isset ($tabs[$link])
- && ($enabled === false)
- )
- unset($tabs[$link]);
- return;
- }
-
+ $section = $f_params['section'];
+ $tabs = &$f_params['tabs'];
+
+ if (!isset($this->conf['tab_links'][$section])) {
+ return;
+ }
+
+ foreach ($this->conf['tab_links'][$section] as $link => $enabled) {
+ if (isset($tabs[$link])
+ && ($enabled === false)
+ ) {
+ unset($tabs[$link]);
+ }
+ }
+
+ return;
+ }
+
function filter_trail(&$f_params) {
- if (!isset($this->conf['trail_links']))
- return;
+ if (!isset($this->conf['trail_links'])) {
+ return;
+ }
- if ($this->conf['trail_links'] === false)
- $f_params['trail'] = array();
+ if ($this->conf['trail_links'] === false) {
+ $f_params['trail'] = [];
+ }
- return;
- }
-
- function filter_navlinks(&$f_params) {
- $place = $f_params['place'];
- $navlinks = &$f_params['navlinks'];
-
- if (! isset($this->conf['navlinks'][$place]))
- return;
-
- foreach ($this->conf['navlinks'][$place] as $link => $enabled)
- if (isset ($navlinks[$link])
- && ($enabled === false)
- )
- unset($navlinks[$link]);
- return;
- }
-
- function filter_actionbuttons(&$f_params) {
- $place = $f_params['place'];
- $actions = &$f_params['actionbuttons'];
+ return;
+ }
- if (! isset($this->conf['actionbuttons'][$place]))
- return;
+ function filter_navlinks(&$f_params) {
+ $place = $f_params['place'];
+ $navlinks = &$f_params['navlinks'];
+
+ if (!isset($this->conf['navlinks'][$place])) {
+ return;
+ }
+
+ foreach ($this->conf['navlinks'][$place] as $link => $enabled) {
+ if (isset($navlinks[$link])
+ && ($enabled === false)
+ ) {
+ unset($navlinks[$link]);
+ }
+ }
+
+ return;
+ }
- foreach ($this->conf['actionbuttons'][$place] as $link => $enabled)
- if (isset ($actions[$link])
- && ($enabled === false)
- )
- unset($actions[$link]);
- return;
- }
+ function filter_actionbuttons(&$f_params) {
+ $place = $f_params['place'];
+ $actions = &$f_params['actionbuttons'];
+
+ if (!isset($this->conf['actionbuttons'][$place])) {
+ return;
+ }
+
+ foreach ($this->conf['actionbuttons'][$place] as $link => $enabled) {
+ if (isset($actions[$link])
+ && ($enabled === false)
+ ) {
+ unset($actions[$link]);
+ }
+ }
+
+ return;
+ }
function filter_tree() {
- return;
- }
+ return;
+ }
}
?> \ No newline at end of file
diff --git a/src/plugins/Report/plugin.php b/src/plugins/Report/plugin.php
index b37d8161..3dbbe9ec 100644
--- a/src/plugins/Report/plugin.php
+++ b/src/plugins/Report/plugin.php
@@ -1,15 +1,15 @@
<?php
-require_once('./classes/Plugin.php');
-require_once('./plugins/Report/classes/Reports.php');
-class Report extends Plugin {
+require_once './plugins/Report/classes/Reports.php';
+
+class Report extends \PHPPgAdmin\Plugin {
/**
* Attributes
*/
protected $name = 'Report';
protected $lang;
- protected $conf = array();
+ protected $conf = [];
protected $_reportsdb = null;
/**
@@ -23,23 +23,23 @@ class Report extends Plugin {
parent::__construct($language);
/* default values */
- if (! isset($this->conf['reports_db'])) {
+ if (!isset($this->conf['reports_db'])) {
$this->conf['reports_db'] = 'phppgadmin';
}
- if (! isset($this->conf['reports_schema'])) {
+ if (!isset($this->conf['reports_schema'])) {
$this->conf['reports_schema'] = 'public';
}
- if (! isset($this->conf['reports_table'])) {
+ if (!isset($this->conf['reports_table'])) {
$this->conf['reports_table'] = 'ppa_reports';
}
- if (! isset($this->conf['owned_reports_only'])) {
+ if (!isset($this->conf['owned_reports_only'])) {
$this->conf['owned_reports_only'] = false;
}
}
function get_reportsdb() {
if ($this->_reportsdb === null) {
- $status = 0;
+ $status = 0;
$this->_reportsdb = new Reports($this->conf, $status);
if ($status !== 0) {
@@ -47,7 +47,7 @@ class Report extends Plugin {
$misc->printHeader($this->lang['strreports']);
$misc->printBody();
$misc->printTrail('server');
- $misc->printTabs('server','reports');
+ $misc->printTabs('server', 'reports');
$misc->printMsg($this->lang['strnoreportsdb']);
$misc->printFooter();
exit;
@@ -72,11 +72,11 @@ class Report extends Plugin {
* @return $hooks
*/
function get_hooks() {
- $hooks = array(
- 'tabs' => array('add_plugin_tabs'),
- 'trail' => array('add_plugin_trail'),
- 'navlinks' => array('plugin_navlinks')
- );
+ $hooks = [
+ 'tabs' => ['add_plugin_tabs'],
+ 'trail' => ['add_plugin_trail'],
+ 'navlinks' => ['plugin_navlinks'],
+ ];
return $hooks;
}
@@ -92,7 +92,7 @@ class Report extends Plugin {
* @return $actions
*/
function get_actions() {
- $actions = array(
+ $actions = [
'save_edit',
'edit',
'properties',
@@ -101,8 +101,8 @@ class Report extends Plugin {
'drop',
'confirm_drop',
'execute',
- 'default_action'
- );
+ 'default_action',
+ ];
return $actions;
}
@@ -116,31 +116,31 @@ class Report extends Plugin {
$tabs = &$plugin_functions_parameters['tabs'];
if ($plugin_functions_parameters['section'] == 'server') {
- $tabs['report_plugin'] = array (
+ $tabs['report_plugin'] = [
'title' => $this->lang['strplugindescription'],
'url' => 'plugin.php',
- 'urlvars' => array(
+ 'urlvars' => [
'subject' => 'server',
'action' => 'default_action',
- 'plugin' => $this->name
- ),
+ 'plugin' => $this->name,
+ ],
'hide' => false,
- 'icon' => $this->icon('Report')
- );
+ 'icon' => $this->icon('Report'),
+ ];
}
if ($plugin_functions_parameters['section'] == 'report') {
- $tabs['report_plugin'] = array (
+ $tabs['report_plugin'] = [
'title' => $this->lang['strplugindescription'],
'url' => 'plugin.php',
- 'urlvars' => array(
+ 'urlvars' => [
'subject' => 'server',
'action' => 'default_action',
- 'plugin' => $this->name
- ),
+ 'plugin' => $this->name,
+ ],
'hide' => false,
- 'icon' => $this->icon('Report')
- );
+ 'icon' => $this->icon('Report'),
+ ];
}
}
@@ -150,8 +150,8 @@ class Report extends Plugin {
*/
function add_plugin_trail(&$plugin_functions_parameters) {
global $misc;
- $trail = &$plugin_functions_parameters['trail'];
- $done = false;
+ $trail = &$plugin_functions_parameters['trail'];
+ $done = false;
$subject = '';
if (isset($_REQUEST['subject'])) {
$subject = $_REQUEST['subject'];
@@ -163,19 +163,19 @@ class Report extends Plugin {
}
if (isset($_REQUEST['plugin']) and $_REQUEST['plugin'] == 'Report') {
- $url = array (
+ $url = [
'url' => 'plugin.php',
- 'urlvars' => array (
+ 'urlvars' => [
'plugin' => $this->name,
- 'action' => 'default_action'
- )
- );
- $trail['report_plugin'] = array (
+ 'action' => 'default_action',
+ ],
+ ];
+ $trail['report_plugin'] = [
'title' => $this->lang['strreport'],
'text' => $this->lang['strreport'],
- 'url' => $misc->getActionUrl($url, $_REQUEST, null, false),
- 'icon' => $this->icon('Reports')
- );
+ 'url' => $misc->getActionUrl($url, $_REQUEST, null, false),
+ 'icon' => $this->icon('Reports'),
+ ];
}
if (isset($_REQUEST['plugin'])
@@ -184,27 +184,29 @@ class Report extends Plugin {
and in_array($action, $this->get_actions())
) {
- $url = array (
+ $url = [
'url' => 'plugin.php',
- 'urlvars' => array (
+ 'urlvars' => [
'plugin' => $this->name,
'action' => 'properties',
'report_id' => field('report_id'),
- )
- );
+ ],
+ ];
- if (isset($_REQUEST['report']))
+ if (isset($_REQUEST['report'])) {
$url['urlvars']['report'] = field('report');
+ }
- $trail['report_plugin_name'] = array (
+ $trail['report_plugin_name'] = [
'title' => $this->lang['strreport'],
'text' => $this->lang['strreport'],
- 'url' => $misc->getActionUrl($url, $_REQUEST, null, false),
- 'icon' => $this->icon('Report')
- );
+ 'url' => $misc->getActionUrl($url, $_REQUEST, null, false),
+ 'icon' => $this->icon('Report'),
+ ];
- if (isset($_REQUEST['report']))
+ if (isset($_REQUEST['report'])) {
$trail['report_plugin_name']['text'] = $_REQUEST['report'];
+ }
}
}
@@ -219,126 +221,127 @@ class Report extends Plugin {
if (
($params['place'] == 'sql-form'
or $params['place'] == 'display-browse')
- and ( isset($params['env']['rs'])
- and is_object($params['env']['rs'])
- and $params['env']['rs']->recordCount() > 0))
- {
- if ( ! (isset($_REQUEST['plugin'])
- and $_REQUEST['plugin'] == $this->name)
+ and (isset($params['env']['rs'])
+ and is_object($params['env']['rs'])
+ and $params['env']['rs']->recordCount() > 0)) {
+ if (!(isset($_REQUEST['plugin'])
+ and $_REQUEST['plugin'] == $this->name)
) {
/* ResultSet doesn't come from a plugin:
* show a create report link. */
- $params['navlinks']['report_link'] = array (
- 'attr'=> array (
- 'href' => array (
+ $params['navlinks']['report_link'] = [
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array (
+ 'urlvars' => [
'plugin' => $this->name,
'action' => 'create',
'server' => $_REQUEST['server'],
'database' => $_REQUEST['database'],
- )
- )
- ),
- 'content' => $this->lang['strcreatereport']
- );
-
- if (isset($_REQUEST['paginate']))
- $params['navlinks']['report_link']['attr']['href']['urlvars']['paginate']
+ ],
+ ],
+ ],
+ 'content' => $this->lang['strcreatereport'],
+ ];
+
+ if (isset($_REQUEST['paginate'])) {
+ $params['navlinks']['report_link']['attr']['href']['urlvars']['paginate']
= $_REQUEST['paginate'];
+ }
if (!empty($_SESSION['sqlquery'])) {
$params['navlinks']['report_link']['attr']['href']['urlvars']['fromsql']
- = 1;
- }
- else {
+ = 1;
+ } else {
if (isset($_REQUEST['subject'])
- and isset($_REQUEST[$_REQUEST['subject']]))
- {
+ and isset($_REQUEST[$_REQUEST['subject']])) {
$params['navlinks']['report_link']['attr']['href']['urlvars']['subject']
- = $_REQUEST['subject'];
+ = $_REQUEST['subject'];
$params['navlinks']['report_link']['attr']['href']['urlvars'][$_REQUEST['subject']]
- = $_REQUEST[$_REQUEST['subject']];
+ = $_REQUEST[$_REQUEST['subject']];
$params['navlinks']['report_link']['attr']['href']['urlvars']['sortkey']
- = isset($_REQUEST['sortkey']) ? $_REQUEST['sortkey'] : '';
+ = isset($_REQUEST['sortkey']) ? $_REQUEST['sortkey'] : '';
$params['navlinks']['report_link']['attr']['href']['urlvars']['sortdir']
- = isset($_REQUEST['sortdir']) ? $_REQUEST['sortdir'] : '';
- }
- else {
+ = isset($_REQUEST['sortdir']) ? $_REQUEST['sortdir'] : '';
+ } else {
unset($params['navlinks']['report_link']);
}
}
- }
- else {
+ } else {
/* ResultSet comes from a plugin:
* show a edit report link. */
- $params['navlinks']['report_link'] = array (
- 'attr'=> array (
- 'href' => array (
+ $params['navlinks']['report_link'] = [
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array (
+ 'urlvars' => [
'plugin' => $this->name,
'action' => 'edit',
'server' => $_REQUEST['server'],
'database' => $_REQUEST['database'],
- 'report_id' => $_REQUEST['report_id']
- )
- )
- ),
- 'content' => $this->lang['streditreport']
- );
+ 'report_id' => $_REQUEST['report_id'],
+ ],
+ ],
+ ],
+ 'content' => $this->lang['streditreport'],
+ ];
/* edit collapse link to add report related vars */
$params['navlinks']['collapse']['attr']['href']['urlvars']
- ['plugin'] = $this->name;
+ ['plugin'] = $this->name;
$params['navlinks']['collapse']['attr']['href']['urlvars']
- ['report_id'] = $_REQUEST['report_id'];
+ ['report_id'] = $_REQUEST['report_id'];
$params['navlinks']['collapse']['attr']['href']['urlvars']
- ['report'] = $_REQUEST['report'];
+ ['report'] = $_REQUEST['report'];
/* edit refresh link to add report related vars */
$params['navlinks']['refresh']['attr']['href']['urlvars']
- ['plugin'] = $this->name;
+ ['plugin'] = $this->name;
$params['navlinks']['refresh']['attr']['href']['urlvars']
- ['report_id'] = $_REQUEST['report_id'];
+ ['report_id'] = $_REQUEST['report_id'];
$params['navlinks']['refresh']['attr']['href']['urlvars']
- ['report'] = $_REQUEST['report'];
+ ['report'] = $_REQUEST['report'];
if (isset($_REQUEST['action'])) {
$params['navlinks']['collapse']['attr']['href']['urlvars']
- ['action'] = $_REQUEST['action'];
+ ['action'] = $_REQUEST['action'];
$params['navlinks']['refresh']['attr']['href']['urlvars']
- ['action'] = $_REQUEST['action'];
+ ['action'] = $_REQUEST['action'];
}
}
- if (isset($_REQUEST['schema']))
+ if (isset($_REQUEST['schema'])) {
$params['navlinks']['report_link']['attr']['href']['urlvars']['schema']
- = $_REQUEST['schema'];
+ = $_REQUEST['schema'];
+ }
+
}
}
function get_subject_params() {
- $vars = array();
-
- if (! isset($_REQUEST['action']))
+ $vars = [];
+
+ if (!isset($_REQUEST['action'])) {
return $vars;
+ }
$action = $_REQUEST['action'];
switch ($action) {
case 'execute':
- $vars = array(
+ $vars = [
'report_id' => $_REQUEST['report_id'],
'report' => $_REQUEST['report'],
- 'action' => 'properties' /*defaults to properties*/
- );
- if (isset($_REQUEST['back']))
+ 'action' => 'properties', /*defaults to properties*/
+ ];
+ if (isset($_REQUEST['back'])) {
$vars['action'] = $_REQUEST['back'];
- break;
+ }
+
+ break;
}
return $vars;
@@ -357,12 +360,12 @@ class Report extends Plugin {
// If it's a first, load then get the data from the database
$report = $reportsdb->getReport($_REQUEST['report_id']);
-
- if ($_REQUEST['action'] == 'edit') {
+
+ if ($_REQUEST['action'] == 'edit') {
$_POST['report_name'] = $report->fields['report_name'];
- $_POST['db_name'] = $report->fields['db_name'];
- $_POST['descr'] = $report->fields['descr'];
- $_POST['report_sql'] = $report->fields['report_sql'];
+ $_POST['db_name'] = $report->fields['db_name'];
+ $_POST['descr'] = $report->fields['descr'];
+ $_POST['report_sql'] = $report->fields['report_sql'];
if ($report->fields['paginate'] == 't') {
$_POST['paginate'] = true;
}
@@ -378,23 +381,23 @@ class Report extends Plugin {
echo "<table style=\"width: 100%\">\n";
echo "<tr><th class=\"data left required\">{$lang['strname']}</th>\n";
echo "<td class=\"data1\"><input name=\"report_name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
- htmlspecialchars($_POST['report_name']), "\" /></td></tr>\n";
+ htmlspecialchars($_POST['report_name']), "\" /></td></tr>\n";
echo "<tr><th class=\"data left required\">{$lang['strdatabase']}</th>\n";
echo "<td class=\"data1\"><select name=\"db_name\">\n";
while (!$databases->EOF) {
$dbname = $databases->fields['datname'];
echo "<option value=\"", htmlspecialchars($dbname), "\"",
($dbname == $_POST['db_name']) ? ' selected="selected"' : '', ">",
- htmlspecialchars($dbname), "</option>\n";
+ htmlspecialchars($dbname), "</option>\n";
$databases->moveNext();
}
echo "</select></td></tr>\n";
echo "<tr><th class=\"data left\">{$lang['strcomment']}</th>\n";
echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"5\" cols=\"50\" name=\"descr\">",
- htmlspecialchars($_POST['descr']), "</textarea></td></tr>\n";
+ htmlspecialchars($_POST['descr']), "</textarea></td></tr>\n";
echo "<tr><th class=\"data left required\">{$lang['strsql']}</th>\n";
echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"15\" cols=\"50\" name=\"report_sql\">",
- htmlspecialchars($_POST['report_sql']), "</textarea></td></tr>\n";
+ htmlspecialchars($_POST['report_sql']), "</textarea></td></tr>\n";
echo "</table>\n";
echo "<label for=\"paginate\"><input type=\"checkbox\" id=\"paginate\" name=\"paginate\"", (isset($_POST['paginate']) ? ' checked="checked"' : ''), " />&nbsp;{$lang['strpaginate']}</label>\n";
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_edit\" />\n";
@@ -416,10 +419,21 @@ class Report extends Plugin {
exit;
}
- if (!isset($_POST['report_name'])) $_POST['report_name'] = '';
- if (!isset($_POST['db_name'])) $_POST['db_name'] = '';
- if (!isset($_POST['descr'])) $_POST['descr'] = '';
- if (!isset($_POST['report_sql'])) $_POST['report_sql'] = '';
+ if (!isset($_POST['report_name'])) {
+ $_POST['report_name'] = '';
+ }
+
+ if (!isset($_POST['db_name'])) {
+ $_POST['db_name'] = '';
+ }
+
+ if (!isset($_POST['descr'])) {
+ $_POST['descr'] = '';
+ }
+
+ if (!isset($_POST['report_sql'])) {
+ $_POST['report_sql'] = '';
+ }
// Check that they've given a name and a definition
if ($_POST['report_name'] == '') {
@@ -429,10 +443,12 @@ class Report extends Plugin {
} else {
$status = $reportsdb->alterReport($_POST['report_id'], $_POST['report_name'], $_POST['db_name'],
$_POST['descr'], $_POST['report_sql'], isset($_POST['paginate']));
- if ($status == 0)
+ if ($status == 0) {
$this->default_action($this->lang['strreportcreated']);
- else
+ } else {
$this->edit($this->lang['strreportcreatedbad']);
+ }
+
}
}
@@ -444,7 +460,7 @@ class Report extends Plugin {
global $lang;
$reportsdb = $this->get_reportsdb();
-
+
$misc->printHeader($this->lang['strreports']);
$misc->printBody();
$misc->printTrail('server');
@@ -464,47 +480,53 @@ class Report extends Plugin {
echo "<tr><th class=\"data left\">{$lang['strcomment']}</th>\n";
echo "<td class=\"data1\">", $misc->printVal($report->fields['descr']), "</td></tr>\n";
echo "<tr><th class=\"data left\">{$lang['strpaginate']}</th>\n";
- echo "<td class=\"data1\">", $misc->printVal($report->fields['paginate'], 'yesno', array('align' => 'left')), "</td></tr>\n";
+ echo "<td class=\"data1\">", $misc->printVal($report->fields['paginate'], 'yesno', ['align' => 'left']), "</td></tr>\n";
echo "<tr><th class=\"data left\">{$lang['strsql']}</th>\n";
echo "<td class=\"data1\">", $misc->printVal($report->fields['report_sql']), "</td></tr>\n";
echo "</table>\n";
+ } else {
+ echo "<p>{$lang['strinvalidparam']}</p>\n";
}
- else echo "<p>{$lang['strinvalidparam']}</p>\n";
- $urlvars = array (
+ $urlvars = [
'plugin' => $this->name,
- 'server' => $_REQUEST['server']
- );
- if (isset($_REQUEST['schema'])) $urlvars['schema'] = $_REQUEST['schema'];
- if (isset($_REQUEST['schema'])) $urlvars['database'] = $_REQUEST['schema'];
-
- $navlinks = array (
- 'showall' => array (
- 'attr'=> array (
- 'href' => array (
+ 'server' => $_REQUEST['server'],
+ ];
+ if (isset($_REQUEST['schema'])) {
+ $urlvars['schema'] = $_REQUEST['schema'];
+ }
+
+ if (isset($_REQUEST['schema'])) {
+ $urlvars['database'] = $_REQUEST['schema'];
+ }
+
+ $navlinks = [
+ 'showall' => [
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array_merge($urlvars, array('action' => 'default_action'))
- )
- ),
- 'content' => $this->lang['strshowallreports']
- ),
- 'edit' => array (
- 'attr'=> array (
- 'href' => array (
+ 'urlvars' => array_merge($urlvars, ['action' => 'default_action']),
+ ],
+ ],
+ 'content' => $this->lang['strshowallreports'],
+ ],
+ 'edit' => [
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array_merge($urlvars, array(
+ 'urlvars' => array_merge($urlvars, [
'action' => 'edit',
- 'report_id' => $report->fields['report_id'])
- )
- )
- ),
- 'content' => $lang['stredit']
- ),
- 'execute' => array (
- 'attr'=> array (
- 'href' => array (
+ 'report_id' => $report->fields['report_id']]
+ ),
+ ],
+ ],
+ 'content' => $lang['stredit'],
+ ],
+ 'execute' => [
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array_merge($urlvars, array(
+ 'urlvars' => array_merge($urlvars, [
'action' => 'execute',
'report' => $report->fields['report_name'],
'database' => $report->fields['db_name'],
@@ -512,13 +534,13 @@ class Report extends Plugin {
'paginate' => $report->fields['paginate'],
'nohistory' => 't',
'return' => 'plugin',
- 'back' => 'properties'
- ))
- )
- ),
- 'content' => $lang['strexecute']
- )
- );
+ 'back' => 'properties',
+ ]),
+ ],
+ ],
+ 'content' => $lang['strexecute'],
+ ],
+ ];
$misc->printNavLinks($navlinks, 'reports-properties');
}
@@ -534,25 +556,36 @@ class Report extends Plugin {
$misc->printTrail('server');
$misc->printTabs('server', 'report_plugin');
$misc->printMsg($msg);
-
- if (!isset($_REQUEST['report_name'])) $_REQUEST['report_name'] = '';
- if (!isset($_REQUEST['db_name'])) $_REQUEST['db_name'] = '';
- if (!isset($_REQUEST['descr'])) $_REQUEST['descr'] = '';
+
+ if (!isset($_REQUEST['report_name'])) {
+ $_REQUEST['report_name'] = '';
+ }
+
+ if (!isset($_REQUEST['db_name'])) {
+ $_REQUEST['db_name'] = '';
+ }
+
+ if (!isset($_REQUEST['descr'])) {
+ $_REQUEST['descr'] = '';
+ }
+
if (!isset($_REQUEST['report_sql'])) {
// Set the query from session if linked from a user query result
- if (isset($_REQUEST['fromsql']) and $_REQUEST['fromsql'] == 1 ) {
+ if (isset($_REQUEST['fromsql']) and $_REQUEST['fromsql'] == 1) {
$_REQUEST['report_sql'] = $_SESSION['sqlquery'];
- }
- else {
+ } else {
$_REQUEST['sortkey'] = isset($_REQUEST['sortkey']) ? $_REQUEST['sortkey'] : '';
- if (preg_match('/^[0-9]+$/', $_REQUEST['sortkey']) && $_REQUEST['sortkey'] > 0) $orderby = array($_REQUEST['sortkey'] => $_REQUEST['sortdir']);
- else $orderby = array();
+ if (preg_match('/^[0-9]+$/', $_REQUEST['sortkey']) && $_REQUEST['sortkey'] > 0) {
+ $orderby = [$_REQUEST['sortkey'] => $_REQUEST['sortdir']];
+ } else {
+ $orderby = [];
+ }
$subject = isset($_REQUEST['subject']) && isset($_REQUEST[$_REQUEST['subject']])
- ? $_REQUEST[$_REQUEST['subject']]
- : '';
+ ? $_REQUEST[$_REQUEST['subject']]
+ : '';
- $_REQUEST['report_sql'] = $data->getSelectSQL($subject, array(), array(), array(), $orderby);
+ $_REQUEST['report_sql'] = $data->getSelectSQL($subject, [], [], [], $orderby);
}
}
@@ -561,7 +594,7 @@ class Report extends Plugin {
unset($_REQUEST['database']);
$misc->setForm();
}
-
+
$databases = $data->getDatabases();
echo "<form action=\"plugin.php?plugin={$this->name}\" method=\"post\">\n";
@@ -569,23 +602,23 @@ class Report extends Plugin {
echo "<table style=\"width: 100%\">\n";
echo "<tr><th class=\"data left required\">{$lang['strname']}</th>\n";
echo "<td class=\"data1\"><input name=\"report_name\" size=\"32\" maxlength=\"{$data->_maxNameLen}\" value=\"",
- htmlspecialchars($_REQUEST['report_name']), "\" /></td></tr>\n";
+ htmlspecialchars($_REQUEST['report_name']), "\" /></td></tr>\n";
echo "<tr><th class=\"data left required\">{$lang['strdatabase']}</th>\n";
echo "<td class=\"data1\"><select name=\"db_name\">\n";
while (!$databases->EOF) {
$dbname = $databases->fields['datname'];
echo "<option value=\"", htmlspecialchars($dbname), "\"",
($dbname == $_REQUEST['db_name']) ? ' selected="selected"' : '', ">",
- htmlspecialchars($dbname), "</option>\n";
+ htmlspecialchars($dbname), "</option>\n";
$databases->moveNext();
}
echo "</select></td></tr>\n";
echo "<tr><th class=\"data left\">{$lang['strcomment']}</th>\n";
echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"5\" cols=\"50\" name=\"descr\">",
- htmlspecialchars($_REQUEST['descr']), "</textarea></td></tr>\n";
+ htmlspecialchars($_REQUEST['descr']), "</textarea></td></tr>\n";
echo "<tr><th class=\"data left required\">{$lang['strsql']}</th>\n";
echo "<td class=\"data1\"><textarea style=\"width:100%;\" rows=\"15\" cols=\"50\" name=\"report_sql\">",
- htmlspecialchars($_REQUEST['report_sql']), "</textarea></td></tr>\n";
+ htmlspecialchars($_REQUEST['report_sql']), "</textarea></td></tr>\n";
echo "</table>\n";
echo "<label for=\"paginate\"><input type=\"checkbox\" id=\"paginate\" name=\"paginate\"", (isset($_REQUEST['paginate']) ? ' checked="checked"' : ''), " />&nbsp;{$lang['strpaginate']}</label>\n";
echo "<p><input type=\"hidden\" name=\"action\" value=\"save_create\" />\n";
@@ -606,21 +639,36 @@ class Report extends Plugin {
$reportsdb = $this->get_reportsdb();
- if (!isset($_POST['report_name'])) $_POST['report_name'] = '';
- if (!isset($_POST['db_name'])) $_POST['db_name'] = '';
- if (!isset($_POST['descr'])) $_POST['descr'] = '';
- if (!isset($_POST['report_sql'])) $_POST['report_sql'] = '';
+ if (!isset($_POST['report_name'])) {
+ $_POST['report_name'] = '';
+ }
+
+ if (!isset($_POST['db_name'])) {
+ $_POST['db_name'] = '';
+ }
+
+ if (!isset($_POST['descr'])) {
+ $_POST['descr'] = '';
+ }
+
+ if (!isset($_POST['report_sql'])) {
+ $_POST['report_sql'] = '';
+ }
// Check that they've given a name and a definition
- if ($_POST['report_name'] == '') $this->create($this->lang['strreportneedsname']);
- elseif ($_POST['report_sql'] == '') $this->create($this->lang['strreportneedsdef']);
- else {
+ if ($_POST['report_name'] == '') {
+ $this->create($this->lang['strreportneedsname']);
+ } elseif ($_POST['report_sql'] == '') {
+ $this->create($this->lang['strreportneedsdef']);
+ } else {
$status = $reportsdb->createReport($_POST['report_name'], $_POST['db_name'],
- $_POST['descr'], $_POST['report_sql'], isset($_POST['paginate']));
- if ($status == 0)
+ $_POST['descr'], $_POST['report_sql'], isset($_POST['paginate']));
+ if ($status == 0) {
$this->default_action($this->lang['strreportcreated']);
- else
+ } else {
$this->create($this->lang['strreportcreatedbad']);
+ }
+
}
}
@@ -632,13 +680,15 @@ class Report extends Plugin {
global $lang;
$confirm = false;
- if (isset($_REQUEST['confirm'])) $confirm = true;
+ if (isset($_REQUEST['confirm'])) {
+ $confirm = true;
+ }
$reportsdb = $this->get_reportsdb();
$misc->printHeader($this->lang['strreports']);
$misc->printBody();
-
+
if (isset($_REQUEST['cancel'])) {
$this->default_action();
exit;
@@ -663,10 +713,12 @@ class Report extends Plugin {
echo "</form>\n";
} else {
$status = $reportsdb->dropReport($_POST['report_id']);
- if ($status == 0)
+ if ($status == 0) {
$this->default_action($this->lang['strreportdropped']);
- else
+ } else {
$this->default_action($this->lang['strreportdroppedbad']);
+ }
+
}
$misc->printFooter();
@@ -678,10 +730,10 @@ class Report extends Plugin {
$reportsdb = $this->get_reportsdb();
$report = $reportsdb->getReport($_REQUEST['report_id']);
-
+
$_POST['query'] = $report->fields['report_sql'];
- include('./sql.php');
+ include './sql.php';
}
/**
@@ -697,51 +749,51 @@ class Report extends Plugin {
$misc->printTrail('server');
$misc->printTabs('server', 'report_plugin');
$misc->printMsg($msg);
-
+
$reports = $reportsdb->getReports();
- $columns = array(
- 'report' => array(
+ $columns = [
+ 'report' => [
'title' => $this->lang['strreport'],
'field' => field('report_name'),
- 'url' => "plugin.php?plugin={$this->name}&amp;action=properties&amp;{$misc->href}&amp;",
- 'vars' => array(
+ 'url' => "plugin.php?plugin={$this->name}&amp;action=properties&amp;{$misc->href}&amp;",
+ 'vars' => [
'report_id' => 'report_id',
- 'report' => 'report_name'
- ),
- ),
- 'database' => array(
+ 'report' => 'report_name',
+ ],
+ ],
+ 'database' => [
'title' => $lang['strdatabase'],
'field' => field('db_name'),
- ),
- 'created' => array(
+ ],
+ 'created' => [
'title' => $lang['strcreated'],
'field' => field('date_created'),
- ),
- 'paginate' => array(
+ ],
+ 'paginate' => [
'title' => $lang['strpaginate'],
'field' => field('paginate'),
'type' => 'yesno',
- ),
- 'actions' => array(
+ ],
+ 'actions' => [
'title' => $lang['stractions'],
- ),
- 'comment' => array(
+ ],
+ 'comment' => [
'title' => $lang['strcomment'],
'field' => field('descr'),
- ),
- );
-
+ ],
+ ];
+
//$return_url = urlencode("plugin.php?plugin={$this->name}&amp;{$misc->href}");
$urlvars = $misc->getRequestVars();
-
- $actions = array(
- 'run' => array (
+
+ $actions = [
+ 'run' => [
'content' => $lang['strexecute'],
- 'attr'=> array (
- 'href' => array (
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array_merge($urlvars, array (
+ 'urlvars' => array_merge($urlvars, [
'plugin' => $this->name,
'action' => 'execute',
'report' => field('report_name'),
@@ -750,56 +802,56 @@ class Report extends Plugin {
'paginate' => field('paginate'),
'nohistory' => 't',
'return' => 'plugin',
- 'back' => 'default_action'
- ))
- )
- )
- ),
- 'edit' => array (
+ 'back' => 'default_action',
+ ]),
+ ],
+ ],
+ ],
+ 'edit' => [
'content' => $lang['stredit'],
- 'attr'=> array (
- 'href' => array (
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array_merge($urlvars, array (
+ 'urlvars' => array_merge($urlvars, [
'plugin' => $this->name,
'action' => 'edit',
'report_id' => field('report_id'),
- ))
- )
- )
- ),
- 'drop' => array(
+ ]),
+ ],
+ ],
+ ],
+ 'drop' => [
'content' => $lang['strdrop'],
- 'attr'=> array (
- 'href' => array (
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array_merge($urlvars, array (
+ 'urlvars' => array_merge($urlvars, [
'plugin' => $this->name,
'action' => 'drop',
'confirm' => 'true',
'report_id' => field('report_id'),
- ))
- )
- )
- ),
- );
-
+ ]),
+ ],
+ ],
+ ],
+ ];
+
$misc->printTable($reports, $columns, $actions, 'reports-reports', $this->lang['strnoreports']);
- $navlinks = array (
- array (
- 'attr'=> array (
- 'href' => array (
+ $navlinks = [
+ [
+ 'attr' => [
+ 'href' => [
'url' => 'plugin.php',
- 'urlvars' => array (
- 'plugin' => $this->name,
+ 'urlvars' => [
+ 'plugin' => $this->name,
'server' => field('server'),
- 'action' => 'create')
- )
- ),
- 'content' => $this->lang['strcreatereport']
- )
- );
+ 'action' => 'create'],
+ ],
+ ],
+ 'content' => $this->lang['strcreatereport'],
+ ],
+ ];
$misc->printNavLinks($navlinks, 'reports-reports');
$misc->printFooter();
}
diff --git a/src/plugins/instaGIS/plugin.php b/src/plugins/instaGIS/plugin.php
index 4012c815..fcf990ce 100644
--- a/src/plugins/instaGIS/plugin.php
+++ b/src/plugins/instaGIS/plugin.php
@@ -1,7 +1,6 @@
<?php
-require_once 'classes/Plugin.php';
-class instaGIS extends Plugin {
+class instaGIS extends \PHPPgAdmin\Plugin {
/**
* Attributes
@@ -33,7 +32,7 @@ class instaGIS extends Plugin {
* @return $hooks
*/
function get_hooks() {
- $hooks = array(
+ $hooks = [
/*'toplinks' => array(
'add_plugin_toplinks'
@@ -42,9 +41,9 @@ class instaGIS extends Plugin {
'add_plugin_navlinks'
*/
- 'head' => array(
+ 'head' => [
'add_plugin_head',
- ),
+ ],
/*
'tabs' => array('...'),
@@ -53,7 +52,7 @@ class instaGIS extends Plugin {
'actionbuttons' => array('...')
'logout' => array('...')
*/
- );
+ ];
return $hooks;
}
@@ -69,54 +68,54 @@ class instaGIS extends Plugin {
* @return $actions
*/
function get_actions() {
- $actions = array(
+ $actions = [
'some_action...',
- );
+ ];
return $actions;
}
function add_plugin_toplinks(&$plugin_functions_parameters) {
global $misc;
- $link = array(
+ $link = [
'url' => '/plugin.php',
//php file's name. Every link to a plugin must point to plugin.php
- 'urlvars' => array(
+ 'urlvars' => [
//array with the url variables
'plugin' => $this->name,
//Every link to a plugin must have its name in it.
'subject' => 'server',
'action' => 'show_page',
- ),
- );
+ ],
+ ];
- $toplink = array(
- 'bettersql' => array(
- 'attr' => array(
- 'href' => array(
+ $toplink = [
+ 'bettersql' => [
+ 'attr' => [
+ 'href' => [
'url' => '/sqledit.php',
- 'urlvars' => array_merge($reqvars, array(
+ 'urlvars' => array_merge($reqvars, [
'action' => 'sql',
- )),
- ),
+ ]),
+ ],
'target' => "sqledit",
'id' => 'toplink_sql',
- ),
+ ],
'content' => 'BetterSQL',
- ),
- );
+ ],
+ ];
- $plugin_functions_parameters['toplinks']['betterSQL'] = array(
- 'attr' => array(
- 'href' => array(
+ $plugin_functions_parameters['toplinks']['betterSQL'] = [
+ 'attr' => [
+ 'href' => [
'url' => '/sqledit.php',
- 'urlvars' => array_merge($reqvars, array(
+ 'urlvars' => array_merge($reqvars, [
'action' => 'sql',
- )),
- ),
- ),
+ ]),
+ ],
+ ],
'content' => 'BetterSQL',
- );
+ ];
}
/**
* Prints HTML code to include plugin's js file
@@ -129,10 +128,10 @@ class instaGIS extends Plugin {
function add_plugin_head(&$plugin_functions_parameters) {
global $misc;
- $plugin_functions_parameters['heads']['bootstrap'] = '<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">';
+ $plugin_functions_parameters['heads']['bootstrap'] = '<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">';
$plugin_functions_parameters['heads']['bootstrap.theme'] = '<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css">';
- $plugin_functions_parameters['heads']['fonts'] = '<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Dosis:600|Open+Sans:300,600,400,700|Roboto:300italic,400italic">';
- $plugin_functions_parameters['heads']['bootstrap.js'] = '<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>';
+ $plugin_functions_parameters['heads']['fonts'] = '<link rel="stylesheet" href="//fonts.googleapis.com/css?family=Dosis:600|Open+Sans:300,600,400,700|Roboto:300italic,400italic">';
+ $plugin_functions_parameters['heads']['bootstrap.js'] = '<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script>';
$plugin_functions_parameters['heads']['include_js'] = $this->include_js();
@@ -142,48 +141,48 @@ class instaGIS extends Plugin {
function add_plugin_navlinks(&$plugin_functions_parameters) {
global $misc;
- $navlinks = array();
+ $navlinks = [];
switch ($plugin_functions_parameters['place']) {
- case 'display-browse':
- echo '<iframe src="http://phppga.instagis.com/sqledit.php?subject=table&server=postgismaster.instagis.com%3A5432%3Aallow&database=pstn_db&schema=asistente&action=sql" width="100%" height="200"></iframe>';
- $link = array(
- 'url' => 'plugin.php',
- 'urlvars' => array(
- 'plugin' => $this->name,
- 'subject' => 'show_page',
- 'action' => 'show_display_extension',
- 'database' => field('database'),
- 'table' => field('table'),
- ),
- );
-
- $plugin_functions_parameters['navlinks']['query'] = array(
- 'attr' => array(
- 'href' => $link,
- ),
- 'content' => 'QUERY',
- );
-
- /*echo 'PLUGIN NAVLINKS <pre>';
- print_r($plugin_functions_parameters['navlinks']);
- echo '</pre>';*/
- break;
-
- case 'all_db-databases':
- $navlinks[] = array(
- 'attr' => array(
- 'href' => array(
- 'url' => 'plugin.php',
- 'urlvars' => array(
- 'plugin' => $this->name,
- 'subject' => 'show_page',
- 'action' => 'show_databases_extension',
- ),
- ),
- ),
- 'content' => $this->lang['strdbext'],
- );
- break;
+ case 'display-browse':
+ echo '<iframe src="http://phppga.instagis.com/sqledit.php?subject=table&server=postgismaster.instagis.com%3A5432%3Aallow&database=pstn_db&schema=asistente&action=sql" width="100%" height="200"></iframe>';
+ $link = [
+ 'url' => 'plugin.php',
+ 'urlvars' => [
+ 'plugin' => $this->name,
+ 'subject' => 'show_page',
+ 'action' => 'show_display_extension',
+ 'database' => field('database'),
+ 'table' => field('table'),
+ ],
+ ];
+
+ $plugin_functions_parameters['navlinks']['query'] = [
+ 'attr' => [
+ 'href' => $link,
+ ],
+ 'content' => 'QUERY',
+ ];
+
+ /*echo 'PLUGIN NAVLINKS <pre>';
+ print_r($plugin_functions_parameters['navlinks']);
+ */
+ break;
+
+ case 'all_db-databases':
+ $navlinks[] = [
+ 'attr' => [
+ 'href' => [
+ 'url' => 'plugin.php',
+ 'urlvars' => [
+ 'plugin' => $this->name,
+ 'subject' => 'show_page',
+ 'action' => 'show_databases_extension',
+ ],
+ ],
+ ],
+ 'content' => $this->lang['strdbext'],
+ ];
+ break;
}
if (count($navlinks) > 0) {
diff --git a/src/themes.php b/src/themes.php
deleted file mode 100644
index 1b0e1f91..00000000
--- a/src/themes.php
+++ /dev/null
@@ -1,68 +0,0 @@
-<?php
-
-/**
- * Available Themes for phpPgAdmin
- *
- * $Id:
- */
-
-// List of themes
-
-$appThemes = [
- 'default' => 'Default',
- 'cappuccino' => 'Cappuccino',
- 'gotar' => 'Blue/Green',
- 'bootstrap' => 'Bootstrap3',
-];
-
-/* select the theme */
-unset($_theme);
-if (!isset($conf['theme'])) {
- $conf['theme'] = 'default';
-}
-DEFINE('THEME_PATH', BASE_PATH . "/src/themes");
-
-// 1. Check for the theme from a request var
-if (isset($_REQUEST['theme']) && is_file(THEME_PATH . "/{$_REQUEST['theme']}/global.css")) {
- /* save the selected theme in cookie for a year */
- setcookie('ppaTheme', $_REQUEST['theme'], time() + 31536000);
- $_theme = $_SESSION['ppaTheme'] = $conf['theme'] = $_REQUEST['theme'];
-}
-
-// 2. Check for theme session var
-if (!isset($_theme) && isset($_SESSION['ppaTheme']) && is_file(THEME_PATH . "/{$_SESSION['ppaTheme']}/global.css")) {
- $conf['theme'] = $_SESSION['ppaTheme'];
-}
-
-// 3. Check for theme in cookie var
-if (!isset($_theme) && isset($_COOKIE['ppaTheme']) && is_file(THEME_PATH . "/{$_COOKIE['ppaTheme']}/global.css")) {
- $conf['theme'] = $_COOKIE['ppaTheme'];
-}
-
-if (!is_null($_server_info)) {
-
- $_theme = '';
-
- if (isset($_server_info['theme']['default']) && is_file(THEME_PATH . "/{$_server_info['theme']['default']}/global.css")) {
- $_theme = $_server_info['theme']['default'];
- }
-
- if (isset($_REQUEST['database'])
- and isset($_server_info['theme']['db'][$_REQUEST['database']])
- and is_file(THEME_PATH . "/{$_server_info['theme']['db'][$_REQUEST['database']]}/global.css")
- ) {
- $_theme = $_server_info['theme']['db'][$_REQUEST['database']];
- }
-
- if (isset($_server_info['username'])
- and isset($_server_info['theme']['user'][$_server_info['username']])
- and is_file(THEME_PATH . "/{$_server_info['theme']['user'][$_server_info['username']]}/global.css")
- ) {
- $_theme = $_server_info['theme']['user'][$_server_info['username']];
- }
-
- if ($_theme !== '') {
- setcookie('ppaTheme', $_theme, time() + 31536000);
- $conf['theme'] = $_theme;
- }
-}
diff --git a/src/themes/bootstrap/global.css b/src/themes/bootstrap/global.css
index 45f647fc..539edffa 100644
--- a/src/themes/bootstrap/global.css
+++ b/src/themes/bootstrap/global.css
@@ -432,7 +432,7 @@ div.logo {
/* 1em; */
border: none;
margin-bottom: 2px;
- background-image: url('../../images/themes/bootstrap/title.png');
+ background-image: url('../../../images/themes/bootstrap/title.png');
background-repeat: none;
height: 50px;
}
diff --git a/src/themes/cappuccino/global.css b/src/themes/cappuccino/global.css
index 5d1a3aa7..75574b58 100644
--- a/src/themes/cappuccino/global.css
+++ b/src/themes/cappuccino/global.css
@@ -1,25 +1,44 @@
@import url(../global.css);
+
/**
* cappuccino style sheet
*/
+
+
/* ELEMENTS */
+
body {
background-color: #ded9c9;
- margin: 0;
+ margin: 0;
padding: 0;
font-family: arial;
- font-size: 0.9em; /*0.8em;*/
+ font-size: 0.9em;
+ /*0.8em;*/
+}
+
+body > * {
+ margin-left: 20px
}
-body > * { margin-left: 20px }
+
body.browser {
background-color: #363330;
font-size: 0.9em;
border-right: 1px dashed #887f5c;
color: #fff;
}
-body.browser > * { margin: 0 }
-body.browser div.webfx-tree-row:hover { background: #524a42}
-h1 {font-size: 1.5em}
+
+body.browser > * {
+ margin: 0
+}
+
+body.browser div.webfx-tree-row:hover {
+ background: #524a42
+}
+
+h1 {
+ font-size: 1.5em
+}
+
h2 {
color: #fff;
font-size: 1em;
@@ -30,38 +49,54 @@ h2 {
margin-top: 2em;
margin-bottom: 2em;
}
+
h3 {
color: #111;
font-weight: bold;
}
+
table {
border: 0;
border-collapse: collapse;
}
-td, th {
+
+td,
+th {
padding: 1px 8px;
}
+
a {
color: #2d547b;
text-decoration: none;
}
+
a:hover {
color: #cc0000;
text-decoration: underline;
}
-input[type=checkbox], input[type=password], input[type=text], input[type=radio] {
+
+input[type=checkbox],
+input[type=password],
+input[type=text],
+input[type=radio] {
background: #ded4b3;
border: 1px solid #887f5c;
}
-input[type=submit], input[type=reset], input[type=button], select {
- background: #c4ba95 url('../../images/themes/cappuccino/inputbckg.png') repeat-x top left;
+
+input[type=submit],
+input[type=reset],
+input[type=button],
+select {
+ background: #c4ba95 url('../../../images/themes/cappuccino/inputbckg.png') repeat-x top left;
border: 1px solid #887f5c;
}
+
table.error {
background-color: #dec9d0;
border: 2px solid #de7c9c;
margin: auto;
}
+
th.data {
color: #fff;
background-color: #363330;
@@ -69,30 +104,53 @@ th.data {
font-size: 0.9em;
padding: 3px 7px;
}
-th.required {text-decoration: underline}
-.topbar, .trail {
+
+th.required {
+ text-decoration: underline
+}
+
+.topbar,
+.trail {
color: #fff;
background-color: #363330;
margin: 0;
padding: 0;
text-align: left;
}
-.topbar a, .trail a, body.browser a, th.data a {
+
+.topbar a,
+.trail a,
+body.browser a,
+th.data a {
color: #a8aac2;
}
-.topbar .platform, .topbar .host, .topbar .username {
+
+.topbar .platform,
+.topbar .host,
+.topbar .username {
font-weight: bold;
}
-.topbar, .trail, .tab {
+
+.topbar,
+.trail,
+.tab {
padding: 2px 1ex;
}
-.trail td {padding: 2px}
-.crumb .icon {margin-right: 5px}
+
+.trail td {
+ padding: 2px
+}
+
+.crumb .icon {
+ margin-right: 5px
+}
+
table.tabs {
width: 100%;
border-collapse: collapse;
margin: 20px 0 40px 0;
}
+
.tab {
text-align: center;
vertical-align: top;
@@ -102,94 +160,152 @@ table.tabs {
padding: 2px 10px;
white-space: nowrap;
}
-.tab:hover {background-color: #b7af8d}
+
+.tab:hover {
+ background-color: #b7af8d
+}
+
.tabs .active {
border-bottom: none;
background-color: #ded9c9;
}
+
.tab .icon {
display: block;
}
-.active a {font-weight: bold}
-a:hover {text-decoration: underline}
-ul.toplink, ul.navlink {
+
+.active a {
+ font-weight: bold
+}
+
+a:hover {
+ text-decoration: underline
+}
+
+ul.toplink,
+ul.navlink {
list-style: none;
- margin:0;padding:0;
+ margin: 0;
+ padding: 0;
+}
+
+ul.navlink {
+ margin: 20px 0 20px 20px
}
-ul.navlink{margin:20px 0 20px 20px}
-ul.toplink li, ul.navlink li {
- display:inline;
- border-left:1px solid #000000;
- margin:0;padding: 0 2px 0 5px;
+
+ul.toplink li,
+ul.navlink li {
+ display: inline;
+ border-left: 1px solid #000000;
+ margin: 0;
+ padding: 0 2px 0 5px;
}
-ul.toplink li:first-child, ul.navlink li:first-child {
+
+ul.toplink li:first-child,
+ul.navlink li:first-child {
border: none;
- padding-left:0;
+ padding-left: 0;
}
-tr.data1, tr.data2, tr.data3 {
+
+tr.data1,
+tr.data2,
+tr.data3 {
color: #000000;
font-size: 0.8em;
border: 1px dotted #887f5c;
}
-tr.data1:hover, tr.data2:hover, tr.data3:hover {
+
+tr.data1:hover,
+tr.data2:hover,
+tr.data3:hover {
background-color: #c8c0a2;
}
-.row1, .data1 {
+
+.row1,
+.data1 {
background-color: #d8d2b9;
text-align: left;
}
-.row2, .data2 {
+
+.row2,
+.data2 {
background-color: #ded9c9;
text-align: left;
}
-.row3, .data3 {background-color: #d4c8a1}
-td.opbutton1, td.opbutton2 {
+
+.row3,
+.data3 {
+ background-color: #d4c8a1
+}
+
+td.opbutton1,
+td.opbutton2 {
color: #000000;
- cursor: pointer;
+ cursor: pointer;
padding: 2px 6px;
text-align: center;
border: 1px dotted #887f5c;
}
-td.opbutton1:hover, td.opbutton2:hover {
+
+td.opbutton1:hover,
+td.opbutton2:hover {
background-color: #b7af8d;
}
+
a.help {
color: #A46600;
vertical-align: super;
text-decoration: none;
font-size: 0.8em;
}
-pre {font-size: 110%}
-pre.data {font-size: 100%}
-pre.error {font-size: 120%}
-.intro li {font-weight: bold}
+pre {
+ font-size: 110%
+}
+
+pre.data {
+ font-size: 100%
+}
+
+pre.error {
+ font-size: 120%
+}
+
+.intro li {
+ font-weight: bold
+}
+
.ac_field {
- border:1px solid #363330;
- background: url('../../images/themes/cappuccino/openListe.png') no-repeat right;
+ border: 1px solid #363330;
+ background: url('../../../images/themes/cappuccino/openListe.png') no-repeat right;
padding-right: 20px;
}
+
.bottom_link {
background: #b7af8d;
border-top: 1px dotted #887f5c;
border-left: 1px dotted #887f5c;
}
+
/** FK browsing **/
+
div.fk {
- background: #fff;
+ background: #fff;
border-left: 1px dotted #000;
padding: 5px;
}
+
div.logo {
- margin: 0px;
+ margin: 0px;
padding: 0px;
border: none;
margin-bottom: 15px;
- background-image: url('../../images/themes/cappuccino/title.png');
+ background-image: url('../../../images/themes/cappuccino/title.png');
background-repeat: no-repeat;
height: 50px;
}
+
div.logo a {
display: block;
height: 100%;
diff --git a/src/themes/default/global.css b/src/themes/default/global.css
index 4c80f79b..225aba77 100644
--- a/src/themes/default/global.css
+++ b/src/themes/default/global.css
@@ -9,7 +9,7 @@
/** ELEMENTS */
body {
- background-color: #FFFFFF;
+ background-color: #F5F5F7;
margin: 0;
font-family: roboto;
padding: 0;
diff --git a/src/xhtml/HTMLController.php b/src/xhtml/HTMLController.php
index 2a794fde..cdf1c4e9 100644
--- a/src/xhtml/HTMLController.php
+++ b/src/xhtml/HTMLController.php
@@ -8,16 +8,9 @@ use \PHPPgAdmin\Decorators\Decorator;
*/
class HTMLController {
private $container = null;
- private $_connection = null;
- private $_reload_browser = false;
- private $app = null;
private $data = null;
private $database = null;
private $server_id = null;
- public $appLangFiles = [];
- public $appThemes = [];
- public $appName = '';
- public $appVersion = '';
public $form = '';
public $href = '';
public $lang = [];
diff --git a/src/xhtml/HTMLNavbarController.php b/src/xhtml/HTMLNavbarController.php
index ab30dade..0f258c20 100644
--- a/src/xhtml/HTMLNavbarController.php
+++ b/src/xhtml/HTMLNavbarController.php
@@ -197,6 +197,7 @@ class HTMLNavbarController extends HTMLController {
$appLangFiles = $misc->appLangFiles;
$server_info = $misc->getServerInfo();
+ $server_id = $misc->getServerId();
$reqvars = $misc->getRequestVars('table');
$topbar_html = "<div class=\"topbar\"><table style=\"width: 100%\"><tr><td>";
@@ -280,8 +281,8 @@ class HTMLNavbarController extends HTMLController {
$topbar_html .= "</td>";
- $sql_window_id = htmlentities('sqledit:' . $this->server_id);
- $history_window_id = htmlentities('history:' . $this->server_id);
+ $sql_window_id = htmlentities('sqledit:' . $server_id);
+ $history_window_id = htmlentities('history:' . $server_id);
$topbar_html .= "<script type=\"text/javascript\">
$('#toplink_sql').click(function() {
diff --git a/templates/browser.twig b/templates/browser.twig
index da2782be..28e29ee3 100644
--- a/templates/browser.twig
+++ b/templates/browser.twig
@@ -10,10 +10,6 @@
.webfx-tree-children {
background-image: url("{{icons.I}}");
}
-
- body {
- background-color: #F5F5F7 !important;
- }
</style>
</head>