From 08297ea0983e118dd63cd3be2f6ecf4bb8242c0d Mon Sep 17 00:00:00 2001 From: Alex Date: Thu, 5 Mar 2015 12:59:31 +0300 Subject: [PATCH] forgotten to include functions.import.php --- admin/import.php | 345 ++++++++++++++++++--------------- functions/functions.import.php | 31 +-- 2 files changed, 204 insertions(+), 172 deletions(-) diff --git a/admin/import.php b/admin/import.php index e2989d00..63e7ebd6 100644 --- a/admin/import.php +++ b/admin/import.php @@ -1,158 +1,187 @@ - " . T_("Go back") . ""; - - - //verify each GET field is unique (except import_form) - $sfields = array(); - foreach($_POST as $getv => $val) - //clean up? - $sfields[$getv] = $val; - - $error = verify_fields($sfields); - - $description = $_POST['description']; - - if ($error == "") - { //verified so upload - if (import_file($_POST['filename'],$description,$sfields)) - { - print "

" . T_("Successfully imported sample") . " 

$description

"; - } - else - { - print -"

" . T_("Error importing file. Please try again") . "

"; - } - } - else - print "

" . T_("Error:") . " $error

" . T_("Please go back in your browser and fix the problem") . "

"; - - //verifiy that exactly one primary phone number is selected - //upload to database - - xhtml_foot($js_foot); - -} -else if (isset($_POST['import_file'])) -{ - //file has been submitted - $subtitle = T_("Select columns to import"); - xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); - echo " " . T_("Go back") . ""; - - - print "
"; - - $tmpfname = tempnam(TEMPORARY_DIRECTORY, "FOO"); - move_uploaded_file($_FILES['file']['tmp_name'],$tmpfname); - - display_table(get_first_row($tmpfname)); - - ?> -

- -
- -
- -
-
- -
- - - -  " . T_("Go back") . ""; - - $ua = $_SERVER['HTTP_USER_AGENT']; - if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; - //print "ua=" . $_SERVER['HTTP_USER_AGENT']; - ?> - -
-
- - - - -
- - -
- " type="file" accept="" /> -
-
- - -
- -
- " class="form-control input-md"> -
-
- - -
- -
- -
-
- -
-
- - + + * @copyright Deakin University 2007,2008 + * @package queXS + * @subpackage admin + * @link http://www.deakin.edu.au/dcarf/ queXS was writen for DCARF - Deakin Computer Assisted Research Facility + * @license http://opensource.org/licenses/gpl-2.0.php The GNU General Public License (GPL) Version 2 + * + */ + +/** + * Configuration file + */ +include ("../config.inc.php"); + +/** + * XHTML functions + */ +include ("../functions/functions.xhtml.php"); + +/** + * Sample import functions + */ +include("../functions/functions.import.php"); + +$css = array( +"../include/bootstrap-3.3.2/css/bootstrap.min.css", +"../include/bootstrap-3.3.2/css/bootstrap-theme.min.css", +"../include/font-awesome-4.3.0/css/font-awesome.css", +"../css/bootstrap-switch.min.css", +"../css/custom.css" + ); +$js_head = array( +"../js/jquery-2.1.3.min.js", +"../include/bootstrap-3.3.2/js/bootstrap.min.js", +"../js/bootstrap-switch.min.js" + ); +$js_foot = array( +"../js/bootstrap-filestyle.min.js", +"../js/custom.js" + ); + +if (isset($_POST['import_form'])) +{ + //form has been submitted + $subtitle = T_("Validating and uploading"); + xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); + echo " " . T_("Go back") . ""; + + + //verify each GET field is unique (except import_form) + $sfields = array(); + foreach($_POST as $getv => $val) + //clean up? + $sfields[$getv] = $val; + + $error = verify_fields($sfields); + + $description = $_POST['description']; + + if ($error == "") + { //verified so upload + if (import_file($_POST['filename'],$description,$sfields)) + { + print "

" . T_("Successfully imported sample") . " 

$description

"; + } + else + { + print -"

" . T_("Error importing file. Please try again") . "

"; + } + } + else + print "

" . T_("Error:") . " $error

" . T_("Please go back in your browser and fix the problem") . "

"; + + //verifiy that exactly one primary phone number is selected + //upload to database + + xhtml_foot($js_foot); + +} +else if (isset($_POST['import_file'])) +{ + //file has been submitted + $subtitle = T_("Select columns to import"); + xhtml_head(T_("Import sample") . ":",true,$css,$js_head,false,false,false,$subtitle); + echo " " . T_("Go back") . ""; + + + print "
"; + + $tmpfname = tempnam(TEMPORARY_DIRECTORY, "FOO"); + move_uploaded_file($_FILES['file']['tmp_name'],$tmpfname); + + display_table(get_first_row($tmpfname)); + + + + ?> +

+ +
+ +
+ +
+
+ +
+ + + +  " . T_("Go back") . ""; + + $ua = $_SERVER['HTTP_USER_AGENT']; + if (preg_match('/Firefox/i', $ua)) $csv= "text/csv"; else $csv= ".csv"; + //print "ua=" . $_SERVER['HTTP_USER_AGENT']; + ?> + +
+
+ + + + +
+ + +
+ " type="file" accept="" /> +
+
+ + +
+ +
+ " class="form-control input-md"> +
+
+ + +
+ +
+ +
+
+ +
+
+ + diff --git a/functions/functions.import.php b/functions/functions.import.php index 60514330..ee7f75d3 100644 --- a/functions/functions.import.php +++ b/functions/functions.import.php @@ -123,8 +123,8 @@ function verify_fields($fields) */ function display_table($data) { - print ""; - print ""; + print "
" . T_("Import?") . "" . T_("Name") . "" . T_("Type") . "" . T_("Allow operator to see?") . "
"; + print ""; $row = 1; global $db; @@ -140,21 +140,24 @@ function display_table($data) $checked = "checked"; if (empty($val)) $val = "samp_$row"; - print ""; - print ""; + print " + + + "; + print ""; print ""; $row++; - } - print "
" . T_("Selected file column name") . "" . T_("Import ?") . "" . T_("New Sample Variable Name") . "" . T_("Variable Type") . "" . T_("Show to operator?") . "
$value"; - print "
$value"; + print "
"; + print ""; }