- Timestamp:
- Apr 22, 2026, 12:04:59 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pstamp-20260421/pstamp/web/upload.php
r25322 r42994 2 2 3 3 // get the locatl configuration variables 4 include "pstamp.php"; 4 require "pstamp.php"; 5 require "submitted.php"; 5 6 6 7 7 8 $user = $_SERVER['PHP_AUTH_USER']; 8 9 $passwd = $_SERVER['PHP_AUTH_PW']; 9 echo "<HTML> 10 ?> 11 12 <HTML> 10 13 <head> 11 14 <title> 12 15 Upload Postage Stamp Request File 13 16 </title> 17 <script type='text/javascript'> 18 setTimeout('countdown()', 100); 19 function countdown() { 20 var s = document.getElementById('timer'); 21 s.innerHTML = s.innerHTML - 1; 22 if (s.innerHTML == 0) 23 // window.location = 'http://pstamp.ipp.ifa.hawaii.edu/upload.php'; 24 location.reload(); 25 else 26 setTimeout('countdown()', 1000*60); 27 } 28 </script> 29 </head> 14 30 <body> 15 "; 31 <H1 align=center> 32 Postage Stamp Request Upload Form 33 </h1> 16 34 35 <?php 36 37 welcomeHeader($auth_user, 0, 0); 38 // include "pstamp_links.php"; 39 echo "<br/><br/>"; 40 echo "The page will refresh in <span id='timer'>20</span> min<br><br>"; 17 41 // echo "Hello $user $passwd"; 18 42 … … 21 45 <label>Postage Stamp Request File: 22 46 <input type="file" name='filename' accept='image/x-fits' /></label> 47 Maximum Size 2 MB 23 48 <br /> 24 49 <br /> 25 <input type="submit" value=" Upload" />50 <input type="submit" value="Submit" /> 26 51 27 52 <input type="reset" name="cancel" value="Cancel"/> … … 31 56 _END; 32 57 58 $debug = 0; 59 33 60 $command = ""; 34 61 if ($_FILES) { 62 $error = $_FILES['filename']['error']; 35 63 $name = $_FILES['filename']['name']; 36 $tmp_name = $_FILES['filename']['tmp_name'];37 $type = $_FILES['filename']['type'];38 $size = $_FILES['filename']['size'];39 64 40 if ($name && ($size > 0)) { 41 // echo "Uploaded $size bytes for '$type' file '$name' as '$tmp_name'<br />"; 42 $command = "$SCRIPT pstamp_insert_request.pl --tmp_req_file $tmp_name --dbname $dbname --dbserver $dbserver --workdir $WORKDIR"; 65 if ($error == UPLOAD_ERR_OK) { 66 $tmp_name = $_FILES['filename']['tmp_name']; 67 $type = $_FILES['filename']['type']; 68 $size = $_FILES['filename']['size']; 69 70 71 if ($name) { 72 if ($size > 0) { 73 // echo "Uploaded $size bytes for '$type' file '$name' as '$tmp_name'<br />"; 74 $command = "$SCRIPT pstamp_insert_request.pl --tmp_req_file $tmp_name --dbname $dbname --dbserver $dbserver --workdir $WORKDIR"; 75 } else { 76 echo "Error: Received 0 bytes for file '$name' <br />\n"; 77 } 78 } else { 79 if ($debug) { 80 echo "Error: no name for file<br />\n"; 81 } 82 } 83 } else { 84 if ($error == UPLOAD_ERR_INI_SIZE) { 85 echo "File <b>$name</b> is too large.<br />\n"; 86 } else if ($error == UPLOAD_ERR_NO_FILE) { 87 if ($debug) { 88 echo "no file<br />\n"; 89 } 90 } else { 91 echo "File upload error $error<br />\n"; 92 } 93 } 94 } else { 95 if ($debug) { 96 echo "_FILES is null<br />\n"; 43 97 } 44 98 } 45 99 46 class Request 47 { 48 public $id; 49 public $name; 50 function __construct($p1, $p2) 51 { 52 $this->id = $p1; 53 $this->name = $p2; 54 } 55 } 56 57 if (!isset($_SESSION['requests'])) { 58 // echo "initializing requests\n"; 59 // echo "<br />"; 60 $_SESSION['requests'] = array(); 61 } 100 initializeRequests(); 62 101 63 102 // echo "<br />SCRIPT is <br />$SCRIPT"; … … 67 106 if ($command) { 68 107 $command = escapeshellcmd($command); 69 //echo "<br />command:<br />$command";108 // echo "<br />command:<br />$command"; 70 109 echo "<br />"; 71 110 exec($command, $output, $command_status); … … 75 114 // get rid of any whitespace in req_name 76 115 $req_name = trim($output[1]); 77 echo "Submitted Request ID: $req_id Request Name: $req_name<br \>"; 78 $new_request = new Request($req_id, $req_name); 79 $num = count($_SESSION['requests']); 80 // echo "request array length: $num<br />"; 81 $_SESSION['requests'][$num] = $new_request; 82 $num = count($_SESSION['requests']); 83 // echo "after request array length: $num<br />"; 116 echo "Submitted Request ID: $req_id Request Name: $req_name<br />"; 117 118 addRequest($req_id, $req_name); 84 119 } else if ($command_status == 5) { 85 120 // PS_EXIT_DATA_ERROR 86 echo "Error: ";121 echo "Error: 5 "; 87 122 for ($i=0; $i < count($output); $i++) { 88 123 echo $output[$i]; 124 } 125 if (count($output) == 0) { 126 echo "Insert command failed. Invalid request file?"; 89 127 } 90 128 echo "<br />\n"; 91 129 } else { 92 130 echo "Unexpected Error.<br /> insert command returned $command_status<br \>"; 131 echo "<br \OUTPUT: $output>"; 93 132 } 94 133 } 95 echo "<br /> ";134 echo "<br />\n"; 96 135 97 foreach ($_SESSION['requests'] as $req) { 98 echo "<br />"; 99 echo $req->id; 100 echo "  "; 101 $name = $req->name; 102 echo "  "; 103 // XXX: get this data store product location a configuation 104 echo "<a href=\"http://datastore.ipp.ifa.hawaii.edu/pstampresults/$name\" TARGET=\"upload_results_fileset\">$name</a>\n"; 105 } 106 echo "<br />"; 136 // listRequests("http://datastore.ipp.ifa.hawaii.edu", "pstamp_results_fileset"); 137 listRequests("http://datastore.ipp.ifa.hawaii.edu/ds", "pstamp_results_fileset"); 138 139 echo "<br />\n"; 107 140 108 141 // print lots of information … … 111 144 // phpinfo(32); 112 145 113 echo "</body> </html>";146 echo "</body>\n</html>"; 114 147 115 148 ?>
Note:
See TracChangeset
for help on using the changeset viewer.
