Beispiel #1
0
/**
 * Ask the user whether he wants to trust this site
 */
function action_trust()
{
    global $store;
    $info = getRequestInfo();
    $trusted = isset($_POST['trust']);
    if ($info && isset($_POST['remember'])) {
        $store->setTrustedSite($info->trust_root);
    }
    return doAuth($info, $trusted, true);
}
Beispiel #2
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";
    }
}
Beispiel #3
0
 static function AJupdateImage($requestid = 0, $userid = 0, $comments = '', $autocaptured = 0)
 {
     global $user, $clickThroughText;
     if ($userid == 0) {
         $userid = $user['id'];
     }
     if (!$autocaptured) {
         $imageid = getContinuationVar('imageid');
         $imageData = getImages(0, $imageid);
         if ($imageData[$imageid]['ownerid'] != $userid) {
             $ret = array('status' => 'noaccess');
             sendJSON($ret);
             return 0;
         }
         $oldrevisionid = getContinuationVar('revisionid');
     }
     $fromclickthrough = getContinuationVar('fromclickthrough', 0);
     if ($fromclickthrough) {
         $comments = getContinuationVar('comments');
     } elseif (!$autocaptured) {
         $comments = processInputVar('comments', ARG_STRING, '');
         $comments = htmlspecialchars($comments);
         if (get_magic_quotes_gpc()) {
             $comments = stripslashes($comments);
         }
     }
     if (!$autocaptured) {
         $requestid = getContinuationVar('requestid');
     }
     $checkpoint = getContinuationVar('checkpoint', 0);
     if (!$autocaptured && !$fromclickthrough) {
         $agree = str_replace("\n", "<br>\n", sprintf($clickThroughText, ''));
         $agree = str_replace("<br>\n<br>\n", "<br>\n", $agree);
         $obj = new Image();
         $cdata = array('obj' => $obj, 'comments' => $comments, 'agree' => $agree, 'requestid' => $requestid, 'imageid' => $imageid, 'revisionid' => $oldrevisionid, 'checkpoint' => $checkpoint, 'fromclickthrough' => 1);
         $cont = addContinuationsEntry('AJupdateImage', $cdata);
         $ret = array('status' => 'success', 'action' => 'clickthrough', 'agree' => $agree, 'cont' => $cont);
         sendJSON($ret);
         return;
     }
     if ($autocaptured) {
         $data = getRequestInfo($requestid);
         if (count($data['reservations']) == 1) {
             $imageid = $data['reservations'][0]['imageid'];
             $oldrevisionid = $data['reservations'][0]['imagerevisionid'];
         } else {
             foreach ($data["reservations"] as $res) {
                 if ($res["forcheckout"]) {
                     $imageid = $res["imageid"];
                     $oldrevisionid = $res['imagerevisionid'];
                     break;
                 }
             }
         }
     }
     // set the test flag on the image in the image table
     $query = "UPDATE image SET test = 1 WHERE id = {$imageid}";
     doQuery($query, 101);
     # add entry to imagerevision table
     $query = "SELECT revision, " . "imagename " . "FROM imagerevision " . "WHERE imageid = {$imageid} " . "ORDER BY revision DESC " . "LIMIT 1";
     $qh = doQuery($query, 101);
     $row = mysql_fetch_assoc($qh);
     $newrevision = $row['revision'] + 1;
     $newname = preg_replace("/{$row['revision']}\$/", $newrevision, $row['imagename']);
     $comments = mysql_real_escape_string($comments);
     $query = "INSERT INTO imagerevision " . "(imageid, " . "revision, " . "userid, " . "datecreated, " . "deleted, " . "production, " . "comments, " . "imagename, " . "autocaptured) " . "VALUES ({$imageid}, " . "{$newrevision}, " . "{$userid}, " . "NOW(), " . "1, " . "0, " . "'{$comments}', " . "'{$newname}', " . "{$autocaptured})";
     doQuery($query, 101);
     $imagerevisionid = dbLastInsertID();
     # duplicate any entries in connectmethodmap for new revision
     $query = "INSERT INTO connectmethodmap " . "SELECT connectmethodid, " . "OStypeid, " . "OSid, " . "{$imagerevisionid}, " . "disabled, " . "autoprovisioned " . "FROM connectmethodmap " . "WHERE imagerevisionid = {$oldrevisionid}";
     doQuery($query, 101);
     $sets = array("rs.imagerevisionid = {$imagerevisionid}");
     if ($checkpoint) {
         $sets[] = "rq.stateid = 24";
     } else {
         $sets[] = "rq.stateid = 16";
         $sets[] = "rq.forimaging = 1";
     }
     # update request and reservation
     $allsets = implode(', ', $sets);
     $query = "UPDATE request rq, " . "reservation rs " . "SET {$allsets} " . "WHERE rq.id = {$requestid} AND " . "rq.id = rs.requestid AND " . "rs.imageid = {$imageid}";
     doQuery($query, 101);
     if ($autocaptured) {
         return 1;
     }
     $agree = mysql_real_escape_string(getContinuationVar('agree'));
     $query = "INSERT INTO clickThroughs " . "(userid, " . "imageid, " . "accepted, " . "agreement) " . "VALUES " . "({$userid}, " . "{$imageid}, " . "NOW(), " . "'{$agree}')";
     doQuery($query, 101);
     $return = array('status' => 'success', 'action' => 'update', 'imageid' => $imageid);
     sendJSON($return);
 }
