public static function bootstrap() { // Configure Pheal PhealConfig::getInstance()->cache = new \Pheal\Cache\FileStorage(storage_path() . '/cache/phealcache/'); PhealConfig::getInstance()->access = new \Pheal\Access\StaticCheck(); PhealConfig::getInstance()->log = new \Pheal\Log\FileStorage(storage_path() . '/logs/'); PhealConfig::getInstance()->api_customkeys = true; PhealConfig::getInstance()->http_method = 'curl'; // Build a meaningful User-Agent for CCP should they need to contact someone $user_agent = 'SeAT ' . \Config::get('seat.version') . ' API Fetcher at ' . \Config::get('app.url'); // Add the Url // If the administrative_contact is set, add this to the User-Agent, else use the // default mail_from in the settings if (Settings::getSetting('administrative_contact') == null) { $user_agent .= ' Install mail_from: ' . \Config::get('mail.from.name') . ' <' . \Config::get('mail.from.address') . '>'; } else { $user_agent .= ' Administrative Contact: ' . Settings::getSetting('administrative_contact'); } // Set the newly compiled User-Agent PhealConfig::getInstance()->http_user_agent = $user_agent; // Should the EVE api be determined as 'down', set the cache value for 'eve_api_down' // with a expiration of 30 minutes. We will also decrement the current error count // by 10 to allow for some calls to happen after the value has expired out of // cache if (\Cache::get('eve_api_error_count') >= \Config::get('seat.error_limit')) { \Cache::put('eve_api_down', true, 30); \Cache::decrement('eve_api_error_count', 10); } // Check if the EVE Api has been detected as 'down'. if (\Cache::has('eve_api_down')) { throw new Exception\APIServerDown(); } // Disable the Laravel query log. Some of the API calls do.. a lot of queries :P \DB::connection()->disableQueryLog(); }
public function getNew() { if (Settings::getSetting('registration_enabled') == 'true') { return View::make('register.enabled'); } else { return View::make('register.disabled'); } }
public static function Update() { // Before we even bother getting to the point of // determining which members are inactive // check if there are any users // configured that have // the required roles $recruiters = \Auth::findAllUsersWithAccess('recruiter'); // If there are none with the role, just stop if (count($recruiters) <= 0) { return; } // Now we will loop over the recruiters and send // a notification about the member inactivity. // We should actually batch the members so // that we dont spam a 100 entries per // recruiter for inactivities. But // that can come later :D foreach ($recruiters as $recruiter) { // Do a lookup to see how many months without a login should // be considered as a inactive member (int) ($inactive_months = SettingHelper::getSetting('seatnotify_member_inactivity_months')); // Now, get a list of members that have not // logged in for 1 month. $members = \EveCorporationMemberTracking::where('logoffDateTime', '<', \DB::raw('date_sub(NOW(), INTERVAL ' . $inactive_months . ' MONTH)'))->get(); // If there are no members, continue if (!$members) { continue; } // For every member that we have found, we want // to send a notification for. foreach ($members as $member) { // Determine if this recruiter that we have // has access to the corporation that the // member is a part of. // // Is this step really needed? if (BaseNotify::canAccessCorp($recruiter->id, $member->corporationID)) { // Get the corporation name for the notification $corporation_name = \DB::table('account_apikeyinfo_characters')->where('corporationID', $member->corporationID)->pluck('corporationName'); // Prepare the total notification $notification_type = 'Corporation'; $notification_title = 'Member Inactivity'; $notification_text = $member->name . ' in ' . $corporation_name . ' has been inactive ' . 'for ' . $inactive_months . ' month(s). The last logon time was ' . \Carbon\Carbon::parse($member->logonDateTime)->diffFOrHumans() . ' with the last ' . 'known location being ' . $member->location . '.'; // Send the notification BaseNotify::sendNotification($recruiter->id, $notification_type, $notification_title, $notification_text); } } } }
/** * Is this command enbaled. * * @return bool */ public function isEnabled() { return Settings::getSetting('seatscheduled_queue_cleanup') == 'true' ? true : false; }
public function postUpdateSetting() { $validation = new SettingValidator(); if ($validation->passes()) { // Global Settings Settings::setSetting('app_name', Input::get('app_name')); Settings::setSetting('color_scheme', Input::get('color_scheme')); Settings::setSetting('thousand_seperator', Input::get('thousand_seperator')); Settings::setSetting('decimal_seperator', Input::get('decimal_seperator')); Settings::setSetting('required_mask', Input::get('required_mask')); Settings::setSetting('registration_enabled', Input::get('registration_enabled')); Settings::setSetting('administrative_contact', Input::get('administrative_contact')); // SeAT Notifications Settings::setSetting('seatnotify_member_inactivity_months', Input::get('seatnotify_member_inactivity_months')); Settings::setSetting('seatnotify_fuel_warning_days', Input::get('seatnotify_fuel_warning_days')); // SeAT Queues Settings::setSetting('seatscheduled_character', Input::get('seatscheduled_character')); Settings::setSetting('seatscheduled_corporation', Input::get('seatscheduled_corporation')); Settings::setSetting('seatscheduled_corporation_assets', Input::get('seatscheduled_corporation_assets')); Settings::setSetting('seatscheduled_corporation_wallets', Input::get('seatscheduled_corporation_wallets')); Settings::setSetting('seatscheduled_eve', Input::get('seatscheduled_eve')); Settings::setSetting('seatscheduled_map', Input::get('seatscheduled_map')); Settings::setSetting('seatscheduled_server', Input::get('seatscheduled_server')); Settings::setSetting('seatscheduled_notifications', Input::get('seatscheduled_notifications')); Settings::setSetting('seatscheduled_queue_cleanup', Input::get('seatscheduled_queue_cleanup')); // Were done. Redirect to the setting page, flashing a message return Redirect::action('SettingsController@getSettings')->with('success', 'Settings Successfully Saved!'); } else { return Redirect::back()->withInput()->withErrors($validation->errors); } }
/** * Is this command enbaled. * * @return bool */ public function isEnabled() { return Settings::getSetting('seatscheduled_character') == 'true' ? true : false; }
/** * Is this command enbaled. * * @return bool */ public function isEnabled() { return Settings::getSetting('seatscheduled_notifications') == 'true' ? true : false; }
public function postNewKey() { if (Request::ajax()) { // We will validate the key pais as we dont want to cause unneeded errors $validation = new APIKeyValidator(); if ($validation->passes()) { // Setup a pheal instance and get some API data :D BaseApi::bootstrap(); $pheal = new Pheal(Input::get('keyID'), Input::get('vCode')); // Get API Key Information try { $key_info = $pheal->accountScope->APIKeyInfo(); } catch (\Pheal\Exceptions\PhealException $e) { return View::make('keys.ajax.errors')->withErrors(array('error' => $e->getCode() . ': ' . $e->getMessage())); } // Here, based on the type of key, we will either call some further information, // or just display what we have learned so far. if ($key_info->key->type == 'Corporation') { // Just return the view for corporation keys return View::make('keys.ajax.corporation')->with('keyID', Input::get('keyID'))->with('vCode', Input::get('vCode'))->with('key_info', $key_info)->with('existance', SeatKey::where('keyID', Input::get('keyID'))->count()); } elseif ($key_info->key->accessMask < Settings::getSetting('required_mask')) { return View::make('keys.ajax.errors')->withErrors(array('error' => 'Invalid API Mask!')); } // Get API Account Status Information try { $status_info = $pheal->accountScope->AccountStatus(); } catch (\Pheal\Exceptions\PhealException $e) { return View::make('keys.ajax.errors')->withErrors(array('error' => $e->getCode() . ': ' . $e->getMessage())); } // Return the view return View::make('keys.ajax.character')->with('keyID', Input::get('keyID'))->with('vCode', Input::get('vCode'))->with('key_info', $key_info)->with('status_info', $status_info)->with('existance', SeatKey::where('keyID', Input::get('keyID'))->count()); } else { return View::make('keys.ajax.errors')->withErrors($validation->errors); } } }
/** * Is this command enbaled. * * @return bool */ public function isEnabled() { return Settings::getSetting('seatscheduled_corporation_assets') == 'true' ? true : false; }
public static function sendNotification($user_id, $type, $title, $text) { // Generate a hash to lookup $hash = BaseNotify::makeNotificationHash($user_id, $type, $title, $text); // Check the existance of the hash in the notifications table if (!\SeatNotification::where('hash', '=', $hash)->exists()) { // Send the new noticiation $notification = new \SeatNotification(); $notification->user_id = $user_id; $notification->type = $type; $notification->title = $title; $notification->text = $text; $notification->hash = $hash; $notification->save(); // Check if the user is configured to receive the // notifications via email if (SettingHelper::getSetting('email_notifications', false, $user_id) == 'true') { // Prepare data to be sent along with the email. These // are accessed by their keys in the email template $data = array('type' => $type, 'title' => $title, 'text' => $text, 'notification_id' => $notification->id); // Send the notifications email \Mail::send('emails.notifications.notify', $data, function ($message) use($user_id, $title) { $message->to(\Auth::findUserById($user_id)->email, \Auth::findUserById($user_id)->username)->subject('New SeAT ' . $title . ' notification.'); }); } return true; } return false; }
public function postSetSettings() { $validation = new Validators\UserSettingValidator(); if ($validation->passes()) { // We will have to lookup the characterID's name // quickly before we set the setting, so lets // do that. $character_name = \DB::table('account_apikeyinfo_characters')->where('characterID', Input::get('main_character_id'))->pluck('characterName'); Settings::setSetting('color_scheme', Input::get('color_scheme'), \Auth::User()->id); Settings::setSetting('thousand_seperator', Input::get('thousand_seperator'), \Auth::User()->id); Settings::setSetting('decimal_seperator', Input::get('decimal_seperator'), \Auth::User()->id); Settings::setSetting('main_character_id', Input::get('main_character_id'), \Auth::User()->id); Settings::setSetting('main_character_name', $character_name, \Auth::User()->id); Settings::setSetting('email_notifications', Input::get('email_notifications'), \Auth::User()->id); return Redirect::back()->with('success', 'Settings Saved!'); } else { return Redirect::back()->withInput()->withErrors($validation->errors); } }
public static function Update() { // Before we even bother getting to the point of // determining which starbases would need a // notification to be sent, check if there // are any users configured that have // ther required roles $pos_role_users = \Auth::findAllUsersWithAccess('pos_manager'); // If there are none with the role, just stop if (count($pos_role_users) <= 0) { return; } // Next, grab the list of starbases that we are aware of $starbases = \DB::table('corporation_starbaselist')->select('corporation_starbaselist.corporationID', 'corporation_starbaselist.itemID', 'corporation_starbaselist.moonID', 'corporation_starbaselist.state', 'corporation_starbaselist.stateTimeStamp', 'corporation_starbaselist.onlineTimeStamp', 'corporation_starbaselist.onlineTimeStamp', 'corporation_starbasedetail.useStandingsFrom', 'corporation_starbasedetail.onAggression', 'corporation_starbasedetail.onCorporationWar', 'corporation_starbasedetail.allowCorporationMembers', 'corporation_starbasedetail.allowAllianceMembers', 'corporation_starbasedetail.fuelBlocks', 'corporation_starbasedetail.strontium', 'corporation_starbasedetail.starbaseCharter', 'invTypes.typeID', 'invTypes.typeName', 'mapDenormalize.itemName', 'mapDenormalize.security', 'invNames.itemName', 'map_sovereignty.solarSystemName', 'corporation_starbasedetail.updated_at')->join('corporation_starbasedetail', 'corporation_starbaselist.itemID', '=', 'corporation_starbasedetail.itemID')->join('mapDenormalize', 'corporation_starbaselist.locationID', '=', 'mapDenormalize.itemID')->join('invNames', 'corporation_starbaselist.moonID', '=', 'invNames.itemID')->join('invTypes', 'corporation_starbaselist.typeID', '=', 'invTypes.typeID')->leftJoin('map_sovereignty', 'corporation_starbaselist.locationID', '=', 'map_sovereignty.solarSystemID')->orderBy('invNames.itemName', 'asc')->get(); // To determine the fuel needed, we need to get some // values out there that tell us *how* much fuel // certain towers need. So, we will set a base // amount for each of them. Should this // change in the future, then we can // simply edit the value here // The final usage once we have determined the tower // type $usage = 0; $stront_usage = 0; // The base values for the tower sizes // ... fuel for non sov towers ... $large_usage = 40; $medium_usage = 20; $small_usage = 10; // ... and sov towers $sov_large_usage = 30; $sov_medium_usage = 15; $sov_small_usage = 8; // Stront usage $stront_large = 400; $stront_medium = 200; $stront_small = 100; // Now, we will loop over the starbases that we know if and determine // the size of the tower, along with the location of the tower. // Towers anchored in sov space get to use less fuel. // // The result of this loop should have $usage and $stront_usage // populated with the correct value for the tower in question foreach ($starbases as $starbase) { // Lets check if the tower is anchored in space where the // owner of it holds sov. $sov_tower = false; // Get the allianceID that the corporation is a member of $alliance_id = \DB::table('corporation_corporationsheet')->where('corporationID', $starbase->corporationID)->pluck('allianceID'); // Check if the alliance_id was actually determined. If so, // do the sov_towers loop, else we just set the if ($alliance_id) { // Lets see if this tower is in a sov system $sov_location = \DB::table('corporation_starbaselist')->whereIn('locationID', function ($location) use($alliance_id) { $location->select('solarSystemID')->from('map_sovereignty')->where('factionID', 0)->where('allianceID', $alliance_id); })->where('corporationID', $starbase->corporationID)->where('itemID', $starbase->itemID)->first(); if ($sov_location) { $sov_tower = true; } } // With the soverenity status known, move on to // determine the size of the tower. if (strpos($starbase->typeName, 'Small') !== false) { $stront_usage = $stront_small; $usage = $sov_tower ? $sov_small_usage : $small_usage; } elseif (strpos($starbase->typeName, 'Medium') !== false) { $stront_usage = $stront_medium; $usage = $sov_tower ? $sov_medium_usage : $medium_usage; } else { $stront_usage = $stront_large; $usage = $sov_tower ? $sov_large_usage : $large_usage; } // Now we finally have $usage and $stront_usage known! // Lets get to the part where we finally check if // there is enough reserves. If not, do what // we came for and notify someone // If now plus (the fuel amount devided by the usage) muliplied // by hours is less than the configured days, send a // notification // Retreive the configured days ... (int) ($warning_days = SettingHelper::getSetting('seatnotify_fuel_warning_days')); // ... and process a notification if required if (\Carbon\Carbon::now()->addHours($starbase->fuelBlocks / $usage)->lte(\Carbon\Carbon::now()->addDays($warning_days))) { // OK! We need to tell someone that their towers fuel is // going to be running out soon! foreach ($pos_role_users as $pos_user) { // A last check is done now to make sure we // don't let everyone for every corp know // about a specific corp. No, we first // check that the user we want to // send to has the role for that // specific corp too! if (BaseNotify::canAccessCorp($pos_user->id, $starbase->corporationID)) { // Ok! Time to finally get to pushing the // notification out! :D // Get the corporation name for the notification $corporation_name = \DB::table('account_apikeyinfo_characters')->where('corporationID', $starbase->corporationID)->pluck('corporationName'); // Prepare the total notification $notification_type = 'Starbase'; $notification_title = 'Low Fuel Reserve'; $notification_text = 'The ' . $starbase->typeName . ' at ' . $starbase->itemName . ' owned by ' . $corporation_name . ' has ' . $starbase->fuelBlocks . ' fuel blocks left. The estimated offline time is ' . \Carbon\Carbon::now()->addHours($starbase->fuelBlocks / $usage)->diffForHumans() . '.'; // Send the notification BaseNotify::sendNotification($pos_user->id, $notification_type, $notification_title, $notification_text); } } } // End fuel left over if() // Check how many starbase charters are left. We // will have to check the security of the // anchored system to ensure we dont // spazz out and notifify about // 0sec towers. // // If the security status of the system the tower // is anchored in is > 5, check the charters if ($starbase->security >= 5) { if (Carbon\Carbon::now()->addHours($starbase->starbaseCharter / 1)->lte(Carbon\Carbon::now()->addDays($warning_days))) { // OK! We need to tell someone that their towers charters is // going to be running out soon! foreach ($pos_role_users as $pos_user) { // A last check is done now to make sure we // don't let everyone for every corp know // about a specific corp. No, we first // check that the user we want to // send to has the role for that // specific corp too! if (BaseNotify::canAccessCorp($pos_user->id, $starbase->corporationID)) { // Ok! Time to finally get to pushing the // notification out! :D // Get the corporation name for the notification $corporation_name = \DB::table('account_apikeyinfo_characters')->where('corporationID', $starbase->corporationID)->pluck('corporationName'); // Prepare the total notification $notification_type = 'Starbase'; $notification_title = 'Low Charter Reserve'; $notification_text = 'The ' . $starbase->typeName . ' at ' . $starbase->itemName . ' owned by ' . $corporation_name . ' has ' . $starbase->fuelBlocks . ' starbase charters left. The estimated offline time is ' . \Carbon\Carbon::now()->addHours($starbase->starbaseCharter / 1)->diffForHumans() . '.'; // Send the notification BaseNotify::sendNotification($pos_user->id, $notification_type, $notification_title, $notification_text); } } } } // End charters left over if() } }