forked from SimonT-STHS/STHS-DynamicWebsite-Production
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBoxscore.php
98 lines (90 loc) · 4.46 KB
/
Boxscore.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
<?php include "Header.php";
$Title = (string)"";
$TypeText = (string)"True";
$Farm = (boolean)False;
if(isset($_GET['Farm'])){$TypeText = "False";$Farm = True;}
$GameNumber = (integer)0;
$GameYear = (integer)0;
$GameHTML = (string)"";
$YearH1 = (integer)0;
$Playoff = (boolean)False;
$Preseason = (boolean)False;
$AllStar = (boolean)False;
If (file_exists($DatabaseFile) == false){
Goto STHSErrorBoxscore;
}else{try{
$db = new SQLite3($DatabaseFile);
$Query = "Select Name, LeagueYear, PlayOffStarted, PreSeasonSchedule, OutputName from LeagueGeneral";
$LeagueGeneral = $db->querySingle($Query,true);
$LeagueName = $LeagueGeneral['Name'];
$GameYear = $LeagueGeneral['LeagueYear'];
$Query = "Select OutputGameHTMLToSQLiteDatabase, WebsiteURL from LeagueOutputOption";
$LeagueOutputOption = $db->querySingle($Query,true);
if(isset($_GET['Game'])){$GameNumber = (int)filter_var($_GET['Game'], FILTER_SANITIZE_NUMBER_INT);}
if(isset($_GET['Year'])){
$GameYear = filter_var($_GET['Year'], FILTER_SANITIZE_NUMBER_INT);$YearH1=$GameYear;
if(isset($_GET['Playoff'])){$Playoff=True;}
if(isset($_GET['Preseason'])){$Preseason=True;}
}else{
if($LeagueGeneral['PlayOffStarted'] == "True"){$Playoff=True;}
if($LeagueGeneral['PreSeasonSchedule'] == "True"){$Preseason=True;}
}
If ($GameNumber > 0){
If ($LeagueOutputOption['OutputGameHTMLToSQLiteDatabase'] == "True"){
If($Playoff == True){$GameHTMLDatabaseFile = str_replace("-STHSGame","-PLF-STHSGame",$GameHTMLDatabaseFile);}
If($Preseason == True){$GameHTMLDatabaseFile = str_replace("-STHSGame","-PRE-STHSGame",$GameHTMLDatabaseFile);}
$GameDatabaseFile = str_replace("@-@",$GameYear."-".floor($GameNumber/200),$GameHTMLDatabaseFile);
If ($GameNumber == 9999){$GameDatabaseFile = $AllStarDatabaseFile;$GameNumber=0;$AllStar=True;}
If (file_exists($GameDatabaseFile) == false){
If (file_exists($LeagueGeneral['OutputName']."-".$GameNumber.".php") == true AND $Farm = false){
echo "<meta http-equiv=\"refresh\" content=\"0;url=" . $LeagueOutputOption['WebsiteURL'] . "/" . $LeagueGeneral['OutputName'] . "-" .$GameNumber . ".php" . "\"/>";
}elseif(file_exists($LeagueGeneral['OutputName']."-Farm-".$GameNumber.".php") == true AND $Farm = true){
echo "<meta http-equiv=\"refresh\" content=\"0;url=" . $LeagueOutputOption['WebsiteURL'] . "/" . $LeagueGeneral['OutputName'] . "-Farm-" .$GameNumber . ".php". "\"/>";
}else{
echo "<title>" . $DatabaseNotFound . "</title>";
$GameHTML = "<h1>" . $DatabaseNotFound . "</h1>";
}
}else{
$Gamedb = new SQLite3($GameDatabaseFile);
$Query = "Select * from GameResult WHERE Number = '" . $GameNumber . "' AND Pro = '" . $TypeText . "'";
$GameResult = $Gamedb ->querySingle($Query,true);
If ($GameResult != Null){
$GameHTML = gzdecode(base64_decode($GameResult['HTML']));
echo $GameResult['Engine']. "\n";
echo $GameResult['Title'];
}elseif (file_exists($LeagueGeneral['OutputName']."-".$GameNumber.".php") == true AND $Farm = false){
echo "<meta http-equiv=\"refresh\" content=\"0;url=" . $LeagueOutputOption['WebsiteURL'] . "/" . $LeagueGeneral['OutputName'] . "-" .$GameNumber . ".php" . "\"/>";
}elseif (file_exists($LeagueGeneral['OutputName']."-Farm-".$GameNumber.".php") == true AND $Farm = true){
echo "<meta http-equiv=\"refresh\" content=\"0;url=" . $LeagueOutputOption['WebsiteURL'] . "/" . $LeagueGeneral['OutputName'] . "-Farm-" .$GameNumber . ".php". "\"/>";
}else{
echo "<title>" . $IncorrectGameQuery . "</title>";
$GameHTML = "<h1>" . $IncorrectGameQuery . "</h1>";
}
}
}else{
echo "<title>" . $IncorrectGameQuery . "</title>";
$GameHTML = "<h1>" . $IncorrectGameQuery . "</h1>";
}
}else{
echo "<title>" . $IncorrectGameQuery . "</title>";
$GameHTML = "<h1>" . $IncorrectGameQuery . "</h1>";
}
} catch (Exception $e) {
STHSErrorBoxscore:
$LeagueName = $DatabaseNotFound;
echo "<title>" . $DatabaseNotFound . "</title>";
$GameHTML = "<h1>" . $DatabaseNotFound . "</h1>";
}}?>
</head><body>
<?php
include "Menu.php";
if($YearH1 > 0){
If ($lang == "fr"){include 'LanguageFR-Main.php';}else{include 'LanguageEN-Main.php';}
echo "<h1>" . $BoxscoreLang['BoxscorefromYear'] . $YearH1;
If ($Playoff == True){echo $TopMenuLang['Playoff'];}
echo "</h1>";
}elseif($AllStar == True){
echo "<h1>" . $TopMenuLang['AllStar'] . "</h1>";
}
echo($GameHTML);
include "Footer.php";?>