aboutsummaryrefslogtreecommitdiffstats
path: root/admin/database.php
blob: a257071b3cff42f3a84399cad765c360b8c0218f (plain)
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
<?php
#===============================================================================
# DEFINE: Administration
#===============================================================================
const ADMINISTRATION = TRUE;
const AUTHENTICATION = TRUE;

#===============================================================================
# INCLUDE: Initialization
#===============================================================================
require '../core/application.php';

#===============================================================================
# Execute database command(s)
#===============================================================================
if(HTTP::issetPOST(['token' => Application::getSecurityToken()], 'command')) {
	try {
		$Statement = $Database->query(HTTP::POST('command'));

		do {
			$result[] = print_r($Statement->fetchAll(), TRUE);
		} while($Statement->nextRowset());
	} catch(PDOException $Exception) {
		$messages[] = $Exception->getMessage();
	}
}

#===============================================================================
# Build document
#===============================================================================
$DatabaseTemplate = Template\Factory::build('database');
$DatabaseTemplate->set('FORM', [
	'INFO' => $messages ?? [],
	'TOKEN' => Application::getSecurityToken(),
	'RESULT' => implode(NULL, $result ?? []),
	'COMMAND' => HTTP::POST('command'),
]);

$MainTemplate = Template\Factory::build('main');
$MainTemplate->set('NAME', 'SQL');
$MainTemplate->set('HTML', $DatabaseTemplate);
echo $MainTemplate;