IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42994


Ignore:
Timestamp:
Apr 22, 2026, 12:04:59 PM (2 weeks ago)
Author:
eugene
Message:

update pstamp/web relative to installation

Location:
branches/eam_branches/ipp-pstamp-20260421/pstamp/web
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/authenticate.php

    r25322 r42994  
    33// function check_login()
    44
     5$lifetime=86400;
    56session_start();
     7setcookie(session_name(),session_id(),time()+$lifetime);
     8ini_set('session.gc_maxlifetime', 86400);
    69
    710// 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";
    1016
    1117$user   = $_SERVER['PHP_AUTH_USER'];
     
    1319$did_login = isset($_SESSION['did_login']);
    1420
    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;
    1723
    18     echo "Welcome:  " . $user;
    19     echo "&nbsp;&nbsp;&nbsp; <a href=\"./logout.php\">Logout</a>";
    20     echo "<br />";
    21     echo "<br />";
    22 } else {
     24$valid_pwd = 0;
     25if ($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
     30if (!$skip_login && !$valid_pwd) {
    2331    $_SESSION['did_login'] = true;
    2432    header('WWW-Authenticate: Basic realm="Restricted Section"');
     
    3139
    3240?>
     41<?php
     42function welcomeHeader($user, $link, $text)
     43{
     44    echo "Welcome:  " . $user;  //  . "<br /><br />";
     45    echo "&nbsp;&nbsp;&nbsp;";
     46    echo "<a href=\"./logout.php\">Logout</a>";
     47    echo "&nbsp;&nbsp;&nbsp;\n";
     48    if ($link) {
     49        echo "<a href=\"./$link\">$text</a>";
     50    }
     51    include "pstamp_links.php";
     52    echo "<br /><br />";
    3353
     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  
    77$_SESSION = array();
    88if (isset($_COOKIE[session_name()])) {
    9     setcookie(session_name(), '', time()-42000, '/');
     9    setcookie(session_name(), '', time()+3600, '/');
    1010}
    1111session_destroy();
    1212
    1313echo "You are now logged out<br /><br />";
    14 echo "<a href=\"./upload.php\">Upload</a>";
    1514
    16 // phpinfo(32);
    1715?>
     16<a href="./pshome.php">Postage Stamp Home</a>
     17<br />
     18<br />
     19<?php
    1820
     21include "pstamp_links.php";
     22
     23?>
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/request.php

    r29086 r42994  
    1414// The mode for the page is given by $request_id != 0
    1515
    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
    1718
    1819require "pstamp.php";
     
    2728// Initialize variables
    2829$output_array = array();
     30
     31// set to 1 to print command line and to change label to TEST
     32$TESTING = 0;
    2933
    3034$request_id = 0;
     
    3539$warp_selected = "";
    3640$stack_selected = "";
     41$stack_summary_selected = "";
    3742$diff_selected = "";
    3843
     
    5661
    5762$gpc1_selected="";
     63$gpc2_selected="";
    5864$mops_selected="";
    5965$simtest_selected="";
    6066
    61 $require_class_id = 0;
    62 
     67$require_component = 0;
     68
     69$rvar_email = "";
    6370$rvar_select_by = "";
    6471$rvar_img_type = "";
    6572$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 = "";
    6878
    6979$rvar_center_type = "";
     
    7989$rvar_H = "";
    8090
     91$rvar_make_jpeg = "";
     92$rvar_getall_roi = "";
     93
    8194$rvar_cmd_mode = "";
    8295$rvar_last_cmd_mode = "";
     
    90103if ($rvar_project == "gpc1") {
    91104    $gpc1_selected = "selected";
    92 //    $require_class_id = 1;
     105//    $require_component = 1;
     106} else if ($rvar_project == "gpc2") {
     107    $gpc2_selected = "selected";
    93108} else if ($rvar_project == "megacam-mops") {
    94109    $mops_selected = "selected";
    95     $require_class_id = 0;
     110    $require_component = 0;
    96111} else { //    if ($rvar_project == "simtest") {
    97112    $simtest_selected = "selected";
    98     $require_class_id = 0;
     113    $require_component = 0;
    99114}
    100115
     
    123138} else if ($rvar_img_type == "stack") {
    124139    $stack_selected = "selected";
     140} else if ($rvar_img_type == "stack_summary") {
     141    $stack_summary_selected = "selected";
    125142} else if ($rvar_img_type == "diff") {
    126143    $diff_selected = "selected";
     
    145162}
    146163
     164if ($rvar_make_jpeg) {
     165    $make_jpeg_checked = "checked";
     166} else {
     167    $make_jpeg_checked = "";
     168}
     169
     170if ($rvar_getall_roi) {
     171    $getall_roi_checked = "checked";
     172} else {
     173    $getall_roi_checked = "";
     174}
     175
    147176// When request_id is non-zero we respond to posts by check the status of that request
    148177// request_id gets set to zero when the status of all jobs for the request is 'stop'
     
    162191if ($rvar_cmd_mode == "Make Stamps") {
    163192    $pstamp_checked = "checked";
    164 } else if ($rvar_cmd_mode == "Get Images") {
     193} else if ($rvar_cmd_mode == "Get Bundles") {
    165194    $get_checked = "checked";
    166195} else if ($rvar_cmd_mode == "Get Status") {
     
    185214        try {
    186215            $command_line = build_request_cmd();
     216            if ($TESTING) {
     217                echo "$command_line\n";
     218            }
    187219            $error_line = "";
    188             run_command($command_line);
     220            $command_status = run_command($command_line);
     221            // run_command($command_line);
    189222            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;
    195238                    addRequest($request_id, $request_name);
    196239                    // setcookie("our_request_id", $request_id);
    197240                    // echo "The request id is $request_id\n";
     241                    // switch page Mode to Get Status
    198242                    $getstatus_checked = "checked";
    199243                    $pstamp_checked = "";
     244                    $get_checked = "";
    200245                } else {
     246                    echo "got an error\n";
    201247                    // XXX: TODO print out the error
     248                    // This doesn't work
     249                    // echo "$error_line\n";
    202250                    if (count($output_array) != 0) {
    203251                        throw new Exception("unexpected output returned by pstampwebrequest.");
     
    211259        }
    212260    }
     261} else {
     262    // default to stack
     263    $rvar_img_type = "stack";
     264    $stack_selected = "selected";
    213265}
    214266
     
    218270{
    219271    global $rvar_project;
     272    global $rvar_email;
    220273    global $sky_checked, $rsky_checked;
    221274    global $list_checked;
     
    227280    global $exp_checked, $file_checked, $coord_checked, $diff_checked;
    228281    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;
    230285    global $command_line;
    231286    global $dbname;
    232287    global $dbserver;
    233     global $require_class_id;
     288    global $require_component;
    234289    global $PSCONFDIR, $PSCONFIG, $WORKDIR;
    235290    global $SCRIPT;
     291    global $TESTING;
     292    global $rvar_make_jpeg;
     293    global $rvar_getall_roi;
    236294
    237295    $making_stamps = 1;
    238296    $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    }
    239304
    240305    if ($list_checked) {
     
    245310        $cmd .= " --job_type get_image";
    246311    }
     312//    echo "making_stamps: $making_stamps<br>\n";
     313//    echo "$cmd<br>\n";
    247314
    248315    if ($dbname) {
    249316        $cmd .= " --dbname $dbname --dbserver $dbserver";
    250317    }
     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
    251325
    252326    if (! $rvar_project ) {
     
    258332        // TODO: put options on the GUI for these
    259333//        $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) {
    263340        // Set up the ROI parameters
     341        $wholefile = 0;
    264342        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)");
    267345            }
    268346            $cmd .= " --ra $rvar_RA --dec $rvar_DEC";
    269347        } 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";
    274355        }
    275356
    276357        if ($rsky_checked) {
    277358            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.');
    279360            }
    280361            $cmd .= " --arcseconds --width $rvar_dRA --height $rvar_dDEC";
    281362        } else {
    282363            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.');
    284371            }
    285372            $cmd .= " --width $rvar_W --height $rvar_H";
     
    298385        }
    299386        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.');
    301388        }
    302389        $cmd .= " --req_type byexp --stage $rvar_img_type --id $rvar_id";
    303390    } else if ($file_checked) {
    304391        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.");
    306398        }
    307399        $cmd .= " --req_type byid --stage $rvar_img_type --id $rvar_id";
     
    317409    }
    318410
    319 // XXX: don't need to require class_id anymore
     411// XXX: don't need to require component anymore
    320412//    if (($rvar_img_type == "raw") || ($rvar_img_type == "chip")) {
    321 //        if (!$sky_checked && ($require_class_id && ! $rvar_class_id )) {
     413//        if (!$sky_checked && ($require_component && ! $rvar_component )) {
    322414//            throw new Exception("must specify Class ID with Image Type $rvar_img_type.");
    323415//        }
    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";
    327420        }
    328421//    }
     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    }
    329447
    330448    return escapeshellcmd($cmd);
     
    337455    global $command_status;
    338456
    339     //    echo "running $command_line\n";
     457    // echo "<br>running $command_line\n<br>";
    340458
    341459    exec ("$command_line", $output_array, $command_status);
     
    349467            echo "Output: $size lines\n";
    350468            for ($i = 0; $i < $size; $i++) {
    351                 echo "$output_array[$i]\n";
     469                echo "<br>$i: $output_array[$i]\n";
    352470            }
    353471        }
     
    359477        }
    360478    }
    361 
     479    return $command_status;
    362480}
    363481
     
    386504                $dirName  = "$dsroot/$product/$req_name";
    387505                // 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
    389509                $fullpath = "$dirName/$fileName";
    390510// echo "<pre>fullpath: $fullpath filesetURL: $filesetURL\n</pre>";
     
    422542<head>
    423543  <title>
    424     Postage Stamp Request Form (prototype)
     544    Prototype Postage Stamp Request Form : test
    425545  </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>
    426559</head>
    427560<body>
    428561
    429562<H1 align=center>
    430 Postage Stamp Request Form
     563Prototype Postage Stamp Request Form : test
    431564</h1>
    432565
    433566<?php
    434     welcomeHeader($auth_user, "pstamp_links.php", "Postage Stamp Home");
     567    welcomeHeader($auth_user, 0, 0);
     568    echo "<br>\n";
    435569?>
    436570
    437571<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
     577interface 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
    438588<!-- Whole page is a single column table -->
    439 
    440 
    441589<table width=90% align=center>
    442590
     
    447595
    448596<table width=100% align=center>
     597
     598<tr>
     599<td>
     600</td>
     601<td align = left>
     602<b>Email Address:</b>&nbsp;&nbsp;
     603<input type="text" name="email" size=60 value= "<?php echo $rvar_email; ?>" >&nbsp; REQUIRED
     604</td>
     605<td>
     606</td>
     607</tr>
    449608
    450609<!-- first row of image selector is "Project" pulldown menu "Select Image By" radio boxes -->
     
    455614        <td><select name="project">
    456615           <option <?php echo $gpc1_selected;?> >gpc1
     616           <option <?php echo $gpc2_selected;?> >gpc2
    457617<!--
    458618           <option <?php echo $mops_selected;?> >megacam-mops
     
    490650            <option <?php echo $warp_selected ;?> >warp
    491651            <option <?php echo $stack_selected;?> >stack   
     652            <option <?php echo $stack_summary_selected;?> >stack_summary   
    492653            <option <?php echo $diff_selected;?>  >diff
    493654            <option <?php echo $raw_selected;?>   >raw
     
    499660<td>
    500661&nbsp;<b>ID/Name:</b>&nbsp; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    501 <input type="text" name="id" value= <?php echo $rvar_id; ?> >
     662<input type="text" name="id" size=14 value= <?php echo $rvar_id; ?> >
    502663&nbsp;&nbsp;&nbsp;&nbsp;
    503 <b>
    504 <?php if (0 && $rvar_project == "gpc1") {
    505         echo "Chip ID:";
    506       } else {
    507         echo "Component:";
    508       }
    509 ?>
    510 </b>
    511 &nbsp;<input type="text" name="class_id" size=10 value="<?php echo $rvar_class_id;?>" >
    512 
     664<b>Component:</b> &nbsp; <input type="text" name="component" size=14 value="<?php echo $rvar_component;?>" >
    513665&nbsp;&nbsp;&nbsp;&nbsp;
    514 <!-- add text input field for Cell ID, not used yet -->
    515 
    516 <!--
    517 <b>Cell ID:</b>&nbsp;<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&nbsp;&nbsp;&nbsp;&nbsp;
     669<b>Release:<input type="text" name="release" size=6 value="<?php echo $rvar_release;?>" >
     670&nbsp;&nbsp;&nbsp;&nbsp;
     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
    520674
    521675</td>
     
    612766        </td>
    613767    </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>
    614781    </table>
    615782    </td>
     
    628795    <input type=radio name="cmd_mode" value="Get Status"<?php echo $getstatus_checked; ?> >Get Status
    629796    <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 Bundles
     797    <input type=radio name="cmd_mode" value="Get Bundles" <?php echo $get_checked; ?> >Get Bundles
    631798<!--
    632799    <input type=radio name="cmd_mode" value="List Images" <?php echo $list_checked; ?> >List Images
     
    683850<caption height=10 valign=center><b>Request Results</b></caption>
    684851
    685 <?php
    686 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() below
    689 
    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 them
    695             // later we might add links to cause a stamp to be made from a selected file
    696             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 urls
    703             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 ?>
    712852</table>
    713853</td>
     
    737877
    738878<?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");
    740882?>
    741883
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/upload.php

    r25322 r42994  
    22
    33// get the locatl configuration variables
    4 include "pstamp.php";
     4require "pstamp.php";
     5require "submitted.php";
    56
    67
    78$user = $_SERVER['PHP_AUTH_USER'];
    89$passwd = $_SERVER['PHP_AUTH_PW'];
    9 echo "<HTML>
     10?>
     11
     12<HTML>
    1013<head>
    1114    <title>
    1215        Upload Postage Stamp Request File
    1316    </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>
    1430<body>
    15 ";
     31<H1 align=center>
     32Postage Stamp Request Upload Form
     33</h1>
    1634
     35<?php
     36
     37welcomeHeader($auth_user, 0, 0);
     38// include "pstamp_links.php";
     39echo "<br/><br/>";
     40echo "The page will refresh in <span id='timer'>20</span> min<br><br>";
    1741// echo "Hello $user $passwd";
    1842
     
    2145        <label>Postage Stamp Request File:
    2246        <input type="file" name='filename' accept='image/x-fits' /></label>
     47        Maximum Size 2 MB
    2348    <br />
    2449    <br />
    25     <input type="submit" value="Upload" />
     50    <input type="submit" value="Submit" />
    2651    &nbsp; &nbsp; &nbsp;
    2752    <input type="reset" name="cancel" value="Cancel"/>
     
    3156_END;
    3257
     58$debug = 0;
     59
    3360$command = "";
    3461if ($_FILES) {
     62    $error = $_FILES['filename']['error'];
    3563    $name = $_FILES['filename']['name'];
    36     $tmp_name = $_FILES['filename']['tmp_name'];
    37     $type = $_FILES['filename']['type'];
    38     $size = $_FILES['filename']['size'];
    3964
    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";
    4397    }
    4498}
    4599
    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 }
     100initializeRequests();
    62101
    63102// echo "<br />SCRIPT is <br />$SCRIPT";
     
    67106if ($command) {
    68107    $command = escapeshellcmd($command);
    69    // echo "<br />command:<br />$command";
     108//    echo "<br />command:<br />$command";
    70109    echo "<br />";
    71110    exec($command, $output, $command_status);
     
    75114        // get rid of any whitespace in req_name
    76115        $req_name = trim($output[1]);
    77         echo "Submitted Request ID:&nbsp; $req_id Request Name: &nbsp; $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:&nbsp; $req_id Request Name: &nbsp; $req_name<br />";
     117
     118        addRequest($req_id, $req_name);
    84119    } else if ($command_status == 5) {
    85120        // PS_EXIT_DATA_ERROR
    86         echo "Error:&nbsp;&nbsp;&nbsp;";
     121        echo "Error: 5 &nbsp;&nbsp;&nbsp;";
    87122        for ($i=0; $i < count($output); $i++) {
    88123            echo $output[$i];
     124        }
     125        if (count($output) == 0) {
     126            echo "Insert command failed. Invalid request file?";
    89127        }
    90128        echo "<br />\n";
    91129    } else {
    92130        echo "Unexpected Error.<br /> insert command returned $command_status<br \>";
     131        echo "<br \OUTPUT: $output>";
    93132    }
    94133}
    95 echo "<br />";
     134echo "<br />\n";
    96135
    97 foreach ($_SESSION['requests'] as $req) {
    98     echo "<br />";
    99     echo $req->id;
    100     echo "&nbsp;&nbsp";
    101     $name = $req->name;
    102     echo "&nbsp;&nbsp";
    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");
     137listRequests("http://datastore.ipp.ifa.hawaii.edu/ds", "pstamp_results_fileset");
     138
     139echo "<br />\n";
    107140
    108141// print lots of information
     
    111144// phpinfo(32);
    112145
    113 echo "</body></html>";
     146echo "</body>\n</html>";
    114147
    115148?>
Note: See TracChangeset for help on using the changeset viewer.