1<?php
2
3//includes
4	include "root.php";
5	require_once "resources/require.php";
6	require_once "resources/check_auth.php";
7
8//check permission
9	if (permission_exists('adminer')) {
10		//access granted
11	}
12	else {
13		echo "access denied";
14		exit;
15	}
16
17//only allow users in the superadmin group to use this feature
18	if (if_group("superadmin")) {
19		//echo "access granted";
20	}
21	else {
22		echo "access denied";
23		exit;
24	}
25
26//auto login
27	if (isset($_SESSION['adminer']['auto_login']['boolean'])) {
28		function adminer_object() {
29		    class AdminerSoftware extends Adminer {
30
31				function name() {
32					// custom name in title and heading
33					return 'Adminer';
34				}
35
36				function permanentLogin() {
37					// key used for permanent login
38					if ($_SESSION['adminer']['auto_login']['boolean'] == 'true') {
39						return "7bebc76d8680196752c6b961ef13c360";
40					}
41				}
42
43				function credentials() {
44					// server, username and password for connecting to database
45					if ($_SESSION['adminer']['auto_login']['boolean'] == 'true') {
46						global $db_host, $db_username, $db_password;
47						return array($db_host.':'.$db_port, $db_username, $db_password);
48					}
49				}
50
51				function database() {
52					// database name, will be escaped by Adminer
53					if ($_SESSION['adminer']['auto_login']['boolean'] == 'true') {
54						global $db_name;
55						return $db_name;
56					}
57				}
58
59				function login($login, $password) {
60					// validate user submitted credentials
61					return ($_SESSION['adminer']['auto_login']['boolean'] == 'true') ? true : false;
62				}
63
64		    }
65		    return new AdminerSoftware;
66		}
67	}
68
69// include original Adminer or Adminer Editor
70	include "adminer.php";
71
72?>
73