function search() { $tpl = new templates(); $MyPage = CurrentPageName(); $sock = new sockets(); $q = new mysql(); $postgres = new postgres_sql(); $page = 1; $FORCE_FILTER = null; $total = 0; $table = "pg_database"; if (isset($_POST['page'])) { $page = $_POST['page']; } $searchstring = string_to_flexquery(null, true); if ($searchstring != null) { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table} {$searchstring}"; $ligne = pg_fetch_assoc($postgres->QUERY_SQL($sql, "artica_backup")); $total = $ligne["TCOUNT"]; } else { $sql = "SELECT COUNT(*) as TCOUNT FROM {$table}"; $ligne = pg_fetch_assoc($postgres->QUERY_SQL($sql, "artica_backup")); $total = $ligne["TCOUNT"]; } if (isset($_POST['rp'])) { $rp = $_POST['rp']; } $pageStart = ($page - 1) * $rp; $limitSql = "LIMIT {$rp} OFFSET {$pageStart}"; if (isset($_POST["sortname"])) { if ($_POST["sortname"] != null) { $ORDER = "ORDER BY {$_POST["sortname"]} {$_POST["sortorder"]}"; } } $data = array(); $data['page'] = $page; $data['total'] = 0; $data['rows'] = array(); $data['total'] = $total; $fontsize = 20; $style = "style='font-size:20px'"; $c = 0; $tpl = new templates(); $curr = $tpl->javascript_parse_text("{current}"); $sql = "SELECT * FROM {$table} {$searchstring} {$FORCE_FILTER} {$ORDER} {$limitSql}"; $results = $postgres->QUERY_SQL($sql); if (!$postgres->ok) { json_error_show($postgres->mysql_error); } if (pg_num_rows($results) == 0) { json_error_show("no data - {$sql}"); } while ($ligne = @pg_fetch_assoc($results)) { $c++; $current = null; $database = $ligne["datname"]; $ms5 = md5($database); $TABLES = $postgres->LIST_TABLES($database); $CountOfTables = count($TABLES); $delete = imgsimple("delete-32.png", null, "Loadjs('{$MyPage}?delete-db-js={$database}')"); $color = "black"; $size = FormatBytes(intval($size) / 1024); if (preg_match("#^template#", $database)) { $delete = " "; } if (preg_match("#^postgres#", $database)) { $delete = " "; } $data['rows'][] = array('id' => $ms5, 'cell' => array("<span {$style}>{$database}</a></span>", "<center {$style}>{$CountOfTables}</a></center>", "<center>{$delete}</a></center>")); } if ($c == 0) { json_error_show("no data"); } echo json_encode($data); }