Esempio n. 1
0
function confirmDeleteDoc()
{
    global $viewmode;
    $item = getContinuationVar('item');
    if ($viewmode != ADMIN_DEVELOPER && !in_array($user['id'], $doceditors)) {
        showDatabaseDoc($item);
        return;
    }
    $query = "SELECT title, data FROM documentation WHERE name = '{$item}'";
    $qh = doQuery($query, 101);
    if (!($row = mysql_fetch_assoc($qh))) {
        print "<h2>Online Documentation</h2>\n";
        print "Failed to retrieve documentation for \"{$item}\".<br>\n";
        return;
    }
    print "Are you sure you want to delete the following documentation ";
    print "page?<br>\n";
    print "<font color=red>Note: the document will be unrecoverable</font>";
    print "<br>\n";
    print "<table>\n";
    print "<tr><td>\n";
    print "<form action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cdata = array('item' => $item);
    $cont = addContinuationsEntry('submitdeletedoc', $cdata, SECINDAY, 0, 0);
    print "<input type=hidden name=continuation value={$cont}>\n";
    print "<input type=submit value=\"Delete Page\">\n";
    print "</form>\n";
    print "</td><td>\n";
    print "<form action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cont = addContinuationsEntry('viewdocs', $cdata);
    print "<input type=hidden name=continuation value={$cont}>\n";
    print "<input type=submit value=\"View Page\">\n";
    print "</form>\n";
    print "</td></tr>\n";
    print "</table>\n";
    print "<h2>{$row['title']}</h2>\n";
    print $row['data'];
}
Esempio n. 2
0
function AJsetImageProduction()
{
    $requestid = getContinuationVar('requestid');
    $data = getRequestInfo($requestid);
    foreach ($data["reservations"] as $res) {
        if ($res["forcheckout"]) {
            $prettyimage = $res["prettyimage"];
            break;
        }
    }
    $title = "<big><strong>" . i("Change Test Image to Production") . "</strong></big><br><br>\n";
    $text = sprintf(i("This will update %s so that new reservations for it will be for the newly created revision. Are you sure it works correctly and is ready to be made the production revision?"), "<b>{$prettyimage}</b>") . "<br>\n";
    $cdata = array('requestid' => $requestid);
    $cont = addContinuationsEntry('AJsubmitSetImageProduction', $cdata, SECINDAY, 0, 0);
    $text = preg_replace("/(.{1,60}[ \n])/", '\\1<br>', $text);
    $data = array('content' => $title . $text, 'cont' => $cont, 'btntxt' => i('Make Production'));
    sendJSON($data);
}
Esempio n. 3
0
function viewMgmtnodeMapping($mngroups = 0)
{
    global $mode;
    if (!is_array($mngroups)) {
        $tmp = getUserResources(array("mgmtNodeAdmin"), array("manageGroup"), 1);
        $mngroups = $tmp["managementnode"];
    }
    $mapping = getResourceMapping("managementnode", "computer");
    $resources2 = getUserResources(array("computerAdmin"), array("manageGroup"), 1);
    $compgroups = $resources2["computer"];
    uasort($compgroups, "sortKeepIndex");
    if (count($mngroups) && count($compgroups)) {
        print "<H2>Management Node Group to Computer Group Mapping</H2>\n";
        if ($mode == "submitMgmtnodeMapping") {
            print "<font color=\"#008000\">Management node group to computer ";
            print "group mapping successfully updated";
            print "</font><br><br>\n";
        }
        print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
        print "<TABLE border=1>\n";
        print "  <col>\n";
        foreach (array_keys($compgroups) as $id) {
            print "  <col id=compgrp{$id}>\n";
        }
        print "  <TR>\n";
        print "    <TH rowspan=2>Management Node Group</TH>\n";
        print "    <TH class=nohlcol colspan=" . count($compgroups) . ">Computer Groups</TH>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        foreach ($compgroups as $id => $group) {
            print "    <TH onclick=\"toggleColSelect('compgrp{$id}');\">{$group}</TH>\n";
        }
        print "  </TR>\n";
        $count = 1;
        foreach ($mngroups as $mnid => $mnname) {
            if ($count % 12 == 0) {
                print "  <TR>\n";
                print "    <TH><img src=images/blank.gif></TH>\n";
                foreach ($compgroups as $id => $group) {
                    print "    <TH onclick=\"toggleColSelect('compgrp{$id}');\">{$group}</TH>\n";
                }
                print "  </TR>\n";
            }
            print "  <TR id=mngrpid{$mnid}>\n";
            print "    <TH align=right onclick=\"toggleRowSelect('mngrpid{$mnid}');\">{$mnname}</TH>\n";
            foreach ($compgroups as $compid => $compname) {
                $name = "mapping[" . $mnid . ":" . $compid . "]";
                if (array_key_exists($mnid, $mapping) && in_array($compid, $mapping[$mnid])) {
                    $checked = "checked";
                } else {
                    $checked = "";
                }
                print "    <TD align=center>\n";
                print "      <INPUT type=checkbox name=\"{$name}\" {$checked}>\n";
                print "    </TD>\n";
            }
            print "  </TR>\n";
            $count++;
        }
        print "</TABLE>\n";
        $cont = addContinuationsEntry('submitMgmtnodeMapping', array(), SECINDAY, 1, 0);
        print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
        print "<INPUT type=submit value=\"Submit Changes\">\n";
        print "<INPUT type=reset value=Reset>\n";
        print "</FORM>\n";
    }
}
Esempio n. 4
0
 function AJcompScheduleChange()
 {
     $schid = processInputVar('schid', ARG_NUMERIC);
     $resources = getUserResources(array("scheduleAdmin"), array("manageGroup"));
     if (!array_key_exists($schid, $resources['schedule'])) {
         $ret = array('status' => 'error', 'errormsg' => 'You do not have access to the selected schedule.');
         sendJSON($ret);
         return;
     }
     $compids = $this->validateCompIDs();
     if (array_key_exists('error', $compids)) {
         $ret = array('status' => 'error', 'errormsg' => $compids['msg']);
         sendJSON($ret);
         return;
     }
     if (count($compids) == 0) {
         $ret = array('status' => 'noaction');
         sendJSON($ret);
         return;
     }
     $tmp = getUserResources(array($this->restype . "Admin"), array("administer"), 0, 1);
     $computers = $tmp['computer'];
     $msg = "Change the schedule of the following computers to ";
     $msg .= "<strong>{$resources['schedule'][$schid]}</strong>?<br><br>\n";
     $complist = '';
     foreach ($compids as $compid) {
         $complist .= $computers[$compid] . "<br>\n";
     }
     $complist .= "<br>\n";
     $cdata = $this->basecdata;
     $cdata['compids'] = $compids;
     $cdata['schid'] = $schid;
     $cdata['schname'] = $resources['schedule'][$schid];
     $cdata['complist'] = $complist;
     $cont = addContinuationsEntry('AJsubmitCompScheduleChange', $cdata, SECINDAY, 1, 0);
     $ret = array('status' => 'success', 'title' => "Schedule Change", 'btntxt' => 'Submit Schedule Change', 'cont' => $cont, 'actionmsg' => $msg, 'complist' => $complist);
     sendJSON($ret);
 }
