Example #1
0
 */
include "../functions/functions.import.php";
xhtml_head(T_("Import data file"));
if (isset($_POST['import_file'])) {
    //file has been submitted
    $ddifname = tempnam("/tmp", "FOO");
    $datafname = tempnam("/tmp", "FOO");
    move_uploaded_file($_FILES['ddifile']['tmp_name'], $ddifname);
    move_uploaded_file($_FILES['datafile']['tmp_name'], $datafname);
    $data_id = new_data($_POST['description']);
    if ($data_id) {
        print "<p>" . T_("Created new data entry: ") . "{$data_id}</p>";
        $ds = import_ddi($ddifname, $data_id);
        if ($ds) {
            print "<p>" . T_("Created column strucure") . "</p>";
            $is = import_fixed_width($datafname, $data_id);
            if ($is != false) {
                print "<p>" . T_("Data imported successfully") . "</p>";
            }
        }
    }
} else {
    ?>
	<form enctype="multipart/form-data" action="" method="post">
	<p><input type="hidden" name="MAX_FILE_SIZE" value="1000000000" /></p>
	<p><?php 
    echo T_("Choose the DDI file file to upload:");
    ?>
<input name="ddifile" type="file" /></p>
	<p><?php 
    echo T_("Choose the Fixed width data file to upload:");
Example #2
0
/**
 * XHTML functions
 */
include "../functions/functions.xhtml.php";
/**
 * Import functions
 */
include "../functions/functions.import.php";
xhtml_head(T_("Import data file"), true, false, array('../js/display.js'));
if (isset($_POST['import_file']) && isset($_GET['data_id']) && isset($_GET['column_id'])) {
    //file has been submitted
    $datafname = tempnam("/tmp", "FOO");
    move_uploaded_file($_FILES['datafile']['tmp_name'], $datafname);
    $data_id = intval($_GET['data_id']);
    $column_id = intval($_GET['column_id']);
    $is = import_fixed_width($datafname, $data_id, $column_id);
    if ($is != false) {
        $rows = count($is);
        print "<p>" . T_("Data imported successfully") . " " . T_("Rows:") . " {$rows}</p>";
        if ($rows > 0) {
            include "../functions/functions.work.php";
            if (run_auto_processes(get_auto_processes($data_id), $is)) {
                p(T_("Successfully ran automatic processes"), "p");
            } else {
                p(T_("Failed to run automatic processes"), "p");
            }
        }
    } else {
        p(T_("Failed to import data"), "p");
    }
} else {