Beispiel #4
0
function timeToNextReservation($request)
{
    if (!is_array($request)) {
        $request = getRequestInfo($request);
    }
    $comps = array();
    foreach ($request['reservations'] as $res) {
        $comps[] = $res['computerid'];
    }
    $compids = implode(',', $comps);
    $res = array_shift($request["reservations"]);
    $query = "SELECT rq.start " . "FROM reservation rs, " . "request rq " . "WHERE rs.computerid IN ({$compids}) AND " . "rq.start >= '{$request['end']}' AND " . "rs.requestid = rq.id " . "ORDER BY start " . "LIMIT 1";
    $qh = doQuery($query, 101);
    if ($row = mysql_fetch_assoc($qh)) {
        $end = datetimeToUnix($request["end"]);
        $start = datetimeToUnix($row["start"]);
        return ($start - $end) / 60;
    } else {
        return -1;
    }
}
Beispiel #5
0
function timeToNextReservation($request)
{
    if (!is_array($request)) {
        $request = getRequestInfo($request);
    }
    $res = array_shift($request["reservations"]);
    $query = "SELECT rq.start " . "FROM reservation rs, " . "request rq " . "WHERE rs.computerid = {$res["computerid"]} AND " . "rq.start >= '{$request["end"]}' AND " . "rs.requestid = rq.id " . "ORDER BY start " . "LIMIT 1";
    $qh = doQuery($query, 101);
    if ($row = mysql_fetch_assoc($qh)) {
        $end = datetimeToUnix($request["end"]);
        $start = datetimeToUnix($row["start"]);
        return ($start - $end) / 60;
    } else {
        return -1;
    }
}
Beispiel #6
0
function XMLRPCautoCapture($requestid)
{
    global $user, $xmlrpcBlockAPIUsers;
    if (!in_array($user['id'], $xmlrpcBlockAPIUsers)) {
        return array('status' => 'error', 'errorcode' => 47, 'errormsg' => 'access denied to XMLRPCautoCapture');
    }
    $query = "SELECT id FROM request WHERE id = {$requestid}";
    $qh = doQuery($query, 101);
    if (!mysql_num_rows($qh)) {
        return array('status' => 'error', 'errorcode' => 52, 'errormsg' => 'specified request does not exist');
    }
    $reqData = getRequestInfo($requestid);
    # check state of reservation
    if ($reqData['stateid'] != 14 || $reqData['laststateid'] != 8) {
        return array('status' => 'error', 'errorcode' => 51, 'errormsg' => 'reservation not in valid state');
    }
    # check that not a cluster reservation
    if (count($reqData['reservations']) > 1) {
        return array('status' => 'error', 'errorcode' => 48, 'errormsg' => 'cannot image a cluster reservation');
    }
    require_once ".ht-inc/image.php";
    $imageid = $reqData['reservations'][0]['imageid'];
    $imageData = getImages(0, $imageid);
    $captime = unixToDatetime(time());
    $comments = "start: {$reqData['start']}<br>" . "end: {$reqData['end']}<br>" . "computer: {$reqData['reservations'][0]['reservedIP']}<br>" . "capture time: {$captime}";
    # create new revision if requestor is owner and not a kickstart image
    if ($imageData[$imageid]['installtype'] != 'kickstart' && $reqData['userid'] == $imageData[$imageid]['ownerid']) {
        $rc = Image::AJupdateImage($requestid, $reqData['userid'], $comments, 1);
        if ($rc == 0) {
            return array('status' => 'error', 'errorcode' => 49, 'errormsg' => 'error encountered while attempting to create new revision');
        }
    } else {
        $ownerdata = getUserInfo($reqData['userid'], 1, 1);
        $desc = "This is an autocaptured image.<br>" . "captured from image: {$reqData['reservations'][0]['prettyimage']}<br>" . "captured on: {$captime}<br>" . "owner: {$ownerdata['unityid']}@{$ownerdata['affiliation']}<br>";
        $connectmethods = getImageConnectMethods($imageid, $reqData['reservations'][0]['imagerevisionid']);
        $data = array('requestid' => $requestid, 'desc' => $desc, 'usage' => '', 'owner' => "{$ownerdata['unityid']}@{$ownerdata['affiliation']}", 'name' => "Autocaptured ({$ownerdata['unityid']} - {$requestid})", 'ram' => 64, 'cores' => 1, 'cpuspeed' => 500, 'networkspeed' => 10, 'concurrent' => '', 'checkuser' => 1, 'rootaccess' => 1, 'checkout' => 1, 'sysprep' => 1, 'basedoffrevisionid' => $reqData['reservations'][0]['imagerevisionid'], 'platformid' => $imageData[$imageid]['platformid'], 'osid' => $imageData[$imageid]["osid"], 'ostype' => $imageData[$imageid]["ostype"], 'sethostname' => $imageData[$imageid]["sethostname"], 'reload' => 20, 'comments' => $comments, 'connectmethodids' => implode(',', array_keys($connectmethods)), 'autocaptured' => 1);
        $obj = new Image();
        $imageid = $obj->addResource($data);
        if ($imageid == 0) {
            return array('status' => 'error', 'errorcode' => 50, 'errormsg' => 'error encountered while attempting to create image');
        }
        $query = "UPDATE request rq, " . "reservation rs " . "SET rs.imageid = {$imageid}, " . "rs.imagerevisionid = {$obj->imagerevisionid}, " . "rq.stateid = 16  " . "WHERE rq.id = {$requestid} AND " . "rq.id = rs.requestid";
        doQuery($query);
    }
    return array('status' => 'success');
}
Beispiel #7
0
function AJstartImage()
{
    global $user;
    $requestid = getContinuationVar("requestid");
    $checkpoint = getContinuationVar("checkpoint", 0);
    $data = getRequestInfo($requestid, 1);
    if (is_null($data) || $data['stateid'] == 11 || $data['stateid'] == 12 || $data['stateid'] == 14 && ($data['laststateid'] == 11 || $data['laststateid'] == 12)) {
        $ret = array('status' => 'resgone', 'errmsg' => i("The reservation you selected to image has expired."));
        sendJSON($ret);
        return;
    }
    $disableUpdate = 1;
    $imageid = '';
    if (count($data['reservations']) == 1) {
        $imageid = $data['reservations'][0]['imageid'];
        $revid = $data['reservations'][0]['imagerevisionid'];
    } else {
        foreach ($data["reservations"] as $res) {
            if ($res["forcheckout"]) {
                $imageid = $res["imageid"];
                $revid = $res['imagerevisionid'];
                break;
            }
        }
    }
    $ostype = 'windows';
    if (!empty($imageid)) {
        $imageData = getImages(0, $imageid);
        if ($imageData[$imageid]['ownerid'] == $user['id']) {
            $disableUpdate = 0;
        }
        if ($imageData[$imageid]['installtype'] == 'none' || $imageData[$imageid]['installtype'] == 'kickstart') {
            $disableUpdate = 1;
        }
        $ostype = $imageData[$imageid]['ostype'];
    } else {
        $data['status'] = 'error';
        $data['errmsg'] = i("There was an error in starting the imaging process. Please contact a system administrator.");
        sendJSON($data);
        return;
    }
    # check for root access being disabled
    if ($imageData[$imageid]['rootaccess'] == 0 && $imageData[$imageid]['ownerid'] != $user['id']) {
        $ret = array('status' => 'rootaccessnoimage');
        sendJSON($ret);
        return;
    }
    $obj = new Image();
    $cdata = array('obj' => $obj, 'requestid' => $requestid, 'imageid' => $imageid, 'baserevisionid' => $revid, 'checkpoint' => $checkpoint, 'add' => 1);
    $cont = addContinuationsEntry('AJsaveResource', $cdata, SECINDAY, 0);
    $arr = array('newcont' => $cont, 'enableupdate' => 0, 'connectmethods' => $imageData[$imageid]['connectmethods'], 'owner' => "{$user['unityid']}@{$user['affiliation']}", 'checkpoint' => $checkpoint, 'ostype' => $ostype);
    $cdata = array('obj' => $obj, 'imageid' => $imageid, 'newimage' => 1, 'curmethods' => $imageData[$imageid]['connectmethods']);
    $cont = addContinuationsEntry('connectmethodDialogContent', $cdata);
    $arr['connectmethodurl'] = BASEURL . SCRIPT . "?continuation={$cont}";
    if (!$disableUpdate) {
        $revisions = getImageRevisions($imageid, 1);
        if (array_key_exists($revid, $revisions)) {
            $comments = $revisions[$revid]['comments'];
        } else {
            $keys = array_keys($revisions);
            if (count($keys)) {
                $key = array_pop($keys);
                $comments = $revisions[$key]['comments'];
            } else {
                $comments = '';
            }
        }
        if (preg_match('/\\w/', $comments)) {
            $cmt = sprintf(i("These are the comments from the previous revision (%s):"), $revisions[$revid]['revision']);
            $cmt .= "<br>";
            $cmt .= "{$revisions[$revid]['comments']}<br><br>";
        } else {
            $cmt = i("The previous revision did not have any comments.") . "<br><br>";
        }
        $arr['comments'] = $cmt;
        $cdata = array('obj' => $obj, 'requestid' => $requestid, 'imageid' => $imageid, 'checkpoint' => $checkpoint, 'revisionid' => $revid);
        $cont = addContinuationsEntry('AJupdateImage', $cdata, SECINDAY, 0);
        $arr['updatecont'] = $cont;
        $arr['enableupdate'] = 1;
    }
    $arr['status'] = 'success';
    sendJSON($arr);
}
Beispiel #8
0
function submitSetImageProduction()
{
    $requestid = getContinuationVar('requestid');
    $data = getRequestInfo($requestid);
    foreach ($data["reservations"] as $res) {
        if ($res["forcheckout"]) {
            $prettyimage = $res["prettyimage"];
            break;
        }
    }
    /*$regs = array();
    	if(ereg('(.*)-v([0-9]){1,2}$', $data["image"], $regs)) {
    		$newname = $regs[1] . "-v" . ++$regs[2];
    		print "newname - $newname<br>\n";
    	}
    	else {
    		$newname = $data["image"] . "-v0";
    	}
    	$query = "UPDATE image "
    	       . "SET name = '$newname', "
    	       .     "test = 0 "
    	       . "WHERE id = " . $data["imageid"];*/
    $query = "UPDATE request SET stateid = 17 WHERE id = {$requestid}";
    doQuery($query, 101);
    //deleteRequest($data);
    print "<H2>Change Test Image to Production</H2>\n";
    print "<b>{$prettyimage}</b> is in the process of being ";
    print "updated to use the newly created image.<br>\n";
}
Beispiel #9
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) . '}*/';
}
Beispiel #10
0
 */
