public function create(array $params) { $form = new \Kingboard\Lib\Forms\BattleCreateForm(); if (!$form->validate($_POST)) { // @todo handle invalid return $this->error("form is not valid"); } $user = \Kingboard\Lib\Auth\Auth::getUser(); $key = $form->apiKey; $scope = "char"; // for now we default to char. Account keys are never corp keys. if ($key['type'] == "Character") { $scope = "char"; } if ($key['type'] == "Corporation") { $scope = "corp"; } $pheal = new Pheal($key['apiuserid'], $key['apikey'], $scope); $contacts = $pheal->ContactList(array('characterID' => $form->character)); // reset to neutral pheal $pheal = new Pheal(); $characterInfo = $pheal->eveScope->CharacterInfo(array('characterID' => $form->character)); $positives = array(); foreach ($contacts->corporateContactList as $contact) { // accumulate postive standings if ($contact->standing > 0) { $positives[$contact->contactID] = $contact->contactName; } } // alliance standings override corp standings foreach ($contacts->allianceContactList as $contact) { if ($contact->standing > 0) { $positives[$contact->contactID] = $contact->contactName; } else { // negative standings, we only need those if corp has positive, but alliance negative if (isset($positives[$contact->contactID])) { unset($positives[$contact->contactID]); } } } $battleSetting = new \Kingboard\Model\BattleSettings(); $battleSetting->startdate = new \MongoDate(strtotime($_POST['startdate'])); $battleSetting->user = $user->_id; $battleSetting->enddate = new \MongoDate(strtotime($_POST['enddate'])); $battleSetting->system = $_POST['system']; $battleSetting->key = $key; // lets fix some info about the creator of this report $battleSetting->ownerCharacter = $form->character; $battleSetting->ownerCharacterName = $characterInfo->characterName; $battleSetting->ownerCorporation = (int) $characterInfo->corporationID; $battleSetting->ownerCorporationName = $characterInfo->corporation; $battleSetting->ownerAlliance = (int) $characterInfo->allianceID; $battleSetting->ownerAllianceName = $characterInfo->alliance; $battleSetting->positives = $positives; $battleSetting->runs = 0; $battleSetting->nextRun = new \MongoDate(time()); $battleSetting->save(); // we are done here, lets redirect to the battle! $this->redirect("/battle/" . $battleSetting->_id); }
public function delete(array $params) { if (\Kingboard\Lib\Form::getXSRFToken() != $params['xsrf']) { return $this->error('xsrf token missmatch'); } $user = \Kingboard\Lib\Auth\Auth::getUser(); if (isset($user['keys'])) { $keys = $user['keys']; unset($keys[$params['keyid']]); $user->keys = $keys; $user->save(); } $this->myKingboard(array()); }
/** * constructor, should be called by all derived views * will cause redirect if $loginrequired and not logged in * @param bool $loginrequired */ public function __construct($loginrequired = false) { if (isset($_COOKIE['PHPSESSID'])) { session_start(); } if ($loginrequired && !Auth::isLoggedIn()) { session_start(); $this->redirect("/login"); } parent::__construct(); $reg = Registry::getInstance(); $this->_context['images'] = $reg->imagePaths; $this->_context['baseHost'] = $reg->baseHost; $this->_context['disqus'] = $reg->disqus; // ownerID, if this is an owned board, this should be filled, for public boards this needs to be false $this->_context['ownerID'] = $reg->ownerID; // ownerType, if this is an owned board, this should be filled, for public boards this doesn't matter $this->_context['ownerType'] = $reg->ownerType; // when user is logged in we provide user object to all pages, false otherwise $this->_context['user'] = Auth::getUser(); // make sure all views have the XSRF Token available $this->_context['XSRF'] = Form::getXSRFToken(); // Global Kingboard information // pass version information $this->_context['Kingboard']['Version'] = Kingboard::VERSION; // ownerName, use Kingboard if not set if (!is_null($reg->ownerName) && $reg->ownerName) { $this->_context['Kingboard']['Name'] = $reg->ownerName; } else { $this->_context['Kingboard']['Name'] = Kingboard::NAME; } // release name $this->_context['Kingboard']['ReleaseName'] = Kingboard::RELEASE_NAME; // pick bootstrap theme path from public/css/themes folder $this->_context['theme'] = !is_null($reg->theme) ? $reg->theme : "default"; // set header image, fall back to default if non configured $this->_context['header_image'] = !is_null($reg->headerImage) ? $reg->headerImage : "/images/banner/kingboard.png"; $debugbar = $reg->debugbar; if (!is_null($debugbar)) { $jsrenderer = new JavascriptRenderer($debugbar, '/DebugBar'); $this->_context['debugbar_header'] = $jsrenderer->renderhead(); $this->_context['debugbar'] = $jsrenderer->render(); } // ingame browser check $this->_context['igb'] = $this->isIGB(); }
/** * validate if character is actually a character of the current user * @param $characterData * @return bool */ protected function validateCharacter($characterData) { $characterData = explode("|", $characterData); // dont have a user, meaning not logged in.. if (!($user = \Kingboard\Lib\Auth\Auth::getUser())) { return false; } // user does not have any api keys, so can't be his character if (is_null($user->keys) || !is_array($user->keys)) { return false; } if (!isset($user->keys[$characterData[0]]) || !$user->keys[$characterData[0]]["active"]) { return false; } // key was not found $this->apiKey = $user->keys[$characterData[0]]; $this->character = (int) $characterData[1]; return true; }
/** * uses Kingboart_Auth to destroy the session, therefor logging the user out. * @param $params */ public function logout(array $params) { \Kingboard\Lib\Auth\Auth::logout(); session_destroy(); $this->redirect("/"); }
public function logout($request) { \Kingboard\Lib\Auth\Auth::logout(); $this->redirect("/"); }