forked from pipprit/XIVPads-LodestoneAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAPI.php
More file actions
executable file
·3710 lines (3111 loc) · 137 KB
/
Copy pathAPI.php
File metadata and controls
executable file
·3710 lines (3111 loc) · 137 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<?php
/*
XIVPads.com (v4) - Lodestone Query API
--------------------------------------------------
Author: Josh Freeman (Premium Virtue)
Support: http://xivpads.com/?Portal
Version: 5
PHP: 5.4
Always ensure you download from the github
https://github.com/viion/XIVPads-LodestoneAPI
--------------------------------------------------
If you have an auto loader, either change the namespace
or put the API into /api/lodestone/api.php
Legacy new LodestoneAPI(); will still work.
--------------------------------------------------
Note on foreign character results, these in raw format
will render very weird, this happens when debugging
and it is usually because no charset, you can add a
meta tag to your document to get true output.
<meta charset="UTF-8">
View the test.php script as an example.
*/
// Debug stuff
//error_reporting(-1);
// Namespace
namespace Viion\Lodestone;
require_once(dirname(__FILE__).'/phpQuery.php');
/* trait 'Funky'
* Cool functions that all classes will get access to
*/
trait Funky
{
/**
* Return Unicode for a character
* @param string $u
* @return int
*/
function uniord($u) {
$k = mb_convert_encoding($u, 'UCS-2LE', 'UTF-8');
$k1 = ord(substr($k, 0, 1));
$k2 = ord(substr($k, 1, 1));
return $k2 * 256 + $k1;
}
/* - sƒow
* Shows the contents of an object.
*/
function show($data = null)
{
// If there is no data, replace it with this
if (!$data) { $data = $this; }
// Print it
echo '<pre>';
print_r($data);
echo '</pre>';
}
/* - sksort
* Sorts by a key. Can handle multi-dimentional arrays.
* It is used globally, so it modifies the pointered array, thus use it like so:
*
* $array = ['some' => 'array'];
* $this->sksort($array, 'some');
*/
function sksort(&$array, $subkey, $sort_ascending = false)
{
if (count($array))
{
$temp_array[key($array)] = array_shift($array);
}
foreach($array as $key => $val)
{
$offset = 0;
$found = false;
foreach($temp_array as $tmp_key => $tmp_val)
{
if(!$found and strtolower($val[$subkey]) > strtolower($tmp_val[$subkey]))
{
$temp_array = array_merge( (array)array_slice($temp_array,0,$offset),
array($key => $val),
array_slice($temp_array,$offset)
);
$found = true;
}
$offset++;
}
if(!$found)
{
$temp_array = array_merge($temp_array, array($key => $val));
}
}
if ($sort_ascending)
{
$array = array_reverse($temp_array);
}
else
{
$array = $temp_array;
}
}
/* - log
* Sends a message to the global log variable if it exists
*/
function log($line, $message, $Array = null)
{
if (array_key_exists('LodestoneAPILogger', $GLOBALS))
{
global $LodestoneAPILogger;
// If we have an array, append per param
if ($Array)
{
$message = $message .' # Params: ';
foreach($Array as $i => $param)
{
$message = $message . '[('. $i .') '. $param .']';
}
}
// Append line number
$message = $line .' > '. $message;
// Log
$LodestoneAPILogger->log($message);
}
}
}
/* trait 'Funky'
* Various configuration data to be used by other classes
*/
trait Config
{
// url addresses to various lodestone content. (DO NOT CHANGE, it will break some functionality of the API)
private $URL =
[
# base url
'base' => 'http://eu.finalfantasyxiv.com',
# Search related urls
'search' =>
[
'query' => '?q=%name%&worldname=%server%',
],
# Character related urls
'character' =>
[
'profile' => 'http://eu.finalfantasyxiv.com/lodestone/character/',
'achiSummary' => '/achievement/',
'achievement' => '/achievement/kind/',
'blog' => '/blog/',
],
# Free company related urls
'freecompany' =>
[
'profile' => 'http://eu.finalfantasyxiv.com/lodestone/freecompany/',
'member' => '/member/',
'memberpage' => '?page=%page%',
],
# Linkshell related urls
'linkshell' =>
[
'profile' => 'http://eu.finalfantasyxiv.com/lodestone/linkshell/',
'activity' => '/activity/',
],
# Lodestone
'lodestone' =>
[
'news' => 'http://eu.finalfantasyxiv.com/lodestone/news/',
'topic' => 'http://eu.finalfantasyxiv.com/lodestone/topics/',
'notices' => 'http://eu.finalfantasyxiv.com/lodestone/news/category/1',
'maintenance' => 'http://eu.finalfantasyxiv.com/lodestone/news/category/2',
'updates' => 'http://eu.finalfantasyxiv.com/lodestone/news/category/3',
'status' => 'http://eu.finalfantasyxiv.com/lodestone/news/category/4',
'worldstatus' => 'http://eu.finalfantasyxiv.com/lodestone/worldstatus/',
// Multi language is currently not supposed as the "Dev Tracker" links change
// based on time. I could make it parse this page, get the correct link and
// then go parse the dev tracker links, but that is multiple curl and I dont
// want to do that just yet. Maybe in the future!
'forums' =>'http://forum.square-enix.com/ffxiv/forum.php',
],
###
# Social IDs
'social' =>
[
'youtube' => 'FINALFANTASYXIV',
],
# Youtube API
'youtube' =>
[
'channels' => 'https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername={channel}&key={key}',
'playlists' => 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults={max}&playlistId={playlistID}&key={key}',
],
# Because twitter is a useless piece of shit when it comes to API
# and practically prevents public access even through app key (like youtube)
# I will have to do the old fashion source code parse... Fun!
'twitter' =>
[
'en' => 'https://twitter.com/ff_xiv_en'
],
];
// Gamedataz
public $AchievementCategories = [1, 2, 4, 5, 6, 8, 11, 12, 13];
// Gear sets
public $GearSlots =
[
"main","tool","shield","soul crystal",
"head","body","hands","waist","legs","feet",
"necklace","earrings","bracelets","ring","ring2"
];
public $ClassList = [];
public $ClassDisicpline = [];
//---------------------------------------------------------------------
// Keys!
//---------------------------------------------------------------------
// Google API key (used to parse Youtube API)
// Change this to your own app ID if you wish.
private $GoogleAPIKey = 'AIzaSyDWPpnQYGaiZN-AuQBNyDDSCJdy9fQcHnQ';
public function getGoogleAPIKey() { return $this->GoogleAPIKey; }
function __construct()
{
// Set classes
$this->ClassList = array(
"Gladiator", "Pugilist", "Marauder", "Lancer", "Archer", "Rogue", "Conjurer", "Thaumaturge", "Arcanist", "Carpenter", "Blacksmith",
"Armorer", "Goldsmith", "Leatherworker", "Weaver", "Alchemist", "Culinarian", "Miner", "Botanist", "Fisher"
);
// Set class by disicpline
$this->ClassDisicpline = array(
"dow" => array_slice($this->ClassList, 0, 6),
"dom" => array_slice($this->ClassList, 6, 3),
"doh" => array_slice($this->ClassList, 9, 8),
"dol" => array_slice($this->ClassList, 17, 3),
);
}
}
/* LodestoneAPI
* ------------
*/
class API extends Parser
{
use Funky;
use Config;
// defaults
private $defaults =
[
'automaticallyParseFreeCompanyMembers' => false,
'pagesPerFreeCompanyMemberList' => 20,
];
// List of characters parsed
public $Characters = [];
public $Achievements = [];
public $Search = [];
/**
* Blog
* @var Blog
*/
public $Blog = null;
// List of free company data parsed
public $FreeCompanyList = [];
public $FreeCompanyMembersList = [];
// List of linkshell data parsed
public $Linkshells = [];
// Initialize
public function __construct() {}
#-------------------------------------------#
# SHORT GETS #
#-------------------------------------------#
/**
* - get
* Gets a character, the array can be either "name, server" OR "id". If you
* pass an name and server, the API will have to search, it will then select the
* first result found. If you pass an ID, the search is skipped and is twice as
* fast and more reliable due to exact ID being known.
*
* The same principle applies to getFC and getLS
*
* @return Character
**/
public function get($Array, $Options = null)
{
$this->log(__LINE__, 'function: get() - start');
// Clean
$Name = isset($Array['name']) ? trim(ucwords($Array['name'])) : NULL;
$Server = isset($Array['server']) ? trim(ucwords($Array['server'])) : NULL;
$ID = isset($Array['id']) ? trim($Array['id']) : NULL;
// If no ID passed, find it.
if (!$ID)
{
// Search by Name + Server, exact
$this->searchCharacter($Name, $Server, true);
// Get by specific ID
$ID = $this->getSearch()['results'][0]['id'];
}
// If an ID
if ($ID)
{
// Parse profile
$this->parseProfile($ID);
// Return character
$this->log(__LINE__, 'function: get() - return');
return $this->getCharacterByID($ID);
}
else
{
return false;
}
}
/** - getFC
* Read "get" for characters, same rules apply to this.
* @return FreeCompany
**/
public function getFC($Array, $Options = null)
{
// Clean
$Name = isset($Array['name']) ? trim(ucwords($Array['name'])) : NULL;
$Server = isset($Array['server']) ? trim(ucwords($Array['server'])) : NULL;
$ID = isset($Array['id']) ? trim($Array['id']) : NULL;
// If no ID passed, find it.
if (!$ID)
{
// Search by Name + Server, exact
$this->searchFreeCompany($Name, $Server, true);
// Get by specific ID
$ID = $this->getSearch()['results'][0]['id'];
}
// If an ID
if ($ID)
{
// Parse profile
$this->parseFreeCompany($ID, $Options);
// Return character
return $this->getFreeCompanyByID($ID);
}
else
{
return false;
}
}
/* - getLS
* Read "get" for characters, same rules apply to this.
* returns: Linkshell object
*/
public function getLS($Array, $Options = null)
{
// Clean
$Name = isset($Array['name']) ? trim(ucwords($Array['name'])) : NULL;
$Server = isset($Array['server']) ? trim(ucwords($Array['server'])) : NULL;
$ID = isset($Array['id']) ? trim($Array['id']) : NULL;
// If no ID passed, find it.
if (!$ID)
{
// Search by Name + Server, exact
$this->searchLinkshell($Name, $Server, true);
// Get by specific ID
$ID = $this->getSearch()['results'][0]['id'];
}
// If an ID
if ($ID)
{
// Parse profile
$this->parseLinkshell($ID, $Options);
// Return character
return $this->getLinkshellByID($ID);
}
else
{
return false;
}
}
// Get lodestone object
public function Lodestone() { return new Lodestone(); }
// Get social object
public function Social() { return new Social(); }
#-------------------------------------------#
# SEARCH #
#-------------------------------------------#
// Search a character by its name and server.
public function searchCharacter($Name, $Server, $GetExact = true)
{
$this->log(__LINE__, 'function: searchCharacter()');
if (!$Name)
{
echo "error: No Name Set.";
}
else if (!$Server)
{
echo "error: No Server Set.";
}
else
{
// Exact name for later
$ExactName = $Name;
$this->log(__LINE__, 'function: searchCharacter() - searching ...');
// Get the source
$this->getSource($this->URL['character']['profile'] . str_ireplace(array('%name%', '%server%'), array(str_ireplace(" ", "+", $Name), $Server), $this->URL['search']['query']));
// Get all found characters
$Found = $this->findAll('thumb_cont_black_50', 10, NULL, false);
$this->log(__LINE__, 'function: searchCharacter() - got results');
// Loop through results
if ($Found)
{
foreach($Found as $F)
{
$Avatar = explode('"', $F[1])[3];
$Data = explode('"', $F[6]);
$ID = trim(explode('/', $Data[3])[3]);
$NameServer = explode("(", trim(str_ireplace(">", NULL, strip_tags(html_entity_decode($Data[4])))));
$Name = htmlspecialchars_decode(trim($NameServer[0]), ENT_QUOTES);
$Server = trim(str_ireplace(")", NULL, $NameServer[1]));
$Language = $F[4];
// Append search results
$this->Search['results'][] = array(
"avatar" => $Avatar,
"name" => $Name,
"server" => $Server,
"id" => $ID,
);
}
// If to get exact
if ($GetExact)
{
$Exact = false;
foreach($this->Search['results'] as $Character)
{
//show($Character['name'] .' < > '. $ExactName);
//show(md5($Character['name']) .' < > '. md5($ExactName));
//show(strlen($Character['name']) .' < > '. strlen($ExactName));
$n1 = trim(strtolower($Character['name']));
$n2 = trim(strtolower($ExactName));
if ($n1 == $n2 && strlen($n1) == strlen($n2))
{
$Exact = true;
$this->Search['results'] = NULL;
$this->Search['results'][] = $Character;
$this->Search['isExact'] = true;
break;
}
}
// If no exist false, null array
if (!$Exact)
{
$this->Search = NULL;
}
}
// Number of results
$this->Search['total'] = count($this->Search['results']);
}
else
{
$this->Search['total'] = 0;
$this->Search['results'] = NULL;
}
}
}
// Search a free company by name and server
public function searchFreeCompany($Name, $Server, $GetExact = true)
{
if (!$Name)
{
echo "error: No Name Set.";
}
else if (!$Server)
{
echo "error: No Server Set.";
}
else
{
// Exact name for later
$ExactName = $Name;
// Get the source
$this->getSource($this->URL['freecompany']['profile'] . str_ireplace(array('%name%', '%server%'), array(str_ireplace(" ", "+", $Name), $Server), $this->URL['search']['query']));
// Get all found data
$Found = $this->findAll('ic_freecompany_box', null, '/tr', false);
// if found
if ($Found)
{
foreach($Found as $F)
{
$Temp = [];
foreach($F as $i => $line)
{
if (stripos($line, 'ic_crest_64') !== false)
{
$offset = $i + 2;
$Temp['emblum'][] = $this->getAttribute('src', $F[$offset]);
$Temp['emblum'][] = $this->getAttribute('src', $F[$offset + 1]);
$Temp['emblum'][] = $this->getAttribute('src', $F[$offset + 2]);
}
if (stripos($line, 'groundcompany_name') !== false)
{
$Temp['grandcompany'] = $this->strip_html($line);
}
if (stripos($line, 'player_name_gold') !== false)
{
$offset = $i + 1;
$data = explode('(', $this->strip_html($F[$offset]));
$Temp['name'] = trim($data[0]);
$Temp['server'] = trim(str_ireplace(')', null, $data[1]));
$Temp['id'] = explode('/', $F[$offset])[3];
$Temp['url'] = $this->URL['freecompany']['profile'] . $Temp['id'];
}
if (stripos($line, 'ldst_strftime') !== false)
{
$Temp['formed'] = explode('(', $line)[2];
$Temp['formed'] = explode(',', $Temp['formed'])[0];
}
}
$this->Search['results'][] = $Temp;
}
// If to get exact
if ($GetExact)
{
$Exact = false;
foreach($this->Search['results'] as $FreeCompany)
{
$n1 = trim(strtolower($FreeCompany['name']));
$n2 = trim(strtolower($ExactName));
if ($n1 == $n2 && strlen($n1) == strlen($n2))
{
$Exact = true;
$this->Search['results'] = NULL;
$this->Search['results'][] = $FreeCompany;
$this->Search['isExact'] = true;
break;
}
}
// If no exist false, null array
if (!$Exact)
{
$this->Search = NULL;
}
}
// Number of results
$this->Search['total'] = count($this->Search['results']);
}
else
{
$this->Search['total'] = 0;
$this->Search['results'] = NULL;
}
}
}
// Search a linkshell by name and server
public function searchLinkshell($Name, $Server, $GetExact = true)
{
if (!$Name)
{
echo "error: No Name Set.";
}
else if (!$Server)
{
echo "error: No Server Set.";
}
else
{
// Exact name for later
$ExactName = $Name;
// Get the source
$this->getSource($this->URL['linkshell']['profile'] . str_ireplace(array('%name%', '%server%'), array(str_ireplace(" ", "+", $Name), $Server), $this->URL['search']['query']));
// Get all found data
$Found = $this->findAll('player_name_gold linkshell_name', 5, NULL, false);
// if found
if ($Found)
{
foreach($Found as $F)
{
$ID = trim(explode("/", $F[0])[3]);
$Name = trim(str_ireplace(['"', '<', '>'], null, explode("/", $F[0])[4]));
$Server = trim(strip_tags(html_entity_decode(str_ireplace(")", null, explode("(", $F[0])[1]))));
$Members = trim(explode(":", strip_tags(html_entity_decode($F[3])))[1]);
$this->Search['results'][] =
[
"id" => $ID,
"name" => $Name,
"server" => $Server,
"members" => $Members,
];
}
// If to get exact
if ($GetExact)
{
$Exact = false;
foreach($this->Search['results'] as $Linkshell)
{
$n1 = trim(strtolower($Linkshell['name']));
$n2 = trim(strtolower($ExactName));
if ($n1 == $n2 && strlen($n1) == strlen($n2))
{
$Exact = true;
$this->Search['results'] = NULL;
$this->Search['results'][] = $Linkshell;
$this->Search['isExact'] = true;
break;
}
}
// If no exist false, null array
if (!$Exact)
{
$this->Search = NULL;
}
}
// Number of results
$this->Search['total'] = count($this->Search['results']);
}
else
{
$this->Search['total'] = 0;
$this->Search['results'] = NULL;
}
}
}
// Get search results
public function getSearch() { return $this->Search; }
// Checks if an error page exists
public function errorPage($ID)
{
// Check error message
$PageNotFound = $this->find('base_visual_error');
// if error message is found.
if ($PageNotFound) { return true; }
return false;
}
#-------------------------------------------#
# PROFILE #
#-------------------------------------------#
// Parse a profile based on ID (skips searching)
public function parseProfile($ID)
{
$this->log(__LINE__, 'function: parseProfile() - parsing profile: '. $ID);
if (!$ID)
{
echo "error: No ID Set.";
}
// Get the source
$this->log(__LINE__, 'function: parseProfile() - get source');
$this->getSource($this->URL['character']['profile'] . $ID);
$this->log(__LINE__, 'function: parseProfile() - obtained source');
if ($this->errorPage($ID))
{
echo "error: Character page does not exist.";
}
else
{
$this->log(__LINE__, 'function: parseProfile() - starting parse');
// Create a new character object
$Character = new Character();
$this->log(__LINE__, 'function: parseProfile() - new character object');
// Set Character Data
$Character->setID(trim($ID), $this->URL['character']['profile'] . $ID);
$Character->setNameServer($this->findRange('player_name_thumb', 15));
$this->log(__LINE__, 'function: parseProfile() - set id, name and server');
// Only process if character name set
if (strlen($Character->getName()) > 3)
{
$this->log(__LINE__, 'function: parseProfile() - parsing chunk 1');
$Character->setTitle($this->findRange('chara_title', 2, NULL, false));
$Character->setAvatar($this->findRange('player_name_thumb', 10, NULL, false));
$Character->setPortrait($this->findRange('bg_chara_264', 2, NULL, false));
$Character->setRaceClan($this->find('chara_profile_title'));
//$Character->setLegacy($this->find('bt_legacy_history'));
$Character->setNamedayCityCompanyFC($this->findRange('chara_profile_left', null, "chara_class_box", false));
$Character->setCity($this->findRange('City-state', 5));
$Character->setBiography($this->findRange('txt_selfintroduction', 5));
$Character->setStats($this->findAll('param_left_area_inner', 12, null, false));
$Character->setHPMPTP($this->findRange('param_power_area', 10));
$Character->setActiveClassLevel($this->findAll('class_info', 5, null, false));
$this->log(__LINE__, 'function: parseProfile() - parsing chunk 2');
// Set Gear (Also sets Active Class and Job), then set item level from the gear
$Character->setGear($this->findAll('-- ITEM Detail --', NULL, '-- //ITEM Detail --', false));
$Character->setItemLevel($this->GearSlots);
#$this->segment('area_header_w358_inner');
$this->log(__LINE__, 'function: parseProfile() - parsing chunk 3');
// Set Minions
$Minions = $this->findRange('-- Minion --', NULL, '//Minion', false);
$Character->setMinions($Minions);
// Set Mounts
$this->log(__LINE__, 'function: parseProfile() - parsing chunk 4');
$Mounts = $this->findRange('-- Mount --', NULL, '//Mount', false);
$Character->setMounts($Mounts);
#$this->segment('class_fighter');
// Set ClassJob
$this->log(__LINE__, 'function: parseProfile() - parsing chunk 5');
$Character->setClassJob($this->findRange('class_fighter', NULL, '//Class Contents', false));
// Validate data
$Character->validate();
$this->log(__LINE__, 'function: parseProfile() - complete profile parse for: '. $ID);
// Append character to array
$this->Characters[$ID] = $Character;
}
else
{
$this->Characters[$ID] = NULL;
}
}
}
// Parse just biography, based on ID
public function parseBiography($ID)
{
// Get the source
$this->getSource($this->URL['character']['profile'] . $ID);
// Create a new character object
$Character = new Character();
// Get biography
$Character->setBiography($this->findRange('txt_selfintroduction', 5));
// Return biography
return $Character->getBiography();
}
// Get a list of parsed characters
public function getCharacters() { return $this->Characters; }
/**
* Gett Charcater by id
* @param int $ID
* @return Character Get a character by id
*/
public function getCharacterByID($ID) { return isset($this->Characters[$ID]) ? $this->Characters[$ID] : NULL; }
#-------------------------------------------#
# ACHIEVEMENTS #
#-------------------------------------------#
// Parse a achievements based on ID
public function parseAchievements($ID = null)
{
if (!$ID)
{
$ID = $this->getID();
}
if (!$ID)
{
echo "error: No ID Set.";
}
else
{
// Main achievement object
$MA = new Achievements();
// Loop through categories
foreach($this->AchievementCategories as $cID)
{
// Parse Achievements
$this->parseAchievementsByCategory($cID, $ID);
// Get Achievement Object
$A = $this->Achievements[$cID];
// Add onto main achievements object
$MA->setTotalPoints($MA->getTotalPoints() + $A->getTotalPoints());
$MA->setCurrentPoints($MA->getCurrentPoints() + $A->getCurrentPoints());
$MA->setTotalAchievements($MA->getTotalAchievements() + $A->getTotalAchievements());
$MA->setCurrentAchievements($MA->getCurrentAchievements() + $A->getCurrentAchievements());
$MA->genPointsPercentage();
$MA->addAchievements($A->get());
$MA->addCategory($cID);
}
// Format Achievements
$this->Achievements = $MA;
}
}
// Parse achievement by category
public function parseAchievementsSummary($ID = null)
{
if (!$ID)
{
$ID = $this->getID();
}
if (!$ID)
{
echo "error: No ID Set.";
}
else
{
// Get the source
$this->getSource($this->URL['character']['profile'] . $ID . $this->URL['character']['achiSummary']);
// Create a new character object
$Achievements = new Achievements();
// Get Achievements
$Public = $Achievements->checkIfPublic($this->findAll('area_inner_tc', 20));
if ($Public)
{
$Achievements->setSummary($this->findAll('achievement_area_footer', NULL, '/li', false));
// Append character to array
return $Achievements;
}
else
{
return false;
}
}
}
// Parse achievement by category
public function parseAchievementsByCategory($cID, $ID = null)
{
if (!$ID)
{
$ID = $this->getID();
}
if (!$ID)
{
echo "error: No ID Set.";
}
else if (!$cID)
{
echo "No catagory id set.";
}
else
{
// Get the source
$this->getSource($this->URL['character']['profile'] . $ID . $this->URL['character']['achievement'] . $cID .'/');
// Create a new character object
$Achievements = new Achievements();
// Get Achievements
$Public = $Achievements->checkIfPublic($this->findAll('area_inner_tc', 20));
if ($Public)
{
// Get Achievements
$Achievements->addCategory($cID);
$Achievements->set($this->findAll('achievement_area_body', NULL, 'bt_more', false));
// Append character to array
return $Achievements;
}
else
{
return false;
}
// Append character to array
$this->Achievements[$cID] = $Achievements;
return $Achievements;
}
}
// Get a list of parsed characters
public function getAchievements() { return $this->Achievements; }
// Get the achievement categories
public function getAchievementCategories() { return $this->AchievementCategories; }
#-------------------------------------------#
# BLOG #
#-------------------------------------------#
// Parse achievement by CharacterID
public function parseBlog($ID = null)
{
if (!$ID)
{
$ID = $this->getID();
}
if (!$ID)
{
echo "error: No ID Set.";
}
else
{
$Blog = new Blog($ID);
$Blog->setEntries();
$this->Blog = $Blog;
}
}
/**
* Get a list of blogEntries
* @return Blog
**/
public function getBlog() { return $this->Blog; }
/**
* Get a blogEntryById
* @return array