Exemplo n.º 1
0
function AJgetDelSiteMaintenanceData()
{
    $id = getContinuationVar('id');
    $tmp = getMaintItems($id);
    $data = $tmp[$id];
    $cdata = array('id' => $id, 'update' => 1, 'start' => datetimeToUnix($data['start']));
    $cont = addContinuationsEntry('AJdeleteSiteMaintenance', $cdata, SECINDAY, 1, 0);
    $tmp = datetimeToUnix($data['start']);
    $start = date('g:i A, n/j/Y', $tmp);
    $tmp = datetimeToUnix($data['end']);
    $end = date('g:i A, n/j/Y', $tmp);
    $tmp = datetimeToUnix($data['created']);
    $created = date('g:i A, n/j/Y', $tmp);
    $hours = $data['informhoursahead'] % 24;
    if ($hours == 1) {
        $hours = (int) ($data['informhoursahead'] / 24) . " days, 1 hour";
    } else {
        $hours = (int) ($data['informhoursahead'] / 24) . " days, {$hours} hours";
    }
    $hours = "{$data['informhoursahead']} ({$hours})";
    if ($data['allowreservations']) {
        $allowres = 'Yes';
    } else {
        $allowres = 'No';
    }
    $reason = preg_replace("/(.{1,50}([ \n]|\$))/", '\\1<br>', $data['reason']);
    $reason = preg_replace('/\\n<br>\\n/', "<br><br>\n", $reason);
    $usermsg = preg_replace("/(.{1,50}([ \n]|\$))/", '\\1<br>', $data['usermessage']);
    $usermsg = preg_replace('/\\n<br>\\n/', "<br><br>\n", $usermsg);
    $arr = array('start' => $start, 'end' => $end, 'owner' => $data['owner'], 'created' => $created, 'hoursahead' => $hours, 'allowreservations' => $allowres, 'reason' => $reason, 'usermessage' => $usermsg, 'cont' => $cont);
    sendJSON($arr);
}
Exemplo n.º 2
0
function AJgetStatData()
{
    $start = getContinuationVar("start");
    $end = getContinuationVar("end");
    $affilid = getContinuationVar("affilid");
    $divid = getContinuationVar('divid');
    $mode = getContinuationVar('mode');
    $provid = getContinuationVar('provid');
    if ($divid == 'resbyday') {
        $data = getStatGraphDayData($start, $end, $affilid, $mode, $provid);
    } elseif ($divid == 'maxconcurresday') {
        $data = getStatGraphDayConUsersData($start, $end, $affilid, $mode, $provid);
    } elseif ($divid == 'maxconcurbladeday') {
        $data = getStatGraphConBladeUserData($start, $end, $affilid, $mode, $provid);
    } elseif ($divid == 'maxconcurvmday') {
        $data = getStatGraphConVMUserData($start, $end, $affilid, $mode, $provid);
    } elseif ($divid == 'resbyhour') {
        $data = getStatGraphHourData($start, $end, $affilid, $mode, $provid);
    } elseif (preg_match('/^resbyday/', $divid)) {
        $data = getStatGraphDayData($start, $end, $affilid, $mode, $provid);
    } elseif (preg_match('/^maxconcurresday/', $divid)) {
        $data = getStatGraphDayConUsersData($start, $end, $affilid, $mode, $provid);
    } elseif (preg_match('/^maxconcurbladeday/', $divid)) {
        $data = getStatGraphConBladeUserData($start, $end, $affilid, $mode, $provid);
    } elseif (preg_match('/^maxconcurvmday/', $divid)) {
        $data = getStatGraphConVMUserData($start, $end, $affilid, $mode, $provid);
    }
    $data['id'] = $divid;
    sendJSON($data);
}
Exemplo n.º 3
0
 function AJaddRemGroupResource()
 {
     $newids = getContinuationVar('newids');
     if (is_null($newids)) {
         $rscid = processInputVar('id', ARG_NUMERIC);
         $resources = getUserResources(array($this->restype . "Admin"), array("manageGroup"));
         if (!array_key_exists($rscid, $resources[$this->restype])) {
             $arr = array('status' => 'noaccess');
             sendJSON($arr);
             return;
         }
     }
     $groups = getUserResources(array($this->restype . "Admin"), array("manageGroup"), 1);
     $tmp = processInputVar('listids', ARG_STRING);
     $tmp = explode(',', $tmp);
     $groupids = array();
     foreach ($tmp as $id) {
         if (!is_numeric($id)) {
             continue;
         }
         if (!array_key_exists($id, $groups[$this->restype])) {
             $arr = array('status' => 'noaccess');
             sendJSON($arr);
             return;
         }
         $groupids[] = $id;
     }
     $args = $this->defaultGetDataArgs;
     if (is_null($newids)) {
         $args['rscid'] = $rscid;
     }
     $resdata = $this->getData($args);
     $mode = getContinuationVar('mode');
     if ($mode == 'add') {
         $adds = array();
         if (is_null($newids)) {
             foreach ($groupids as $id) {
                 $adds[] = "({$resdata[$rscid]['resourceid']}, {$id})";
             }
         } else {
             foreach ($newids as $newrscid) {
                 foreach ($groupids as $id) {
                     $adds[] = "({$resdata[$newrscid]['resourceid']}, {$id})";
                 }
             }
         }
         $query = "INSERT IGNORE INTO resourcegroupmembers " . "(resourceid, resourcegroupid) VALUES ";
         $query .= implode(',', $adds);
         doQuery($query);
     } else {
         $rems = implode(',', $groupids);
         if (is_null($newids)) {
             $query = "DELETE FROM resourcegroupmembers " . "WHERE resourceid = {$resdata[$rscid]['resourceid']} AND " . "resourcegroupid IN ({$rems})";
         } else {
             $allrscids = array();
             foreach ($newids as $newrscid) {
                 $allrscids[] = $resdata[$newrscid]['resourceid'];
             }
             $allrscids = implode(',', $allrscids);
             $query = "DELETE FROM resourcegroupmembers " . "WHERE resourceid IN ({$allrscids}) AND " . "resourcegroupid IN ({$rems})";
         }
         doQuery($query);
     }
     $_SESSION['userresources'] = array();
     $regids = "^" . implode('$|^', $groupids) . "\$";
     $arr = array('status' => 'success', 'regids' => $regids, 'inselobj' => 'ingroups', 'outselobj' => 'outgroups');
     sendJSON($arr);
 }
