Skip to content

Instantly share code, notes, and snippets.

@overplumbum
Created April 2, 2012 16:32
Show Gist options
  • Save overplumbum/2284823 to your computer and use it in GitHub Desktop.
Save overplumbum/2284823 to your computer and use it in GitHub Desktop.
phppgadmin hosts
diff --git a/database.php b/database.php
index 95cdf2b..de5ef19 100755
--- a/database.php
+++ b/database.php
@@ -400,6 +400,27 @@
echo "</div>";
}
+
+ function clientResolve($addr) {
+ global $_clientResolveCache;
+
+ if (!isset($_clientResolveCache[$addr])) {
+ if (preg_match("/^10[.]0[.]0[.]/", $addr)) {
+ $result = trim(end(explode("\t", `avahi-resolve-address $addr`)));
+ if ($result) {
+ $addr = $result;
+ }
+ }
+ $_clientResolveCache[$addr] = $addr;
+ }
+ return $_clientResolveCache[$addr];
+ }
+
+ function prepareProcess($proc, $actions) {
+ $proc->fields['client_addr'] = clientResolve($proc->fields['client_addr']);
+ return $actions;
+ }
+
function currentProcesses($isAjax = false) {
global $data, $misc, $lang;
@@ -442,6 +463,10 @@
'field' => field('waiting'),
'type' => 'yesno',
),
+ 'client' => array(
+ 'title' => 'Client',
+ 'field' => field('client_addr'),
+ ),
'user' => array(
'title' => $lang['strusername'],
'field' => field('usename'),
@@ -487,7 +512,7 @@
// Remove query start time for <7.4
if (!isset($processes->fields['query_start'])) unset($columns['start_time']);
- $misc->printTable($processes, $columns, $actions, $lang['strnodata']);
+ $misc->printTable($processes, $columns, $actions, $lang['strnodata'], 'prepareProcess');
if ($isAjax) exit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment