Skip to content

Commit

Permalink
Merge pull request #861 from exodus4d/develop
Browse files Browse the repository at this point in the history
v1.5.4
  • Loading branch information
exodus4d authored Oct 12, 2019
2 parents 7d11851 + 84cd08a commit aef6d4e
Show file tree
Hide file tree
Showing 244 changed files with 11,541 additions and 3,131 deletions.
2 changes: 1 addition & 1 deletion .jshintrc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"node": true,

// Allow ES6.
"esversion": 6,
"esversion": 7,

/*
* ENFORCING OPTIONS
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ Mapping tool for [*EVE ONLINE*](https://www.eveonline.com)
- [wiki](https://github.com/exodus4d/pathfinder/wiki)
- Developer [Slack](https://slack.com) chat:
- https://pathfinder-eve-online.slack.com
- Please send me a mail for invite: [email protected]
- Join channel [pathfinder-eve-online.slack.com](https://join.slack.com/t/pathfinder-eve-online/shared_invite/enQtMzMyOTkyMjczMTA3LWI2NGE1OTY5ODBmNDZlMDY3MDIzYjk5ZTljM2JjZjIwNDRkNzMyMTEwMDUzOGQwM2E3ZjE1NGEwNThlMzYzY2Y)
- Can´t join? [email protected]

**Feel free to check the code for bugs and security issues.
Issues should be reported in the [Issue](https://github.com/exodus4d/pathfinder/issues) section.**
Expand Down Expand Up @@ -49,7 +50,7 @@ Issues should be reported in the [Issue](https://github.com/exodus4d/pathfinder/
|-- app.js --> require.js config (!required for production!)
|-- [0777] logs/ --> log files
|-- ...
| -- node_modules/ --> node.js modules (not used for production)
|-- node_modules/ --> node.js modules (not used for production)
|-- ...
|-- [0755] public/ --> frontend source
|-- css/ --> CSS dist/build folder (minified)
Expand Down
9 changes: 7 additions & 2 deletions app/cron.ini
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,13 @@ deleteStatisticsData = Cron\StatisticsUpdate->deleteStatisticsD
; truncate map history log files
truncateMapHistoryLogFiles = Cron\MapHistory->truncateFiles, @halfHour

; updates small amount of static system data from CCP API
; sync "sovereignty" and "faction warfare" data from CCP´s ESI API
updateSovereigntyData = Cron\Universe->updateSovereigntyData, @halfPastHour

; sync static system data from CCP´s ESI API
; -> Job is WIP!
;updateUniverseSystems = Cron\Universe->updateUniverseSystems, @instant

; setup universe DB with static data from ESI
; bootstrap job for "eve_universe" DB from CCP´s ESI API
; -> Only for development! This job is used to build the initial export/sql/eve_universe.sql
;setup = Cron\Universe->setup, @instant
28 changes: 14 additions & 14 deletions app/lib/db/cortex.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function fields(array $fields=array(), $exclude=false) {
} else
$this->whitelist=$fields;
$id=$this->dbsType=='sql'?$this->primary:'_id';
if (!in_array($id,$this->whitelist))
if (!in_array($id,$this->whitelist) && !($exclude && in_array($id,$fields)))
$this->whitelist[]=$id;
$this->applyWhitelist();
return $this->whitelist;
Expand Down Expand Up @@ -595,7 +595,7 @@ public function afind($filter = NULL, array $options = NULL, $ttl = 0, $rel_dept
* @param array|null $filter
* @param array|null $options
* @param int $ttl
* @return CortexCollection
* @return CortexCollection|false
*/
public function find($filter = NULL, array $options = NULL, $ttl = 0) {
$sort=false;
Expand Down Expand Up @@ -731,12 +731,12 @@ protected function filteredFind($filter = NULL, array $options = NULL, $ttl = 0,
$addToFilter = array($id.' IN ?', $result);
}
// *-to-one
elseif ($this->dbsType == 'sql') {
elseif (!$deep && $this->dbsType == 'sql') {
// use sub-query inclusion
$has_filter=$this->mergeFilter([$has_filter,
[$this->rel($key)->getTable().'.'.$fromConf[1].'='.$this->getTable().'.'.$id]]);
$result = $this->_refSubQuery($key,$has_filter,$has_options);
$addToFilter = ['exists('.$result[0].')']+$result[1];
$addToFilter = array_merge(['exists('.$result[0].')'],$result[1]);
}
elseif ($result = $this->_hasRefsIn($key,$has_filter,$has_options,$ttl))
$addToFilter = array($id.' IN ?', $result);
Expand Down Expand Up @@ -781,11 +781,11 @@ protected function filteredFind($filter = NULL, array $options = NULL, $ttl = 0,
$options['order'] = preg_replace('/\h+DESC(?=\s*(?:$|,))/i',' DESC NULLS LAST',$options['order']);
// assemble full sql query for joined queries
if ($hasJoin) {
$adhoc=[];
// when in count-mode and grouping is active, wrap the query later
// otherwise add a an adhoc counter field here
if (!($subquery_mode=($options && !empty($options['group']))) && $count)
$this->adhoc['_rows']=['expr'=>'COUNT(*)','value'=>NULL];
$adhoc=[];
$adhoc[]='(COUNT(*)) as _rows';
if (!$count)
// add bind parameters for filters in adhoc fields
if ($this->preBinds) {
Expand Down Expand Up @@ -1224,7 +1224,7 @@ function save() {
// m:m save cascade
if (!empty($this->saveCsd)) {
foreach($this->saveCsd as $key => $val) {
if($fields[$key]['relType'] == 'has-many') {
if ($fields[$key]['relType'] == 'has-many') {
$relConf = $fields[$key]['has-many'];
if ($relConf['hasRel'] == 'has-many') {
$mmTable = $this->mmTable($relConf,$key);
Expand All @@ -1236,12 +1236,12 @@ function save() {
$filter[] = $id;
}
// delete all refs
if (is_null($val))
if (empty($val))
$mm->erase($filter);
// update refs
elseif (is_array($val)) {
$mm->erase($filter);
foreach($val as $v) {
foreach(array_unique($val) as $v) {
if ($relConf['isSelf'] && $v==$id)
continue;
$mm->set($key,$v);
Expand All @@ -1256,7 +1256,7 @@ function save() {
$rel = $this->getRelInstance($relConf[0],$relConf,$key);
// find existing relations
$refs = $rel->find([$relConf[1].' = ?',$this->getRaw($relConf['relField'])]);
if (is_null($val)) {
if (empty($val)) {
foreach ($refs?:[] as $model) {
$model->set($relConf[1],NULL);
$model->save();
Expand Down Expand Up @@ -1470,7 +1470,7 @@ function set($key, $val) {
// handle relations
if (isset($fields[$key]['belongs-to-one'])) {
// one-to-many, one-to-one
if (is_null($val))
if (empty($val))
$val = NULL;
elseif (is_object($val) &&
!($this->dbsType=='mongo' && (
Expand All @@ -1489,7 +1489,7 @@ function set($key, $val) {
$val = $this->db->legacy() ? new \MongoId($val) : new \MongoDB\BSON\ObjectId($val);
} elseif (isset($fields[$key]['has-one'])){
$relConf = $fields[$key]['has-one'];
if (is_null($val)) {
if (empty($val)) {
$val = $this->get($key);
$val->set($relConf[1],NULL);
} else {
Expand Down Expand Up @@ -2554,7 +2554,7 @@ public function sql_quoteCondition($cond, $db) {
function($match) use($db) {
if (!isset($match[1]))
return $match[0];
if (preg_match('/\b(AND|OR|IN|LIKE|NOT)\b/i',$match[1]))
if (preg_match('/\b(AND|OR|IN|LIKE|NOT|HAVING|SELECT|FROM|WHERE)\b/i',$match[1]))
return $match[1];
return $db->quotekey($match[1]);
}, $cond);
Expand All @@ -2576,7 +2576,7 @@ public function sql_prependTableToFields($cond, $table) {
function($match) use($table) {
if (!isset($match[3]))
return $match[1];
if (preg_match('/\b(AND|OR|IN|LIKE|NOT)\b/i',$match[3]))
if (preg_match('/\b(AND|OR|IN|LIKE|NOT|HAVING|SELECT|FROM|WHERE)\b/i',$match[3]))
return $match[0];
return $match[2].$table.'.'.$match[3];
}, $cond);
Expand Down
5 changes: 3 additions & 2 deletions app/main/controller/accesscontroller.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,15 @@ function beforeroute(\Base $f3, $params) : bool {
}

/**
* get current character and check if it is a valid character
* check login status and look or a valid character
* @param \Base $f3
* @return string
* @throws \Exception
*/
protected function isLoggedIn(\Base $f3) : string {
$loginStatus = 'UNKNOWN';
if($character = $this->getCharacter()){
// disable ttl cache time here. Further getCharacter() calls should use a short ttl
if($character = $this->getCharacter(0)){
if($character->checkLoginTimer()){
if(( $authStatus = $character->isAuthorized()) === 'OK'){
$loginStatus = 'OK';
Expand Down
8 changes: 4 additions & 4 deletions app/main/controller/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function afterroute(\Base $f3) {
protected function getAdminCharacter(\Base $f3){
$adminCharacter = null;
if( !$f3->exists(Sso::SESSION_KEY_SSO_ERROR) ){
if( $character = $this->getCharacter() ){
if( $character = $this->getCharacter(0) ){
if(in_array($character->roleId->name, ['SUPER', 'CORPORATION'], true)){
// current character is admin
$adminCharacter = $character;
Expand Down Expand Up @@ -288,7 +288,7 @@ protected function filterValidCharacters(CharacterModel $character, $characterId
$characters = [];
// check if kickCharacters belong to same Corp as admin character
// -> remove admin char from valid characters...
if( !empty($characterIds = array_diff( [$characterId], [$character->_id])) ){
if( !empty($characterIds = array_diff([$characterId], [$character->_id])) ){
if($character->roleId->name === 'SUPER'){
if($filterCharacters = CharacterModel::getAll($characterIds)){
$characters = $filterCharacters;
Expand Down Expand Up @@ -337,7 +337,7 @@ protected function filterValidMaps(CharacterModel $character, int $mapId) {
$maps = $filterMaps;
}
}else{
$maps = $character->getCorporation()->getMaps([$mapId], ['addInactive' => true, 'ignoreMapCount' => true]);
$maps = $character->getCorporation()->getMaps($mapId, ['addInactive' => true, 'ignoreMapCount' => true]);
}

return $maps;
Expand Down Expand Up @@ -404,7 +404,7 @@ protected function initMaps(\Base $f3, CharacterModel $character){
$corporations = $this->getAccessibleCorporations($character);

foreach($corporations as $corporation){
if($maps = $corporation->getMaps([], ['addInactive' => true, 'ignoreMapCount' => true])){
if($maps = $corporation->getMaps(null, ['addInactive' => true, 'ignoreMapCount' => true])){
$data->corpMaps[$corporation->name] = $maps;
}
}
Expand Down
Loading

0 comments on commit aef6d4e

Please sign in to comment.