Skip to content

Commit 2b9f2ef

Browse files
committed
Dawntrail related fixes
1 parent aba3434 commit 2b9f2ef

File tree

15 files changed

+68
-51
lines changed

15 files changed

+68
-51
lines changed

composer.lock

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/fftracker/Api/General.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Simbiat\fftracker\Api;
44

55
use Simbiat\Abstracts\Api;
6+
use Simbiat\Errors;
67
use Simbiat\http20\Headers;
78

89
abstract class General extends Api
@@ -43,7 +44,8 @@ protected function genData(array $path): array
4344
}
4445
} catch (\UnexpectedValueException) {
4546
return ['http_error' => 400, 'reason' => 'ID `'.$path[0].'` has unsupported format'];
46-
} catch (\Throwable) {
47+
} catch (\Throwable $e) {
48+
Errors::error_log($e);
4749
return ['http_error' => 500, 'reason' => 'Unknown error during request processing'];
4850
}
4951
#Check for errors

lib/fftracker/Entities/Achievement.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Simbiat\Config;
66
use Simbiat\Cron\TaskInstance;
7+
use Simbiat\Errors;
78
use Simbiat\fftracker\Entity;
89
use Simbiat\HomePage;
910
use Simbiat\Images;
@@ -174,7 +175,8 @@ protected function updateDB(): string|bool
174175
}
175176
return HomePage::$dbController->query('INSERT INTO `ffxiv__achievement` SET `achievementid`=:achievementid, `name`=:name, `icon`=:icon, `points`=:points, `category`=:category, `subcategory`=:subcategory, `howto`=:howto, `title`=:title, `item`=:item, `itemicon`=:itemicon, `itemid`=:itemid, `dbid`=:dbid ON DUPLICATE KEY UPDATE `achievementid`=:achievementid, `name`=:name, `icon`=:icon, `points`=:points, `category`=:category, `subcategory`=:subcategory, `howto`=:howto, `title`=:title, `item`=:item, `itemicon`=:itemicon, `itemid`=:itemid, `dbid`=:dbid, `updated`=CURRENT_TIMESTAMP()', $bindings);
176177
} catch(\Exception $e) {
177-
return $e->getMessage()."\r\n".$e->getTraceAsString();
178+
Errors::error_log($e, 'achievementid: '.$this->id);
179+
return false;
178180
}
179181
}
180182

lib/fftracker/Entities/Character.php

+30-20
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
declare(strict_types=1);
33
namespace Simbiat\fftracker\Entities;
44

