'',
'label' => __('Extensions'),
],
]
);
if (is_metaconsole() === true) {
$img = '../../images/warning_modern.png';
} else {
$img = 'images/warning_modern.png';
}
$msg = '
'.html_print_image(
$img,
true
);
$msg .= '
'.__(
'Warning, you are accessing the database directly. You can leave the system inoperative if you run an inappropriate SQL statement'
).'
';
$warning_message = '';
if (empty($sql) === true) {
echo $warning_message;
}
ui_print_warning_message(
__(
"This is an advanced extension to interface with %s database directly from WEB console
using native SQL sentences. Please note that you can damage your %s installation
if you don't know exactly what are you are doing,
this means that you can severily damage your setup using this extension.
This extension is intended to be used only by experienced users
with a depth knowledge of %s internals.",
get_product_name(),
get_product_name(),
get_product_name()
)
);
echo "';
// Processing SQL Code.
if ($sql == '') {
return;
}
try {
if (\is_metaconsole() === true && $node_id !== -1) {
$node = new Node($node_id);
$dbconnection = @get_dbconnection(
[
'dbhost' => $node->dbhost(),
'dbport' => $node->dbport(),
'dbname' => $node->dbname(),
'dbuser' => $node->dbuser(),
'dbpass' => io_output_password($node->dbpass()),
]
);
$error = '';
$result = dbmanager_query($sql, $error, $dbconnection);
} else {
$dbconnection = $config['dbconnection'];
$error = '';
$result = dbmanager_query($sql, $error, $dbconnection);
}
} catch (\Exception $e) {
$error = __('Error querying database node');
$result = false;
}
if ($result === false) {
echo 'An error has occured when querying the database.
';
echo $error;
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'DB Interface Extension. Error in SQL',
false,
false,
$sql
);
return;
}
if (is_array($result) === false) {
echo 'Output: '.$result;
db_pandora_audit(
AUDIT_LOG_SYSTEM,
'DB Interface Extension. SQL',
false,
false,
$sql
);
return;
}
echo "";
$table = new stdClass();
$table->width = '100%';
$table->class = 'info_table';
$table->head = array_keys($result[0]);
$table->data = $result;
html_print_table($table);
echo '
';
}
if (is_metaconsole() === true) {
// This adds a option in the operation menu.
extensions_add_meta_menu_option(
__('DB interface'),
'PM',
'gextensions',
'database.png',
'v1r1'
);
extensions_add_meta_function('dbmgr_extension_main');
}
// This adds a option in the operation menu.
extensions_add_godmode_menu_option(__('DB interface'), 'PM', 'gextensions', 'dbmanager/icon.png', 'v1r1', 'gdbman');
// This sets the function to be called when the extension is selected in the operation menu.
extensions_add_godmode_function('dbmgr_extension_main');