function main() { $this->PageSubtitle = "Imports"; // Process uploaded files if there are any if (!gpExists('gp_xajax')) { foreach ($_FILES as $onefile) { if (!$onefile['error']) { // Generate a previously unused name, give up after 20 tries $dir = $GLOBALS['AG']['dirs']['root'] . 'tmp/'; $count = 0; while (true) { $fn = $onefile['name'] . '.' . rand(1000, 9999); $fs = $dir . $fn; if (!file_exists($fs)) { break; } $count++; if ($count > 20) { $fn = ''; break; } } if ($fn == '') { continue; } // skip this file, we couldn't name it // If we got to here, then we have a good name to use, lets copy // the file over. move_uploaded_file($onefile['tmp_name'], $fs); $newfile = array('name' => $onefile['name'], 'uname' => $fs, 'type' => $onefile['type'], 'error' => $onefile['error'], 'size' => $onefile['size']); vgfSet('files', array($newfile)); break; // only do one file! } } } // Routing if (gp('gp_fbproc') == '1') { return $this->fbProc(); } if (gpExists('gp_xajax')) { return $this->xAjax(); } // Obtain the basic parameters we need on this page, and then assign // them to hidden variables so that FORM POSTs will return here. $tid = gp('gp_table_id'); $t = DD_TableRef(gp('gp_table_id')); hidden('gp_page', 'x_import'); hidden('gp_nofile', ''); hidden('gp_table_id', gp('gp_table_id')); // Process requests. If they uploaded a file, save the // info to the session. If they requested file destroy, // throw it away. $files = vgfGet('files', array()); $fi = null; if (isset($files[0])) { $fi = $files[0]; SessionSet('importfile', $fi); } if (gp('gp_nofile') == 1) { SessionUnSet('importfile'); $fi = null; } // If a file is uploaded we just output the div and then call // back for the content // On this branch we // - - - - - - - - - - - - - - - - - - - - - - - - - - - - // BEGIN HTML // - - - - - - - - - - - - - - - - - - - - - - - - - - - - ?> <h1>Table Import</h1> <p><b>Destination Table:</b><?php echo hLinkPage('', $tid); ?> </p> <p><b>Table Name in Database:</b> <?php echo $tid; ?> . </p> <p>This is standardized import program that can accept file uploads in the popular "CSV" format. The first row is expected to name columns, and all subsequent rows are expected to contain comma-separated values. </p> <p>This routine will match known column names and display the columns that will be imported. </p> <hr /> <?php if ($fi) { ?> <div id="xajax"></div> <div id="xajaxm"></div> <script type="text/javascript"> </script> <?php elementAdd('scriptend', "andrax('?gp_page=x_import&gp_table_id=" . gp("gp_table_id") . "&gp_xajax=1');"); return; } else { ?> <h2>File Upload</h2> <p>Please upload a file to process. <p><?php echo hFileUpload(); ?> <?php } }
function main() { // When building, just do this, then leave if (gp('gp_build') == 1) { SessionSet('UID', SessionGet('xUID')); SessionSet('PWD', SessionGet('xPWD')); ob_start(); $GLOBALS["parm"] = array("DBSERVER_URL" => "localhost", "UID" => SessionGet('UID'), "DIR_PUBLIC" => realpath($GLOBALS['AG']['dirs']['root'] . '..'), "DIR_PUBLIC_APP" => "andro", "APP" => "andro", "APPDSC" => "Andromeda Node Manager", "SPEC_BOOT" => "AndroDBB", "SPEC_LIB" => "andro_universal", "SPEC_LIST" => "andro.dd.yaml"); include "androBuild.php"; SessionSet('UID', 'andro'); SessionSet('PWD', 'andro'); echo ob_get_clean(); return; } ob_start(); ?> td.bad { color: red ; font-weight: bolder; } td.good { color: green; } div.config { border: 1px solid gray; background-color: #C0E0FF; margin: 5px 20px 5px 20px; padding: 5px; white-space: pre; font-family: monospace; } textarea.config { background-color: lightsteelblue; margin: 5px 20px 5px 20px; padding: 5px; font-family: monospace; } div.cli { margin: 1em 20px 1em 20px; padding: 5px; border: 1px solid gray; background-color: #404040; color: orange; white-space: pre; font-weight: bolder; } <?php elementAdd('styles', ob_get_clean()); // Define the meta data for the steps $steps = array(array(false, 'PostgreSQL support in PHP'), array(false, 'Connect as superuser to PostgreSQL'), array(false, 'Confirm PostgreSQL >= 8.1'), array(false, 'Create Node Manager Database'), array(false, 'Initialize Node Manager Database'), array(false, 'Final Notes')); // Begin by assuming we must start here $current_step = 0; // Call the routine that figures out what step we are on $current_step = $this->DoTests($steps); ?> <h1>New Install Detected</h1> <p>This looks like a new Andromeda node. This wizard will help you to install Andromeda and get it running. <h2>Status Checklist</h2> <p>The installation process consists of completing each of the items here. Some of the items can be checked automatically, and some will require your feedback. </p> <br> <table style='border: 1px solid black'> <tr> <td class="dhead">Complete <td class="dhead">Step <td class="dhead">Rollback <?php foreach ($steps as $index => $step) { echo "<tr><td class='" . ($step[0] ? 'good' : 'bad') . "'>" . ($step[0] ? 'YES' : 'NO') . "<td>" . $step[1] . "<td>"; if ($index < $current_step) { echo "<a href='?stepreset=" . $index . "'>Rollback</a>"; } } ?> </table> <br> <h2>Next Step: <?php echo $steps[$current_step][1]; ?> </h2> <?php if ($this->error) { echo "<div class='errorbox'>" . $this->error . "</div>"; } if (!$steps[0][0]) { $this->PGPhp(); } elseif (!$steps[1][0]) { $this->PGConnect(); } elseif (!$steps[2][0]) { $this->PG81(); } elseif (!$steps[3][0]) { $this->NMCreate(); } elseif (!$steps[4][0]) { $this->NMInit(); } elseif (!$steps[5][0]) { $this->Final0(); } ?> <br><br> <hr> <h3>A Note About Install Mode</h3> <p>Install mode is triggered by the presence of the file 'install.php' in the application directory: <p><?php echo $GLOBALS['AG']['dirs']['application']; ?> <p>If you are an expert and wish to bypass this wizard, then simply remove or rename that file and Andromeda will attempt to operate normally. <?php }