5+
use Simbiat\Config;
56
use Simbiat\Cron\TaskInstance;
67
use Simbiat\Errors;
78
use Simbiat\fftracker\Entity;
89
use Simbiat\HomePage;
10+
use Simbiat\Images;
911
use Simbiat\Lodestone;
1012
use Simbiat\Sanitization;
1113
use Simbiat\Security;
@@ -217,7 +219,7 @@ protected function updateDB(bool $manual = false): string|bool
217219
':server'=>$this->lodestone['server'],
218220
':name'=>$this->lodestone['name'],
219221
':manual'=>[$manual, 'bool'],
220-
':avatar'=>str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0_96x96.jpg'], '', $this->lodestone['avatar']),
222+
':avatar'=>str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0_96x96.jpg', 'c0.jpg'], '', $this->lodestone['avatar']),
221223
':biography'=>[
222224
(empty($this->lodestone['bio']) ? NULL : $this->lodestone['bio']),
223225
(empty($this->lodestone['bio']) ? 'null' : 'string'),
@@ -302,25 +304,32 @@ protected function updateDB(bool $manual = false): string|bool
302304
#Achievements
303305
if (!empty($this->lodestone['achievements']) && is_array($this->lodestone['achievements'])) {
304306
foreach ($this->lodestone['achievements'] as $achievementid=>$item) {
305-
$queries[] = [
306-
'INSERT INTO `ffxiv__achievement` SET `achievementid`=:achievementid, `name`=:name, `icon`=:icon, `points`=:points ON DUPLICATE KEY UPDATE `updated`=`updated`, `name`=:name, `icon`=:icon, `points`=:points;',
307-
[
308-
':achievementid'=>$achievementid,
309-
':name'=> $item['name'],
310-
':icon'=> str_replace('.png', '.webp', self::removeLodestoneDomain($item['icon'])),
311-
':points'=> $item['points'],
312-
],
313-
];
314-
$queries[] = [
315-
'INSERT INTO `ffxiv__character_achievement` SET `characterid`=:characterid, `achievementid`=:achievementid, `time`=UTC_DATE() ON DUPLICATE KEY UPDATE `time`=:time;',
316-
[
317-
':characterid'=>$this->id,
318-
':achievementid'=>$achievementid,
319-
':time'=>[$item['time'], 'datetime'],
320-
],
321-
];
307+
$icon = self::removeLodestoneDomain($item['icon']);
308+
#Download icon
309+
$webp = Images::download($item['icon'], Config::$icons.$icon);
310+
if ($webp) {
311+
$icon = str_replace('.png', '.webp', $icon);
312+
$queries[] = [
313+
'INSERT INTO `ffxiv__achievement` SET `achievementid`=:achievementid, `name`=:name, `icon`=:icon, `points`=:points ON DUPLICATE KEY UPDATE `updated`=`updated`, `name`=:name, `icon`=:icon, `points`=:points;',
314+
[
315+
':achievementid'=>$achievementid,
316+
':name'=> $item['name'],
317+
':icon'=> $icon,
318+
':points'=> $item['points'],
319+
],
320+
];
321+
$queries[] = [
322+
'INSERT INTO `ffxiv__character_achievement` SET `characterid`=:characterid, `achievementid`=:achievementid, `time`=UTC_DATE() ON DUPLICATE KEY UPDATE `time`=:time;',
323+
[
324+
':characterid'=>$this->id,
325+
':achievementid'=>$achievementid,
326+
':time'=>[$item['time'], 'datetime'],
327+
],
328+
];
329+
}
322330
}
323331
}
332+
#HomePage::$dbController->debug = true;
324333
HomePage::$dbController->query($queries);
325334
#Register Free Company update if change was detected
326335
if (!empty($this->lodestone['freeCompany']['id']) && HomePage::$dbController->check('SELECT `characterid` FROM `ffxiv__freecompany_character` WHERE `characterid`=:characterid AND `freecompanyid`=:fcID;', [':characterid' => $this->id, ':fcID' => $this->lodestone['freeCompany']['id']]) === false && (new FreeCompany($this->lodestone['freeCompany']['id']))->update() !== true) {
@@ -338,7 +347,8 @@ protected function updateDB(bool $manual = false): string|bool
338347
}
339348
return true;
340349
} catch(\Exception $e) {
341-
return $e->getMessage()."\r\n".$e->getTraceAsString();
350+
Errors::error_log($e, 'characterid: '.$this->id);
351+
return false;
342352
}
343353
}
344354

@@ -418,7 +428,7 @@ public function linkUser(): array
418428
]);
419429
Security::log('User details change', 'Attempted to link FFXIV character', ['id' => $this->id, 'result' => $result]);
420430
#Download avatar
421-
(new User($_SESSION['userid']))->addAvatar(false, 'https://img2.finalfantasyxiv.com/f/'.$this->avatarID.'c0_96x96.jpg', $this->id);
431+
(new User($_SESSION['userid']))->addAvatar(false, 'https://img2.finalfantasyxiv.com/f/'.$this->avatarID.'c0.jpg', $this->id);
422432
return ['response' => $result];
423433
} catch (\Throwable $exception) {
424434
return ['http_error' => 500, 'reason' => $exception->getMessage()];

lib/fftracker/Entities/FreeCompany.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ protected function updateDB(bool $manual = false): string|bool
293293
':characterid' => $member,
294294
':server' => $details['server'],
295295
':name' => $details['name'],
296-
':avatar' => str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0_96x96.jpg'], '', $details['avatar']),
296+
':avatar' => str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0.jpg'], '', $details['avatar']),
297297
':gcRank' => (empty($details['grandCompany']['rank']) ? '' : $details['grandCompany']['rank']),
298298
]
299299
];
@@ -317,7 +317,8 @@ protected function updateDB(bool $manual = false): string|bool
317317
}
318318
return true;
319319
} catch(\Exception $e) {
320-
return $e->getMessage()."\r\n".$e->getTraceAsString();
320+
Errors::error_log($e, 'freecompanyid: '.$this->id);
321+
return false;
321322
}
322323
}
323324

