本文整理汇总了PHP中getKey函数的典型用法代码示例。如果您正苦于以下问题:PHP getKey函数的具体用法?PHP getKey怎么用?PHP getKey使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getKey函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getArrOut
function getArrOut($calc, $count)
{
$output = [];
$calcOut = ['a' => 0, 'b' => 0, 'c' => 0];
$vesIn = getVes($calc);
for ($i = 1; $i <= $count; $i++) {
$keyCalc = getKey($calc, $vesIn, $calcOut);
foreach ($calc as $key => $arrin) {
if ($keyCalc == $key) {
$calcOut[$key] = $calcOut[$key] + 1;
}
}
}
$output['calc'] = $calcOut;
$output['ves'] = $vesIn;
$output['vesout'] = getVes($calcOut);
return $output;
}
示例2: getvideo
function getvideo($id, $pid = 2)
{
$hz = '_letv';
$pidarrs[] = '350';
$pidarrs[] = '1000';
$pidarrs[] = '720p';
$stime = 'http://api.letv.com/time?tn=0.' . time();
$str = get_curl_contents($stime);
$t = preg_match('|{"stime":(\\d+)}|', $str, $matchs) ? $matchs[1] : false;
$content = get_curl_contents('http://api.letv.com/mms/out/video/play?id=' . $id . '&platid=1&splatid=101&domain=http://www.letv.com&tkey=' . getKey($t), 0, 0, 1);
$data = preg_match('~<playurl><!\\[cdata\\[(.*)\\]\\]></playurl>~iUs', $content, $matchs) ? $matchs[1] : false;
$json = json_decode($data);
$pido = '';
if (strpos($data, '"720p"')) {
$pido = '3';
}
if (!$pido) {
if (strpos($data, '"1000"')) {
$pido = '2';
}
}
if (!$pido) {
$pido = '1';
}
switch ($pido) {
case '1':
$qvars = __BQ__ . '_' . $id . $hz;
break;
case '2':
$qvars = __BQ__ . '_' . $id . $hz . '|' . __GQ__ . '_' . $id . $hz;
break;
case '3':
$qvars = __BQ__ . '_' . $id . $hz . '|' . __GQ__ . '_' . $id . $hz . '|' . __CQ__ . '_' . $id . $hz;
break;
default:
$qvars = $id . $hz;
break;
}
$pid = min($pid, $pido);
$dispatch = $json->dispatch->{$pidarrs}[$pid - 1];
$urllist['urls'][0]['url'] = str_replace('tss=ios', 'tss=no', $dispatch[0]);
$urllist['vars'] = '{h->1}{a->' . $qvars . '}{f->' . __HOSTURL__ . '?url=[$pat' . ($pid - 1) . ']}';
return $urllist;
}
示例3: getLoginJSONP
function getLoginJSONP($type)
{
require_once "../leader/jsupport.php";
$success = false;
$username = "";
$key = "";
//Ignore any messages from the login system that may corrupt our JSON
ob_start();
if (array_key_exists("username", $_COOKIE) && array_key_exists("key", $_COOKIE)) {
//We may have saved these via javascript. Try loading them
$username = strtolower($_COOKIE["username"]);
$key = $_COOKIE["key"];
$success = true;
} else {
if (checkPostLogin() == 7) {
//Can we log in with leaderboards?
$username = strtolower(getPostValue("username"));
$key = getKey($username);
$success = true;
} else {
//Nope
$success = false;
}
}
ob_end_clean();
//Return their key formatted as specified
if ($success) {
if ($type === "JS") {
return "webchat.setUser(\"{$username}\", \"{$key}\", \"true\"); webchat.connect();";
} else {
if ($type === "JSON") {
return json_encode(array("success" => true, "username" => $username, "key" => $key));
}
}
} else {
if ($type === "JS") {
return "webchat.enableLogin(true); webchat.setLoginStatus(\"No Saved Login Found\");";
} else {
if ($type === "JSON") {
return json_encode(array("success" => false));
}
}
}
}
示例4: getCompStateFlow
function getCompStateFlow($compid)
{
$key = getKey(array($compid));
if (array_key_exists($key, $_SESSION['compstateflow'])) {
return $_SESSION['compstateflow'][$key];
}
# get id for repeat state, useful because several of the calling functions
# need this information
$query = "SELECT id FROM computerloadstate WHERE loadstatename = 'repeat'";
$qh = doQuery($query, 101);
if (!($row = mysql_fetch_assoc($qh))) {
return array();
}
$loadstates['repeatid'] = $row['id'];
$query = "SELECT `type` FROM computer WHERE id = {$compid}";
$qh = doQuery($query, 101);
if (!($row = mysql_fetch_assoc($qh))) {
return array();
}
$type = $row['type'];
$query = "SELECT cf.computerloadstateid AS stateid, " . "cs1.prettyname AS state, " . "cs1.loadstatename AS statename, " . "cf.nextstateid, " . "cs2.prettyname AS nextstate, " . "cs1.est AS statetime " . "FROM computerloadstate cs1, " . "computerloadflow cf " . "LEFT JOIN computerloadstate cs2 ON (cf.nextstateid = cs2.id) " . "WHERE cf.computerloadstateid = cs1.id AND " . "cf.type = '{$type}' ";
$query2 = $query . "AND cf.computerloadstateid NOT IN " . "(SELECT nextstateid FROM computerloadflow WHERE `type` = '{$type}' " . "AND nextstateid IS NOT NULL)";
$qh = doQuery($query2, 101);
if (!($row = mysql_fetch_assoc($qh))) {
return array();
}
$loadstates['data'][$row['stateid']] = $row;
$loadstates['stateids'] = array($row['stateid']);
$loadstates['nextstates'] = array($row['stateid'] => $row['nextstateid']);
$loadstates['totaltime'] = 0;
for ($i = 0; $i < 100; $i++) {
# don't want an endless loop
$query2 = $query . "AND cf.computerloadstateid = {$row['nextstateid']} " . "AND `type` = '{$type}'";
$qh = doQuery($query2, 101);
if (!($row = mysql_fetch_assoc($qh))) {
$_SESSION['compstateflow'][$key] = $loadstates;
return $loadstates;
} else {
array_push($loadstates['stateids'], $row['stateid']);
$loadstates['nextstates'][$row['stateid']] = $row['nextstateid'];
$loadstates['totaltime'] += $row['statetime'];
$loadstates['data'][$row['stateid']] = $row;
}
if (empty($row['nextstateid'])) {
$_SESSION['compstateflow'][$key] = $loadstates;
return $loadstates;
}
}
$_SESSION['compstateflow'][$key] = $loadstates;
return $loadstates;
}
示例5: getConnectMethods
function getConnectMethods($imageid)
{
$key = getKey(array('getConnectMethods', $imageid));
if (array_key_exists($key, $_SESSION['usersessiondata'])) {
return $_SESSION['usersessiondata'][$key];
}
$query = "SELECT DISTINCT c.id, " . "c.description, " . "cm.autoprovisioned " . "FROM connectmethod c, " . "connectmethodmap cm, " . "image i " . "LEFT JOIN OS o ON (o.id = i.OSid) " . "LEFT JOIN OStype ot ON (ot.name = o.type) " . "WHERE i.id = {$imageid} AND " . "cm.connectmethodid = c.id AND " . "cm.autoprovisioned IS NOT NULL AND " . "(cm.OStypeid = ot.id OR " . "cm.OSid = o.id) " . "ORDER BY c.description";
$methods = array();
$qh = doQuery($query, 101);
while ($row = mysql_fetch_assoc($qh)) {
$methods[$row['id']] = $row;
}
$_SESSION['usersessiondata'][$key] = $methods;
return $methods;
}
示例6: AJsaveResource
//.........这里部分代码省略.........
}
# 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);
}
示例7: getKey
<?php
include "getKey.php";
$key = getKey();
$file = "https://global.api.pvp.net/api/lol/static-data/na/v1.2/champion?champData=all&api_key=" . $key;
// header('Content-Type: application/json');
echo file_get_contents($file);
示例8: AudioStreamConfig
$audioStreamConfig = new AudioStreamConfig();
$audioStreamConfig->bitrate = 128000;
$audioStreamConfig->samplerate = 44100;
$encodingProfileConfig->audioStreamConfigs[] = $audioStreamConfig;
/* CREATE ENCODING PROFILE */
$encodingProfile = EncodingProfile::create($encodingProfileConfig);
$jobConfig = new JobConfig();
$jobConfig->speed = \bitcodin\JobSpeedTypes::STANDARD;
$jobConfig->encodingProfile = $encodingProfile;
$jobConfig->input = $input;
$jobConfig->manifestTypes[] = ManifestTypes::M3U8;
/* CREATE JOB */
$job = Job::create($jobConfig);
/* WAIT UNTIL JOB IS FINISHED */
do {
$job->update();
sleep(1);
} while ($job->status != Job::STATUS_FINISHED && $job->status != Job::STATUS_ERROR);
$outputConfig = new FtpOutputConfig();
$outputConfig->name = "TestS3Output";
$outputConfig->host = str_replace('ftp://', '', getKey('ftpServer'));
$outputConfig->username = getKey('ftpUser');
$outputConfig->password = getKey('ftpPassword');
$output = Output::create($outputConfig);
/* TRANSFER JOB OUTPUT */
$job->transfer($output);
/* HELPER FUNCTION */
function getKey($key)
{
return json_decode(file_get_contents(__DIR__ . '/test/config.json'))->{$key};
}
示例9: checkUserHasPriv
function checkUserHasPriv($priv, $uid, $node, $privs = 0, $cascadePrivs = 0)
{
global $user;
$key = getKey(array($priv, $uid, $node, $privs, $cascadePrivs));
if (array_key_exists($key, $_SESSION['userhaspriv'])) {
return $_SESSION['userhaspriv'][$key];
}
if ($user["id"] != $uid) {
$_user = getUserInfo($uid);
} else {
$_user = $user;
}
$affilUserid = "{$_user['unityid']}@{$_user['affiliation']}";
if (!is_array($privs)) {
$privs = getNodePrivileges($node, 'users');
$privs = getNodePrivileges($node, 'usergroups', $privs);
}
if (!is_array($cascadePrivs)) {
$cascadePrivs = getNodeCascadePrivileges($node, 'users');
$cascadePrivs = getNodeCascadePrivileges($node, 'usergroups', $cascadePrivs);
}
// if user (has $priv at this node) ||
# (has cascaded $priv && ! have block at this node) return 1
if (array_key_exists($affilUserid, $privs["users"]) && in_array($priv, $privs["users"][$affilUserid]) || array_key_exists($affilUserid, $cascadePrivs["users"]) && in_array($priv, $cascadePrivs["users"][$affilUserid]) && (!array_key_exists($affilUserid, $privs["users"]) || !in_array("block", $privs["users"][$affilUserid]))) {
$_SESSION['userhaspriv'][$key] = 1;
return 1;
}
foreach ($_user["groups"] as $groupname) {
// if group (has $priv at this node) ||
# (has cascaded $priv && ! have block at this node) return 1
if (array_key_exists($groupname, $privs["usergroups"]) && in_array($priv, $privs["usergroups"][$groupname]['privs']) || array_key_exists($groupname, $cascadePrivs["usergroups"]) && in_array($priv, $cascadePrivs["usergroups"][$groupname]['privs']) && (!array_key_exists($groupname, $privs["usergroups"]) || !in_array("block", $privs["usergroups"][$groupname]['privs']))) {
$_SESSION['userhaspriv'][$key] = 1;
return 1;
}
}
$_SESSION['userhaspriv'][$key] = 0;
return 0;
}
示例10: getKey
<?php
function getKey()
{
if ($handle = opendir('./scripts/resources/')) {
while (false !== ($entry = readdir($handle))) {
if ($entry != "." && $entry != "..") {
$path = "./scripts/resources/" . $entry;
}
}
closedir($handle);
}
return $key = file_get_contents($path);
}
$url = "https://data.opentechinstitute.org/api/3/action/";
$auth_key = getKey();
$resource_id = "78377408-b750-4db9-bffb-dec9ef9c9477";
示例11: getKey
/**
* [getKey 根据value得到数组key]
* @param [type] $arr [数组]
* @param [type] $value [值]
* @return [type] [description]
*/
function getKey($arr, $value)
{
if (!is_array($arr)) {
return null;
}
foreach ($arr as $k => $v) {
$return = getKey($v, $value);
if ($v == $value) {
return $k;
}
if (!is_null($return)) {
return $return;
}
}
}
示例12: array
<?php
require_once "_key.php";
return array('debug' => true, 'url' => 'https://neshto.shantavo.com', 'timezone' => 'EST', 'locale' => 'bg', 'fallback_locale' => 'en', 'key' => getKey(), 'cipher' => MCRYPT_RIJNDAEL_128, 'providers' => array('Illuminate\\Foundation\\Providers\\ArtisanServiceProvider', 'Illuminate\\Auth\\AuthServiceProvider', 'Illuminate\\Cache\\CacheServiceProvider', 'Illuminate\\Session\\CommandsServiceProvider', 'Illuminate\\Foundation\\Providers\\ConsoleSupportServiceProvider', 'Illuminate\\Routing\\ControllerServiceProvider', 'Illuminate\\Cookie\\CookieServiceProvider', 'Illuminate\\Database\\DatabaseServiceProvider', 'Illuminate\\Encryption\\EncryptionServiceProvider', 'Illuminate\\Filesystem\\FilesystemServiceProvider', 'Illuminate\\Hashing\\HashServiceProvider', 'Illuminate\\Html\\HtmlServiceProvider', 'Illuminate\\Log\\LogServiceProvider', 'Illuminate\\Mail\\MailServiceProvider', 'Illuminate\\Database\\MigrationServiceProvider', 'Illuminate\\Pagination\\PaginationServiceProvider', 'Illuminate\\Queue\\QueueServiceProvider', 'Illuminate\\Redis\\RedisServiceProvider', 'Illuminate\\Remote\\RemoteServiceProvider', 'Illuminate\\Auth\\Reminders\\ReminderServiceProvider', 'Illuminate\\Database\\SeedServiceProvider', 'Illuminate\\Session\\SessionServiceProvider', 'Illuminate\\Translation\\TranslationServiceProvider', 'Illuminate\\Validation\\ValidationServiceProvider', 'Illuminate\\View\\ViewServiceProvider', 'Illuminate\\Workbench\\WorkbenchServiceProvider', 'Roumen\\Feed\\FeedServiceProvider', 'Roumen\\Sitemap\\SitemapServiceProvider', 'Roumen\\Disqus\\DisqusServiceProvider', 'Roumen\\Asset\\AssetServiceProvider', 'Greggilbert\\Recaptcha\\RecaptchaServiceProvider', 'Mews\\Purifier\\PurifierServiceProvider'), 'manifest' => storage_path() . '/meta', 'aliases' => array('App' => 'Illuminate\\Support\\Facades\\App', 'Artisan' => 'Illuminate\\Support\\Facades\\Artisan', 'Auth' => 'Illuminate\\Support\\Facades\\Auth', 'Blade' => 'Illuminate\\Support\\Facades\\Blade', 'Cache' => 'Illuminate\\Support\\Facades\\Cache', 'ClassLoader' => 'Illuminate\\Support\\ClassLoader', 'Config' => 'Illuminate\\Support\\Facades\\Config', 'Controller' => 'Illuminate\\Routing\\Controller', 'Cookie' => 'Illuminate\\Support\\Facades\\Cookie', 'Crypt' => 'Illuminate\\Support\\Facades\\Crypt', 'DB' => 'Illuminate\\Support\\Facades\\DB', 'Eloquent' => 'Illuminate\\Database\\Eloquent\\Model', 'Event' => 'Illuminate\\Support\\Facades\\Event', 'File' => 'Illuminate\\Support\\Facades\\File', 'Form' => 'Illuminate\\Support\\Facades\\Form', 'Hash' => 'Illuminate\\Support\\Facades\\Hash', 'HTML' => 'Illuminate\\Support\\Facades\\HTML', 'Input' => 'Illuminate\\Support\\Facades\\Input', 'Lang' => 'Illuminate\\Support\\Facades\\Lang', 'Log' => 'Illuminate\\Support\\Facades\\Log', 'Mail' => 'Illuminate\\Support\\Facades\\Mail', 'Paginator' => 'Illuminate\\Support\\Facades\\Paginator', 'Password' => 'Illuminate\\Support\\Facades\\Password', 'Queue' => 'Illuminate\\Support\\Facades\\Queue', 'Redirect' => 'Illuminate\\Support\\Facades\\Redirect', 'Redis' => 'Illuminate\\Support\\Facades\\Redis', 'Request' => 'Illuminate\\Support\\Facades\\Request', 'Response' => 'Illuminate\\Support\\Facades\\Response', 'Route' => 'Illuminate\\Support\\Facades\\Route', 'Schema' => 'Illuminate\\Support\\Facades\\Schema', 'Seeder' => 'Illuminate\\Database\\Seeder', 'Session' => 'Illuminate\\Support\\Facades\\Session', 'SoftDeletingTrait' => 'Illuminate\\Database\\Eloquent\\SoftDeletingTrait', 'SSH' => 'Illuminate\\Support\\Facades\\SSH', 'Str' => 'Illuminate\\Support\\Str', 'URL' => 'Illuminate\\Support\\Facades\\URL', 'Validator' => 'Illuminate\\Support\\Facades\\Validator', 'View' => 'Illuminate\\Support\\Facades\\View', 'Asset' => 'Roumen\\Asset\\Asset', 'Feed' => 'Roumen\\Feed\\Facades\\Feed', 'Purifier' => 'Mews\\Purifier\\Facades\\Purifier'));
示例13: getKey
<?php
$input = "iwrupvqb";
echo getKey($input);
function getKey($input)
{
$count = 346386;
while (true) {
$hash = str_split(md5($input . $count), 6);
if ($hash[0] === "000000") {
return $count;
}
$count++;
}
}
示例14: getServerProfileGroups
function getServerProfileGroups($userid, $type)
{
global $user;
$key = getKey(array('getServerProfileAdminGroups', $userid, $type));
if (array_key_exists($key, $_SESSION['usersessiondata'])) {
return $_SESSION['usersessiondata'][$key];
}
$resources = getUserResources(array('serverCheckOut', 'serverProfileAdmin'), array('available', 'administer'));
$ids = array_keys($resources['serverprofile']);
$inids = implode(',', $ids);
if (empty($inids)) {
$_SESSION['usersessiondata'][$key] = array();
return array();
}
if ($type == 'admin') {
$field = 'admingroupid';
} else {
$field = 'logingroupid';
}
if ($user['showallgroups']) {
$query = "SELECT DISTINCT(u.id), " . "CONCAT(u.name, '@', a.name) AS name " . "FROM serverprofile s, " . "usergroup u, " . "affiliation a " . "WHERE s.{$field} = u.id AND " . "u.affiliationid = a.id AND " . "s.id IN ({$inids}) " . "ORDER BY name";
} else {
$query = "SELECT DISTINCT(u.id), " . "u.name " . "FROM serverprofile s, " . "usergroup u " . "WHERE s.{$field} = u.id AND " . "s.id IN ({$inids}) " . "ORDER BY name";
}
$qh = doQuery($query, 101);
$groups = array();
while ($row = mysql_fetch_assoc($qh)) {
$groups[$row['id']] = $row['name'];
}
$_SESSION['usersessiondata'][$key] = $groups;
return $groups;
}
示例15: AJremImageConnectMethod
function AJremImageConnectMethod()
{
$imageid = getContinuationVar('imageid');
$methods = getContinuationVar('methods');
$revids = getContinuationVar('revids');
$curmethods = getImageConnectMethods($imageid);
$remidlist = mysql_real_escape_string(processInputVar('ids', ARG_STRING));
$remids = explode(',', $remidlist);
$revid = processInputVar('revid', ARG_NUMERIC);
$newimage = getContinuationVar('newimage');
foreach ($remids as $id) {
if (!is_numeric($id)) {
$arr = array('error' => 'invalidinput', 'msg' => i("Non-numeric data was submitted for a connection method id."));
sendJSON($arr);
return;
}
}
if ($revid != 0 && !in_array($revid, $revids)) {
$arr = array('error' => 'invalidrevision', 'msg' => i("Invalid revision id submitted."));
sendJSON($arr);
return;
}
if (!$newimage) {
if ($revid == 0) {
$revid = getProductionRevisionid($imageid);
}
# delete any current entries for method and image
$query = "DELETE FROM connectmethodmap " . "WHERE imagerevisionid = {$revid} AND " . "connectmethodid IN ({$remidlist}) AND " . "autoprovisioned IS NULL";
doQuery($query, 101);
# query to see if enabled for OStype or OS
$insvals = array();
foreach ($remids as $id) {
$query = "SELECT cm.connectmethodid " . "FROM connectmethodmap cm, " . "image i " . "LEFT JOIN OS o ON (o.id = i.OSid) " . "LEFT JOIN OStype ot ON (ot.name = o.type) " . "WHERE i.id = {$imageid} AND " . "cm.autoprovisioned IS NULL AND " . "cm.connectmethodid = {$id} AND " . "cm.disabled = 0 AND " . "(cm.OStypeid = ot.id OR " . "cm.OSid = o.id)";
$qh = doQuery($query, 101);
if (mysql_num_rows($qh)) {
# if so, add disabled entry for image revision and method
$insvals[] = "({$id}, {$revid}, 1)";
}
}
if (count($insvals)) {
$allinsvals = implode(',', $insvals);
$query = "INSERT INTO connectmethodmap " . "(connectmethodid, " . "imagerevisionid, " . "disabled) " . "VALUES {$allinsvals}";
doQuery($query, 101);
}
}
$cdata = $this->basecdata;
$cdata['imageid'] = $imageid;
$cdata['methods'] = $methods;
$cdata['revids'] = $revids;
$cdata['newimage'] = $newimage;
$addcont = addContinuationsEntry('AJaddImageConnectMethod', $cdata, 3600, 1, 0);
$remcont = addContinuationsEntry('AJremImageConnectMethod', $cdata, 3600, 1, 0);
$arr = array('addcont' => $addcont, 'remcont' => $remcont);
sendJSON($arr);
$key = getKey(array('getImageConnectMethods', (int) $imageid, (int) $revid));
if (array_key_exists($key, $_SESSION['usersessiondata'])) {
unset($_SESSION['usersessiondata'][$key]);
}
$key = getKey(array('getImageConnectMethods', (int) $imageid, 0));
if (array_key_exists($key, $_SESSION['usersessiondata'])) {
unset($_SESSION['usersessiondata'][$key]);
}
}