IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

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

update pstamp/web relative to installation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.