@@ -146,7 +146,7 @@ discard block |
||
| 146 | 146 | $conn = new mysqli($this->db, $this->dbUser, $this->dbPass, $this->dbName); |
| 147 | 147 | |
| 148 | 148 | //$sql = "SELECT characterID, discordID, eveName, role FROM authUsers WHERE active='yes'"; |
| 149 | - $sql = "SELECT characterID, discordID, eveName, active, role FROM authUsers"; |
|
| 149 | + $sql = "SELECT characterID, discordID, eveName, active, role FROM authUsers"; |
|
| 150 | 150 | |
| 151 | 151 | $result = $conn->query($sql); |
| 152 | 152 | |
@@ -175,130 +175,130 @@ discard block |
||
| 175 | 175 | |
| 176 | 176 | if ($result->num_rows >= 1) { |
| 177 | 177 | while ($rows = $result->fetch_assoc()) { |
| 178 | - $charID = $rows['characterID']; |
|
| 179 | - $discordID = $rows['discordID']; |
|
| 180 | - $role = $rows['role']; |
|
| 181 | - $member = $guild->members->get('id', $discordID); |
|
| 182 | - $eveName = $rows['eveName']; |
|
| 183 | - //Check if member has roles |
|
| 184 | - if (null === @$member->roles) { |
|
| 185 | - continue; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - //Auth things |
|
| 189 | - $character = characterDetails($charID); |
|
| 190 | - //if issue with esi, skip |
|
| 191 | - $timeout = 0; |
|
| 192 | - while (null === $character) { //try 10 times to pull characterDetails |
|
| 193 | - if ($timeout > 9) { |
|
| 194 | - continue; |
|
| 195 | - } |
|
| 196 | - else{ |
|
| 197 | - $character = characterDetails($charID); |
|
| 198 | - $timeout++; |
|
| 199 | - } |
|
| 200 | - } |
|
| 201 | - $corporationID = $character['corporation_id']; |
|
| 202 | - $corporationDetails = corpDetails($corporationID); |
|
| 203 | - $timeout = 0; |
|
| 204 | - while (null === $corporationDetails) { //try 10 times to pull corporationDetails |
|
| 205 | - if ($timeout > 9) { |
|
| 206 | - continue; |
|
| 207 | - } |
|
| 208 | - else{ |
|
| 209 | - $corporationDetails = corpDetails($corporationID); |
|
| 210 | - $timeout++; |
|
| 211 | - } |
|
| 212 | - } |
|
| 213 | - $allianceID = @$corporationDetails['alliance_id']; |
|
| 214 | - if ($rows['active'] == "yes"){ |
|
| 215 | - |
|
| 216 | - //check if user authed based on standings |
|
| 217 | - $standings = null; |
|
| 218 | - if ($role === 'blue' || 'neut' || 'red') { |
|
| 219 | - $allianceContacts = getContacts($allianceID); |
|
| 220 | - $corpContacts = getContacts($corporationID); |
|
| 221 | - if ($role === 'blue' && ((int) $allianceContacts['standing'] === 5 || 10 || (int) $corpContacts['standing'] === 5 || 10)) { |
|
| 222 | - $standings = 1; |
|
| 223 | - } |
|
| 224 | - if ($role === 'red' && ((int) $allianceContacts['standing'] === -5 || -10 || (int) $corpContacts['standing'] === -5 || -10)) { |
|
| 225 | - $standings = 1; |
|
| 226 | - } |
|
| 227 | - if ($role === 'neut' && ((int) $allianceContacts['standing'] === 0 || (int) $corpContacts['standing'] === 0 || (@(int) $allianceContacts['standings'] === null || '' && @(int) $corpContacts['standings'] === null || ''))) { |
|
| 228 | - $standings = 1; |
|
| 229 | - } |
|
| 230 | - } |
|
| 231 | - if (!in_array((int) $allianceID, $allianceArray) && !in_array((int) $corporationID, $corpArray) && null === $standings) { |
|
| 232 | - // Deactivate user in database |
|
| 233 | - $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'"; |
|
| 234 | - $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are no longer in a correct corp/alliance."); |
|
| 235 | - $conn->query($sql); |
|
| 236 | - continue; |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - elseif($rows['active'] == "no") { |
|
| 240 | - $roles = @$guild->roles; |
|
| 241 | - $member = @$guild->members->get('id', $discordID); |
|
| 242 | - if (in_array((int) $allianceID, $allianceArray) || in_array((int) $corporationID, $corpArray)) { |
|
| 243 | - foreach ($this->authGroups as $authGroup) { |
|
| 244 | - //Check if it's set to match corp and alliance |
|
| 245 | - if ($authGroup['corpID'] !== 0 && $authGroup['allianceID'] !== 0) { |
|
| 246 | - //Check if corpID matches |
|
| 247 | - if ($corpID === $authGroup['corpID'] && $allianceID === $authGroup['allianceID']) { |
|
| 248 | - foreach ($roles as $role) { |
|
| 249 | - if ((string) $role->name === (string) $authGroup['corpMemberRole']) { |
|
| 250 | - $member->addRole($role); |
|
| 251 | - } |
|
| 252 | - if ((string) $role->name === (string) $authGroup['allyMemberRole']) { |
|
| 253 | - $member->addRole($role); |
|
| 254 | - $role = 'corp/ally'; |
|
| 255 | - $guild->members->save($member); |
|
| 256 | - // Deactivate user in database |
|
| 257 | - $sql = "UPDATE authUsers SET active='yes' WHERE discordID='$discordID'"; |
|
| 258 | - $this->logger->addInfo("AuthCheck: {$eveName} account has been activates as they are in correct corp/alliance."); |
|
| 259 | - $conn->query($sql); |
|
| 260 | - } |
|
| 261 | - } |
|
| 262 | - break; |
|
| 263 | - } |
|
| 264 | - } elseif ($authGroup['corpID'] !== 0 || $authGroup['allianceID'] !== 0) { |
|
| 265 | - //Check if corpID matches |
|
| 266 | - if ($corpID === $authGroup['corpID']) { |
|
| 267 | - foreach ($roles as $role) { |
|
| 268 | - if ((string) $role->name === (string) $authGroup['corpMemberRole']) { |
|
| 269 | - $member->addRole($role); |
|
| 270 | - $role = 'corp'; |
|
| 271 | - $guild->members->save($member); |
|
| 272 | - // Deactivate user in database |
|
| 273 | - $sql = "UPDATE authUsers SET active='yes' WHERE discordID='$discordID'"; |
|
| 274 | - $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are in correct corp/alliance."); |
|
| 275 | - $conn->query($sql); |
|
| 276 | - } |
|
| 277 | - } |
|
| 278 | - break; |
|
| 279 | - } |
|
| 280 | - //Check if allianceID matches |
|
| 281 | - if ($allianceID === $authGroup['allianceID'] && $authGroup['allianceID'] !== 0) { |
|
| 282 | - foreach ($roles as $role) { |
|
| 283 | - if ((string) $role->name === (string) $authGroup['allyMemberRole']) { |
|
| 284 | - $member->addRole($role); |
|
| 285 | - $role = 'ally'; |
|
| 286 | - $guild->members->save($member); |
|
| 287 | - // Deactivate user in database |
|
| 288 | - $sql = "UPDATE authUsers SET active='yes' WHERE discordID='$discordID'"; |
|
| 289 | - $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are in correct corp/alliance."); |
|
| 290 | - $conn->query($sql); |
|
| 291 | - } |
|
| 292 | - } |
|
| 293 | - break; |
|
| 294 | - } |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - } |
|
| 298 | - } |
|
| 299 | - $nextCheck = time() + 10800; |
|
| 300 | - setPermCache('permsLastChecked', $nextCheck); |
|
| 301 | - } |
|
| 178 | + $charID = $rows['characterID']; |
|
| 179 | + $discordID = $rows['discordID']; |
|
| 180 | + $role = $rows['role']; |
|
| 181 | + $member = $guild->members->get('id', $discordID); |
|
| 182 | + $eveName = $rows['eveName']; |
|
| 183 | + //Check if member has roles |
|
| 184 | + if (null === @$member->roles) { |
|
| 185 | + continue; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + //Auth things |
|
| 189 | + $character = characterDetails($charID); |
|
| 190 | + //if issue with esi, skip |
|
| 191 | + $timeout = 0; |
|
| 192 | + while (null === $character) { //try 10 times to pull characterDetails |
|
| 193 | + if ($timeout > 9) { |
|
| 194 | + continue; |
|
| 195 | + } |
|
| 196 | + else{ |
|
| 197 | + $character = characterDetails($charID); |
|
| 198 | + $timeout++; |
|
| 199 | + } |
|
| 200 | + } |
|
| 201 | + $corporationID = $character['corporation_id']; |
|
| 202 | + $corporationDetails = corpDetails($corporationID); |
|
| 203 | + $timeout = 0; |
|
| 204 | + while (null === $corporationDetails) { //try 10 times to pull corporationDetails |
|
| 205 | + if ($timeout > 9) { |
|
| 206 | + continue; |
|
| 207 | + } |
|
| 208 | + else{ |
|
| 209 | + $corporationDetails = corpDetails($corporationID); |
|
| 210 | + $timeout++; |
|
| 211 | + } |
|
| 212 | + } |
|
| 213 | + $allianceID = @$corporationDetails['alliance_id']; |
|
| 214 | + if ($rows['active'] == "yes"){ |
|
| 215 | + |
|
| 216 | + //check if user authed based on standings |
|
| 217 | + $standings = null; |
|
| 218 | + if ($role === 'blue' || 'neut' || 'red') { |
|
| 219 | + $allianceContacts = getContacts($allianceID); |
|
| 220 | + $corpContacts = getContacts($corporationID); |
|
| 221 | + if ($role === 'blue' && ((int) $allianceContacts['standing'] === 5 || 10 || (int) $corpContacts['standing'] === 5 || 10)) { |
|
| 222 | + $standings = 1; |
|
| 223 | + } |
|
| 224 | + if ($role === 'red' && ((int) $allianceContacts['standing'] === -5 || -10 || (int) $corpContacts['standing'] === -5 || -10)) { |
|
| 225 | + $standings = 1; |
|
| 226 | + } |
|
| 227 | + if ($role === 'neut' && ((int) $allianceContacts['standing'] === 0 || (int) $corpContacts['standing'] === 0 || (@(int) $allianceContacts['standings'] === null || '' && @(int) $corpContacts['standings'] === null || ''))) { |
|
| 228 | + $standings = 1; |
|
| 229 | + } |
|
| 230 | + } |
|
| 231 | + if (!in_array((int) $allianceID, $allianceArray) && !in_array((int) $corporationID, $corpArray) && null === $standings) { |
|
| 232 | + // Deactivate user in database |
|
| 233 | + $sql = "UPDATE authUsers SET active='no' WHERE discordID='$discordID'"; |
|
| 234 | + $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are no longer in a correct corp/alliance."); |
|
| 235 | + $conn->query($sql); |
|
| 236 | + continue; |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + elseif($rows['active'] == "no") { |
|
| 240 | + $roles = @$guild->roles; |
|
| 241 | + $member = @$guild->members->get('id', $discordID); |
|
| 242 | + if (in_array((int) $allianceID, $allianceArray) || in_array((int) $corporationID, $corpArray)) { |
|
| 243 | + foreach ($this->authGroups as $authGroup) { |
|
| 244 | + //Check if it's set to match corp and alliance |
|
| 245 | + if ($authGroup['corpID'] !== 0 && $authGroup['allianceID'] !== 0) { |
|
| 246 | + //Check if corpID matches |
|
| 247 | + if ($corpID === $authGroup['corpID'] && $allianceID === $authGroup['allianceID']) { |
|
| 248 | + foreach ($roles as $role) { |
|
| 249 | + if ((string) $role->name === (string) $authGroup['corpMemberRole']) { |
|
| 250 | + $member->addRole($role); |
|
| 251 | + } |
|
| 252 | + if ((string) $role->name === (string) $authGroup['allyMemberRole']) { |
|
| 253 | + $member->addRole($role); |
|
| 254 | + $role = 'corp/ally'; |
|
| 255 | + $guild->members->save($member); |
|
| 256 | + // Deactivate user in database |
|
| 257 | + $sql = "UPDATE authUsers SET active='yes' WHERE discordID='$discordID'"; |
|
| 258 | + $this->logger->addInfo("AuthCheck: {$eveName} account has been activates as they are in correct corp/alliance."); |
|
| 259 | + $conn->query($sql); |
|
| 260 | + } |
|
| 261 | + } |
|
| 262 | + break; |
|
| 263 | + } |
|
| 264 | + } elseif ($authGroup['corpID'] !== 0 || $authGroup['allianceID'] !== 0) { |
|
| 265 | + //Check if corpID matches |
|
| 266 | + if ($corpID === $authGroup['corpID']) { |
|
| 267 | + foreach ($roles as $role) { |
|
| 268 | + if ((string) $role->name === (string) $authGroup['corpMemberRole']) { |
|
| 269 | + $member->addRole($role); |
|
| 270 | + $role = 'corp'; |
|
| 271 | + $guild->members->save($member); |
|
| 272 | + // Deactivate user in database |
|
| 273 | + $sql = "UPDATE authUsers SET active='yes' WHERE discordID='$discordID'"; |
|
| 274 | + $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are in correct corp/alliance."); |
|
| 275 | + $conn->query($sql); |
|
| 276 | + } |
|
| 277 | + } |
|
| 278 | + break; |
|
| 279 | + } |
|
| 280 | + //Check if allianceID matches |
|
| 281 | + if ($allianceID === $authGroup['allianceID'] && $authGroup['allianceID'] !== 0) { |
|
| 282 | + foreach ($roles as $role) { |
|
| 283 | + if ((string) $role->name === (string) $authGroup['allyMemberRole']) { |
|
| 284 | + $member->addRole($role); |
|
| 285 | + $role = 'ally'; |
|
| 286 | + $guild->members->save($member); |
|
| 287 | + // Deactivate user in database |
|
| 288 | + $sql = "UPDATE authUsers SET active='yes' WHERE discordID='$discordID'"; |
|
| 289 | + $this->logger->addInfo("AuthCheck: {$eveName} account has been deactivated as they are in correct corp/alliance."); |
|
| 290 | + $conn->query($sql); |
|
| 291 | + } |
|
| 292 | + } |
|
| 293 | + break; |
|
| 294 | + } |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + } |
|
| 298 | + } |
|
| 299 | + $nextCheck = time() + 10800; |
|
| 300 | + setPermCache('permsLastChecked', $nextCheck); |
|
| 301 | + } |
|
| 302 | 302 | } |
| 303 | 303 | $nextCheck = time() + 10800; |
| 304 | 304 | setPermCache('permsLastChecked', $nextCheck); |
@@ -449,17 +449,17 @@ discard block |
||
| 449 | 449 | |
| 450 | 450 | //corp ticker |
| 451 | 451 | if ($this->corpTickers === 'true') { |
| 452 | - $timeout = 0; |
|
| 453 | - $character = characterDetails($charID); |
|
| 454 | - while (null === $character) { //try 10 times to pull characterDetails |
|
| 455 | - if ($timeout > 9) { |
|
| 456 | - continue; |
|
| 457 | - } |
|
| 458 | - else{ |
|
| 459 | - $character = characterDetails($charID); |
|
| 460 | - $timeout++; |
|
| 461 | - } |
|
| 462 | - } |
|
| 452 | + $timeout = 0; |
|
| 453 | + $character = characterDetails($charID); |
|
| 454 | + while (null === $character) { //try 10 times to pull characterDetails |
|
| 455 | + if ($timeout > 9) { |
|
| 456 | + continue; |
|
| 457 | + } |
|
| 458 | + else{ |
|
| 459 | + $character = characterDetails($charID); |
|
| 460 | + $timeout++; |
|
| 461 | + } |
|
| 462 | + } |
|
| 463 | 463 | if (!array_key_exists('corporation_id', $character)) { |
| 464 | 464 | continue; |
| 465 | 465 | } |