Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100755 98 lines (79 sloc) 3.041 kb
d4847048 »
2009-01-09 * let's not discriminate unix :) (= generalized paths)
1 #!/usr/bin/env php
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
2 <?php
155bbb8d »
2008-10-07 - added bin/killcache.php script (#1485434)
3 /*
4 +-----------------------------------------------------------------------+
30aa4cca »
2010-05-18 - Renamed all php-cli scripts to use .sh extension
5 | bin/dumpschema.sh |
155bbb8d »
2008-10-07 - added bin/killcache.php script (#1485434)
6 | |
e019f2d0 »
2010-09-25 - s/RoundCube/Roundcube/
7 | This file is part of the Roundcube Webmail client |
f5e7b353 »
2011-01-12 Bumbed version; Roundcube development is not Switzerland only
8 | Copyright (C) 2005-2009, The Roundcube Dev Team |
7fe3811c »
2012-01-18 Changed license to GNU GPLv3+ with exceptions for skins and plugins
9 | |
10 | Licensed under the GNU General Public License version 3 or |
11 | any later version with exceptions for skins & plugins. |
12 | See the README file for a full license statement. |
155bbb8d »
2008-10-07 - added bin/killcache.php script (#1485434)
13 | |
14 | PURPOSE: |
15 | Dumps database schema in XML format using MDB2_Schema |
16 | |
17 +-----------------------------------------------------------------------+
18 | Author: Thomas Bruederli <roundcube@gmail.com> |
19 +-----------------------------------------------------------------------+
20 */
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
21
da402d66 »
2008-10-07 #1485456: small improvements in scripts
22 define('INSTALL_PATH', realpath(dirname(__FILE__) . '/..') . '/' );
6cc3f588 »
2011-04-20 - Use clisetup.php where possible, remove redundant code
23
24 require INSTALL_PATH.'program/include/clisetup.php';
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
25
26 /** callback function for schema dump **/
27 function print_schema($dump)
28 {
29 foreach ((array)$dump as $part)
30 echo $dump . "\n";
31 }
32
33 $config = new rcube_config();
34
35 // don't allow public access if not in devel_mode
36 if (!$config->get('devel_mode') && $_SERVER['REMOTE_ADDR']) {
37 header("HTTP/1.0 401 Access denied");
38 die("Access denied!");
39 }
40
41 $options = array(
42 'use_transactions' => false,
43 'log_line_break' => "\n",
44 'idxname_format' => '%s',
45 'debug' => false,
46 'quote_identifier' => true,
47 'force_defaults' => false,
06c3d105 »
2008-10-07 - fix for postgresql
48 'portability' => false,
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
49 );
50
e905db13 »
2008-10-14 Set postgres-specific schema options + fix indentation
51 $dsnw = $config->get('db_dsnw');
52 $dsn_array = MDB2::parseDSN($dsnw);
53
54 // set options for postgres databases
55 if ($dsn_array['phptype'] == 'pgsql') {
56 $options['disable_smart_seqname'] = true;
57 $options['seqname_format'] = '%s';
58 }
59
60 $schema =& MDB2_Schema::factory($dsnw, $options);
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
61 $schema->db->supported['transactions'] = false;
62
e905db13 »
2008-10-14 Set postgres-specific schema options + fix indentation
63
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
64 // send as text/xml when opened in browser
65 if ($_SERVER['REMOTE_ADDR'])
66 header('Content-Type: text/xml');
67
68
69 if (PEAR::isError($schema)) {
70 $error = $schema->getMessage() . ' ' . $schema->getUserInfo();
71 }
72 else {
73 $dump_config = array(
74 // 'output_mode' => 'file',
75 'output' => 'print_schema',
76 );
155bbb8d »
2008-10-07 - added bin/killcache.php script (#1485434)
77
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
78 $definition = $schema->getDefinitionFromDatabase();
e905db13 »
2008-10-14 Set postgres-specific schema options + fix indentation
79 $definition['charset'] = 'utf8';
80
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
81 if (PEAR::isError($definition)) {
82 $error = $definition->getMessage() . ' ' . $definition->getUserInfo();
83 }
84 else {
85 $operation = $schema->dumpDatabase($definition, $dump_config, MDB2_SCHEMA_DUMP_STRUCTURE);
86 if (PEAR::isError($operation)) {
87 $error = $operation->getMessage() . ' ' . $operation->getUserInfo();
88 }
89 }
90 }
91
92 $schema->disconnect();
93
e905db13 »
2008-10-14 Set postgres-specific schema options + fix indentation
94 if ($error && !$_SERVER['REMOTE_ADDR'])
95 fputs(STDERR, $error);
1e9cd564 »
2008-09-18 Script to dump the current database schema using MDB2_Schema (for dev…
96
97 ?>
Something went wrong with that request. Please try again.