예제 #1
0
function AJsubmitRemoveRequest()
{
    global $mode;
    $mode = 'AJviewRequests';
    $requestid = getContinuationVar('requestid', 0);
    $request = getRequestInfo($requestid, 1);
    if (is_null($requestid)) {
        viewRequests();
        return;
    }
    if ($request['serverrequest']) {
        $query = "SELECT id FROM serverrequest WHERE requestid = {$requestid}";
        $qh = doQuery($query);
        if ($row = mysql_fetch_assoc($qh)) {
            $query = "DELETE FROM serverrequest WHERE requestid = {$requestid}";
            doQuery($query, 152);
            deleteVariable("fixedIPsr{$row['id']}");
        }
    }
    $query = "DELETE FROM request WHERE id = {$requestid}";
    doQuery($query, 153);
    $query = "DELETE FROM reservation WHERE requestid = {$requestid}";
    doQuery($query, 154);
    viewRequests();
}
예제 #2
0
 function AJdeleteAffiliationSetting()
 {
     if (!checkUserHasPerm('Site Configuration (global)')) {
         $arr = array('status' => 'noaccess', 'msg' => i('You do not have access to delete the submitted setting.'));
         sendJSON($arr);
         return;
     }
     $key = processInputVar('key', ARG_STRING);
     $origvals = getContinuationVar('origvals');
     if (!array_key_exists($key, $origvals)) {
         $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'msg' => i('Invalid data submitted.'));
         sendJSON($arr);
         return;
     }
     $tmp = explode('|', $origvals[$key]['key']);
     $affil = $tmp[1];
     $affilid = getAffiliationID($affil);
     deleteVariable($origvals[$key]['key']);
     # recreate update continuation
     $data = getVariablesRegex("^{$this->key}.*");
     $origvals = array();
     $origvals[$this->key] = array('key' => $this->key, 'val' => $data[$this->key]);
     foreach ($data as $prekey => $val) {
         $okey = str_replace('|', '_', $prekey);
         $origvals[$okey] = array('key' => $prekey, 'val' => $val);
     }
     $cdata = $this->basecdata;
     $cdata['origvals'] = $origvals;
     $savecont = addContinuationsEntry('AJupdateAllSettings', $cdata);
     $arr = array('status' => 'success', 'msgid' => "{$this->domidbase}msg", 'delid' => $key, 'affil' => $affil, 'affilid' => $affilid, 'savecont' => $savecont, 'extrafunc' => "{$this->jsname}.deleteAffiliationSettingCBextra", 'msg' => sprintf($this->delmsg, $affil));
     sendJSON($arr);
 }
