Ejemplo n.º 1
0
 public function showIndex()
 {
     // Prepare some summarized totals for the home view to display in the
     // widgets
     // EVE Online Server Information
     $server = EveServerServerStatus::find(1);
     // Key Information
     // If the user has 0 keys, we can 0 all of the values
     // If the user has keys, determine values only applicable to
     // this users keys
     if (!\Auth::isSuperUser()) {
         if (count(Session::get('valid_keys')) > 0) {
             $total_keys = SeatKey::whereIn('keyID', Session::get('valid_keys'))->count();
             $total_characters = EveCharacterCharacterSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->count();
             $total_corporations = EveCorporationCorporationSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.corporationID', '=', 'corporation_corporationsheet.corporationID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '=', 'Corporation')->count();
             $total_char_isk = EveCharacterCharacterSheet::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->sum('balance');
             $total_corp_isk = EveCorporationAccountBalance::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.corporationID', '=', 'corporation_accountbalance.corporationID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '=', 'Corporation')->where('accountKey', '!=', EveCorporationAccountBalance::Dust_Account_Key)->sum('balance');
             $total_skillpoints = EveCharacterCharacterSheetSkills::join('account_apikeyinfo_characters', 'account_apikeyinfo_characters.characterID', '=', 'character_charactersheet_skills.characterID')->join('account_apikeyinfo', 'account_apikeyinfo.keyID', '=', 'account_apikeyinfo_characters.keyID')->whereIn('account_apikeyinfo_characters.keyID', Session::get('valid_keys'))->where('account_apikeyinfo.type', '!=', 'Corporation')->sum('skillpoints');
         } else {
             $total_keys = $total_characters = $total_corporations = $total_char_isk = $total_corp_isk = $total_skillpoints = 0;
         }
     } else {
         // Super user gets all of the data!
         $total_keys = SeatKey::count();
         $total_characters = EveCharacterCharacterSheet::count();
         $total_corporations = EveCorporationCorporationSheet::count();
         $total_char_isk = EveCharacterCharacterSheet::sum('balance');
         $total_corp_isk = EveCorporationAccountBalance::where('accountKey', '!=', EveCorporationAccountBalance::Dust_Account_Key)->sum('balance');
         $total_skillpoints = EveCharacterCharacterSheetSkills::sum('skillpoints');
     }
     return View::make('home')->with('server', $server)->with('total_keys', $total_keys)->with('total_characters', $total_characters)->with('total_corporations', $total_corporations)->with('total_char_isk', $total_char_isk)->with('total_corp_isk', $total_corp_isk)->with('total_skillpoints', $total_skillpoints);
 }
