Changeset 42994
- Timestamp:
- Apr 22, 2026, 12:04:59 PM (2 weeks ago)
- Location:
- branches/eam_branches/ipp-pstamp-20260421/pstamp/web
- Files:
-
- 2 added
- 4 edited
-
authenticate.php (modified) (3 diffs)
-
dsroot.php (added)
-
logout.php (modified) (1 diff)
-
request.php (modified) (30 diffs)
-
submitted.php (added)
-
upload.php (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
branches/eam_branches/ipp-pstamp-20260421/pstamp/web/authenticate.php
r25322 r42994 3 3 // function check_login() 4 4 5 $lifetime=86400; 5 6 session_start(); 7 setcookie(session_name(),session_id(),time()+$lifetime); 8 ini_set('session.gc_maxlifetime', 86400); 6 9 7 10 // XXX TODO use mysql 8 $auth_user="setme"; 9 $auth_passwd="setmetoo"; 11 $auth_user="SET_ME"; 12 $auth_passwd="SET_ME"; 13 14 $alt_user="SET_ME"; 15 $alt_passwd="SET_ME"; 10 16 11 17 $user = $_SERVER['PHP_AUTH_USER']; … … 13 19 $did_login = isset($_SESSION['did_login']); 14 20 15 if ($did_login && isset($user) && isset($passwd) && 16 ($auth_user == $user) && ($auth_passwd == $passwd)) { 21 # uncomment this to skipp authentication 22 $skip_login = 0; 17 23 18 echo "Welcome: " . $user; 19 echo " <a href=\"./logout.php\">Logout</a>"; 20 echo "<br />"; 21 echo "<br />"; 22 } else { 24 $valid_pwd = 0; 25 if ($did_login && isset($user) && isset($passwd)) { 26 $valid_pwd = $valid_pwd || (($auth_user == $user) && ($auth_passwd == $passwd)); 27 $valid_pwd = $valid_pwd || (($alt_user == $user) && ($alt_passwd == $passwd)); 28 } 29 30 if (!$skip_login && !$valid_pwd) { 23 31 $_SESSION['did_login'] = true; 24 32 header('WWW-Authenticate: Basic realm="Restricted Section"'); … … 31 39 32 40 ?> 41 <?php 42 function welcomeHeader($user, $link, $text) 43 { 44 echo "Welcome: " . $user; // . "<br /><br />"; 45 echo " "; 46 echo "<a href=\"./logout.php\">Logout</a>"; 47 echo " \n"; 48 if ($link) { 49 echo "<a href=\"./$link\">$text</a>"; 50 } 51 include "pstamp_links.php"; 52 echo "<br /><br />"; 33 53 54 // Top of the page is the contents of the "message of the day file" 55 // This can be empty but must exist or the user sees an error. 56 $motd_filename = "pstamp_motd.html"; 57 $file = fopen($motd_filename, "r"); 58 if ($file) { 59 fpassthru($file); 60 } 61 62 // echo "<br />"; 63 // echo "<br />"; 64 } 65 ?> -
branches/eam_branches/ipp-pstamp-20260421/pstamp/web/logout.php
r25322 r42994 7 7 $_SESSION = array(); 8 8 if (isset($_COOKIE[session_name()])) { 9 setcookie(session_name(), '', time() -42000, '/');9 setcookie(session_name(), '', time()+3600, '/'); 10 10 } 11 11 session_destroy(); 12 12 13 13 echo "You are now logged out<br /><br />"; 14 echo "<a href=\"./upload.php\">Upload</a>";15 14 16 // phpinfo(32);17 15 ?> 16 <a href="./pshome.php">Postage Stamp Home</a> 17 <br /> 18 <br /> 19 <?php 18 20 21 include "pstamp_links.php"; 22 23 ?> -
branches/eam_branches/ipp-pstamp-20260421/pstamp/web/request.php
r29086 r42994 14 14 // The mode for the page is given by $request_id != 0 15 15 16 // XXX This is just a prototype for testing purposes. 16 // XXX This was intended to just be a prototype for testing purposes but people have 17 // become dependent on it so it lives on 17 18 18 19 require "pstamp.php"; … … 27 28 // Initialize variables 28 29 $output_array = array(); 30 31 // set to 1 to print command line and to change label to TEST 32 $TESTING = 0; 29 33 30 34 $request_id = 0; … … 35 39 $warp_selected = ""; 36 40 $stack_selected = ""; 41 $stack_summary_selected = ""; 37 42 $diff_selected = ""; 38 43 … … 56 61 57 62 $gpc1_selected=""; 63 $gpc2_selected=""; 58 64 $mops_selected=""; 59 65 $simtest_selected=""; 60 66 61 $require_class_id = 0; 62 67 $require_component = 0; 68 69 $rvar_email = ""; 63 70 $rvar_select_by = ""; 64 71 $rvar_img_type = ""; 65 72 $rvar_id = ""; 66 $rvar_class_id = ""; 67 $rvar_cell_id = ""; 73 $rvar_component = ""; 74 $rvar_survey = "bypass"; 75 $rvar_release = ""; 76 $rvar_data_group = ""; 77 $rvar_filter = ""; 68 78 69 79 $rvar_center_type = ""; … … 79 89 $rvar_H = ""; 80 90 91 $rvar_make_jpeg = ""; 92 $rvar_getall_roi = ""; 93 81 94 $rvar_cmd_mode = ""; 82 95 $rvar_last_cmd_mode = ""; … … 90 103 if ($rvar_project == "gpc1") { 91 104 $gpc1_selected = "selected"; 92 // $require_class_id = 1; 105 // $require_component = 1; 106 } else if ($rvar_project == "gpc2") { 107 $gpc2_selected = "selected"; 93 108 } else if ($rvar_project == "megacam-mops") { 94 109 $mops_selected = "selected"; 95 $require_c lass_id= 0;110 $require_component = 0; 96 111 } else { // if ($rvar_project == "simtest") { 97 112 $simtest_selected = "selected"; 98 $require_c lass_id= 0;113 $require_component = 0; 99 114 } 100 115 … … 123 138 } else if ($rvar_img_type == "stack") { 124 139 $stack_selected = "selected"; 140 } else if ($rvar_img_type == "stack_summary") { 141 $stack_summary_selected = "selected"; 125 142 } else if ($rvar_img_type == "diff") { 126 143 $diff_selected = "selected"; … … 145 162 } 146 163 164 if ($rvar_make_jpeg) { 165 $make_jpeg_checked = "checked"; 166 } else { 167 $make_jpeg_checked = ""; 168 } 169 170 if ($rvar_getall_roi) { 171 $getall_roi_checked = "checked"; 172 } else { 173 $getall_roi_checked = ""; 174 } 175 147 176 // When request_id is non-zero we respond to posts by check the status of that request 148 177 // request_id gets set to zero when the status of all jobs for the request is 'stop' … … 162 191 if ($rvar_cmd_mode == "Make Stamps") { 163 192 $pstamp_checked = "checked"; 164 } else if ($rvar_cmd_mode == "Get Images") {193 } else if ($rvar_cmd_mode == "Get Bundles") { 165 194 $get_checked = "checked"; 166 195 } else if ($rvar_cmd_mode == "Get Status") { … … 185 214 try { 186 215 $command_line = build_request_cmd(); 216 if ($TESTING) { 217 echo "$command_line\n"; 218 } 187 219 $error_line = ""; 188 run_command($command_line); 220 $command_status = run_command($command_line); 221 // run_command($command_line); 189 222 if (! $list_checked) { 190 // The only output from a successful run is the request_id 191 $request_name = trim(Array_pop($output_array)); 192 $request_id = Array_pop($output_array); 193 $last_request_id = $request_id; 194 if ($request_id && $request_name) { 223 // The only output from a successful run is the request_id and the request name 224 $words = array(); 225 $words = explode(" ", trim(Array_pop($output_array))); 226 $request_id = $words[0]; 227 $request_name = $words[1]; 228 229 // echo "<br>Submission Results: Request_name: $request_name Request_id $request_id status: $command_status\n<br>"; 230 $whatthaheck = $request_id && $request_name; 231 // $whatthaheck = !$command_status; 232 // echo "<br>Boolean: $whatthaheck\n<br>"; 233 234 // XXX: for some reason this does not evaluate to true 235 // if (!$command_status && $request_id && $request_name) { 236 if (!$command_status) { 237 $last_request_id = $request_id; 195 238 addRequest($request_id, $request_name); 196 239 // setcookie("our_request_id", $request_id); 197 240 // echo "The request id is $request_id\n"; 241 // switch page Mode to Get Status 198 242 $getstatus_checked = "checked"; 199 243 $pstamp_checked = ""; 244 $get_checked = ""; 200 245 } else { 246 echo "got an error\n"; 201 247 // XXX: TODO print out the error 248 // This doesn't work 249 // echo "$error_line\n"; 202 250 if (count($output_array) != 0) { 203 251 throw new Exception("unexpected output returned by pstampwebrequest."); … … 211 259 } 212 260 } 261 } else { 262 // default to stack 263 $rvar_img_type = "stack"; 264 $stack_selected = "selected"; 213 265 } 214 266 … … 218 270 { 219 271 global $rvar_project; 272 global $rvar_email; 220 273 global $sky_checked, $rsky_checked; 221 274 global $list_checked; … … 227 280 global $exp_checked, $file_checked, $coord_checked, $diff_checked; 228 281 global $rvar_img_type; 229 global $rvar_id, $rvar_class_id; 282 global $rvar_id, $rvar_component; 283 global $rvar_data_group, $rvar_filter; 284 global $rvar_survey, $rvar_release; 230 285 global $command_line; 231 286 global $dbname; 232 287 global $dbserver; 233 global $require_c lass_id;288 global $require_component; 234 289 global $PSCONFDIR, $PSCONFIG, $WORKDIR; 235 290 global $SCRIPT; 291 global $TESTING; 292 global $rvar_make_jpeg; 293 global $rvar_getall_roi; 236 294 237 295 $making_stamps = 1; 238 296 $cmd = "$SCRIPT pstamp_webrequest.pl"; 297 298 // echo "list_checked: $list_checked\n"; 299 // echo "get_checked: $get_checked\n<br>"; 300 301 if ($TESTING) { 302 $cmd .= " --label TEST"; 303 } 239 304 240 305 if ($list_checked) { … … 245 310 $cmd .= " --job_type get_image"; 246 311 } 312 // echo "making_stamps: $making_stamps<br>\n"; 313 // echo "$cmd<br>\n"; 247 314 248 315 if ($dbname) { 249 316 $cmd .= " --dbname $dbname --dbserver $dbserver"; 250 317 } 318 319 if (! $rvar_email ) { 320 throw new Exception('Email address must be specified.'); 321 } 322 // TODO: check for "valid" email address 323 $cmd .= " --username $rvar_email"; // This arg is used by pstamptool -addreq 324 $cmd .= " --email $rvar_email"; // This is used by psmkreq 251 325 252 326 if (! $rvar_project ) { … … 258 332 // TODO: put options on the GUI for these 259 333 // $cmd .= " -mask -weight"; 260 } 261 262 if ($making_stamps || $coord_checked) { 334 if ($rvar_img_type == "stack_summary") { 335 $cmd .= " --option_mask 196673"; 336 } 337 } 338 339 if ($making_stamps) { // || $coord_checked) { 263 340 // Set up the ROI parameters 341 $wholefile = 0; 264 342 if ($sky_checked) { 265 if ( ! $rvar_RA || ! $rvar_DEC) {266 throw new Exception( 'RA and DEC must be specified.');343 if ($rvar_RA == NULL || $rvar_DEC == NULL) { 344 throw new Exception("RA and DEC must be specified. Got: ($rvar_RA, $rvar_DEC)"); 267 345 } 268 346 $cmd .= " --ra $rvar_RA --dec $rvar_DEC"; 269 347 } else { 270 if (! $rvar_X || ! $rvar_Y) { 271 throw new Exception('X and Y must be specified.'); 272 } 273 $cmd .= " -pixcenter --x $rvar_X --y $rvar_Y"; 348 if ($rvar_X == NULL || $rvar_Y == NULL) { 349 } 350 if ($rvar_X == 0 && $rvar_Y == 0) { 351 // Pixel center with both coordinates == 0 is code for return the whole file 352 $wholefile = 1; 353 } 354 $cmd .= " --pixcenter --x $rvar_X --y $rvar_Y"; 274 355 } 275 356 276 357 if ($rsky_checked) { 277 358 if (! $rvar_dRA || ! $rvar_dDEC) { 278 throw new Exception('dRA and dDEC must be specified.');359 throw new Exception('dRA and dDEC must be non zero.'); 279 360 } 280 361 $cmd .= " --arcseconds --width $rvar_dRA --height $rvar_dDEC"; 281 362 } else { 282 363 if (! $rvar_W || ! $rvar_H) { 283 throw new Exception('width and height must be specified.'); 364 $wholefile = 1; 365 } 366 if ($wholefile) { 367 $rvar_W = 0; 368 $rvar_H = 0; 369 // } else if (! $rvar_W || ! $rvar_H) { 370 // throw new Exception('width and height must be specified and non zero.'); 284 371 } 285 372 $cmd .= " --width $rvar_W --height $rvar_H"; … … 298 385 } 299 386 if (! $rvar_id ) { 300 throw new Exception('Must set ID to the Exposure ID.');387 throw new Exception('Must set ID to the Exposure name.'); 301 388 } 302 389 $cmd .= " --req_type byexp --stage $rvar_img_type --id $rvar_id"; 303 390 } else if ($file_checked) { 304 391 if (! $rvar_id ) { 305 throw new Exception('Must set ID to the exposure name.'); 392 throw new Exception("Must set ID to the ${rvar_img_type}_id."); 393 } 394 $id = $rvar_id + 0; 395 // echo "id is $id rvar_id is $rvar_id\n"; 396 if (!$id) { 397 throw new Exception("$rvar_id is not a valid ${rvar_img_type}_id."); 306 398 } 307 399 $cmd .= " --req_type byid --stage $rvar_img_type --id $rvar_id"; … … 317 409 } 318 410 319 // XXX: don't need to require c lass_idanymore411 // XXX: don't need to require component anymore 320 412 // if (($rvar_img_type == "raw") || ($rvar_img_type == "chip")) { 321 // if (!$sky_checked && ($require_c lass_id && ! $rvar_class_id)) {413 // if (!$sky_checked && ($require_component && ! $rvar_component )) { 322 414 // throw new Exception("must specify Class ID with Image Type $rvar_img_type."); 323 415 // } 324 // leave off compoennt if we're looking up by coordinates. It breaks it 325 if (!$coord_checked && (($rvar_class_id) && ($rvar_class_id != "all"))) { 326 $cmd .= " --component $rvar_class_id"; 416 // leave off component if we're looking up by coordinates. The parser will figure it out 417 // IS THIS a good idea? What if somebody only wants images from a particular skycell? 418 if (!$coord_checked && (($rvar_component) && ($rvar_component != "all"))) { 419 $cmd .= " --component $rvar_component"; 327 420 } 328 421 // } 422 423 if ($rvar_survey) { 424 $cmd .= " --survey $rvar_survey"; 425 } 426 if ($rvar_release) { 427 $cmd .= " --release $rvar_release"; 428 } 429 if ($rvar_data_group) { 430 $cmd .= " --data_group $rvar_data_group"; 431 } 432 if ($rvar_filter) { 433 $cmd .= " --filter $rvar_filter"; 434 } 435 436 if ($rvar_img_type == 'stack') { 437 $cmd .= " --unconvolved"; 438 } 439 440 if ($rvar_make_jpeg) { 441 $cmd .= " --jpeg"; 442 } 443 444 if ($rvar_getall_roi) { 445 $cmd .= " --allroi"; 446 } 329 447 330 448 return escapeshellcmd($cmd); … … 337 455 global $command_status; 338 456 339 // echo "running $command_line\n";457 // echo "<br>running $command_line\n<br>"; 340 458 341 459 exec ("$command_line", $output_array, $command_status); … … 349 467 echo "Output: $size lines\n"; 350 468 for ($i = 0; $i < $size; $i++) { 351 echo " $output_array[$i]\n";469 echo "<br>$i: $output_array[$i]\n"; 352 470 } 353 471 } … … 359 477 } 360 478 } 361 479 return $command_status; 362 480 } 363 481 … … 386 504 $dirName = "$dsroot/$product/$req_name"; 387 505 // XXX: TODO: make this a configuration parameter 388 $filesetURL = "http://datastore.ipp.ifa.hawaii.edu/$product/$req_name"; 506 //$filesetURL = "http://datastore.ipp.ifa.hawaii.edu/$product/$req_name"; 507 $filesetURL = "http://datastore.ipp.ifa.hawaii.edu/ds/$product/$req_name"; 508 389 509 $fullpath = "$dirName/$fileName"; 390 510 // echo "<pre>fullpath: $fullpath filesetURL: $filesetURL\n</pre>"; … … 422 542 <head> 423 543 <title> 424 P ostage Stamp Request Form (prototype)544 Prototype Postage Stamp Request Form : test 425 545 </title> 546 <script type='text/javascript'> 547 setTimeout('countdown()', 100); 548 549 function countdown() { 550 var s = document.getElementById('timer'); 551 s.innerHTML = s.innerHTML - 1; 552 if (s.innerHTML == 0) 553 // window.location = 'http://pstamp.ipp.ifa.hawaii.edu/request.php'; 554 location.reload(); 555 else 556 setTimeout('countdown()', 1000*60); 557 } 558 </script> 426 559 </head> 427 560 <body> 428 561 429 562 <H1 align=center> 430 P ostage Stamp Request Form563 Prototype Postage Stamp Request Form : test 431 564 </h1> 432 565 433 566 <?php 434 welcomeHeader($auth_user, "pstamp_links.php", "Postage Stamp Home"); 567 welcomeHeader($auth_user, 0, 0); 568 echo "<br>\n"; 435 569 ?> 436 570 437 571 <form method="post"> 572 573 <b>Notice: This request submission form is an obsolete prototype -- MODIFIED 20180501 </b> 574 575 <br><br><b>Some time soon this form will no longer be available. 576 <br> <br>Please migrate our requests to new more fully featured postage stamp 577 interface located at </b> 578 <a href=http://psps.ifa.hawaii.edu/PSI/postage_stamp.php>PSI Postage Stamp Request Form</a>. 579 <br> 580 <b>Or upload your own request tables using the upload link.</b> 581 <br><br> 582 <b>This page will refresh in <span id='timer'>20</span> mins</b> 583 <! -- Add link to STSCI page as well --> 584 <br><br><br> 585 586 587 438 588 <!-- Whole page is a single column table --> 439 440 441 589 <table width=90% align=center> 442 590 … … 447 595 448 596 <table width=100% align=center> 597 598 <tr> 599 <td> 600 </td> 601 <td align = left> 602 <b>Email Address:</b> 603 <input type="text" name="email" size=60 value= "<?php echo $rvar_email; ?>" > REQUIRED 604 </td> 605 <td> 606 </td> 607 </tr> 449 608 450 609 <!-- first row of image selector is "Project" pulldown menu "Select Image By" radio boxes --> … … 455 614 <td><select name="project"> 456 615 <option <?php echo $gpc1_selected;?> >gpc1 616 <option <?php echo $gpc2_selected;?> >gpc2 457 617 <!-- 458 618 <option <?php echo $mops_selected;?> >megacam-mops … … 490 650 <option <?php echo $warp_selected ;?> >warp 491 651 <option <?php echo $stack_selected;?> >stack 652 <option <?php echo $stack_summary_selected;?> >stack_summary 492 653 <option <?php echo $diff_selected;?> >diff 493 654 <option <?php echo $raw_selected;?> >raw … … 499 660 <td> 500 661 <b>ID/Name:</b> 501 <input type="text" name="id" value= <?php echo $rvar_id; ?> >662 <input type="text" name="id" size=14 value= <?php echo $rvar_id; ?> > 502 663 503 <b> 504 <?php if (0 && $rvar_project == "gpc1") { 505 echo "Chip ID:"; 506 } else { 507 echo "Component:"; 508 } 509 ?> 510 </b> 511 <input type="text" name="class_id" size=10 value="<?php echo $rvar_class_id;?>" > 512 664 <b>Component:</b> <input type="text" name="component" size=14 value="<?php echo $rvar_component;?>" > 513 665 514 <!-- add text input field for Cell ID, not used yet --> 515 516 <!-- 517 <b>Cell ID:</b> <input type="text" name="cell_id" size=10 value="<?php echo $rvar_cell_id;?>" > 518 519 --> 666 667 <b>Survey:<input type="text" name="survey" size=6 value="<?php echo $rvar_survey;?>" > 668 669 <b>Release:<input type="text" name="release" size=6 value="<?php echo $rvar_release;?>" > 670 671 <b>Data Group:<input type="text" name="data_group" size=14 value="<?php echo $rvar_data_group;?>" > 672 <b>Filter:<input type="text" name="filter" size=3 value="<?php echo $rvar_filter;?>" > 673 520 674 521 675 </td> … … 612 766 </td> 613 767 </tr> 768 <!-- a blank row for space--> 769 <tr height=20><td></td> 770 </tr> 771 <tr> 772 <td> 773 <input type=checkbox name ="make_jpeg" value="value" checked="<?php echo $make_jpeg_checked; ?>" >Produce a JPEG 774 <td> 775 </tr> 776 <tr> 777 <td> 778 <input type=checkbox name ="getall_roi" value="value" checked="<?php echo $getall_roi_checked; ?>" >Include all images in ROI (MOPS) 779 <td> 780 </tr> 614 781 </table> 615 782 </td> … … 628 795 <input type=radio name="cmd_mode" value="Get Status"<?php echo $getstatus_checked; ?> >Get Status 629 796 <input type=radio name="cmd_mode" value="Make Stamps"<?php echo $pstamp_checked; ?> >Make Stamps 630 <input type=radio name="cmd_mode" value="Get Images" <?php echo $get_checked; ?> >Get Bundles797 <input type=radio name="cmd_mode" value="Get Bundles" <?php echo $get_checked; ?> >Get Bundles 631 798 <!-- 632 799 <input type=radio name="cmd_mode" value="List Images" <?php echo $list_checked; ?> >List Images … … 683 850 <caption height=10 valign=center><b>Request Results</b></caption> 684 851 685 <?php686 if (0) {687 // This is the old way of listing the status of the current request.688 // now we save the submitted requests in the session see listRequests() below689 690 $size = sizeof($output_array);691 // echo "<pre>size of output array is $size\n</pre>";692 if ($command_status == 0) {693 if ($list_checked) {694 // in list mode the output is a list of image files, just list them695 // later we might add links to cause a stamp to be made from a selected file696 for ($i = 0; $i < $size; $i++) {697 // $uri = array_shift($output_array);698 $uri = $output_array[$i];699 echo "<tr><td>$uri</td></tr>";700 }701 } else {702 // output the list of urls703 for ($i = 0; $i < $size; $i++) {704 // $uri = array_shift($output_array);705 $uri = $output_array[$i];706 printURL($uri);707 }708 }709 }710 } // end if if(0)711 ?>712 852 </table> 713 853 </td> … … 737 877 738 878 <?php 739 listRequests("http://datastore.ipp.ifa.hawaii.edu/pstampresults", "pstamp_results_fileset"); 879 // echo "calling listRequests\n"; 880 //listRequests("http://datastore.ipp.ifa.hawaii.edu", "pstamp_results_fileset"); 881 listRequests("http://datastore.ipp.ifa.hawaii.edu/ds", "pstamp_results_fileset"); 740 882 ?> 741 883 -
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.