Esempio n. 5
0
function viewStatistics()
{
    global $submitErr, $submitErrMsg, $user;
    define("30MIN", 1800);
    define("1HOUR", 3600);
    define("2HOURS", 7200);
    define("4HOURS", 14400);
    $month1 = processInputVar("month1", ARG_NUMERIC);
    $day1 = processInputVar("day1", ARG_NUMERIC);
    $year1 = processInputVar("year1", ARG_NUMERIC);
    $month2 = processInputVar("month2", ARG_NUMERIC);
    $day2 = processInputVar("day2", ARG_NUMERIC);
    $year2 = processInputVar("year2", ARG_NUMERIC);
    $affilid = processInputVar("affilid", ARG_NUMERIC, $user['affiliationid']);
    $mode2 = getContinuationVar('mode', 'default');
    $provid = processInputVar('provid', ARG_NUMERIC, 0);
    if ($mode2 == 'provisioning') {
        $affilid = 0;
        $provs = getContinuationVar('provs');
        if (!array_key_exists($provid, $provs)) {
            $ids = array_keys($provs);
            $provid = $ids[0];
        }
    } else {
        $provid = 0;
    }
    $affils = getAffiliations();
    if (!checkUserHasPerm('View Statistics by Affiliation') || $affilid != 0 && !array_key_exists($affilid, $affils)) {
        $affilid = $user['affiliationid'];
    }
    if ($affilid == 0) {
        $statsfor = i("All Affiliations");
    } else {
        $statsfor = $affils[$affilid];
    }
    $start = "{$year1}-{$month1}-{$day1} 00:00:00";
    $end = "{$year2}-{$month2}-{$day2} 23:59:59";
    if (!checkdate($month1, $day1, $year1)) {
        $submitErr |= STARTERR;
        $submitErrMsg[STARTERR] = i("The selected start date is not valid. Please select a valid date.") . "<br>\n";
    }
    if (!checkdate($month2, $day2, $year2)) {
        $submitErr |= ENDERR;
        $submitErrMsg[ENDERR] = i("The selected end date is not valid. Please select a valid date.") . "<br>\n";
    }
    if (datetimeToUnix($start) > datetimeToUnix($end)) {
        $submitErr |= ORDERERR;
        $submitErrMsg[ORDERERR] = i("The selected end date is before the selected start date. Please select an end date equal to or greater than the start date.") . "<br>\n";
    }
    if ($submitErr) {
        selectStatistics();
        return;
    }
    $timestart = microtime(1);
    if ($mode2 == 'default') {
        print "<H2>" . i("Statistic Information for") . " {$statsfor}</H2>\n";
    } elseif ($mode2 == 'provisioning') {
        print "<H2>" . i("Statistic Information for") . " {$provs[$provid]}</H2>\n";
    }
    print "<H3>";
    $tmp = mktime(0, 0, 0, $month1, $day1, $year1);
    $starttime = strftime('%x', $tmp);
    $tmp = mktime(0, 0, 0, $month2, $day2, $year2);
    $endtime = strftime('%x', $tmp);
    printf(i("Reservation information between %s and %s:"), $starttime, $endtime);
    print "</H3>\n";
    $reloadid = getUserlistID('vclreload@Local');
    if ($mode2 == 'default') {
        $query = "SELECT l.userid, " . "u.affiliationid, " . "l.nowfuture, " . "UNIX_TIMESTAMP(l.start) AS start, " . "(UNIX_TIMESTAMP(l.loaded) - UNIX_TIMESTAMP(l.start)) AS loadtime, " . "UNIX_TIMESTAMP(l.finalend) AS finalend, " . "l.wasavailable, " . "l.ending, " . "i.prettyname, " . "o.prettyname AS OS " . "FROM log l, " . "image i, " . "user u, " . "OS o " . "WHERE l.start >= '{$start}' AND " . "l.finalend <= '{$end}' AND " . "i.id = l.imageid AND " . "i.OSid = o.id AND " . "l.userid != {$reloadid} AND ";
    } elseif ($mode2 == 'provisioning') {
        $query = "SELECT l.userid, " . "u.affiliationid, " . "l.nowfuture, " . "UNIX_TIMESTAMP(l.start) AS start, " . "(UNIX_TIMESTAMP(l.loaded) - UNIX_TIMESTAMP(l.start)) AS loadtime, " . "UNIX_TIMESTAMP(l.finalend) AS finalend, " . "l.wasavailable, " . "l.ending, " . "i.prettyname, " . "o.prettyname AS OS " . "FROM image i, " . "user u, " . "OS o, " . "log l " . "JOIN (" . "SELECT s.logid, " . "MIN(s.computerid) AS computerid " . "FROM sublog s, " . "computer c " . "WHERE s.computerid = c.id AND " . "c.provisioningid = {$provid} " . "GROUP BY logid " . ") AS s ON (s.logid = l.id) " . "WHERE l.start >= '{$start}' AND " . "l.finalend <= '{$end}' AND " . "i.id = l.imageid AND " . "i.OSid = o.id AND " . "l.userid != {$reloadid} AND ";
    }
    if ($affilid != 0) {
        $query .= "u.affiliationid = {$affilid} AND ";
    }
    $query .= "l.userid = u.id " . "ORDER BY i.prettyname";
    $qh = doQuery($query, 275);
    $totalreservations = 0;
    $users = array();
    $nows = 0;
    $futures = 0;
    $notavailable = 0;
    $loadtimes = array("2less" => 0, "2to6" => 0, "6to8" => 0, "8more" => 0);
    $ending = array("deleted" => 0, "released" => 0, "failed" => 0, "noack" => 0, "nologin" => 0, "timeout" => 0, "EOR" => 0, "none" => 0);
    $imagecount = array();
    $imageusers = array();
    $imagehours = array();
    $imageload2less = array();
    $imageload2to6 = array();
    $imageload6to8 = array();
    $imageload8more = array();
    $imagefails = array();
    $lengths = array("30min" => 0, "1hour" => 0, "2hours" => 0, "4hours" => 0, "6hours" => 0, "8hours" => 0, "10hours" => 0, "10hrsplus" => 0);
    $totalhours = 0;
    $osusers = array();
    while ($row = mysql_fetch_assoc($qh)) {
        if (!array_key_exists($row["prettyname"], $imageload2less)) {
            $imageload2less[$row["prettyname"]] = 0;
        }
        if (!array_key_exists($row["prettyname"], $imageload2to6)) {
            $imageload2to6[$row["prettyname"]] = 0;
        }
        if (!array_key_exists($row["prettyname"], $imageload6to8)) {
            $imageload6to8[$row["prettyname"]] = 0;
        }
        if (!array_key_exists($row["prettyname"], $imageload8more)) {
            $imageload8more[$row["prettyname"]] = 0;
        }
        # notavailable
        if ($row["wasavailable"] == 0) {
            $notavailable++;
        } else {
            $totalreservations++;
            # load times
            if ($row['loadtime'] <= 120) {
                $loadtimes['2less']++;
                # imageload2less
                $imageload2less[$row['prettyname']]++;
            } elseif ($row['loadtime'] > 120 && $row['loadtime'] <= 360) {
                $loadtimes['2to6']++;
                $imageload2to6[$row['prettyname']]++;
            } elseif ($row['loadtime'] > 360 && $row['loadtime'] <= 480) {
                $loadtimes['6to8']++;
                $imageload6to8[$row['prettyname']]++;
            } else {
                $loadtimes['8more']++;
                $imageload8more[$row['prettyname']]++;
            }
        }
        # users
        $users[$row['userid']] = 1;
        # nowfuture
        if ($row["nowfuture"] == "now") {
            $nows++;
        } else {
            $futures++;
        }
        # ending
        $ending[$row["ending"]]++;
        # imagecount
        if (!array_key_exists($row["prettyname"], $imagecount)) {
            $imagecount[$row["prettyname"]] = 0;
        }
        $imagecount[$row["prettyname"]]++;
        # imageusers
        if (!array_key_exists($row["prettyname"], $imageusers)) {
            $imageusers[$row["prettyname"]] = array();
        }
        $imageusers[$row['prettyname']][$row['userid']] = 1;
        # lengths
        $length = $row["finalend"] - $row["start"];
        if ($length < 0) {
            $length = 0;
        }
        if ($length <= 1800) {
            $lengths["30min"]++;
        } elseif ($length <= 3600) {
            $lengths["1hour"]++;
        } elseif ($length <= 7200) {
            $lengths["2hours"]++;
        } elseif ($length <= 14400) {
            $lengths["4hours"]++;
        } elseif ($length <= 21600) {
            $lengths["6hours"]++;
        } elseif ($length <= 28800) {
            $lengths["8hours"]++;
        } elseif ($length <= 36000) {
            $lengths["10hours"]++;
        } else {
            $lengths["10hrsplus"]++;
        }
        # imagehours
        if (!array_key_exists($row["prettyname"], $imagehours)) {
            $imagehours[$row["prettyname"]] = 0;
        }
        $imagehours[$row["prettyname"]] += $length / 3600;
        # imagefails
        if (!array_key_exists($row["prettyname"], $imagefails)) {
            $imagefails[$row["prettyname"]] = 0;
        }
        if ($row['ending'] == 'failed') {
            $imagefails[$row["prettyname"]] += 1;
        }
        # total hours
        $totalhours += $length;
        # osusers
        if (!array_key_exists($row["OS"], $osusers)) {
            $osusers[$row["OS"]] = array();
        }
        $osusers[$row['OS']][$row['userid']] = 1;
    }
    print "<DIV align=center>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Total Reservations:") . "</TH>\n";
    print "    <TD>{$totalreservations}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Total Hours Used:") . "</TH>\n";
    print "    <TD>" . (int) ($totalhours / 3600) . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("\"Now\" Reservations:") . "</TH>\n";
    print "    <TD>{$nows}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("\"Later\" Reservations:") . "</TH>\n";
    print "    <TD>{$futures}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Unavailable:") . "</TH>\n";
    print "    <TD>{$notavailable}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Load times &lt; 2 minutes:") . "</TH>\n";
    print "    <TD>{$loadtimes['2less']}</TD>\n";
    print "  </TR>\n";
    print "    <TH align=right>" . i("Load times 2-6 minutes:") . "</TH>\n";
    print "    <TD>{$loadtimes['2to6']}</TD>\n";
    print "  </TR>\n";
    print "    <TH align=right>" . i("Load times 6-8 minutes:") . "</TH>\n";
    print "    <TD>{$loadtimes['6to8']}</TD>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Load times &gt;= 8 minutes:") . "</TH>\n";
    print "    <TD>{$loadtimes['8more']}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Total Unique Users:") . "</TH>\n";
    print "    <TD>" . count($users) . "</TD>\n";
    print "  </TR>\n";
    foreach (array_keys($osusers) as $key) {
        print "  <TR>\n";
        print "    <TH align=right>";
        printf(i("Unique Users of %s:"), $key);
        print "</TH>\n";
        print "    <TD>" . count($osusers[$key]) . "</TD>\n";
        print "  </TR>\n";
    }
    print "</TABLE>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TD></TD>\n";
    print "    <TH>" . i("Reservations") . "</TH>\n";
    print "    <TH>" . i("Unique Users") . "</TH>\n";
    print "    <TH>" . i("Hours Used") . "</TH>\n";
    print "    <TH>" . i("&lt; 2 min wait") . "</TH>\n";
    print "    <TH>" . i("2-6 min wait") . "</TH>\n";
    print "    <TH>" . i("6-8 min wait") . "</TH>\n";
    print "    <TH>" . i("&gt;= 8 min wait") . "</TH>\n";
    print "    <TH>" . i("Failures") . "</TH>\n";
    print "  </TR>\n";
    foreach ($imagecount as $key => $value) {
        print "  <TR>\n";
        print "    <TH align=right>{$key}:</TH>\n";
        print "    <TD align=center>{$value}</TD>\n";
        print "    <TD align=center>" . count($imageusers[$key]) . "</TD>\n";
        if ((int) $imagehours[$key] == 0) {
            print "    <TD align=center>1</TD>\n";
        } else {
            print "    <TD align=center>" . (int) $imagehours[$key] . "</TD>\n";
        }
        print "    <TD align=center>{$imageload2less[$key]}</TD>\n";
        print "    <TD align=center>{$imageload2to6[$key]}</TD>\n";
        print "    <TD align=center>{$imageload6to8[$key]}</TD>\n";
        print "    <TD align=center>{$imageload8more[$key]}</TD>\n";
        if ($imagefails[$key]) {
            $percent = $imagefails[$key] * 100 / $value;
            if ($percent < 1) {
                $percent = sprintf('%.1f%%', $percent);
            } else {
                $percent = sprintf('%d%%', $percent);
            }
            print "    <TD align=center><font color=red>{$imagefails[$key]} ";
            print "({$percent})</font></TD>\n";
        } else {
            print "    <TD align=center>{$imagefails[$key]}</TD>\n";
        }
        print "  </TR>\n";
    }
    print "</TABLE>\n";
    print "<H3>" . i("Durations:") . "</H3>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("0 - 30 Min:") . "</TH>\n";
    print "    <TD>" . $lengths["30min"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("30 Min - 1 Hour:") . "</TH>\n";
    print "    <TD>" . $lengths["1hour"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("1 Hour - 2 Hours:") . "</TH>\n";
    print "    <TD>" . $lengths["2hours"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("2 Hours - 4 Hours:") . "</TH>\n";
    print "    <TD>" . $lengths["4hours"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("4 Hours - 6 Hours:") . "</TH>\n";
    print "    <TD>" . $lengths["6hours"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("6 Hours - 8 Hours:") . "</TH>\n";
    print "    <TD>" . $lengths["8hours"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("8 Hours - 10 Hours:") . "</TH>\n";
    print "    <TD>" . $lengths["10hours"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("&gt; 10 Hours:") . "</TH>\n";
    print "    <TD>" . $lengths["10hrsplus"] . "</TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "<H3>" . i("Ending information:") . "</H3>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Deleted:") . "</TH>\n";
    print "    <TD>" . $ending["deleted"] . "</TD>\n";
    print "    <TD rowspan=7><img src=\"images/blank.gif\" width=5></TD>\n";
    print "    <TD>" . i("(Future reservation deleted before start time reached)") . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Released:") . "</TH>\n";
    print "    <TD>" . $ending["released"] . "</TD>\n";
    print "    <TD>" . i("(Reservation released before end time reached)") . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Not Acknowledged:") . "</TH>\n";
    print "    <TD>" . $ending["noack"] . "</TD>\n";
    print "    <TD>" . i("(\"Connect!\" button never clicked)") . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("No Login:"******"</TH>\n";
    print "    <TD>" . $ending["nologin"] . "</TD>\n";
    print "    <TD>" . i("(User never logged in)") . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("End of Reservation:") . "</TH>\n";
    print "    <TD>" . $ending["EOR"] . "</TD>\n";
    print "    <TD>" . i("(End of reservation reached)") . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Timed Out:") . "</TH>\n";
    print "    <TD>" . $ending["timeout"] . "</TD>\n";
    print "    <TD>" . i("(Disconnect and no reconnection within 15 minutes)") . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>" . i("Failed:") . "</TH>\n";
    print "    <TD>" . $ending["failed"] . "</TD>\n";
    print "    <TD>" . i("(Reserved computer failed to get prepared for user)") . "</TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "<br>\n";
    print "</div>\n";
    $unixstart = datetimeToUnix($start);
    $unixend = datetimeToUnix($end);
    $start = date('Y-m-d', $unixstart);
    $end = date('Y-m-d', $unixend);
    $cdata = array('start' => $start, 'end' => $end, 'affilid' => $affilid, 'mode' => $mode2, 'provid' => $provid);
    print "<H2>" . i("Reservations by Day") . "</H2>\n";
    print "<small>" . i("(Reservations with start time on given day)") . "</small><br>\n";
    $cdata['divid'] = 'resbyday';
    $cont = addContinuationsEntry('AJgetStatData', $cdata);
    print "<input type=hidden id=statdaycont value=\"{$cont}\">\n";
    print "<div id=\"resbyday\" class=\"statgraph\">(Loading...)</div>\n";
    print "<H2>" . i("Max Concurrent Reservations By Day") . "</H2>\n";
    $cdata['divid'] = 'maxconcurresday';
    $cont = addContinuationsEntry('AJgetStatData', $cdata);
    print "<input type=hidden id=statconcurrescont value=\"{$cont}\">\n";
    print "<div id=\"maxconcurresday\" class=\"statgraph\">Loading graph data...</div>\n";
    print "<H2>" . i("Max Concurrent Blade Reservations By Day") . "</H2>\n";
    $cdata['divid'] = 'maxconcurbladeday';
    $cont = addContinuationsEntry('AJgetStatData', $cdata);
    print "<input type=hidden id=statconcurbladecont value=\"{$cont}\">\n";
    print "<div id=\"maxconcurbladeday\" class=\"statgraph\">Loading graph data...</div>\n";
    print "<H2>" . i("Max Concurrent Virtual Machine Reservations By Day") . "</H2>\n";
    $cdata['divid'] = 'maxconcurvmday';
    $cont = addContinuationsEntry('AJgetStatData', $cdata);
    print "<input type=hidden id=statconcurvmcont value=\"{$cont}\">\n";
    print "<div id=\"maxconcurvmday\" class=\"statgraph\">Loading graph data...</div>\n";
    print "<H2>" . i("Reservations by Hour") . "</H2>\n";
    print "<small>(" . i("Active reservations during given hour averaged over selected dates") . ")</small><br><br>\n";
    $cdata['divid'] = 'resbyhour';
    $cont = addContinuationsEntry('AJgetStatData', $cdata);
    print "<input type=hidden id=statreshourcont value=\"{$cont}\">\n";
    print "<div id=\"resbyhour\" class=\"statgraph\">Loading graph data...</div>\n";
    $endtime = microtime(1);
    $end = $endtime - $timestart;
    #print "running time: $endtime - $timestart = $end<br>\n";
}
Esempio n. 6
0
function connectRequest()
{
    global $remoteIP, $user, $inContinuation;
    if ($inContinuation) {
        $requestid = getContinuationVar('requestid', 0);
    } else {
        $requestid = processInputVar("requestid", ARG_NUMERIC);
    }
    $requestData = getRequestInfo($requestid);
    if ($requestData['reservations'][0]['remoteIP'] != $remoteIP) {
        $setback = unixToDatetime(time() - 600);
        $query = "UPDATE reservation " . "SET remoteIP = '{$remoteIP}', " . "lastcheck = '{$setback}' " . "WHERE requestid = {$requestid}";
        $qh = doQuery($query, 226);
        addChangeLogEntry($requestData["logid"], $remoteIP);
    }
    print "<H2 align=center>Connect!</H2>\n";
    if ($requestData['forimaging']) {
        print "<font color=red><big><strong>NOTICE:</strong> Later in this process, you must accept a\n\t\t<a href=\"" . BASEURL . SCRIPT . "?mode=imageClickThrough\">click-through agreement</a> about software licensing.</big></font><br><br>\n";
    }
    if (count($requestData["reservations"]) == 1) {
        $serverIP = $requestData["reservations"][0]["reservedIP"];
        $osname = $requestData["reservations"][0]["OS"];
        $passwd = $requestData["reservations"][0]["password"];
        if (eregi("windows", $osname)) {
            print "You will need to use a ";
            print "Remote Desktop program to connect to the ";
            print "system. If you did not click on the <b>Connect!</b> button from ";
            print "the computer you will be using to access the VCL system, you ";
            print "will need to cancel this reservation, request a new one, and ";
            print "make sure you click the <strong>Connect!</strong> button in ";
            print "a web browser running on the same computer from which you will ";
            print "be connecting to the VCL system. Otherwise, you may be denied ";
            print "access to the remote computer.<br><br>\n";
            print "Use the following information when you are ready to connect:<br>\n";
            print "<UL>\n";
            print "<LI><b>Remote Computer</b>: {$serverIP}</LI>\n";
            if ($requestData["forimaging"]) {
                print "<LI><b>User ID</b>: Administrator</LI>\n";
            } else {
                if (preg_match('/(.*)@(.*)/', $user['unityid'], $matches)) {
                    print "<LI><b>User ID</b>: " . $matches[1] . "</LI>\n";
                } else {
                    print "<LI><b>User ID</b>: " . $user['unityid'] . "</LI>\n";
                }
            }
            if (strlen($passwd)) {
                print "<LI><b>Password</b>: {$passwd}<br></LI>\n";
                print "</UL>\n";
                print "<b>NOTE</b>: The given password is for <i>this reservation ";
                print "only</i>. You will be given a different password for any other ";
                print "reservations.<br>\n";
            } else {
                print "<LI><b>Password</b>: (use your campus password)</LI>\n";
                print "</UL>\n";
            }
            /*print "<br>\n";
            		print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
            		print "<h3>NEW!</h3>\n";
            		print "Connect to the server using a java applet:<br>\n";
            		print "<INPUT type=submit value=\"Connect with Applet\">\n";
            		print "<INPUT type=hidden name=mode value=connectRDPapplet>\n";
            		print "<INPUT type=hidden name=requestid value=$requestid>\n";
            		print "</FORM><br>\n";*/
            print "For automatic connection, you can download an RDP file that can ";
            print "be opened by the Remote Desktop Connection program.<br><br>\n";
            print "<table summary=\"\">\n";
            print "  <TR>\n";
            print "    <TD>\n";
            print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
            $cdata = array('requestid' => $requestid);
            $expire = datetimeToUnix($requestData['end']) - datetimeToUnix($requestData['start']) + 1800;
            # reservation time plus 30 min
            $cont = addContinuationsEntry('sendRDPfile', $cdata, $expire);
            print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
            print "      <INPUT type=submit value=\"Get RDP File\">\n";
            print "      </FORM>\n";
            print "    </TD>\n";
            print "  </TR>\n";
            print "</table>\n";
        } else {
            print "You will need to have an ";
            print "X server running on your local computer and use an ";
            print "ssh client to connect to the system. If you did not ";
            print "click on the <b>Connect!</b> button from the computer you will ";
            print "need to cancel this reservation, request a new one, and ";
            print "make sure you click the <strong>Connect!</strong> button in ";
            print "a web browser running on the same computer from which you will ";
            print "be connecting to the VCL system. Otherwise, you may be denied ";
            print "access to the remote computer.<br><br>\n";
            print "Use the following information when you are ready to connect:<br>\n";
            print "<UL>\n";
            print "<LI><b>Remote Computer</b>: {$serverIP}</LI>\n";
            if (preg_match('/(.*)@(.*)/', $user['unityid'], $matches)) {
                print "<LI><b>User ID</b>: " . $matches[1] . "</LI>\n";
            } else {
                print "<LI><b>User ID</b>: " . $user['unityid'] . "</LI>\n";
            }
            if (strlen($passwd)) {
                print "<LI><b>Password</b>: {$passwd}<br></LI>\n";
                print "</UL>\n";
                print "<b>NOTE</b>: The given password is for <i>this reservation ";
                print "only</i>. You will be given a different password for any other ";
                print "reservations.<br>\n";
            } else {
                print "<LI><b>Password</b>: (use your campus password)</LI>\n";
                print "</UL>\n";
            }
            print "<strong><big>NOTE:</big> You cannot use the Windows Remote ";
            print "Desktop Connection to connect to this computer. You must use an ";
            print "ssh client.</strong>\n";
            /*if(eregi("windows", $_SERVER["HTTP_USER_AGENT"])) {
            			print "<br><br><h3>NEW!</h3>\n";
            			print "Connect to the server using a java applet:<br>\n";
            			print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
            			print "<INPUT type=submit value=\"Connect with Applet\">\n";
            			print "<INPUT type=hidden name=mode value=connectMindterm>\n";
            			print "<INPUT type=hidden name=serverip value=\"$serverIP\">\n";
            			print "</FORM>\n";
            		}*/
        }
    } else {
        print "You will need an ";
        print "ssh client to connect to any unix systems.<br>\n";
        print "You will need a ";
        print "Remote Desktop program</a> to connect to any windows systems.<br><br>\n";
        print "Use the following information when you are ready to connect:<br>\n";
        $total = count($requestData["reservations"]);
        $count = 0;
        foreach ($requestData["reservations"] as $key => $res) {
            $count++;
            print "<h3>{$res["prettyimage"]}</h3>\n";
            print "<UL>\n";
            print "<LI><b>Platform</b>: {$res["OS"]}</LI>\n";
            print "<LI><b>Remote Computer</b>: {$res["reservedIP"]}</LI>\n";
            print "<LI><b>User ID</b>: " . $user['unityid'] . "</LI>\n";
            if (eregi("windows", $res["OS"])) {
                if (strlen($res['password'])) {
                    print "<LI><b>Password</b>: {$res['password']}<br></LI>\n";
                    print "</UL>\n";
                    print "<b>NOTE</b>: The given password is for <i>this reservation ";
                    print "only</i>. You will be given a different password for any other ";
                    print "reservations.<br>\n";
                } else {
                    print "<LI><b>Password</b>: (use your campus password)</LI>\n";
                    print "</UL>\n";
                }
                /*print "Connect to the server using a java applet:<br>\n";
                		print "<INPUT type=submit value=\"Connect with Applet\">\n";
                		print "<INPUT type=hidden name=mode value=connectRDPapplet>\n";
                		print "<INPUT type=hidden name=requestid value=$requestid>\n";
                		print "<INPUT type=hidden name=reservedIP value=\"{$res["reservedIP"]}\">\n";
                		print "</FORM><br><br>\n";*/
                print "Automatic connection using an RDP file:<br>\n";
                print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                $cdata = array('requestid' => $requestid, 'reservedIP' => $res['reservedIP']);
                $expire = datetimeToUnix($requestData['end']) - datetimeToUnix($requestData['start']) + 1800;
                # reservation time plus 30 min
                $cont = addContinuationsEntry('sendRDPfile', $cdata, $expire);
                print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
                print "<INPUT type=submit value=\"Get RDP File\">\n";
                print "</FORM>\n";
            } else {
                if (strlen($res['password'])) {
                    print "<LI><b>Password</b>: {$res['password']}<br></LI>\n";
                    print "</UL>\n";
                    print "<b>NOTE</b>: The given password is for <i>this reservation ";
                    print "only</i>. You will be given a different password for any other ";
                    print "reservations.<br>\n";
                } else {
                    print "<LI><b>Password</b>: (use your campus password)</LI>\n";
                    print "</UL>\n";
                }
                /*if(eregi("windows", $_SERVER["HTTP_USER_AGENT"])) {
                			print "Connect to the server using a java applet:<br>\n";
                			print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
                			print "<INPUT type=submit value=\"Connect with Applet\">\n";
                			print "<INPUT type=hidden name=mode value=connectMindterm>\n";
                			print "<INPUT type=hidden name=requestid value=$requestid>\n";
                			print "<INPUT type=hidden name=serverip value=\"{$res["reservedIP"]}\">\n";
                			print "</FORM>\n";
                		}*/
            }
            if ($count < $total) {
                print "<hr>\n";
            }
        }
    }
    foreach ($requestData["reservations"] as $res) {
        if ($res["forcheckout"]) {
            $imageid = $res["imageid"];
            break;
        }
    }
    $imagenotes = getImageNotes($imageid);
    if (preg_match('/\\w/', $imagenotes['usage'])) {
        print "<h3>Notes on using this environment:</h3>\n";
        print "{$imagenotes['usage']}<br><br><br>\n";
    }
}
Esempio n. 7
0
function viewStatistics()
{
    global $submitErr, $submitErrMsg, $user, $viewmode;
    define("30MIN", 1800);
    define("1HOUR", 3600);
    define("2HOURS", 7200);
    define("4HOURS", 14400);
    $month1 = processInputVar("month1", ARG_NUMERIC);
    $day1 = processInputVar("day1", ARG_NUMERIC);
    $year1 = processInputVar("year1", ARG_NUMERIC);
    $month2 = processInputVar("month2", ARG_NUMERIC);
    $day2 = processInputVar("day2", ARG_NUMERIC);
    $year2 = processInputVar("year2", ARG_NUMERIC);
    $affilid = processInputVar("affilid", ARG_NUMERIC, $user['affiliationid']);
    $affils = getAffiliations();
    if ($viewmode < ADMIN_FULL || $affilid != 0 && !array_key_exists($affilid, $affils)) {
        $affilid = $user['affiliationid'];
    }
    $start = "{$year1}-{$month1}-{$day1} 00:00:00";
    $end = "{$year2}-{$month2}-{$day2} 23:59:59";
    if (!checkdate($month1, $day1, $year1)) {
        $submitErr |= STARTERR;
        $submitErrMsg[STARTERR] = "The selected start date is not valid. Please " . "select a valid date.<br>\n";
    }
    if (!checkdate($month2, $day2, $year2)) {
        $submitErr |= ENDERR;
        $submitErrMsg[ENDERR] = "The selected end date is not valid. Please " . "select a valid date.<br>\n";
    }
    if (datetimeToUnix($start) > datetimeToUnix($end)) {
        $submitErr |= ORDERERR;
        $submitErrMsg[ORDERERR] = "The selected end date is before the selected " . "start date.  Please select an end date equal " . "to or greater than the start date.<br>\n";
    }
    if ($submitErr) {
        selectStatistics();
        return;
    }
    $timestart = microtime(1);
    print "<H2>Statistic Information</H2>\n";
    print "<H3>Reservation information between {$month1}/{$day1}/{$year1} and ";
    print "{$month2}/{$day2}/{$year2}:\n";
    print "</H3>\n";
    $reloadid = getUserlistID('vclreload@Local');
    $query = "SELECT l.userid, " . "l.nowfuture, " . "UNIX_TIMESTAMP(l.start) AS start, " . "(UNIX_TIMESTAMP(l.loaded) - UNIX_TIMESTAMP(l.start)) AS loadtime, " . "UNIX_TIMESTAMP(l.finalend) AS finalend, " . "l.wasavailable, " . "l.ending, " . "i.prettyname, " . "o.prettyname AS OS " . "FROM log l, " . "image i, " . "user u, " . "OS o " . "WHERE l.start >= '{$start}' AND " . "l.finalend <= '{$end}' AND " . "i.id = l.imageid AND " . "i.OSid = o.id AND " . "l.userid != {$reloadid} AND ";
    if ($affilid != 0) {
        $query .= "u.affiliationid = {$affilid} AND ";
    }
    $query .= "l.userid = u.id " . "ORDER BY i.prettyname";
    $qh = doQuery($query, 275);
    $totalreservations = 0;
    $users = array();
    $nows = 0;
    $futures = 0;
    $notavailable = 0;
    $loadtimes = array("2less" => 0, "2more" => 0);
    $ending = array("deleted" => 0, "released" => 0, "failed" => 0, "noack" => 0, "nologin" => 0, "timeout" => 0, "EOR" => 0, "none" => 0);
    $imagecount = array();
    $imageusers = array();
    $imagehours = array();
    $imageload2less = array();
    $imageload2more = array();
    $lengths = array("30min" => 0, "1hour" => 0, "2hours" => 0, "4hours" => 0, "4hrsplus" => 0);
    $totalhours = 0;
    $osusers = array();
    while ($row = mysql_fetch_assoc($qh)) {
        if (!array_key_exists($row["prettyname"], $imageload2less)) {
            $imageload2less[$row["prettyname"]] = 0;
        }
        if (!array_key_exists($row["prettyname"], $imageload2more)) {
            $imageload2more[$row["prettyname"]] = 0;
        }
        # notavailable
        if ($row["wasavailable"] == 0) {
            $notavailable++;
        } else {
            $totalreservations++;
            # load times
            if ($row['loadtime'] < 120) {
                $loadtimes['2less']++;
                # imageload2less
                $imageload2less[$row['prettyname']]++;
            } else {
                $loadtimes['2more']++;
                # imageload2more
                $imageload2more[$row['prettyname']]++;
            }
        }
        # users
        $users[$row['userid']] = 1;
        # nowfuture
        if ($row["nowfuture"] == "now") {
            $nows++;
        } else {
            $futures++;
        }
        # ending
        $ending[$row["ending"]]++;
        # imagecount
        if (!array_key_exists($row["prettyname"], $imagecount)) {
            $imagecount[$row["prettyname"]] = 0;
        }
        $imagecount[$row["prettyname"]]++;
        # imageusers
        if (!array_key_exists($row["prettyname"], $imageusers)) {
            $imageusers[$row["prettyname"]] = array();
        }
        $imageusers[$row['prettyname']][$row['userid']] = 1;
        # lengths
        $length = $row["finalend"] - $row["start"];
        if ($length <= 1800) {
            $lengths["30min"]++;
        } elseif ($length <= 3600) {
            $lengths["1hour"]++;
        } elseif ($length <= 7200) {
            $lengths["2hours"]++;
        } elseif ($length <= 14400) {
            $lengths["4hours"]++;
        } else {
            $lengths["4hrsplus"]++;
        }
        # imagehours
        if (!array_key_exists($row["prettyname"], $imagehours)) {
            $imagehours[$row["prettyname"]] = 0;
        }
        $imagehours[$row["prettyname"]] += $length / 3600;
        # total hours
        $totalhours += $length / 3600;
        # osusers
        if (!array_key_exists($row["OS"], $osusers)) {
            $osusers[$row["OS"]] = array();
        }
        $osusers[$row['OS']][$row['userid']] = 1;
    }
    print "<DIV align=center>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>Total Reservations:</TH>\n";
    print "    <TD>{$totalreservations}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Total Hours Used:</TH>\n";
    print "    <TD>" . (int) $totalhours . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>\"Now\" Reservations:</TH>\n";
    print "    <TD>{$nows}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>\"Later\" Reservations:</TH>\n";
    print "    <TD>{$futures}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Unavailable:</TH>\n";
    print "    <TD>{$notavailable}</TD>\n";
    print "  </TR>\n";
    if ($viewmode >= ADMIN_FULL) {
        print "  <TR>\n";
        print "    <TH align=right>Load times &lt; 2 minutes:</TH>\n";
        print "    <TD>{$loadtimes['2less']}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>Load times &gt;= 2 minutes:</TH>\n";
        print "    <TD>{$loadtimes['2more']}</TD>\n";
        print "  </TR>\n";
    }
    print "  <TR>\n";
    print "    <TH align=right>Total Unique Users:</TH>\n";
    print "    <TD>" . count($users) . "</TD>\n";
    print "  </TR>\n";
    foreach (array_keys($osusers) as $key) {
        print "  <TR>\n";
        print "    <TH align=right>Unique Users of {$key}:</TH>\n";
        print "    <TD>" . count($osusers[$key]) . "</TD>\n";
        print "  </TR>\n";
    }
    print "</TABLE>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TD></TD>\n";
    print "    <TH>Reservations</TH>\n";
    print "    <TH>Unique Users</TH>\n";
    print "    <TH>Hours Used</TH>\n";
    if ($viewmode >= ADMIN_FULL) {
        print "    <TH>&lt; 2 min load time</TH>\n";
        print "    <TH>&gt;= 2 min load time</TH>\n";
    }
    print "  </TR>\n";
    foreach ($imagecount as $key => $value) {
        print "  <TR>\n";
        print "    <TH align=right>{$key}:</TH>\n";
        print "    <TD align=center>{$value}</TD>\n";
        print "    <TD align=center>" . count($imageusers[$key]) . "</TD>\n";
        if ((int) $imagehours[$key] == 0) {
            print "    <TD align=center>1</TD>\n";
        } else {
            print "    <TD align=center>" . (int) $imagehours[$key] . "</TD>\n";
        }
        if ($viewmode >= ADMIN_FULL) {
            print "    <TD align=center>{$imageload2less[$key]}</TD>\n";
            print "    <TD align=center>{$imageload2more[$key]}</TD>\n";
        }
        print "  </TR>\n";
    }
    print "</TABLE>\n";
    print "<H3>Durations:</H3>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>0 - 30 Min:</TH>\n";
    print "    <TD>" . $lengths["30min"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>30 Min - 1 Hour:</TH>\n";
    print "    <TD>" . $lengths["1hour"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>1 Hour - 2 Hours:</TH>\n";
    print "    <TD>" . $lengths["2hours"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>2 Hours - 4 Hours:</TH>\n";
    print "    <TD>" . $lengths["4hours"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>&gt; 4 Hours:</TH>\n";
    print "    <TD>" . $lengths["4hrsplus"] . "</TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "<H3>Ending information:</H3>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>Deleted:</TH>\n";
    print "    <TD>" . $ending["deleted"] . "</TD>\n";
    print "    <TD rowspan=7><img src=\"images/blank.gif\" width=5></TD>\n";
    print "    <TD>(Future reservation deleted before start time reached)</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Released:</TH>\n";
    print "    <TD>" . $ending["released"] . "</TD>\n";
    print "    <TD>(Reservation released before end time reached)</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Not Acknowledged:</TH>\n";
    print "    <TD>" . $ending["noack"] . "</TD>\n";
    print "    <TD>(\"Connect!\" button never clicked)</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>No Login:</TH>\n";
    print "    <TD>" . $ending["nologin"] . "</TD>\n";
    print "    <TD>(User never logged in)</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>End of Reservation:</TH>\n";
    print "    <TD>" . $ending["EOR"] . "</TD>\n";
    print "    <TD>(End of reservation reached)</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Timed Out:</TH>\n";
    print "    <TD>" . $ending["timeout"] . "</TD>\n";
    print "    <TD>(Disconnect and no reconnection within 15 minutes)</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Failed:</TH>\n";
    print "    <TD>" . $ending["failed"] . "</TD>\n";
    print "    <TD>(Reserved computer failed to get prepared for user)</TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "<br>\n";
    $unixstart = datetimeToUnix($start);
    $unixend = datetimeToUnix($end);
    $start = date('Y-m-d', $unixstart);
    $end = date('Y-m-d', $unixend);
    $cdata = array('start' => $start, 'end' => $end, 'affilid' => $affilid);
    print "<H2>Reservations by Day</H2>\n";
    $cont = addContinuationsEntry('statgraphday', $cdata);
    print "<img src=" . BASEURL . SCRIPT . "?continuation={$cont}>";
    print "<H2>Max Concurrent Reservations By Day</H2>\n";
    if ($unixend - $unixstart > SECINMONTH) {
        print "(this graph only available for up to a month of data)<br>\n";
    } else {
        $cont = addContinuationsEntry('statgraphdayconcuruser', $cdata);
        print "<img src=" . BASEURL . SCRIPT . "?continuation={$cont}>";
    }
    print "<H2>Max Concurrent Blade Reservations By Day</H2>\n";
    if ($unixend - $unixstart > SECINMONTH) {
        print "(this graph only available for up to a month of data)<br>\n";
    } else {
        $cont = addContinuationsEntry('statgraphdayconcurblade', $cdata);
        print "<img src=" . BASEURL . SCRIPT . "?continuation={$cont}>";
    }
    print "<H2>Reservations by Hour</H2>\n";
    print "(Averaged over the time period)<br><br>\n";
    $cont = addContinuationsEntry('statgraphhour', $cdata);
    print "<img src=" . BASEURL . SCRIPT . "?continuation={$cont}>";
    print "</div>\n";
    $endtime = microtime(1);
    $end = $endtime - $timestart;
    #print "running time: $endtime - $timestart = $end<br>\n";
}
Esempio n. 8
0
function printLoginPage()
{
    global $authMechs, $skin, $user;
    $user['id'] = 0;
    $authtype = getContinuationVar("authtype", processInputVar("authtype", ARG_STRING));
    $userid = processInputVar('userid', ARG_STRING, '');
    if ($userid == 'Proceed to Login') {
        $userid = '';
    }
    if (!array_key_exists($authtype, $authMechs)) {
        // FIXME - hackerish
        dbDisconnect();
        exit;
    }
    /*if($skin == 'example1') {
    		$useridLabel = 'Pirateid';
    		$passLabel = 'Passphrase';
    		$text1 = 'Login with your Pirate ID';
    		$text2 = "";
    	}
    	elseif($skin == 'example2') {
    		print "<br>";
    		print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post name=loginform>\n";
    		if(strlen($userid))
    			print "<font color=red>Login failed</font>\n";
    		print "<TABLE width=\"250\">\n";
    		print "  <TR>\n";
    		print "    <TH align=right>Key Account:</TH>\n";
    		print "    <TD><INPUT type=text name=userid value=\"\"></TD>\n";
    		print "  </TR>\n";
    		print "  <TR>\n";
    		print "    <TH align=right>Password:</TH>\n";
    		print "    <TD><INPUT type=password name=password></TD>\n";
    		print "  </TR>\n";
    		print "  <TR>\n";
    		print "    <TD colspan=2 align=right><INPUT type=submit value=Login class=button></TD>\n";
    		print "  </TR>\n";
    		print "</TABLE>\n";
    		print "<div width=250 align=center>\n";
    		print "<p>\n";
    		$cdata = array('authtype' => $authtype);
    		$cont = addContinuationsEntry('submitLogin', $cdata);
    		print "  <INPUT type=hidden name=continuation value=\"$cont\">\n";
    		print "  <br>\n";
    		print "  </p>\n";
    		print "</div>\n";
    		print "</FORM>\n";
    		print getFooter();
    		return;
    	}
    	else {*/
    $useridLabel = 'Userid';
    $passLabel = 'Password';
    $text1 = "Login with {$authtype}";
    $text2 = "";
    #}
    print "<H2 style=\"display: block\">{$text1}</H2>\n";
    print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post name=loginform>\n";
    if (strlen($userid)) {
        print "<font color=red>Login failed</font>\n";
    }
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>{$useridLabel}:</TH>\n";
    print "    <TD><INPUT type=text name=userid value=\"{$userid}\"></TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>{$passLabel}:</TH>\n";
    print "    <TD><INPUT type=password name=password></TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TD colspan=2 align=right><INPUT type=submit value=Login></TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    $cdata = array('authtype' => $authtype);
    $cont = addContinuationsEntry('submitLogin', $cdata);
    print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "</FORM>\n";
    print "{$text2}<br>\n";
    print getFooter();
}
Esempio n. 9
0
function printHelpForm()
{
    global $user, $submitErr, $noHTMLwrappers;
    if ($submitErr) {
        $name = processInputVar("name", ARG_STRING);
        $email = processInputVar("email", ARG_STRING);
        $summary = processInputVar("summary", ARG_STRING);
        $text = processInputVar("comments", ARG_STRING);
    } else {
        $name = $user["firstname"] . " " . $user["lastname"];
        $email = $user["email"];
        $summary = "";
        $text = "";
    }
    if (!in_array('helpform', $noHTMLwrappers)) {
        print "<H2>VCL Help</H2>\n";
    }
    print "This form sends a request to the VCL support group.  Please provide ";
    print "as much information as possible.<br><br>\n";
    if (HELPFAQURL != '') {
        print "Please see our <a href=\"" . HELPFAQURL . "\">";
        print "FAQ</a> Section before sending your request - it may be an easy ";
        print "fix!<br><br>\n";
    }
    print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>Name:</TH>\n";
    print "    <TD><INPUT type=text name=name size=25 value=\"{$name}\"></TD>\n";
    print "    <TD>";
    printSubmitErr(NAMEERR);
    print "    </TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Email:</TH>\n";
    print "    <TD><INPUT type=text name=email size=25 value=\"{$email}\"></TD>\n";
    print "    <TD>";
    printSubmitErr(EMAILERR);
    print "    </TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Summary:</TH>\n";
    print "    <TD><INPUT type=text name=summary size=25 value=\"{$summary}\"></TD>\n";
    print "    <TD>";
    printSubmitErr(SUMMARYERR);
    print "    </TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "<br>\n";
    print "Please describe the problem you are having. Include a description ";
    print "of how you encountered the problem and any error messages you ";
    print "received:<br>\n";
    printSubmitErr(TEXTERR);
    print "<textarea tabindex=2 name=comments cols=50 rows=8>{$text}</textarea><br>\n";
    if (in_array('helpform', $noHTMLwrappers)) {
        $cdata = array('indrupal' => 1);
    } else {
        $cdata = array();
    }
    $cont = addContinuationsEntry('submitHelpForm', $cdata, SECINDAY, 1, 0);
    print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "<INPUT tabindex=3 type=submit value=\"Submit Help Request\">\n";
    print "</FORM>\n";
}
Esempio n. 10
0
function confirmDeleteSchedule()
{
    $scheduleid = getContinuationVar("scheduleid");
    $schedules = getSchedules();
    $days = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday");
    $name = $schedules[$scheduleid]["name"];
    $owner = $schedules[$scheduleid]["owner"];
    print "<DIV align=center>\n";
    print "<H2>Delete Schedule</H2>\n";
    print "Delete the following schedule?<br><br>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>Name:</TH>\n";
    print "    <TD>{$name}</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Owner:</TH>\n";
    print "    <TD>{$owner}</TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    if (count($schedules[$scheduleid]["times"])) {
        print "<TABLE>\n";
        print "  <TR>\n";
        print "    <TH>Start</TH>\n";
        print "    <TD>&nbsp;</TD>\n";
        print "    <TH>End</TH>\n";
        print "  <TR>\n";
        foreach ($schedules[$scheduleid]["times"] as $time) {
            print "  <TR>\n";
            print "    <TD>" . minToDaytime($time["start"]) . "</TD>\n";
            print "    <TD>&nbsp;</TD>\n";
            print "    <TD>" . minToDaytime($time["end"]) . "</TD>\n";
            print "  </TR>\n";
        }
        print "</TABLE>\n";
    }
    print "<TABLE>\n";
    print "  <TR valign=top>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cdata = array('scheduleid' => $scheduleid);
    $cont = addContinuationsEntry('submitDeleteSchedule', $cdata, SECINDAY, 0, 0);
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=Submit>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "      <INPUT type=hidden name=mode value=viewSchedules>\n";
    print "      <INPUT type=submit value=Cancel>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
}
Esempio n. 11
0
function confirmDeleteGroup()
{
    $groupid = getContinuationVar("groupid");
    $type = getContinuationVar("type");
    $usergroups = getUserGroups(1);
    $resourcegroups = getResourceGroups();
    if ($type == "user") {
        $title = "Delete User Group";
        $question = "Delete the following user group?";
        $name = $usergroups[$groupid]["name"];
        $target = "";
    } else {
        $title = "Delete Resource Group";
        $question = "Delete the following resource group?";
        list($resourcetype, $name) = split('/', $resourcegroups[$groupid]["name"]);
        $target = "#resources";
    }
    if (checkForGroupUsage($groupid, $type)) {
        print "<H2 align=center>{$title}</H2>\n";
        print "This group is currently assigned to at least one node in the ";
        print "privilege tree.  You cannot delete it until it is no longer ";
        print "in use.";
        return;
    }
    print "<DIV align=center>\n";
    print "<H2>{$title}</H2>\n";
    print "{$question}<br><br>\n";
    print "<TABLE>\n";
    if ($type == "resource") {
        print "  <TR>\n";
        print "    <TH align=right>Type:</TH>\n";
        print "    <TD>{$resourcetype}</TD>\n";
        print "  </TR>\n";
    }
    print "  <TR>\n";
    print "    <TH align=right>Name:</TH>\n";
    print "    <TD>{$name}</TD>\n";
    print "  </TR>\n";
    if ($type == "resource") {
        print "  <TR>\n";
        print "    <TH align=right>Owning User Group:</TH>\n";
        print "    <TD>" . $resourcegroups[$groupid]["owner"] . "</TD>\n";
        print "  </TR>\n";
    }
    print "</TABLE>\n";
    print "<TABLE>\n";
    print "  <TR valign=top>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "{$target}\" method=post>\n";
    $cdata = array('groupid' => $groupid, 'type' => $type);
    $cont = addContinuationsEntry('submitDeleteGroup', $cdata);
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=Submit>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "      <INPUT type=hidden name=mode value=viewGroups>\n";
    print "      <INPUT type=submit value=Cancel>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
}
Esempio n. 12
0
function userLookup()
{
    global $user;
    $userid = processInputVar("userid", ARG_STRING);
    if (get_magic_quotes_gpc()) {
        $userid = stripslashes($userid);
    }
    $affilid = processInputVar('affiliationid', ARG_NUMERIC, $user['affiliationid']);
    $force = processInputVar('force', ARG_NUMERIC, 0);
    print "<div align=center>\n";
    print "<H2>User Lookup</H2>\n";
    print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH>Name (last, first) or User ID:</TH>\n";
    print "    <TD><INPUT type=text name=userid value=\"{$userid}\" size=25></TD>\n";
    if (checkUserHasPerm('User Lookup (global)')) {
        $affils = getAffiliations();
        print "    <TD>\n";
        print "@";
        printSelectInput("affiliationid", $affils, $affilid);
        print "    </TD>\n";
    }
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TD colspan=2>\n";
    print "      <input type=checkbox id=force name=force value=1>\n";
    print "      <label for=force>Attempt forcing an update from LDAP (User ID only)</label>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TD colspan=3 align=center><INPUT type=submit value=Submit>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    $cont = addContinuationsEntry('submitUserLookup');
    print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "</FORM><br>\n";
    if (!empty($userid)) {
        $esc_userid = mysql_real_escape_string($userid);
        if (preg_match('/,/', $userid)) {
            $mode = 'name';
            $force = 0;
        } else {
            $mode = 'userid';
        }
        if (!checkUserHasPerm('User Lookup (global)') && $user['affiliationid'] != $affilid) {
            print "<font color=red>{$userid} not found</font><br>\n";
            return;
        }
        if ($mode == 'userid') {
            $query = "SELECT id " . "FROM user " . "WHERE unityid = '{$esc_userid}' AND " . "affiliationid = {$affilid}";
            $affilname = getAffiliationName($affilid);
            $userid = "{$userid}@{$affilname}";
            $esc_userid = "{$esc_userid}@{$affilname}";
        } else {
            $tmp = explode(',', $userid);
            $last = mysql_real_escape_string(trim($tmp[0]));
            $first = mysql_real_escape_string(trim($tmp[1]));
            $query = "SELECT CONCAT(u.unityid, '@', a.name) AS unityid " . "FROM user u, " . "affiliation a " . "WHERE u.firstname = '{$first}' AND " . "u.lastname = '{$last}' AND " . "u.affiliationid = {$affilid} AND " . "a.id = {$affilid}";
        }
        $qh = doQuery($query, 101);
        if (!mysql_num_rows($qh)) {
            if ($mode == 'name') {
                print "<font color=red>User not found</font><br>\n";
                return;
            } else {
                print "<font color=red>{$userid} not currently found in VCL user database, will try to add...</font><br>\n";
            }
        } elseif ($force) {
            $_SESSION['userresources'] = array();
            $row = mysql_fetch_assoc($qh);
            $newtime = unixToDatetime(time() - SECINDAY - 5);
            $query = "UPDATE user SET lastupdated = '{$newtime}' WHERE id = {$row['id']}";
            doQuery($query, 101);
        } elseif ($mode == 'name') {
            $row = mysql_fetch_assoc($qh);
            $userid = $row['unityid'];
            $esc_userid = $row['unityid'];
        }
        $userdata = getUserInfo($esc_userid);
        if (is_null($userdata)) {
            $userdata = getUserInfo($esc_userid, 1);
            if (is_null($userdata)) {
                print "<font color=red>{$userid} not found</font><br>\n";
                return;
            }
        }
        $userdata["groups"] = getUsersGroups($userdata["id"], 1, 1);
        print "<TABLE>\n";
        if (!empty($userdata['unityid'])) {
            print "  <TR>\n";
            print "    <TH align=right>User ID:</TH>\n";
            print "    <TD>{$userdata["unityid"]}</TD>\n";
            print "  </TR>\n";
        }
        if (!empty($userdata['firstname'])) {
            print "  <TR>\n";
            print "    <TH align=right>First Name:</TH>\n";
            print "    <TD>{$userdata["firstname"]}</TD>\n";
            print "  </TR>\n";
        }
        if (!empty($userdata['lastname'])) {
            print "  <TR>\n";
            print "    <TH align=right>Last Name:</TH>\n";
            print "    <TD>{$userdata["lastname"]}</TD>\n";
            print "  </TR>\n";
        }
        if (!empty($userdata['preferredname'])) {
            print "  <TR>\n";
            print "    <TH align=right>Preferred Name:</TH>\n";
            print "    <TD>{$userdata["preferredname"]}</TD>\n";
            print "  </TR>\n";
        }
        if (!empty($userdata['affiliation'])) {
            print "  <TR>\n";
            print "    <TH align=right>Affiliation:</TH>\n";
            print "    <TD>{$userdata["affiliation"]}</TD>\n";
            print "  </TR>\n";
        }
        if (!empty($userdata['email'])) {
            print "  <TR>\n";
            print "    <TH align=right>Email:</TH>\n";
            print "    <TD>{$userdata["email"]}</TD>\n";
            print "  </TR>\n";
        }
        print "  <TR>\n";
        print "    <TH align=right style=\"vertical-align: top\">Groups:</TH>\n";
        print "    <TD>\n";
        uasort($userdata["groups"], "sortKeepIndex");
        foreach ($userdata["groups"] as $group) {
            print "      {$group}<br>\n";
        }
        print "    </TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right style=\"vertical-align: top\">User Group Permissions:</TH>\n";
        print "    <TD>\n";
        if (count($userdata['groupperms'])) {
            foreach ($userdata['groupperms'] as $perm) {
                print "      {$perm}<br>\n";
            }
        } else {
            print "      No additional user group permissions\n";
        }
        print "    </TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right style=\"vertical-align: top\">Privileges (found somewhere in the tree):</TH>\n";
        print "    <TD>\n";
        uasort($userdata["privileges"], "sortKeepIndex");
        foreach ($userdata["privileges"] as $priv) {
            if ($priv == "block" || $priv == "cascade") {
                continue;
            }
            print "      {$priv}<br>\n";
        }
        print "    </TD>\n";
        print "  </TR>\n";
        print "</TABLE>\n";
        # get user's resources
        $userResources = getUserResources(array("imageCheckOut"), array("available"), 0, 0, $userdata['id']);
        # find nodes where user has privileges
        $query = "SELECT p.name AS privnode, " . "upt.name AS userprivtype, " . "up.privnodeid " . "FROM userpriv up, " . "privnode p, " . "userprivtype upt " . "WHERE up.privnodeid = p.id AND " . "up.userprivtypeid = upt.id AND " . "up.userid = {$userdata['id']} " . "ORDER BY p.name, " . "upt.name";
        $qh = doQuery($query, 101);
        if (mysql_num_rows($qh)) {
            print "Nodes where user is granted privileges:<br>\n";
            print "<TABLE>\n";
            $privnodeid = 0;
            while ($row = mysql_fetch_assoc($qh)) {
                if ($privnodeid != $row['privnodeid']) {
                    if ($privnodeid) {
                        print "    </TD>\n";
                        print "  </TR>\n";
                    }
                    print "  <TR>\n";
                    $privnodeid = $row['privnodeid'];
                    $path = getNodePath($privnodeid);
                    print "    <TH align=right>{$path}</TH>\n";
                    print "    <TD>\n";
                }
                print "      {$row['userprivtype']}<br>\n";
            }
            print "    </TD>\n";
            print "  </TR>\n";
            print "</TABLE>\n";
        }
        # find nodes where user's groups have privileges
        if (!empty($userdata['groups'])) {
            $query = "SELECT DISTINCT p.name AS privnode, " . "upt.name AS userprivtype, " . "up.privnodeid " . "FROM userpriv up, " . "privnode p, " . "userprivtype upt " . "WHERE up.privnodeid = p.id AND " . "up.userprivtypeid = upt.id AND " . "upt.name != 'cascade' AND " . "upt.name != 'block' AND " . "up.usergroupid IN (" . implode(',', array_keys($userdata['groups'])) . ") " . "ORDER BY p.name, " . "upt.name";
            $qh = doQuery($query, 101);
            if (mysql_num_rows($qh)) {
                print "Nodes where user's groups are granted privileges:<br>\n";
                print "<TABLE>\n";
                $privnodeid = 0;
                while ($row = mysql_fetch_assoc($qh)) {
                    if ($privnodeid != $row['privnodeid']) {
                        if ($privnodeid) {
                            print "    </TD>\n";
                            print "  </TR>\n";
                        }
                        print "  <TR>\n";
                        $privnodeid = $row['privnodeid'];
                        $path = getNodePath($privnodeid);
                        print "    <TH align=right>{$path}</TH>\n";
                        print "    <TD>\n";
                    }
                    print "      {$row['userprivtype']}<br>\n";
                }
                print "    </TD>\n";
                print "  </TR>\n";
                print "</TABLE>\n";
            }
        }
        print "<table>\n";
        print "  <tr>\n";
        print "    <th>Images User Has Access To:<th>\n";
        print "    <td>\n";
        foreach ($userResources['image'] as $img) {
            print "      {$img}<br>\n";
        }
        print "    </td>\n";
        print "  </tr>\n";
        print "</table>\n";
        # login history
        $query = "SELECT authmech, " . "timestamp, " . "passfail, " . "remoteIP, " . "code " . "FROM loginlog " . "WHERE (user = '******'unityid']}' OR " . "user = '******'unityid']}@{$userdata['affiliation']}') AND " . "affiliationid = {$userdata['affiliationid']} " . "ORDER BY timestamp DESC " . "LIMIT 8";
        $logins = array();
        $qh = doQuery($query);
        while ($row = mysql_fetch_assoc($qh)) {
            $logins[] = $row;
        }
        if (count($logins)) {
            $logins = array_reverse($logins);
            print "<h3>Login History (last 8 attempts)</h3>\n";
            print "<table summary=\"login attempts\">\n";
            print "<colgroup>\n";
            print "<col class=\"logincol\" />\n";
            print "<col class=\"logincol\" />\n";
            print "<col class=\"logincol\" />\n";
            print "<col class=\"logincol\" />\n";
            print "<col />\n";
            print "</colgroup>\n";
            print "  <tr>\n";
            print "    <th>Authentication Method</th>\n";
            print "    <th>Timestamp</th>\n";
            print "    <th>Result</th>\n";
            print "    <th>Remote IP</th>\n";
            print "    <th>Extra Info</th>\n";
            print "  </tr>\n";
            foreach ($logins as $login) {
                print "  <tr>\n";
                print "    <td class=\"logincell\">{$login['authmech']}</td>\n";
                $ts = prettyDatetime($login['timestamp'], 1);
                print "    <td class=\"logincell\">{$ts}</td>\n";
                if ($login['passfail']) {
                    print "    <td class=\"logincell\"><font color=\"#008000\">Pass</font></td>\n";
                } else {
                    print "    <td class=\"logincell\"><font color=\"red\">Fail</font></td>\n";
                }
                print "    <td class=\"logincell\">{$login['remoteIP']}</td>\n";
                print "    <td class=\"logincell\">{$login['code']}</td>\n";
                print "  </tr>\n";
            }
            print "</table>\n";
        } else {
            print "<h3>Login History</h3>\n";
            print "There are no login attempts by this user.<br>\n";
        }
        # reservation history
        $requests = array();
        $query = "SELECT DATE_FORMAT(l.start, '%W, %b %D, %Y, %h:%i %p') AS start, " . "DATE_FORMAT(l.finalend, '%W, %b %D, %Y, %h:%i %p') AS end, " . "c.hostname, " . "i.prettyname AS prettyimage, " . "s.IPaddress, " . "l.ending " . "FROM log l, " . "image i, " . "computer c, " . "sublog s " . "WHERE l.userid = {$userdata['id']} AND " . "s.logid = l.id AND " . "i.id = s.imageid AND " . "c.id = s.computerid " . "ORDER BY l.start DESC " . "LIMIT 5";
        $qh = doQuery($query, 290);
        while ($row = mysql_fetch_assoc($qh)) {
            array_push($requests, $row);
        }
        $requests = array_reverse($requests);
        if (!empty($requests)) {
            print "<h3>User's last " . count($requests) . " reservations:</h3>\n";
            print "<table>\n";
            $first = 1;
            foreach ($requests as $req) {
                if ($first) {
                    $first = 0;
                } else {
                    print "  <tr>\n";
                    print "    <td colspan=2><hr></td>\n";
                    print "  </tr>\n";
                }
                print "  <tr>\n";
                print "    <th align=right>Image:</th>\n";
                print "    <td>{$req['prettyimage']}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>Computer:</th>\n";
                print "    <td>{$req['hostname']}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>Start:</th>\n";
                print "    <td>{$req['start']}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>End:</th>\n";
                print "    <td>{$req['end']}</td>\n";
                print "  </tr>\n";
                if ($req['IPaddress'] != '') {
                    print "  <tr>\n";
                    print "    <th align=right>IP Address:</th>\n";
                    print "    <td>{$req['IPaddress']}</td>\n";
                    print "  </tr>\n";
                }
                print "  <tr>\n";
                print "    <th align=right>Ending:</th>\n";
                print "    <td>{$req['ending']}</td>\n";
                print "  </tr>\n";
            }
            print "</table>\n";
        } else {
            print "User made no reservations in the past week.<br>\n";
        }
        # current reservations
        $requests = array();
        $query = "SELECT DATE_FORMAT(rq.start, '%W, %b %D, %Y, %h:%i %p') AS start, " . "DATE_FORMAT(rq.end, '%W, %b %D, %Y, %h:%i %p') AS end, " . "rq.id AS requestid, " . "MIN(rs.id) AS reservationid, " . "c.hostname AS computer, " . "i.prettyname AS prettyimage, " . "c.IPaddress AS compIP, " . "rs.remoteIP AS userIP, " . "ch.hostname AS vmhost, " . "mn.hostname AS managementnode, " . "srq.name AS servername, " . "aug.name AS admingroup, " . "lug.name AS logingroup, " . "s1.name AS state, " . "s2.name AS laststate " . "FROM image i, " . "managementnode mn, " . "request rq " . "LEFT JOIN reservation rs ON (rs.requestid = rq.id) " . "LEFT JOIN computer c ON (rs.computerid = c.id) " . "LEFT JOIN vmhost vh ON (c.vmhostid = vh.id) " . "LEFT JOIN computer ch ON (vh.computerid = ch.id) " . "LEFT JOIN serverrequest srq ON (srq.requestid = rq.id) " . "LEFT JOIN usergroup aug ON (aug.id = srq.admingroupid) " . "LEFT JOIN usergroup lug ON (lug.id = srq.logingroupid) " . "LEFT JOIN state s1 ON (s1.id = rq.stateid) " . "LEFT JOIN state s2 ON (s2.id = rq.laststateid) " . "WHERE rq.userid = {$userdata['id']} AND " . "i.id = rs.imageid AND " . "mn.id = rs.managementnodeid " . "GROUP BY rq.id " . "ORDER BY rq.start";
        $qh = doQuery($query, 290);
        while ($row = mysql_fetch_assoc($qh)) {
            array_push($requests, $row);
        }
        $requests = array_reverse($requests);
        if (!empty($requests)) {
            print "<h3>User's current reservations:</h3>\n";
            print "<table>\n";
            $first = 1;
            foreach ($requests as $req) {
                if ($first) {
                    $first = 0;
                } else {
                    print "  <tr>\n";
                    print "    <td colspan=2><hr></td>\n";
                    print "  </tr>\n";
                }
                print "  <tr>\n";
                print "    <th align=right>Request ID:</th>\n";
                print "    <td>{$req['requestid']}</td>\n";
                print "  </tr>\n";
                if ($req['servername'] != '') {
                    print "  <tr>\n";
                    print "    <th align=right>Reservation Name:</th>\n";
                    print "    <td>{$req['servername']}</td>\n";
                    print "  </tr>\n";
                }
                print "  <tr>\n";
                print "    <th align=right>Image:</th>\n";
                print "    <td>{$req['prettyimage']}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>State:</th>\n";
                if ($req['state'] == 'pending') {
                    print "    <td>{$req['laststate']}</td>\n";
                } else {
                    print "    <td>{$req['state']}</td>\n";
                }
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>Computer:</th>\n";
                print "    <td>{$req['computer']}</td>\n";
                print "  </tr>\n";
                if (!empty($req['vmhost'])) {
                    print "  <tr>\n";
                    print "    <th align=right>VM Host:</th>\n";
                    print "    <td>{$req['vmhost']}</td>\n";
                    print "  </tr>\n";
                }
                print "  <tr>\n";
                print "    <th align=right>Start:</th>\n";
                print "    <td>{$req['start']}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>End:</th>\n";
                if ($req['end'] == 'Friday, Jan 1st, 2038, 12:00 AM') {
                    print "    <td>(indefinite)</td>\n";
                } else {
                    print "    <td>{$req['end']}</td>\n";
                }
                print "  </tr>\n";
                if ($req['compIP'] != '') {
                    print "  <tr>\n";
                    print "    <th align=right>Node's IP Address:</th>\n";
                    print "    <td>{$req['compIP']}</td>\n";
                    print "  </tr>\n";
                }
                if ($req['userIP'] != '') {
                    print "  <tr>\n";
                    print "    <th align=right>User's IP Address:</th>\n";
                    print "    <td>{$req['userIP']}</td>\n";
                    print "  </tr>\n";
                }
                if ($req['admingroup'] != '') {
                    print "  <tr>\n";
                    print "    <th align=right>Admin Group:</th>\n";
                    print "    <td>{$req['admingroup']}</td>\n";
                    print "  </tr>\n";
                }
                if ($req['logingroup'] != '') {
                    print "  <tr>\n";
                    print "    <th align=right>Access Group:</th>\n";
                    print "    <td>{$req['logingroup']}</td>\n";
                    print "  </tr>\n";
                }
                print "  <tr>\n";
                print "    <th align=right>Management Node:</th>\n";
                print "    <td>{$req['managementnode']}</td>\n";
                print "  </tr>\n";
            }
            print "</table>\n";
        } else {
            print "User does not have any current reservations.<br>\n";
        }
    }
    print "</div>\n";
}
Esempio n. 13
0
function manageGroupingHTML()
{
    global $mode;
    $resources = getUserResources(array("serverProfileAdmin"), array("manageGroup"));
    $resourcegroups = getUserResources(array("serverProfileAdmin"), array("manageGroup"), 1);
    $h = '';
    if ($mode == 'submitServerProfileGroups') {
        $gridSelected = "selected=\"true\"";
    } else {
        $gridSelected = "";
    }
    $h .= "<H2>Server Profile Grouping</H2>\n";
    $h .= "<span id=\"noprofilegroupsspan\"";
    if (count($resources["serverprofile"]) && count($resourcegroups['serverprofile'])) {
        $h .= " class=\"hidden\"";
    }
    $h .= ">\n";
    $h .= "You don't have access to modify any server profile groups.<br>\n";
    $h .= "</span>\n";
    $h .= "<span id=\"groupprofilesspan\"";
    if (!count($resources["serverprofile"]) || !count($resourcegroups['serverprofile'])) {
        $h .= " class=\"hidden\"";
    }
    $h .= ">\n";
    $h .= "<div id=\"groupTabContainer\" dojoType=\"dijit.layout.TabContainer\"\n";
    $h .= "     style=\"width:600px;height:400px\">\n";
    # by profile tab
    $h .= "<div id=\"resource\" dojoType=\"dijit.layout.ContentPane\" title=\"By Server Profile\">\n";
    $h .= "Select a server profile and click \"Get Groups\" to see all of the groups ";
    $h .= "it is in. Then,<br>select a group it is in and click the Remove ";
    $h .= "button to remove it from that group,<br>or select a group it is not ";
    $h .= "in and click the Add button to add it to that group.<br><br>\n";
    $h .= "Server Profile:<select dojoType=\"dijit.form.Select\" id=\"profiles\" ";
    $h .= "sortByLabel=\"true\" onChange=\"dojo.addClass('groupsdiv', 'hidden');";
    $h .= "\"></select>\n";
    # build list of profiles
    /*$profiles = $resources['serverprofile'];
    	uasort($profiles, 'sortKeepIndex');
    	foreach($profiles as $id => $profile) {
    		$h .= "<option value=$id>$profile</option>\n";
    	}
    	$h .= "</select>\n";*/
    $h .= "<button dojoType=\"dijit.form.Button\" id=\"fetchGrpsButton\">\n";
    $h .= "\tGet Groups\n";
    $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
    $h .= "\t\tgetGroups();\n";
    $h .= "\t</script>\n";
    $h .= "</button>\n";
    $h .= "<div id=\"groupsdiv\" class=\"hidden\">\n";
    $h .= "<table><tbody><tr>\n";
    # select for groups profile is in
    $h .= "<td valign=top>\n";
    $h .= "Groups <span style=\"font-weight: bold;\" id=inprofilename></span> is in:<br>\n";
    $h .= "<select name=ingroups multiple id=ingroups size=15>\n";
    $h .= "</select>\n";
    $h .= "</td>\n";
    # transfer buttons
    $h .= "<td style=\"vertical-align: middle;\">\n";
    $h .= "<button dojoType=\"dijit.form.Button\" id=\"addBtn1\">\n";
    $h .= "  <div style=\"width: 50px;\">&lt;-Add</div>\n";
    $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
    $cont = addContinuationsEntry('AJaddGroupToProfile');
    $h .= "\t\taddRemItem('{$cont}', 'profiles', 'outgroups', addRemProfileCB);\n";
    $h .= "\t</script>\n";
    $h .= "</button>\n";
    $h .= "<br>\n";
    $h .= "<br>\n";
    $h .= "<br>\n";
    $h .= "<button dojoType=\"dijit.form.Button\" id=\"remBtn1\">\n";
    $h .= "\t<div style=\"width: 50px;\">Remove-&gt;</div>\n";
    $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
    $cont = addContinuationsEntry('AJremGroupFromProfile');
    $h .= "\t\taddRemItem('{$cont}', 'profiles', 'ingroups', addRemProfileCB);\n";
    $h .= "\t</script>\n";
    $h .= "</button>\n";
    $h .= "</td>\n";
    # select for groups profile is not in
    $h .= "<td valign=top>\n";
    $h .= "Groups <span style=\"font-weight: bold;\" id=outprofilename></span> is not in:<br>\n";
    $h .= "<select name=outgroups multiple id=outgroups size=15>\n";
    $h .= "</select>\n";
    $h .= "</td>\n";
    $h .= "</tr><tbody/></table>\n";
    $h .= "</div>\n";
    # groupsdiv
    $h .= "</div>\n";
    # resource
    # by group tab
    $h .= "<div id=\"group\" dojoType=\"dijit.layout.ContentPane\" title=\"By Group\">\n";
    $h .= "Select a group and click \"Get Server Profiles\" to see all of the server profiles ";
    $h .= "in it. Then,<br>select a server profile in it and click the Remove ";
    $h .= "button to remove it from the group,<br>or select a server profile that is not ";
    $h .= "in it and click the Add button to add it to the group.<br><br>\n";
    $h .= "Group:<select dojoType=\"dijit.form.Select\" id=\"profileGroups\" ";
    $h .= "onChange=\"dojo.addClass('profilesdiv', 'hidden');\">\n";
    # build list of groups
    $tmp = getUserResources(array('serverProfileAdmin'), array('manageGroup'), 1);
    $groups = $tmp['serverprofile'];
    uasort($groups, 'sortKeepIndex');
    foreach ($groups as $id => $group) {
        $h .= "<option value={$id}>{$group}</option>\n";
    }
    $h .= "</select>\n";
    $h .= "<button dojoType=\"dijit.form.Button\" id=\"fetchImgsButton\">\n";
    $h .= "\tGet Server Profiles\n";
    $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
    $h .= "\t\tgetProfiles();\n";
    $h .= "\t</script>\n";
    $h .= "</button>\n";
    $h .= "<div id=\"profilesdiv\" class=\"hidden\">\n";
    $h .= "<table><tbody><tr>\n";
    # select for profiles in group
    $h .= "<td valign=top>\n";
    $h .= "Server Profiles in <span style=\"font-weight: bold;\" id=ingroupname></span>:<br>\n";
    $h .= "<select name=inprofiles multiple id=inprofiles size=15>\n";
    $h .= "</select>\n";
    $h .= "</td>\n";
    # transfer buttons
    $h .= "<td style=\"vertical-align: middle;\">\n";
    $h .= "<button dojoType=\"dijit.form.Button\" id=\"addBtn2\">\n";
    $h .= "  <div style=\"width: 50px;\">&lt;-Add</div>\n";
    $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
    $cont = addContinuationsEntry('AJaddProfileToGroup');
    $h .= "\t\taddRemItem('{$cont}', 'profileGroups', 'outprofiles', addRemGroupCB);\n";
    $h .= "\t</script>\n";
    $h .= "</button>\n";
    $h .= "<br>\n";
    $h .= "<br>\n";
    $h .= "<br>\n";
    $h .= "<button dojoType=\"dijit.form.Button\" id=\"remBtn2\">\n";
    $h .= "\t<div style=\"width: 50px;\">Remove-&gt;</div>\n";
    $h .= "\t<script type=\"dojo/method\" event=onClick>\n";
    $cont = addContinuationsEntry('AJremProfileFromGroup');
    $h .= "\t\taddRemItem('{$cont}', 'profileGroups', 'inprofiles', addRemGroupCB);\n";
    $h .= "\t</script>\n";
    $h .= "</button>\n";
    $h .= "</td>\n";
    # profiles not in group select
    $h .= "<td valign=top>\n";
    $h .= "Server Profiles not in <span style=\"font-weight: bold;\" id=outgroupname></span>:<br>\n";
    $h .= "<select name=outprofiles multiple id=outprofiles size=15>\n";
    $h .= "</select>\n";
    $h .= "</td>\n";
    $h .= "</tr><tbody/></table>\n";
    $h .= "</div>\n";
    # profilesdiv
    $h .= "</div>\n";
    # group
    $h .= "</div>\n";
    # end of main tab container
    $h .= "</span>\n";
    $cont = addContinuationsEntry('jsonProfileGroupingProfiles');
    $h .= "<input type=hidden id=profilecont value=\"{$cont}\">\n";
    $cont = addContinuationsEntry('jsonProfileGroupingGroups');
    $h .= "<input type=hidden id=grpcont value=\"{$cont}\">\n";
    return array('html' => $h);
}
Esempio n. 14
0
function compScheduleChange()
{
    global $submitErr;
    print "<H2>Change Schedule of Computers</H2>\n";
    $data = processComputerInput3();
    $computers = getComputers(1);
    $schedules = getSchedules();
    print "You are about to place the following computer(s) into schedule ";
    print "<strong><big>{$schedules[$data['scheduleid']]['name']}</big></strong>";
    print ".<br><strong>Note:</strong> ";
    print "This will not affect reservations currently on the computer(s).  It ";
    print "will only affect new reservations made on the computer(s).<br>\n";
    print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cdata = array('scheduleid' => $data['scheduleid'], 'schedule' => $schedules[$data['scheduleid']]['name'], 'computerids' => $data['computerids']);
    $cont = addContinuationsEntry('submitCompScheduleChange', $cdata, SECINDAY, 1, 0);
    print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "<TABLE>\n";
    foreach ($data['computerids'] as $compid) {
        print "  <TR>\n";
        print "    <TD>{$computers[$compid]['hostname']}</TD>\n";
        print "  </TR>\n";
    }
    print "</TABLE>\n";
    print "<INPUT type=submit value=Submit>\n";
    print "</FORM>\n";
}
Esempio n. 15
0
function getSelectLanguagePulldown()
{
    global $locale, $user, $remoteIP, $mode, $authMechs;
    $tmp = explode('/', $_SERVER['SCRIPT_FILENAME']);
    array_pop($tmp);
    array_push($tmp, 'locale');
    $locales = getFSlocales();
    if (count($locales) < 1) {
        return '';
    }
    if (!is_array($user)) {
        $user['id'] = 0;
    }
    $rt = "<form name=\"localeform\" id=\"localeform\" action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $rt .= "<select name=\"continuation\" onChange=\"document.localeform.submit();\">\n";
    $cdata = array('IP' => $remoteIP, 'oldmode' => $mode);
    if ($mode == 'selectauth') {
        $type = processInputVar('authtype', ARG_STRING);
        if (!empty($type) && array_key_exists($type, $authMechs)) {
            $cdata['authtype'] = $type;
        }
    }
    foreach ($locales as $dir => $lang) {
        $cdata['locale'] = $dir;
        $tmp = explode('/', $dir);
        $testlocale = array_pop($tmp);
        $cont = addContinuationsEntry('changeLocale', $cdata, 86400);
        if ($locale == $testlocale) {
            $rt .= "<option value=\"{$cont}\" selected>{$lang}</option>\n";
        } else {
            $rt .= "<option value=\"{$cont}\">{$lang}</option>\n";
        }
    }
    $rt .= "</select>\n";
    $rt .= "</form> \n";
    return $rt;
}
Esempio n. 16
0
function userLookup()
{
    global $user, $viewmode;
    $userid = processInputVar("userid", ARG_STRING);
    print "<div align=center>\n";
    print "<H2>User Lookup</H2>\n";
    print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH>User ID:</TH>\n";
    print "    <TD><INPUT type=text name=userid value=\"{$userid}\" size=25></TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TD></TD>\n";
    print "    <TD align=right><INPUT type=submit value=Submit>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    $cont = addContinuationsEntry('submitUserLookup');
    print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "</FORM>\n";
    if (!empty($userid)) {
        $loginid = $userid;
        getAffilidAndLogin($loginid, $affilid);
        if (empty($affilid)) {
            print "{$matches[2]} is an unknown affiliation<br>\n";
            return;
        }
        if ($viewmode != ADMIN_DEVELOPER && $user['affiliationid'] != $affilid) {
            print "You are only allowed to look up users from your own affiliation.<br>\n";
            return;
        }
        $query = "SELECT id " . "FROM user " . "WHERE unityid = '{$loginid}' AND " . "affiliationid = {$affilid}";
        $qh = doQuery($query, 101);
        if (!mysql_num_rows($qh)) {
            print "<font color=red>{$userid} not currently found in VCL user database, will try to add...</font><br>\n";
        }
        $userdata = getUserInfo($userid);
        if (is_null($userdata)) {
            print "<font color=red>{$userid} not found in any known systems</font><br>\n";
            return;
        }
        print "<TABLE>\n";
        print "  <TR>\n";
        print "    <TH align=right>First Name:</TH>\n";
        print "    <TD>{$userdata["firstname"]}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>Last Name:</TH>\n";
        print "    <TD>{$userdata["lastname"]}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>Preferred Name:</TH>\n";
        print "    <TD>{$userdata["preferredname"]}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>Email:</TH>\n";
        print "    <TD>{$userdata["email"]}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>Admin Level:</TH>\n";
        print "    <TD>{$userdata["adminlevel"]}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right style=\"vertical-align: top\">Groups:</TH>\n";
        print "    <TD>\n";
        uasort($userdata["groups"], "sortKeepIndex");
        foreach ($userdata["groups"] as $group) {
            print "      {$group}<br>\n";
        }
        print "    </TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right style=\"vertical-align: top\">Privileges (found somewhere in the tree):</TH>\n";
        print "    <TD>\n";
        uasort($userdata["privileges"], "sortKeepIndex");
        foreach ($userdata["privileges"] as $priv) {
            if ($priv == "block" || $priv == "cascade") {
                continue;
            }
            print "      {$priv}<br>\n";
        }
        print "    </TD>\n";
        print "  </TR>\n";
        print "</TABLE>\n";
        # get user's resources
        $userResources = getUserResources(array("imageCheckOut"), array("available"), 0, 0, $userdata['id']);
        # find nodes where user has privileges
        $query = "SELECT p.name AS privnode, " . "upt.name AS userprivtype, " . "up.privnodeid " . "FROM userpriv up, " . "privnode p, " . "userprivtype upt " . "WHERE up.privnodeid = p.id AND " . "up.userprivtypeid = upt.id AND " . "up.userid = {$userdata['id']} " . "ORDER BY p.name, " . "upt.name";
        $qh = doQuery($query, 101);
        if (mysql_num_rows($qh)) {
            print "Nodes where user is granted privileges:<br>\n";
            print "<TABLE>\n";
            $privnodeid = 0;
            while ($row = mysql_fetch_assoc($qh)) {
                if ($privnodeid != $row['privnodeid']) {
                    if ($privnodeid) {
                        print "    </TD>\n";
                        print "  </TR>\n";
                    }
                    print "  <TR>\n";
                    $privnodeid = $row['privnodeid'];
                    print "    <TH align=right>{$row['privnode']}</TH>\n";
                    print "    <TD>\n";
                }
                print "      {$row['userprivtype']}<br>\n";
            }
            print "    </TD>\n";
            print "  </TR>\n";
            print "</TABLE>\n";
        }
        # find nodes where user's groups have privileges
        if (!empty($userdata['groups'])) {
            $query = "SELECT DISTINCT p.name AS privnode, " . "upt.name AS userprivtype, " . "up.privnodeid " . "FROM userpriv up, " . "privnode p, " . "userprivtype upt " . "WHERE up.privnodeid = p.id AND " . "up.userprivtypeid = upt.id AND " . "upt.name != 'cascade' AND " . "upt.name != 'block' AND " . "up.usergroupid IN (" . implode(',', array_keys($userdata['groups'])) . ") " . "ORDER BY p.name, " . "upt.name";
            $qh = doQuery($query, 101);
            if (mysql_num_rows($qh)) {
                print "Nodes where user's groups are granted privileges:<br>\n";
                print "<TABLE>\n";
                $privnodeid = 0;
                while ($row = mysql_fetch_assoc($qh)) {
                    if ($privnodeid != $row['privnodeid']) {
                        if ($privnodeid) {
                            print "    </TD>\n";
                            print "  </TR>\n";
                        }
                        print "  <TR>\n";
                        $privnodeid = $row['privnodeid'];
                        print "    <TH align=right>{$row['privnode']}</TH>\n";
                        print "    <TD>\n";
                    }
                    print "      {$row['userprivtype']}<br>\n";
                }
                print "    </TD>\n";
                print "  </TR>\n";
                print "</TABLE>\n";
            }
        }
        print "<table>\n";
        print "  <tr>\n";
        print "    <th>Images User Has Access To:<th>\n";
        print "    <td>\n";
        foreach ($userResources['image'] as $img) {
            print "      {$img}<br>\n";
        }
        print "    </td>\n";
        print "  </tr>\n";
        print "</table>\n";
        $requests = array();
        $query = "SELECT l.start AS start, " . "l.finalend AS end, " . "c.hostname, " . "i.prettyname AS prettyimage, " . "l.ending " . "FROM log l, " . "image i, " . "computer c, " . "sublog s " . "WHERE l.userid = {$userdata["id"]} AND " . "s.logid = l.id AND " . "i.id = s.imageid AND " . "c.id = s.computerid " . "ORDER BY l.start DESC " . "LIMIT 5";
        $qh = doQuery($query, 290);
        while ($row = mysql_fetch_assoc($qh)) {
            array_push($requests, $row);
        }
        $requests = array_reverse($requests);
        if (!empty($requests)) {
            print "<h3>User's last " . count($requests) . " reservations:</h3>\n";
            print "<table>\n";
            $first = 1;
            foreach ($requests as $req) {
                $thisstart = str_replace('&nbsp;', ' ', prettyDatetime($req["start"]));
                $thisend = str_replace('&nbsp;', ' ', prettyDatetime($req["end"]));
                if ($first) {
                    $first = 0;
                } else {
                    print "  <tr>\n";
                    print "    <td colspan=2><hr></td>\n";
                    print "  </tr>\n";
                }
                print "  <tr>\n";
                print "    <th align=right>Image:</th>\n";
                print "    <td>{$req['prettyimage']}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>Computer:</th>\n";
                print "    <td>{$req['hostname']}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>Start:</th>\n";
                print "    <td>{$thisstart}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>End:</th>\n";
                print "    <td>{$thisend}</td>\n";
                print "  </tr>\n";
                print "  <tr>\n";
                print "    <th align=right>Ending:</th>\n";
                print "    <td>{$req['ending']}</td>\n";
                print "  </tr>\n";
            }
            print "</table>\n";
        } else {
            print "User made no reservations in the past week.<br>\n";
        }
    }
    print "</div>\n";
}
Esempio n. 17
0
function showTimeTable($links)
{
    global $mode, $viewmode, $user;
    if ($links == 1) {
        $imageid = getContinuationVar('imageid');
        $length = getContinuationVar('length');
        $requestid = getContinuationVar('requestid', 0);
        $showmessage = getContinuationVar('showmessage', 0);
        $platforms = array();
        $schedules = array();
    } else {
        $imageid = 0;
        $length = 0;
        $requestid = 0;
        $showmessage = 0;
        $platforms = getContinuationVar("platforms");
        if (empty($platforms)) {
            $platforms = processInputVar("platforms", ARG_MULTINUMERIC);
        }
        $schedules = getContinuationVar("schedules");
        if (empty($schedules)) {
            $schedules = processInputVar("schedules", ARG_MULTINUMERIC);
        }
    }
    $argstart = getContinuationVar("start");
    $argend = getContinuationVar("end");
    $resources = getUserResources(array("computerAdmin"));
    $userCompIDs = array_keys($resources["computer"]);
    $computerData = getComputers();
    $imageData = getImages();
    $now = time();
    if ($links) {
        $resources = getUserResources(array("imageAdmin", "imageCheckOut"));
        $usercomputerids = array_keys($resources["computer"]);
        # get list of computers' platformids
        $qh = doQuery("SELECT platformid FROM image WHERE id = {$imageid}", 110);
        $row = mysql_fetch_row($qh);
        $platformid = $row[0];
        $computer_platformids = array();
        $qh = doQuery("SELECT id, platformid FROM computer", 111);
        while ($row = mysql_fetch_row($qh)) {
            $computer_platformids[$row[0]] = $row[1];
        }
        $mappedcomputers = getMappedResources($imageid, "image", "computer");
        $compidlist = array_intersect($mappedcomputers, $usercomputerids);
    } else {
        $compidlist = $userCompIDs;
    }
    if (!empty($argstart) && !empty($argend)) {
        $timeslots = getTimeSlots($compidlist, $argend, $argstart);
        $start = $argstart;
        $end = $argend;
    } else {
        $start = $now;
        $end = $start + SECINDAY / 2;
        $timeslots = getTimeSlots($compidlist, $end);
    }
    print "<DIV align=center>\n";
    print "<H2>Time Table</H2>\n";
    print "</DIV>\n";
    $computeridrow = "";
    $displayedids = array();
    $computers = array_keys($timeslots);
    if ($links) {
        $computers = array_intersect($computers, $usercomputerids);
    }
    foreach ($computers as $id) {
        if ($links) {
            # don't show computers that don't meet hardware criteria, are not
            # in the available state, are the wrong platform, or wrong group,
            # or aren't mapped in resourcemap
            if ($computer_platformids[$id] != $platformid || $computerData[$id]["stateid"] != 2 && $computerData[$id]["stateid"] != 3 && $computerData[$id]["stateid"] != 6 && $computerData[$id]["stateid"] != 8 || $computerData[$id]["ram"] < $imageData[$imageid]["minram"] || $computerData[$id]["procnumber"] < $imageData[$imageid]["minprocnumber"] || $computerData[$id]["procspeed"] < $imageData[$imageid]["minprocspeed"] || $computerData[$id]["network"] < $imageData[$imageid]["minnetwork"] || !in_array($id, $mappedcomputers)) {
                continue;
            }
        } elseif (!array_key_exists($id, $computerData) || !in_array($computerData[$id]["platformid"], $platforms) || !in_array($computerData[$id]["scheduleid"], $schedules) || !in_array($id, $userCompIDs)) {
            continue;
        }
        $computeridrow .= "          <TH>{$id}</TH>\n";
        array_push($displayedids, $id);
    }
    if (empty($displayedids)) {
        if ($links) {
            print "There are currently no computers available that can run the application you selected.\n";
        } else {
            print "There are no computers that meet the specified criteria\n";
        }
        return;
    }
    if ($showmessage) {
        print "The time you have requested to use the environment is not ";
        print "available. You may select from the green blocks of time to ";
        print "select an available time slot to make a reservation.<br>\n";
    }
    print "<table summary=\"\">\n";
    print "  <TR>\n";
    print "    <TD>";
    # print Previous/Next links
    if (!empty($argstart) && $argstart - SECINDAY / 2 > $now - 600) {
        $prevstart = $start - SECINDAY / 2;
        $prevend = $end - SECINDAY / 2;
        print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
        $cdata = array('start' => $prevstart, 'end' => $prevend, 'imageid' => $imageid, 'requestid' => $requestid, 'length' => $length, 'platforms' => $platforms, 'schedules' => $schedules);
        $cont = addContinuationsEntry($mode, $cdata, SECINDAY);
        print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
        print "<INPUT type=submit value=Previous>\n";
        print "</FORM>\n";
    }
    print "</TD>\n";
    print "    <TD>";
    if ($end + SECINDAY / 2 < $now + DAYSAHEAD * SECINDAY) {
        $nextstart = $start + SECINDAY / 2;
        $nextend = $end + SECINDAY / 2;
        print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
        $cdata = array('start' => $nextstart, 'end' => $nextend, 'imageid' => $imageid, 'requestid' => $requestid, 'length' => $length, 'platforms' => $platforms, 'schedules' => $schedules);
        $cont = addContinuationsEntry($mode, $cdata, SECINDAY);
        print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
        print "<INPUT type=submit value=Next>\n";
        print "</FORM>\n";
    }
    print "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TD>\n";
    $tmpArr = array_keys($computers);
    $first = $computers[$tmpArr[0]];
    print "      <table id=ttlayout summary=\"\">\n";
    if (!$links || $viewmode >= ADMIN_DEVELOPER) {
        print "        <TR>\n";
        print "          <TH align=right>Computer&nbsp;ID:</TH>\n";
        print $computeridrow;
        print "        </TR>\n";
    }
    $yesterday = "";
    foreach (array_keys($timeslots[$first]) as $stamp) {
        if ($stamp < $now) {
            continue;
        }
        print "        <TR>\n";
        $stampArr = getdate($stamp);
        $label = "";
        if ($stampArr["mday"] != $yesterday) {
            $label = date('n/d/Y+g:i+a', $stamp);
            $label = str_replace('+', '&nbsp;', $label);
            $yesterday = $stampArr["mday"];
        } elseif ($stampArr["minutes"] == 0) {
            $label = date('g:i a', $stamp);
        }
        print "          <TH align=right>{$label}</TH>\n";
        $free = 0;
        # print the cells
        foreach ($computers as $id) {
            if (!in_array($id, $displayedids)) {
                continue;
            }
            if ($links && ($computer_platformids[$id] != $platformid || $computerData[$id]["stateid"] == 10 || $computerData[$id]["stateid"] == 5)) {
                continue;
            }
            # computer's schedule is currently closed
            if ($timeslots[$id][$stamp]["scheduleclosed"] == 1) {
                print "          <TD bgcolor=\"#a0a0a0\"><img src=images/gray.jpg ";
                print "alt=scheduleclosed border=0></TD>\n";
            } elseif ($computerData[$id]["stateid"] == 10) {
                print "          <TD bgcolor=\"#a0a0a0\"><img src=images/gray.jpg ";
                print "alt=maintenance border=0></TD>\n";
            } elseif ($timeslots[$id][$stamp]['blockRequest'] && ($timeslots[$id][$stamp]['blockRequestInfo']['imageid'] != $imageid || !in_array($timeslots[$id][$stamp]['blockRequestInfo']['groupid'], array_keys($user['groups']))) && $timeslots[$id][$stamp]['available']) {
                if ($links) {
                    print "          <TD bgcolor=\"#ff0000\"><img src=images/red.jpg ";
                    print "alt=blockrequest border=0></TD>\n";
                } else {
                    print "          <TD bgcolor=\"#e58304\"><img src=images/orange.jpg ";
                    $title = "Block Request: {$timeslots[$id][$stamp]['blockRequestInfo']['name']}\n" . "Image: {$timeslots[$id][$stamp]['blockRequestInfo']['image']}";
                    print "alt=blockrequest border=0 title=\"{$title}\"></TD>\n";
                }
            } elseif ($timeslots[$id][$stamp]["available"]) {
                if ($links) {
                    print "          <TD bgcolor=\"#00ff00\"><a href=\"" . BASEURL . SCRIPT;
                    print "?mode=newRequest&stamp={$stamp}&imageid={$imageid}&length={$length}\"><img ";
                    print "src=images/green.jpg alt=free border=0></a></TD>\n";
                } else {
                    print "          <TD bgcolor=\"#00ff00\"><img src=images/green.jpg alt=free border=0></TD>\n";
                }
            } else {
                if ($links) {
                    print "          <TD bgcolor=\"#ff0000\"><font color=\"#ff0000\">used</font></TD>\n";
                } else {
                    $title = "User: "******"unityid"] . " Image: " . $timeslots[$id][$stamp]["prettyimage"];
                    $cdata = array('requestid' => $timeslots[$id][$stamp]["requestid"]);
                    $cont = addContinuationsEntry('viewRequestInfo', $cdata);
                    print "          <TD bgcolor=\"#ff0000\"><a href=\"" . BASEURL;
                    print SCRIPT . "?continuation={$cont}\"><img src=images/red.jpg ";
                    print "alt=used border=0 title=\"{$title}\"></a></TD>\n";
                }
            }
        }
        print "        </TR>\n";
    }
    print "      </table>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TD>";
    # print Previous/Next links
    if (!empty($argstart) && $argstart - SECINDAY / 2 > $now - 600) {
        $prevstart = $start - SECINDAY / 2;
        $prevend = $end - SECINDAY / 2;
        print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
        $cdata = array('start' => $prevstart, 'end' => $prevend, 'imageid' => $imageid, 'requestid' => $requestid, 'length' => $length, 'platforms' => $platforms, 'schedules' => $schedules);
        $cont = addContinuationsEntry($mode, $cdata, SECINDAY);
        print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
        print "<INPUT type=submit value=Previous>\n";
        print "</FORM>\n";
    }
    print "</TD>\n";
    print "    <TD>";
    if ($end + SECINDAY / 2 < $now + DAYSAHEAD * SECINDAY) {
        $nextstart = $start + SECINDAY / 2;
        $nextend = $end + SECINDAY / 2;
        print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
        $cdata = array('start' => $nextstart, 'end' => $nextend, 'imageid' => $imageid, 'requestid' => $requestid, 'length' => $length, 'platforms' => $platforms, 'schedules' => $schedules);
        $cont = addContinuationsEntry($mode, $cdata, SECINDAY);
        print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
        print "<INPUT type=submit value=Next>\n";
        print "</FORM>\n";
    }
    print "</TD>\n";
    print "  </TR>\n";
    print "</table>\n";
}
Esempio n. 18
0
function confirmUserPrefs($type)
{
    global $submitErr, $user;
    $data = processUserPrefsInput(1);
    if ($submitErr) {
        userpreferences();
        return;
    }
    if ($data["audiomode"] == "none") {
        $audio = i("None");
    } else {
        $audio = i("Use my speakers");
    }
    if ($data["mapdrives"] == 0) {
        $drives = i("No");
    } else {
        $drives = i("Yes");
    }
    if ($data["mapprinters"] == 0) {
        $printers = i("No");
    } else {
        $printers = i("Yes");
    }
    if ($data["mapserial"] == 0) {
        $serial = i("No");
    } else {
        $serial = i("Yes");
    }
    print "<div align=center>\n";
    if ($type == 0) {
        print "<H2>" . i("Personal Information") . "</H2>\n";
        print "<H3>" . i("Submit the following changes?") . "</H3>\n";
        print "<table>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("Preferred Name:") . "</TH>\n";
        print "    <TD>" . $data["preferredname"] . "</TD>\n";
        print "  </TR>\n";
        print "</table>\n";
        if ($user['affiliation'] == 'Local' && !empty($data['newpassword'])) {
            print i("New password will be submitted") . "<br>\n";
        }
    } elseif ($type == 1) {
        print "<H2>" . i("RDP Preferences") . "</H2>\n";
        print "<H3>" . i("Submit the following changes?") . "</H3>\n";
        print "<table>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("Resolution:") . "</TH>\n";
        print "    <TD>" . $data["resolution"] . "</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("Color Depth:") . "</TH>\n";
        $colordepth = array("8" => "8", "16" => "16", "24" => "24", "32" => "32");
        print "    <TD>" . $colordepth[$data["bpp"]] . "</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("Audio:") . "</TH>\n";
        print "    <TD>{$audio}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("Map Local Drives:") . "</TH>\n";
        print "    <TD>{$drives}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("Map Local Printers:") . "</TH>\n";
        print "    <TD>{$printers}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("Map Local Serial Ports:") . "</TH>\n";
        print "    <TD>{$serial}</TD>\n";
        print "  </TR>\n";
        print "  <TR>\n";
        print "    <TH align=right>" . i("RDP Port") . ":</TH>\n";
        print "    <TD>{$data['rdpport']}</TD>\n";
        print "  </TR>\n";
        print "</table>\n";
    }
    print "<table>\n";
    print "  <TR>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cont = addContinuationsEntry('submituserprefs', $data, SECINWEEK, 0, 0);
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=" . i("Submit") . ">\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cont = addContinuationsEntry('userpreferences');
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=" . i("Cancel") . ">\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</table>\n";
    print "</div>\n";
}
Esempio n. 19
0
 function AJremImageConnectMethod()
 {
     $imageid = getContinuationVar('imageid');
     $methods = getContinuationVar('methods');
     $revids = getContinuationVar('revids');
     $curmethods = getImageConnectMethods($imageid);
     $remidlist = mysql_real_escape_string(processInputVar('ids', ARG_STRING));
     $remids = explode(',', $remidlist);
     $revid = processInputVar('revid', ARG_NUMERIC);
     $newimage = getContinuationVar('newimage');
     foreach ($remids as $id) {
         if (!is_numeric($id)) {
             $arr = array('error' => 'invalidinput', 'msg' => i("Non-numeric data was submitted for a connection method id."));
             sendJSON($arr);
             return;
         }
     }
     if ($revid != 0 && !in_array($revid, $revids)) {
         $arr = array('error' => 'invalidrevision', 'msg' => i("Invalid revision id submitted."));
         sendJSON($arr);
         return;
     }
     if (!$newimage) {
         if ($revid == 0) {
             $revid = getProductionRevisionid($imageid);
         }
         # delete any current entries for method and image
         $query = "DELETE FROM connectmethodmap " . "WHERE imagerevisionid = {$revid} AND " . "connectmethodid IN ({$remidlist}) AND " . "autoprovisioned IS NULL";
         doQuery($query, 101);
         # query to see if enabled for OStype or OS
         $insvals = array();
         foreach ($remids as $id) {
             $query = "SELECT cm.connectmethodid " . "FROM connectmethodmap cm, " . "image i " . "LEFT JOIN OS o ON (o.id = i.OSid) " . "LEFT JOIN OStype ot ON (ot.name = o.type) " . "WHERE i.id = {$imageid} AND " . "cm.autoprovisioned IS NULL AND " . "cm.connectmethodid = {$id} AND " . "cm.disabled = 0 AND " . "(cm.OStypeid = ot.id OR " . "cm.OSid = o.id)";
             $qh = doQuery($query, 101);
             if (mysql_num_rows($qh)) {
                 # if so, add disabled entry for image revision and method
                 $insvals[] = "({$id}, {$revid}, 1)";
             }
         }
         if (count($insvals)) {
             $allinsvals = implode(',', $insvals);
             $query = "INSERT INTO connectmethodmap " . "(connectmethodid, " . "imagerevisionid, " . "disabled) " . "VALUES {$allinsvals}";
             doQuery($query, 101);
         }
     }
     $cdata = $this->basecdata;
     $cdata['imageid'] = $imageid;
     $cdata['methods'] = $methods;
     $cdata['revids'] = $revids;
     $cdata['newimage'] = $newimage;
     $addcont = addContinuationsEntry('AJaddImageConnectMethod', $cdata, 3600, 1, 0);
     $remcont = addContinuationsEntry('AJremImageConnectMethod', $cdata, 3600, 1, 0);
     $arr = array('addcont' => $addcont, 'remcont' => $remcont);
     sendJSON($arr);
     $key = getKey(array('getImageConnectMethods', (int) $imageid, (int) $revid));
     if (array_key_exists($key, $_SESSION['usersessiondata'])) {
         unset($_SESSION['usersessiondata'][$key]);
     }
     $key = getKey(array('getImageConnectMethods', (int) $imageid, 0));
     if (array_key_exists($key, $_SESSION['usersessiondata'])) {
         unset($_SESSION['usersessiondata'][$key]);
     }
 }
Esempio n. 20
0
 function getHTML()
 {
     global $user;
     $val = getVariable($this->key, $this->defaultval);
     $h = "<div class=\"configwidget\" style=\"width: 100%;\">\n";
     $h .= "<h3>{$this->name}</h3>\n";
     $h .= "<span class=\"siteconfigdesc\">\n";
     $h .= $this->desc;
     $h .= "<br><br></span>\n";
     switch ($this->type) {
         case 'numeric':
             $extra = array('smallDelta' => 1, 'largeDelta' => 10);
             $h .= labeledFormItem($this->domidbase, $this->label, 'spinner', "{min:{$this->minval}, max:{$this->maxval}}", 1, $val, '', '', $extra);
             break;
         case 'boolean':
             $extra = array();
             if ($val == 1) {
                 $extra = array('checked' => 'checked');
             }
             $h .= labeledFormItem($this->domidbase, $this->label, 'check', '', 1, 1, '', '', $extra);
             break;
         case 'textarea':
             $h .= labeledFormItem($this->domidbase, $this->label, 'textarea', '', 1, $val, '', '', '', '120px');
             break;
         default:
             $h .= labeledFormItem($this->domidbase, $this->label, 'text', '', 1, $val);
             break;
     }
     $h .= "<div id=\"{$this->domidbase}msg\"></div>\n";
     $h .= dijitButton("{$this->domidbase}btn", i('Submit Changes'), "{$this->jsname}.saveSettings();", 1);
     $cdata = $this->basecdata;
     $cont = addContinuationsEntry('AJupdateAllSettings', $cdata);
     $h .= "<input type=\"hidden\" id=\"{$this->domidbase}cont\" value=\"{$cont}\">\n";
     $h .= "</div>\n";
     return $h;
 }
Esempio n. 21
0
function confirmDeleteGroup()
{
    global $user;
    $groupid = getContinuationVar("groupid");
    $type = getContinuationVar("type");
    $usergroups = getUserGroups();
    $groupid = processInputVar('groupid', ARG_NUMERIC);
    if ($type == 'user') {
        if (!array_key_exists($groupid, $usergroups)) {
            print "<h2>Delete User Group</h2>\n";
            print "The selected user group does not exist.\n";
            return;
        }
        if ($usergroups[$groupid]['ownerid'] != $user['id']) {
            if ($usergroups[$groupid]['custom'] == 0 || $usergroups[$groupid]['courseroll'] == 1) {
                if (!checkUserHasPerm('Manage Federated User Groups (global)') && (!checkUserHasPerm('Manage Federated User Groups (affiliation only)') || $usergroups[$groupid]['groupaffiliationid'] != $user['affiliationid'])) {
                    print "<h2>Delete User Group</h2>\n";
                    print "You do not have access to delete the selected user group.\n";
                    return;
                }
            } else {
                print "<h2>Delete User Group</h2>\n";
                print "You do not have access to delete the selected user group.\n";
                return;
            }
        }
        $tmp = explode('@', $usergroups[$groupid]['name']);
        $checkname = $tmp[0];
        if ($usergroups[$groupid]['groupaffiliationid'] == 1 && ($checkname == 'Specify End Time' || $checkname == 'Allow No User Check' || $checkname == 'Default for Editable by')) {
            print "<h2>Delete User Group</h2>\n";
            print "{$usergroups[$groupid]['name']} is a system group that cannot be deleted";
            return;
        }
    } else {
        $userresources = getUserResources(array("groupAdmin"), array("manageGroup"), 1);
        $noaccess = 1;
        foreach (array_keys($userresources) as $rtype) {
            if (array_key_exists($groupid, $userresources[$rtype])) {
                $noaccess = 0;
                break;
            }
        }
        if ($noaccess) {
            print "<h2>Delete Resource Group</h2>\n";
            print "You do not have access to delete the selected resource group.\n";
            return;
        }
    }
    $resourcegroups = getResourceGroups();
    if ($type == "user") {
        $title = "Delete User Group";
        $usemsg = "This group is currently in use.  You cannot delete it until " . "it is no longer being used.";
        $question = "Delete the following user group?";
        $name = $usergroups[$groupid]["name"];
        $target = "";
    } else {
        $title = "Delete Resource Group";
        $usemsg = "This group is currently assigned to at least one node in the " . "privilege tree.  You cannot delete it until it is no longer " . "in use.";
        $question = "Delete the following resource group?";
        list($resourcetype, $name) = explode('/', $resourcegroups[$groupid]["name"]);
        $target = "#resources";
    }
    if (checkForGroupUsage($groupid, $type, $usemsg)) {
        print "<H2 align=center>{$title}</H2>\n";
        print $usemsg;
        return;
    }
    print "<DIV align=center>\n";
    print "<H2>{$title}</H2>\n";
    print "{$question}<br><br>\n";
    print "<TABLE>\n";
    if ($type == "resource") {
        print "  <TR>\n";
        print "    <TH align=right>Type:</TH>\n";
        print "    <TD>{$resourcetype}</TD>\n";
        print "  </TR>\n";
    }
    print "  <TR>\n";
    print "    <TH align=right>Name:</TH>\n";
    print "    <TD>{$name}</TD>\n";
    print "  </TR>\n";
    if ($type == "resource") {
        print "  <TR>\n";
        print "    <TH align=right>Owning User Group:</TH>\n";
        print "    <TD>" . $resourcegroups[$groupid]["owner"] . "</TD>\n";
        print "  </TR>\n";
    } elseif ($usergroups[$groupid]['courseroll'] == 1 || $usergroups[$groupid]['custom'] == 0) {
        print "<TR>\n";
        print "  <TH align=right>Type:</TH>\n";
        if ($usergroups[$groupid]['courseroll'] == 1) {
            print "  <TD>Course Roll</TD>\n";
        } elseif ($usergroups[$groupid]['custom'] == 0) {
            print "  <TD>Federated</TD>\n";
        }
        print "</TR>\n";
        print "<TR>\n";
        print "  <TD colspan=2><br><strong>Note</strong>: This type of group is ";
        print "created from external sources<br>and could be recreated from ";
        print "those sources at any time.<br><br></TD>\n";
        print "</TR>\n";
    }
    print "</TABLE>\n";
    print "<TABLE>\n";
    print "  <TR valign=top>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "{$target}\" method=post>\n";
    $cdata = array('groupid' => $groupid, 'type' => $type);
    $cont = addContinuationsEntry('submitDeleteGroup', $cdata);
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=Submit>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "      <INPUT type=hidden name=mode value=viewGroups>\n";
    print "      <INPUT type=submit value=Cancel>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "</DIV>\n";
}
Esempio n. 22
0
function confirmDeleteImage()
{
    $imageid = getContinuationVar("imageid");
    $images = getImages(1);
    if ($images[$imageid]["deleted"] == 0) {
        $deleted = 0;
        $title = "Delete Image";
        $question = "Delete the following image?";
    } else {
        $deleted = 1;
        $title = "Undelete Image";
        $question = "Undelete the following image?";
    }
    if (!$deleted && checkForImageUsage($imageid)) {
        print "<H2 align=center>Delete Image</H2>\n";
        print "The image you selected is currently in use. You cannot delete ";
        print "the image until it is no longer being used.<br>\n";
        return;
    }
    $platforms = getPlatforms();
    $oslist = getOSList();
    print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    print "<DIV align=center>\n";
    print "<H2>{$title}</H2>\n";
    print "{$question}<br><br>\n";
    print "<TABLE>\n";
    /*print "  <TR>\n";
    	print "    <TH align=right>Short Name:</TH>\n";
    	print "    <TD>" . $images[$imageid]["name"] . "</TD>\n";
    	print "  </TR>\n";*/
    print "  <TR>\n";
    print "    <TH align=right>Long Name:</TH>\n";
    print "    <TD>" . $images[$imageid]["prettyname"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Owner:</TH>\n";
    print "    <TD>" . $images[$imageid]["owner"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Platform:</TH>\n";
    print "    <TD>" . $platforms[$images[$imageid]["platformid"]] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>OS:</TH>\n";
    print "    <TD>" . $oslist[$images[$imageid]["osid"]]["prettyname"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Minimum RAM (MB):</TH>\n";
    print "    <TD>" . $images[$imageid]["minram"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Minimum Num of Processors:</TH>\n";
    print "    <TD>" . $images[$imageid]["minprocnumber"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Minimum Processor Speed (MHz):</TH>\n";
    print "    <TD>" . $images[$imageid]["minprocspeed"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Minimum Network Speed (Mbps):</TH>\n";
    print "    <TD>" . $images[$imageid]["minnetwork"] . "</TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>Estimated Reload Time (min):</TH>\n";
    print "    <TD>" . $images[$imageid]["reloadtime"] . "</TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    print "<TABLE>\n";
    print "  <TR valign=top>\n";
    print "    <TD>\n";
    $cdata = array('deleted' => $deleted, 'imageid' => $imageid);
    $cont = addContinuationsEntry('submitDeleteImage', $cdata, SECINDAY, 0, 0);
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=Submit>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "    <TD>\n";
    print "      <FORM action=\"" . BASEURL . SCRIPT . "\" method=post>\n";
    $cont = addContinuationsEntry('viewImages');
    print "      <INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "      <INPUT type=submit value=Cancel>\n";
    print "      </FORM>\n";
    print "    </TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
}
Esempio n. 23
0
function AJeditSiteMaintenance()
{
    global $user;
    $id = getContinuationVar('id');
    $data = processSiteMaintenanceInput();
    $olddata = getMaintItems($id);
    $start = datetimeToUnix($olddata[$id]['start']);
    if (!deleteMaintenanceFile($start) || !writeMaintenanceFile($data['startts'], $data['endts'], $data['usermessage'])) {
        print "alert('Failed to modify maintenance file on web server.\\n";
        print "Please have sysadmin check permissions on maintenance directory.');\n";
        print "dijit.byId('confirmDialog').hide();";
        $data['err'] = 1;
    }
    if ($data['err']) {
        $data = array('id' => $id, 'update' => 1);
        $cont = addContinuationsEntry('AJeditSiteMaintenance', $data, SECINDAY, 1, 0);
        print "dojo.byId('submitcont').value = '{$cont}';";
        return;
    }
    $reason = mysql_real_escape_string($data['reason']);
    $usermessage = mysql_real_escape_string($data['usermessage']);
    $query = "UPDATE sitemaintenance " . "SET start = '{$data['startdt']}', " . "end = '{$data['enddt']}', " . "ownerid = {$user['id']}, " . "created = NOW(), " . "reason = '{$reason}', " . "usermessage = '{$usermessage}', " . "informhoursahead = {$data['hoursahead']}, " . "allowreservations = {$data['allowreservations']} " . "WHERE id = {$id}";
    doQuery($query, 101);
    $_SESSION['usersessiondata'] = array();
    print "window.location.href = '" . BASEURL . SCRIPT . "?mode=siteMaintenance';";
    #print "clearEdit();";
    #siteMaintenance();
}
Esempio n. 24
0
function AJcancelVMmove()
{
    $hostid = processInputVar('hostid', ARG_NUMERIC);
    $hostdata = getVMHostData($hostid);
    $resources = getUserResources(array("computerAdmin"), array("administer"));
    if (!array_key_exists($hostdata[$hostid]['computerid'], $resources['computer'])) {
        $arr = array('failed' => 'nohostaccess');
        header('Content-Type: text/json-comment-filtered; charset=utf-8');
        print '/*{"items":' . json_encode($arr) . '}*/';
        return;
    }
    $fails = array();
    $requestids = processInputVar('listids', ARG_STRING);
    $now = time();
    $msg = 'FAIL';
    foreach (explode(',', $requestids) as $reqid) {
        $request = getRequestInfo($reqid);
        if (!array_key_exists($request['reservations'][0]['computerid'], $resources['computer'])) {
            $fails[] = array('id' => $request['reservations'][0]['computerid'], 'name' => $request['reservations'][0]['hostname'], 'reason' => 'noaccess');
            continue;
        }
        if (datetimeToUnix($request["start"]) < $now) {
            # set stateid and laststateid for each request to deleted
            $query = "UPDATE request " . "SET stateid = 1, " . "laststateid = 1 " . "WHERE id = {$reqid}";
            doQuery($query, 101);
        } else {
            $query = "DELETE FROM request WHERE id = {$reqid}";
            doQuery($query, 101);
            $query = "DELETE FROM reservation WHERE requestid = {$reqid}";
            doQuery($query, 101);
        }
        $msg = 'SUCCESS';
    }
    header('Content-Type: text/json-comment-filtered; charset=utf-8');
    $cont = addContinuationsEntry('vmhostdata');
    $arr = array('msg' => $msg, 'cont' => $cont, 'fails' => $fails);
    print '/*{"items":' . json_encode($arr) . '}*/';
}
Esempio n. 25
0
 function AJdeleteConfigMapping()
 {
     $configmapid = processInputVar('configmapid', ARG_NUMERIC);
     # TODO check access - who is allowed to map/unmap?
     $data = $this->getConfigMapData($configmapid);
     if (is_null($data)) {
         $ret = array('status' => 'notfound');
         sendJSON($ret);
         return;
     }
     $h = '';
     $h .= "Delete the following config mapping?<br><br>";
     $h .= "<strong>Config</strong>: {$data['configname']}<br><br>";
     $subname = $this->getMapSubName($data['prettyconfigmaptype'], $data['subid']);
     $h .= "<strong>{$data['prettyconfigmaptype']}</strong>: {$subname}<br><br>";
     $h .= "<strong>Additional options</strong>:<br>";
     $h .= "Affiliation: {$data['affiliation']}<br>";
     $h .= "Stage: {$data['stage']}";
     $cdata = $this->basecdata;
     $cdata['configmapid'] = $configmapid;
     $cont = addContinuationsEntry('AJsubmitDeleteConfigMapping', $cdata, SECINDAY, 1, 0);
     $ret = array('status' => 'success', 'html' => $h, 'cont' => $cont);
     sendJSON($ret);
 }
Esempio n. 26
0
function getFailedImagingData()
{
    $affilid = getDashboardAffilID();
    $query = "SELECT c.hostname AS computer, " . "i.prettyname AS image, " . "rq.id, " . "rq.start, " . "o.installtype, " . "m.hostname AS managementnode, " . "ch.hostname AS vmhost, " . "u.unityid AS owner " . "FROM request rq " . "LEFT JOIN reservation rs ON (rs.requestid = rq.id) " . "LEFT JOIN computer c ON (c.id = rs.computerid) " . "LEFT JOIN image i ON (i.id = rs.imageid) " . "LEFT JOIN OS o ON (o.id = i.OSid) " . "LEFT JOIN managementnode m ON (m.id = rs.managementnodeid) " . "LEFT JOIN vmhost vh ON (c.vmhostid = vh.id) " . "LEFT JOIN computer ch ON (vh.computerid = ch.id) " . "LEFT JOIN user u ON (rq.userid = u.id) " . "LEFT JOIN user u2 ON (u2.id = c.ownerid) " . "LEFT JOIN state s1 ON (s1.id = rq.stateid) " . "LEFT JOIN state s2 ON (s2.id = rq.laststateid) " . "WHERE s1.name = 'maintenance' AND " . "s2.name IN ('image','checkpoint')";
    if ($affilid) {
        $query .= "AND (u.affiliationid = {$affilid} OR u2.affiliationid = {$affilid}) ";
    }
    $query .= "ORDER BY rq.start";
    $qh = doQuery($query, 101);
    $data = array();
    while ($row = mysql_fetch_assoc($qh)) {
        $tmp = explode('.', $row['computer']);
        $row['computer'] = $tmp[0];
        $tmp = explode('.', $row['vmhost']);
        $row['vmhost'] = $tmp[0];
        $tmp = explode(' ', $row['start']);
        $row['start'] = "{$tmp[0]}<br>{$tmp[1]}";
        $tmp = explode('.', $row['managementnode']);
        $row['managementnode'] = $tmp[0];
        if ($row['vmhost'] == '') {
            $row['vmhost'] = "N/A";
        }
        $row['contid'] = addContinuationsEntry('AJrestartImageCapture', array('requestid' => $row['id']), 120, 1, 0);
        $data[] = $row;
    }
    return $data;
}
Esempio n. 27
0
function AJgetBlockAllocatedMachineData()
{
    global $user;
    $start = processInputVar('start', ARG_STRING);
    if (!preg_match('/^\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}$/', $start)) {
        $start = unixFloor15(time() - 3600);
        $startdt = unixToDatetime($start);
    } else {
        $startdt = "{$start}:00";
        $start = datetimeToUnix($startdt);
    }
    $end = $start + 12 * 3600;
    $enddt = unixToDatetime($end);
    $alldata = array();
    # bare
    $data = array();
    if (checkUserHasPerm('Manage Block Allocations (global)')) {
        $query = "SELECT COUNT(id) " . "FROM computer " . "WHERE stateid IN (2, 3, 6, 8, 11) AND " . "type = 'blade'";
        $qh = doQuery($query, 101);
        if ($row = mysql_fetch_row($qh)) {
            $data['total'] = $row[0];
        }
    } else {
        // TODO once we allow limiting total machines by affiliation, put that value here
        $data['total'] = 0;
    }
    for ($time = $start, $i = 0; $time < $end; $time += 900, $i++) {
        $fmttime = date('g:i a', $time);
        $data["points"][$i] = array('x' => $i, 'y' => 0, 'value' => $i, 'text' => $fmttime);
    }
    $data['maxy'] = 0;
    if (checkUserHasPerm('Manage Block Allocations (global)')) {
        $query = "SELECT UNIX_TIMESTAMP(bt.start) as start, " . "UNIX_TIMESTAMP(bt.end) as end, " . "br.numMachines " . "FROM blockTimes bt, " . "blockRequest br, " . "image i, " . "OS o " . "WHERE bt.blockRequestid = br.id AND " . "bt.skip = 0 AND " . "bt.start < '{$enddt}' AND " . "bt.end > '{$startdt}' AND " . "br.imageid = i.id AND " . "i.OSid = o.id AND " . "o.installtype != 'vmware'";
    } else {
        $query = "SELECT UNIX_TIMESTAMP(bt.start) as start, " . "UNIX_TIMESTAMP(bt.end) as end, " . "br.numMachines " . "FROM blockTimes bt, " . "blockRequest br, " . "image i, " . "OS o, " . "user u " . "WHERE bt.blockRequestid = br.id AND " . "bt.skip = 0 AND " . "bt.start < '{$enddt}' AND " . "bt.end > '{$startdt}' AND " . "br.imageid = i.id AND " . "i.OSid = o.id AND " . "o.installtype != 'vmware' AND " . "br.ownerid = u.id AND " . "u.affiliationid = {$user['affiliationid']}";
    }
    $qh = doQuery($query, 101);
    while ($row = mysql_fetch_assoc($qh)) {
        for ($binstart = $start, $binend = $start + 900, $binindex = 0; $binend <= $end; $binstart += 900, $binend += 900, $binindex++) {
            if ($binend <= $row['start']) {
                continue;
            } elseif ($row['start'] < $binend && $row['end'] > $binstart) {
                $data["points"][$binindex]['y'] += $row['numMachines'];
            } elseif ($binstart >= $row['end']) {
                break;
            }
        }
    }
    for ($time = $start, $i = 0; $time < $end; $time += 900, $i++) {
        if ($data["points"][$i]['y'] > $data['maxy']) {
            $data['maxy'] = $data['points'][$i]['y'];
        }
        $data["points"][$i]['tooltip'] = "{$data['points'][$i]['text']}: {$data['points'][$i]['y']}";
    }
    $alldata['bare'] = $data;
    # virtual
    $data = array();
    if (checkUserHasPerm('Manage Block Allocations (global)')) {
        $query = "SELECT COUNT(id) " . "FROM computer " . "WHERE stateid IN (2, 3, 6, 8, 11) AND " . "type = 'virtualmachine'";
        $qh = doQuery($query, 101);
        if ($row = mysql_fetch_row($qh)) {
            $data['total'] = $row[0];
        }
    } else {
        // TODO once we allow limiting total machines by affiliation, put that value here
        $data['total'] = 0;
    }
    for ($time = $start, $i = 0; $time < $end; $time += 900, $i++) {
        $fmttime = date('g:i a', $time);
        $data["points"][$i] = array('x' => $i, 'y' => 0, 'value' => $i, 'text' => $fmttime);
    }
    $data['maxy'] = 0;
    if (checkUserHasPerm('Manage Block Allocations (global)')) {
        $query = "SELECT UNIX_TIMESTAMP(bt.start) as start, " . "UNIX_TIMESTAMP(bt.end) as end, " . "br.numMachines " . "FROM blockTimes bt, " . "blockRequest br, " . "image i, " . "OS o " . "WHERE bt.blockRequestid = br.id AND " . "bt.skip = 0 AND " . "bt.start < '{$enddt}' AND " . "bt.end > '{$startdt}' AND " . "br.imageid = i.id AND " . "i.OSid = o.id AND " . "o.installtype = 'vmware'";
    } else {
        $query = "SELECT UNIX_TIMESTAMP(bt.start) as start, " . "UNIX_TIMESTAMP(bt.end) as end, " . "br.numMachines " . "FROM blockTimes bt, " . "blockRequest br, " . "image i, " . "OS o, " . "user u " . "WHERE bt.blockRequestid = br.id AND " . "bt.skip = 0 AND " . "bt.start < '{$enddt}' AND " . "bt.end > '{$startdt}' AND " . "br.imageid = i.id AND " . "i.OSid = o.id AND " . "o.installtype = 'vmware' AND " . "br.ownerid = u.id AND " . "u.affiliationid = {$user['affiliationid']}";
    }
    $qh = doQuery($query, 101);
    while ($row = mysql_fetch_assoc($qh)) {
        for ($binstart = $start, $binend = $start + 900, $binindex = 0; $binend <= $end; $binstart += 900, $binend += 900, $binindex++) {
            if ($binend <= $row['start']) {
                continue;
            } elseif ($row['start'] < $binend && $row['end'] > $binstart) {
                $data["points"][$binindex]['y'] += $row['numMachines'];
            } elseif ($binstart >= $row['end']) {
                break;
            }
        }
    }
    for ($time = $start, $i = 0; $time < $end; $time += 900, $i++) {
        if ($data["points"][$i]['y'] > $data['maxy']) {
            $data['maxy'] = $data['points'][$i]['y'];
        }
        $data["points"][$i]['tooltip'] = "{$data['points'][$i]['text']}: {$data['points'][$i]['y']}";
    }
    $alldata['virtual'] = $data;
    $val = getContinuationVar('val') + 1;
    $cont = addContinuationsEntry('AJgetBlockAllocatedMachineData', array('val' => $val), SECINDAY, 1, 0);
    $alldata['cont'] = $cont;
    sendJSON($alldata);
}
Esempio n. 28
0
 function AJeditResource()
 {
     $rscid = processInputVar('rscid', ARG_NUMERIC);
     $resources = getUserResources(array($this->restype . 'Admin'), array('administer'), 0, 1);
     if (!array_key_exists($rscid, $resources[$this->restype])) {
         $ret = array('status' => 'noaccess');
         sendJSON($ret);
         return;
     }
     $args = $this->defaultGetDataArgs;
     $args['rscid'] = $rscid;
     $tmp = $this->getData($args);
     $data = $tmp[$rscid];
     $cdata = $this->basecdata;
     $cdata['rscid'] = $rscid;
     $cdata['olddata'] = $data;
     # save continuation
     $cont = addContinuationsEntry('AJsaveResource', $cdata);
     $ret = $this->jsondata;
     $ret['title'] = "Edit {$this->restypename}";
     $ret['cont'] = $cont;
     $ret['resid'] = $rscid;
     $ret['data'] = $data;
     $ret['status'] = 'success';
     sendJSON($ret);
 }
Esempio n. 29
0
function printLoginPage($servertimeout = 0)
{
    global $authMechs, $skin, $user;
    $user['id'] = 0;
    $authtype = getContinuationVar("authtype", processInputVar("authtype", ARG_STRING));
    if ($authtype == '' && array_key_exists('VCLAUTHSEL', $_COOKIE)) {
        $authtype = $_COOKIE['VCLAUTHSEL'];
    }
    if (isset($_GET['userid'])) {
        unset($_GET['userid']);
    }
    $userid = processInputVar('userid', ARG_STRING, '');
    if ($userid == i('Proceed to Login')) {
        $userid = '';
    }
    if (!array_key_exists($authtype, $authMechs)) {
        // FIXME - hackish
        dbDisconnect();
        exit;
    }
    if (get_magic_quotes_gpc()) {
        $userid = stripslashes($userid);
    }
    $userid = htmlspecialchars($userid);
    $extrafailedmsg = '';
    if ($servertimeout) {
        $extrafailedmsg = " " . i("(unable to connect to authentication server)");
    }
    /*if($skin == 'example1') {
    		$useridLabel = 'Pirateid';
    		$passLabel = 'Passphrase';
    		$text1 = 'Login with your Pirate ID';
    		$text2 = "";
    	}
    	elseif($skin == 'example2') {
    		print "<br>";
    		print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post name=loginform>\n";
    		if(strlen($userid))
    			print "<font color=red>Login failed $extrafailedmsg</font>\n";
    		print "<TABLE width=\"250\">\n";
    		print "  <TR>\n";
    		print "    <TH align=right>Key Account:</TH>\n";
    		print "    <TD><INPUT type=text name=userid value=\"\"></TD>\n";
    		print "  </TR>\n";
    		print "  <TR>\n";
    		print "    <TH align=right>Password:</TH>\n";
    		print "    <TD><INPUT type=password name=password></TD>\n";
    		print "  </TR>\n";
    		print "  <TR>\n";
    		print "    <TD colspan=2 align=right><INPUT type=submit value=Login class=button></TD>\n";
    		print "  </TR>\n";
    		print "</TABLE>\n";
    		print "<div width=250 align=center>\n";
    		print "<p>\n";
    		$cdata = array('authtype' => $authtype);
    		$cont = addContinuationsEntry('submitLogin', $cdata);
    		print "  <INPUT type=hidden name=continuation value=\"$cont\">\n";
    		print "  <br>\n";
    		print "  </p>\n";
    		print "</div>\n";
    		print "</FORM>\n";
    		print getFooter();
    		return;
    	}
    	else {*/
    $useridLabel = i('Userid');
    $passLabel = i('Password');
    $text1 = i("Login with") . " {$authtype}";
    $text2 = "";
    #}
    print "<H2 style=\"display: block\">{$text1}</H2>\n";
    print "<FORM action=\"" . BASEURL . SCRIPT . "\" method=post name=loginform>\n";
    if (strlen($userid)) {
        print "<font color=red>" . i("Login failed") . " {$extrafailedmsg}</font>\n";
    }
    print "<TABLE>\n";
    print "  <TR>\n";
    print "    <TH align=right>{$useridLabel}:</TH>\n";
    print "    <TD><INPUT type=text name=userid value=\"{$userid}\"></TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TH align=right>{$passLabel}:</TH>\n";
    print "    <TD><INPUT type=password name=password></TD>\n";
    print "  </TR>\n";
    print "  <TR>\n";
    print "    <TD colspan=2 align=right><INPUT type=submit value=\"" . i("Login") . "\"></TD>\n";
    print "  </TR>\n";
    print "</TABLE>\n";
    $cdata = array('authtype' => $authtype);
    $cont = addContinuationsEntry('submitLogin', $cdata);
    print "<INPUT type=hidden name=continuation value=\"{$cont}\">\n";
    print "</FORM>\n";
    print "{$text2}<br>\n";
    print getFooter();
}
Esempio n. 30
0
 function addEditDialogHTML($add = 0)
 {
     global $user;
     # dialog for on page editing
     $h = '';
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"addeditdlg\"\n";
     $h .= "      title=\"Edit {$this->restypename}\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"addeditdlgcontent\">\n";
     $h .= "<div id=\"mgmtnodedlgcontent\">\n";
     $h .= "<div style=\"text-align: center;\">\n";
     $h .= "<small>* denotes required fields</small><br><br>\n";
     $h .= "</div>\n";
     # id
     $h .= "<input type=\"hidden\" id=\"editresid\">\n";
     #$h .= "<div style=\"width: 80%; margin-left: 10%;\">\n";
     # name
     $errmsg = i("Name can only contain letters, numbers, dashes(-), periods(.), and underscores(_). It can be from 1 to 50 characters long.");
     $h .= labeledFormItem('name', i('Name') . '*', 'text', '^([a-zA-Z0-9_][-a-zA-Z0-9_\\.]{1,49})$', 1, '', $errmsg);
     # owner
     $extra = array('onKeyPress' => 'setOwnerChecking');
     $h .= labeledFormItem('owner', i('Owner') . '*', 'text', '', 1, "{$user['unityid']}@{$user['affiliation']}", i('Unknown user'), 'checkOwner', $extra);
     $cont = addContinuationsEntry('AJvalidateUserid');
     $h .= "<input type=\"hidden\" id=\"valuseridcont\" value=\"{$cont}\">\n";
     # IP address
     $ipreg = '(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)';
     $ipreg1 = "^{$ipreg}\$";
     $errmsg = i("Invalid IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('ipaddress', i('IP Address') . '*', 'text', $ipreg1, 1, '', $errmsg);
     # State
     $vals = array(2 => "available", 10 => "maintenance", 5 => "failed");
     $h .= labeledFormItem('stateid', i('State'), 'select', $vals);
     # sysadmin email
     $reg = '^([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4},)*([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4})$';
     $errmsg = i("Invalid email address(es) specified");
     $h .= labeledFormItem('sysadminemail', i("SysAdmin Email Address(es)"), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('sysadminemailhelp'));
     # shared mailbox
     $reg = '^([A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4})$';
     $errmsg = i("Invalid email address specified");
     $h .= labeledFormItem('sharedmailbox', i('Address for Shadow Emails'), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('sharedmailboxhelp'));
     # checkininterval
     $extra = array('smallDelta' => 1, 'largeDelta' => 2);
     $h .= labeledFormItem('checkininterval', i('Check-in Interval (sec)'), 'spinner', '{min:5,max:30,places:0}', 1, '6', '', '', $extra, '', helpIcon('checkinhelp'));
     # installpath
     $reg = '^([-a-zA-Z0-9_\\.\\/]){2,100}$';
     $errmsg = i("Invalid install path specified");
     $h .= labeledFormItem('installpath', i('Install Path'), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('installpathhelp'));
     # timeserver list
     $reg = '^(([a-zA-Z0-9_][-a-zA-Z0-9_\\.]{1,49})(,?)){1,5}$';
     $errmsg = i("Invalid time server(s) specified. Must be comman delimited list of hostnames or IP addresses, with up to 5 allowed");
     $val = getVariable('timesource|global');
     $h .= labeledFormItem('timeservers', i('Time Server(s)'), 'text', $reg, 0, $val, $errmsg, '', '', '', helpIcon('timeservershelp'));
     # keys
     $reg = '^([-a-zA-Z0-9_\\.\\/,]){2,1024}$';
     $errmsg = i("Invalid path to identity key files");
     $h .= labeledFormItem('keys', i('End Node SSH Identity Key Files'), 'text', $reg, 0, '', $errmsg, '', '', '', helpIcon('identityhelp'));
     # sshport
     $extra = array('smallDelta' => 1, 'largeDelta' => 2);
     $h .= labeledFormItem('sshport', i('SSH Port for this node'), 'spinner', '{min:1,max:65535,places:0}', 1, '22', '', '', $extra, '', helpIcon('sshporthelp'));
     # image library
     $h .= "<div class=\"boxedoptions\">\n";
     # imagelibenable
     $extra = array('onChange' => 'toggleImageLibrary();');
     $h .= labeledFormItem('imagelibenable', i('Enable Image Library'), 'check', '', '', '', '', '', $extra, '', helpIcon('imagelibhelp'));
     # imagelibgroupid
     $disabled = array('disabled' => 'true');
     $vals = getUserResources(array('mgmtNodeAdmin'), array("manageGroup"), 1);
     $h .= labeledFormItem('imagelibgroupid', i('Image Library Management Node Group'), 'select', $vals['managementnode'], '', '', '', '', $disabled, '', helpIcon('imagelibgrouphelp'));
     # imagelibuser
     $reg = '^([-a-zA-Z0-9_\\.\\/,]){2,20}$';
     $errmsg = i("Invalid image library user");
     $h .= labeledFormItem('imagelibuser', i('Image Library User'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('imagelibuserhelp'));
     # imagelibkey
     $reg = '^([-a-zA-Z0-9_\\.\\/,]){2,100}$';
     $errmsg = i("Invalid image library identity key");
     $h .= labeledFormItem('imagelibkey', i('Image Library SSH Identity Key File'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('imagelibkeyhelp'));
     $h .= "</div>\n";
     # image library
     # IP config method
     $h .= "<div class=\"boxedoptions\">\n";
     # publicIPconfig
     $extra = array('onChange' => 'togglePublic();');
     $vals = array('dynamicDHCP' => 'Dynamic DHCP', 'manualDHCP' => 'Manual DHCP', 'static' => 'Static');
     $h .= labeledFormItem('publicIPconfig', i('Public NIC configuration method'), 'select', $vals, '', '', '', '', $extra, '', helpIcon('ipconfighelp'));
     # netmask
     $errmsg = i("Invalid public netmask");
     $h .= labeledFormItem('publicnetmask', i('Public Netmask'), 'text', $ipreg1, 0, '', $errmsg, '', $disabled, '', helpIcon('netmaskhelp'));
     # gateway
     $reg = '^[a-zA-Z0-9_][-a-zA-Z0-9_\\.]{1,56}$';
     $errmsg = i("Invalid public gateway");
     $h .= labeledFormItem('publicgateway', i('Public Gateway'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('gatewayhelp'));
     # dnsserver
     $reg = "^({$ipreg},)*({$ipreg})\$";
     $errmsg = i("Invalid public DNS server");
     $h .= labeledFormItem('publicdnsserver', i('Public DNS Server'), 'text', $reg, 0, '', $errmsg, '', $disabled, '', helpIcon('dnsserverhelp'));
     $h .= "</div>\n";
     # IP config method
     # available public networks
     $h .= labeledFormItem('availablenetworks', i('Available Public Networks'), 'textarea', '', 1, '', '', '', '', '', helpIcon('availnetshelp'));
     # federated auth
     $h .= labeledFormItem('federatedauth', i('Affiliations using Federated Authentication for Linux Images'), 'textarea', '', 1, '', '', '', '', '', helpIcon('federatedauthhelp'));
     # NAT Host
     $h .= "<div id=\"nathost\" class=\"boxedoptions\">\n";
     # use as NAT host
     $extra = array('onChange' => "toggleNAThost();");
     $h .= labeledFormItem('nathostenabled', i('Use as NAT Host'), 'check', '', '', '1', '', '', $extra);
     # public IP
     $errmsg = i("Invalid NAT Public IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('natpublicipaddress', i('NAT Public IP Address'), 'text', $ipreg1, 1, '', $errmsg, '', '', '', helpIcon('natpubliciphelp'));
     # internal IP
     $errmsg = i("Invalid NAT Internal IP address specified - must be a valid IPV4 address");
     $h .= labeledFormItem('natinternalipaddress', i('NAT Internal IP Address'), 'text', $ipreg1, 1, '', $errmsg, '', '', '', helpIcon('natinternaliphelp'));
     $h .= "</div>\n";
     # NAT Host
     $h .= "</div>\n";
     # mgmtnodedlgcontent
     $h .= "</div>\n";
     # addeditdlgcontent
     $h .= "<div id=\"addeditdlgerrmsg\" class=\"nperrormsg\"></div>\n";
     $h .= "<div id=\"editdlgbtns\" align=\"center\">\n";
     $h .= dijitButton('addeditbtn', "Confirm", "saveResource();");
     $h .= dijitButton('', "Cancel", "dijit.byId('addeditdlg').hide();");
     $h .= "</div>\n";
     # editdlgbtns
     $h .= "</div>\n";
     # addeditdlg
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupingnote\"\n";
     $h .= "      title=\"Management Node Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "Each managemente node needs to be a member of a<br>management node resource group. The following dialog<br>will allow you to add the new management node to a group.<br><br>\n";
     $h .= "<div align=\"center\">\n";
     $h .= dijitButton('', "Close", "dijit.byId('groupingnote').hide();");
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupingnote
     $h .= "<div dojoType=dijit.Dialog\n";
     $h .= "      id=\"groupdlg\"\n";
     $h .= "      title=\"Management Node Grouping\"\n";
     $h .= "      duration=250\n";
     $h .= "      draggable=true>\n";
     $h .= "<div id=\"groupdlgcontent\"></div>\n";
     $h .= "<div align=\"center\">\n";
     $script = "    dijit.byId('groupdlg').hide();\n";
     $script .= "    checkFirstAdd();\n";
     $h .= dijitButton('', "Close", $script);
     $h .= "</div>\n";
     # btn div
     $h .= "</div>\n";
     # groupdlg
     $h .= "<div id=\"tooltips\">\n";
     $h .= helpTooltip('sysadminemailhelp', i("Comma delimited list of email addresses for sysadmins who should receive error emails from this management node. Leave empty to disable this feature."));
     $h .= helpTooltip('sharedmailboxhelp', i("Single email address to which copies of all user emails should be sent. This is a high traffic set of emails. Leave empty to disable this feature."));
     $h .= helpTooltip('checkinhelp', i("the number of seconds that this management node will wait before checking the database for tasks."));
     $h .= helpTooltip('installpathhelp', i("path to parent directory of image repository directories (typically /install) - only needed with bare metal installs or VMWare with local disk"));
     $h .= helpTooltip('timeservershelp', i("comma delimited list of time servers for this management node"));
     $h .= helpTooltip('identityhelp', i("comma delimited list of full paths to ssh identity keys to try when connecting to end nodes (optional)"));
     $h .= helpTooltip('sshporthelp', i("SSH port this node is listening on for image file transfers"));
     $h .= helpTooltip('imagelibhelp', i("Enable sharing of images between management nodes. This allows a management node to attempt fetching files for a requested image from other management nodes if it does not have them."));
     $h .= helpTooltip('imagelibgrouphelp', i("This management node will try to get image files from other nodes in the selected group."));
     $h .= helpTooltip('imagelibuserhelp', i("userid to use for scp when copying image files from another management node"));
     $h .= helpTooltip('imagelibkeyhelp', i("path to ssh identity key file to use for scp when copying image files from another management node"));
     $h .= helpTooltip('ipconfighelp', i("Method by which public NIC on nodes controlled by this management node recive their network configuration <ul><li>Dynamic DHCP - nodes receive an address via DHCP from a pool of addresses</li><li>Manual DHCP - nodes always receive the same address via DHCP</li><li>Static - VCL will configure the public address of the node</li></ul>"));
     $h .= helpTooltip('netmaskhelp', i("Netmask for public NIC"));
     $h .= helpTooltip('gatewayhelp', i("IP address of gateway for public NIC"));
     $h .= helpTooltip('dnsserverhelp', i("comma delimited list of IP addresses of DNS servers for public network"));
     $h .= helpTooltip('availnetshelp', i("This is a list of IP networks, one per line, available to nodes deployed by this management node. Networks should be specified in x.x.x.x/yy form.  It is for deploying servers having a fixed IP address to ensure a node is selected that can actually be on the specified network."));
     $h .= helpTooltip('federatedauthhelp', i("Comma delimited list of affiliations for which user passwords are not set for Linux image reservations under this management node. Each Linux image is then required to have federated authentication set up so that users' passwords are passed along to the federated authentication system when a user attempts to log in. (for clarity, not set setting user passwords does not mean users have an empty password, but that a federated system must authenticate the users)"));
     $h .= helpTooltip('natpubliciphelp', i("message"));
     $h .= helpTooltip('natinternaliphelp', i("message 2"));
     $h .= "</div>\n";
     # tooltips
     return $h;
 }