Ejemplo n.º 2
0
 public static function Update($keyID, $vCode)
 {
     // Start and validate they key pair
     BaseApi::bootstrap();
     BaseApi::validateKeyPair($keyID, $vCode);
     // Set key scopes and check if the call is banned
     $scope = 'Corp';
     $api = 'CorporationSheet';
     if (BaseApi::isBannedCall($api, $scope, $keyID)) {
         return;
     }
     // Get the characters for this key
     $characters = BaseApi::findKeyCharacters($keyID);
     // Check if this key has any characters associated with it
     if (!$characters) {
         return;
     }
     // Lock the call so that we are the only instance of this running now()
     // If it is already locked, just return without doing anything
     if (!BaseApi::isLockedCall($api, $scope, $keyID)) {
         $lockhash = BaseApi::lockCall($api, $scope, $keyID);
     } else {
         return;
     }
     // So I think a corporation key will only ever have one character
     // attached to it. So we will just use that characterID for auth
     // things, but the corporationID for locking etc.
     $corporationID = BaseApi::findCharacterCorporation($characters[0]);
     // Prepare the Pheal instance
     $pheal = new Pheal($keyID, $vCode);
     // Do the actual API call. pheal-ng actually handles some internal
     // caching too.
     try {
         $corporation_sheet = $pheal->corpScope->CorporationSheet(array('characterID' => $characters[0]));
     } catch (\Pheal\Exceptions\APIException $e) {
         // If we cant get account status information, prevent us from calling
         // this API again
         BaseApi::banCall($api, $scope, $keyID, 0, $e->getCode() . ': ' . $e->getMessage());
         return;
     } catch (\Pheal\Exceptions\PhealException $e) {
         throw $e;
     }
     // Check if the data in the database is still considered up to date.
     // checkDbCache will return true if this is the case
     if (!BaseApi::checkDbCache($scope, $api, $corporation_sheet->cached_until, $corporationID)) {
         $corporation_data = \EveCorporationCorporationSheet::where('corporationID', '=', $corporationID)->first();
         if (!$corporation_data) {
             $corporation_data = new \EveCorporationCorporationSheet();
         }
         $corporation_data->corporationID = $corporation_sheet->corporationID;
         $corporation_data->corporationName = $corporation_sheet->corporationName;
         $corporation_data->ticker = $corporation_sheet->ticker;
         $corporation_data->ceoID = $corporation_sheet->ceoID;
         $corporation_data->ceoName = $corporation_sheet->ceoName;
         $corporation_data->stationID = $corporation_sheet->stationID;
         $corporation_data->stationName = $corporation_sheet->stationName;
         $corporation_data->description = $corporation_sheet->description;
         $corporation_data->url = $corporation_sheet->url;
         $corporation_data->allianceID = $corporation_sheet->allianceID;
         $corporation_data->factionID = $corporation_sheet->factionID;
         $corporation_data->allianceName = $corporation_sheet->allianceName;
         $corporation_data->taxRate = $corporation_sheet->taxRate;
         $corporation_data->memberCount = $corporation_sheet->memberCount;
         $corporation_data->memberLimit = $corporation_sheet->memberLimit;
         $corporation_data->shares = $corporation_sheet->shares;
         $corporation_data->graphicID = $corporation_sheet->logo->graphicID;
         $corporation_data->shape1 = $corporation_sheet->logo->shape1;
         $corporation_data->shape2 = $corporation_sheet->logo->shape2;
         $corporation_data->shape3 = $corporation_sheet->logo->shape3;
         $corporation_data->color1 = $corporation_sheet->logo->color1;
         $corporation_data->color2 = $corporation_sheet->logo->color2;
         $corporation_data->color3 = $corporation_sheet->logo->color3;
         $corporation_data->corporationID = $corporation_sheet->corporationID;
         $corporation_data->save();
         // Update the Divisions
         foreach ($corporation_sheet->divisions as $division) {
             $division_data = \EveCorporationCorporationSheetDivisions::where('corporationID', '=', $corporationID)->where('accountKey', '=', $division->accountKey)->first();
             if (!$division_data) {
                 $division_data = new \EveCorporationCorporationSheetDivisions();
             }
             $division_data->corporationID = $corporationID;
             $division_data->accountKey = $division->accountKey;
             $division_data->description = $division->description;
             $corporation_data->divisions()->save($division_data);
         }
         // Update the Wallet Divisions
         foreach ($corporation_sheet->walletDivisions as $division) {
             $division_data = \EveCorporationCorporationSheetWalletDivisions::where('corporationID', '=', $corporationID)->where('accountKey', '=', $division->accountKey)->first();
             if (!$division_data) {
                 $division_data = new \EveCorporationCorporationSheetWalletDivisions();
             }
             $division_data->corporationID = $corporationID;
             $division_data->accountKey = $division->accountKey;
             $division_data->description = $division->description;
             $corporation_data->walletdivisions()->save($division_data);
         }
         // Update the cached_until time in the database for this api call
         BaseApi::setDbCache($scope, $api, $corporation_sheet->cached_until, $corporationID);
     }
     // Unlock the call
     BaseApi::unlockCall($lockhash);
     return $corporation_sheet;
 }
