IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42996


Ignore:
Timestamp:
Apr 22, 2026, 5:16:15 PM (2 weeks ago)
Author:
eugene
Message:

fixing for modern PHP

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

Legend:

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

    r42994 r42996  
    99
    1010// XXX TODO use mysql
    11 $auth_user="SET_ME";
    12 $auth_passwd="SET_ME";
     11$auth_user="ps1sc";
     12$auth_passwd="skysurveys";
    1313
    1414$alt_user="SET_ME";
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/dsroot.php

    r42994 r42996  
    11<?php // upload.php
    22
    3 // get the locatl configuration variables
     3// get the local configuration variables
    44require "pstamp.php";
    55require "dblogin.php";
    6 
    76
    87$user = $_SERVER['PHP_AUTH_USER'];
     
    2221    s.innerHTML = s.innerHTML - 1;
    2322    if (s.innerHTML == 0)
    24   //    window.location = 'http://pstamp.ipp.ifa.hawaii.edu/dsroot.php';
     23      // window.location = 'http://pstamp.ipp.ifa.hawaii.edu/dsroot.php';
    2524      location.reload();
    2625    else
     
    4039echo "<body>\n";
    4140echo "The page will NOW refresh in <span id='timer'> 20</span> mins";
    42 $dbserver = dblogin();
     41$dbconnection = dblogin("DATASTORE");
    4342
    4443$query = "SELECT prod_name, last_fs, last_update, type, description FROM dsProduct ORDER BY type, prod_id";
    45 $result = mysqli_query($dbserver, $query);
     44$result = mysqli_query($dbconnection, $query);
    4645if (!$result) {
    47     die("Database access failed: " . mysqli_error($dbserver));
     46    die("Database access failed: " . mysqli_error($dbconnection));
    4847}
    4948
     
    5857    $prod_name = $row[0];
    5958    echo "<td>";
    60     // echo "<a href=\"http://datastore.ipp.ifa.hawaii.edu/$prod_name\">$prod_name</a>";
    61     //$prod_link = "http://datastore.ipp.ifa.hawaii.edu/$prod_name";
    62     $prod_link = "http://datastore.ipp.ifa.hawaii.edu/ds/$prod_name";
    63 
    64     // $prod_link "<a href=\"http://datastore.ipp.ifa.hawaii.edu/$prod_name\">$prod_name</a>";
     59    $prod_link = "$DS_URL/$prod_name";
    6560    echo "<a href=\"$prod_link\">$prod_name</a>";
    66    
    6761    echo "</td>";
    6862
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstamp.php

    r25322 r42996  
     1
    12<?php
    23
     
    45require_once "authenticate.php";
    56
     7function request_var($key, $filter = FILTER_DEFAULT, $default = null, $options = null) {
     8  $raw = $_POST[$key] ?? $_GET[$key] ?? null;
     9
     10  // Treat missing or empty as null
     11  if ($raw === '' || $raw === null) {
     12    return $default;
     13  }
     14
     15  // Apply validation
     16  $val = filter_var($raw, $filter, $options ?? []);
     17
     18  if ($val === false) {
     19    http_response_code(400);
     20    die("Invalid value for key '$key'");
     21  }
     22  return $val;
     23}
     24
     25//  $val = filter_input(INPUT_GET, $key, $filter, $options);
     26//  if ($val === false) {
     27//    http_response_code(400);
     28//    echo "<b> invalid GET key $key </b><br>";
     29//    die ("invalid GET key $key");
     30//  }
     31//  if ($val !== null) {
     32//    return $val;
     33//  }
     34//
     35//  $val = filter_input(INPUT_POST, $key, $filter, $options);
     36//  if ($val === false) {
     37//    http_response_code(400);
     38//    echo "<b> invalid POST key $key </b><br>";
     39//    die ("invalid POST key $key");
     40//  }
     41//  if ($val !== null) {
     42//    return $val;
     43//  }
     44//  return $default;
     45// }
     46
    647?>
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/pstampconfig.php

    r25322 r42996  
    22// BEGIN Local configuration
    33
    4 $WORKDIR = "set to the location of pstamp working directory";
    5 $dsroot = "set to the root of the data store";
    6 $dbname = "set to the pstamp database name";
    7 $dbserver = "set to the pstamp database server";
     4$WORKDIR = "/data/kukui.2/eugene/datastore.20260421/ps-out";
     5$DS_ROOT = "/data/kukui.2/eugene/datastore.20260421/dsroot";
     6$DS_URL  = "http://dstest.ifa.hawaii.edu";
     7// $dbname = "set to the pstamp database name";
     8// $dbserver = "set to the pstamp database server";
    89
    9 $PSCONFDIR = "";
    10 $PSCONFIG  = "";
     10# database info for the datastore
     11$DS_HOSTNAME = "localhost";
     12$DS_USERNAME = "ipp";
     13$DS_PASSWORD = "ipp";
     14$DS_DATABASE = "datastore";
     15
     16# database info for the pstamp
     17$PS_HOSTNAME = "localhost";
     18$PS_USERNAME = "ipp";
     19$PS_PASSWORD = "ipp";
     20$PS_DATABASE = "pstamp";
     21
     22$PSCONFDIR = "/home/kiawe/eugene/src/psconfig/";
     23$PSCONFIG  = "ipp-pstamp-20260421";
    1124$PSBINDIR  = "$PSCONFDIR/$PSCONFIG.lin64/bin";
    1225
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/request.php

    r42994 r42996  
    2222# this script sets up the environment to run IPP commands with current directory
    2323# $WORKDIR
    24 $SCRIPT    = "$PSBINDIR/pstamp_runcommand.sh $PSCONFDIR $PSCONFIG $WORKDIR";
     24// $SCRIPT    = "$PSBINDIR/pstamp_runcommand.sh $PSCONFDIR $PSCONFIG $WORKDIR";
    2525
    2626// END of moved to pstampconfig.php
     
    5757$outFileset = "";
    5858
    59 // Initialize the request variables that we depend upon
    60 $rvar_project="";
    61 
    6259$gpc1_selected="";
    6360$gpc2_selected="";
     
    6764$require_component = 0;
    6865
    69 $rvar_email = "";
    70 $rvar_select_by = "";
    71 $rvar_img_type = "";
    72 $rvar_id = "";
    73 $rvar_component = "";
    74 $rvar_survey = "bypass";
    75 $rvar_release = "";
    76 $rvar_data_group = "";
    77 $rvar_filter = "";
    78 
    79 $rvar_center_type = "";
    80 $rvar_range_type  = "";
    81 
    82 $rvar_RA = "";
    83 $rvar_DEC = "";
    84 $rvar_dRA = "";
    85 $rvar_dDEC = "";
    86 $rvar_X = "";
    87 $rvar_Y = "";
    88 $rvar_W = "";
    89 $rvar_H = "";
    90 
    91 $rvar_make_jpeg = "";
    92 $rvar_getall_roi = "";
    93 
    94 $rvar_cmd_mode = "";
    95 $rvar_last_cmd_mode = "";
    96 $rvar_request_id = 0;
    97 $rvar_last_request_id = 0;
     66// Initialize the request variables that we depend upon
     67
     68// EAM: modern PHP has deprecated the function import_request_variables
     69// I have created a wrapper function to filter_input to replace
     70$rvar_project         = request_var ('project', FILTER_SANITIZE_STRING);
     71$rvar_email           = request_var ('email',   FILTER_VALIDATE_EMAIL);
     72$rvar_select_by       = request_var ('select_by', FILTER_SANITIZE_STRING);
     73$rvar_img_type        = request_var ('img_type', FILTER_SANITIZE_STRING);
     74$rvar_id              = request_var ('id', FILTER_SANITIZE_STRING);
     75$rvar_component       = request_var ('component', FILTER_SANITIZE_STRING);
     76$rvar_survey          = request_var ('survey', FILTER_SANITIZE_STRING, "bypass");
     77$rvar_release         = request_var ('release', FILTER_SANITIZE_STRING);
     78$rvar_data_group      = request_var ('data_group', FILTER_SANITIZE_STRING);
     79$rvar_filter          = request_var ('filter', FILTER_SANITIZE_STRING);
     80$rvar_center_type     = request_var ('center_type', FILTER_SANITIZE_STRING);
     81$rvar_range_type      = request_var ('range_type', FILTER_SANITIZE_STRING);
     82$rvar_RA              = request_var ('RA', FILTER_VALIDATE_FLOAT);
     83$rvar_DEC             = request_var ('DEC', FILTER_VALIDATE_FLOAT);
     84$rvar_dRA             = request_var ('dRA', FILTER_VALIDATE_FLOAT);
     85$rvar_dDEC            = request_var ('dDEC', FILTER_VALIDATE_FLOAT);
     86$rvar_X               = request_var ('X', FILTER_VALIDATE_FLOAT);
     87$rvar_Y               = request_var ('Y', FILTER_VALIDATE_FLOAT);
     88$rvar_W               = request_var ('W', FILTER_VALIDATE_FLOAT);
     89$rvar_H               = request_var ('H', FILTER_VALIDATE_FLOAT);
     90$rvar_make_jpeg       = request_var ('make_jpeg', FILTER_SANITIZE_STRING);
     91$rvar_getall_roi      = request_var ('getall_roi', FILTER_SANITIZE_STRING);
     92$rvar_cmd_mode        = request_var ('cmd_mode', FILTER_SANITIZE_STRING);
     93$rvar_last_cmd_mode   = request_var ('last_cmd_mode', FILTER_SANITIZE_STRING);
     94$rvar_request_id      = request_var ('request_id', FILTER_VALIDATE_INT, 0);
     95$rvar_last_request_id = request_var ('last_request_id', FILTER_VALIDATE_INT, 0);
    9896
    9997// now get the values from this post
    10098
    101 import_request_variables("gp", "rvar_");
     99// import_request_variables("gp", "rvar_");
    102100
    103101if ($rvar_project == "gpc1") {
     
    284282    global $rvar_survey, $rvar_release;
    285283    global $command_line;
    286     global $dbname;
    287     global $dbserver;
    288284    global $require_component;
    289285    global $PSCONFDIR, $PSCONFIG, $WORKDIR;
     
    314310
    315311    if ($dbname) {
    316         $cmd .= " --dbname $dbname --dbserver $dbserver";
     312        $cmd .= " --dbname $PS_DATABASE --dbserver $PS_HOSTNAME";
    317313    }
    318314
     
    455451    global $command_status;
    456452
    457     // echo "<br>running $command_line\n<br>";
    458 
    459     exec ("$command_line", $output_array, $command_status);
     453    // EAM : testing:
     454    echo "<br>running $command_line\n<br>";
     455
     456    // EAM : testing:
     457    // exec ("$command_line", $output_array, $command_status);
     458    http_response_code(400);
     459    echo "<b> run command $command_line</b><br>";
     460    die ("run command $command_line");
    460461
    461462    $size = sizeof($output_array);
     
    503504                global $dsroot;
    504505                $dirName  = "$dsroot/$product/$req_name";
    505                 // XXX: TODO: make this a configuration parameter
    506                 //$filesetURL = "http://datastore.ipp.ifa.hawaii.edu/$product/$req_name";
    507                 $filesetURL = "http://datastore.ipp.ifa.hawaii.edu/ds/$product/$req_name";
     506                $filesetURL = "$DS_URL/$product/$req_name";
    508507
    509508                $fullpath = "$dirName/$fileName";
    510 // echo "<pre>fullpath: $fullpath filesetURL: $filesetURL\n</pre>";
     509                // echo "<pre>fullpath: $fullpath filesetURL: $filesetURL\n</pre>";
    511510                if (file_exists($dirName)) {
    512511                    // this job is done, list the url as a link
     
    551550  s.innerHTML = s.innerHTML - 1;
    552551  if (s.innerHTML == 0)
    553 //    window.location = 'http://pstamp.ipp.ifa.hawaii.edu/request.php';
     552 //    window.location = 'http://pstamp.ipp.ifa.hawaii.edu/request.php';
    554553    location.reload();
    555554  else
     
    878877<?php
    879878    // 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");
     879    listRequests("$DS_URL", "pstamp_results_fileset");
    882880?>
    883881
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/submitted.php

    r42994 r42996  
    7272        if ($id && ($req->state != "stop")) {
    7373            // Get the current state of this request from the database
    74             if (!$dbserver) {
    75                 $dbserver = dblogin();
     74            if (!$dbconnection) {
     75                $dbconnection = dblogin("PSTAMP");
    7676            }
    7777
     
    7979            // echo "<br />$query<br />";
    8080
    81             $result  = mysqli_query($dbserver, $query);
     81            $result  = mysqli_query($dbconnection, $query);
    8282            if (!$result) {
    83                 die("Database access failed: " . mysqli_error($dbserver));
     83                die("Database access failed: " . mysqli_error($dbconnection));
    8484            }
    8585
     
    128128function listRequests($dataStoreRoot, $targetWindow)
    129129{
    130     $debug_listing = 0;
    131     $request_count = count($_SESSION['requests']);
    132     // echo "request_count: $request_count<br />";
     130  $debug_listing = 0;
     131  $request_count = count($_SESSION['requests']);
     132  $dbconnection = 0;
     133 
     134  // echo "request_count: $request_count<br />";
    133135
    134136    for ($i = $request_count-1; $i >= 0; $i--) {
     
    147149            // Request not done last time that we checked.
    148150            // Get its current state of this request from the database
    149             if (!$dbserver) {
    150                 $dbserver = dblogin();
     151            if (!$dbconnection) {
     152                $dbconnection = dblogin("PSTAMP");
    151153            }
    152154            $query = "SELECT pstampRequest.state, COUNT(job_id) as num_jobs, pstampRequest.fault, pstampRequest.outProduct FROM pstampRequest LEFT JOIN pstampJob USING(req_id) WHERE req_id = $id";
     
    154156            // echo "<br />$query<br />";
    155157
    156             $result  = mysqli_query($dbserver, $query);
     158            $result  = mysqli_query($dbconnection, $query);
    157159            if (!$result) {
    158                 die("Database access failed: " . mysqli_error($dbserver));
     160                die("Database access failed: " . mysqli_error($dbconnection));
    159161            }
    160162
  • branches/eam_branches/ipp-pstamp-20260421/pstamp/web/upload.php

    r42994 r42996  
    7272           if ($size > 0) {
    7373      //      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";
     74            $command = "$SCRIPT pstamp_insert_request.pl --tmp_req_file $tmp_name --dbname $PS_DATABASE --dbserver $PS_HOSTNAME --workdir $WORKDIR";
    7575            } else {
    7676                echo "Error: Received 0 bytes for file '$name' <br />\n";
     
    134134echo "<br />\n";
    135135
    136 // listRequests("http://datastore.ipp.ifa.hawaii.edu", "pstamp_results_fileset");
    137 listRequests("http://datastore.ipp.ifa.hawaii.edu/ds", "pstamp_results_fileset");
     136listRequests($DS_URL, "pstamp_results_fileset");
    138137
    139138echo "<br />\n";
Note: See TracChangeset for help on using the changeset viewer.