require_once dirname(dirname(__FILE__)) . '/openid_server_include.php';
require_once 'lib/common.php';
require_once 'lib/session.php';
$iframe_template = <<<END
<iframe
width="%s"
height="%s"
src="%s"
>
</iframe>');
END;
$openid_url = getLoggedinUser();
$store = getOpenIDServerStore();
$sites = $store->getAutoLoginSites();
$request = getRequestInfo();
if ($request) {
    $return_url = $request->return_to;
    setRequestInfo(null);
} else {
    $return_url = $CONFIG->wwwroot;
}
// TODO: get this to work with posts
$iframes = '';
foreach ($sites as $site) {
    $iframes .= sprintf($iframe_template, $site->width, $site->height, sprintf($site->auto_login, $openid_url));
}
$body = elgg_view("openid_server/forms/autologin", array('iframes' => $iframes, 'return_to' => $return_url));
$CONFIG->events['login'] = array();
login();
header("Content-type:text/html");
Beispiel #11
0
/**
 * Ask the user whether he wants to trust this site
 */
function action_trust()
{
    $info = getRequestInfo();
    $trusted = isset($_POST['trust']);
    if ($info && isset($_POST['remember'])) {
        $sites = getSessionSites();
        $sites[$info->trust_root] = $trusted;
        setSessionSites($sites);
    }
    return doAuth($info, $trusted, true);
}
Beispiel #12
0
function action_authorize()
{
    $server =& getServer();
    $info = getRequestInfo();
    if (!$info) {
        $info = $server->decodeRequest();
    }
    // Throw away the info, we no longer need it.
    setRequestInfo();
    $trusted = isset($_POST['save']);
    if ($trusted) {
        return send_geni_user($server, $info);
    } else {
        return send_cancel($info);
    }
}
Beispiel #13
0
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');
}
Beispiel #14
0
<?php

