IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 9016


Ignore:
Timestamp:
Sep 27, 2006, 4:57:39 PM (20 years ago)
Author:
eugene
Message:

adding login, cookie tables, database selection

Location:
trunk/ippMonitor
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/ippMonitor/def/autocode.php

    r9011 r9016  
    44
    55$ID = checkID ();
     6if ($ID['proj']) {
     7  $db = dbconnect($ID['proj']);
     8} else {
     9  $db = dbconnect('detrend');
     10}
    611
    712if ($ID['menu']) {
     
    1419
    1520echo "<p> $TITLE </p>";
    16 
    17 $db = dbconnect();
    1821
    1922// define restrictiosn to the queries
  • trunk/ippMonitor/def/detInputExp.d

    r9011 r9016  
    44MENU  ipp.detrend.dat
    55
    6 HEAD HTML  test head 1 <br>
    7 HEAD HTML  test head 2 <br>
    8 HEAD HTML  test head 3 <br>
     6# HEAD HTML  test head 1 <br>
    97
    108#     field      width  name        show  link to                 extras
     
    1513FIELD include,   7,     include
    1614
    17 TAIL HTML test tail 1 <br>
    18 TAIL HTML test tail 2 <br>
    19 TAIL HTML test tail 3 <br>
     15# TAIL HTML  test tail 1 <br>
  • trunk/ippMonitor/raw/SelectProject.php

    r8984 r9016  
    33include 'ipp.php';
    44
    5 checkID ();
     5if (($_SERVER[REQUEST_METHOD] != 'POST') && ($_SERVER[REQUEST_METHOD] != 'GET')) {
     6  menu ('ipp.menu.dat', 'Select Project', 'ipp.css', '');
     7  echo "Invalid Client Request<br>\n";
     8  menu_end ();
     9  exit ();
     10}
     11
     12$ID = checkID ();
    613
    714if ($_SERVER[REQUEST_METHOD] == 'GET') {
    8     menu ('ipp.menu.dat', 'Project', 'ipp.css', '');
     15    menu ('ipp.menu.dat', 'Select Project', 'ipp.css', '');
    916    echo "<p> Select the project of interest </p>\n";
    1017    echo "<form action=\"$myPage\" method=\"POST\">\n";
    1118    echo "Project: <input type=\"text\" name=\"proj\"><br>\n";
    1219    echo "<input type=\"submit\" name=\"project\">\n";
     20
     21    $pass = $ID['pass'];
     22    echo "<input type=\"hidden\" name=\"pass\" value=\"$pass\">\n";
    1323    echo "</form>\n";
    1424
     
    1626}
    1727
    18 if ($_SERVER[REQUEST_METHOD] != 'POST') {
    19   menu ('ipp.menu.dat', 'Project', 'ipp.css', '');
    20   echo "Invalid Client Request<br>\n";
    21   menu_end ();
     28if ($_SERVER[REQUEST_METHOD] == 'POST') {
     29
     30  if (key_exists (project, $_POST)) {
     31    $myProj = $_POST[proj];
     32    $ID['proj'] = $myProj;
     33    // validate the existence of the project
     34
     35    // update ID['link']
     36    // $link is attached to every nav link
     37    $ID['link'] = "pass=" . $ID['pass'];
     38    if ($ID['proj']) {
     39      $ID['link'] = $ID['link'] . "&proj=" . $ID['proj'];
     40    }
     41
     42    menu ('ipp.menu.dat', 'Select Project', 'ipp.css', $ID['link']);
     43    echo "New project is : $myProj<br>\n";
     44
     45    echo "ID list<br>\n";
     46    foreach ($ID as $key => $value) {
     47      echo "$key : $value<br>\n";
     48    }
     49
     50    menu_end();
     51  }
    2252}
    23 
    24 if (key_exists (project, $_POST)) {
    25   $myProj = $_POST[proj];
    26   # validate the existence of the project
    27   $_GET[proj] = $myProj;
    28   menu ('ipp.menu.dat', 'Project', 'ipp.css', '');
    29   echo "New project is : $myProj\n";
    30   menu_end();
    31 }
    32  
    33 menu ('ipp.menu.dat', 'Project', 'ipp.css', '');
    34 echo "Invalid Client Post Request<br>\n";
    35 foreach ($_POST as $key => $value) {
    36   echo "$key : $value<br>\n";
    37 }
    38 menu_end ();
    39 
    4053?>
  • trunk/ippMonitor/raw/ipp.detrend.dat

    r9011 r9016  
    2424menutop   | menutop      | plain   | &nbsp;                       |
    2525menulink  | menuselect   | link    | Master Detrend Frames        | masterDetrendFrames.php
     26menulink  | menuselect   | link    | Master Detrend Imfiles       | masterDetrendImfiles.php
    2627menulink  | menuselect   | link    | Detrend Runs                 | detRunSummary.php             
     28menulink  | menuselect   | link    | Raw Detrend Exp              | rawDetrendExp.php
    2729menulink  | menuselect   | link    | Input Detrend Exp            | detInputExp.php                   
    2830menulink  | menuselect   | link    | Resid Detrend Exp            | detResidExp.php                       
  • trunk/ippMonitor/raw/ipp.php

    r9009 r9016  
    1515}
    1616
    17 function dbconnect () {
     17function dbconnect ($database) {
    1818
    1919  // connect to the database
    2020  require_once('DB.php');
    21   // $db = DB::connect("mysql://ipp:ipp@localhost/ipp");
    22   $db = DB::connect("mysql://ipp:ipp@localhost/detrend");
     21  $db = DB::connect("mysql://ipp:ipp@alala/$database");
    2322  if (DB::iserror($db)) {
    2423    echo "<b>error accessing database</b><br>\n";
     
    4039  $password = $_POST[password];
    4140
     41  $db = dbconnect('ippadmin');
     42
    4243  // make this a DB lookup
    43   $success = (($username == "eugene") && ($password == "test"));
    44 
     44  $sql = "SELECT username FROM users WHERE username = '$username' AND password = '$password'";
     45
     46  $qry = $db->query($sql);
     47  if (DB::iserror($db)) {
     48    echo "<b>error reading users table</b><br>\n";
     49    echo "Login Failed, please try again<br>\n";
     50    loginform ();
     51    menu_end();
     52  }
     53 
     54  $success = $qry->fetchInto($row);
    4555  if (!$success) { 
    4656    menu ('ipp.menu.dat', 'Login', 'ipp.css', '');
     
    5363  // generate an random ephemeral ID
    5464  $ID['name'] = $username;
    55   $ID['pass'] = "foobar";
    5665  $ID['proj'] = "";
     66
     67  // generate a cookie for the user
     68  $sql = "SELECT username,cookie FROM cookies WHERE username = '$username'";
     69  $qry = $db->query($sql);
     70  if (DB::iserror($db)) {
     71    echo "Cookie Failed, please try again<br>\n";
     72    menu_end();
     73  }
     74
     75  if ($qry->fetchInto($row)) {
     76    $ID['pass'] = $row[1];
     77  } else {
     78    $cookie = rand(0,100000);
     79    $ID['pass'] = $cookie;
     80    $sql = "INSERT into cookies (username, cookie) values ('$username', '$cookie')";
     81    $qry = $db->query($sql);
     82    if (DB::iserror($db)) {
     83      echo "Cookie Failed, please try again<br>\n";
     84      menu_end();
     85    }
     86  }
    5787
    5888  // the link is attached to every nav link
     
    107137  }
    108138
    109   // user supplied an invalid pass
    110   if ($ID['pass'] != "foobar") {
     139  $db = dbconnect ('ippadmin');
     140
     141  // make this a DB lookup
     142  $pass = $ID['pass'];
     143  $sql = "SELECT username FROM cookies WHERE cookie = '$pass'";
     144  $qry = $db->query($sql);
     145  if (DB::iserror($db)) {
     146    echo "<b>error reading users table</b><br>\n";
     147    echo "Login Failed, please try again<br>\n";
     148    loginform ();
     149    menu_end();
     150  }
     151 
     152  # $success = (($username == "eugene") && ($password == "test"));
     153  $success = $qry->fetchInto($row);
     154  if (! $success) {
    111155    menu('ipp.menu.dat', 'Login', 'ipp.css', '');
    112156    echo "unknown user, please login again<br>\n";
     
    114158    menu_end ();
    115159  }
    116 
    117160  // use the pass value to find the corresponding user
    118   $ID['name'] = "eugene";
     161  $ID['name'] = $row[0];
    119162
    120163  // $link is attached to every nav link
    121164  $ID['link'] = "pass=" . $ID['pass'];
    122165  if ($ID['proj']) {
    123     $ID['link'] = $link . "&proj=" . $ID['proj'];
    124   }
    125 
     166    $ID['link'] = $ID['link'] . "&proj=" . $ID['proj'];
     167  }
     168 
    126169  return $ID;
    127170}
Note: See TracChangeset for help on using the changeset viewer.