IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 39498


Ignore:
Timestamp:
Mar 31, 2016, 6:26:07 AM (10 years ago)
Author:
eugene
Message:

fix MDB2 DBI methods; avoid php warnings by putting quotes around hash arguments; check for hash element existence before using; simplify code with get_htmlkey_value function

Location:
trunk/ippMonitor
Files:
24 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/configure.tcsh

    r38208 r39498  
    227227
    228228Fine tuning of the installation directories:
     229  --useMDB2              use MDB2 interface instead of DB
     230
    229231  --bindir=DIR           user executables [PREFIX/bin/$ARCH]
    230232  --libdir=DIR           object code libraries [PREFIX/lib/$ARCH]
  • trunk/ippMonitor/def/autocode.php

    r34014 r39498  
    2626
    2727// define restrictions to the queries
     28$WHERE = "";
    2829// ** TABLE RESTRICTIONS **
    2930
     
    4041
    4142// get the result table count
    42 if ($MODE == "basic") {
     43if ("$MODE" == "basic") {
    4344  $sql = "SELECT count(*) FROM $TABLE $WHERE";
    4445}
    45 if ($MODE == "summary") {
     46if ("$MODE" == "summary") {
    4647  $sql = "SELECT count(*) FROM (SELECT $FIELDS FROM $TABLE $WHERE) as TEMP";
    4748}
     
    5354  menu_end();
    5455}
    55 if (!$qry->fetchInto($row)) {
     56if (!dbFetchInto($qry, $row)) {
    5657  echo "<b>error reading $TABLE table count</b><br>\n";
    5758  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    7879
    7980// query the database
    80 if ($MODE == "basic") {
     81if ("$MODE" == "basic") {
    8182  $sql = "SELECT $FIELDS FROM $TABLE $WHERE LIMIT $dTABLE OFFSET $rowStart";
    8283}
    83 if ($MODE == "summary") {
     84if ("$MODE" == "summary") {
    8485  $sql = "SELECT $FIELDS FROM $TABLE $WHERE LIMIT $dTABLE OFFSET $rowStart";
    8586}
     
    9495// ** HEAD CODE **
    9596
     97$buttonLink = "";
    9698// ** BUTTON RESTRICTIONS **
    9799navigate_buttons ($rowStart, $rowLast, $dTABLE, $rowTotal, $buttonLink, $ID, '$FILE');
     
    113115
    114116// list the results
    115 while ($qry->fetchInto($row)) {
     117while (dbFetchInto($qry, $row)) {
    116118  // $link = "$FILE" . "?expID=" . $row[0] . "&" . $ID['link'];
    117119
  • trunk/ippMonitor/def/autocodeImage.php

    r31102 r39498  
    4646  menu_end();
    4747}
    48 if (!$qry->fetchInto($row)) {
     48if (!dbFetchInto($qry, $row)) {
    4949  echo "<b>error reading $TABLE table count</b><br>\n";
    5050  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    111111
    112112// output the results to tmpfile
    113 while ($qry->fetchInto($row)) {
     113while (dbFetchInto($qry, $row)) {
    114114  $line = "";
    115115  foreach ($row as $i => $value) {
  • trunk/ippMonitor/def/detInputExp.d

    r18193 r39498  
    3838FIELD rawExp.bg_stdev,        5, %.2f,   stdev   
    3939FIELD rawExp.bg_mean_stdev,   5, %.2f,   &lt;backgnd&gt;
    40 FIELD *,                      5, %s,     choose,     value=resid, detResidImfile.php,     ARG2
    41 FIELD *,                      5, %s,     choose,     value=proc,  detProcessedImfile.php, ARG3
     40FIELD *,                      5, %s,     choose,     value='resid', detResidImfile.php,     ARG2
     41FIELD *,                      5, %s,     choose,     value='proc',  detProcessedImfile.php, ARG3
    4242
    4343TD_CLASS det_off  $detInputExp.include == 0
  • trunk/ippMonitor/def/detRun.d

    r26072 r39498  
    2323FIELD det_type,     12, %s,     type
    2424FIELD state,         5, %s,     state
    25 FIELD *,             5, %s,     IN,          value=IN,   detInputExp.php,          ARG2
    26 FIELD *,             5, %s,     P,           value=P,   detProcessedExp.php,      ARG3
    27 FIELD *,             5, %s,     D,           value=D,   detResidExp.php,          ARG4
    28 FIELD *,             5, %s,     S,           value=S,   detStackedImfile.php,     ARG5
    29 FIELD *,             5, %s,     N,           value=N,   detNormalizedImfile.php,  ARG6
    30 FIELD *,             5, %s,     R,           value=R,   detRegisteredImfile.php,  ARG7
     25FIELD *,             5, %s,     IN,          value='IN',  detInputExp.php,          ARG2
     26FIELD *,             5, %s,     P,           value='P',   detProcessedExp.php,      ARG3
     27FIELD *,             5, %s,     D,           value='D',   detResidExp.php,          ARG4
     28FIELD *,             5, %s,     S,           value='S',   detStackedImfile.php,     ARG5
     29FIELD *,             5, %s,     N,           value='N',   detNormalizedImfile.php,  ARG6
     30FIELD *,             5, %s,     R,           value='R',   detRegisteredImfile.php,  ARG7
    3131FIELD mode,          5, %s,     mode
    3232FIELD filter,        5, %s,     filter     
  • trunk/ippMonitor/def/detRunActive.d

    r24868 r39498  
    2626FIELD det_type,     12, %s,     type
    2727FIELD state,         5, %s,     state
    28 FIELD *,             5, %s,     IN,          value=IN,   detInputExp.php,          ARG2
    29 FIELD *,             5, %s,     P,           value=P,   detProcessedExp.php,      ARG3
    30 FIELD *,             5, %s,     D,           value=D,   detResidExp.php,          ARG4
    31 FIELD *,             5, %s,     S,           value=S,   detStackedImfile.php,     ARG5
    32 FIELD *,             5, %s,     N,           value=N,   detNormalizedImfile.php,  ARG6
    33 FIELD *,             5, %s,     R,           value=R,   detRegisteredImfile.php,  ARG7
     28FIELD *,             5, %s,     IN,          value='IN',   detInputExp.php,          ARG2
     29FIELD *,             5, %s,     P,           value='P',   detProcessedExp.php,      ARG3
     30FIELD *,             5, %s,     D,           value='D',   detResidExp.php,          ARG4
     31FIELD *,             5, %s,     S,           value='S',   detStackedImfile.php,     ARG5
     32FIELD *,             5, %s,     N,           value='N',   detNormalizedImfile.php,  ARG6
     33FIELD *,             5, %s,     R,           value='R',   detRegisteredImfile.php,  ARG7
    3434FIELD mode,          5, %s,     mode
    3535FIELD filter,        5, %s,     filter     
  • trunk/ippMonitor/def/detRunSummary.d

    r19726 r39498  
    1616FIELD detRunSummary.iteration,  5,  %s,     iter
    1717FIELD detRunSummary.accept,     4,  %s,     keep
    18 FIELD *,                       20,  %s,     choose,    value=input, detInputExp.php,  ARG1
    19 FIELD *,                       20,  %s,     choose,    value=proc,  detProcessedExp.php,      ARG3
    20 FIELD *,                       20,  %s,     choose,    value=resid, detResidExp.php,  ARG2
     18FIELD *,                       20,  %s,     choose,    value='input', detInputExp.php,  ARG1
     19FIELD *,                       20,  %s,     choose,    value='proc',  detProcessedExp.php,      ARG3
     20FIELD *,                       20,  %s,     choose,    value='resid', detResidExp.php,  ARG2
    2121FIELD detRunSummary.bg,        20,  %s,     bg
    2222FIELD detRunSummary.bg_stdev,  20,  %s,     bg_stdev
  • trunk/ippMonitor/def/keptDetrendFrames.d

    r15954 r39498  
    2828FIELD detRun.det_type,         5,    %s,     type
    2929FIELD detRun.state,            5,    %s,     state
    30 FIELD *,                       20,   %s,     choose,       value=input, detInputExp.php,          ARG2
    31 FIELD *,                       20,   %s,     choose,       value=proc,  detProcessedExp.php,      ARG3
    32 FIELD *,                       20,   %s,     choose,       value=resid, detResidExp.php,          ARG4
     30FIELD *,                       20,   %s,     choose,       value='input', detInputExp.php,          ARG2
     31FIELD *,                       20,   %s,     choose,       value='proc',  detProcessedExp.php,      ARG3
     32FIELD *,                       20,   %s,     choose,       value='resid', detResidExp.php,          ARG4
    3333FIELD detRunSummary.bg,        20,   %s,     bg
    3434FIELD detRunSummary.bg_stdev,  20,   %s,     bg_stdev
  • trunk/ippMonitor/def/masterDetrendFrames.d

    r19726 r39498  
    3030# FIELD detRun.mode,             5,    %s,     mode
    3131# FIELD detRunSummary.accept,    5,    %s,     accept
    32 FIELD *,                       5,    %s,     choose,       value=input, detInputExp.php,          ARG2
    33 FIELD *,                       5,    %s,     choose,       value=proc,  detProcessedExp.php,      ARG3
    34 FIELD *,                       5,    %s,     choose,       value=stack, detStackedImfile.php,  ARG5
    35 FIELD *,                       5,    %s,     choose,       value=resid, detResidExp.php,          ARG4
     32FIELD *,                       5,    %s,     choose,       value='input', detInputExp.php,          ARG2
     33FIELD *,                       5,    %s,     choose,       value='proc',  detProcessedExp.php,      ARG3
     34FIELD *,                       5,    %s,     choose,       value='stack', detStackedImfile.php,  ARG5
     35FIELD *,                       5,    %s,     choose,       value='resid', detResidExp.php,          ARG4
    3636FIELD mode,                    5,    %s,     mode
    3737FIELD filter,                 10,    %s,     filter     
  • trunk/ippMonitor/raw/columns_in_db.php

    r28688 r39498  
    130130  $line = "";
    131131  $values = array();
    132   while ($qry->fetchInto($row)) {
     132  while (dbFetchInto($qry, $row)) {
    133133    // print "[".$row[0]."]<br>\n";
    134134    foreach ($row as $index => $value) {
  • trunk/ippMonitor/raw/czartool_exposures.php

    r38258 r39498  
    7474
    7575    $qry = $db->query($sql);
    76     $qry->fetchInto($count);
     76  dbFetchInto($qry, $count);
    7777
    7878    if ($surveyStr == "") $surveyText = "all surveys";
     
    154154
    155155    // loop through results in order to make html table
    156     while ($qry->fetchInto($row)) {
     156    while (dbFetchInto($qry, $row)) {
    157157
    158158        $exp_id = $row[0];
     
    257257    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    258258
    259     while ($qry->fetchInto($row)) {
     259    while (dbFetchInto($qry, $row)) {
    260260
    261261        if ($row[2] > 0) $hash[$row[0]] = "Y";
     
    287287    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    288288
    289     while ($qry->fetchInto($row)) {
     289    while (dbFetchInto($qry, $row)) {
    290290
    291291        if ($row[2] > 0) $hash[$row[0]] = "Y";
     
    318318    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    319319
    320     while ($qry->fetchInto($row)) {
     320    while (dbFetchInto($qry, $row)) {
    321321
    322322        if ($row[2] > 0) $hash[$row[0]] = "Y";
     
    350350    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    351351
    352     while ($qry->fetchInto($row)) {
     352    while (dbFetchInto($qry, $row)) {
    353353
    354354        if ($row[2] > 0) $hash[$row[0]] = $row[2];
     
    380380    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    381381
    382     while ($qry->fetchInto($row)) {
     382    while (dbFetchInto($qry, $row)) {
    383383
    384384        if ($row[2] > 0) $hash[$row[0]] = $row[2];
     
    408408    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    409409
    410     while ($qry->fetchInto($row)) {
     410    while (dbFetchInto($qry, $row)) {
    411411
    412412        if ($row[2] > 0) {
     
    444444    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    445445
    446     while ($qry->fetchInto($row)) {
     446    while (dbFetchInto($qry, $row)) {
    447447
    448448        if ($row[2] > 0) $hash[$row[0]] = $row[2];
     
    475475    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    476476
    477     while ($qry->fetchInto($row)) {
     477    while (dbFetchInto($qry, $row)) {
    478478
    479479        if ($row[2] > 0) $hash[$row[0]] = $row[2];
     
    505505    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    506506
    507     while ($qry->fetchInto($row)) {
     507    while (dbFetchInto($qry, $row)) {
    508508
    509509        $hash[$row[0]] = $row[1];
     
    536536    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    537537
    538     while ($qry->fetchInto($row)) {
     538    while (dbFetchInto($qry, $row)) {
    539539
    540540        if ($row[2] > 0) $hash[$row[0]] = $row[2];
     
    566566    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    567567    $hash = array();
    568     while ($qry->fetchInto($row)) {
     568    while (dbFetchInto($qry, $row)) {
    569569
    570570        if ($row[2] == 2) $hash1[$row[0]] = $row[1];
  • trunk/ippMonitor/raw/czartool_ipptopsps.php

    r33846 r39498  
    176176    $qry = $db->query($sql);
    177177    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    178     while ($qry->fetchInto($row)) {
     178    while (dbFetchInto($qry, $row)) {
    179179
    180180        $labels[] = $row[0];
     
    367367    $qry = $db->query($sql);
    368368    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    369     $qry->fetchInto($row);
     369    dbFetchInto($qry, $row);
    370370
    371371    $pending = $row[0];
     
    400400    $qry = $db->query($sql);
    401401    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    402     $qry->fetchInto($row);
     402    dbFetchInto($qry, $row);
    403403
    404404    return $row[0];
  • trunk/ippMonitor/raw/czartool_labels.php

    r38719 r39498  
    313313
    314314    // list the results
    315     while ($qry->fetchInto($row)) {
     315    while (dbFetchInto($qry, $row)) {
    316316
    317317        echo "<tr>";
     
    358358
    359359    // list the results
    360     while ($qry->fetchInto($expType)) {
     360    while (dbFetchInto($qry, $expType)) {
    361361
    362362        $sql = "SELECT COUNT(*) FROM summitExp WHERE dateobs > '$date' AND exp_type = '$expType[0]'";
    363363        $qry2 = $projectdb->query($sql);
    364         $qry2->fetchInto($summit);
     364      dbFetchInto($qry2, $summit);
    365365        $sql = "SELECT COUNT(*) FROM summitExp JOIN rawExp ON summitExp.exp_name = rawExp.exp_name WHERE summitExp.dateobs > '$date' AND summitExp.exp_type = '$expType[0]'";
    366366        $qry2 = $projectdb->query($sql);
    367         $qry2->fetchInto($mhpcc);
     367      dbFetchInto($qry2, $mhpcc);
    368368
    369369        echo "<tr>";
     
    397397    $qry = $db->query($sql);
    398398    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    399     while ($qry->fetchInto($row)) {
     399    while (dbFetchInto($qry, $row)) {
    400400
    401401        $labels[] = $row[0];
     
    621621    $qry = $db->query($sql);
    622622    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    623     $qry->fetchInto($row);
     623    dbFetchInto($qry, $row);
    624624
    625625    return $row[0];
     
    655655    $qry = $db->query($sql);
    656656    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    657     $qry->fetchInto($row);
     657    dbFetchInto($qry, $row);
    658658
    659659    return $row[0];
     
    673673    $qry = $db->query($sql);
    674674    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    675     $qry->fetchInto($row);
     675    dbFetchInto($qry, $row);
    676676
    677677    $pending = $row[0];
     
    730730    $dates = "";
    731731    $firstIn = true;
    732     while ($qry->fetchInto($row)) {
     732    while (dbFetchInto($qry, $row)) {
    733733
    734734        if ($firstIn) {
     
    887887    $qry = $db->query($sql);
    888888    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    889     $qry->fetchInto($row);
     889    dbFetchInto($qry, $row);
    890890
    891891    $alive = $row[0];
     
    906906    $qry = $db->query($sql);
    907907    if (dberror($qry)) {echo "<b>error with $sql </b><br>\n";}
    908     $qry->fetchInto($row);
     908    dbFetchInto($qry, $row);
    909909
    910910    return $row[0];
     
    947947    }
    948948    $res = $dbRepl->query('SHOW SLAVE STATUS');
    949     while ($res->fetchInto($row)) {
     949    while (dbFetchInto($res, $row)) {
    950950        # Have a look for Last_Errno in http://dev.mysql.com/doc/refman/5.0/en/show-slave-status.html
    951951        $errorStatusInMySql = $row[18];
  • trunk/ippMonitor/raw/diskUsage.php

    r29031 r39498  
    9090
    9191  // list the results
    92   while ($qry->fetchInto($row)) {
     92  while (dbFetchInto($qry, $row)) {
    9393    echo "<tr><td class=\"$class\"><b>$TABLE</b></td>\n";
    9494    // ** TABLE DATA **
  • trunk/ippMonitor/raw/getimage.php

    r37983 r39498  
    1717// load an image file from the image directory
    1818// validate request
    19 if ($_SERVER[REQUEST_METHOD] != 'GET') {
     19if ($_SERVER['REQUEST_METHOD'] != 'GET') {
    2020  exit ();
    2121}
     
    3737
    3838// $basename may contain filename@filerule
    39 $basename = $_GET[name];
     39$basename = $_GET['name'];
    4040if ($basename == "noimage.noimage") {
    4141  $file = fopen ("noimage.png", "r");//$MISSING?
     
    4747  exit ();
    4848}
    49 $filerule = $_GET[rule];
    50 $camera   = $_GET[camera];
    51 $class_id = $_GET[class_id];
     49$filerule = $_GET['rule'];
     50$camera   = $_GET['camera'];
     51$class_id = $_GET['class_id'];
    5252
    5353# $filerule = strtok("@");
  • trunk/ippMonitor/raw/histogram.php

    r28433 r39498  
    101101  menu_end();
    102102}
    103 if (!$qry->fetchInto($row)) {
     103if (!dbFetchInto($qry, $row)) {
    104104  echo "<b>error reading camRun, chipRun, rawExp, camProcessedExp table count</b><br>\n";
    105105  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    376376}
    377377// ** TAIL CODE **
    378 while ($qry->fetchInto($row)) {
     378while (dbFetchInto($qry, $row)) {
    379379  foreach ($keysToRowIndex as $i => $value) {
    380380    if (get_value_from_key($i, TRUE) == "on") {
  • trunk/ippMonitor/raw/ipp.php

    r38262 r39498  
    11<?php
    22
     3$debug = 0;
    34$dTABLE = 80;
    45include 'site.php';
     
    5051  echo "<table class=select>\n";
    5152  echo "<tr class=select><th class=select> projects </th></tr>\n";
    52   while ($qry->fetchInto($row)) {
     53  while (dbFetchInto($qry, $row)) {
    5354    // add a link here to set the database
    5455    $tmp_proj = $row[0];
     
    5657    echo "<tr class=select><td class=select><a class=\"menutop\" href=\"SelectProject.php?$tmp_link&proj=$tmp_proj&new=1\"> $row[0] </a></td></tr>\n";
    5758    // echo "<tr class=select><td class=select> $row[0] </td></tr>\n";
    58   }
     59  } 
    5960  echo "</table>\n";
    6061
    6162  menu_end ();
     63}
     64
     65function dbFetchInto ($qry, &$result) {
     66  global $DBI;
     67
     68  if ($DBI == "MDB2") {
     69    $result = $qry->fetchRow();
     70    if ($result == NULL) {
     71      $success = 0;
     72    } else {
     73      $success = 1;
     74    }
     75  }
     76  if ($DBI == "DB") {
     77    $success = $qry->fetchInto($result);
     78  }
     79  return $success;
    6280}
    6381
     
    87105
    88106  // 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  }
    89114  if ($DBI == "DB") {
    90     if ($database == $CZARDBNAME) {
    91         $db = DB::connect("mysql://$DBUSER:$DBPASS@$CZARDBHOST/$database");
    92     } else {
    93         $db = DB::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
    94     }
     115    $db = DB::connect($dsn);
    95116  }
    96117  if ($DBI == "MDB2") {
    97     $db = MDB2::connect("mysql://$DBUSER:$DBPASS@$DBHOST/$database");
     118    $db = MDB2::connect($dsn);
    98119  }
    99120
    100121  if (dberror($db)) {
    101122    echo "<b>error accessing database</b><br>\n";
    102     echo "<b>tried mysql://$DBUSER:XXX@$DBHOST/$database</b><br>\n";
     123    echo "<b>tried $dsnerr</b><br>\n";
    103124    $result = $db->getMessage();
    104125    echo "$result<br>";
     
    112133
    113134  if ($DBI == "MDB2") {
    114     $dberr = MDB2::isError($db);
     135    $dberr = PEAR::isError($db);
    115136  }
    116137  if ($DBI == "DB") {
     
    129150function checkLogin () {
    130151
    131   $username = $_POST[username];
    132   $password = $_POST[password];
     152  $username = $_POST['username'];
     153  $password = $_POST['password'];
    133154
    134155  // if password is not specified, keep username and ask again
     
    143164  // get the users from the DB
    144165  $sql = "SELECT username FROM users WHERE username = '$username' AND password = '$password'";
    145 
    146166  $qry = $db->query($sql);
     167
    147168  if (dberror($db)) {
    148169    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     
    152173    menu_end();
    153174  }
    154  
    155   $success = $qry->fetchInto($row);
     175
     176  $success = dbFetchInto($qry, $row);
    156177  if (!$success) { 
    157178    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     
    174195  }
    175196
    176   if ($qry->fetchInto($row)) {
     197  if (dbFetchInto($qry, $row)) {
    177198    $ID['pass'] = $row[1];
    178199  } else {
     
    197218
    198219function checkID () {
    199 
    200 
    201220  $VERBOSE = 0;
    202221  if ($VERBOSE > 1) {
     
    205224
    206225  // check for valid server method
    207   if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
     226  if (($_SERVER['REQUEST_METHOD'] != 'POST') && ($_SERVER['REQUEST_METHOD'] != 'GET')) {
    208227    menu ('ipp.menu.dat', 'Login', 'ipp.css', '', '');
    209228    echo "Invalid Client Request<br>\n";
     
    213232
    214233  // look for pass & proj in appropriate location
    215   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    216     $ID['pass'] = $_GET[pass];
    217     $ID['proj'] = $_GET[proj];
    218     $ID['menu'] = $_GET[menu];
    219     $ID['from'] = $_GET[from];
     234  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
     235    $ID['pass'] = array_key_exists('pass', $_GET) ? $_GET['pass'] : "";
     236    $ID['proj'] = array_key_exists('proj', $_GET) ? $_GET['proj'] : "";
     237    $ID['menu'] = array_key_exists('menu', $_GET) ? $_GET['menu'] : "";
     238    $ID['from'] = array_key_exists('from', $_GET) ? $_GET['from'] : "";
    220239
    221240    if ($VERBOSE) {
     
    227246    }
    228247  }
    229   if ($_SERVER[REQUEST_METHOD] == 'POST') {
    230     $ID['pass'] = $_POST[pass];
    231     $ID['proj'] = $_POST[proj];
    232     $ID['menu'] = $_POST[menu];
    233     $ID['from'] = $_POST[from];
     248  if ($_SERVER['REQUEST_METHOD'] == 'POST') {
     249    $ID['pass'] = array_key_exists('pass', $_POST) ? $_POST['pass'] : "";
     250    $ID['proj'] = array_key_exists('proj', $_POST) ? $_POST['proj'] : "";
     251    $ID['menu'] = array_key_exists('menu', $_POST) ? $_POST['menu'] : "";
     252    $ID['from'] = array_key_exists('from', $_POST) ? $_POST['from'] : "";
    234253
    235254    if ($VERBOSE) {
     
    264283  }
    265284 
    266   $success = $qry->fetchInto($row);
     285  $success = dbFetchInto($qry,$row);
    267286  if (! $success) {
    268287    menu('ipp.menu.dat', 'Login', 'ipp.css', '', '');
     
    359378    }
    360379       
    361     $thisname = $_SERVER[SCRIPT_NAME];
     380    $thisname = $_SERVER['SCRIPT_NAME'];
    362381    $page = "$root/" . $base;
    363382    if ($page == $thisname) {
     
    396415  $sortKey = "";
    397416  // try sort forward
    398   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    399     $sortVal = $_GET['sort'];
    400   } else {
    401     $sortVal = $_POST['sort'];
    402   }
     417  $sortVal = get_htmlkey_value ('sort');
    403418  if ($sortVal != "") {
    404419    $sortKey = "&sort=" . $sortVal;
     
    406421  // try sort reverse
    407422  if ($sortKey == "") {
    408     if ($_SERVER[REQUEST_METHOD] == 'GET') {
    409       $sortVal = $_GET['rsort'];
    410     } else {
    411       $sortVal = $_POST['rsort'];
    412     }
     423    $sortVal = get_htmlkey_value ('rsort');
    413424    if ($sortVal != "") {
    414425      $sortKey = "&rsort=" . $sortVal;
     
    473484  }
    474485
    475   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    476     $value = $_GET[$htmlkey];
    477   } else {
    478     $value = $_POST[$htmlkey];
     486  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
     487    $value = array_key_exists($htmlkey, $_GET) ? $_GET[$htmlkey] : "";
     488  } else {
     489    $value = array_key_exists($htmlkey, $_POST) ? $_POST[$htmlkey] : "";
    479490  }
    480491  if ($value == "") { return $where; }
     
    517528  }
    518529
    519   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    520     $value = $_GET['sort'];
    521   } else {
    522     $value = $_POST['sort'];
    523   }
     530  $value = get_htmlkey_value ('sort');
    524531  if ($value != "") {
    525532    $where = $where . " ORDER BY $value";
    526533    return $where;
    527534  }
    528   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    529     $value = $_GET['rsort'];
    530   } else {
    531     $value = $_POST['rsort'];
    532   }
     535  $value = get_htmlkey_value ('rsort');
    533536  if ($value != "") {
    534537    $where = $where . " ORDER BY $value DESC";
     
    538541}
    539542
     543function get_htmlkey_value ($htmlkey) {
     544  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
     545    $value = array_key_exists($htmlkey, $_GET) ? $_GET[$htmlkey] : "";
     546  } else {
     547    $value = array_key_exists($htmlkey, $_POST) ? $_POST[$htmlkey] : "";
     548  }
     549  return $value;
     550}
     551
    540552// if we have a restriction for a string-valued field, supply it to outgoing links
    541553function button_restrict_string ($key, $line) {
    542554  $htmlkey = preg_replace ('|\.|', '_', $key);
    543   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    544     $value = $_GET[$htmlkey];
    545   } else {
    546     $value = $_POST[$htmlkey];
    547   }
     555  $value = get_htmlkey_value ($htmlkey);
     556
    548557  # a search restriction may include an SQL wild-card.  we have to mangle these so that the http
    549558  # does not get converted to a special character
     
    563572  $htmlkey = preg_replace ('|\.|', '_', $key);
    564573  $htmlkey = $htmlkey . '_min';
    565   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    566     $value = $_GET[$htmlkey];
    567   } else {
    568     $value = $_POST[$htmlkey];
    569   }
     574  $value = get_htmlkey_value ($htmlkey);
    570575  if ($value != "") {
    571576    if ($line) {
     
    582587  $htmlkey = preg_replace ('|\.|', '_', $key);
    583588  $htmlkey = $htmlkey . '_max';
    584   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    585     $value = $_GET[$htmlkey];
    586   } else {
    587     $value = $_POST[$htmlkey];
    588   }
     589  $value = get_htmlkey_value ($htmlkey);
    589590  if ($value != "") {
    590591    if ($line) {
     
    600601function button_restrict_checkbox ($key, $line) {
    601602  $htmlkey = preg_replace ('|\.|', '_', $key);
    602   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    603     $value = $_GET[$htmlkey];
    604   } else {
    605     $value = $_POST[$htmlkey];
    606   }
     603  $value = get_htmlkey_value ($htmlkey);
    607604  if ($value != "") {
    608605    if ($line) {
     
    618615function button_restrict_radio ($key, $line) {
    619616  $htmlkey = preg_replace ('|\.|', '_', $key);
    620   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    621     $value = $_GET[$htmlkey];
    622   } else {
    623     $value = $_POST[$htmlkey];
    624   }
     617  $value = get_htmlkey_value ($htmlkey);
    625618  if ($value != "") {
    626619    if ($line) {
     
    648641  }
    649642
    650   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    651     $up   = $_GET['rsort'];
    652     $down = $_GET['sort'];
    653     $from = $_GET['from'];
    654   } else {
    655     $up   = $_POST['rsort'];
    656     $down = $_POST['sort'];
    657     $from = $_POST['from'];
     643  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
     644    $up   = array_key_exists('rsort', $_GET) ? $_GET['rsort'] : "";
     645    $down = array_key_exists('sort',  $_GET) ? $_GET['sort'] : "";
     646    $from = array_key_exists('from',  $_GET) ? $_GET['from'] : "";
     647  } else {
     648    $up   = array_key_exists('rsort', $_POST) ? $_POST['rsort'] : "";
     649    $down = array_key_exists('sort',  $_POST) ? $_POST['sort'] : "";
     650    $from = array_key_exists('from',  $_POST) ? $_POST['from'] : "";
    658651  }
    659652
     
    695688    $htmlkey = $htmlkey . "_max";
    696689  }
    697   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    698     $value = $_GET[$htmlkey];
    699   } else {
    700     $value = $_POST[$htmlkey];
    701   }
     690  $value = get_htmlkey_value ($htmlkey);
    702691
    703692  // full table element includes optionally the <= or >= words
     
    714703function write_query_checkbox ($key, $comment) {
    715704  $htmlkey = preg_replace ('|\.|', '_', $key);
    716 
    717   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    718     $value = $_GET[$htmlkey];
    719   } else {
    720     $value = $_POST[$htmlkey];
    721   }
     705  $value = get_htmlkey_value ($htmlkey);
     706
    722707  echo "<td> <input type=\"checkbox\" name=\"$htmlkey\"";
    723708  if ($value == "on") {
     
    734719  $htmlvalue = preg_replace ('|\.|', '_', $value);
    735720
    736   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    737     $value = $_GET[$htmlkey];
    738   } else {
    739     $value = $_POST[$htmlkey];
    740   }
     721  $value = get_htmlkey_value ($htmlkey);
    741722  if ($htmlvalue == get_value_from_key($htmlkey, TRUE)) {
    742723    $checked = "checked";
     
    779760function insert_image ($rule, $size) {
    780761
    781   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    782     $basename = $_GET['basename'];
    783     $class_id = $_GET['class'];
    784     $camera   = $_GET['camera'];
    785   } else {
    786     $basename = $_POST['basename'];
    787     $class_id = $_POST['class'];
    788     $camera   = $_POST['camera'];
     762  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
     763    $basename = array_key_exists('basename', $_GET) ? $_GET['basename'] : "";
     764    $class_id = array_key_exists('class',    $_GET) ? $_GET['class']    : "";
     765    $camera   = array_key_exists('camera',   $_GET) ? $_GET['camera']   : "";
     766  } else {
     767    $basename = array_key_exists('basename', $_POST) ? $_POST['basename'] : "";
     768    $class_id = array_key_exists('class',    $_POST) ? $_POST['class']    : "";
     769    $camera   = array_key_exists('camera',   $_POST) ? $_POST['camera']   : "";
    789770  }
    790771
     
    802783function insert_log ($filerule) {
    803784
    804   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    805     $basename = $_GET['basename'];
    806     $class_id = $_GET['class'];
    807     $camera   = $_GET['camera'];
    808     $state    = $_GET['state'];
    809   } else {
    810     $basename = $_POST['basename'];
    811     $class_id = $_POST['class'];
    812     $camera   = $_POST['camera'];
    813     $state    = $_POST['state'];
     785  if ($_SERVER['REQUEST_METHOD'] == 'GET') {
     786    $basename = array_key_exists('basename', $_GET) ? $_GET['basename'] : "";
     787    $class_id = array_key_exists('class',    $_GET) ? $_GET['class']    : "";
     788    $camera   = array_key_exists('camera',   $_GET) ? $_GET['camera']   : "";
     789    $state    = array_key_exists('state',    $_GET) ? $_GET['state']    : "";
     790  } else {
     791    $basename = array_key_exists('basename', $_POST) ? $_POST['basename'] : "";
     792    $class_id = array_key_exists('class',    $_POST) ? $_POST['class']    : "";
     793    $camera   = array_key_exists('camera',   $_POST) ? $_POST['camera']   : "";
     794    $state    = array_key_exists('state',    $_POST) ? $_POST['state']    : "";
    814795  }
    815796
     
    830811  //It's necessary for staticsky logs and it would require to join tables
    831812  //back to the warpRun table
    832   if (! $camera) { $camera = strtoupper($_GET['proj']); }
     813  if (! $camera) {
     814    $camera = strtoupper($_GET['proj']);
     815  }
    833816
    834817  if ($basename && $camera && $filerule) {
     
    886869function insert_backref ($page, $key, $link) {
    887870
    888   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    889     $name = $_GET[$key];
    890   } else {
    891     $name = $_POST[$key];
    892   }
     871  $name = get_htmlkey_value ($key);
    893872
    894873  if ($name) {
     
    911890    $htmlkey = $key;
    912891  }
    913   if ($_SERVER[REQUEST_METHOD] == 'GET') {
    914     return $_GET[$htmlkey];
    915   } else {
    916     return $_POST[$htmlkey];
    917   }
     892  $value = get_htmlkey_value ($key);
     893  return $value;
    918894}
    919895
  • trunk/ippMonitor/raw/masterDetrendImfiles.php

    r21137 r39498  
    5353
    5454// list the results
    55 while ($qry->fetchInto($row)) {
     55while (dbFetchInto($qry, $row)) {
    5656  // $link = "masterDetrendImfiles.php" . "?expID=" . $row[0] . "&" . $ID['link'];
    5757
  • trunk/ippMonitor/raw/nightSummary.php

    r33846 r39498  
    2525
    2626  // list the results
    27   while ($qry->fetchInto($row)) {
     27  while (dbFetchInto($qry, $row)) {
    2828    echo "<tr><td class=\"$class\"><b>$TABLE</b></td>\n";
    2929    // ** TABLE DATA **
  • trunk/ippMonitor/raw/simplePlot.php

    r31102 r39498  
    8181  menu_end();
    8282}
    83 if (!$qry->fetchInto($row)) {
     83if (!dbFetchInto($qry, $row)) {
    8484  echo "<b>error reading chipRun, rawExp table count</b><br>\n";
    8585  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    238238
    239239// list the results
    240 while ($qry->fetchInto($row)) {
     240while (dbFetchInto($qry, $row)) {
    241241  switch ($row[2]) {
    242242   case 'g.00000':
  • trunk/ippMonitor/raw/simplePlotcam.php

    r34431 r39498  
    8484  menu_end();
    8585}
    86 if (!$qry->fetchInto($row)) {
     86if (!dbFetchInto($qry, $row)) {
    8787  echo "<b>error reading camProcessedExp, camRun, chipRun, rawExp table count</b><br>\n";
    8888  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    246246
    247247// list the results
    248 while ($qry->fetchInto($row)) {
     248while (dbFetchInto($qry, $row)) {
    249249  switch ($row[2]) {
    250250   case 'g.00000':
  • trunk/ippMonitor/raw/simplePlotraw.php

    r31102 r39498  
    7575  menu_end();
    7676}
    77 if (!$qry->fetchInto($row)) {
     77if (!dbFetchInto($qry, $row)) {
    7878  echo "<b>error reading rawExp table count</b><br>\n";
    7979  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    218218
    219219// list the results
    220 while ($qry->fetchInto($row)) {
     220while (dbFetchInto($qry, $row)) {
    221221  switch ($row[2]) {
    222222   case 'g.00000':
  • trunk/ippMonitor/raw/warpProcessedExp.php

    r32367 r39498  
    9999  menu_end();
    100100}
    101 if (!$qry->fetchInto($row)) {
     101if (!dbFetchInto($qry, $row)) {
    102102  echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table count</b><br>\n";
    103103  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    295295
    296296// list the results
    297 while ($qry->fetchInto($row)) {
     297while (dbFetchInto($qry, $row)) {
    298298  // $link = "warpProcessedExp.php" . "?expID=" . $row[0] . "&" . $ID['link'];
    299299
  • trunk/ippMonitor/raw/warpProcessedExp_Images.php

    r32366 r39498  
    9191  menu_end();
    9292}
    93 if (!$qry->fetchInto($row)) {
     93if (!dbFetchInto($qry, $row)) {
    9494  echo "<b>error reading warpRun, fakeRun, camRun, chipRun, rawExp, warpSummary table count</b><br>\n";
    9595  echo "<br><small><b> count query : $sql </b></small><br>\n";
     
    307307
    308308// list the results
    309 while ($qry->fetchInto($row)) {
     309while (dbFetchInto($qry, $row)) {
    310310  // $link = "warpProcessedExp_Images.php" . "?expID=" . $row[0] . "&" . $ID['link'];
    311311
Note: See TracChangeset for help on using the changeset viewer.