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

Commit 0a99301

Browse files
committed
Merge remote-tracking branch 'origin/master'
2 parents 6dca9cb + c41b148 commit 0a99301

File tree

3 files changed

+34
-1
lines changed

3 files changed

+34
-1
lines changed

app.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
}
4646
if (!isset($_GET['code'])) {
4747
// If we don't have a code yet, we need to make the link
48-
$scopes = 'guilds.join%20identify%20guilds';
48+
$scopes = 'identify%20guilds';
4949
$discordLink = url($config['discord']['clientId'], $config['discord']['redirectUri'], $scopes);
5050
$app->render("discord.twig", array("botToken" => $config['discord']['botToken'], "discordLink" => $discordLink));
5151

cron.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@
3131
createAuthDb();
3232

3333
$users = getUsers();
34+
$status = serverStatus();
35+
if (!$status || $status['players'] === null || (int)$status['players'] < 100) {
36+
die();
37+
}
3438
$members = $restcord->guild->listGuildMembers(['guild.id' => $config['discord']['guildId'], 'limit' => 1000]);
3539
$roles = $restcord->guild->getGuildRoles(['guild.id' => $config['discord']['guildId']]);
3640
$currentGuild = $restcord->guild->getGuild(['guild.id' => (int)$config['discord']['guildId']]);
@@ -49,6 +53,10 @@
4953
break;
5054
}
5155
}
56+
//Additional ESI Check
57+
if (!(int)$characterData['corporation_id'] || (int)$characterData['corporation_id'] === null){
58+
continue;
59+
}
5260
if (!$exists) {
5361
$log->notice("$eveName has been removed from the database as they are no longer a member of the server.");
5462
deleteUser($id);

libraries/esi.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,5 +46,30 @@ function corporationDetails($corpID)
4646
return null;
4747
}
4848

49+
return $data;
50+
}
51+
52+
function serverStatus()
53+
{
54+
try {
55+
// Initialize a new request for this URL
56+
$ch = curl_init("https://esi.tech.ccp.is/latest/status/");
57+
// Set the options for this request
58+
curl_setopt_array($ch, array(
59+
CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect
60+
CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data
61+
CURLOPT_TIMEOUT => 8,
62+
CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate
63+
));
64+
// Fetch the data from the URL
65+
$data = curl_exec($ch);
66+
// Close the connection
67+
curl_close($ch);
68+
$data = json_decode($data, TRUE);
69+
70+
} catch (Exception $e) {
71+
return null;
72+
}
73+
4974
return $data;
5075
}

0 commit comments

Comments
 (0)