This repository has been archived by the owner on Sep 19, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
release.php
76 lines (76 loc) · 2.88 KB
/
release.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
<?php
require_once(dirname(__FILE__) . '/include/db.php');
require_once(dirname(__FILE__) . '/config/general.php');
//Output appropriate status
if(empty($_GET['r'])) {
$releasename = 'Nonexistent Release';
header('HTTP/1.1 404 Not Found');
} else {
$releaseid = $oar_sql->real_escape_string($_GET['r']);
$releasequery = $oar_sql->query('SELECT * FROM `' . $oar_sql->get_table_prefix() . 'releases` WHERE releaseid = \'' . $releaseid . '\'');
if($oar_sql->error()) {
$releasename = 'Release We Couldn\'t Get';
header('HTTP/1.1 500 Internal Server Error');
} else {
if($oar_sql->num_rows($releasequery) == 0) {
$releasename = 'Nonexistent Release';
header('HTTP/1.1 404 Not Found');
} else {
$releaserow = $oar_sql->fetch_assoc($releasequery);
$releasename = $releaserow['releasename'];
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>"<?php echo htmlspecialchars($releasename);?>" by <?php echo htmlspecialchars($oar_config['artist']); ?></title>
<link rel="stylesheet" type="text/css" href="styles.css"/>
</head>
<body>
<!-- common header -->
<!-- end common header -->
<?php
//check for error
if($oar_sql->error()) {
echo '<p>Sorry, we couldn\'t get the description for this release. Technical info: ' . $oar_sql->error() . '</p>';
} else {
//check for nonexistent release
if(empty($_GET['r']) || $oar_sql->num_rows($releasequery) == 0) {
echo '<p>Sorry, we couldn\'t find this release. Check the URL and try again. Or, <a href=".">head home</a>.</p>';
} else {
//release-specific header
echo $releaserow['releaseheader'];
//cover image
if($releaserow['releasecover']) {
$releasecover = $releaserow['releasecover'];
} else {
$releasecover = $oar_config['defaultcover'];
}
echo '<div><img class="cover" src="' . $releasecover . '" alt="Cover for "' . htmlspecialchars($releaserow['releasename']) . '""/></div>';
//release date
$releasedate = strtotime($releaserow['releasedate']);
echo '<p class="releasedate">Released <time datetime="' . date('Y-m-d', $releasedate) . '">' . date('j F Y', $releasedate) . '</time></p>';
//description
echo $releaserow['releasedesc'];
//sections
$secquery = $oar_sql->query('SELECT * FROM `' . $oar_sql->get_table_prefix(). 'sections` WHERE releaseid = \'' . $releaseid . '\' ORDER BY secpos ASC');
if($oar_sql->error()) {
echo '<p>Sorry, we couldn\'t get some information for this release. Technical info: ' . $oar_sql->error() . '</p>';
} else {
//display each section
$tparams['releaseid'] = $releaseid;
while($secrow = $oar_sql->fetch_assoc($secquery)) {
echo '<h1>' . $secrow['sectitle'] . '</h1>';
$tparams['secpos'] = $secrow['secpos'];
include('templates/' . $secrow['sectemplate']);
}
}
}
}
?>
</body>
</html>