Skip to content

Instantly share code, notes, and snippets.

@Adjokip
Last active April 9, 2018 22:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Adjokip/22910db12d9533628b4d3964730796c2 to your computer and use it in GitHub Desktop.
Save Adjokip/22910db12d9533628b4d3964730796c2 to your computer and use it in GitHub Desktop.
checkJobs.php
<?php
function checkJobs($jobsArray, $db) {
$return = array();
foreach ($jobsArray as $remote_server_id => $jobs) {
foreach ($jobs as $jobId => $job) {
if (!isset($job['action'])) continue;
$hasAccess = ($db->isAdmin($_SESSION['user_id'])) ? $db->getGameHome($job['home_id']) : $db->getUserGameHome($_SESSION['user_id'], $job['home_id']);
if (!$hasAccess) continue;
if (array_key_exists('home_id', $job) && array_key_exists('ip', $job) && array_key_exists('port', $job) && hasValue($job['home_id']) && hasValue($job['ip']) && hasValue($job['port'])) {
$job['uniqueStr'] = $job['home_id']."_".$job['ip']."_".$job['port'];
} elseif(hasValue($job['home_id'])) {
$job['uniqueStr'] = $job['home_id'];
}
$job['job_id'] = $jobId;
$job['r_server_id'] = $remote_server_id;
$return[] = $job;
}
}
return $return;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment