Skip to content

Commit

Permalink
Merge pull request #485 from exodus4d/develop
Browse files Browse the repository at this point in the history
v1.2.2
  • Loading branch information
exodus4d authored May 1, 2017
2 parents 721cfb2 + a1008cb commit 5c6b9e8
Show file tree
Hide file tree
Showing 97 changed files with 6,313 additions and 4,184 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,3 +50,5 @@ Temporary Items
.sass-cache
.usage
*.gz
/composer-dev.lock
/composer.lock
30 changes: 16 additions & 14 deletions app/environment.ini
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,15 @@ DB_CCP_NAME = eve_citadel_min
DB_CCP_USER = root
DB_CCP_PASS =

; CCP SSO settings (OAuth2) - visit: https://developers.eveonline.com/applications
CCP_CREST_URL = https://api-sisi.testeveonline.com
SSO_CCP_URL = https://sisilogin.testeveonline.com
SSO_CCP_CLIENT_ID =
SSO_CCP_SECRET_KEY =
; CCP SSO (OAuth2) - visit: https://developers.eveonline.com/applications
CCP_SSO_URL = https://sisilogin.testeveonline.com
CCP_SSO_CLIENT_ID =
CCP_SSO_SECRET_KEY =

; CCP XML APIv2
CCP_XML = https://api.testeveonline.com
; CCP ESI API
CCP_ESI_URL = https://esi.tech.ccp.is
CCP_ESI_DATASOURCE = singularity
CCP_ESI_SCOPES = esi-location.read_location.v1,esi-location.read_ship_type.v1,esi-ui.write_waypoint.v1,esi-ui.open_window.v1

; SMTP settings (optional)
SMTP_HOST = localhost
Expand Down Expand Up @@ -70,14 +71,15 @@ DB_CCP_NAME =
DB_CCP_USER =
DB_CCP_PASS =

; CCP SSO settings
CCP_CREST_URL = https://crest-tq.eveonline.com
SSO_CCP_URL = https://login.eveonline.com
SSO_CCP_CLIENT_ID =
SSO_CCP_SECRET_KEY =
; CCP SSO
CCP_SSO_URL = https://login.eveonline.com
CCP_SSO_CLIENT_ID =
CCP_SSO_SECRET_KEY =

; CCP XML APIv2
CCP_XML = https://api.eveonline.com
; CCP ESI API
CCP_ESI_URL = https://esi.tech.ccp.is
CCP_ESI_DATASOURCE = tranquility
CCP_ESI_SCOPES = esi-location.read_location.v1,esi-location.read_ship_type.v1,esi-ui.write_waypoint.v1,esi-ui.open_window.v1

