Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
shibdib committed Jan 7, 2018
2 parents 6dca9cb + c41b148 commit 0a99301
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
2 changes: 1 addition & 1 deletion app.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
}
if (!isset($_GET['code'])) {
// If we don't have a code yet, we need to make the link
$scopes = 'guilds.join%20identify%20guilds';
$scopes = 'identify%20guilds';
$discordLink = url($config['discord']['clientId'], $config['discord']['redirectUri'], $scopes);
$app->render("discord.twig", array("botToken" => $config['discord']['botToken'], "discordLink" => $discordLink));

Expand Down
8 changes: 8 additions & 0 deletions cron.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
createAuthDb();

$users = getUsers();
$status = serverStatus();
if (!$status || $status['players'] === null || (int)$status['players'] < 100) {
die();
}
$members = $restcord->guild->listGuildMembers(['guild.id' => $config['discord']['guildId'], 'limit' => 1000]);
$roles = $restcord->guild->getGuildRoles(['guild.id' => $config['discord']['guildId']]);
$currentGuild = $restcord->guild->getGuild(['guild.id' => (int)$config['discord']['guildId']]);
Expand All @@ -49,6 +53,10 @@
break;
}
}
//Additional ESI Check
if (!(int)$characterData['corporation_id'] || (int)$characterData['corporation_id'] === null){
continue;
}
if (!$exists) {
$log->notice("$eveName has been removed from the database as they are no longer a member of the server.");
deleteUser($id);
Expand Down
25 changes: 25 additions & 0 deletions libraries/esi.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,30 @@ function corporationDetails($corpID)
return null;
}

return $data;
}

function serverStatus()
{
try {
// Initialize a new request for this URL
$ch = curl_init("https://esi.tech.ccp.is/latest/status/");
// Set the options for this request
curl_setopt_array($ch, array(
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data
CURLOPT_TIMEOUT => 8,
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate
));
// Fetch the data from the URL
$data = curl_exec($ch);
// Close the connection
curl_close($ch);
$data = json_decode($data, TRUE);

} catch (Exception $e) {
return null;
}

return $data;
}

0 comments on commit 0a99301

Please sign in to comment.