commit | author | age
|
1e9cd5
|
1 |
<?php |
T |
2 |
|
da402d
|
3 |
define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' ); |
1e9cd5
|
4 |
require INSTALL_PATH.'program/include/iniset.php'; |
T |
5 |
|
|
6 |
/** callback function for schema dump **/ |
|
7 |
function print_schema($dump) |
|
8 |
{ |
|
9 |
foreach ((array)$dump as $part) |
|
10 |
echo $dump . "\n"; |
|
11 |
} |
|
12 |
|
|
13 |
$config = new rcube_config(); |
|
14 |
|
|
15 |
// don't allow public access if not in devel_mode |
|
16 |
if (!$config->get('devel_mode') && $_SERVER['REMOTE_ADDR']) { |
|
17 |
header("HTTP/1.0 401 Access denied"); |
|
18 |
die("Access denied!"); |
|
19 |
} |
|
20 |
|
|
21 |
$options = array( |
|
22 |
'use_transactions' => false, |
|
23 |
'log_line_break' => "\n", |
|
24 |
'idxname_format' => '%s', |
|
25 |
'debug' => false, |
|
26 |
'quote_identifier' => true, |
|
27 |
'force_defaults' => false, |
|
28 |
'portability' => false |
|
29 |
); |
|
30 |
|
|
31 |
$schema =& MDB2_Schema::factory($config->get('db_dsnw'), $options); |
|
32 |
$schema->db->supported['transactions'] = false; |
|
33 |
|
|
34 |
// send as text/xml when opened in browser |
|
35 |
if ($_SERVER['REMOTE_ADDR']) |
|
36 |
header('Content-Type: text/xml'); |
|
37 |
|
|
38 |
|
|
39 |
if (PEAR::isError($schema)) { |
|
40 |
$error = $schema->getMessage() . ' ' . $schema->getUserInfo(); |
|
41 |
} |
|
42 |
else { |
|
43 |
$dump_config = array( |
|
44 |
// 'output_mode' => 'file', |
|
45 |
'output' => 'print_schema', |
|
46 |
); |
|
47 |
|
|
48 |
$definition = $schema->getDefinitionFromDatabase(); |
|
49 |
if (PEAR::isError($definition)) { |
|
50 |
$error = $definition->getMessage() . ' ' . $definition->getUserInfo(); |
|
51 |
} |
|
52 |
else { |
|
53 |
$operation = $schema->dumpDatabase($definition, $dump_config, MDB2_SCHEMA_DUMP_STRUCTURE); |
|
54 |
if (PEAR::isError($operation)) { |
|
55 |
$error = $operation->getMessage() . ' ' . $operation->getUserInfo(); |
|
56 |
} |
|
57 |
} |
|
58 |
} |
|
59 |
|
|
60 |
$schema->disconnect(); |
|
61 |
|
|
62 |
//if ($error) |
|
63 |
// fputs(STDERR, $error); |
|
64 |
|
|
65 |
?> |