Ejemplo n.º 3
0
 public function getDeleteKey($keyID, $delete_all_info = false)
 {
     // Ensure that this user may access the data for $keyID
     if (!\Auth::isSuperUser()) {
         if (!in_array($keyID, Session::get('valid_keys'))) {
             App::abort(404);
         }
     }
     // Ensure the user is allowed to delete this key
     if (!\Auth::hasAccess('key_manager')) {
         App::abort(404);
     }
     // Get the full key and vCode
     $key = SeatKey::where('keyID', $keyID)->first();
     if (!$key) {
         App::abort(404);
     }
     // Based on delete_all_info, we will either just delete the key,
     // or all of the information associated with it
     switch ((bool) $delete_all_info) {
         case true:
             // Check if we can determine if this is a corporation or account/char key.
             $type = \EveAccountAPIKeyInfo::where('keyID', $keyID)->pluck('type');
             // Check if the type is set
             if ($type) {
                 // For corporation keys, we will delete corporation stuff, duhr
                 if ($type == "Corporation") {
                     // Most of the data for corporations is stored with the corporationID
                     // as key. To get this ID, we need to find the character attached to
                     // this key, and then the corporation for that character
                     $characters = BaseApi::findKeyCharacters($keyID);
                     $corporationID = BaseApi::findCharacterCorporation($characters[0]);
                     // With the corporationID now known, go ahead and cleanup the database
                     \EveCorporationAccountBalance::where('corporationID', $corporationID)->delete();
                     \EveCorporationAssetList::where('corporationID', $corporationID)->delete();
                     \EveCorporationAssetListContents::where('corporationID', $corporationID)->delete();
                     \EveCorporationAssetListLocations::where('corporationID', $corporationID)->delete();
                     \EveCorporationContactListAlliance::where('corporationID', $corporationID)->delete();
                     \EveCorporationContactListCorporate::where('corporationID', $corporationID)->delete();
                     \EveCorporationContracts::where('corporationID', $corporationID)->delete();
                     \EveCorporationContractsItems::where('corporationID', $corporationID)->delete();
                     \EveCorporationCorporationSheet::where('corporationID', $corporationID)->delete();
                     \EveCorporationCorporationSheetDivisions::where('corporationID', $corporationID)->delete();
                     \EveCorporationCorporationSheetWalletDivisions::where('corporationID', $corporationID)->delete();
                     \EveCorporationIndustryJobs::where('corporationID', $corporationID)->delete();
                     \EveCorporationMarketOrders::where('corporationID', $corporationID)->delete();
                     \EveCorporationMedals::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberMedals::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityGrantableRoles::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityGrantableRolesAtBase::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityGrantableRolesAtHQ::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityGrantableRolesAtOther::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityLog::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityRoles::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityRolesAtBase::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityRolesAtHQ::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityRolesAtOther::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberSecurityTitles::where('corporationID', $corporationID)->delete();
                     \EveCorporationMemberTracking::where('corporationID', $corporationID)->delete();
                     \EveCorporationShareholderCharacters::where('corporationID', $corporationID)->delete();
                     \EveCorporationShareholderCorporations::where('corporationID', $corporationID)->delete();
                     \EveCorporationStandingsAgents::where('corporationID', $corporationID)->delete();
                     \EveCorporationStandingsFactions::where('corporationID', $corporationID)->delete();
                     \EveCorporationStandingsNPCCorporations::where('corporationID', $corporationID)->delete();
                     \EveCorporationStarbaseDetail::where('corporationID', $corporationID)->delete();
                     \EveCorporationStarbaseList::where('corporationID', $corporationID)->delete();
                     \EveCorporationWalletJournal::where('corporationID', $corporationID)->delete();
                     \EveCorporationWalletTransactions::where('corporationID', $corporationID)->delete();
                 } else {
                     // And for character stuff, we delete character stuff
                     // Here we need to be careful now. It may happen that we have more than 1 key
                     // for a character, so we have to be aware of this. It adds a factor of
                     // complexity to the whole thing.
                     $characters = BaseApi::findKeyCharacters($keyID);
                     // Now that we know about all of the characters, we will loop over them and check
                     // that we only have 1 key for them. If more than one keys have this character, we will
                     // simply ignore the cleanup and add a message about it
                     foreach ($characters as $id => $character) {
                         // Check how many keys know about this character
                         if (\EveAccountAPIKeyInfoCharacters::where('characterID', $character)->count() > 1) {
                             // Write a log entry about this
                             \Log::warning('Character ' . $character . ' is recorded on another key and will not been cleaned up');
                             // Remove this character from $characters
                             unset($characters[$id]);
                         }
                     }
                     // So we now have an array of characterID's that can be cleaned up. Lets do that
                     if (count($characters) > 0) {
                         \EveCharacterAccountBalance::whereIn('characterID', $characters)->delete();
                         \EveCharacterAssetList::whereIn('characterID', $characters)->delete();
                         \EveCharacterAssetListContents::whereIn('characterID', $characters)->delete();
                         \EveCharacterCharacterSheet::whereIn('characterID', $characters)->delete();
                         \EveCharacterCharacterSheetSkills::whereIn('characterID', $characters)->delete();
                         \EveCharacterContactList::whereIn('characterID', $characters)->delete();
                         \EveCharacterContactListAlliance::whereIn('characterID', $characters)->delete();
                         \EveCharacterContactListCorporate::whereIn('characterID', $characters)->delete();
                         \EveCharacterContactNotifications::whereIn('characterID', $characters)->delete();
                         \EveCharacterContracts::whereIn('characterID', $characters)->delete();
                         \EveCharacterContractsItems::whereIn('characterID', $characters)->delete();
                         \EveCharacterIndustryJobs::whereIn('characterID', $characters)->delete();
                         // Intentionally ignoring the mail related information as this has a lot of overlap
                         // and is almost always usefull
                         \EveCharacterMarketOrders::whereIn('characterID', $characters)->delete();
                         \EveCharacterPlanetaryColonies::whereIn('characterID', $characters)->delete();
                         \EveCharacterPlanetaryLinks::whereIn('characterID', $characters)->delete();
                         \EveCharacterPlanetaryPins::whereIn('characterID', $characters)->delete();
                         \EveCharacterPlanetaryRoutes::whereIn('characterID', $characters)->delete();
                         \EveCharacterResearch::whereIn('characterID', $characters)->delete();
                         \EveCharacterSkillInTraining::whereIn('characterID', $characters)->delete();
                         \EveCharacterSkillQueue::whereIn('characterID', $characters)->delete();
                         \EveCharacterStandingsAgents::whereIn('characterID', $characters)->delete();
                         \EveCharacterStandingsFactions::whereIn('characterID', $characters)->delete();
                         \EveCharacterStandingsNPCCorporations::whereIn('characterID', $characters)->delete();
                         \EveCharacterUpcomingCalendarEvents::whereIn('characterID', $characters)->delete();
                         \EveCharacterWalletJournal::whereIn('characterID', $characters)->delete();
                         \EveCharacterWalletTransactions::whereIn('characterID', $characters)->delete();
                     }
                 }
                 // Finally, delete the key and redirect
                 $key->delete();
                 // Delete the information that we have for this key too
                 \EveAccountAPIKeyInfo::where('keyID', $keyID)->delete();
                 \EveAccountAPIKeyInfoCharacters::where('keyID', $keyID)->delete();
                 return Redirect::action('ApiKeyController@getAll')->with('success', 'Key has been deleted');
             } else {
                 // So, we are unable to determine the key type, so maybe this is
                 // a invalid one or whatever. Just get rid of it.
                 // Delete the API Key
                 $key->delete();
                 // Delete the information that we have for this key too
                 \EveAccountAPIKeyInfo::where('keyID', $keyID)->delete();
                 \EveAccountAPIKeyInfoCharacters::where('keyID', $keyID)->delete();
                 return Redirect::action('ApiKeyController@getAll')->with('success', 'Key has been deleted');
             }
             break;
         case false:
             // Delete the API Key
             $key->delete();
             // Delete the information that we have for this key too
             \EveAccountAPIKeyInfo::where('keyID', $keyID)->delete();
             \EveAccountAPIKeyInfoCharacters::where('keyID', $keyID)->delete();
             return Redirect::action('ApiKeyController@getAll')->with('success', 'Key has been deleted');
             break;
     }
 }