/**
 * Elgg openid_server: handle trust form
 * 
 * @package ElggOpenID
 * @license http://www.gnu.org/licenses/old-licenses/gpl-2.0.html GNU Public License version 2
 * @author Kevin Jardine <*****@*****.**>
 * @copyright Curverider Ltd 2008-2009
 * @link http://elgg.org/
 */
//error_log("in trust.php");
require_once dirname(dirname(__FILE__)) . '/openid_server_include.php';
require_once 'lib/common.php';
require_once 'lib/session.php';
$info = getRequestInfo();
$trusted = get_input('trust');
$remember = get_input('remember');
$trust_root = get_input('trust_root');
$store = getOpenIDServerStore();
if ($remember) {
    $store->setTrustedSite($info);
    //$store->setTrustedSite($info->trust_root);
}
if (!$info) {
    // There is no authentication information, so bail
    system_message(elgg_echo("openid_server:cancelled"));
    forward();
} else {
    if ($idpSelect = $info->idSelect()) {
        if ($idpSelect) {
Beispiel #15
0
function AJsubmitSetImageProduction()
{
    $requestid = getContinuationVar('requestid');
    $data = getRequestInfo($requestid);
    foreach ($data["reservations"] as $res) {
        if ($res["forcheckout"]) {
            $prettyimage = $res["prettyimage"];
            break;
        }
    }
    $query = "UPDATE request SET stateid = 17 WHERE id = {$requestid}";
    doQuery($query, 101);
    $content = sprintf(i("%s is now in the process of being updated to use the newly created revision."), "<b>{$prettyimage}</b>") . "<br>";
    $content = preg_replace("/(.{1,60}[ \n])/", '\\1<br>', $content);
    $a = "var dlg = new dijit.Dialog({" . "title: \"" . i("Change Test Image to Production") . "\"," . "id: \"toproddlg\"" . "});" . "var content = '{$content}" . "<div align=\"center\">" . "<button dojoType=\"dijit.form.Button\">" . i("Close") . "<script type=\"dojo/method\" event=\"onClick\">" . "dijit.byId(\"toproddlg\").destroy();" . "</script>" . "</button>" . "</div>';" . "dlg.set(\"content\", content);" . "dlg.show();" . "resRefresh();";
    print $a;
}
Beispiel #16
0
function AJrestartImageCapture()
{
    $requestid = getContinuationVar('requestid');
    if (!checkUserHasPerm('View Dashboard (global)')) {
        sendJSON(array('status' => 'noaccess'));
        return;
    }
    $request = getRequestInfo($requestid);
    if ($request['stateid'] != 10 || $request['laststateid'] != 16 && $request['laststateid'] != 24 || count($request['reservations']) > 1) {
        sendJSON(array('status' => 'wrongstate'));
        return;
    }
    $compid = $request['reservations'][0]['computerid'];
    $query = "UPDATE computer c, " . "request rq " . "SET c.stateid = 8, " . "rq.stateid = {$request['laststateid']}, " . "rq.laststateid = 10 " . "WHERE c.id = {$compid} AND " . "rq.id = {$requestid}";
    doQuery($query);
    sendJSON(array('status' => 'success'));
}
Beispiel #17
0
/**
 * Ask the user whether he wants to trust this site
 */
function action_trust()
{
    $info = getRequestInfo();
    $trusted = isset($_POST['trust']);
    return doAuth($info, $trusted, true, @$_POST['idSelect']);
}
Beispiel #18
0
function render_trust($method, &$request, &$template)
{
    global $storage;
    Server_needAuth($request);
    $account = Server_getAccount();
    list($request_info, $sreg) = getRequestInfo();
    if (!$request_info) {
        Server_redirect(getServerURL());
    }
    $urls = $storage->getUrlsForAccount($account);
    if (!in_array($request_info->identity, $urls)) {
        Server_clearAccount();
        setRequestInfo($request_info, $sreg);
        Server_needAuth($request);
    }
    if ($method == 'POST') {
        $trusted = false;
        if (isset($request['trust_forever'])) {
            $storage->trustLog(Server_getAccount(), $request_info->trust_root, true);
            $trusted = true;
        } else {
            if (isset($request['trust_once'])) {
                $storage->trustLog(Server_getAccount(), $request_info->trust_root, false);
                $trusted = true;
            } else {
                $storage->trustLog(Server_getAccount(), $request_info->trust_root, false);
            }
        }
        if ($trusted) {
            $allowed_fields = array();
            if (array_key_exists('sreg', $request)) {
                $allowed_fields = array_keys($request['sreg']);
            }
            $response = $request_info->answer(true);
            addSregData($account, $response, $allowed_fields);
        } else {
            $response = $request_info->answer(false);
        }
        setRequestInfo();
        Server_handleResponse($response);
    }
    if ($sreg) {
        // Get the profile data and mark it up so it's easy to tell
        // what's required and what's optional.
        $profile = $storage->getPersona($account);
        list($optional, $required, $policy_url) = $sreg;
        $sreg_labels = array('nickname' => 'Nickname', 'fullname' => 'Full name', 'email' => 'E-mail address', 'dob' => 'Birth date', 'postcode' => 'Postal code', 'gender' => 'Gender', 'country' => 'Country', 'timezone' => 'Time zone', 'language' => 'Language');
        $profile['country'] = getCountryName($profile['country']);
        $profile['language'] = getLanguage($profile['language']);
        $new_profile = array();
        foreach ($profile as $k => $v) {
            if (in_array($k, $optional) || in_array($k, $required)) {
                $new_profile[] = array('name' => $sreg_labels[$k], 'real_name' => $k, 'value' => $v, 'optional' => in_array($k, $optional), 'required' => in_array($k, $required));
            }
        }
        $template->assign('profile', $new_profile);
        $template->assign('policy_url', $policy_url);
    }
    $template->assign('trust_root', $request_info->trust_root);
    $template->assign('identity', $request_info->identity);
    $template->display('trust.tpl');
}