-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathview.php
More file actions
215 lines (193 loc) · 7.2 KB
/
view.php
File metadata and controls
215 lines (193 loc) · 7.2 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
<?php
include_once "./utils/no-warning.php";
include_once "./utils/opening.php";
require_once "./utils/db.php";
$opening = new Opening(
0,
"Titolo qui",
"Nome episodio qui",
"Contenuto qui",
"it",
null, new DateTime(), null);
if (isset($_GET["id"]) && ctype_digit($_GET["id"]))
{
$opening = Opening::Load($db, (int)$_GET["id"]);
if (!isset($opening))
{
throw new Exception("Risorsa non trovata", 404);
}
} elseif (isset($_GET["original"]) && ctype_digit($_GET["original"]))
{
$original = (int)$_GET["original"];
if ($original < 1 || $original > 9)
{
throw new Exception("Risorsa non trovata", 404);
}
$lang = OpeningLanguage::Italian;
if (!isEmpty($_GET["lang"]) && is_string($_GET["lang"]))
{
$lang = Opening::StringToLanguage($_GET["lang"]);
}
$opening = Opening::LoadOriginal($original, $lang);
} else {
if (!isEmpty($_GET["title"]) && is_string($_GET["title"]))
{
$opening->Title = $_GET["title"];
}
if (!isEmpty($_GET["episode"]) && is_string($_GET["episode"]))
{
$opening->Episode = $_GET["episode"];
}
if (!isEmpty($_GET["content"]) && is_string($_GET["content"]))
{
$opening->Content = $_GET["content"];
}
if (!isEmpty($_GET["lang"]) && is_string($_GET["lang"]))
{
$opening->Language = Opening::StringToLanguage($_GET["lang"]);
}
}
$opening->Title = htmlspecialchars($opening->Title);
$opening->Episode = htmlspecialchars($opening->Episode);
$MAX_STARS = 100;
$TITLE = "$opening->Episode - $opening->Title";
$DESCRIPTION = "Guarda l'opening personalizzata di Star Wars";
if (isset($_SERVER['HTTPS']) &&
($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) ||
isset($_SERVER['HTTP_X_FORWARDED_PROTO']) &&
$_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') {
$protocol = 'https://';
} else {
$protocol = 'http://';
}
$URL = $protocol . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
?>
<!DOCTYPE html>
<html lang="<?= $opening->Language->value ?>">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="ie=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">
<?php if (!isEmpty($opening->Author)) { ?>
<meta name="author" content="<?= htmlspecialchars($opening->Author) ?>">
<?php } ?>
<title>
<?= $TITLE ?>
</title>
<meta name="title" content="<?= $TITLE ?>">
<meta name="description" content="<?= $DESCRIPTION ?>">
<meta name="robots" content="index,follow">
<meta name="google" content="notranslate">
<link rel="icon" href="./assets/sitelogo.svg">
<link rel="shortcut icon" href="./assets/sitelogo.svg">
<!-- Facebook -->
<meta property="og:type" content="website">
<meta property="og:url" content="<?= $URL ?>">
<meta property="og:title" content="<?= $TITLE ?>">
<meta property="og:description" content="<?= $DESCRIPTION ?>">
<meta property="og:image" content="./assets/sitelogo.svg">
<!-- Twitter -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="<?= $URL ?>">
<meta property="twitter:title" content="<?= $TITLE ?>">
<meta property="twitter:description" content="<?= $DESCRIPTION ?>">
<meta property="twitter:image" content="./assets/sitelogo.svg">
<!-- Main script that handles timing: must be loaded before body -->
<script type="text/javascript" src="./assets/view/view.js"></script>
<!-- Styles -->
<link rel="stylesheet" type="text/css"
href="./assets/view/view.css" onload="PageStyleLoaded()">
<link rel="stylesheet" type="text/css"
href="./assets/view/animations.css" onload="PageAnimationsLoaded()">
</head>
<body class="wait">
<!--
Included an h1 for better search ranking
-->
<h1 class="hidden">
<?= $TITLE ?>
</h1>
<!-- Loader shown on start -->
<div id="loader">
<div class="loader"></div>
</div>
<!-- Most important element -->
<main id="screen">
<!-- Intro part -->
<section class="intro">
<?= $opening->getIntro() ?>
</section>
<!-- Star wars logo svg. Do not copy -->
<section class="logo">
<?php include "./assets/img/starwarslogo.svg"; ?>
</section>
<!-- Text parts -->
<article id="board">
<div id="content">
<p id="episode">
<?= htmlspecialchars(string: $opening->Episode) ?>
</p>
<p id="title">
<?= htmlspecialchars(string: $opening->Title) ?>
</p>
<br>
<?php foreach ($opening->Paragraphs() as $part) { ?>
<p class="paragraph">
<?= $part ?>
</p>
<?php } ?>
</div>
</article>
<!-- Who created the opening -->
<article id="credits" class="hidden">
<?php if (!isEmpty(str: $opening->Author)) { ?>
<h2>
Creato da utente <?= htmlspecialchars(string: $opening->Author) ?>
</h2>
<?php } ?>
<p>
La musica è di proprietà di LucasFilm e Disney.
<br>
Questa simulazione è a solo scopo dimostrativo delle capacità
del design web; è pubblica e non può essere utilizzata per fini commerciali.
<br>
Per maggiori informazioni vai alla <a href="./index.php">Pagina principale</a>
</p>
<div class="row">
<button type="button" id="restart">
Riavvia
</button>
<button type="button" id="share">
Condividi
</button>
</div>
</article>
<!-- Stars for the background -->
<?php include "./parts/stars.php" ?>
</main>
<script type="text/javascript">
'use strict';
// Restart the page (reload) and share
const reloadBtn = document.getElementById('restart');
if (reloadBtn) {
reloadBtn.addEventListener('click', () => window.location.reload());
}
const shareBtn =document.getElementById('share');
if (!navigator.share || ! navigator.canShare({
title: document.title,
text: 'Guarda anche tu la mia intro di Star Wars',
url: window.location.href
})) {
shareBtn.classList.add('hidden');
} else {
shareBtn.addEventListener('click', () => {
navigator.share({
title: document.title,
text: 'Guarda anche tu la mia intro di Star Wars',
url: window.location.href
})
});
}
</script>
</body>
</html>