From 055b7f921c3738b8de5999654b5485a2d117adb0 Mon Sep 17 00:00:00 2001 From: athreyab Date: Thu, 21 Feb 2013 05:12:18 +0000 Subject: [PATCH] code for contact upload script svn path=/; revision=430 --- .../ia_upload/contact_process.php | 104 ++++++++++++++++++ .../image_annotation_db/ia_upload/data.html | 18 +++ .../image_annotation_db/ia_upload/index.html | 18 +++ 3 files changed, 140 insertions(+) create mode 100755 Personnel/athreyab/image_annotation_db/ia_upload/contact_process.php create mode 100755 Personnel/athreyab/image_annotation_db/ia_upload/data.html create mode 100755 Personnel/athreyab/image_annotation_db/ia_upload/index.html diff --git a/Personnel/athreyab/image_annotation_db/ia_upload/contact_process.php b/Personnel/athreyab/image_annotation_db/ia_upload/contact_process.php new file mode 100755 index 0000000..64d6287 --- /dev/null +++ b/Personnel/athreyab/image_annotation_db/ia_upload/contact_process.php @@ -0,0 +1,104 @@ + 0 && $row[0] == '')) + return -1; + return $row[0]; + } + + function get_image_source_version_id($image_source_id,$source_version){ + $query = "select image_source_version_id from image_source_version where image_source_id='$image_source_id' and source_version='$source_version'"; + $row = getRowFromDB($query,"image source version id"); + if(count($row) == 0 || (count($row) > 0 && $row[0] == '')) + return -1; + return $row[0]; + } + + function save_image_source_version_information($image_source_id,$contact){ + $source_version = $contact['source_version']; + $publication_id = $contact['publication_id']; + $contribution_date = $contact['contribution_date']; + $mysqldate = date( 'Y-m-d H:i:s', $contribution_date ); + $contribution_date = strtotime( $mysqldate ); + + $id_from_db = get_image_source_version_id($image_source_id,$source_version); + if($id_from_db == -1){ + $query = "INSERT INTO image_source_version(image_source_id,source_version,contribution_date,publication_id) VALUES('$image_source_id','$source_version','$contribution_date','$publication_id')"; + $rsrcResult = mysql_query($query); + if (!$rsrcResult) { + echo "DB Error while trying to add new image source version information\n"; + echo 'MySQL Error: ' . mysql_error(); + exit(); + } + $id_from_db = get_image_source_version_id($image_source_id,$source_version); + } + return $id_from_db; + } + + $file = $_FILES['file']['tmp_name']; + $file_handle = fopen($file, "r"); + $contact = array(); + while (!feof($file_handle)) { + $line = fgets($file_handle); + $s = explode("\t",$line); + if($s[0] != "") + $contact[$s[0]] = $s[1]; + } + fclose($file_handle); + + if(count($contact) < 4 || $contact['source_name'] == '' || $contact['contributor_name'] == '' || $contact['contact_email'] == '' || $contact['contribution_date'] == ''){ + echo "Required information is missing. "; + } + else{ + $image_source_id = save_image_source_information($contact); + $image_source_version_id = save_image_source_version_information($image_source_id,$contact); + + if($image_source_id != -1 && $image_source_version_id != -1){ + echo "information saved successfully
"; + echo "Click here to upload annotated image data file"; + } + else{ + echo "Couldn't save information"; + exit(); + } + } + +?> diff --git a/Personnel/athreyab/image_annotation_db/ia_upload/data.html b/Personnel/athreyab/image_annotation_db/ia_upload/data.html new file mode 100755 index 0000000..8972814 --- /dev/null +++ b/Personnel/athreyab/image_annotation_db/ia_upload/data.html @@ -0,0 +1,18 @@ + + +Tool for uploading image annotation information + + +

Tool for uploading image annotation information

+

Step 2

+

Please upload the image annotation information file below

+


+
+ + +
+ +
+ + + diff --git a/Personnel/athreyab/image_annotation_db/ia_upload/index.html b/Personnel/athreyab/image_annotation_db/ia_upload/index.html new file mode 100755 index 0000000..1f3ded2 --- /dev/null +++ b/Personnel/athreyab/image_annotation_db/ia_upload/index.html @@ -0,0 +1,18 @@ + + +Tool for uploading image annotation information + + +

Tool for uploading image annotation information

+

Step 1

+

Please upload the contact information file below

+


+
+ + +
+ +
+ + + -- 2.34.1