\n";
print "The time you requested is in the past.";
print " Please select \"Now\" or use a time in the future. \n";
$submitErr = 1;
newReservation();
print getFooter();
return;
}
$nowfuture = "future";
}
if($data["ending"] == "length")
$end = $start + $data["length"] * 60 + $add;
else {
$end = datetimeToUnix($data["enddate"]);
if($end % (15 * 60))
$end = unixFloor15($end) + (15 * 60);
}
// get semaphore lock
if(! semLock())
abort(3);
$availablerc = isAvailable($images, $data["imageid"], $start, $end, $data["os"]);
$max = getMaxOverlap($user['id']);
if($availablerc != 0 && checkOverlap($start, $end, $max)) {
$printedHTMLheader = 1;
print $HTMLheader;
print "
New Reservation
\n";
if($max == 0) {
print "The time you requested overlaps with ";
print "another reservation you currently have. You are only allowed ";
print "to have a single reservation at any given time. Please select ";
print "another time to use the application. If you are finished with ";
print "an active reservation, click \"Current Reservations\", ";
print "then click the \"End\" button of your active reservation.";
print "
\n";
}
else {
print "The time you requested overlaps with ";
print "another reservation you currently have. You are allowed ";
print "to have $max overlapping reservations at any given time. ";
print "Please select another time to use the application. If you are ";
print "finished with an active reservation, click \"Current ";
print "Reservations\", then click the \"End\" button of your active ";
print "reservation.
\n";
}
$submitErr = 1;
newReservation();
print getFooter();
return;
}
// if user is owner of the image and there is a test version of the image
# available, ask user if production or test image desired
if($mode != "submitTestProd" && $showrevisions &&
$images[$data["imageid"]]["ownerid"] == $user["id"]) {
#unset($data["testprod"]);
$printedHTMLheader = 1;
print $HTMLheader;
print "
New Reservation
\n";
if($subimages) {
print "This is a cluster environment. At least one image in the ";
print "cluster has more than one version available. Please select ";
print "the version you desire for each image listed below: \n";
}
else {
print "There are multiple versions of this environment available. Please ";
print "select the version you would like to check out: \n";
}
print "\n";
print getFooter();
return;
}
if($availablerc == -1) {
$printedHTMLheader = 1;
print $HTMLheader;
print "
New Reservation
\n";
print "You have requested an environment that is limited in the number ";
print "of concurrent reservations that can be made. No further ";
print "reservations for the environment can be made for the time you ";
print "have selected. Please select another time to use the ";
print "environment. ";
addLogEntry($nowfuture, unixToDatetime($start),
unixToDatetime($end), 0, $data["imageid"]);
print getFooter();
}
elseif($availablerc > 0) {
$requestid = addRequest(0, $data["revisionid"]);
$time = prettyLength($data["length"]);
if($data["time"] == "now") {
$cdata = array('lengthchanged' => $data['lengthchanged']);
$cont = addContinuationsEntry('viewRequests', $cdata);
header("Location: " . BASEURL . SCRIPT . "?continuation=$cont");
dbDisconnect();
exit;
}
else {
if($data["minute"] == 0) {
$data["minute"] = "00";
}
$printedHTMLheader = 1;
print $HTMLheader;
print "
New Reservation
\n";
if($data["ending"] == "length") {
if($data['testjavascript'] == 0 && $data['lengthchanged']) {
print "NOTE: The maximum allowed reservation ";
print "length for this environment is $time, and the length of ";
print "this reservation has been adjusted accordingly.\n";
print "
\n";
}
print "Your request to use " . $images[$data["imageid"]]["prettyname"];
print " on " . prettyDatetime($start) . " for $time has been ";
print "accepted.
\n";
}
else {
print "Your request to use " . $images[$data["imageid"]]["prettyname"];
print " starting " . prettyDatetime($start) . " and ending ";
print prettyDatetime($end) . " has been accepted.
\n";
}
print "When your reservation time has been reached, the ";
print "Current Reservations page will have further ";
print "instructions on connecting to the reserved computer. If you ";
print "would like to modify your reservation, you can do that from ";
print "the Current Reservations page as well. \n";
print getFooter();
}
}
else {
$cdata = array('imageid' => $data['imageid'],
'length' => $data['length'],
'showmessage' => 1);
$cont = addContinuationsEntry('selectTimeTable', $cdata);
addLogEntry($nowfuture, unixToDatetime($start),
unixToDatetime($end), 0, $data["imageid"]);
header("Location: " . BASEURL . SCRIPT . "?continuation=$cont");
/*print "
New Reservation
\n";
print "The reservation you have requested is not available. You may ";
print "";
print "view a timetable of free and reserved times to find ";
print "a time that will work for you. \n";*/
}
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn blockRequest()
///
/// \brief prints a page for selecting block request stuff
///
////////////////////////////////////////////////////////////////////////////////
function blockRequest() {
print "
Block Reservation
\n";
print "\n";
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn newBlockRequest()
///
/// \brief prints form for submitting a new block request
///
////////////////////////////////////////////////////////////////////////////////
function newBlockRequest() {
global $submitErr, $user, $days;
$data = processBlockRequestInput(0);
if(! $submitErr) {
if($data['state'])
print "
Edit Block Reservation
\n";
else {
print "
New Block Reservation
\n";
$data['machinecnt'] = '';
}
}
else {
foreach($days as $day) {
if(in_array($day, $data['wdays']))
$data['wdayschecked'][$day] = 'checked';
}
}
print "\n";
printBlockRequestJavascript($data['available']);
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn selectEditBlockRequest()
///
/// \brief prints a page with summary info on each block request allowing one
/// to be select for editing
///
////////////////////////////////////////////////////////////////////////////////
function selectEditBlockRequest() {
global $user, $days;
$groups = getUserEditGroups($user['id']);
$groupids = implode(',', array_keys($groups));
$query = "SELECT b.id, "
. "b.name AS blockname, "
. "b.imageid, "
. "i.prettyname AS image, "
. "b.numMachines AS machinecnt, "
. "b.groupid as usergroupid, "
. "CONCAT(g.name, '@', a.name) AS `group`, "
. "b.admingroupid as admingroupid, "
. "CONCAT(ga.name, '@', aa.name) AS `admingroup`, "
. "b.repeating AS available "
. "FROM image i, "
. "usergroup g, "
. "affiliation a, "
. "blockRequest b "
. "LEFT JOIN usergroup ga ON (b.admingroupid = ga.id) "
. "LEFT JOIN affiliation aa ON (ga.affiliationid = aa.id) "
. "WHERE (b.ownerid = {$user['id']} ";
if(! empty($groupids))
$query .= "OR b.admingroupid IN ($groupids) ";
$query .= ") AND b.imageid = i.id AND "
. "b.groupid = g.id AND "
. "g.affiliationid = a.id "
. "ORDER BY b.name";
$qh = doQuery($query, 101);
while($row = mysql_fetch_assoc($qh)) {
$blockrequest[$row['id']] = $row;
$query2 = "SELECT DATE_FORMAT(start, '%c/%e/%y %l:%i %p') AS start1 "
. "FROM blockTimes "
. "WHERE blockRequestid = {$row['id']} "
. "ORDER BY start "
. "LIMIT 1";
$qh2 = doQuery($query2, 101);
if($row2 = mysql_fetch_assoc($qh2))
$blockrequest[$row['id']]['nextstart'] = $row2['start1'];
else
$blockrequest[$row['id']]['nextstart'] = "none found";
}
print "
\n";
if(requestIsReady($requests[$i])) {
$connect = 1;
# request is ready, print Connect! and End buttons
$cdata = array('requestid' => $requests[$i]['id']);
$text .= "
\n";
$text .= " \n";
$text .= "
\n";
if($requests[$i]['forimaging']) {
# this is the imaging case, need to do sanity check here for if the request
# state currstateid or laststateid are "inuse", otherwise disable out the
# create image button
$noedit = 1;
$text .= "
\n";
if($requests[$i]['currstateid'] == 8 || $requests[$i]['laststateid'] == 8) {
# the user has connected successfully so we will allow create image button
# to be displayed
$text .= " \n";
}
$text .= "
\n";
if(! empty($normal)) {
if(! empty($imaging) || ! empty($long))
$text .= "You currently have the following normal reservations: \n";
else
$text .= "You currently have the following normal reservations: \n";
if($lengthchanged) {
$text .= "NOTE: The maximum allowed reservation ";
$text .= "length for one of these reservations was less than the ";
$text .= "length you submitted, and the length of that reservation ";
$text .= "has been adjusted accordingly.\n";
}
$text .= "
\n";
}
if(! empty($long)) {
if(! empty($normal) || ! empty($imaging))
$text .= "\n";
$text .= "You currently have the following long term reservations: \n";
$text .= "
Click the ";
$text .= "Connect! button to get further ";
$text .= "information about connecting to the reserved system. You must ";
$text .= "click the button from a web browser running on the same computer ";
$text .= "from which you will be connecting to the remote computer; ";
$text .= "otherwise, you may be denied access to the machine.\n";
}
if($refresh) {
$text .= "
This page will automatically update ";
$text .= "every 20 seconds until the Pending...";
#$text .= " reservation is ready.
An error has occurred that has kept one of your reservations ";
$text .= "from being processed. We apologize for any inconvenience ";
$text .= "this may have caused.\n";
if(! $refresh) {
$cont = addContinuationsEntry('AJviewRequests', $cdata, SECINDAY);
$text .= "\n";
}
}
if(empty($normal) && empty($imaging) && empty($long))
$text .= "You have no current reservations. \n";
$text .= "\n";
if($mode != 'AJviewRequests') {
if($refresh || $failed) {
$text .= "
\n";
$text .= "dojo.addOnLoad(showScriptOnly);\n";
$text .= "dojo.byId('resStatusPane').title = \"Detailed Reservation Status\";\n";
$text .= "\n";
}
print $text;
}
else {
$text = str_replace("\n", ' ', $text);
if($refresh)
print "refresh_timer = setTimeout(resRefresh, 20000);\n";
print(setAttribute('subcontent', 'innerHTML', $text));
print "AJdojoCreate('subcontent');";
if($incPaneDetails) {
$text = detailStatusHTML($refreqid);
print(setAttribute('resStatusText', 'innerHTML', $text));
}
dbDisconnect();
exit;
}
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn detailStatusHTML($reqid)
///
/// \param $reqid - a request id
///
/// \return html text showing detailed status from computerloadlog for specified
/// request
///
/// \brief gathers information about the state flow for $reqid and formats it
/// nicely for a user to view
///
////////////////////////////////////////////////////////////////////////////////
function detailStatusHTML($reqid) {
$requests = getUserRequests("all");
$found = 0;
foreach($requests as $request) {
if($request['id'] == $reqid) {
$found = 1;
break;
}
}
if(! $found) {
$text = "The selected reservation is no longer available. Go to ";
$text .= "New ";
$text .= "Reservations to request a new reservation or ";
$text .= "select another one that is available.";
return $text;
}
if($request['imageid'] == $request['compimageid'])
$nowreq = 1;
else
$nowreq = 0;
$flow = getCompStateFlow($request['computerid']);
# cluster reservations not supported here yet
if(empty($flow) || count($request['reservations']) > 0) {
$noinfo = "No detailed loading information is available for this ";
$noinfo .= "reservation.";
return $noinfo;
}
$logdata = getCompLoadLog($request['resid']);
# determine an estimated load time for the image
$imgLoadTime = getImageLoadEstimate($request['imageid']);
if($imgLoadTime == 0) {
$images = getImages(0, $request['imageid']);
$imgLoadTime = $images[$request['imageid']]['reloadtime'] * 60;
}
$time = 0;
$now = time();
$text = "
";
$text .= "
";
$text .= "
State
";
$text .= "
Est/Act Time
";
$text .= "
Total Time
";
$text .= "
";
$slash = "/";
$total = 0;
$id = "";
$last = array();
$logstateids = array();
$skippedstates = array();
# loop through all states in the log data
foreach($logdata as $data) {
# keep track of the states in the log data
array_push($logstateids, $data['loadstateid']);
# keep track of any skipped states
if(! empty($last) &&
$last['loadstateid'] != $flow['repeatid'] &&
$data['loadstateid'] != $flow['data'][$last['loadstateid']]['nextstateid']) {
array_push($skippedstates, $flow['data'][$last['loadstateid']]['nextstateid']);
}
// if we reach a repeat state, include a message about having to go back
if($data['loadstateid'] == $flow['repeatid']) {
if(empty($id))
return $noinfo;
$text .= "
";
$text .= "
problem at state ";
$text .= "\"{$flow['data'][$id]['nextstate']}\"";
$query = "SELECT additionalinfo "
. "FROM computerloadlog "
. "WHERE loadstateid = {$flow['repeatid']} AND "
. "reservationid = {$request['resid']} AND "
. "timestamp = '" . unixToDatetime($data['ts']) . "'";
$qh = doQuery($query, 101);
if($row = mysql_fetch_assoc($qh)) {
$reason = $row['additionalinfo'];
$text .= " retrying at state \"$reason\"";
}
$text .= "
";
$total += $data['time'];
$last = $data;
continue;
}
$id = $data['loadstateid'];
// if in post config state, compute estimated time for the state
if($flow['data'][$id]['statename'] == 'loadimagecomplete') {
$addtime = 0;
foreach($skippedstates as $stateid)
$addtime += $flow['data'][$stateid]['statetime'];
# this state's time is (avg image load time - all other states time +
# state time for any skipped states)
$tmp = $imgLoadTime - $flow['totaltime'] + $addtime;
if($tmp < 0)
$flow['data'][$id]['statetime'] = 0;
else
$flow['data'][$id]['statetime'] = $tmp;
}
$total += $data['time'];
$text .= "
";
$last = $data;
}
# $id will be set if there was log data, use the first state in the flow
# if it isn't set
if(! empty($id))
$id = $flow['nextstates'][$id];
else
$id = $flow['stateids'][0];
# determine any skipped states
$matchingstates = array();
foreach($flow['stateids'] as $stateid) {
if($stateid == $id)
break;
array_push($matchingstates, $stateid);
}
$skippedstates = array_diff($matchingstates, $logstateids);
$addtime = 0;
foreach($skippedstates as $stateid)
$addtime += $flow['data'][$stateid]['statetime'];
$first = 1;
$count = 0;
# loop through the states in the flow that haven't been reached yet
# $count is included to protect against an infinite loop
while(! is_null($id) && $count < 100) {
$count++;
// if in post config state, compute estimated time for the state
if($flow['data'][$id]['statename'] == 'loadimagecomplete') {
# this state's time is (avg image load time - all other states time +
# state time for any skipped states)
$tmp = $imgLoadTime - $flow['totaltime'] + $addtime;
if($tmp < 0)
$flow['data'][$id]['statetime'] = 0;
else
$flow['data'][$id]['statetime'] = $tmp;
}
// if first time through this loop, this is the current state
if($first) {
// if request has failed, it was during this state, get reason
if($request['currstateid'] == 5) {
$query = "SELECT additionalInfo, "
. "UNIX_TIMESTAMP(timestamp) AS ts "
. "FROM computerloadlog "
. "WHERE loadstateid = (SELECT id "
. "FROM computerloadstate "
. "WHERE loadstatename = 'failed') AND "
. "reservationid = {$request['resid']} "
. "ORDER BY id "
. "LIMIT 1";
$qh = doQuery($query, 101);
if($row = mysql_fetch_assoc($qh)) {
$reason = $row['additionalInfo'];
if(! empty($data))
$currtime = $row['ts'] - $data['ts'];
else
$currtime = $row['ts'] -
datetimeToUnix($request['daterequested']);
}
else {
$text = "No detailed information is available for this ";
$text .= "reservation.";
return $text;
}
$text .= "
\n";
foreach($request["reservations"] as $res) {
print "
\n";
print "
Image:
\n";
print "
{$res["prettyimage"]}
\n";
print "
\n";
print "
\n";
print "
Hostname:
\n";
print "
{$res["hostname"]}
\n";
print "
\n";
print "
\n";
print "
IP Address:
\n";
print "
{$res["reservedIP"]}
\n";
print "
\n";
}
print "
\n";
}
print "
\n";
print "
\n";
/*print "
\n";
print " \n";
print "
\n";*/
print "
\n";
print " \n";
print "
\n";
print "
\n";
print "
\n";
print "
\n";
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn editRequest()
///
/// \brief prints a page for a user to edit a previous request
///
////////////////////////////////////////////////////////////////////////////////
function editRequest() {
global $submitErr, $user;
$requestid = getContinuationVar('requestid', 0);
$request = getRequestInfo($requestid);
if(! array_key_exists("stateid", $request)) {
viewRequests();
return;
}
if($request['forimaging'])
$reservation = $request['reservations'][0];
else {
foreach($request["reservations"] as $res) {
if($res["forcheckout"]) {
$reservation = $res;
break;
}
}
}
if($submitErr) {
$data = processRequestInput(0);
}
$groupid = getUserGroupID('Specify End Time', 1);
$members = getUserGroupMembers($groupid);
if(array_key_exists($user['id'], $members))
$openend = 1;
else
$openend = 0;
$unixstart = datetimeToUnix($request["start"]);
$unixend = datetimeToUnix($request["end"]);
$maxtimes = getUserMaxTimes("initialmaxtime");
$timeToNext = timeToNextReservation($request);
print "
Modify Reservation
\n";
$now = time();
if($unixstart > $now)
$started = 0;
else {
# \todo if $timeToNext is anything < 30, try moving reservations off until it is >= 30
if($timeToNext == 0) {
$movedall = 1;
foreach($request["reservations"] as $res) {
if(! moveReservationsOffComputer($res["computerid"], 1)) {
$movedall = 0;
break;
}
}
if(! $movedall) {
// cannot extend the reservation unless we move the next one to another computer
print "The computer you are using has another reservation ";
print "immediately following yours. Therefore, you cannot extend ";
print "your reservation because it would overlap with the next ";
print "one. \n";
return;
}
$timeToNext = timeToNextReservation($request);
}
$started = 1;
print "Because this reservation has already started, you can only ";
print "extend the length of the reservation. ";
if(! $openend) {
print "If there are no reservations following yours, ";
print "you can extend your reservation ";
print "by up to " . minToHourMin($maxtimes["extend"]) . ", but not ";
print "exceeding " . minToHourMin($maxtimes["total"]) . " for your ";
print "total reservation time.
\n";
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn adminEditRequest()
///
/// \brief prints a page for an admin to edit a user's request
///
////////////////////////////////////////////////////////////////////////////////
/*function adminEditRequest() {
$requestid = processInputVar("requestid", ARG_NUMERIC);
$request = getRequestInfo($requestid);
foreach($request["reservations"] as $res) {
if($res["forcheckout"]) {
$reservation = $res;
break;
}
}
$userinfo = getUserInfo($request["userid"]);
$images = getImages();
$unixstart = datetimeToUnix($request["start"]);
print "
Modify Reservation
\n";
if($unixstart > time()) {
$started = 0;
}
else {
$started = 1;
print "Because this reservation has already started, you can only ";
print "modify the end time of the reservation. You will only be able ";
print "to extend the length if the computer the reservation is on ";
print "has time available before the next reservation.
\n";
}*/
////////////////////////////////////////////////////////////////////////////////
///
/// \fn submitEditRequest()
///
/// \brief submits changes to a request and prints that it has been changed
///
////////////////////////////////////////////////////////////////////////////////
function submitEditRequest() {
global $user, $submitErr, $viewmode, $mode;
$data = getContinuationVar();
$request = getRequestInfo($data["requestid"]);
print "
Modify Reservation
\n";
$hour = $data["hour"];
if($data["hour"] == 12) {
if($data["meridian"] == "am") {
$hour = 0;
}
}
elseif($data["meridian"] == "pm") {
$hour = $data["hour"] + 12;
}
$tmp = explode('/', $data["day"]);
$start = mktime($hour, $data["minute"], "0", $tmp[0], $tmp[1], $tmp[2]);
if($data['openend'] && $data['ending'] == 'date')
$end = datetimeToUnix($data['enddate']);
else {
if(datetimeToUnix($request["start"]) < datetimeToUnix($request["daterequested"]))
$end = $start + $data["length"] * 60 + 900;
else
$end = $start + $data["length"] * 60;
}
// get semaphore lock
if(! semLock())
abort(3);
$max = getMaxOverlap($user['id']);
if(checkOverlap($start, $end, $max, $data["requestid"])) {
if($max == 0) {
print "The time you requested overlaps with ";
print "another reservation you currently have. You are only allowed ";
print "to have a single reservation at any given time. Please select ";
print "another time to use the application.
\n";
}
else {
print "The time you requested overlaps with ";
print "another reservation you currently have. You are allowed ";
print "to have $max overlapping reservations at any given time. ";
print "Please select another time to use the application. ";
print " \n";
}
$submitErr = 1;
editRequest();
return;
}
$rc = isAvailable(getImages(), $data["imageid"], $start, $end, $data["os"], $data["requestid"]);
if($rc == -1) {
print "You have requested an environment that is limited in the number ";
print "of concurrent reservations that can be made. No further ";
print "reservations for the environment can be made for the time you ";
print "have selected. Please select another time to use the ";
print "environment. ";
addChangeLogEntry($request["logid"], NULL, unixToDatetime($end),
unixToDatetime($start), NULL, NULL, 0);
}
elseif($rc > 0) {
updateRequest($data["requestid"]);
if($data["started"]) {
if($data['openend'] && $data['ending'] == 'date') {
print "Your request to change the ending of your reservation for ";
print "{$data["prettyimage"]} to {$data['enddate']} ";
print "has been accepted.
\n";
}
else {
$remaining = ($end - time()) / 60;
print "Your request to extend your reservation for ";
print "{$data["prettyimage"]} by " . prettyLength($data["extend"]);
print " has been accepted.
\n";
print "You now have " . prettyLength($remaining) . " remaining for ";
print "your reservation \n";
}
}
else {
print "Your request to use " . $data["prettyimage"] . " on ";
if(datetimeToUnix($request["start"]) <
datetimeToUnix($request["daterequested"])) {
print prettyDatetime($request["daterequested"]);
}
else
print prettyDatetime($start);
if($data['openend'] && $data['ending'] == 'date')
print " until " . prettyDatetime($end);
else
print " for " . prettyLength($data["length"]);
print " has been accepted. \n";
}
}
else {
$cdata = array('imageid' => $data['imageid'],
'length' => $data['length'],
'requestid' => $data['requestid']);
$cont = addContinuationsEntry('selectTimeTable', $cdata);
print "The time you have requested is not available. You may ";
print "";
print "view a timetable of free and reserved times to find ";
print "a time that will work for you. \n";
addChangeLogEntry($request["logid"], NULL, unixToDatetime($end),
unixToDatetime($start), NULL, NULL, 0);
}
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn submitAdminEditRequest()
///
/// \brief submits changes to a request and prints that it has been changed
///
////////////////////////////////////////////////////////////////////////////////
/*function submitAdminEditRequest() {
$data = processRequestInput(0);
$request = getRequestInfo($data["requestid"]);
$userinfo = getUserInfo($request["userid"]);
$images = getImages();
print "
\n";
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn confirmDeleteRequestProduction($request)
///
/// \param $request - a request array as returend from getRequestInfo
///
/// \brief prints a page asking if the user is ready to make the image
/// production or just end this reservation
///
////////////////////////////////////////////////////////////////////////////////
function confirmDeleteRequestProduction($request) {
$cdata = array('requestid' => $request['id']);
print "
End Reservation/Make Production
\n";
print "Are you satisfied that this environment is ready to be made production ";
print "and replace the current production version, or would you just like to ";
print "end this reservation and test it again later?\n";
print "
\n";
$cont = addContinuationsEntry('setImageProduction', $cdata, SECINDAY, 0, 1);
print " Make this the production version \n";
$cont = addContinuationsEntry('submitDeleteRequest', $cdata, SECINDAY, 0, 0);
print " Just end the reservation \n";
$cont = addContinuationsEntry('viewRequests');
print " Neither, go back to Current Reservations";
print "
\n";
print "\n";
print "
\n";
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn submitDeleteRequest()
///
/// \brief submits deleting a request and prints that it has been deleted
///
////////////////////////////////////////////////////////////////////////////////
function submitDeleteRequest() {
$requestid = getContinuationVar('requestid', 0);
$request = getRequestInfo($requestid);
if($request['forimaging'])
$reservation = $request['reservations'][0];
else {
foreach($request["reservations"] as $res) {
if($res["forcheckout"]) {
$reservation = $res;
break;
}
}
}
deleteRequest($request);
if(datetimeToUnix($request["start"]) > time()) {
print "
Delete Reservation
";
print "The reservation for " . $reservation["prettyimage"];
print " starting " . prettyDatetime($request["start"]);
print " has been deleted. \n";
}
else {
print "
End Reservation
";
print "The reservation for " . $reservation["prettyimage"];
print " starting ";
if(datetimeToUnix($request["start"]) <
datetimeToUnix($request["daterequested"])) {
print prettyDatetime($request["daterequested"]);
}
else {
print prettyDatetime($request["start"]);
}
print " has been released. \n";
}
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn printReserveItems($modifystart, $day, $hour, $minute,
/// $meridian, $length, $oneline, $nolength)
///
/// \param $modifystart - (optional) 1 to print form for modifying start time,
/// 0 not to
/// \param $day - (optional) initial day of week (Sunday - Saturday)
/// \param $hour - (optional) initial hour (1-12)
/// \param $minute - (optional) initial minute (00-59)
/// \param $meridian - (optional) initial meridian (am/pm)
/// \param $length - (optional) initial length (in minutes)
/// \param $oneline - (optional) print all items on one line
/// \param $nolength - (optional) 0 to print length, 1 not to
///
/// \brief prints reserve form data
///
////////////////////////////////////////////////////////////////////////////////
function printReserveItems($modifystart=1, $day=NULL, $hour=NULL, $minute=NULL,
$meridian=NULL, $length=60, $oneline=0, $nolength=0) {
global $user;
$enddate = processInputVar("enddate", ARG_STRING);
$groupid = getUserGroupID('Specify End Time', 1);
$members = getUserGroupMembers($groupid);
if(array_key_exists($user['id'], $members))
$openend = 1;
else
$openend = 0;
$days = array();
$inputday = "";
for($cur = time(), $end = $cur + DAYSAHEAD * SECINDAY;
$cur < $end;
$cur += SECINDAY) {
$tmp = getdate($cur);
$index = $tmp["mon"] . "/" . $tmp["mday"] . "/" . $tmp["year"];
$days[$index] = $tmp["weekday"];
if($tmp["weekday"] == $day) {
$inputday = $index;
}
}
if($modifystart) {
printSelectInput("day", $days, $inputday);
print " At \n";
$tmpArr = array();
for($i = 1; $i < 13; $i++) {
$tmpArr[$i] = $i;
}
printSelectInput("hour", $tmpArr, $hour);
$minutes = array("zero" => "00",
"15" => "15",
"30" => "30",
"45" => "45");
printSelectInput("minute", $minutes, $minute);
printSelectInput("meridian", array("am" => "a.m.", "pm" => "p.m."), $meridian);
print "(Eastern Time Zone)";
//if(! $oneline)
print "
";
/*else
print " ";*/
if(! $nolength) {
if($openend) {
print " ";
}
print "Duration: \n";
}
}
else {
print "\n";
print "\n";
print "\n";
print "\n";
}
// check for a "now" reservation that got 15 min added to it
if($length % 30) {
$length -= 15;
}
// if ! $modifystart, we return at this point because we don't
# know enough about the current reservation to determine how
# long they can extend it for, the calling function would have
# to determine that and print a length dropdown box
if(! $modifystart)
return;
# create an array of usage times based on the user's max times
$maxtimes = getUserMaxTimes("initialmaxtime");
$lengths = array();
if($maxtimes["initial"] >= 30)
$lengths["30"] = "30 minutes";
if($maxtimes["initial"] >= 60)
$lengths["60"] = "1 hour";
for($i = 120; $i <= $maxtimes["initial"]; $i += 120) {
$lengths[$i] = $i / 60 . " hours";
}
if($nolength)
print "Reservation will be for 8 hours \n";
else {
printSelectInput("length", $lengths, $length, 0, 0, 'reqlength', "onChange='updateWaitTime(0);'");
print " \n";
if($openend) {
print " Until\n";
print "(YYYY-MM-DD HH:MM:SS)\n";
printSubmitErr(ENDDATEERR);
print " \n";
}
}
}
////////////////////////////////////////////////////////////////////////////////
///
/// \fn connectRequest()
///
/// \brief sets IPaddress for the request; tells the user how to connect
///
////////////////////////////////////////////////////////////////////////////////
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 "
Connect!
\n";
if($requestData['forimaging']) {
print "NOTICE: Later in this process, you must accept a
click-through agreement about software licensing.
\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 Connect! 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 Connect! 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.
\n";
print "Use the following information when you are ready to connect: \n";
print "
\n";
print "NOTE: The given password is for this reservation ";
print "only. You will be given a different password for any other ";
print "reservations. \n";
}
else {
print "
Password: (use your campus password)
\n";
print "\n";
}
/*print " \n";
print "
\n";
print "
NEW!
\n";
print "Connect to the server using a java applet: \n";
print "\n";
print "\n";
print "\n";
print "
\n";*/
print "For automatic connection, you can download an RDP file that can ";
print "be opened by the Remote Desktop Connection program.
\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 Connect! button from the computer you will ";
print "need to cancel this reservation, request a new one, and ";
print "make sure you click the Connect! 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.
\n";
print "Use the following information when you are ready to connect: \n";
print "
\n";
print "NOTE: The given password is for this reservation ";
print "only. You will be given a different password for any other ";
print "reservations. \n";
}
else {
print "
Password: (use your campus password)
\n";
print "\n";
}
print "NOTE: You cannot use the Windows Remote ";
print "Desktop Connection to connect to this computer. You must use an ";
print "ssh client.\n";
/*if(eregi("windows", $_SERVER["HTTP_USER_AGENT"])) {
print "
NEW!
\n";
print "Connect to the server using a java applet: \n";
print "
\n";
print "\n";
print "\n";
print "\n";
print "
\n";
}*/
}
}
else {
print "You will need an ";
print "ssh client to connect to any unix systems. \n";
print "You will need a ";
print "Remote Desktop program to connect to any windows systems.
\n";
print "Use the following information when you are ready to connect: \n";
$total = count($requestData["reservations"]);
$count = 0;
foreach($requestData["reservations"] as $key => $res) {
$count++;
print "
\n";
print "NOTE: The given password is for this reservation ";
print "only. You will be given a different password for any other ";
print "reservations. \n";
}
else {
print "
Password: (use your campus password)
\n";
print "\n";
}
/*print "Connect to the server using a java applet: \n";
print "\n";
print "\n";
print "\n";
print "\n";
print "
\n";*/
print "Automatic connection using an RDP file: \n";
print "
\n";
print "\n";
print "NOTE: The given password is for this reservation ";
print "only. You will be given a different password for any other ";
print "reservations. \n";
}
else {
print "
Password: (use your campus password)
\n";
print "\n";
}
/*if(eregi("windows", $_SERVER["HTTP_USER_AGENT"])) {
print "Connect to the server using a java applet: \n";
print "