File: example.php

package info (click to toggle)
adminer 5.4.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,828 kB
  • sloc: php: 28,768; javascript: 1,188; xml: 107; makefile: 48; sh: 3
file content (50 lines) | stat: -rw-r--r-- 1,233 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
function adminer_object() {
	class AdminerCds extends Adminer\Adminer {

		function name() {
			// custom name in title and heading
			return 'CDs';
		}

		function credentials() {
			// ODBC user with password ODBC on localhost
			return array('localhost', 'ODBC', 'ODBC');
		}

		function database() {
			// will be escaped by Adminer
			return 'adminer_test';
		}

		function login($login, $password) {
			// username: 'admin', password: anything
			return ($login == 'admin');
		}

		function tableName($tableStatus) {
			// tables without comments would return empty string and will be ignored by Adminer
			return Adminer\h($tableStatus["Comment"]);
		}

		function fieldName($field, $order = 0) {
			if ($order && preg_match('~_(md5|sha1)$~', $field["field"])) {
				return ""; // hide hashes in select
			}
			// display only column with comments, first five of them plus searched columns
			if ($order < 5) {
				return Adminer\h($field["comment"]);
			}
			foreach ((array) $_GET["where"] as $key => $where) {
				if ($where["col"] == $field["field"] && ($key >= 0 || $where["val"] != "")) {
					return Adminer\h($field["comment"]);
				}
			}
			return "";
		}
	}

	return new AdminerCds;
}

include "./index.php";