Ejemplo n.º 4
0
 public function Update()
 {
     parent::bootstrap();
     $server_groups = $this->tsClient->serverGroupList();
     $users = \User::all();
     $seat_groups = \Auth::findAllGroups();
     $corps = \EveCorporationCorporationSheet::all();
     list($validCorps, $invalidUsers) = $this->getValidCorps($users);
     foreach ($server_groups as $sg) {
         foreach ($validCorps as $c) {
             $corp = array_shift($c['corps']);
             $groups = $c['user_groups'];
             if ($sg->toString() === $corp) {
                 $this->addClient($sg, $c['user']);
             }
             foreach ($groups as $uGroup) {
                 $this->updateServerGroup($uGroup, $sg, $c['user']);
             }
             if ($this->seatGroupCompare($sg)) {
                 foreach ($seat_groups as $seatGroup) {
                     $this->updateSeatGroup($sg, $seatGroup, $c['user']);
                 }
             }
         }
         $client_list = $sg->clientList();
         foreach ($invalidUsers as $user) {
             foreach ($client_list as $client) {
                 if ($client["client_unique_identifier"] == $user->tsid) {
                     try {
                         $usr_client = self::$tsClient->clientFindDb($user->tsid, true);
                         if (!empty($usr_client)) {
                             $sg->clientDel($usr_client);
                         }
                     } catch (Exception $e) {
                     }
                 }
             }
             if ($sg->__toString() != "Guest Server Query" && $sg->__toString() != "Admin Server Query" && $sg->__toString() != "Server Admin" && $sg->__toString() != "Guest" && $sg->__toString() != "epicness" && $sg->__toString() != "Friends" && $sg->__toString() != "Normal") {
                 $client_list = $sg->clientList();
                 foreach ($client_list as $client) {
                     if ($client["client_unique_identifier"] == $user->tsid) {
                         try {
                             $sg->clientDel($client["cldbid"]);
                         } catch (Exception $e) {
                         }
                     }
                 }
             }
         }
     }
 }