forked from RetroAchievements/RAWeb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
_dynrender.php
3181 lines (2615 loc) · 124 KB
/
_dynrender.php
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
require_once('db.inc.php');
/////////////////////////////////////////////////////////////////////////////////////////
// Dynamic Rendering
//////////////////////////////////////////////////////////////////////////////////////////
function getFeedItemTitle( $feedData, $withHyperlinks = true, $site = 'http://www.retroachievements.org' )
{
$retHTML = '';
$actType = $feedData[ 'activitytype' ];
$user = $feedData[ 'User' ];
$timestamp = $feedData[ 'timestamp' ];
$achID = $feedData[ 'data' ]; // intentional: blind data, dual use
$achTitle = $feedData[ 'AchTitle' ];
$achPoints = $feedData[ 'AchPoints' ];
$gameID = $feedData[ 'GameID' ];
$gameTitle = $feedData[ 'GameTitle' ];
$console = $feedData[ 'ConsoleName' ];
// LB only:
$nextLBID = $feedData[ 'data' ];
$nextLBScore = $feedData[ 'data2' ];
$nextLBName = $feedData[ 'LBTitle' ];
$nextLBFormat = $feedData[ 'LBFormat' ];
// Inject hyperlinks:
if( $withHyperlinks )
{
$user = "<a href='$site/User/$user'>$user</a>";
$achTitle = "<a href='$site/Achievement/$achID'>$achTitle</a>";
$gameTitle = "<a href='$site/Game/$gameID'>$gameTitle</a>";
$nextLBName = "<a href='$site/leaderboardinfo.php?i=$nextLBID'>$nextLBName</a>";
}
switch( $actType )
{
case 0: // misc
$retHTML = 'Unknown';
break;
case 1: // achievement
$retHTML .= "$user earned $achTitle ($achPoints) in $gameTitle";
break;
case 2: // login
$retHTML .= "$user logged in";
break;
case 3: // start playing game
$retHTML .= "$user started playing $gameTitle ($console)";
break;
case 4: // upload ach
$retHTML = "$user uploaded a new achievement: $achTitle ($achPoints) for $gameTitle ($console)";
break;
case 5: // modify ach
$retHTML = "$user made improvements to: $achTitle ($achPoints) for $gameTitle ($console)";
break;
case 6: // complete game
$retHTML = "$user completed $gameTitle ($console)";
break;
case 7: // submit new record
$retHTML = "$user submitted " . GetFormattedLeaderboardEntry( $nextLBFormat, $nextLBScore ) . " for $nextLBName on $gameTitle ($console)";
break;
case 8: // updated record
$entryType = ( strcmp( $nextLBFormat, 'TIME' ) == 0 || strcmp( $nextLBFormat, 'TIMESECS' ) == 0 ) ? "time" : "score";
$retHTML = "$user improved their $entryType: " . GetFormattedLeaderboardEntry( $nextLBFormat, $nextLBScore ) . " for $nextLBName on $gameTitle ($console)";
break;
}
return $retHTML;
}
function getFeedItemHTML( $feedData, $user )
{
$retHTML = '';
// WILL ALWAYS BE PRESENT in feedData. Note: in SQL order
$nextID = $feedData[ 'ID' ];
$nextTimestamp = $feedData[ 'timestamp' ];
$nextActivityType = $feedData[ 'activitytype' ];
$nextUser = $feedData[ 'User' ];
$nextUserPoints = $feedData[ 'RAPoints' ];
$nextUserMotto = $feedData[ 'Motto' ];
$nextData = $feedData[ 'data' ];
$nextData2 = $feedData[ 'data2' ];
$nextGameTitle = $feedData[ 'GameTitle' ];
$nextGameID = $feedData[ 'GameID' ];
$nextGameIcon = $feedData[ 'GameIcon' ];
$nextConsoleName = $feedData[ 'ConsoleName' ];
$nextAchTitle = $feedData[ 'AchTitle' ];
$nextAchDesc = $feedData[ 'AchDesc' ];
$nextAchPoints = $feedData[ 'AchPoints' ];
$nextAchBadge = $feedData[ 'AchBadge' ];
$nextLBName = $feedData[ 'LBTitle' ];
$nextLBDesc = $feedData[ 'LBDesc' ];
$nextLBFormat = $feedData[ 'LBFormat' ];
$rowID = "art_$nextID";
$dateCell = "<td class='date'><small> " . date( "H:i ", $nextTimestamp ) . " </small></td>";
switch( $nextActivityType )
{
case 0: // misc
$retHTML .= "<tr id='$rowID' class='feed_login'>";
$retHTML .= $dateCell;
$retHTML .= "<td class='icons'>";
$retHTML .= "</td>";
$retHTML .= "<td></td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
break;
case 1: // achievement
$retHTML .= "<tr id='$rowID' class='feed_won'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= GetAchievementAndTooltipDiv( $nextData, $nextAchTitle, $nextAchDesc, $nextAchPoints, $nextGameTitle, $nextAchBadge, TRUE, TRUE );
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_won'>";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
$retHTML .= " earned ";
$retHTML .= GetAchievementAndTooltipDiv( $nextData, $nextAchTitle, $nextAchDesc, $nextAchPoints, $nextGameTitle, $nextAchBadge, FALSE );
if( isset( $nextData2 ) && $nextData2 == 1 )
$retHTML .= " (HARDCORE)";
$retHTML .= " in ";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, FALSE, 32, TRUE );
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
break;
case 2: // login
$retHTML .= "<tr id='$rowID' class='feed_login'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= "<img alt='$nextUser logged in' title='Logged in' src='/Images/LoginIcon32.png' width='32' height='32' class='badgeimg' />";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_login'>";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
$retHTML .= " logged in";
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
break;
case 3: // start playing game
if( $nextGameTitle !== "UNRECOGNISED" )
{
$retHTML .= "<tr id='$rowID' class='feed_startplay'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, TRUE );
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_startplay'>";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
$retHTML .= " started playing ";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, FALSE, 32, TRUE );
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
}
break;
case 4: // upload ach
$retHTML .= "<tr id='$rowID' class='feed_dev1'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= GetAchievementAndTooltipDiv( $nextData, $nextAchTitle, $nextAchDesc, $nextAchPoints, $nextGameTitle, $nextAchBadge, TRUE, TRUE );
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_dev1'>";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
$retHTML .= " uploaded a new achievement: ";
$retHTML .= GetAchievementAndTooltipDiv( $nextData, $nextAchTitle, $nextAchDesc, $nextAchPoints, $nextGameTitle, $nextAchBadge, FALSE );
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
break;
case 5: // modify ach
$retHTML .= "<tr id='$rowID' class='feed_dev2'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= GetAchievementAndTooltipDiv( $nextData, $nextAchTitle, $nextAchDesc, $nextAchPoints, $nextGameTitle, $nextAchBadge, TRUE, TRUE );
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_dev2'>";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
$retHTML .= " made improvements to: ";
$retHTML .= GetAchievementAndTooltipDiv( $nextData, $nextAchTitle, $nextAchDesc, $nextAchPoints, $nextGameTitle, $nextAchBadge, FALSE );
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
break;
case 6: // complete game
{
$retHTML .= "<tr id='$rowID' class='feed_completegame'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, TRUE );
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_completegame'>";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
if( $nextData2 == 1 )
$retHTML .= " MASTERED ";
else
$retHTML .= " completed ";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, FALSE, 32, TRUE );
if( $nextData2 == 1 )
$retHTML .= " (HARDCORE)";
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
}
break;
case 7: // submit new record
{
$retHTML .= "<tr id='$rowID' class='feed_submitrecord'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, TRUE );
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_submitrecord'>";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
$retHTML .= " submitted ";
$retHTML .= GetLeaderboardAndTooltipDiv( $nextData, $nextLBName, $nextLBDesc, $nextGameTitle, $nextGameIcon, GetFormattedLeaderboardEntry( $nextLBFormat, $nextData2 ) );
$retHTML .= " for ";
$retHTML .= GetLeaderboardAndTooltipDiv( $nextData, $nextLBName, $nextLBDesc, $nextGameTitle, $nextGameIcon, $nextLBName );
$retHTML .= " on ";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, FALSE, 32, TRUE );
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
}
break;
case 8: // updated record
{
$retHTML .= "<tr id='$rowID' class='feed_updaterecord'>";
$retHTML .= $dateCell;
// Images:
$retHTML .= "<td class='icons'>";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, TRUE );
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, TRUE );
$retHTML .= "</td>";
// Content:
$retHTML .= "<td class='feed_updaterecord'>";
$entryType = ( strcmp( $nextLBFormat, 'TIME' ) == 0 || strcmp( $nextLBFormat, 'TIMESECS' ) == 0 ) ? "time" : "score";
$retHTML .= GetUserAndTooltipDiv( $nextUser, $nextUserPoints, $nextUserMotto, NULL, NULL, FALSE );
$retHTML .= " improved their $entryType: ";
$retHTML .= GetLeaderboardAndTooltipDiv( $nextData, $nextLBName, $nextLBDesc, $nextGameTitle, $nextGameIcon, GetFormattedLeaderboardEntry( $nextLBFormat, $nextData2 ) );
$retHTML .= " for ";
$retHTML .= GetLeaderboardAndTooltipDiv( $nextData, $nextLBName, $nextLBDesc, $nextGameTitle, $nextGameIcon, $nextLBName );
$retHTML .= " on ";
$retHTML .= GetGameAndTooltipDiv( $nextGameID, $nextGameTitle, $nextGameIcon, $nextConsoleName, FALSE, 32, TRUE );
$retHTML .= "</td>";
if( $user !== NULL )
$retHTML .= "<td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '5' )\" /></td>";
$retHTML .= "</tr>";
}
break;
}
return $retHTML;
}
function RenderFeedItem( $feedData, $user )
{
echo getFeedItemHTML( $feedData, $user );
}
// 23:22 06/04/2013
function RenderFeedComment( $user, $comment, $submittedDate )
{
echo "<tr class='feed_comment'>";
$niceDate = date( "d M\nG:i y ", strtotime( $submittedDate ) );
//$fullDateHover = date( "d M\nH:i yy", strtotime( $submittedDate ) );
echo "<td class='smalldate'>$niceDate</td><td class='iconscomment'><a href='/User/$user'><img alt='$user' title='$user' class='badgeimg' src='/UserPic/$user" . ".png' width='32' height='32' /></a></td><td colspan='3'>$comment</td>";
echo "</tr>";
}
//
function RenderWelcomeComponent()
{
echo "
<div class='component welcome'>
<h2>Welcome!</h2>
<div id='Welcome'>
<p>
Were you the greatest in your day at Mega Drive or SNES games? Wanna prove it? Use our modified emulators and you will be awarded achievements as you play! Your progress will be tracked so you can compete with your friends to complete all your favourite classics to 100%: we provide the emulators for your Windows-based PC, all you need are the roms!<br/>
<a href='/Game/1'>Click here for an example:</a> which of these do you think you can get?
</p>
<br/>
<p style='clear:both; text-align:center'>
<a href='download.php'><b>>>Download an emulator here!<<</b></a><br/>
</p>
</div>
</div>";
}
//
function RenderNewsComponent()
{
echo "<div class='left'>";
echo "<h2>News</h2>";
$numNewsItems = getLatestNewsHeaders( 0, 10, $newsHeaders );
echo "<div id='carouselcontainer' style='height=300px;' >";
echo "<div id='carousel'>";
for( $i = 0; $i < $numNewsItems; $i++ )
RenderNewsHeader( $newsHeaders[ $i ] );
echo "</div>";
echo "<a href='#' id='ui-carousel-next'><span>next</span></a>";
echo "<a href='#' id='ui-carousel-prev'><span>prev</span></a>";
echo "<div id='carouselpages'></div>";
echo "</div>";
echo "</div>";
}
//
function RenderFeedComponent( $user )
{
echo "<div class='left'>";
echo "<div style='float:right;'>";
$feedFriendsPrefs = 0;
if( isset( $user ) )
{
$feedFriendsPrefs = RA_ReadCookie( "RAPrefs_Feed" );
$selGlobal = ( $feedFriendsPrefs == 1 ) ? '' : 'checked';
$selFriends = ( $feedFriendsPrefs == 1 ) ? 'checked' : '';
echo "<input type='radio' name='feedpref' $selGlobal onclick=\"refreshFeed(false);\" > Global<br/>";
echo "<input type='radio' name='feedpref' $selFriends onclick=\"refreshFeed(true);\" > Friends Only";
}
echo "</div>";
echo "<h2 id='globalfeedtitle'>" . ( $feedFriendsPrefs ? "Friends Feed" : "Global Feed" ) . "</h2>";
echo "<div id='globalfeed'>";
echo "Here's a breakdown of what's been happening recently:";
echo "<table id='feed'><tbody>";
echo "<tr id='feedloadingfirstrow'>";
echo "<td class='chatcell'>";
echo "<img src='http://i.retroachievements.org/Images/loading.gif' width='16' height='16' alt='loading icon' />";
echo "</td>";
echo "<td class='chatcell'>";
echo "</td>";
echo "<td class='chatcellmessage'>";
echo "loading feed...";
echo "</td>";
echo "</tr>";
echo "</tbody></table>";
echo "</div>";
echo "</div>";
}
//
function RenderDemoVideosComponent()
{
$width = '392'; //600px
$height = $width * (3.0 / 4.0); //'100%'; //400px
echo "<div id='demo' >";
echo "<h2>Demos</h2>";
echo "<h4>Using RAGens</h4>";
echo "<div class='videocontainer' >";
echo "<iframe style='border:0;' width='$width' height='$height' src='http://www.youtube.com/embed/rKY2mZjurJw' allowfullscreen></iframe>";
//echo "<iframe src='https://www.youtube-nocookie.com/v/rKY2mZjurJw?hl=en&fs=1' frameborder='0' allowfullscreen></iframe>";
//echo "<object data='https://www.youtube-nocookie.com/v/rKY2mZjurJw?hl=en&fs=1' style='width:300px;'></object>";
echo "</div>";
echo "<h4>Finding Memory Addresses</h4>";
echo "<div class='videocontainer' >";
echo "<object type='application/x-shockwave-flash' width='$width' height='$height' data='http://www.twitch.tv/widgets/archive_embed_player.swf' id='clip_embed_player_flash' >
<param name='movie' value='http://www.twitch.tv/widgets/archive_embed_player.swf' />
<param name='allowScriptAccess' value='always' />
<param name='allowNetworking' value='all' />
<param name='flashvars' value='auto_play=false&channel=retroachievementsorg&title=Finding%2BMemory%2BAddresses&chapter_id=2674100&start_volume=25' />
</object>";
echo "</div>";
echo "</div>";
}
// 19:56 06/04/2013
function RenderArticleEmptyComment( $articleType, $articleID )
{
$rowID = "art_$articleID";
echo "<tr id='$rowID' class='feed_comment'>";
echo "<td></td><td></td><td></td><td></td><td class='editbutton'><img src='http://i.retroachievements.org/Images/Edit.png' width='16' height='16' style='cursor: pointer;' onclick=\"insertEditForm( '$rowID', '$articleType' )\" /></td>";
echo "</tr>";
}
// 19:56 06/04/2013
function RenderArticleComment( $articleID, $user, $points, $motto, $comment, $submittedDate, $localUser, $articleTypeID, $commentID, $allowDelete )
{
$class = '';
$deleteIcon = '';
if( $user == $localUser || $allowDelete )
{
$class = 'localuser';
$img = "<img src='http://i.retroachievements.org/Images/cross.png' width='16' height='16' alt='delete comment'/>";
$deleteIcon = "<div style='float: right;'><a onclick=\"removeComment($articleID, $commentID); return false;\" href='#'>$img</a></div>";
}
$artCommentID = "artcomment_" . $articleID . "_" . $commentID;
echo "<tr class='feed_comment $class' id='$artCommentID'>";
//$niceDate = date( "d M\nH:i ", $submittedDate );
$niceDate = date( "j M\nG:i Y ", $submittedDate );
echo "<td alt='Test' class='smalldate'>$niceDate</td>";
echo "<td class='iconscommentsingle'>" . GetUserAndTooltipDiv( $user, $points, $motto, NULL, NULL, TRUE ) . "</td>";
echo "<td class='commenttext' colspan='3'>$deleteIcon$comment</td>";
echo "</tr>";
}
function RenderCommentInputRow( $user, $rowIDStr, $artTypeID )
{
$userImage = "<img alt='$user' title='$user' class='badgeimg' src='/UserPic/" . $user . ".png' width='32' height='32' />";
$formStr = "<textarea id='commentTextarea' rows=0 cols=30 name='c' maxlength=250></textarea>";
$formStr .= " ";
$formStr .= "<img id='submitButton' src='http://i.retroachievements.org/Images/Submit.png' alt='Submit' style='cursor: pointer;' onclick=\"processComment( '$rowIDStr', '$artTypeID' )\" />";
echo "<tr id='comment_$rowIDStr'><td></td><td class='iconscommentsingle'>$userImage</td><td colspan='3'>$formStr</td></tr>";
}
function RenderPHPBBIcons()
{
echo "<div class='buttoncollection'>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[b]\", \"[/b]\")'><b>b</b></a></span>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[i]\", \"[/i]\")'><i>i</i></a></span>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[s]\", \"[/s]\")'><s> s </s></a></span>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[img=\", \"]\")'>img</a></span>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[url=\", \"]Link[/url]\")'>url</a></span>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[ach=\", \"]\")'>ach</a></span>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[game=\", \"]\")'>game</a></span>";
echo "<span class='clickablebutton'><a href='#a' onclick='injectphpbb(\"[user=\", \"]\")'>user</a></span>";
echo "</div>";
}
function RenderTitleBar( $user, $points, $truePoints, $unreadMessageCount, $errorCode )
{
settype( $truePoints, 'integer' );
// js tooltip code is basically on every page:
echo "<script type='text/javascript' src='/js/wz_tooltip.js'></script>";
settype( $unreadMessageCount, "integer" );
echo "<div id='topborder'><span id='preload-01'></span><span id='preload-02'></span><span id='preload-03'></span></div>\n";
echo "<div id='title'>";
echo "<div id='logocontainer'><a id='logo' href='/'> </a></div>";
echo "<div class='login'>";
if( $user == FALSE )
{
echo "<div style='float:right; font-size:75%;'><a href='/resetPassword.php'>Forgot password?</a></div>";
echo "<b>login</b> to " . AT_HOST . ":<br/>";
echo "<form method='post' action='/login.php'>";
echo "<div>";
echo "<input type='hidden' name='r' value='" . $_SERVER[ 'REQUEST_URI' ] . "' />";
echo "<table><tbody>";
echo "<tr>";
echo "<td>User: </td>";
echo "<td><input type='text' name='u' size='16' class='loginbox' value='' /></td>";
echo "<td></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Pass: </td>";
echo "<td><input type='password' name='p' size='16' class='loginbox' value='' /></td>";
echo "<td style='width: 45%'><input type='submit' value='Login' name='submit' class='loginbox' /></td>";
echo "</tr>";
echo "</tbody></table>";
echo "</div>";
echo "</form>";
if( !isset( $errorCode ) )
{
echo "<div class='rightalign'>...or <a href='/createaccount.php'>create a new account</a></div>";
}
RenderThemeSelector();
}
else
{
echo "<p>";
echo "<img src='/UserPic/$user.png' alt='$user' style='float:right' align='right' width='64' height='64' class='userpic' />";
if( $errorCode == "validatedEmail" )
echo "Welcome, <a href='/user/$user'>$user</a>!<br/>";
else
echo "<strong><a href='/user/$user'>$user</a></strong> ($points) <span class='TrueRatio'>($truePoints)</span><br/>";
echo "<a href='/logout.php?Redir=" . $_SERVER[ 'REQUEST_URI' ] . "'>logout</a><br/>";
$mailboxIcon = $unreadMessageCount > 0 ? 'http://i.retroachievements.org/Images/_MailUnread.png' : 'http://i.retroachievements.org/Images/_Mail.png';
echo "<a href='/inbox.php'>";
echo "<img id='mailboxicon' style='float:left' src='$mailboxIcon' width='20' height='20'/>";
echo " ";
echo "(";
echo "<span id='mailboxcount'>$unreadMessageCount</span>";
echo ")";
echo "</a>";
echo "</p>";
RenderThemeSelector(); // Only when logged in
}
echo "<br/>";
echo "</div>";
echo "</div>";
}
function RenderToolbar( $user, $permissions = 0 )
{
echo "<div id='innermenu'>";
echo "<ul id='menuholder'>";
echo "<li><a href='#'>Home</a>";
echo "<ul>";
echo "<li><a href='/'>Home</a></li>";
if( isset( $user ) && $user != "" )
{
echo "<li><a href='/User/$user'>$user's Homepage</a></li>";
}
echo "<li><a href='/feed.php?g=1'>Global Feed</a></li>";
// SU:
if( $permissions >= 2 )
{
echo "<li><a href='/submitnews.php'>Submit News Article</a></li>";
}
// Admin:
if( $permissions >= 4 )
{
echo "<li><a href='/admin.php'>Admin Tools</a></li>";
}
echo "<li><a href='/faq.php'>FAQ</a></li>";
echo "</ul>";
echo "</li>";
echo "<li><a href='/download.php'>Download</a>";
//echo "<ul>";
//echo "<li><a href='/download.php'>RAGens (Mega Drive)</a></li>";
//echo "<li><a href='/download.php'>RASnes9x (SNES)</a></li>";
//echo "</ul>";
echo "</li>";
if( isset( $user ) && $user != "" )
{
echo "<li><a href='#'>My Pages</a>";
echo "<ul>";
echo "<li><a href='/User/$user'>$user's Homepage</a></li>";
echo "<li><a href='/feed.php?i=1'>My Feed</a></li>";
echo "<li><a href='/feed.php'>Friends Feed</a></li>";
echo "<li><a href='/friends.php'>Friends List</a></li>";
echo "<li><a href='/achievementList.php?s=4&p=2'>Easy Achievements</a></li>";
echo "<li><a href='/achievementList.php?s=14&p=1'>My Best Awards</a></li>";
echo "<li><a href='/history.php'>My Legacy</a></li>";
echo "<li><a href='/logout.php'>Log Out</a></li>";
echo "</ul>";
echo "</li>";
}
else
{
echo "<li><a href='/createaccount.php'>Create Account</a>";
echo "</li>";
}
if( isset( $user ) && $user != "" )
{
echo "<li><a href='#'>Messages</a>";
echo "<ul>";
echo "<li><a href='/inbox.php'>Inbox</a></li>";
echo "<li><a href='/createmessage.php'>New Message</a></li>";
//echo "<li><a href='/sentitems.php'>Sent Items</a></li>";
//echo "<li><a href='/inbox.aspx?deleted=1'>Deleted Items</a></li>";
//echo "<li><a href='/archive.aspx'>Archived Inbox</a></li>";
//echo "<li><a href='/archivesent.aspx'>Archived Sent Items</a></li>";
echo "</ul>";
echo "</li>";
}
echo "<li><a href='#'>Forums</a>";
echo "<ul>";
echo "<li><a href='/forum.php'>Forums</a></li>";
echo "<li><a href='/forum.php?c=1'>- Community</a></li>";
echo "<li><a href='/viewforum.php?f=25'>+- Competitions</a></li>";
echo "<li><a href='/forum.php?c=7'>- Developers</a></li>";
echo "<li><a href='/forum.php?c=2'>- Mega Drive/Genesis</a></li>";
echo "<li><a href='/forum.php?c=6'>- SNES</a></li>";
echo "<li><a href='/forum.php?c=8'>- Gameboy/GBA</a></li>";
echo "<li><a href='/forum.php?c=9'>- NES</a></li>";
echo "<li><a href='/forum.php?c=10'>- PC Engine</a></li>";
echo "<li><a href='/largechat.php'>Chat/RA Cinema</a></li>";
echo "<li><a href='#' onclick=\"window.open('http://www.retroachievements.org/popoutchat.php', 'chat', 'status=no,height=560,width=340'); return false;\">Pop-out Chat</a></li>";
echo "<li><a href='/forumposthistory.php'>Recent Posts</a></li>";
echo "</ul>";
echo "</li>";
echo "<li><a href='#'>Site Pages</a>";
echo "<ul>";
echo "<li><a href='/popularGames.php'>Popular Games</a></li>";
echo "<li><a href='/gameList.php'>Supported Games</a></li>";
echo "<li><a href='/gameList.php?c=1'>- Mega Drive/Genesis</a></li>";
echo "<li><a href='/gameList.php?c=11'>- Master System</a></li>";
echo "<li><a href='/gameList.php?c=3'>- Super Nintendo</a></li>";
echo "<li><a href='/gameList.php?c=4'>- Gameboy</a></li>";
echo "<li><a href='/gameList.php?c=6'>- Gameboy Color</a></li>";
echo "<li><a href='/gameList.php?c=5'>- Gameboy Advance</a></li>";
echo "<li><a href='/gameList.php?c=7'>- NES</a></li>";
echo "<li><a href='/gameList.php?c=8'>- PC Engine</a></li>";
echo "<li><a href='/gameList.php?c=2'>- N64</a></li>";
echo "<li><a href='/awardedList.php'>Commonly Won Achievements</a></li>";
echo "<li><a href='/gameSearch.php?p=0'>Hardest Achievements</a></li>";
echo "<li><a href='/userList.php'>User List</a></li>";
echo "<li><a href='/achievementList.php'>Achievements List</a></li>";
echo "<li><a href='/leaderboardList.php'>Leaderboards List</a></li>";
echo "<li><a href='/developerstats.php'>Developer Stats</a></li>";
echo "<li><a href='/searchresults.php'>Search the site</a></li>";
echo "<li><a href='https://github.com/RetroAchievements/RASuite'>Source Code (GPL)</a></li>";
echo "<li><a href='/APIDemo.php'>Web API</a></li>";
echo "<li><a href='/rss.php'>RSS Feeds</a></li>";
echo "</ul>";
//echo "</li>";
//echo "<li><a href='/leaderboards.aspx'>Statistics</a>";
//echo "<ul>";
//echo "<li><a href='/siteleaderboards.aspx'>Site Leaderboards</a></li>";
//echo "<li><a href='/userleaderboards.aspx'>User Leaderboards</a></li>";
//echo "</ul>";
echo "</li>";
if( $permissions >= 3 )
{
echo "<li><a href='#'>Developers</a>";
echo "<ul>";
echo "<li><a href='/achievementinspector.php'>Ach. Inspector</a></li>";
echo "<li><a href='/ticketmanager.php'>Ticket Manager</a></li>";
echo "<li><a href='/viewforum.php?f=0'>Invalid Forum Posts</a></li>";
echo "<li><a href='/viewtopic.php?t=394'>Official To-Do List</a></li>";
echo "</ul>";
echo "</li>";
}
if( isset( $user ) && $user != "" )
{
echo "<li><a href='#'>Settings</a>";
echo "<ul>";
echo "<li><a href='/controlpanel.php'>My Settings</a></li>";
//echo "<li><a href='/customizehomepage.php'>My Homepage</a></li>";
//echo "<li><a href='/facebook.php'>Facebook Settings</a></li>";
//echo "<li><a href='/changeemail.php'>Change Email Address</a></li>";
//echo "<li><a href='/changepassword.php'>Change Password</a></li>";
echo "</ul>";
echo "</li>";
}
//echo "<li><a href='/news.aspx'>Useful Links</a>";
//echo "<ul>";
//echo "<li><a href='/gopro.aspx' title='Upgrade to Pro account'>Pro account</a></li>";
//echo "</ul>";
//echo "</li>";
echo "</ul>";
echo "<form action='/searchresults.php' method='get'>";
echo "<div class='searchbox'>";
//echo "Search: ";
echo "<input size='24' name='s' type='text' class='searchboxinput' />";
echo " ";
echo "<input type='submit' value='Search' />";
echo "</div>";
echo "</form>";
echo "</div>";
echo "<div style='clear:both;'></div>"; // Makes it work with mobile browsers :)
}
function RenderFooter()
{
echo "<div style='clear:all;'></div>";
echo "<div id='footer'>";
// Inject fb like onto every page! muhahaha
//echo "<div class='fb-like' style='float:left'></div>";
echo "<div class='footericonset'>";
// W3
echo "<div class='footericon' >";
//echo "<p about='' resource='http://www.w3.org/TR/rdfa-syntax' rel='dc:conformsTo' xmlns:dc='http://purl.org/dc/terms/'>";
echo "<p>";
echo "<a href='http://validator.w3.org/check?uri=referer'><img src='http://www.w3.org/Icons/valid-xhtml-rdfa' alt='Valid XHTML + RDFa' height='31' width='88' /></a>";
echo "</p>";
echo "</div>";
// CC License
echo "<div class='footericon' >";
echo "<p>";
//echo "<span xmlns:dc='http://p0url.org/dc/elements/1.1/' href='http://purl.org/dc/dcmitype/InteractiveResource' property='dc:title' rel='dc:type' />";
echo "<a rel='license' href='http://creativecommons.org/licenses/by-nc-sa/2.0/uk/'><img alt='Creative Commons License' style='border-width:0' src='http://i.creativecommons.org/l/by-nc-sa/2.0/uk/88x31.png' /></a>";
echo "</p>";
echo "</div>";
// My TM
echo "<div class='footertext'>";
echo "<p style='font-size: x-small;'>";
echo "Content by <small><a href='http://www.immensegames.com'>Immense Games</a></small><br/>";
//echo "<small>Last Updated July 2013</small>";
global $g_numQueries;
global $g_pageLoadAt;
$loadDuration = microtime( true ) - $g_pageLoadAt;
echo "Generated from $g_numQueries queries in " . sprintf( '%1.3f', ($loadDuration ) ) . " seconds";
if( $loadDuration > 2.4 )
error_log( CurrentPageURL() . " - took " . sprintf( '%1.3f', $loadDuration ) . " to fetch!" );
echo "</p>";
echo "</div>";
echo "</div>";
echo "</div>";
}
function RenderFBLoginPrompt()
{
//echo "<div id='fb-root'></div><script type='text/javascript'>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = \"//connect.facebook.net/en_GB/all.js#xfbml=1&appId=490904194261313\"; fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script>";
echo "<div class='fb-login-button' scope='publish_stream'>Login with Facebook</div>";
}
function RenderFBLogoutPrompt()
{
global $fbConn;
printf( "<a href='%s'>(logout)</a>", $fbConn->getLogoutUrl() );
//echo "<div id=\"fb-root\"></div><script type='text/javascript'>(function(d, s, id) {var js, fjs = d.getElementsByTagName(s)[0];if (d.getElementById(id)) return; js = d.createElement(s); js.id = id; js.src = \"//connect.facebook.net/en_GB/all.js#xfbml=1&appId=490904194261313\"; fjs.parentNode.insertBefore(js, fjs);}(document, 'script', 'facebook-jssdk'));</script>";
//echo "<div class=\"fb-login-button\" scope=\"publish_stream\">Login with Facebook</div>";
}
function RenderFBDialog( $fbUser, &$fbRealNameOut, &$fbURLOut, $user )
{
$fbRealNameOut = "";
$fbURLOut = "";
try
{
global $fbConn;
global $fbConfig;
//$access_token =
//$access_token = '490904194261313|WGR9vR4fulyLxEufSRH2CJrthHw';
//$attemptLogin = FALSE;
if( $fbUser == 0 )
{
//echo "req. associate!<br/>";
//// Attempt associate?
//$message = "/me/?access_token=$access_token";
//$ret_obj = $fbConn->api($message,'GET');
//if( $ret_obj )
//{
//echo "found 'me'!<br/>";
//$fbID = $ret_obj['id'];
//if( $fbID !== 0 && $fbUser == 0 )
//{
// error_log( __FUNCTION__ . " warning: inconsistency found $fbID $fbUser" );
// echo "inconsistency found $fbID $fbUser<br/>";
// // DB inconsistency: update our records!
// if( associateFB( $user, $fbID ) )
// {
// error_log( __FUNCTION__ . " warning: associated $user, $fbID" );
// echo "associate OK!<br/>";
// $fbUser = $fbID;
// }
// else
// {
// RenderFBLoginPrompt();
// }
//}
//else
//{
// RenderFBLoginPrompt();
//}
//}
//else
//{
RenderFBLoginPrompt();
//}
}
if( $fbUser !== 0 )
{
$message = "/$fbUser/?access_token=" . $fbConfig[ 'appToken' ];
//echo "<br/>DEBUG:<br/>" . $message . "<br/>";
$ret_obj = $fbConn->api( $message, 'GET' );
if( $ret_obj )
{
$fbRealNameOut = $ret_obj[ 'name' ];
$fbURLOut = $ret_obj[ 'link' ];
//print_r( $ret_obj );
return TRUE;
}
}
}
catch( FacebookApiException $e )
{
error_log( "Facebook API Exception " . $e->getType() );
error_log( "Facebook API Exception Msg " . $e->getMessage() );
error_log( __FUNCTION__ . " catch: input $fbUser" );
RenderFBLoginPrompt();
}
return FALSE;
}
function RenderNewsHeader( $newsData )
{
$dataID = $newsData[ 'ID' ];
$title = $newsData[ 'Title' ];
$payload = $newsData[ 'Payload' ];
$image = $newsData[ 'Image' ];
$link = htmlspecialchars( $newsData[ 'Link' ] );
$author = $newsData[ 'Author' ];
$authorLink = GetUserAndTooltipDiv( $author, NULL, NULL, NULL, NULL, FALSE );
$timestampStr = date( "d M", $newsData[ 'TimePosted' ] );
$niceDate = getNiceDate( $newsData[ 'TimePosted' ] );
//if( isset( $link ) )
//else
// echo "<h4>$title</h4>";
$zPos = $dataID;
$zPos2 = $dataID + 10;
echo "<div class='newsbluroverlay'>";
echo "<div>";
//echo "<span id='NEWSIMG_" . $dataID . "' class='newsimage'><img style='position: absolute; right: 0px; top:0px; width: 100%; z-index:$zPos; opacity: 0.4' src='$image' align='right' /></span>";
// BG
echo "<div class='newscontainer' style='background: url(\"$image\") repeat scroll; z-index:$zPos; opacity:0.5; width: 470px; height:222px; background-size: 100% auto;' >";
echo "</div>";
echo "<div class='news' >";
// Title
echo "<h4 style='z-index:$zPos2; position: absolute; width: 460px; top:2px; left:10px; white-space: nowrap;' ><a class='newstitle shadowoutline' href='$link'>$title</a></h4>";
// Text
//echo "<small>[" . $timestampStr . "] </small>";
echo "<div class='newstext shadowoutline' style='z-index:$zPos2; position: absolute; width: 90%; top: 40px; left:10px;'>$payload</div>";
// Author
echo "<div class='newsauthor shadowoutline' style='z-index:$zPos2; position: absolute; width: 470px; top: 196px; left:0px; text-align: right'>~~$authorLink, $niceDate</div>";
echo "</div>";
//echo "<div style='clear:both'></div>";
echo "</div>";
echo "</div>";
}
function RenderCommentsComponent( $user, $numComments, $commentData, $articleID, $articleTypeID, $forceAllowDeleteComments )
{
$userID = getUserIDFromUser( $user );
echo "<div class='commentscomponent'>";
if( $numComments == 0 )
echo "No comments yet. Will you be the first?<br/>";
else
echo "Recent comment(s):<br/>";
echo "<table id='feed'><tbody>";