lib/fftracker/Entities/Linkshell.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ protected function updateDB(bool $manual = false): string|bool
160160
':characterid'=>$member,
161161
':server'=>$details['server'],
162162
':name'=>$details['name'],
163-
':avatar'=>str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0_96x96.jpg'], '', $details['avatar']),
163+
':avatar'=>str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0.jpg'], '', $details['avatar']),
164164
':gcRank'=>(empty($details['grandCompany']['rank']) ? '' : $details['grandCompany']['rank']),
165165
]
166166
];
@@ -184,7 +184,8 @@ protected function updateDB(bool $manual = false): string|bool
184184
}
185185
return true;
186186
} catch(\Exception $e) {
187-
return $e->getMessage()."\r\n".$e->getTraceAsString();
187+
Errors::error_log($e, 'linkshellid: '.$this->id);
188+
return false;
188189
}
189190
}
190191

lib/fftracker/Entities/PvPTeam.php

+3-2
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ protected function updateDB(bool $manual = false): string|bool
169169
':characterid'=>$member,
170170
':server'=>$details['server'],
171171
':name'=>$details['name'],
172-
':avatar'=>str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0_96x96.jpg'], '', $details['avatar']),
172+
':avatar'=>str_replace(['https://img2.finalfantasyxiv.com/f/', 'c0.jpg'], '', $details['avatar']),
173173
':gcRank'=>(empty($details['grandCompany']['rank']) ? '' : $details['grandCompany']['rank']),
174174
':matches'=>(empty($details['feasts']) ? 0 : $details['feasts']),
175175
]
@@ -194,7 +194,8 @@ protected function updateDB(bool $manual = false): string|bool
194194
}
195195
return true;
196196
} catch(\Exception $e) {
197-
return $e->getMessage()."\r\n".$e->getTraceAsString();
197+
Errors::error_log($e, 'pvpteamid: '.$this->id);
198+
return false;
198199
}
199200
}
200201

lib/fftracker/Pages/Character.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ protected function generate(array $path): array
5959
$this->altLinks[] = ['rel' => 'alternate', 'type' => 'text/html', 'title' => 'Lodestone EU page', 'href' => 'https://eu.finalfantasyxiv.com/lodestone/character/' . $id];
6060
}
6161
#Set favicon to avatar
62-
$outputArray['favicon'] = 'https://img2.finalfantasyxiv.com/f/'.$outputArray['character']['avatarID'].'c0_96x96.jpg';
62+
$outputArray['favicon'] = 'https://img2.finalfantasyxiv.com/f/'.$outputArray['character']['avatarID'].'c0.jpg';
6363
return $outputArray;
6464
}
6565
}

twig/common/elements/entitycard.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
{% elseif type == 'achievement' %}
3333
<img loading="lazy" decoding="async" alt="{{ name }}" src="/assets/images/fftracker/icons/{{ icon }}">
3434
{% elseif type == 'character' %}
35-
<img loading="lazy" decoding="async" alt="{{ name }}" src="https://img2.finalfantasyxiv.com/f/{{ icon }}c0_96x96.jpg">
35+
<img loading="lazy" decoding="async" alt="{{ name }}" src="https://img2.finalfantasyxiv.com/f/{{ icon }}c0.jpg">
3636
{% elseif type == 'freecompany' %}
3737
{% if icon == '1' %}
3838
<img loading="lazy" decoding="async" alt="{{ name }}" src="/assets/images/fftracker/default-crests/Maelstrom.webp">