예제 #3
0
function deleteRequest($request)
{
    # new - 13
    # deleted - 1
    # complete - 12
    # reserved - 3
    # inuse - 8
    # pending - 14
    # timeout - 11
    $now = time();
    if (datetimeToUnix($request["start"]) < $now) {
        # current: new, last: none OR
        # current: pending, last: new
        if ($request["stateid"] == 13 || $request["stateid"] == 14 && $request["laststateid"] == 13) {
            $query = "UPDATE request " . "SET stateid = 1, " . "laststateid = 3 " . "WHERE id = {$request['id']}";
        } elseif ($request["stateid"] == 3 && $request["laststateid"] == 13 || $request["stateid"] == 14 && $request["laststateid"] == 3) {
            $query = "UPDATE request " . "SET stateid = 1, " . "laststateid = 3 " . "WHERE id = {$request['id']}";
        } elseif ($request["stateid"] == 8 && $request["laststateid"] == 3 || $request["stateid"] == 14 && $request["laststateid"] == 8) {
            $query = "UPDATE request " . "SET stateid = 1, " . "laststateid = 8 " . "WHERE id = {$request['id']}";
        } else {
            if ($request["stateid"] == 14) {
                $query = "UPDATE request " . "SET stateid = 1 " . "WHERE id = {$request['id']}";
            } else {
                # somehow a user submitted a deleteRequest where the current
                # stateid was empty
                if (!is_numeric($request["stateid"]) || $request["stateid"] < 0) {
                    $request["stateid"] = 1;
                }
                $query = "UPDATE request " . "SET stateid = 1, " . "laststateid = {$request['stateid']} " . "WHERE id = {$request['id']}";
            }
        }
        $qh = doQuery($query, 150);
        addChangeLogEntry($request["logid"], NULL, unixToDatetime($now), NULL, NULL, "released");
        return;
    }
    if ($request['serverrequest']) {
        $query = "SELECT id FROM serverrequest WHERE requestid = {$request['id']}";
        $qh = doQuery($query);
        if ($row = mysql_fetch_assoc($qh)) {
            $query = "DELETE FROM serverrequest WHERE requestid = {$request['id']}";
            doQuery($query, 152);
            deleteVariable("fixedIPsr{$row['id']}");
        }
    }
    $query = "DELETE FROM request WHERE id = {$request['id']}";
    doQuery($query, 153);
    $query = "DELETE FROM reservation WHERE requestid = {$request['id']}";
    doQuery($query, 154);
    addChangeLogEntry($request["logid"], NULL, NULL, NULL, NULL, "deleted");
}
예제 #4
0
 function AJsaveResource()
 {
     $add = getContinuationVar('add', 0);
     $data = $this->validateResourceData();
     if ($data['error']) {
         $ret = array('status' => 'error', 'msg' => $data['errormsg']);
         sendJSON($ret);
         return;
     }
     if ($add) {
         if (!($data['rscid'] = $this->addResource($data))) {
             sendJSON(array('status' => 'adderror', 'errormsg' => 'Error encountered while trying to create new management node.<br>Please contact an admin for assistance.'));
             return;
         }
     } else {
         $olddata = getContinuationVar('olddata');
         $updates = array();
         # hostname
         if ($data['name'] != $olddata['hostname']) {
             $updates[] = "hostname = '{$data['name']}'";
         }
         $tmp = getVariable("timesource|{$olddata['hostname']}", "<unset>");
         if ($tmp != "<unset>") {
             $query = "UPDATE variable " . "SET name = 'timesource|{$data['name']}' " . "WHERE name = 'timesource|{$olddata['hostname']}'";
             doQuery($query);
         }
         # IPaddress
         if ($data['ipaddress'] != $olddata['IPaddress']) {
             $updates[] = "IPaddress = '{$data['ipaddress']}'";
         }
         # ownerid
         $ownerid = getUserlistID($data['owner']);
         if ($ownerid != $olddata['ownerid']) {
             $updates[] = "ownerid = {$ownerid}";
         }
         # stateid
         if ($data['stateid'] != $olddata['stateid']) {
             $updates[] = "stateid = '{$data['stateid']}'";
         }
         # checkininterval
         if ($data['checkininterval'] != $olddata['checkininterval']) {
             $updates[] = "checkininterval = '{$data['checkininterval']}'";
         }
         # installpath
         if ($data['installpath'] != $olddata['installpath']) {
             $updates[] = "installpath = '{$data['installpath']}'";
         }
         # imagelibenable
         if ($data['imagelibenable'] != $olddata['imagelibenable']) {
             $updates[] = "imagelibenable = '{$data['imagelibenable']}'";
         }
         # imagelibgroupid
         if ($data['imagelibgroupid'] != $olddata['imagelibgroupid']) {
             $updates[] = "imagelibgroupid = '{$data['imagelibgroupid']}'";
         }
         # imagelibuser
         if ($data['imagelibuser'] != $olddata['imagelibuser']) {
             $updates[] = "imagelibuser = '******'imagelibuser']}'";
         }
         # imagelibkey
         if ($data['imagelibkey'] != $olddata['imagelibkey']) {
             $updates[] = "imagelibkey = '{$data['imagelibkey']}'";
         }
         # keys
         if ($data['keys'] != $olddata['keys']) {
             $updates[] = "`keys` = '{$data['keys']}'";
         }
         # sshport
         if ($data['sshport'] != $olddata['sshport']) {
             $updates[] = "sshport = '{$data['sshport']}'";
         }
         # publicIPconfiguration
         if ($data['publicIPconfig'] != $olddata['publicIPconfig']) {
             $updates[] = "publicIPconfiguration = '{$data['publicIPconfig']}'";
         }
         # publicSubnetMask
         if ($data['publicnetmask'] != $olddata['publicnetmask']) {
             $updates[] = "publicSubnetMask = '{$data['publicnetmask']}'";
         }
         # publicDefaultGateway
         if ($data['publicgateway'] != $olddata['publicgateway']) {
             $updates[] = "publicDefaultGateway = '{$data['publicgateway']}'";
         }
         # publicDNSserver
         if ($data['publicdnsserver'] != $olddata['publicdnsserver']) {
             $updates[] = "publicDNSserver = '{$data['publicdnsserver']}'";
         }
         # sysadminEmailAddress
         if ($data['sysadminemail'] != $olddata['sysadminemail']) {
             $updates[] = "sysadminEmailAddress = '{$esc['sysadminemail']}'";
         }
         # sharedMailBox
         if ($data['sharedmailbox'] != $olddata['sharedmailbox']) {
             $updates[] = "sharedMailBox = '{$esc['sharedmailbox']}'";
         }
         # availablenetworks
         if ($data['availablenetworks'] != implode(',', $olddata['availablenetworks'])) {
             $updates[] = "availablenetworks = '{$data['availablenetworks']}'";
         }
         # federatedauth
         if ($data['federatedauth'] != $olddata['federatedauth']) {
             $updates[] = "NOT_STANDALONE = '{$data['federatedauth']}'";
         }
         if (count($updates)) {
             $query = "UPDATE managementnode SET " . implode(', ', $updates) . " WHERE id = {$data['rscid']}";
             doQuery($query);
         }
         # time servers
         if ($data['timeservers'] != $olddata['timeservers']) {
             $globalval = getVariable('timesource|global');
             if ($data['timeservers'] == '' || $data['timeservers'] == $globalval) {
                 deleteVariable("timesource|{$data['name']}");
             } else {
                 setVariable("timesource|{$data['name']}", $data['timeservers'], 'none');
             }
         }
         # NAT host
         if ($data['nathostenabled'] != $olddata['nathostenabled']) {
             if ($data['nathostenabled']) {
                 $query = "INSERT INTO nathost " . "(resourceid, " . "publicIPaddress, " . "internalIPaddress) " . "VALUES " . "({$olddata['resourceid']}, " . "'{$data['natpublicIPaddress']}', " . "'{$data['natinternalIPaddress']}') " . "ON DUPLICATE KEY UPDATE " . "publicIPaddress = '{$data['natpublicIPaddress']}', " . "internalIPaddress = '{$data['natinternalIPaddress']}'";
                 doQuery($query);
             } else {
                 $query = "DELETE FROM nathost " . "WHERE resourceid = {$olddata['resourceid']}";
                 doQuery($query);
             }
         } elseif ($data['nathostenabled'] && ($olddata['natpublicIPaddress'] != $data['natpublicIPaddress'] || $olddata['natinternalIPaddress'] != $data['natinternalIPaddress'])) {
             $query = "UPDATE nathost " . "SET publicIPaddress = '{$data['natpublicIPaddress']}', " . "internalIPaddress = '{$data['natinternalIPaddress']}' " . "WHERE resourceid = {$olddata['resourceid']}";
             doQuery($query);
         }
     }
     # clear user resource cache for this type
     $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("administer"), 0, 1, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("administer"), 0, 0, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("manageGroup"), 0, 1, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $key = getKey(array(array($this->restype . "Admin", 'mgmtnodeAdmin'), array("manageGroup"), 0, 0, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $tmp = $this->getData(array('includedeleted' => 1, 'rscid' => $data['rscid'], 'alive' => 'neither'));
     $data = $tmp[$data['rscid']];
     $arr = array('status' => 'success');
     $arr['data'] = $data;
     if ($add) {
         $arr['action'] = 'add';
         $arr['data']['name'] = $arr['data']['hostname'];
         $arr['nogroups'] = 0;
         $groups = getUserResources(array($this->restype . 'Admin'), array('manageGroup'), 1);
         if (count($groups[$this->restype])) {
             $arr['groupingHTML'] = $this->groupByResourceHTML();
         } else {
             $arr['nogroups'] = 1;
         }
     } else {
         $arr['action'] = 'edit';
     }
     sendJSON($arr);
 }