-
Notifications
You must be signed in to change notification settings - Fork 39
/
iframe_content.php
110 lines (93 loc) · 3.71 KB
/
iframe_content.php
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
// Purpose display output for backup, restore, metadata and dbstats processes
// ubside of an iframe
// Author Lutz Brueckner <[email protected]>
// Copyright (c) 2000-2006 by Lutz Brueckner,
// published under the terms of the GNU General Public Licence v.2,
// see file LICENCE for details
// do not overwrite $s_referer in script_start.inc.php
$no_session_referer = true;
require './inc/script_start.inc.php';
$key = get_request_data('key', 'GET');
if ($job = get_iframejob($s_iframejobs, $key)) {
switch ($job['job']) {
case 'metadata':
list($content, $error) = isql_get_metadata($s_login['user'], $s_login['password'], $s_login['database'], $s_login['host']);
$content = implode("\n", $content);
break;
case 'dbstat':
if (($service = fbird_service_attach($s_login['host'], $s_login['user'], $s_login['password'])) != false) {
$content = fbird_db_info($service, $s_login['database'], $job['option']);
$content = trim(str_replace(array(chr(0x01), "\n\n"), array('', "\n"), $content));
fbird_service_detach($service);
} else {
$error = fbird_errmsg();
}
break;
case 'backup':
if (($service = fbird_service_attach($s_login['host'], $s_login['user'], $s_login['password'])) != false) {
$content = fbird_backup($service, $job['source'], $job['target'], $job['options'], true);
$content = str_replace(array(chr(0x01).chr(0x0a), 'gbak: '), '', $content);
fbird_service_detach($service);
} else {
$error = fbird_errmsg();
}
break;
case 'restore':
if (($service = fbird_service_attach($s_login['host'], $s_login['user'], $s_login['password'])) != false) {
$content = fbird_restore($service, $job['source'], $job['target'], $job['options'], true);
$content = str_replace(array(chr(0x01).chr(0x0a), 'gbak: '), '', $content);
fbird_service_detach($service);
// try to connect the restored database
if ($job['connect']) {
$s_login['database'] = $job['target'];
if (!empty($s_sysdba_pw)) {
$s_login['user'] = 'SYSDBA';
$s_login['password'] = $s_sysdba_pw;
}
if ($dbhandle = db_connect()) {
// connected successfully
$s_connected = true;
remove_edit_panels();
} else {
// connect failed
$content .= '<p><span class="err">'.$info_strings['FBError'].':</span>'.fbird_errmsg()."</p>\n";
$s_login['password'] = '';
$s_connected = false;
}
cleanup_session();
}
} else {
$error = fbird_errmsg();
}
break;
case 'export':
include './inc/export.inc.php';
ob_start();
export_data($job['data']);
$content = ob_get_contents();
ob_end_clean();
break;
}
echo iframe_content($content, $error);
unset($s_iframejobs[$key]);
globalize_session_vars();
}
function get_iframejob($iframejobs, $key)
{
if (isset($iframejobs[$key])) {
return $iframejobs[$key];
}
return false;
}
function iframe_content($content, $error)
{
return html_head('FirebirdWebAdmin '.VERSION)
."<body class=\"if\">\n"
.($error ? '<p><span class="err">'.$GLOBALS['info_strings']['Error'].':</span> '.$error."</p>\n" : '')
."<pre>\n"
.htmlspecialchars($content)."\n"
."</pre>\n"
."</body>\n"
."</html>\n";
}