twig/fftracker/character.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
{% if not character.avatarID %}
44
<img loading="lazy" decoding="async" class="galleryZoom{% if character.owned.id and session_data.userid == character.owned.id %} ff_owned{% endif %}" id="ff_portrait_img" alt="{{ character.name }}" src="/assets/images/fftracker/silhouettes/{% if character.biology.gender == 1 %}male{% else %}female{% endif %}{{ character.biology.race }}.webp">
55
{% else %}
6-
<img loading="lazy" decoding="async" class="galleryZoom{% if character.owned.id and session_data.userid == character.owned.id %} ff_owned{% endif %}" id="ff_portrait_img" alt="{{ character.name }}" src="https://img2.finalfantasyxiv.com/f/{{ character.avatarID }}l0_640x873.jpg">
6+
<img loading="lazy" decoding="async" class="galleryZoom{% if character.owned.id and session_data.userid == character.owned.id %} ff_owned{% endif %}" id="ff_portrait_img" alt="{{ character.name }}" src="https://img2.finalfantasyxiv.com/f/{{ character.avatarID }}l0.jpg">
77
{% endif %}
88
</section>
99
<section class="ff_char_block">

twig/usercontrol/fftracker.twig

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<p>Linked characters:</p>
2828
{% for character in characters %}
2929
<article class="ff_owned_block">
30-
<div class="ff_owned_char"><img loading="lazy" decoding="async" class="avatar ff_owned" alt="{{ character.name }}" src="https://img2.finalfantasyxiv.com/f/{{ character.icon }}c0_96x96.jpg"><a href="/fftracker/characters/{{ character.id }}/{{ prettyURL(character.name) }}">{{ character.name }}</a></div>
30+
<div class="ff_owned_char"><img loading="lazy" decoding="async" class="avatar ff_owned" alt="{{ character.name }}" src="https://img2.finalfantasyxiv.com/f/{{ character.icon }}c0.jpg"><a href="/fftracker/characters/{{ character.id }}/{{ prettyURL(character.name) }}">{{ character.name }}</a></div>
3131
<div class="ff_owned_groups">
3232
{% if groups[character.id] %}
3333
<p>Owned groups:</p>

vendor/composer/autoload_psr4.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
'Simbiat\\http20\\' => array($vendorDir . '/simbiat/http20/src'),
1616
'Simbiat\\Database\\' => array($vendorDir . '/simbiat/database/src'),
1717
'Simbiat\\Cron\\' => array($vendorDir . '/simbiat/cron/src'),
18-
'Simbiat\\' => array($baseDir . '/lib', $vendorDir . '/simbiat/accountkeying/src', $vendorDir . '/simbiat/arrayhelpers/src', $vendorDir . '/simbiat/filename-sanitizer/src', $vendorDir . '/simbiat/htmlcut/src', $vendorDir . '/simbiat/lodestone-parser/src', $vendorDir . '/simbiat/nl2tag/src', $vendorDir . '/simbiat/optimize-tables/src', $vendorDir . '/simbiat/sand-clock/src'),
18+
'Simbiat\\' => array($baseDir . '/lib', $vendorDir . '/simbiat/accountkeying/src', $vendorDir . '/simbiat/arrayhelpers/src', $vendorDir . '/simbiat/filename-sanitizer/src', $vendorDir . '/simbiat/htmlcut/src', $vendorDir . '/simbiat/nl2tag/src', $vendorDir . '/simbiat/optimize-tables/src', $vendorDir . '/simbiat/sand-clock/src', $vendorDir . '/simbiat/lodestone-parser/src'),
1919
'SendGrid\\Stats\\' => array($vendorDir . '/sendgrid/sendgrid/lib/stats'),
2020
'SendGrid\\Mail\\' => array($vendorDir . '/sendgrid/sendgrid/lib/mail'),
2121
'SendGrid\\Helper\\' => array($vendorDir . '/sendgrid/sendgrid/lib/helper'),

