_docs/_input/scripts/export_netofficedb.php

00001 <html>
00002     <head>
00003         <title>Export NetOffice database to XML</title>
00004         <link href="../install/styles.css" rel="stylesheet" type="text/css">
00005     </head>
00006 <body>
00007 <form method="post" action="<? print $_SERVER['PHP_SELF']; ?>">
00008 <div class="form">
00009 <p>
00010     <label>Type database:</label>
00011     <input class='inp required' name='db_type' value='mysql'>
00012 </p>
00013 <p>
00014     <label> Hostname (for Database Server):</label>
00015     <input class='inp required' name='db_host' value='localhost'></p>
00016 <p>
00017     <label>Username (for Database):</label>
00018     <input class='inp required' name='db_user' value='root'>
00019 </p>
00020 <p>
00021     <label>Password (for Database):</label>
00022     <input type=password class='inp' name='db_pass' value=''>
00023 </p>
00024 <p>
00025     <label>Name of database:</label>
00026     <input class='inp required' name='db_name' value='netoffice'>
00027 </p>
00028 <p>
00029     <label>SQL Table prefix (e.g. "pr_"):</label>
00030     <input class='inp' name='db_prefix' value=''>
00031 </p>
00032 <p>
00033     <label>Filename to write XML data:</label>
00034     <input class='inp required' name='filename' value='/tmp/netofficedb.xml'>
00035 </p>
00036 <p>
00037     <input class=button_submit type=submit value='Export' name='export'>
00038 </p>
00039 </div>
00040 </form>
00041 <?php
00042 if ($_POST['export']) {
00043     require_once("../db/class_export.inc");
00044 
00045     $dbtype = $_POST['db_type'];
00046     $dbhost = $_POST['db_host'];
00047     $dbuser = $_POST['db_user'];
00048     $dbpass = $_POST['db_pass'];
00049     $dbname = $_POST['db_name'];
00050     $prefix = $_POST['db_prefix'];
00051     $file   = $_POST['filename'];
00052 
00053     if ("mysql" == $dbtype)
00054         $dbh = mysql_pconnect($dbhost, $dbuser, $dbpass);
00055 
00056     if (! is_resource($dbh)) {
00057         print "<h2>Connection to database failed</h2>";
00058         exit;
00059     }
00060 
00061     if(!mysql_select_db($dbname, $dbh)) {
00062         print "<h2>Database selection failed</h2>";
00063         exit;
00064     }
00065 
00066     $export = new NetOfficeExport($dbh, $prefix);
00067     file_put_contents($file, $export->doExport());
00068 
00069     if (file_exists($file)) {
00070 ?>
00071 <h2>Successfully exported</h2>
00072 <?php
00073     } else {
00074 ?>
00075 <h2>Database export failed</h2>
00076 <?php
00077     }
00078 }
00079 ?>
00080 </body>
00081 </html>

Generated on Sun Mar 4 17:19:27 2007 for streber by  doxygen 1.5.1-p1