Subversion-Projekte lars-tiefland.php_share

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
1 lars 1
<?php
2
// +----------------------------------------------------------------------+
3
// | PHP Version 4                                                        |
4
// +----------------------------------------------------------------------+
5
// | Copyright (c) 1998-2004 Manuel Lemos, Tomas V.V.Cox,                 |
6
// | Stig. S. Bakken, Lukas Smith                                         |
7
// | All rights reserved.                                                 |
8
// +----------------------------------------------------------------------+
9
// | MDB is a merge of PEAR DB and Metabases that provides a unified DB   |
10
// | API as well as database abstraction for PHP applications.            |
11
// | This LICENSE is in the BSD license style.                            |
12
// |                                                                      |
13
// | Redistribution and use in source and binary forms, with or without   |
14
// | modification, are permitted provided that the following conditions   |
15
// | are met:                                                             |
16
// |                                                                      |
17
// | Redistributions of source code must retain the above copyright       |
18
// | notice, this list of conditions and the following disclaimer.        |
19
// |                                                                      |
20
// | Redistributions in binary form must reproduce the above copyright    |
21
// | notice, this list of conditions and the following disclaimer in the  |
22
// | documentation and/or other materials provided with the distribution. |
23
// |                                                                      |
24
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken,    |
25
// | Lukas Smith nor the names of his contributors may be used to endorse |
26
// | or promote products derived from this software without specific prior|
27
// | written permission.                                                  |
28
// |                                                                      |
29
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS  |
30
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT    |
31
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS    |
32
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE      |
33
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,          |
34
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
35
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
36
// |  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED  |
37
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT          |
38
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
39
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE          |
40
// | POSSIBILITY OF SUCH DAMAGE.                                          |
41
// +----------------------------------------------------------------------+
42
// | Author: Lukas Smith <smith@backendmedia.com>                         |
43
// +----------------------------------------------------------------------+
44
//
45
// $Id: reverse_engineer_xml_schema.php,v 1.17.4.3 2004/03/10 14:43:28 lsmith Exp $
46
//
47
 
48
/**
49
 * MDB reverse engineering of xml schemas script.
50
 *
51
 * @package MDB
52
 * @category Database
53
 * @author  Lukas Smith <smith@backendmedia.com>
54
 */
55
 
