function detailStatusHTML($reqid) { $requests = getUserRequests("all"); $found = 0; foreach ($requests as $request) { if ($request['id'] == $reqid) { $found = 1; break; } } if (!$found) { $text = i("The selected reservation is no longer available. You can request a new reservation or select another one that is available."); return $text; } if ($request['currstateid'] == 11 || $request['currstateid'] == 12 && $request['laststateid'] == 11) { return "<br><span class=\"rederrormsg\">" . i("The selected reservation has timed out and is no longer available.") . "</span>"; } if ($request['imageid'] == $request['compimageid']) { $nowreq = 1; } else { $nowreq = 0; } $flow = getCompStateFlow($request['computerid']); # cluster reservations not supported here yet # info on reboots/reinstalls not available yet if (empty($flow) || count($request['reservations']) > 0 || $request['currstateid'] == 14 && $request['laststateid'] == 26 || $request['currstateid'] == 14 && $request['laststateid'] == 24 || $request['currstateid'] == 14 && $request['laststateid'] == 28) { $noinfo = i("No detailed loading information is available for this 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 = "<table summary=\"displays a list of states the reservation must " . "go through to become ready and how long each state will take or " . "has already taken\" id=resStatusTable>"; $text .= "<colgroup>"; $text .= "<col class=resStatusColState />"; $text .= "<col class=resStatusColEst />"; $text .= "<col class=resStatusColTotal />"; $text .= "</colgroup>"; $text .= "<tr>"; $text .= "<th align=right><br>" . i("State") . "</th>"; $text .= "<th>Est/Act<br>" . i("Time") . "</th>"; $text .= "<th>Total<br>" . i("Time") . "</th>"; $text .= "</tr>"; $slash = "<font color=black>/</font>"; $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 .= "<tr>"; $text .= "<td colspan=3><hr>" . i("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 .= "<br>" . i("retrying at state") . " \"{$reason}\""; } $text .= "<hr></td></tr>"; $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 .= "<tr>"; $text .= "<td nowrap align=right><font color=green>"; $text .= i($flow['data'][$id]['state']) . "({$id})</font></td>"; $text .= "<td nowrap align=center><font color=green>"; $text .= secToMinSec($flow['data'][$id]['statetime']) . $slash; $text .= secToMinSec($data['time']) . "</font></td>"; $text .= "<td nowrap align=center><font color=green>"; $text .= secToMinSec($total) . "</font></td>"; $text .= "</tr>"; $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 = i("No detailed information is available for this reservation."); return $text; } $text .= "<tr>"; $text .= "<td nowrap align=right><font color=red>"; $text .= i($flow['data'][$id]['state']) . "({$id})</font></td>"; $text .= "<td nowrap align=center><font color=red>"; $text .= secToMinSec($flow['data'][$id]['statetime']); $text .= $slash . secToMinSec($currtime) . "</font></td>"; $text .= "<td nowrap align=center><font color=red>"; $text .= secToMinSec($total + $currtime) . "</font></td>"; $text .= "</tr>"; $text .= "</table>"; if (strlen($reason)) { $text .= "<br><font color=red>" . i("failed:") . " {$reason}</font>"; } return $text; } else { if (!empty($data)) { $currtime = $now - $data['ts']; } else { $currtime = $now - datetimeToUnix($request['daterequested']); } $text .= "<td nowrap align=right><font color=#CC8500>"; $text .= i($flow['data'][$id]['state']) . "({$id})</font></td>"; $text .= "<td nowrap align=center><font color=#CC8500>"; $text .= secToMinSec($flow['data'][$id]['statetime']); $text .= $slash . secToMinSec($currtime) . "</font></td>"; $text .= "<td nowrap align=center><font color=#CC8500>"; $text .= secToMinSec($total + $currtime) . "</font></td>"; $text .= "</tr>"; $first = 0; } } else { $text .= "<td nowrap align=right>"; $text .= i($flow['data'][$id]['state']) . "({$id})</td>"; $text .= "<td nowrap align=center>"; $text .= secToMinSec($flow['data'][$id]['statetime']) . "</td>"; $text .= "<td></td>"; $text .= "</tr>"; } $id = $flow['nextstates'][$id]; } $text .= "</table>"; return $text; }
function getNavMenu($inclogout, $inchome, $homeurl = HOMEURL) { global $user, $docreaders, $authed, $mode; if ($authed && $mode != 'expiredemouser') { $computermetadata = getUserComputerMetaData(); $requests = getUserRequests("all", $user["id"]); } else { $computermetadata = array("platforms" => array(), "schedules" => array()); } $rt = ''; if ($inchome) { $rt .= menulistLI('home'); $rt .= "<a href=\"{$homeurl}\">" . i("HOME") . "</a></li>\n"; } $rt .= menulistLI('reservations'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=viewRequests\">"; $rt .= i("Reservations") . "</a></li>\n"; #$rt .= menulistLI('config'); #$rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=config\">"; #$rt .= i("Manage Configs") . "</a></li>\n"; $rt .= menulistLI('blockAllocations'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=blockAllocations\">"; $rt .= i("Block Allocations") . "</a></li>\n"; $rt .= menulistLI('userPreferences'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=userpreferences\">"; $rt .= i("User Preferences") . "</a></li>\n"; if (in_array("groupAdmin", $user["privileges"])) { $rt .= menulistLI('manageGroups'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=viewGroups\">"; $rt .= i("Manage Groups") . "</a></li>\n"; } if (in_array("imageAdmin", $user["privileges"])) { $rt .= menulistLI('image'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=image\">"; $rt .= i("Manage Images") . "</a></li>\n"; } if (in_array("scheduleAdmin", $user["privileges"])) { $rt .= menulistLI('schedule'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=schedule\">"; $rt .= i("Manage Schedules") . "</a></li>\n"; } if (in_array("computerAdmin", $user["privileges"])) { $rt .= menulistLI('computer'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=computer\">"; $rt .= i("Manage Computers") . "</a></li>\n"; } if (in_array("mgmtNodeAdmin", $user["privileges"])) { $rt .= menulistLI('managementnode'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=managementnode\">"; $rt .= i("Management Nodes") . "</a></li>\n"; } if (in_array("serverProfileAdmin", $user["privileges"]) || in_array("serverCheckOut", $user["privileges"])) { $rt .= menulistLI('serverProfiles'); $rt .= "<a href=\"" . BASEURL . SCRIPT; $rt .= "?mode=serverProfiles\">" . i("Server Profiles") . "</a></li>\n"; } if (count($computermetadata["platforms"]) && count($computermetadata["schedules"])) { $rt .= menulistLI('timeTable'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=pickTimeTable\">"; $rt .= i("View Time Table") . "</a></li>\n"; } if (in_array("userGrant", $user["privileges"]) || in_array("resourceGrant", $user["privileges"]) || in_array("nodeAdmin", $user["privileges"])) { $rt .= menulistLI('privileges'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=viewNodes\">"; $rt .= i("Privileges") . "</a></li>\n"; } if (checkUserHasPerm('User Lookup (global)') || checkUserHasPerm('User Lookup (affiliation only)')) { $rt .= menulistLI('userLookup'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=userLookup\">"; $rt .= i("User Lookup") . "</a></li>\n"; } if (in_array("computerAdmin", $user["privileges"])) { $rt .= menulistLI('vm'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=editVMInfo\">"; $rt .= i("Virtual Hosts") . "</a></li>\n"; } if (checkUserHasPerm('Schedule Site Maintenance')) { $rt .= menulistLI('sitemaintenance'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=siteMaintenance\">"; $rt .= i("Site Maintenance") . "</a></li>\n"; } $rt .= menulistLI('statistics'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=selectstats\">"; $rt .= i("Statistics") . "</a></li>\n"; if (checkUserHasPerm('View Dashboard (global)') || checkUserHasPerm('View Dashboard (affiliation only)')) { $rt .= menulistLI('dashboard'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=dashboard\">"; $rt .= i("Dashboard") . "</a></li>\n"; } if (checkUserHasPerm('Site Configuration (global)') || checkUserHasPerm('Site Configuration (affiliation only)')) { $rt .= menulistLI('siteconfig'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=siteconfig\">"; $rt .= i("Site Configuration") . "</a></li>\n"; } $rt .= menulistLI('codeDocumentation'); $rt .= "<a href=\"" . DOCUMENTATIONURL . "\">"; $rt .= i("Documentation") . "</a></li>\n"; if ($inclogout) { $rt .= menulistLI('authentication'); $rt .= "<a href=\"" . BASEURL . SCRIPT . "?mode=logout\">"; $rt .= i("Logout") . "</a></li>\n"; } return $rt; }
function printHTMLHeader() { global $mode, $user, $authed, $oldmode, $viewmode, $HTMLheader; global $printedHTMLheader, $docreaders, $skin, $noHTMLwrappers, $actions; if ($printedHTMLheader) { return; } $refresh = 0; if ($authed && $mode == "viewRequests") { $requests = getUserRequests("all", $user["id"]); if ($count = count($requests)) { $now = time() + 15 * 60; for ($i = 0; $i < $count; $i++) { if (datetimeToUnix($requests[$i]["start"]) < $now && ($requests[$i]["currstateid"] == 13 || $requests[$i]["currstateid"] == 14 && $requests[$i]["laststateid"] == 13 || $requests[$i]["currstateid"] == 3)) { $refresh = 1; } } } } if ($mode != 'selectauth' && $mode != 'submitLogin') { $HTMLheader .= getHeader($refresh); } if (!in_array($mode, $noHTMLwrappers)) { print $HTMLheader; $printedHTMLheader = 1; } }
//$dataResultSet=$rm->getAllDetails('user_details_t'); if (mysql_num_rows($dataResultSet) > 0) { while ($row = mysql_fetch_array($dataResultSet)) { $getUserRequestsFields['user_request_id'] = $row['user_request_id']; $getUserRequestsFields['payment_from_bank_id'] = $row['payment_from_bank_id']; $getUserRequestsFields['loginID'] = $row['login_user_id']; $getUserRequestsFields['payment_to_bank_id'] = $row['payment_to_bank_id']; //$getUserRequestsFields['payment_date']=$row['payment_date']; $getUserRequestsFields['fBank'] = $rm->idToValue('bank_name', 'bank_details_t', 'bank_id', $row['payment_from_bank_id']); $getUserRequestsFields['tBank'] = $rm->idToValue('bank_name', 'bank_details_t', 'bank_id', $row['payment_to_bank_id']); //$getUserRequestsFields['payment_reason']=$row['payment_reason']; $getUserRequestsFields['amount'] = $row['amount']; $getUserRequestsFields['payment_type'] = $row['payment_type']; $cdate = $row['request_created_date']; $getUserRequestsFields['request_created_date'] = date('Y/m/d', strtotime($cdate)); $getUserRequestsFields['request_created_time'] = date('H:i:s', strtotime($cdate)); $getUserRequestsFields['status'] = $row['status']; if ($row['status'] == 'Accepted') { $getUserRequestsFields['payment_id'] = $rm->idToValue('payment_id', 'payment_details_t', 'user_request_id', $row['user_request_id']); } array_push($userRequestsDetailsArray, $getUserRequestsFields); } $result = $rm->get_anything_details_success($userRequestsDetailsArray, 'User Request'); return $result; } else { $result = $rm->get_anything_details_fail('User Request'); return $result; } } echo getUserRequests();
function processUserPrefsInput($checks = 1) { global $submitErr, $submitErrMsg, $user; $return = array(); $defaultres = $user["width"] . 'x' . $user["height"]; $return["preferredname"] = processInputVar("preferredname", ARG_STRING, $user["preferredname"]); $return["resolution"] = processInputVar("resolution", ARG_STRING, $defaultres); $return["bpp"] = processInputVar("bpp", ARG_NUMERIC, $user["bpp"]); $return["audiomode"] = processInputVar("audiomode", ARG_STRING, $user["audiomode"]); $return["mapdrives"] = processInputVar("mapdrives", ARG_NUMERIC, $user["mapdrives"]); $return["mapprinters"] = processInputVar("mapprinters", ARG_NUMERIC, $user["mapprinters"]); $return["mapserial"] = processInputVar("mapserial", ARG_NUMERIC, $user["mapserial"]); $return["rdpport"] = processInputVar("rdpport", ARG_NUMERIC, 3389); if (!$checks) { return $return; } if (strlen($return["preferredname"]) > 25) { $submitErr |= PREFNAMEERR; $submitErrMsg[PREFNAMEERR] = i("Preferred name can only be up to 25 characters"); } if (!preg_match('/^[a-zA-Z ]*$/', $return["preferredname"])) { $submitErr |= PREFNAMEERR; $submitErrMsg[PREFNAMEERR] = i("Preferred name can only contain letters and spaces"); } if ($user['affiliation'] == 'Local' && array_key_exists('newpassword', $_POST)) { $return['newpassword'] = $_POST['newpassword']; $confirmpwd = $_POST['confirmpassword']; $curr = $_POST['currentpassword']; if (get_magic_quotes_gpc()) { $return['newpassword'] = stripslashes($return['newpassword']); $confirmpwd = stripslashes($confirmpwd); $curr = stripslashes($curr); } if (!empty($return['newpassword']) && !empty($confirmpwd) && !validateLocalAccount($user['unityid'], $curr)) { $submitErr |= LOCALPASSWORDERR; $submitErrMsg[LOCALPASSWORDERR] = i("Password incorrect"); } elseif (empty($return['newpassword']) && !empty($confirmpwd) || !empty($return['newpassword']) && empty($confirmpwd) || $return['newpassword'] != $confirmpwd) { $submitErr |= LOCALPASSWORDERR; $submitErrMsg[LOCALPASSWORDERR] = i("Passwords do not match"); } } if ($return['rdpport'] != $user['rdpport']) { $requests = getUserRequests('all'); $nochange = 0; foreach ($requests as $req) { if (preg_match('/^(3|8|24|25|26|27|28|29)$/', $req['currstateid']) || $req['currstateid'] == 14 && preg_match('/^(3|8|24|25|26|27|28|29)$/', $req['laststateid'])) { $nochange = 1; break; } } if ($nochange) { $submitErr |= RDPPORTERR; $submitErrMsg[RDPPORTERR] = i("RDP Port cannot be changed while you have active reservations"); } } if (!($submitErr & RDPPORTERR) && ($return['rdpport'] < 1024 || $return['rdpport'] > 65535)) { $submitErr |= RDPPORTERR; $submitErrMsg[RDPPORTERR] = i("RDP Port must be between 1024 and 65535"); } return $return; }
function submitHelpForm() { global $user, $submitErr, $submitErrMsg; $name = processInputVar("name", ARG_STRING); $email = processInputVar("email", ARG_STRING); $summary = processInputVar("summary", ARG_STRING); $text = processInputVar("comments", ARG_STRING); if (!ereg('^([A-Za-z]{1,}( )([A-Za-z]){2,})$', $name)) { $submitErr |= NAMEERR; $submitErrMsg[NAMEERR] = "You must submit your first and last name"; } if (!eregi('^[_a-z0-9-]+(\\.[_a-z0-9-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*(\\.[a-z]{2,3})$', $email)) { $submitErr |= EMAILERR; $submitErrMsg[EMAILERR] = "Invalid email address, please correct"; } if (empty($summary)) { $submitErr |= SUMMARYERR; $submitErrMsg[SUMMARYERR] = "Please fill in a very short summary of the " . "problem"; } if (empty($text)) { $submitErr |= TEXTERR; $submitErrMsg[TEXTERR] = "Please fill in your problem in the box below.<br>"; } if ($submitErr) { printHelpForm(); return; } $computers = getComputers(); $requests = getUserRequests("all"); $query = "SELECT l.start AS start, " . "l.finalend AS end, " . "l.computerid AS computerid, " . "i.prettyname AS prettyimage " . "FROM log l, " . "image i " . "WHERE l.userid = " . $user["id"] . " AND " . "i.id = l.imageid AND " . "(unix_timestamp(NOW()) - unix_timestamp(l.finalend)) < 14400"; $qh = doQuery($query, 290); while ($row = mysql_fetch_assoc($qh)) { array_push($requests, $row); } $from = $user["email"]; if (get_magic_quotes_gpc()) { $text = stripslashes($text); } $message = "Problem report submitted from VCL web form:\n\n" . "User: "******"unityid"] . "\n" . "Name: " . $name . "\n" . "Email: " . $email . "\n" . "Problem description:\n\n{$text}\n\n"; $end = time(); $start = $end - 14400; $recentrequests = ""; foreach ($requests as $request) { if (datetimeToUnix($request["end"]) > $start || datetimeToUnix($request["start"] < $end)) { $thisstart = str_replace(' ', ' ', prettyDatetime($request["start"])); $thisend = str_replace(' ', ' ', prettyDatetime($request["end"])); $recentrequests .= "Image: " . $request["prettyimage"] . "\n" . "Computer: " . $computers[$request["computerid"]]["hostname"] . "\n" . "Start: {$thisstart}\n" . "End: {$thisend}\n\n"; } } if (!empty($recentrequests)) { $message .= "-----------------------------------------------\n"; $message .= "User's recent reservations:\n\n" . $recentrequests . "\n"; } else { $message .= "User has no recent reservations\n"; } $indrupal = getContinuationVar('indrupal', 0); if (!$indrupal) { print "<H2>VCL Help</H2>\n"; } $mailParams = "-f" . ENVELOPESENDER; if (!mail(HELPEMAIL, "{$summary}", $message, "From: {$from}\r\nReply-To: {$email}\r\n", $mailParams)) { print "The Server was unable to send mail at this time. Please e-mail "; print "<a href=\"mailto:" . HELPEMAIL . "\">" . HELPEMAIL . "</a> for "; print "help with your problem."; } else { print "Your problem report has been submitted. Thank you for letting "; print "us know of your problem so that we can improve this site.<br>\n"; } }
function XMLRPCgetRequestIds() { global $user; $requests = getUserRequests("all"); if (empty($requests)) { return array('status' => 'success', 'requests' => array()); } $ret = array(); foreach ($requests as $req) { $start = datetimeToUnix($req['start']); $end = datetimeToUnix($req['end']); $tmp = array('requestid' => $req['id'], 'imageid' => $req['imageid'], 'imagename' => $req['prettyimage'], 'start' => $start, 'end' => $end); array_push($ret, $tmp); } return array('status' => 'success', 'requests' => $ret); }
function XMLRPCendRequest($requestid) { global $user; $requestid = processInputData($requestid, ARG_NUMERIC); $userRequests = getUserRequests('all', $user['id']); $found = 0; foreach ($userRequests as $req) { if ($req['id'] == $requestid) { $request = getRequestInfo($requestid); $found = 1; break; } } if (!$found) { return array('status' => 'error', 'errorcode' => 1, 'errormsg' => 'unknown requestid'); } deleteRequest($request); return array('status' => 'success'); }