Exemplo n.º 4
0
function sendREST($arr)
{
    sendJSON($arr, '', 1);
}
Exemplo n.º 5
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);
 }
Exemplo n.º 6
0
function jsonResourceGroupStore()
{
    $resourcegroups = getResourceGroups();
    $resources = array();
    $userresources = getUserResources(array("groupAdmin"), array("manageGroup"), 1);
    foreach (array_keys($userresources) as $type) {
        foreach ($userresources[$type] as $id => $group) {
            if (array_key_exists($id, $resourcegroups)) {
                // have to make sure it exists in case something was deleted from the session priv cache
                $resources[$id]["type"] = $type;
                $resources[$id]["name"] = $group;
                $resources[$id]["owner"] = $resourcegroups[$id]["owner"];
                $resources[$id]["ownerid"] = $resourcegroups[$id]["ownerid"];
            }
        }
    }
    $items = array();
    foreach (array_keys($resources) as $id) {
        $g = array('id' => $id, 'type' => $resources[$id]['type'], 'name' => $resources[$id]['name'], 'owninggroup' => $resourcegroups[$id]['owner'], 'owninggroupid' => $resourcegroups[$id]['ownerid']);
        $items[] = $g;
    }
    sendJSON($items, 'id');
}
Exemplo n.º 7
0
 function AJeditResource()
 {
     $rscid = processInputVar('rscid', ARG_NUMERIC);
     $resources = getUserResources(array($this->restype . 'Admin'), array('administer'), 0, 1);
     if (!array_key_exists($rscid, $resources[$this->restype])) {
         $ret = array('status' => 'noaccess');
         sendJSON($ret);
         return;
     }
     $args = $this->defaultGetDataArgs;
     $args['rscid'] = $rscid;
     $tmp = $this->getData($args);
     $data = $tmp[$rscid];
     $cdata = $this->basecdata;
     $cdata['rscid'] = $rscid;
     $cdata['olddata'] = $data;
     # save continuation
     $cont = addContinuationsEntry('AJsaveResource', $cdata);
     $ret = $this->jsondata;
     $ret['title'] = "Edit {$this->restypename}";
     $ret['cont'] = $cont;
     $ret['resid'] = $rscid;
     $ret['data'] = $data;
     $ret['status'] = 'success';
     sendJSON($ret);
 }
