Skip to content

Commit aef6d4e

Browse files
authored
Merge pull request #861 from exodus4d/develop
v1.5.4
2 parents 7d11851 + 84cd08a commit aef6d4e

File tree

244 files changed

+11541
-3131
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

244 files changed

+11541
-3131
lines changed

.jshintrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"node": true,
1515

1616
// Allow ES6.
17-
"esversion": 6,
17+
"esversion": 7,
1818

1919
/*
2020
* ENFORCING OPTIONS

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ Mapping tool for [*EVE ONLINE*](https://www.eveonline.com)
1818
- [wiki](https://github.com/exodus4d/pathfinder/wiki)
1919
- Developer [Slack](https://slack.com) chat:
2020
- https://pathfinder-eve-online.slack.com
21-
- Please send me a mail for invite: pathfinder@exodus4d.de
21+
- Join channel [pathfinder-eve-online.slack.com](https://join.slack.com/t/pathfinder-eve-online/shared_invite/enQtMzMyOTkyMjczMTA3LWI2NGE1OTY5ODBmNDZlMDY3MDIzYjk5ZTljM2JjZjIwNDRkNzMyMTEwMDUzOGQwM2E3ZjE1NGEwNThlMzYzY2Y)
22+
- Can´t join? pathfinder@exodus4d.de
2223

2324
**Feel free to check the code for bugs and security issues.
2425
Issues should be reported in the [Issue](https://github.com/exodus4d/pathfinder/issues) section.**
@@ -49,7 +50,7 @@ Issues should be reported in the [Issue](https://github.com/exodus4d/pathfinder/
4950
|-- app.js --> require.js config (!required for production!)
5051
|-- [0777] logs/ --> log files
5152
|-- ...
52-
| -- node_modules/ --> node.js modules (not used for production)
53+
|-- node_modules/ --> node.js modules (not used for production)
5354
|-- ...
5455
|-- [0755] public/ --> frontend source
5556
|-- css/ --> CSS dist/build folder (minified)

app/cron.ini

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,13 @@ deleteStatisticsData = Cron\StatisticsUpdate->deleteStatisticsD
5959
; truncate map history log files
6060
truncateMapHistoryLogFiles = Cron\MapHistory->truncateFiles, @halfHour
6161

62-
; updates small amount of static system data from CCP API
62+
; sync "sovereignty" and "faction warfare" data from CCP´s ESI API
63+
updateSovereigntyData = Cron\Universe->updateSovereigntyData, @halfPastHour
64+
65+
; sync static system data from CCP´s ESI API
66+
; -> Job is WIP!
6367
;updateUniverseSystems = Cron\Universe->updateUniverseSystems, @instant
6468

65-
; setup universe DB with static data from ESI
69+
; bootstrap job for "eve_universe" DB from CCP´s ESI API
70+
; -> Only for development! This job is used to build the initial export/sql/eve_universe.sql
6671
;setup = Cron\Universe->setup, @instant

app/lib/db/cortex.php

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ public function fields(array $fields=array(), $exclude=false) {
213213
} else
214214
$this->whitelist=$fields;
215215
$id=$this->dbsType=='sql'?$this->primary:'_id';
216-
if (!in_array($id,$this->whitelist))
216+
if (!in_array($id,$this->whitelist) && !($exclude && in_array($id,$fields)))
217217
$this->whitelist[]=$id;
218218
$this->applyWhitelist();
219219
return $this->whitelist;
@@ -595,7 +595,7 @@ public function afind($filter = NULL, array $options = NULL, $ttl = 0, $rel_dept
595595
* @param array|null $filter
596596
* @param array|null $options
597597
* @param int $ttl
598-
* @return CortexCollection
598+
* @return CortexCollection|false
599599
*/
600600
public function find($filter = NULL, array $options = NULL, $ttl = 0) {
601601
$sort=false;
@@ -731,12 +731,12 @@ protected function filteredFind($filter = NULL, array $options = NULL, $ttl = 0,
731731
$addToFilter = array($id.' IN ?', $result);
732732
}
733733
// *-to-one
734-
elseif ($this->dbsType == 'sql') {
734+
elseif (!$deep && $this->dbsType == 'sql') {
735735
// use sub-query inclusion
736736
$has_filter=$this->mergeFilter([$has_filter,
737737
[$this->rel($key)->getTable().'.'.$fromConf[1].'='.$this->getTable().'.'.$id]]);
738738
$result = $this->_refSubQuery($key,$has_filter,$has_options);
739-
$addToFilter = ['exists('.$result[0].')']+$result[1];
739+
$addToFilter = array_merge(['exists('.$result[0].')'],$result[1]);
740740
}
741741
elseif ($result = $this->_hasRefsIn($key,$has_filter,$has_options,$ttl))
742742
$addToFilter = array($id.' IN ?', $result);
@@ -781,11 +781,11 @@ protected function filteredFind($filter = NULL, array $options = NULL, $ttl = 0,
781781
$options['order'] = preg_replace('/\h+DESC(?=\s*(?:$|,))/i',' DESC NULLS LAST',$options['order']);
782782
// assemble full sql query for joined queries
783783
if ($hasJoin) {
784+
$adhoc=[];
784785
// when in count-mode and grouping is active, wrap the query later
785786
// otherwise add a an adhoc counter field here
786787
if (!($subquery_mode=($options && !empty($options['group']))) && $count)
787-
$this->adhoc['_rows']=['expr'=>'COUNT(*)','value'=>NULL];
788-
$adhoc=[];
788+
$adhoc[]='(COUNT(*)) as _rows';
789789
if (!$count)
790790
// add bind parameters for filters in adhoc fields
791791
if ($this->preBinds) {
@@ -1224,7 +1224,7 @@ function save() {
12241224
// m:m save cascade
12251225
if (!empty($this->saveCsd)) {
12261226
foreach($this->saveCsd as $key => $val) {
1227-
if($fields[$key]['relType'] == 'has-many') {
1227+
if ($fields[$key]['relType'] == 'has-many') {
12281228
$relConf = $fields[$key]['has-many'];
12291229
if ($relConf['hasRel'] == 'has-many') {
12301230
$mmTable = $this->mmTable($relConf,$key);
@@ -1236,12 +1236,12 @@ function save() {
12361236
$filter[] = $id;
12371237
}
12381238
// delete all refs
1239-
if (is_null($val))
1239+
if (empty($val))
12401240
$mm->erase($filter);
12411241
// update refs
12421242
elseif (is_array($val)) {
12431243
$mm->erase($filter);
1244-
foreach($val as $v) {
1244+
foreach(array_unique($val) as $v) {
12451245
if ($relConf['isSelf'] && $v==$id)
12461246
continue;
12471247
$mm->set($key,$v);
@@ -1256,7 +1256,7 @@ function save() {
12561256
$rel = $this->getRelInstance($relConf[0],$relConf,$key);
12571257
// find existing relations
12581258
$refs = $rel->find([$relConf[1].' = ?',$this->getRaw($relConf['relField'])]);
1259-
if (is_null($val)) {
1259+
if (empty($val)) {
12601260
foreach ($refs?:[] as $model) {
12611261
$model->set($relConf[1],NULL);
12621262
$model->save();
@@ -1470,7 +1470,7 @@ function set($key, $val) {
14701470
// handle relations
14711471
if (isset($fields[$key]['belongs-to-one'])) {
14721472
// one-to-many, one-to-one
1473-
if (is_null($val))
1473+
if (empty($val))
14741474
$val = NULL;
14751475
elseif (is_object($val) &&
14761476
!($this->dbsType=='mongo' && (
@@ -1489,7 +1489,7 @@ function set($key, $val) {
14891489
$val = $this->db->legacy() ? new \MongoId($val) : new \MongoDB\BSON\ObjectId($val);
14901490
} elseif (isset($fields[$key]['has-one'])){
14911491
$relConf = $fields[$key]['has-one'];
1492-
if (is_null($val)) {
1492+
if (empty($val)) {
14931493
$val = $this->get($key);
14941494
$val->set($relConf[1],NULL);
14951495
} else {
@@ -2554,7 +2554,7 @@ public function sql_quoteCondition($cond, $db) {
25542554
function($match) use($db) {
25552555
if (!isset($match[1]))
25562556
return $match[0];
2557-
if (preg_match('/\b(AND|OR|IN|LIKE|NOT)\b/i',$match[1]))
2557+
if (preg_match('/\b(AND|OR|IN|LIKE|NOT|HAVING|SELECT|FROM|WHERE)\b/i',$match[1]))
25582558
return $match[1];
25592559
return $db->quotekey($match[1]);
25602560
}, $cond);
@@ -2576,7 +2576,7 @@ public function sql_prependTableToFields($cond, $table) {
25762576
function($match) use($table) {
25772577
if (!isset($match[3]))
25782578
return $match[1];
2579-
if (preg_match('/\b(AND|OR|IN|LIKE|NOT)\b/i',$match[3]))
2579+
if (preg_match('/\b(AND|OR|IN|LIKE|NOT|HAVING|SELECT|FROM|WHERE)\b/i',$match[3]))
25802580
return $match[0];
25812581
return $match[2].$table.'.'.$match[3];
25822582
}, $cond);

app/main/controller/accesscontroller.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,15 @@ function beforeroute(\Base $f3, $params) : bool {
3636
}
3737

3838
/**
39-
* get current character and check if it is a valid character
39+
* check login status and look or a valid character
4040
* @param \Base $f3
4141
* @return string
4242
* @throws \Exception
4343
*/
4444
protected function isLoggedIn(\Base $f3) : string {
4545
$loginStatus = 'UNKNOWN';
46-
if($character = $this->getCharacter()){
46+
// disable ttl cache time here. Further getCharacter() calls should use a short ttl
47+
if($character = $this->getCharacter(0)){
4748
if($character->checkLoginTimer()){
4849
if(( $authStatus = $character->isAuthorized()) === 'OK'){
4950
$loginStatus = 'OK';

app/main/controller/admin.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ public function afterroute(\Base $f3) {
8989
protected function getAdminCharacter(\Base $f3){
9090
$adminCharacter = null;
9191
if( !$f3->exists(Sso::SESSION_KEY_SSO_ERROR) ){
92-
if( $character = $this->getCharacter() ){
92+
if( $character = $this->getCharacter(0) ){
9393
if(in_array($character->roleId->name, ['SUPER', 'CORPORATION'], true)){
9494
// current character is admin
9595
$adminCharacter = $character;
@@ -288,7 +288,7 @@ protected function filterValidCharacters(CharacterModel $character, $characterId
288288
$characters = [];
289289
// check if kickCharacters belong to same Corp as admin character
290290
// -> remove admin char from valid characters...
291-
if( !empty($characterIds = array_diff( [$characterId], [$character->_id])) ){
291+
if( !empty($characterIds = array_diff([$characterId], [$character->_id])) ){
292292
if($character->roleId->name === 'SUPER'){
293293
if($filterCharacters = CharacterModel::getAll($characterIds)){
294294
$characters = $filterCharacters;
@@ -337,7 +337,7 @@ protected function filterValidMaps(CharacterModel $character, int $mapId) {
337337
$maps = $filterMaps;
338338
}
339339
}else{
340-
$maps = $character->getCorporation()->getMaps([$mapId], ['addInactive' => true, 'ignoreMapCount' => true]);
340+
$maps = $character->getCorporation()->getMaps($mapId, ['addInactive' => true, 'ignoreMapCount' => true]);
341341
}
342342

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

406406
foreach($corporations as $corporation){
407-
if($maps = $corporation->getMaps([], ['addInactive' => true, 'ignoreMapCount' => true])){
407+
if($maps = $corporation->getMaps(null, ['addInactive' => true, 'ignoreMapCount' => true])){
408408
$data->corpMaps[$corporation->name] = $maps;
409409
}
410410
}

0 commit comments

Comments
 (0)