-
Notifications
You must be signed in to change notification settings - Fork 2
/
index.php
1057 lines (962 loc) · 52.8 KB
/
index.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
/////////////////////////////////////////////////////////////////////////////////////
//// Welcome! Below you can find some options to customize the look of the page. ////
/////////////////////////////////////////////////////////////////////////////////////
// You have to get an API key from the OMDb API (it's free, you only have to provide a working email address).
// You can register for an API key here: https://www.omdbapi.com/apikey.aspx and insert it below.
define("API_KEY", "PLACE_YOUR_API_KEY_HERE");
// Change the language of the UI here
define("LANGUAGE", "en");
// The title of the page
define("PAGE_TITLE", "Benflix");
// Default ordering of movies
// Possible values: "title", "added" or "released".
// The date when a file was added to the collection is defined by its file modification time.
// This parameter is currently set to "released" by default.
define("DEFAULT_ORDERING", "released");
// The number of days in the past after which a movie added to the collection is considered "recent".
// If superior to 0, the page will be divided in two blocks:
// - The first block will contain the latest movies added to the collection.
// - The second block will contain all other movies.
// The date when a file was added to the collection is defined by its file modification time.
// This parameter is currently set to 0 by default, meaning the classic display of only one block is used.
define("RECENTLY_ADDED_DAYS", "0");
// The array containing all languages strings
// Feel free to add another subarray for your language
$i18n = Array(
"fr" => Array(
"You need to get an API key for the OMDb API. Don\'t worry, it\'s very simple!\nPlease read the instructions at the top of this file." => "Il vous faut une clé pour accéder à l'API d'OMDb. Pas de panique, c'est très simple !\nMerci de consulter les instructions dans les premières lignes de ce fichier.",
"Benflix needs JavaScript enabled to work." => "Benflix a besoin que JavaScript soit activé.",
"Go to the IMDb page" => "Voir la fiche sur IMDb",
"Watch the trailer on YouTube" => "Voir la bande-annonce",
"Download the movie" => "Télécharger le film",
"You can stream the movie by copying the link of the \"Download\" button,<br />opening VLC, pressing Ctrl+V, and then clicking \"Play\"." => "Lisez le film en streaming en copiant le lien du bouton \"Télécharger\",<br />en appuyant sur Ctrl+V dans VLC puis sur \"Lire\".",
"Genre:" => "Genre :",
"Plot:" => "Synopsis :",
"Runtime:" => "Durée :",
"Directed by:" => "Réalisé par :",
"With:" => "Avec :",
"IMDB rating:" => "Note IMDb :",
"Search for a movie..." => "Chercher un film...",
"No movie matches criteria" => "Aucun film correspondant",
"Deactivate some filters" => "Désactivez certains filtres",
"By" => "Par",
"Bugs? Ideas? Tell me more on" => "Bugs ? Idées ? Faites-m'en part sur",
"The project page on Github" => "La page du projet sur Github",
"Close" => "Fermer",
"All" => "Tous",
"Search for a movie" => "Rechercher un film (titre VO)",
"Filter by IMDb score" => "Filtrer par note IMDb",
"Filter by movie length" => "Filtrer par durée",
"Filter by category" => "Filtrer par catégorie",
"About this app" => "À propos de Benflix",
"Close this modal" => "Afficher les résultats",
"Search" => "Rechercher",
"Order by..." => "Trier par...",
"Alphabetical" => "Alphabétique",
"Date added" => "Ajouts",
"Date released" => "Diffusion",
"Runtime" => "Durée",
"IMDb rating" => "Note IMDb",
"Genre" => "Genre",
"Recently added" => "Ajoutés récemment",
"All movies" => "Tous les films",
)
);
// The path to the local database file
define("LOCAL_DB_FILE", dirname(__FILE__).'/benflix.json');
// Careful: if set to true, anyone can request the local database file to be purged and rebuilt with a simple web request.
// This can cause disturbance for the users, as well as pointlessly take up the server and the API bandwith and resources.
define("ALLOW_PURGE_FROM_WEB", false);
/////////////////////////////////////////////////////////////////////
//// STOP! You shouldn't need to edit anything below this point. ////
/////////////////////////////////////////////////////////////////////
// Returns the translated string if it exists (or the English string otherwise)
function translate($string){
global $i18n;
if(isset($i18n[LANGUAGE]) && isset($i18n[LANGUAGE][$string])){
return $i18n[LANGUAGE][$string];
}
else {
return $string;
}
}
// Converts an array in UTF-8
function utf8ize($mixed) {
if (is_array($mixed)) {
foreach ($mixed as $key => $value) {
$mixed[$key] = utf8ize($value);
}
} else if (is_string ($mixed)) {
return utf8_encode($mixed);
}
return $mixed;
}
// Use cURL to retrieve URL content
function get_url_contents($url) {
$crl = curl_init();
curl_setopt($crl, CURLOPT_URL, $url);
curl_setopt($crl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($crl, CURLOPT_CONNECTTIMEOUT, 5);
$ret = curl_exec($crl);
curl_close($crl);
return $ret;
}
// Handle Ajax calls
if(!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' && !empty($_POST['action'])){
switch($_POST['action']){
case 'getAvailableMovies':
die(json_encode(utf8ize(get_video_files())));
break;
case 'getMovieInfo':
die(get_movie_info($_POST['movieName']));
break;
case 'getServerDatabase':
die(get_local_database());
break;
default:
// Do nothing
break;
}
}
// Update the local database ($argv is for use in CLI mode)
if(!empty($_GET['updateLocalDatabase']) || (!empty($argv[1]) && ($argv[1] == 'updateLocalDatabase'))){
$verbose = ((!empty($_GET['verbose'])) || (in_array('verbose', $argv)));
$purge = ((!empty($_GET['purge'])) || (in_array('purge', $argv)));
$cliRun = defined('STDIN');
if($cliRun){$separator = "\n";}else{$separator = '<br />';}
if($cliRun){$newLine = $separator."----------".$separator;}else{$newLine = '<hr />';}
// Test if the database exists and can be overwritten
if(!test_file_environment($verbose)){
exit;
}
else{
if($purge){
if($cliRun || ALLOW_PURGE_FROM_WEB){
file_put_contents(LOCAL_DB_FILE, '');
}
else{
if($verbose){echo $separator.'Purge of the database file can only be done from CLI for security reasons.<br />';}
if($verbose){echo 'To allow purge from the web, set the ALLOW_PURGE_FROM_WEB constant to true at the beginning of this file.';}
}
}
if($verbose){echo $newLine;}
}
$files = get_video_files();
$movies = 0;
$newMovies = 0;
foreach($files as $file){
$movies++;
$fileName = $file['name'];
if($verbose){echo 'Dealing with file '.$fileName.'...'.$separator;}
$movieName = substr($fileName, 0, strrpos($fileName, "."));
if(!is_movie_in_database($fileName)){
if($verbose){echo 'Movie not found in the local database, querying the OMDb API.'.$separator;}
$movieInfo = get_movie_info($movieName);
if(json_decode($movieInfo,true)['Response'] == 'True'){
if($verbose){echo 'Found info from the API, now saving data to the local database.';}
$newMovies++;
$result = save_movie_info($file['name'], $movieInfo);
if(!$result && $verbose){echo $separator.'Oops, saving this movie\'s info went wrong. Can\'t write to the database file ('.LOCAL_DB_FILE.') maybe?'.$separator;}
if(!$result && $verbose){echo 'Quitting for now, solve the situation before running again.'; exit;}
}
else{
if($verbose){echo '<span color="orange">Couldn\'t get the movie info for this movie.';}
}
}
else{
if($verbose){echo 'Movie already exists in the database, skipping.';}
}
if($verbose){echo $newLine;}
}
if($verbose){echo 'Database was updated and now contains '.$movies.' movies.';}
if($verbose && ($newMovies == 1)){echo ' One new movie was added.';}
if($verbose && ($newMovies > 1)){echo ' '.$newMovies.' new movies were added.';}
if($verbose && $cliRun){echo $separator;}
exit;
}
function get_video_files(){
// Depending on the setting, list files by name or file modification time
if(DEFAULT_ORDERING == 'title'){
$sortFunction = 'scandir';
}
else{
$sortFunction = 'filemtime';
}
$allFiles = glob(dirname(__FILE__).'/*', GLOB_BRACE);
array_multisort(array_map($sortFunction, $allFiles), SORT_DESC, $allFiles);
// Format and return a proper array
$files = Array();
foreach($allFiles as $file){
if((strpos($file, '.php') === False) && (strpos($file, '.json') === False)){
$files[] = Array('name' => basename($file), 'time' => filemtime($file));
}
}
return $files;
}
function get_movie_info($movieName){
// This movie requires to be written with a / so the API can recognize it
// Of course the filename can't have a / in it...
if($movieName == '50-50'){
$movieName = '50/50';
}
// When the year is specified between parenthesis in the filename, perform a search with the year
if(preg_match('/(.+)\s\((\d+)\)/', $movieName, $matches)){
$movieNameEncoded = rawurlencode($matches[1]);
$movieInfo = get_url_contents('https://www.omdbapi.com/?apikey='.API_KEY.'&t='.$movieNameEncoded.'&y='.$matches[2].'&r=json');
}
else {
$movieNameEncoded = rawurlencode($movieName);
$movieInfo = get_url_contents('https://www.omdbapi.com/?apikey='.API_KEY.'&t='.$movieNameEncoded.'&r=json');
}
return $movieInfo;
}
function save_movie_info($fileName, $movieInfo){
// Load the local database
$jsonDb = file_get_contents(LOCAL_DB_FILE);
if($jsonDb){
// Save data to the local database
$arrayDb = json_decode($jsonDb, true);
$arrayDb[$fileName] = filter_movie_properties($movieInfo);
}
else{
// The movie is the first to be added to the local database
$arrayDb = Array($fileName => filter_movie_properties($movieInfo));
}
return file_put_contents(LOCAL_DB_FILE, json_encode($arrayDb));
}
function is_movie_in_database($fileName){
$jsonDb = file_get_contents(LOCAL_DB_FILE);
$exists = false;
if($jsonDb){
$arrayDb = json_decode($jsonDb, true);
if(array_key_exists($fileName, $arrayDb)){
$exists = true;
}
}
return $exists;
}
function test_file_environment($verbose){
$result = true;
if(file_exists(LOCAL_DB_FILE)){
if(is_writable(LOCAL_DB_FILE)){
if($verbose){echo 'Database file exists and can be overwritten, proceeding.';}
}
else{
if($verbose){echo 'Database file exists but cannot be overwritten, exiting.';}
$result = false;
}
}
else {
if(touch(LOCAL_DB_FILE)){
if($verbose){echo 'Database file did not exist and was created, proceeding.';}
}
else{
if($verbose){echo 'Database file does not exist and cannot be created, exiting.';}
$result = false;
}
}
return $result;
}
function is_database_operationnal(){
return (bool)file_get_contents(LOCAL_DB_FILE);
}
function get_local_database(){
return file_get_contents(LOCAL_DB_FILE);
}
function filter_movie_properties($jsonMovieInfo){
$movieInfo = json_decode($jsonMovieInfo);
$propertiesToRemove = Array('Rated', 'Writer', 'Language', 'Country', 'Awards', 'Ratings', 'Metascore', 'imdbVotes', 'Type', 'DVD', 'BoxOffice', 'Production', 'Website', 'Response');
foreach($propertiesToRemove as $property){
unset($movieInfo->$property);
}
return $movieInfo;
}
// The logo is in base64 so that the file is not dependant on anything
define('BENFLIX_LOGO', 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAIwAAAAyCAQAAAAkCfuwAAASDUlEQVRo3rWbd3Rc1Z3HP69ML5JGxSpWl9wrtgGDARNIXMjJmrZpm4SQTUggsOkJkOTkpGxom4RiUjZZkoWEJGQ5sARTAgYbG9yxJVkuskG2+ozaNE197+0f82b0ZjSSJVv78zl+M3ee77v3e+/v+/v9vvdZWPzBwbUDcVRSJlfG5x8YfXMOlTwBbCTKZlbhQwDK2Xb5/Zu0AAaTrA2jyx8xE2WQDVzHKBJ27v3My/WM6be45x269NnWlZ03jgQA29qh6x47jJkTxPkcIVSKaLvsic3xrH6RmqR1DxcEFyITIYQEeNh+3Z/WEgCs6/yfetiECR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yGQWQeH+dfWG7KRs0Sqb6MSBPda8ZkHO24MO5h5Y+vX1F9sjQQQ0PeGWGMU0uGZl2aGJA6s33cktfJ4t2IkQou75mmtcGWl/T6PlicJncmIuKsUcppUifMwZuWxV4SEDbEI6/wizWxc+JMLIx8tXlnTn2VsmO83sZB8ynt0rLvIM5YbCg4TQGGDLgxu/MP7vyk+8y1keXTs/4zdnVry1RL6ICI0sG3v5nuPXGvjKMte/8pXobhjDpf8XqZTHCyS4csx6z/YbctitoOK1mziLgIUXGEPDS/V2yz3BRoIIOBPewyR/wBAhnePcvJNCZ4h+rEj0syg6cveuGwgANnxpjtWw0Y1fFzZjWNnc2XL34BU5z3cJLXZkYgxQi8yHWl+5Z/giAkBB+uAjgI9KVJIo/0k9TqKAW90VwMd6dfW9J7bgB5x9XX2B/wO1CEJ51zFvzwAAAABJRU5ErkJggg==');
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><?php echo PAGE_TITLE; ?></title>
<meta name=viewport content="width=device-width, initial-scale=1, user-scalable=no">
<meta name="author" lang="fr" content="benji1000">
<link href="//maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" rel="stylesheet">
<script src="//code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="icon" href="data:image/x-icon;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAyklEQVQ4jcWSyw2DMBBEX6IUQAURJVBBBB1QQT6XaQNRAfc9pgI6gFQASgVRKqCEHDCR5UTAjZFWXq/X4/FoYWvswoKkK3AJygPwAGoze/kH+z+kRyANIgcqoJMULxFM6IHMReFqEXD2mw4zBIOZtS5vJd2AOGyaI4gkpS4/eZefawkSoPEVAZWZ1X7TnAcD0Lp4Mf6/lJSvVdCbWTZtJHVOVQF8Vcwp+CF0a7JWgW9izDgL+K8vEYQmwuhLuUTwZjQuRAPcw1HeHh8kSTJnDU8pPQAAAABJRU5ErkJggg=="/>
<style>
/* GLOBAL STYLES */
body {
background-color: #171717;
}
/* SPINNER */
.spinner {
margin-top: 9px;
width: 70px;
text-align: center;
}
.spinner > div {
width: 18px;
height: 18px;
background-color: #7D7D7D;
border-radius: 100%;
display: inline-block;
-webkit-animation: sk-bouncedelay 1.4s infinite ease-in-out both;
animation: sk-bouncedelay 1.4s infinite ease-in-out both;
}
.spinner .bounce1 {
-webkit-animation-delay: -0.32s;
animation-delay: -0.32s;
}
.spinner .bounce2 {
-webkit-animation-delay: -0.16s;
animation-delay: -0.16s;
}
@-webkit-keyframes sk-bouncedelay {
0%, 80%, 100% { -webkit-transform: scale(0) }
40% { -webkit-transform: scale(1.0) }
}
@keyframes sk-bouncedelay {
0%, 80%, 100% {
-webkit-transform: scale(0);
transform: scale(0);
} 40% {
-webkit-transform: scale(1.0);
transform: scale(1.0);
}
}
/* MOVIE LIST */
#wall {
width: 100%;
text-align: center;
padding: 60px 15px 30px 15px;
}
body h2:first-of-type{
margin-top: 10px;
}
#wall > div > h2 {
font-size: 26px;
color: #555;
text-align: left;
display: flex;
align-items: center;
margin: 5px 15px;
}
#wall > div > h2::after {
content: '';
flex: 1;
margin-left: 1rem;
height: 1px;
background-color: #555;
}
#wall > div > h2 > span {
font-size: 24px;
margin-right: 10px;
margin-bottom: 5px;
}
#nothing {
display: none;
}
.big-error-message {
font-size: 72px;
position: absolute;
top: 40%;
text-align: center;
left: 0;
right: 0;
}
.error-message-subtext{
font-size: 35px;
}
.img-thumbnail {
height: 300px;
width: 210px;
transition: all 0.5s ease;
opacity: 0.8;
margin: 6px;
padding: 1px;
}
.img-thumbnail:hover {
opacity: 1;
cursor: pointer;
transform: scale(1.07);
}
/* MOVIE MODAL */
.modal-body > .container {
max-width: 100%;
}
#extended-infos > p > .btn {
width: 340px;
max-width: 100%;
}
.modal {
text-align: left;
}
.col-md-4 > img {
max-width: 100%;
}
#extended-infos {
text-align: center;
}
#extended-infos p{
padding-top: 20px;
}
@media (min-width: 992px){
.col-md-5 {
width: 38%;
}
}
/* SEARCH MODAL */
#search-modal p {
margin-top: 10px;
text-align: center;
margin-bottom: 0;
}#search-modal h1 {
font-size: 18px;
text-align: center;
margin-top: 0;
margin-bottom: 15px;
}
#search-modal .form-group {
margin-bottom: 0;
}
/* ABOUT MODAL */
#about-modal .modal-body {
text-align: center;
margin-top: 20px;
}
#about-modal .modal-footer img {
float: left;
}
/* TOP NAVBAR */
.nav-bar {
margin-right: auto;
margin-left: auto;
padding: 5px 30px;
width: 100%;
top: 0;
position: fixed;
z-index: 8;
background: #1d1d1d;
font-size: 1.3em;
color: #7d7d7d;
border-bottom: 1px solid #2f2f2f;
backface-visibility: hidden;
height: 50px;
}
.nav-logo img {
margin-top: 5px;
margin-right: 20px;
height: 30px;
}
#about-div {
display: inline-block;
}
#about-div .btn {
width: 22px;
}
.buttons-topbar {
margin-left: 10px;
margin-top: 9px;
}
.glyphicon-search {
padding: 3px 6px;
}
.dropdown-menu {
z-index: 9999;
min-width: 0px !important;
width: 130px;
}
.dropdown-menu > li > a > strong {
font-variant: all-small-caps;
font-size: 16px;
}
@media (max-width: 725px){
.big-screens {
display: none;
}
.btn-group-xs > .btn, .btn-xs {
padding: 5px 10px;
font-size: 14px;
}
.buttons-topbar {
margin-top: 3px;
}
.nav-bar {
padding: 5px 10px;
}
#extended-infos p {
padding-top: 10px;
}
#extended-infos .btn-lg {
padding: 5px 10px;
font-size: 16px;
}
}
@media (max-width: 992px){
.img-thumbnail {
height: 140px;
width: 95px;
transition: all 0.5s ease;
opacity: 0.8;
margin: 3px;
padding: 1px;
}
#modal-poster {
display: none;
}
h2 {
font-size: 20px;
}
h2 > span {
font-size: 18px;
}
#wall > div > h2 {
font-size: 18px;
}
#wall > div > h2 > span {
font-size: 16px;
margin-right: 5px;
margin-bottom: 3px;
}
}
</style>
<script>
var genresAvailable = new Array();
function insertMovieInPage(fileName, movieInfo, movieId){
var recentlyAddedNumberOfDays = "<?php echo RECENTLY_ADDED_DAYS; ?>";
// Showcase the most recently added movies
if(parseInt(recentlyAddedNumberOfDays) > 0){
var dateAdded = new Date(changeTime*1000);
var recentMoviesDate = new Date();
recentMoviesDate.setDate(recentMoviesDate.getDate()-parseInt(recentlyAddedNumberOfDays));
if(dateAdded > recentMoviesDate){
var container = $('#recentMovieList');
if($('#recentMovieList > img.img-thumbnail').length == 0){
$('#recentMovieList').prepend('<h2><span class="glyphicon glyphicon-pushpin" aria-hidden="true"></span> <?php echo translate('Recently added'); ?></h2>');
$("#recentMovieList h2").hide().fadeIn();
}
}
else {
var container = $('#movieList');
if($('#movieList > img.img-thumbnail').length == 0){
$('#movieList').prepend('<h2><span class="glyphicon glyphicon-film" aria-hidden="true"></span> <?php echo translate('All movies'); ?></h2>');
$("#movieList h2").hide().fadeIn();
}
}
}
else{
var container = $('#movieList');
}
// Populate the array of available genres
var genres = movieInfo.Genre.split(', ');
genres.forEach(function(genre){
if(genresAvailable.indexOf(genre) < 0){
genresAvailable.push(genre)
}
});
// Insert the movie info in the page
container.append('<img class="img-thumbnail poster" src="'+movieInfo.Poster+'" data-id="movie-'+movieId+'" data-title="'+movieInfo.Title+'" data-file="'+fileName+'" data-plot="'+movieInfo.Plot+'" data-actors="'+movieInfo.Actors+'" data-director="'+movieInfo.Director+'" data-year="'+movieInfo.Year+'" data-released="'+new Date(movieInfo.Released)+'" data-added="'+dateAdded+'" data-runtime="'+parseInt(movieInfo.Runtime)+'" data-title="'+movieInfo.Title+'" data-genre="'+movieInfo.Genre+'" data-imdbid="'+movieInfo.imdbID+'" data-imdbrating="'+movieInfo.imdbRating+'" data-toggle="modal" data-target="#modal" alt="" />');
}
function getMovieInfo(fileName, changeTime, id, serverDatabase){
if(Object.keys(serverDatabase).includes(fileName)){
// The movie exists in the database, no need to query the API
var movieInfo = serverDatabase[fileName];
insertMovieInPage(fileName, movieInfo, id);
}
else {
// The movie does not exist in the database, an API query is necessary
$.ajax({
url : '<?php echo basename($_SERVER["PHP_SELF"]); ?>',
type : 'POST',
data : 'action=getMovieInfo&movieName='+encodeURIComponent(fileName.replace(/\.[^/.]+$/, "")),
dataType: 'json',
success: function(movieInfo){
if(movieInfo.Response == 'True'){
insertMovieInPage(fileName, movieInfo, id);
}
else {
console.log("Couldn't get the movie info for file: " + fileName);
}
},
error : function(result, status, error){
console.log("Couldn't get the movie info for file: " + fileName);
}
});
}
}
function search(searchString){
var movies = document.getElementsByClassName('img-thumbnail');
var found = 0;
for(var i = 0; i < movies.length; i++){
if(movies.item(i).dataset.title.toLowerCase().search(searchString.trim()) < 0){
$('.img-thumbnail[data-title="'+movies.item(i).dataset.title+'"]').fadeOut();
}
else {
$('.img-thumbnail[data-title="'+movies.item(i).dataset.title+'"]').fadeIn();
found += 1;
}
}
// If no movie matches the criteria, display a warning
if(found == 0){
$('#nothing').show();
}
else {
$('#nothing').hide();
}
}
function calculatePosterWidth(){
var windowWidth = window.innerWidth;
if(windowWidth < 992){
var numberOfPostersPerLine = 4;
}
else if(windowWidth < 1200){
var numberOfPostersPerLine = 8;
}
else{
var numberOfPostersPerLine = 10;
}
var wallWidth = $('#wall').width();
var posterSeparatorWidth = parseInt($('.img-thumbnail').css('marginLeft'))+parseInt($('.img-thumbnail').css('paddingLeft'));
var wallMargins = parseInt($('#wall').css('paddingLeft'))+parseInt($('#wall').css('paddingRight'));
var posterCalculatedWidth = (wallWidth-wallMargins)/numberOfPostersPerLine - 2*posterSeparatorWidth;
var posterCalculatedHeight = posterCalculatedWidth*1.43;
$('.img-thumbnail').css('width', posterCalculatedWidth+'px');
$('.img-thumbnail').css('height', posterCalculatedHeight+'px');
}
function getServerDatabase(){
return $.ajax({
url : '<?php echo basename($_SERVER["PHP_SELF"]); ?>',
type : 'POST',
data : 'action=getServerDatabase',
dataType: 'json'
});
}
$(window).on('load resize', function(){
calculatePosterWidth();
});
$(window).load(function() {
// Check that the user has an API key
if(("<?php echo API_KEY; ?>" == 'PLACE_YOUR_API_KEY_HERE') || ("<?php echo API_KEY; ?>" == '')){
alert("<?php echo translate('You need to get an API key for the OMDb API. Don\'t worry, it\'s very simple!\nPlease read the instructions at the top of this file.'); ?>");
}
else {
// Check if the database is operationnal
var serverDatabase = false;
if("<?php echo is_database_operationnal(); ?>" == 1){
console.log('Using server database.');
getServerDatabase().then(response => {
serverDatabase = response;
});
}
// Get the movies available and iterate over them
$.ajax({
url : '<?php echo basename($_SERVER["PHP_SELF"]); ?>',
type : 'POST',
data : 'action=getAvailableMovies',
dataType: 'json',
success : function(fileList, status){
var id = 0;
fileList.forEach(function(file){
getMovieInfo(file.name, file.time, id, serverDatabase);
id++;
});
},
error : function(result, status, error){
console.log("Couldn't get the list of available movies.");
}
});
}
// Handle a click on a poster
$("#wall").on('click', '.poster', function(e){
$("#modal-title").html($(this).data('title') + ' <small>' + $(this).data('year') + '</small>');
$("#modal-poster").html('<img src="' + $(this).attr('src') + '" alt="" />');
$("#modal-genre").text($(this).data('genre'));
$("#modal-plot").text($(this).data('plot'));
$("#modal-director").text($(this).data('director'));
$("#modal-actors").text($(this).data('actors'));
$("#modal-imdbLink").attr('href', 'http://www.imdb.com/title/'+$(this).data('imdbid'));
$("#modal-trailerLink").attr('href', 'https://www.youtube.com/results?search_query=' + encodeURI($(this).data('title')) + ' trailer vost');
$("#modal-fileLink").attr('href', window.location.href.substring(0, window.location.href.lastIndexOf("/"))+"/"+$(this).data('file'));
// Display the rating in a Bootstrap label
var htmlRating = '';
if($(this).data('imdbrating') >= 7.5){
htmlRating = '<span class="label label-success">' + $(this).data('imdbrating') + '</span>';
}
else if($(this).data('imdbrating') >= 5){
htmlRating = '<span class="label label-warning">' + $(this).data('imdbrating') + '</span>';
}
else {
htmlRating = '<span class="label label-danger">' + $(this).data('imdbrating') + '</span>';
}
$("#modal-rating").html(htmlRating);
// Display the runtime in (lazy) human-readable format
var runtime = $(this).data('runtime');
var hours = Math.floor(runtime/60);
var minutes = Math.floor(runtime%60/10)*10;
$("#modal-runtime").text(hours + 'h' + ("0" + minutes).slice(-2));
});
// Enable search when pressing Ctrl+F
$(document).keydown(function(e){
if(e.keyCode == 70 && e.ctrlKey){
$('.modal').not('#search-modal').modal('hide');
$('#search-modal').modal('toggle');
event.preventDefault();
return false;
}
});
// Reset the search field when the modal is shown
$('#search-modal').on('show.bs.modal', function(e){
$('#search-input').val('');
search('');
});
$('#search-modal').on('shown.bs.modal', function(e){
$('#search-input').focus();
});
// Handle the search field
$('#search-input').on('keyup',function(){
search($(this).val().toLowerCase());
});
// Handle a filter button
$('.buttons-topbar').on('click','.dropdown-menu li a',function(){
//Adds active class to selected item
$(this).parents('.dropdown-menu').find('li').removeClass('active');
$(this).parent('li').addClass('active');
// Handle the styling of a filter button
var text = $(this).text();
var value = $(this).data('value');
var button = $(this).parents('.btn-group');
var id = button.attr('id');
var icon = '';
switch(id) {
case 'order-selector':
icon = '<span class="glyphicon glyphicon-sort-by-attributes-alt" aria-hidden="true"></span>';
defaultText = '<?php echo translate('Order by...'); ?>';
break;
case 'runtime-selector':
icon = '<span class="glyphicon glyphicon-time" aria-hidden="true"></span>';
defaultText = '<?php echo translate('Runtime'); ?>';
break;
case 'imdb-selector':
icon = '<span class="glyphicon glyphicon-star" aria-hidden="true"></span>';
defaultText = 'IMDb';
break;
case 'genre-selector':
icon = '<span class="glyphicon glyphicon-th" aria-hidden="true"></span>';
defaultText = 'Genre';
break;
}
if((value == '*') || (value == 'title')){
button.find('.dropdown-toggle').html(icon + ' ' + defaultText + ' <span class="caret"></span>').removeClass('btn-warning');
}
else {
button.find('.dropdown-toggle').html(icon + ' ' + text + ' <span class="caret"></span>').addClass('btn-warning');
}
button.data('value', value);
// Get the values of ALL dropdowns
var runtime = $('#runtime-selector').data('value');
var imdb = $('#imdb-selector').data('value');
var genre = $('#genre-selector').data('value');
var order = $('#order-selector').data('value');
// Hide all movies then pick only relevant ones
function hideAndPick(container){
var showed = 0;
var movies = new Array();
$('#'+container+' > .img-thumbnail').each(function(i, img){
$(img).hide();
if(
((runtime == '*') || ($(img).data('runtime') <= runtime))
&& ((imdb == '*') || ($(img).data('imdbrating') >= imdb))
&& ((genre == '*') || ($(img).data('genre').indexOf(genre) >= 0))
){
movies.push({characteristic:$(img).data(order),id:$(img).data('id')});
showed++;
}
});
// Order relevant movies according to what the user asked
if(order == 'title'){
movies.sort(function(a,b){
if (a.characteristic < b.characteristic){
return -1;
}
if (a.characteristic > b.characteristic){
return 1;
}
return 0;
});
}
else {
movies.sort(function(a,b) {
return new Date(b.characteristic).getTime() - new Date(a.characteristic).getTime();
});
}
// Show relevant movies according to what the user asked
movies.forEach(function(movie){
var img = $('#'+container+' > .img-thumbnail[data-id='+movie.id+']');
$('#'+container).append(img);
img.show();
});
// If no movie matches the criteria, display a warning
if(showed == 0){
$('#nothing').show();
}
else {
$('#nothing').hide();
}
}
$('#wall > .row').each(function(){
hideAndPick(this.id);
});
});
});
$(document).ajaxStop(function () {
// Populate the genres selector
genresAvailable.sort().forEach(function(genre){
$('#genre-selector').find('ul').append($('<li>').append($('<a>').attr('href','#').attr('title', '').attr('data-value', genre).text(genre)));
});
// Movies default ordering
$('.dropdown-menu > li > a[data-value="<?php echo DEFAULT_ORDERING; ?>"]').trigger('click');
// Hide the spinner and show the filters
$('.spinner').fadeOut('slow', function(){
$('#controls').fadeIn('fast');
});
// Hide the movie list header if there are no recently added movies
if($('#recentMovieList .img-thumbnail').length == 0){
$('#movieList h2').fadeOut();
}
// Determine the appropriate width of a movie poster
calculatePosterWidth();
});
</script>
</head>
<body>
<header class="nav-bar">
<div class="nav-logo pull-left">
<img src="<?php echo BENFLIX_LOGO; ?>" alt="Benflix"/>
</div>
<div class="pull-right">
<div class="spinner">
<div class="bounce1"></div>
<div class="bounce2"></div>
<div class="bounce3"></div>
</div>
<div id="controls" style="display: none">
<button type="button" class="btn btn-default buttons-topbar btn-xs btn-success" data-toggle="modal" data-target="#search-modal" title="<?php echo translate('Search for a movie'); ?>"><span class="glyphicon glyphicon-search" aria-hidden="true"></span></button>
<div id="order-selector" class="btn-group buttons-topbar" data-value="title">
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="<?php echo translate('Order by...'); ?>"><span class="glyphicon glyphicon-sort-by-attributes-alt" aria-hidden="true"></span> <?php echo translate('Order by...'); ?> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li class="active"><a href="#" title="" data-value="title"><?php echo translate('Alphabetical'); ?></a></li>
<li><a href="#" title="" data-value="added"><?php echo translate('Date added'); ?></a></li>
<li><a href="#" title="" data-value="released"><?php echo translate('Date released'); ?></a></li>
</ul>
</div>
<div id="runtime-selector" class="btn-group buttons-topbar big-screens" data-value="*">
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="<?php echo translate('Filter by movie length'); ?>"><span class="glyphicon glyphicon-time" aria-hidden="true"></span> <?php echo translate('Runtime'); ?> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li class="active"><a href="#" title="" data-value="*"><strong><strong><?php echo translate('All'); ?></strong></strong></a></li>
<li><a href="#" title="" data-value="90">< 1h30</a></li>
<li><a href="#" title="" data-value="120">< 2h</a></li>
<li><a href="#" title="" data-value="180">< 3h</a></li>
</ul>
</div>
<div id="imdb-selector" class="btn-group buttons-topbar big-screens" data-value="*">
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="<?php echo translate('Filter by IMDb score'); ?>"><span class="glyphicon glyphicon-star" aria-hidden="true"></span> <?php echo translate('IMDb rating'); ?> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li class="active"><a href="#" title="" data-value="*"><strong><?php echo translate('All'); ?></strong></a></li>
<li><a href="#" title="" data-value="9">IMDb > 9</a></li>
<li><a href="#" title="" data-value="8">IMDb > 8</a></li>
<li><a href="#" title="" data-value="7">IMDb > 7</a></li>
<li><a href="#" title="" data-value="6">IMDb > 6</a></li>
<li><a href="#" title="" data-value="5">IMDb > 5</a></li>
</ul>
</div>
<div id="genre-selector" class="btn-group buttons-topbar big-screens" data-value="*">
<button type="button" class="btn btn-default dropdown-toggle btn-xs" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" title="<?php echo translate('Filter by category'); ?>"><span class="glyphicon glyphicon-th" aria-hidden="true"></span> <?php echo translate('Genre'); ?> <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right">
<li class="active"><a href="#" title="" data-value="*" selected><strong><strong><?php echo translate('All'); ?></strong></strong></a></li>
</ul>
</div>
<button type="button" class="btn btn-default buttons-topbar big-screens btn-xs btn-info" data-toggle="modal" data-target="#about-modal" title="<?php echo translate('About this app'); ?>"><strong>?</strong></button>
</div>
</div>
</header>
<div class="container" id="wall">
<!-- Modal which displays the details of a movie -->
<div class="modal fade" id="modal" tabindex="-1" role="dialog" aria-labelledby="modal" aria-hidden="true">
<div class="modal-dialog modal-lg">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">×</span></button>
<h4 class="modal-title" id="modal-title"><span class="glyphicon glyphicon-film" aria-hidden="true"></span></h4>
</div>
<div class="modal-body">
<div class="container">
<div class="row">
<div class="col-md-5">
<span id="modal-poster"></span>
</div>
<div class="col-md-7">
<p><strong><?php echo translate('Genre:'); ?></strong> <span id="modal-genre"></span><br />
<strong><?php echo translate('Runtime:'); ?></strong> <span id="modal-runtime"></span></p>
<p><strong><?php echo translate('Plot:'); ?></strong> <span id="modal-plot"></span></p>
<p><strong><?php echo translate('Directed by:'); ?></strong> <span id="modal-director"></span><br />
<strong><?php echo translate('With:'); ?></strong> <span id="modal-actors"></span><br />
<strong><?php echo translate('IMDB rating:'); ?></strong> <span id="modal-rating"></span></p>
<div id="extended-infos">
<p><a id="modal-imdbLink" href="" title="<?php echo translate('Go to the IMDb page'); ?>" target="_blank" type="button" class="btn btn-warning btn-lg"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span> <?php echo translate('Go to the IMDb page'); ?></a></p>
<p><a id="modal-trailerLink" href="" title="<?php echo translate('Watch the trailer on YouTube'); ?>" target="_blank" type="button" class="btn btn-danger btn-lg"><span class="glyphicon glyphicon-new-window" aria-hidden="true"></span> <?php echo translate('Watch the trailer on YouTube'); ?></a></p>