MDB2_Schema
[ class tree: MDB2_Schema ] [ index: MDB2_Schema ] [ all elements ]

Source for file index.php

Documentation is available at index.php

  1. <?php
  2. // +----------------------------------------------------------------------+
  3. // | PHP versions 4 and 5                                                 |
  4. // +----------------------------------------------------------------------+
  5. // | Copyright (c) 1998-2008 Manuel Lemos, Tomas V.V.Cox,                 |
  6. // | Stig. S. Bakken, Lukas Smith, Igor Feghali                           |
  7. // | All rights reserved.                                                 |
  8. // +----------------------------------------------------------------------+
  9. // | MDB2_Schema enables users to maintain RDBMS independant schema files |
  10. // | in XML that can be used to manipulate both data and database schemas |
  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, Igor Feghali nor the names of his contributors may be   |
  26. // | used to endorse or promote products derived from this software       |
  27. // | without specific prior 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@pooteeweet.org>                           |
  43. // | Author: Igor Feghali <ifeghali@php.net>                              |
  44. // +----------------------------------------------------------------------+
  45. //
  46. // $Id: index.php,v 1.1 2008/11/01 13:08:38 ifeghali Exp $
  47. //
  48.  
  49. /**
  50.  * This is all rather ugly code, thats probably very much XSS exploitable etc.
  51.  * However the idea was to keep the magic and dependencies low, to just
  52.  * illustrate the MDB2_Schema API a bit.
  53.  */
  54.  
  55. if (!isset($_REQUEST['loaded'])) {
  56.     require_once 'class.inc.php';
  57.     $defaults = new MDB2_Schema_Example();
  58.     $defaults->saveCookies();
  59.     header('location: index.php?loaded=1');
  60.     exit;
  61. }
  62.  
  63. $databases = array(
  64.     'mysql'  => 'MySQL',
  65.     'mysqli' => 'MySQLi',
  66.     'pgsql'  => 'PostGreSQL',
  67.     'sqlite' => 'SQLite'
  68. );
  69. ?>
  70. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  71.         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  72.       <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  73.       <head><title>MDB2_Schema Web Frontend</title></head>
  74. <body>
  75. <?php
  76. if (isset($_COOKIE['error']&& $_COOKIE['error']{
  77.     echo '<h1>Error</h1>';
  78.     echo '<div id="errors"><ul>';
  79.     echo '<li>' $_COOKIE['error''</li>';
  80.     echo '</ul></div>';
  81.     setcookie('error','');
  82. }
  83. ?>
  84.     <form method="get" action="action.php">
  85.     <fieldset>
  86.     <legend>Database information</legend>
  87.  
  88.     <table>
  89.     <tr>
  90.     <td><label for="type">Database Type:</label></td>
  91.         <td>
  92.         <select name="type" id="type">
  93. <?php
  94.     foreach ($databases as $key => $name{
  95.         echo str_repeat(' '8).'<option value="' $key '"';
  96.         if (isset($_REQUEST['type']&& $_REQUEST['type'== $key{
  97.             echo ' selected="selected"';
  98.         }
  99.         echo ">$name</option>\n";
  100.     }
  101. ?>
  102.         </select>
  103.         </td>
  104.     </tr>
  105.     <tr>
  106.         <td><label for="user">Username:</label></td>
  107.         <td><input type="text" name="user" id="user" value="<?php @print $_REQUEST['username']?>" /></td>
  108.     </tr>
  109.     <tr>
  110.         <td><label for="pass">Password:</label></td>
  111.         <td><input type="text" name="pass" id="pass" value="<?php @print $_REQUEST['password']?>" /></td>
  112.     </tr>
  113.     <tr>
  114.         <td><label for="host">Host:</label></td>
  115.         <td><input type="text" name="host" id="host" value="<?php @print $_REQUEST['hostspec']?>" /></td>
  116.     </tr>
  117.     <tr>
  118.         <td><label for="name">Databasename:</label></td>
  119.         <td><input type="text" name="name" id="name" value="<?php @print $_REQUEST['database']?>" /></td>
  120.     </tr>
  121.     <tr>
  122.         <td><label for="char">Table Charset:</label></td>
  123.         <td><input type="text" name="char" id="char" value="<?php @print $_REQUEST['charset']?>" /></td>
  124.     </tr>
  125.     <tr>
  126.         <td><label for="file">Filename:</label></td>
  127.         <td><input type="text" name="file" id="file" value="<?php @print $_REQUEST['file']?>" /></td>
  128.     </tr>
  129.     <tr>
  130.         <td><label for="dump">Dump:</label></td>
  131.         <td><input type="radio" name="action" id="dump" value="dump" <?php if (isset($_REQUEST['action']&& $_REQUEST['action'== 'dump'{echo (' checked="checked"');?> />
  132.         <select id="dumptype" name="dumptype">
  133.             <option value="all"<?php if (isset($_REQUEST['dumptype']&& $_REQUEST['dumptype'== 'all'{echo (' selected="selected"');?>>All</option>
  134.             <option value="structure"<?php if (isset($_REQUEST['dumptype']&& $_REQUEST['dumptype'== 'structure'{echo (' selected="selected"');?>>Structure</option>
  135.             <option value="content"<?php if (isset($_REQUEST['dumptype']&& $_REQUEST['dumptype'== 'content'{echo (' selected="selected"');?>>Content</option>
  136.         </select>
  137.         </td>
  138.     </tr>
  139.     <tr>
  140.         <td><label for="create">Create:</label></td>
  141.         <td><input type="radio" name="action" id="create" value="create" <?php if (isset($_REQUEST['action']&& $_REQUEST['action'== 'create'echo 'checked="checked"';?> /></td>
  142.     </tr>
  143.     <tr>
  144.         <td><label for="update">Update:</label></td>
  145.         <td><input type="radio" name="action" id="update" value="update" <?php if (isset($_REQUEST['action']&& $_REQUEST['action'== 'update'echo 'checked="checked"';?> /></td>
  146.     </tr>
  147.     <tr>
  148.         <td><label for="update">Initialize:</label></td>
  149.         <td><input type="radio" name="action" id="initialize" value="initialize" <?php if (isset($_REQUEST['action']&& $_REQUEST['action'== 'initialize'echo 'checked="checked"';?> /></td>
  150.     </tr>
  151.     </table>
  152.     </fieldset>
  153.  
  154.     <fieldset>
  155.     <legend>Options</legend>
  156.     <table>
  157.     <tr>
  158.         <td><label for="log_line_break">Log line break:</label></td>
  159.         <td><input type="text" name="log_line_break" id="log_line_break" value="<?php @print $_REQUEST['log_line_break']?>" /></td>
  160.     </tr>
  161.     <tr>
  162.         <td><label for="idxname_format">Index Name Format:</label></td>
  163.         <td><input type="text" name="idxname_format" id="idxname_format" value="<?php @print $_REQUEST['idxname_format']?>" /></td>
  164.     </tr>
  165.     <tr>
  166.         <td><label for="DBA_username">DBA_username:</label></td>
  167.         <td><input type="text" name="DBA_username" id="DBA_username" value="<?php @print $_REQUEST['DBA_username']?>" /></td>
  168.     </tr>
  169.     <tr>
  170.         <td><label for="DBA_password">DBA_password:</label></td>
  171.         <td><input type="text" name="DBA_password" id="DBA_password" value="<?php @print $_REQUEST['DBA_password']?>" /></td>
  172.     </tr>
  173.     <tr>
  174.         <td><label for="default_table_type">Default Table Type:</label></td>
  175.         <td><input type="text" name="default_table_type" id="default_table_type" value="<?php @print $_REQUEST['default_table_type']?>" /></td>
  176.     </tr>
  177.     <tr>
  178.         <td><label for="debug">Debug:</label></td>
  179.         <td><input type="checkbox" name="debug" id="debug" value="1" <?php if (isset($_REQUEST['debug']&& $_REQUEST['debug']{echo (' checked="checked"');?>/></td>
  180.     </tr>
  181.     <tr>
  182.         <td><label for="use_transactions">Use Transactions:</label></td>
  183.         <td><input type="checkbox" name="use_transactions" id="use_transactions" value="1" <?php if (isset($_REQUEST['use_transactions']&& $_REQUEST['use_transactions']{echo (' checked="checked"');?>/></td>
  184.     </tr>
  185.     <tr>
  186.         <td><label for="quote_identifier">Quote Identifier:</label></td>
  187.         <td><input type="checkbox" name="quote_identifier" id="quote_identifier" value="1" <?php if (isset($_REQUEST['quote_identifier']&& $_REQUEST['quote_identifier']{echo (' checked="checked"');?>/></td>
  188.     </tr>
  189.     <tr>
  190.         <td><label for="force_defaults">Force Defaults:</label></td>
  191.         <td><input type="checkbox" name="force_defaults" id="force_defaults" value="1" <?php if (isset($_REQUEST['force_defaults']&& $_REQUEST['force_defaults']{echo (' checked="checked"');?>/></td>
  192.     </tr>
  193.     <tr>
  194.         <td><label for="portability">Portability:</label></td>
  195.         <td><input type="checkbox" name="portability" id="portability" value="1" <?php if (isset($_REQUEST['portability']&& $_REQUEST['portability']{echo (' checked="checked"');?>/></td>
  196.     </tr>
  197.     <tr>
  198.         <td><label for="show_structure">Show database structure:</label></td>
  199.         <td><input type="checkbox" name="show_structure" id="show_structure" value="1" <?php if (isset($_REQUEST['show_structure']&& $_REQUEST['show_structure']{echo (' checked="checked"');?>/></td>
  200.     </tr>
  201.     <tr>
  202.         <td><label for="disable_query">Do not modify database:</label></td>
  203.         <td><input type="checkbox" name="disable_query" id="disable_query" value="1" <?php if (isset($_REQUEST['disable_query']&& $_REQUEST['disable_query']{echo (' checked="checked"');?>/></td>
  204.     </tr>
  205.     </table>
  206.     </fieldset>
  207.  
  208.     <p><input type="submit" name="submit" value="ok" /><input type="button" value="reset" /></p>
  209.     </form>
  210. </body>
  211. </html>

Documentation generated on Mon, 11 Mar 2019 15:26:17 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.