IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 42384 for trunk/ippMonitor


Ignore:
Timestamp:
Feb 8, 2023, 12:00:36 PM (3 years ago)
Author:
eugene
Message:

merge from eam_branches/ipp-20220316. add PDO DB access method (DBI now deprecated); modern PHP is more strict about array index names (must be quoted); more flexible locations for CZARPLOTDIR, METRICSPLOTDIR for test installations; add fpcamera

Location:
trunk/ippMonitor
Files:
19 edited
3 copied

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor

  • trunk/ippMonitor/INSTALL

    r41730 r42384  
    2828psconfig ipp-20210708-gentoo
    2929
     30# Copy these files and modify them.
     31# config.dat is used to generate the site.php file installed in the htdocs location
     32cp config.dat.in config.dat
     33
     34# czarconfig.xml is used by czarpool.pl
     35cp czartool/czarconfig.xml.in czartool/czarconfig.xml
     36
    3037# run psconfigure to generate Makefile and raw/site.php
    3138# DO NOT check site.php into the svn tree
    3239# $CZARPLOTDIR and $METRICSPLOTDIR will be generated as links in the same folder as ippMonitor 
    33 # the structure of the names for these two directories are defined in Makefile.in
    34 psconfigure --htdocs /var/www/localhost/htdocs --wwwbin /var/www/localhost/wwwbin --site ~/ippconfig/ippmonitor.config
     40# the structure of the names for these two directories are defined in Makefile.in a
     41psconfigure --htdocs /var/www/localhost/htdocs --wwwbin /var/www/localhost/wwwbin --pltdir /some/path --site ~/ippconfig/ippmonitor.config
    3542
    3643## NOTES:
     
    4148## For an initial installation, you may need to create /var/www/localhost/wwwbin
    4249
    43 # Copy these files and modify them.
    44 # config.dat is used to generate the site.php file installed in the htdocs location
    45 cp config.dat.in config.dat
    46 
    47 # czarconfig.xml is used by czarpool.pl
    48 cp czartool/czarconfig.xml.in czartool/czarconfig.xml
    49 
    5050# install the php code:
    5151# czartool_plots and ippMetrics will be linked to different path in different hostnames
  • trunk/ippMonitor/Makefile.in

    r42273 r42384  
    99DESTBIN = @WWWBIN@
    1010DESTWWW = @HTDOCS@/ippMonitor
    11 CZARPLOTDIR = /export/@HOST2@.0/ipp/czartool_plots
    12 METRICSPLOTDIR = /export/@HOST2@.0/ipp/ippMetrics
     11
     12CZARPLOTDIR = @PLTDIR@/czartool_plots
     13METRICSPLOTDIR = @PLTDIR@/ippMetrics
    1314
    1415GENERATE = $(SCRIPTS)/generate
  • trunk/ippMonitor/config.dat.in

    r41679 r42384  
    9898$LABEL_APACHE6  = "";
    9999
    100 $HOST_APACHE_BACKUP1  = ";"
    101 $LABEL_APACHE_BACKUP1  = ";"
     100$HOST_APACHE_BACKUP1  = "";
     101$LABEL_APACHE_BACKUP1  = "";
    102102
    103 $HOST_APACHE_BACKUP2  = ";"
    104 $LABEL_APACHE_BACKUP2  = ";"
     103$HOST_APACHE_BACKUP2  = "";
     104$LABEL_APACHE_BACKUP2  = "";
    105105
    106106$HOST_HOME  = "";
  • trunk/ippMonitor/configure.tcsh

    r41730 r42384  
    1818set wwwbin  = ""
    1919set libdir  = ""
     20set pltdir  = ""
    2021set datadir = ""
    2122set site = ""
     
    109110   endif
    110111   breaksw;
     112  case --pltdir*
     113   if ("$1" == "--pltdir") then
     114     shift
     115     set pltdir = $1
     116   else
     117     set pltdir = `echo $1 | tr = ' ' | awk '{print $2}'`
     118   endif
     119   breaksw;
    111120  case --datadir*
    112121   if ("$1" == "--datadir") then
     
    127136  case --useMDB2
    128137   set DBI = "MDB2"
     138   breaksw;
     139  case --usePDO
     140   set DBI = "PDO"
    129141   breaksw;
    130142  case --help:
     
    150162echo "wwwbin: $wwwbin"
    151163echo "libdir: $libdir"
     164echo "pltdir: $pltdir"
    152165echo "datadir:$datadir"
    153166echo "site:   $site"
     
    182195endif
    183196
     197# LIBDIR set the install lib directory
     198if ("$pltdir" == "") then
     199  if ("$prefix" == "") goto usage
     200  set pltdir = $prefix/plots
     201endif
     202
    184203# DATADIR holds the general non-binary files
    185204if ("$datadir" == "") then
     
    198217# convert Makefile.in to Makefile:
    199218if (-e Makefile) mv -f Makefile Makefile~
    200 cat Makefile.in | sed "s|@HTDOCS@|$htdocs|"    > tmp.1
    201 cat tmp.1       | sed "s|@HOST2@|$hostname2|"  > tmp.2
    202 cat tmp.2       | sed "s|@BINDIR@|$bindir|"    > tmp.1
    203 cat tmp.1       | sed "s|@WWWBIN@|$wwwbin|"    > Makefile
     219cat Makefile.in | sed "s|@HTDOCS@|$htdocs|"  > tmp.1
     220cat tmp.1       | sed "s|@PLTDIR@|$pltdir|"  > tmp.2
     221cat tmp.2       | sed "s|@BINDIR@|$bindir|"  > tmp.1
     222cat tmp.1       | sed "s|@WWWBIN@|$wwwbin|"  > Makefile
    204223rm -f tmp.1 tmp.2
    205224
  • trunk/ippMonitor/raw/Login.php

    r25308 r42384  
    33include 'ipp.php';
    44
    5 if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
     5if (($_SERVER['REQUEST_METHOD'] != 'POST') && ($_SERVER['REQUEST_METHOD'] != 'GET')) {
    66  menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
    77  echo "Invalid Client Request<br>\n";
     
    1010}
    1111
    12 if ($_SERVER[REQUEST_METHOD] == 'GET') {
     12if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    1313
    1414  $ID = checkID ();
     
    2929}
    3030
    31 if ($_SERVER[REQUEST_METHOD] == 'POST') {
    32   if (key_exists (login, $_POST)) {
     31if ($_SERVER['REQUEST_METHOD'] == 'POST') {
     32  if (key_exists ('login', $_POST)) {
    3333
    3434    $ID = checkLogin ();
     
    4040  }
    4141
    42   if (key_exists (logout, $_POST)) {
     42  if (key_exists ('logout', $_POST)) {
    4343    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
    4444    echo "You are now logged out<br>\n";
  • trunk/ippMonitor/raw/SelectProject.php

    r9439 r42384  
    33include 'ipp.php';
    44
    5 if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
     5if (($_SERVER['REQUEST_METHOD'] != 'POST') && ($_SERVER['REQUEST_METHOD'] != 'GET')) {
    66  menu ('ipp.menu.dat', 'Select Project', 'ipp.css', '', '');
    77  echo "Invalid Client Request<br>\n";
     
    1212$ID = checkID ();
    1313
    14 if ($_SERVER[REQUEST_METHOD] == 'GET') {
     14if ($_SERVER['REQUEST_METHOD'] == 'GET') {
    1515  projectform ($ID);
    1616}
    1717
    18 if ($_SERVER[REQUEST_METHOD] == 'POST') {
     18if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    1919
    2020  if (key_exists (project, $_POST)) {
    21     $myProj = $_POST[proj];
     21    $myProj = $_POST['proj'];
    2222    $ID['proj'] = $myProj;
    2323    // validate the existence of the project
  • trunk/ippMonitor/raw/czartool_getplot.php

    r40840 r42384  
    88
    99### we must have been past arguments with GET:
    10 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     10if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    1111    exit ();
    1212}
    1313
    14 $mode = $_GET[mode];
    15 $type = $_GET[type];
    16 $label = $_GET[label];
    17 $stage = $_GET[stage];
    18 $plottype = $_GET[plottype];
     14$mode = $_GET['mode'];
     15$type = $_GET['type'];
     16$label = $_GET['label'];
     17$stage = $_GET['stage'];
     18$plottype = $_GET['plottype'];
    1919
    20 $proj = $_GET[proj];
     20$proj = $_GET['proj'];
    2121
    2222$path = $CZARPLOTDIR;
  • trunk/ippMonitor/raw/getlog.php

    r41730 r42384  
    99// load an image file from the image directory
    1010// validate request
    11 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     11if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    1212  exit ();
    1313}
     
    2020
    2121# $basename may contain filename@filerule
    22 $basename = strtok($_GET[name],"@");
     22$basename = strtok($_GET['name'],"@");
    2323$filerule = strtok("@");
    2424
  • trunk/ippMonitor/raw/ipp.ffs.dat

    r41133 r42384  
    99menulink  | menuselect   | link    | Full Force Failed            | failedFullforce.php
    1010
    11 
     11menutop   | menutop      | plain   | &nbsp;                       |
     12menulink  | menuselect   | link    | Forced Phot Camera Exp               | fpcamStageExp.php           
     13menulink  | menuselect   | link    | Forced Phot Camera Pending           | fpcamPendingExp.php             
     14menulink  | menuselect   | link    | Forced Phot Camera Processed Exp     | fpcamProcessedExp.php           
  • trunk/ippMonitor/raw/ipp.ffs.php

    r41126 r42384  
    88if (! $ID['proj']) { projectform ($ID); }
    99
    10 menu('ipp.ffs.dat', 'Full Force Steps', 'ipp.css', $ID['link'], $ID['proj']);
     10menu('ipp.ffs.dat', 'Forced Photometry Steps', 'ipp.css', $ID['link'], $ID['proj']);
    1111
    1212// document body
  • trunk/ippMonitor/raw/ipp.php

    r41730 r42384  
    2626
    2727  menu ('ipp.menu.dat', 'Select Project', 'ipp.css', $ID['link'], $ID['proj']);
    28   if ($_GET['new'] && $_GET['proj']) {
     28  if (isset($_GET['new']) && isset($_GET['proj'])) {
    2929    echo "<p> Project is now <b>" . $_GET['proj'] . "</b></p>\n";
    3030  }
     
    6666  global $DBI;
    6767
     68  if ($DBI == "PDO") {
     69    $result = $qry->fetch();
     70    if ($result == NULL) {
     71      $success = 0;
     72    } else {
     73      $success = 1;
     74    }
     75  }
    6876  if ($DBI == "MDB2") {
    6977    $result = $qry->fetchRow();
     
    9098  global $CZARDBHOST;
    9199
     100  // define the DSN strings. NOTE: PDO uses a different format from DB or MDB2
     101  if ($database == $CZARDBNAME) {
     102    $dsn_pdo = "mysql:host=$DBHOST;dbname=$database";
     103    $dsn = "mysql://$DBUSER:$DBPASS@$CZARDBHOST/$database";
     104    $dsnerr = "mysql://$DBUSER:XXX@$CZARDBHOST/$database"; // only used to report the error
     105  } else {
     106    $dsn_pdo = "mysql:host=$CZARDBHOST;dbname=$database"; // note this is case sensitive
     107    $dsn = "mysql://$DBUSER:$DBPASS@$DBHOST/$database";
     108    $dsnerr = "mysql://$DBUSER:XXX@$DBHOST/$database"; // only used to report the error
     109  }
     110
     111  // PDO has a different error handling method initially (throw exception)
     112  // but after construction can be set to match DB & MDB2
     113  if ($DBI == "PDO") {
     114    try {
     115      $db = new PDO($dsn_pdo, $DBUSER, $DBPASS);
     116      $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
     117    } catch (PDOException $dberr) {
     118      dbconnectFailure($dberr, $dsnerr);
     119    }
     120    return $db;
     121  }
     122
    92123  $success = 0;
    93124  if ($DBI == "MDB2") {
     
    104135  }
    105136
    106   // connect to the database
    107   if ($database == $CZARDBNAME) {
    108     $dsn = "mysql://$DBUSER:$DBPASS@$CZARDBHOST/$database";
    109     $dsnerr = "mysql://$DBUSER:XXX@$CZARDBHOST/$database"; // only used to report the error
    110   } else {
    111     $dsn = "mysql://$DBUSER:$DBPASS@$DBHOST/$database";
    112     $dsnerr = "mysql://$DBUSER:XXX@$DBHOST/$database"; // only used to report the error
    113   }
    114137  if ($DBI == "DB") {
    115138    $db = DB::connect($dsn);
     
    118141    $db = MDB2::connect($dsn);
    119142  }
    120 
    121143  if (dberror($db)) {
    122     echo "<b>error accessing database</b><br>\n";
    123     echo "<b>tried $dsnerr</b><br>\n";
    124     $result = $db->getMessage();
    125     echo "$result<br>";
    126     menu_end();
     144    dbconnectFailure($db, $dsnerr);
    127145  }
    128146  return $db;
    129147}
    130148
     149function dbconnectFailure($db, $dsnerr) {
     150  echo "<b>error accessing database</b><br>\n";
     151  echo "<b>tried $dsnerr</b><br>\n";
     152  $result = $db->getMessage();
     153  echo "$result<br>";
     154  menu_end();
     155}
     156
     157# return true/false for an error
    131158function dberror ($db) {
    132159  global $DBI;
     
    137164  if ($DBI == "DB") {
    138165    $dberr = DB::isError($db);
     166  }
     167  if ($DBI == "PDO") {
     168    if ($db == null) {
     169      $dberr = 1;
     170    } else {
     171      $dberr = 0;
     172    }
    139173  }
    140174
  • trunk/ippMonitor/raw/plotHistogram.php

    r41730 r42384  
    1212
    1313### we must have been past arguments with GET:
    14 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     14if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    1515  exit ();
    1616}
     
    4343}
    4444
    45 $infile  = $_GET[input];
    46 $outfile = $_GET[output];
    47 $title = $_GET[title];
     45$infile  = $_GET['input'];
     46$outfile = $_GET['output'];
     47$title = $_GET['title'];
    4848
    4949if ($debug) {
  • trunk/ippMonitor/raw/scatterPlot.php

    r41730 r42384  
    1212
    1313### we must have been past arguments with GET:
    14 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     14if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    1515  exit ();
    1616}
     
    4343}
    4444
    45 $infile  = $_GET[input];
    46 $outfile = $_GET[output];
    47 $title = $_GET[title];
     45$infile  = $_GET['input'];
     46$outfile = $_GET['output'];
     47$title = $_GET['title'];
    4848
    4949$title = preg_replace("/'/", "", $title);
  • trunk/ippMonitor/raw/show_and_delete_image.php

    r28433 r42384  
    22
    33### we must have been past arguments with GET:
    4 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     4if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    55  exit ();
    66}
    77
    8 $filename = $_GET[file];
     8$filename = $_GET['file'];
    99
    1010$file = fopen ($filename, "r");
  • trunk/ippMonitor/raw/show_log.php

    r41730 r42384  
    55include 'site.php';
    66
    7 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     7if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    88  exit ();
    99}
     
    1313putenv("PATH=$WWWBIN:$BINDIR:$PATH");
    1414
    15 $basename = $_GET[basename];
     15$basename = $_GET['basename'];
    1616$basename = escapeshellarg($basename);
    1717
    18 $state = $_GET[state];
     18$state = $_GET['state'];
    1919$state = escapeshellarg($state);
    2020if (!$state) $state = 'new';
  • trunk/ippMonitor/raw/showimage.php

    r27054 r42384  
    1111// load an image file from the image directory
    1212// validate request
    13 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     13if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    1414  exit ();
    1515}
     
    2020
    2121# $basename may contain filename@filerule
    22 $basename = $_GET[name];
    23 $filerule = $_GET[rule];
    24 $camera   = $_GET[camera];
    25 $class_id = $_GET[class_id];
     22$basename = $_GET['name'];
     23$filerule = $_GET['rule'];
     24$camera   = $_GET['camera'];
     25$class_id = $_GET['class_id'];
    2626
    2727$title = $basename;
  • trunk/ippMonitor/raw/skycellplot.php

    r41730 r42384  
    1313
    1414### we must have been past arguments with GET:
    15 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     15if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    1616  exit ();
    1717}
     
    4444}
    4545
    46 $infile  = $_GET[input];
    47 $outfile = $_GET[output];
     46$infile  = $_GET['input'];
     47$outfile = $_GET['output'];
    4848
    4949$output = shell_exec("skycellplot.dvo $infile $outfile");//, $output, $status);
  • trunk/ippMonitor/raw/skyplot.php

    r41730 r42384  
    2323
    2424### we must have been passed arguments with GET:
    25 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     25if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    2626  exit ();
    2727}
     
    5454}
    5555
    56 $infile  = $_GET[input];
    57 $outfile = $_GET[output];
     56$infile  = $_GET['input'];
     57$outfile = $_GET['output'];
    5858
    5959// $output = shell_exec("skyplot.dvo $infile $outfile");//, $output, $status);
Note: See TracChangeset for help on using the changeset viewer.