56
echo ('
57
<html>
58
<body>
59
');
60
 
61
    if(isset($_REQUEST['submit']) && $_REQUEST['file'] != '') {
62
        // BC hack to define PATH_SEPARATOR for version of PHP prior 4.3
63
        if(!defined('PATH_SEPARATOR')) {
64
            if(defined('DIRECTORY_SEPARATOR') && DIRECTORY_SEPARATOR == "\\") {
65
                define('PATH_SEPARATOR', ';');
66
            } else {
67
                define('PATH_SEPARATOR', ':');
68
            }
69
        }
70
        ini_set('include_path', '..'.PATH_SEPARATOR.ini_get('include_path'));
71
        require_once('MDB.php');
72
        @include_once('Var_Dump.php');
73
        MDB::loadFile('Manager');
74
        $dsn = $_REQUEST['type'].'://'.$_REQUEST['user'].':'.$_REQUEST['pass'].'@'.$_REQUEST['host'].'/'.$_REQUEST['name'];
75
 
76
        $manager =& new MDB_Manager;
77
        $err = $manager->connect($dsn);
78
        if(MDB::isError($err)) {
79
            $error = $err->getMessage();
80
        } else {
81
            $manager->captureDebugOutput(TRUE);
82
            $manager->database->setOption('log_line_break', '<br>');
83
            if($_REQUEST['action']) {
84
                set_time_limit(0);
85
            }
86
            if($_REQUEST['action'] == 'dump') {
87
                switch ($_REQUEST['dump']) {
88
                    case 'structure':
89
                        $dump_what = MDB_MANAGER_DUMP_STRUCTURE;
90
                        break;
91
                    case 'content':
92
                        $dump_what = MDB_MANAGER_DUMP_CONTENT;
93
                        break;
94
                    default:
95
                        $dump_what = MDB_MANAGER_DUMP_ALL;
96
                        break;
97
                }
98
                $dump_config = array(
99
                    'Output_Mode' => 'file',
100
                    'Output' => $_REQUEST['file']
101
                );
102
                if (class_exists('Var_Dump')) {
103
                    Var_Dump::display($manager->dumpDatabase($dump_config, $dump_what));
104
                } else {
105
                    var_dump($manager->dumpDatabase($dump_config, $dump_what));
106
                }
107
            } else if($_REQUEST['action'] == 'create') {
108
                if (class_exists('Var_Dump')) {
109
                    Var_Dump::display($manager->updateDatabase($_REQUEST['file']));
110
                } else {
111
                    var_dump($manager->updateDatabase($_REQUEST['file']));
112
                }
113
            } else {
114
                $error = 'no action selected';
115
            }
116
            $warnings = $manager->getWarnings();
117
            if(count($warnings) > 0) {
118
                echo('Warnings<br>');
119
                if (class_exists('Var_Dump')) {
120
                    Var_Dump::display($warnings);
121
                } else {
122
                    var_dump($warnings);
123
                }
124
            }
125
            if($manager->options['debug']) {
126
                echo('Debug messages<br>');
127
                echo($manager->debugOutput().'<br>');
128
            }
129
            echo('Database structure<br>');
130
            if (class_exists('Var_Dump')) {
131
                Var_Dump::display($manager->database_definition);
132
            } else {
133
                var_dump($manager->database_definition);
134
            }
135
            $manager->disconnect();
136
        }
137
    }
138
 
139
    if (!isset($_REQUEST['submit']) || isset($error)) {
140
        if (isset($error) && $error) {
141
            echo($error.'<br>');
142
        }
143
        echo ('
144
            <form action="reverse_engineer_xml_schema.php">
145
            Database Type:
146
            <select name="type">
147
                <option value="mysql"');
148
                if(isset($_REQUEST['type']) && $_REQUEST['type'] == 'mysql') {echo ('selected');}
149
                echo ('>MySQL</option>
150
                <option value="pgsql"');
151
                if(isset($_REQUEST['type']) && $_REQUEST['type'] == 'mysql') {echo ('selected');}
152
                echo ('>Postgres</option>
153
            </select>
154
            <br />
155
            Username:
156
            <input type="text" name="user" value="'.(isset($_REQUEST['user']) ? $_REQUEST['user'] : '').'" />
157
            <br />
158
            Password:
159
            <input type="text" name="pass" value="'.(isset($_REQUEST['pass']) ? $_REQUEST['pass'] : '').'" />
160
            <br />
161
            Host:
162
            <input type="text" name="host" value="'.(isset($_REQUEST['host']) ? $_REQUEST['host'] : '').'" />
163
            <br />
164
            Databasename:
165
            <input type="text" name="name" value="'.(isset($_REQUEST['name']) ? $_REQUEST['name'] : '').'" />
166
            <br />
167
            Filename:
168
            <input type="text" name="file" value="'.(isset($_REQUEST['file']) ? $_REQUEST['file'] : '').'" />
169
            <br />
170
            Dump:
171
            <input type="radio" name="action" value="dump" />
172
            <select name="dump">
173
                <option value="all"');
174
                if(!isset($_REQUEST['dump']) || $_REQUEST['dump'] == 'all') {echo ('selected');}
175
                echo ('>All</option>
176
                <option value="structure"');
177
                if(isset($_REQUEST['dump']) && $_REQUEST['dump'] == 'structure') {echo ('selected');}
178
                echo ('>Structure</option>
179
                <option value="content"');
180
                if(isset($_REQUEST['dump']) && $_REQUEST['dump'] == 'content') {echo ('selected');}
181
                echo ('>Content</option>
182
            </select>
183
            <br />
184
            Create:
185
            <input type="radio" name="action" value="create" />
186
            <br />
187
            <input type="submit" name="submit" value="ok" />
188
        ');
189
    }
190
 
191
    echo ('
192
</form>
193
</body>
194
</html>
195
    ');
196
?>