Exemplo n.º 8
0
function AJviewBlockAllocationUsage()
{
    $blockid = processInputVar('blockid', ARG_NUMERIC);
    $allowedblockids = getContinuationVar('blockids');
    if (!in_array($blockid, $allowedblockids)) {
        sendJSON(array('status' => 'failed', 'message' => 'noaccess'));
        return;
    }
    $query = "SELECT COUNT(s.computerid) AS used, " . "br.numMachines AS allocated, " . "s.blockStart " . "FROM blockRequest br " . "LEFT JOIN sublog s ON (s.blockRequestid = br.id) " . "WHERE br.id = {$blockid} " . "GROUP BY s.blockRequestid, s.blockStart, s.blockEnd " . "ORDER BY s.blockStart";
    $qh = doQuery($query);
    $usage = array();
    $first = 1;
    $firststart = '';
    $laststart = '';
    while ($row = mysql_fetch_assoc($qh)) {
        if ($first && !is_null($row['blockStart'])) {
            $firststart = datetimeToUnix($row['blockStart']);
            $first = 0;
        } elseif (!is_null($row['blockStart'])) {
            $laststart = datetimeToUnix($row['blockStart']);
        }
        if (is_null($row['blockStart'])) {
            continue;
        }
        $percent = (int) ($row['used'] / $row['allocated'] * 100);
        $startts = datetimeToUnix($row['blockStart']);
        $usage[$startts] = array('percent' => $percent, 'label' => $row['blockStart']);
    }
    if ($firststart == '') {
        sendJSON(array('status' => 'empty', 'message' => 'nousage'));
        return;
    }
    $data = array('points' => array(), 'xlabels' => array());
    $cnt = 0;
    $tmp = localtime($firststart, 1);
    $firstisdst = 0;
    if ($tmp['tm_isdst']) {
        $firstisdst = 1;
    }
    for ($i = $firststart; $i <= $laststart + 3600; $i += SECINDAY) {
        $tmp = localtime($i, 1);
        $time = $i;
        if ($firstisdst && !$tmp['tm_isdst']) {
            $time += 3600;
        }
        if (!$firstisdst && $tmp['tm_isdst']) {
            $time -= 3600;
        }
        $cnt++;
        $label = date('m/d g:i a', $time);
        if (array_key_exists($time, $usage)) {
            $data['points'][] = array('y' => $usage[$time]['percent'], 'tooltip' => "{$label}: " . $usage[$time]['percent'] . " %");
        } else {
            $data['points'][] = array('y' => 0, 'tooltip' => "{$label}: 0");
        }
        $data['xlabels'][] = array('value' => $cnt, 'text' => $label);
    }
    sendJSON(array('status' => 'success', 'usage' => $data));
}
Exemplo n.º 9
0
 function AJupdateAllSettings()
 {
     if (!checkUserHasPerm('Site Configuration (global)')) {
         $arr = array('status' => 'noaccess', 'msg' => i('You do not have access to modify the submitted settings.'));
         sendJSON($arr);
         return;
     }
     switch ($this->type) {
         case 'numeric':
             $newval = processInputVar('newval', ARG_NUMERIC);
             if ($newval < $this->minval || $newval > $this->maxval) {
                 $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
                 sendJSON($arr);
                 return;
             }
             break;
         case 'boolean':
             $newval = processInputVar('newval', ARG_NUMERIC);
             if ($newval !== '0' && $newval !== '1') {
                 $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
                 sendJSON($arr);
                 return;
             }
             break;
         case 'text':
             # TODO
             $newval = processInputVar('newval', ARG_STRING);
             $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("unsupported type"));
             sendJSON($arr);
             return;
         case 'textarea':
             $newval = processInputVar('newval', ARG_STRING);
             if (!$this->validateValue($newval)) {
                 $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
                 if (isset($this->invalidvaluemsg)) {
                     $arr['errmsg'] = $this->invalidvaluemsg;
                 }
                 sendJSON($arr);
                 return;
             }
             break;
         default:
             $arr = array('status' => 'failed', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'errmsg' => i("Invalid value submitted"));
             sendJSON($arr);
             return;
     }
     setVariable($this->key, $newval, 'none');
     $arr = array('status' => 'success', 'msgid' => "{$this->domidbase}msg", 'btn' => "{$this->domidbase}btn", 'msg' => $this->updatemsg);
     sendJSON($arr);
 }