; SMTP settings (optional)
SMTP_HOST = localhost
Expand Down
32 changes: 22 additions & 10 deletions app/main/controller/api/route.php
Original file line number Diff line number Diff line change
Expand Up @@ -109,15 +109,18 @@ private function setStaticJumpData(){
* @param array $filterData
*/
private function setDynamicJumpData($mapIds = [], $filterData = []){
// make sure, mapIds are integers (protect against SQL injections)
$mapIds = array_unique( array_map('intval', $mapIds), SORT_NUMERIC);

if( !empty($mapIds) ){
// make sure, mapIds are integers (protect against SQL injections)
$mapIds = array_map('intval', $mapIds);
// map filter ---------------------------------------------------------------------------------------------
$whereMapIdsQuery = (count($mapIds) == 1) ? " = " . reset($mapIds) : " IN (" . implode(', ', $mapIds) . ")";

// connection filter --------------------------------------------------------
// connection filter --------------------------------------------------------------------------------------
$whereQuery = "";
$includeScopes = [];
$includeTypes = [];
$excludeTypes = [];
$includeEOL = true;

if( $filterData['stargates'] === true){
Expand Down Expand Up @@ -147,16 +150,24 @@ private function setDynamicJumpData($mapIds = [], $filterData = []){
$includeTypes[] = 'wh_critical';
}

if( $filterData['wormholesFrigate'] !== true ){
$excludeTypes[] = 'frigate';
}

if( $filterData['wormholesEOL'] === false ){
$includeEOL = false;
}
}

// search connections -------------------------------------------------------
// search connections -------------------------------------------------------------------------------------

if( !empty($includeScopes) ){
$whereQuery .= " `connection`.`scope` IN ('" . implode("', '", $includeScopes) . "') AND ";

if( !empty($excludeTypes) ){
$whereQuery .= " `connection`.`type` NOT REGEXP '" . implode("|", $excludeTypes) . "' AND ";
}

if( !empty($includeTypes) ){
$whereQuery .= " `connection`.`type` REGEXP '" . implode("|", $includeTypes) . "' AND ";
}
Expand All @@ -179,7 +190,7 @@ private function setDynamicJumpData($mapIds = [], $filterData = []){
`system_tar`.`id` = `connection`.`source` OR
`system_tar`.`id` = `connection`.`target`
WHERE
`connection`.`mapId` IN (" . implode(', ', $mapIds) . ") AND
`connection`.`mapId` " . $whereMapIdsQuery . " AND
`connection`.`active` = 1 AND
(
`connection`.`source` = `system_src`.`id` OR
Expand All @@ -195,7 +206,7 @@ private function setDynamicJumpData($mapIds = [], $filterData = []){
`map` ON
`map`.`id` = `system_src`.`mapId`
WHERE
`system_src`.`mapId` IN (" . implode(', ', $mapIds) . ") AND
`system_src`.`mapId` " . $whereMapIdsQuery . " AND
`system_src`.`active` = 1 AND
`map`.`active` = 1
HAVING
Expand Down Expand Up @@ -228,20 +239,20 @@ private function updateJumpData(&$rows = []){
$systemId = (int)$row['systemId'];
$secStatus = (float)$row['trueSec'];

// fill "nameArray" data ----------------------------------------------------
// fill "nameArray" data ----------------------------------------------------------------------------------
if( !isset($this->nameArray[$systemId]) ){
$this->nameArray[$systemId][0] = $systemName;
$this->nameArray[$systemId][1] = $regionId;
$this->nameArray[$systemId][2] = $constId;
$this->nameArray[$systemId][3] = $secStatus;
}

// fill "idArray" data ------------------------------------------------------
// fill "idArray" data ------------------------------------------------------------------------------------
if( !isset($this->idArray[$systemName]) ){
$this->idArray[$systemName] = $systemId;
}

// fill "jumpArray" data ----------------------------------------------------
// fill "jumpArray" data ----------------------------------------------------------------------------------
if( !is_array($this->jumpArray[$systemName]) ){
$this->jumpArray[$systemName] = [];
}
Expand Down Expand Up @@ -527,7 +538,7 @@ public function search($f3){
$mapData = (array)$routeData['mapIds'];
$mapData = array_flip( array_map('intval', $mapData) );

// check map access (filter requested mapIDs and format) --------------------
// check map access (filter requested mapIDs and format) ----------------------------------------------
array_walk($mapData, function(&$item, &$key, $data){

if( isset($data[1][$key]) ){
Expand Down Expand Up @@ -561,6 +572,7 @@ public function search($f3){
'wormholes' => (bool) $routeData['wormholes'],
'wormholesReduced' => (bool) $routeData['wormholesReduced'],
'wormholesCritical' => (bool) $routeData['wormholesCritical'],
'wormholesFrigate' => (bool) $routeData['wormholesFrigate'],
'wormholesEOL' => (bool) $routeData['wormholesEOL'],
'safer' => (bool) $routeData['safer']
];
Expand Down
61 changes: 21 additions & 40 deletions app/main/controller/api/system.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,9 @@ public function getSystemModelByIds($columnIDs = [], $column = 'solarSystemID'){
* @return array
*/
public function getSystems(){

$ccpDB = $this->getDB('CCP');

$query = $this->_getQuery();

$rows = $ccpDB->exec($query, null, 60 * 60 * 24);

// format result
$mapper = new Mapper\CcpSystemsMapper($rows);

Expand Down Expand Up @@ -385,20 +381,25 @@ public function setDestination(\Base $f3){
$return->clearOtherWaypoints = (bool)$postData['clearOtherWaypoints'];
$return->first = (bool)$postData['first'];

/**
* @var Sso $ssoController
*/
$ssoController = self::getController('Sso');
foreach($postData['systemData'] as $systemData){
$waypointData = $ssoController->setWaypoint($activeCharacter, $systemData['systemId'], [
if( $accessToken = $activeCharacter->getAccessToken() ){
$options = [
'clearOtherWaypoints' => $return->clearOtherWaypoints,
'first' => $return->first,
]);
if($waypointData['systemId']){
$return->systemData[] = $systemData;
}elseif( isset($waypointData['error']) ){
$return->error[] = $waypointData['error'];
'addToBeginning' => $return->first,
];

foreach($postData['systemData'] as $systemData){
$response = $f3->ccpClient->setWaypoint($systemData['systemId'], $accessToken, $options);

if(empty($response)){
$return->systemData[] = $systemData;
}else{
$error = (object) [];
$error->type = 'error';
$error->message = $response['error'];
$return->error[] = $error;
}
}

}
}

Expand Down Expand Up @@ -428,14 +429,14 @@ public function delete(\Base $f3){
if( $system = $map->getSystemById($systemId) ){
// check whether system should be deleted OR set "inactive"
if(
empty($system->alias) &&
empty($system->description)
!empty($system->description) ||
( !empty($system->alias) && ($system->alias != $system->name) )
){
$system->erase();
}else{
// keep data -> set "inactive"
$system->setActive(false);
$system->save();
}else{
$system->erase();
}

$system->reset();
Expand All @@ -452,23 +453,3 @@ public function delete(\Base $f3){
}
}





















55 changes: 41 additions & 14 deletions app/main/controller/api/user.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ public function getCookieCharacter($f3){
}else{
$characterError = (object) [];
$characterError->type = 'warning';
$characterError->message = 'This can happen through "invalid cookie data", "login restrictions", "CREST problems".';
$characterError->message = 'This can happen through "invalid cookies(SSO)", "login restrictions", "ESI problems".';
$return->error[] = $characterError;
}
}
Expand Down Expand Up @@ -196,10 +196,39 @@ public function logout(\Base $f3){
echo json_encode($return);
}

/**
* remote open ingame information window (character, corporation or alliance) Id
* -> the type is auto-recognized by CCP
* @param \Base $f3
*/
public function openIngameWindow(\Base $f3){
$data = $f3->get('POST');

$return = (object) [];
$return->error = [];

if( $targetId = (int)$data['targetId']){
$activeCharacter = $this->getCharacter();

$response = $f3->ccpClient->openWindow($targetId, $activeCharacter->getAccessToken());

if(empty($response)){
$return->targetId = $targetId;
}else{
$error = (object) [];
$error->type = 'error';
$error->message = $response['error'];
$return->error[] = $error;
}
}

echo json_encode($return);
}

/**
* update user account data
* -> a fresh user automatically generated on first login with a new character
* -> see CREST SSO login
* -> see SSO login
* @param \Base $f3
*/
public function saveAccount(\Base $f3){
Expand Down Expand Up @@ -340,25 +369,23 @@ public function deleteAccount(\Base $f3){
$user = $activeCharacter->getUser();

if($user){
// send delete account mail
// try to send delete account mail
$msg = 'Hello ' . $user->name . ',<br><br>';
$msg .= 'your account data has been successfully deleted.';

$mailController = new MailController();
$status = $mailController->sendDeleteAccount($user->email, $msg);
$mailController->sendDeleteAccount($user->email, $msg);

if($status){
// save log
self::getLogger('DELETE_ACCOUNT')->write(
sprintf(self::LOG_DELETE_ACCOUNT, $user->id, $user->name)
);
// save log
self::getLogger('DELETE_ACCOUNT')->write(
sprintf(self::LOG_DELETE_ACCOUNT, $user->id, $user->name)
);

// remove user
$user->erase();
// remove user
$user->erase();

$this->logout($f3);
die();
}
$this->logout($f3);
die();
}
}else{
// captcha not valid -> return error
Expand Down
Loading

0 comments on commit 5c6b9e8

Please sign in to comment.