Source for file action.php
Documentation is available at action.php
// +----------------------------------------------------------------------+
// | PHP versions 4 and 5 |
// +----------------------------------------------------------------------+
// | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox, |
// | Stig. S. Bakken, Lukas Smith, Igor Feghali |
// | All rights reserved. |
// +----------------------------------------------------------------------+
// | MDB2_Schema enables users to maintain RDBMS independant schema files |
// | in XML that can be used to manipulate both data and database schemas |
// | This LICENSE is in the BSD license style. |
// | Redistribution and use in source and binary forms, with or without |
// | modification, are permitted provided that the following conditions |
// | Redistributions of source code must retain the above copyright |
// | notice, this list of conditions and the following disclaimer. |
// | Redistributions in binary form must reproduce the above copyright |
// | notice, this list of conditions and the following disclaimer in the |
// | documentation and/or other materials provided with the distribution. |
// | Neither the name of Manuel Lemos, Tomas V.V.Cox, Stig. S. Bakken, |
// | Lukas Smith, Igor Feghali nor the names of his contributors may be |
// | used to endorse or promote products derived from this software |
// | without specific prior written permission. |
// | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
// | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
// | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
// | FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
// | REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
// | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
// | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS|
// | OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
// | AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
// | LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY|
// | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
// | POSSIBILITY OF SUCH DAMAGE. |
// +----------------------------------------------------------------------+
// | Author: Lukas Smith <smith@pooteeweet.org> |
// | Author: Igor Feghali <ifeghali@php.net> |
// +----------------------------------------------------------------------+
// $Id: action.php,v 1.2 2008/11/17 00:24:52 ifeghali Exp $
* This is all rather ugly code, thats probably very much XSS exploitable etc.
* However the idea was to keep the magic and dependencies low, to just
* illustrate the MDB2_Schema API a bit.
require_once 'MDB2/Schema.php';
require_once 'class.inc.php';
$data = & MDB2_Schema_Example ::factory ($_GET);
if (PEAR ::isError ($data)) {
header('location: index.php');
if (PEAR ::isError ($schema)) {
$error = $schema->getMessage () . ' ' . $schema->getUserInfo ();
header('location: index.php');
switch ($data->dumptype ) {
$definition = $schema->getDefinitionFromDatabase ();
if (PEAR ::isError ($definition)) {
$error = $definition->getMessage () . ' ' . $definition->getUserInfo ();
$operation = $schema->dumpDatabase ($definition, $dump_config, $dump_what);
if (PEAR ::isError ($operation)) {
$error = $operation->getMessage () . ' ' . $operation->getUserInfo ();
if ($data->disable_query ) {
$debug_tmp = $schema->db ->getOption ('debug');
$schema->db ->setOption ('debug', true );
$debug_handler_tmp = $schema->db ->getOption ('debug_handler');
$schema->db ->setOption ('debug_handler', 'printQueries');
'output' => $data->file. '.old'
$definition = $schema->getDefinitionFromDatabase ();
if (PEAR ::isError ($definition)) {
$error = $definition->getMessage () . ' ' . $definition->getUserInfo ();
if (PEAR ::isError ($operation)) {
$error = $operation->getMessage () . ' ' . $operation->getUserInfo ();
$operation = $schema->updateDatabase ($data->file
, $data->file. '.old', array (), $data->disable_query
if (PEAR ::isError ($operation)) {
$error = $operation->getMessage () . ' ' . $operation->getUserInfo ();
if ($data->disable_query ) {
$schema->db ->setOption ('debug', $debug_tmp);
$schema->db ->setOption ('debug_handler', $debug_handler_tmp);
if ($data->disable_query ) {
$debug_tmp = $schema->db ->getOption ('debug');
$schema->db ->setOption ('debug', true );
$debug_handler_tmp = $schema->db ->getOption ('debug_handler');
$schema->db ->setOption ('debug_handler', 'printQueries');
$definition = $schema->parseDatabaseDefinition (
$data->file, false , array (), $schema->options ['fail_on_invalid_names']
if (PEAR ::isError ($definition)) {
$error = $definition->getMessage () . ' ' . $definition->getUserInfo ();
$schema->db ->setOption ('disable_query', $data->disable_query );
$operation = $schema->createDatabase ($definition);
$schema->db ->setOption ('disable_query', false );
if (PEAR ::isError ($operation)) {
$error = $operation->getMessage () . ' ' . $operation->getUserInfo ();
if ($data->disable_query ) {
$schema->db ->setOption ('debug', $debug_tmp);
$schema->db ->setOption ('debug_handler', $debug_handler_tmp);
/* INITIALIZE DATABASE */
if ($data->disable_query ) {
$debug_tmp = $schema->db ->getOption ('debug');
$schema->db ->setOption ('debug', true );
$debug_handler_tmp = $schema->db ->getOption ('debug_handler');
$schema->db ->setOption ('debug_handler', 'printQueries');
$definition = $schema->getDefinitionFromDatabase ();
if (PEAR ::isError ($definition)) {
$error = $definition->getMessage () . ' ' . $definition->getUserInfo ();
$schema->db ->setOption ('disable_query', $data->disable_query );
$operation = $schema->writeInitialization ($data->file, $definition);
if (PEAR ::isError ($operation)) {
$error = $operation->getMessage () . ' ' . $operation->getUserInfo ();
$schema->db ->setOption ('disable_query', false );
if ($data->disable_query ) {
$schema->db ->setOption ('debug', $debug_tmp);
$schema->db ->setOption ('debug_handler', $debug_handler_tmp);
Documentation generated on Mon, 11 Mar 2019 15:26:16 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|