Exemplo n.º 10
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'));
}
Exemplo n.º 11
0
function AJdelProfile()
{
    if (!checkUserHasPerm('Manage VM Profiles')) {
        sendJSON(array('failed' => 'noaccess'));
        return;
    }
    $profileid = processInputVar('profileid', ARG_NUMERIC);
    # check to see if profile is in use
    $query = "SELECT vh.computerid, " . "s.name " . "FROM vmhost vh, " . "computer c, " . "state s " . "WHERE vh.computerid = c.id AND " . "c.stateid = s.id AND " . "s.name IN ('vmhostinuse', 'tovmhostinuse') AND " . "vh.vmprofileid = {$profileid}";
    $qh = doQuery($query, 101);
    if ($row = mysql_fetch_assoc($qh)) {
        sendJSON(array('failed' => 'inuse'));
        return;
    }
    $query = "DELETE FROM vmprofile WHERE id = {$profileid}";
    doQuery($query, 101);
    sendJSON(array('SUCCESS'));
}
Exemplo n.º 12
0
function AJsaveUserGroupPrivs()
{
    global $user;
    $groups = getUserGroups(0, $user['affiliationid']);
    $groupid = processInputVar('groupid', ARG_NUMERIC);
    if (!array_key_exists($groupid, $groups)) {
        sendJSON(array('failed' => 'noaccess'));
        return;
    }
    $permids = processInputVar('permids', ARG_STRING);
    if (!preg_match('/^[0-9,]*$/', $permids)) {
        sendJSON(array('failed' => 'invalid input'));
        return;
    }
    $perms = explode(',', $permids);
    $query = "DELETE FROM usergrouppriv WHERE usergroupid = {$groupid}";
    doQuery($query, 101);
    if (empty($perms[0])) {
        sendJSON(array('success' => 1));
        return;
    }
    $values = array();
    foreach ($perms as $permid) {
        $values[] = "({$groupid}, {$permid})";
    }
    $allvals = implode(',', $values);
    $query = "INSERT INTO usergrouppriv " . "(usergroupid, " . "userprivtypeid) " . "VALUES {$allvals}";
    doQuery($query, 101);
    sendJSON(array('success' => 1));
    $_SESSION['user']["groupperms"] = getUsersGroupPerms(array_keys($user['groups']));
}
Exemplo n.º 13
0
function AJfetchRouterDNS()
{
    $data = array('status' => 'none');
    $page = processInputVar('page', ARG_STRING);
    if ($page != 'deploy' && $page != 'profile') {
        sendJSON($data);
        return;
    }
    $ipaddr = processInputVar('ipaddr', ARG_STRING);
    # validate fixed IP address
    if (!validateIPv4addr($ipaddr)) {
        sendJSON($data);
        return;
    }
    # validate netmask
    $netmask = processInputVar('netmask', ARG_STRING);
    $bnetmask = ip2long($netmask);
    if (!preg_match('/^[1]+0[^1]+$/', sprintf('%032b', $bnetmask))) {
        sendJSON($data);
        return;
    }
    $network = ip2long($ipaddr) & $bnetmask;
    $availnets = getVariable('fixedIPavailnetworks', array());
    $key = long2ip($network) . "/{$netmask}";
    if (array_key_exists($key, $availnets)) {
        $data = array('status' => 'success', 'page' => $page, 'router' => $availnets[$key]['router'], 'dns' => implode(',', $availnets[$key]['dns']));
    }
    sendJSON($data);
}
Exemplo n.º 14
0
 function AJsubmitDeleteConfigMapping()
 {
     $configmapid = getContinuationVar('configmapid');
     $query = "DELETE FROM configmap " . "WHERE id = {$configmapid}";
     doQuery($query);
     $ret = array('status' => 'success', 'configmapid' => $configmapid);
     sendJSON($ret);
 }