vendor/composer/autoload_static.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,10 @@ class ComposerStaticInit9cb5e51127eac4482719e60ef4a40a8f
121121
2 => __DIR__ . '/..' . '/simbiat/arrayhelpers/src',
122122
3 => __DIR__ . '/..' . '/simbiat/filename-sanitizer/src',
123123
4 => __DIR__ . '/..' . '/simbiat/htmlcut/src',
124-
5 => __DIR__ . '/..' . '/simbiat/lodestone-parser/src',
125-
6 => __DIR__ . '/..' . '/simbiat/nl2tag/src',
126-
7 => __DIR__ . '/..' . '/simbiat/optimize-tables/src',
127-
8 => __DIR__ . '/..' . '/simbiat/sand-clock/src',
124+
5 => __DIR__ . '/..' . '/simbiat/nl2tag/src',
125+
6 => __DIR__ . '/..' . '/simbiat/optimize-tables/src',
126+
7 => __DIR__ . '/..' . '/simbiat/sand-clock/src',
127+
8 => __DIR__ . '/..' . '/simbiat/lodestone-parser/src',
128128
),
129129
'SendGrid\\Stats\\' =>
130130
array (

vendor/composer/installed.json

+6-6
Original file line numberDiff line numberDiff line change
@@ -2578,17 +2578,17 @@
25782578
},
25792579
{
25802580
"name": "simbiat/lodestone-parser",
2581-
"version": "1.1.15+20240626",
2582-
"version_normalized": "1.1.15.0",
2581+
"version": "1.1.16+20240628",
2582+
"version_normalized": "1.1.16.0",
25832583
"source": {
25842584
"type": "git",
25852585
"url": "https://github.com/Simbiat/lodestone-parser.git",
2586-
"reference": "2f1f28c93c59f660c46a1a71d1b96ceefa67d74f"
2586+
"reference": "32eb00aa0499964a9dc7acd1a0119fac8c1664ab"
25872587
},
25882588
"dist": {
25892589
"type": "zip",
2590-
"url": "https://api.github.com/repos/Simbiat/lodestone-parser/zipball/2f1f28c93c59f660c46a1a71d1b96ceefa67d74f",
2591-
"reference": "2f1f28c93c59f660c46a1a71d1b96ceefa67d74f",
2590+
"url": "https://api.github.com/repos/Simbiat/lodestone-parser/zipball/32eb00aa0499964a9dc7acd1a0119fac8c1664ab",
2591+
"reference": "32eb00aa0499964a9dc7acd1a0119fac8c1664ab",
25922592
"shasum": ""
25932593
},
25942594
"require": {
@@ -2599,7 +2599,7 @@
25992599
"replace": {
26002600
"simbiat/lodestone-php": "*"
26012601
},
2602-
"time": "2024-06-26T17:57:20+00:00",
2602+
"time": "2024-06-28T12:34:26+00:00",
26032603
"type": "library",
26042604
"installation-source": "source",
26052605
"autoload": {

vendor/composer/installed.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -292,9 +292,9 @@
292292
'dev_requirement' => false,
293293
),
294294
'simbiat/lodestone-parser' => array(
295-
'pretty_version' => '1.1.15+20240626',
296-
'version' => '1.1.15.0',
297-
'reference' => '2f1f28c93c59f660c46a1a71d1b96ceefa67d74f',
295+
'pretty_version' => '1.1.16+20240628',
296+
'version' => '1.1.16.0',
297+
'reference' => '32eb00aa0499964a9dc7acd1a0119fac8c1664ab',
298298
'type' => 'library',
299299
'install_path' => __DIR__ . '/../simbiat/lodestone-parser',
300300
'aliases' => array(),

0 commit comments

Comments
 (0)