Exemplo n.º 15
0
function AJvalidateUserid()
{
    $user = processInputVar('user', ARG_STRING);
    if (validateUserid($user)) {
        sendJSON(array('status' => 'valid'));
    } else {
        sendJSON(array('status' => 'invalid'));
    }
}
Exemplo n.º 16
0
function AJpreviewClickThrough()
{
    global $clickThroughText;
    $text = sprintf($clickThroughText, '');
    $text = preg_replace("/(.{1,80}([ \n]|\$))/", '\\1<br>', $text);
    $text = preg_replace("/<\\/p>\n<br>/", '', $text);
    sendJSON(array('text' => $text));
}
Exemplo n.º 17
0
 function AJdeleteRevisions()
 {
     $revids = getContinuationVar('revids');
     $imageid = getContinuationVar('imageid');
     $checkedids = processInputVar('checkedids', ARG_STRING);
     $ids = explode(',', $checkedids);
     if (empty($ids)) {
         sendJSON(array());
         return;
     }
     foreach ($ids as $id) {
         if (!is_numeric($id) || !in_array($id, $revids)) {
             sendJSON(array());
             return;
         }
     }
     $query = "SELECT DISTINCT ir.revision " . "FROM request rq, " . "reservation rs, " . "imagerevision ir " . "WHERE rs.requestid = rq.id AND " . "rs.imagerevisionid = ir.id AND " . "rs.imagerevisionid IN ({$checkedids}) AND " . "rq.stateid NOT IN (1, 5, 11, 12)";
     $qh = doQuery($query);
     if (mysql_num_rows($qh)) {
         $inuseids = array();
         while ($row = mysql_fetch_assoc($qh)) {
             $inuseids[] = $row['revision'];
         }
         $inuseids = implode(',', $inuseids);
         $rc = array('status' => 'error', 'msg' => i("The following revisions are in use and cannot be deleted at this time:") . " {$inuseids}");
         sendJSON($rc);
         return;
     }
     $query = "UPDATE imagerevision " . "SET deleted = 1, " . "datedeleted = NOW() " . "WHERE id IN ({$checkedids}) " . "AND production != 1";
     doQuery($query, 101);
     $html = $this->getRevisionHTML($imageid);
     $arr = array('html' => $html);
     sendJSON($arr);
 }
Exemplo n.º 18
0
<?php

include 'DBO.php';
include 'Authentication.php';
$userID = $_SESSION['UNO'];
$sql = "SELECT * FROM exam e ,enrolls n  WHERE  e.ENO = n.ENO  AND UNO = '{$userID}';";
$result = execute($sql);
sendJSON($result);
Exemplo n.º 19
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 schedule.<br>Please contact an admin for assistance.'));
             return;
         }
     } else {
         $ownerid = getUserlistID($data['owner']);
         $query = "UPDATE schedule " . "SET name = '{$data['name']}', " . "ownerid = {$ownerid} " . "WHERE id = {$data['rscid']}";
         doQuery($query);
     }
     if (!$add) {
         $query = "DELETE FROM scheduletimes WHERE scheduleid = {$data['rscid']}";
         doQuery($query, 101);
     }
     $qvals = array();
     foreach ($data['times'] as $time) {
         $qvals[] = "({$data['rscid']}, {$time['start']}, {$time['end']})";
     }
     $allvals = implode(',', $qvals);
     $query = "INSERT INTO scheduletimes " . "(scheduleid, start, end) " . "VALUES {$allvals}";
     doQuery($query, 101);
     # clear user resource cache for this type
     $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 1, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $key = getKey(array(array($this->restype . "Admin"), array("administer"), 0, 0, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $key = getKey(array(array($this->restype . "Admin"), array("manageGroup"), 0, 1, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $key = getKey(array(array($this->restype . "Admin"), array("manageGroup"), 0, 0, 0, 0));
     unset($_SESSION['userresources'][$key]);
     $tmp = $this->getData(array('includedeleted' => 0, 'rscid' => $data['rscid']));
     $data = $tmp[$data['rscid']];
     $arr = array('status' => 'success');
     if ($add) {
         $arr['action'] = 'add';
         $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';
     }
     $arr['data'] = $data;
     sendJSON($arr);
 }