-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
155 lines (132 loc) · 5.52 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
<head>
<title>Hayasugi</title>
<link rel = "stylesheet" type = "text/css" href = "./main.css">
<link rel="icon" type="image/png" href="./favicon.png"/>
</head>
<body>
<div id="banner">
<h1><a href="." class="blankLink">Hayasugi</a></h1>
Micro-anime reviews
<hr>
<button id="inputBtn">Write Review</button>
</div>
<form id="searchForm">
<input type="text" id="term" name="term"
<?php
if (isset($_GET["term"])) {
echo 'value="' . $_GET["term"] . '"';
}
?>
>
<select id="type" name="type">
<option value="anime">Anime</option>
<option value="author"
<?php
if (isset($_GET["type"]) && $_GET["type"] == "author") {
echo 'selected="selected"';
}
?>
>Author</option>
</select>
<button type="submit" class="redButton">Search</button>
</form>
<div id="feed">
<?php
$revList = glob('./reviews/*');
rsort($revList);
foreach($revList as $rev) {
$file = fopen($rev, "r");
$title = fgets($file);
$author = fgets($file);
$date = fgets($file);
$score = fgets($file);
if (isset($_GET["term"])) {
$include = FALSE;
$lterm = strtolower($_GET["term"]);
if ($_GET["type"] == "anime") {
if (preg_match('*' . $lterm . '*', strtolower($title))) {
$include = TRUE;
}
}
if ($_GET["type"] == "author") {
if (preg_match('*' . $lterm . '*', strtolower($author))) {
$include = TRUE;
}
}
} else {
$include = TRUE;
}
if ($include) {
$review = "";
while(! feof($file)) {
$review = $review . fgets($file);
}
$review = str_replace("\n", "<br>", $review);
echo '<article id="review' . $rev . '">' . "\n";
echo "\t" . '<div class="revHead">' . "\n";
echo "\t\t" . '<span><h1 class="revTitle"><a class="blankLink" href="./?term=' . $title . '&type=anime">' . $title . '</a></span><span class="revButton"><a class="blankLink">♥</a></span></h1>' . "\n";
echo "\t\t" . '<span class="revAuthor">-<a class="blankLink" href="./?term=' . $author . '&type=author">' . $author . '</a></span>' . "\n";
echo "\t\t" . '<span class="revDate"><i>' . $date . '</i></span>' . "\n";
echo "\t" . '</div>' . "\n";
echo "\t" . '<div class="revBody">' . $review . '</div>' . "\n";
echo "\t" . '<div class="revScore">' . $score . '/10</div>' . "\n";
echo '</article>';
echo "<hr>";
}
fclose($file);
}
?>
</div>
<div id="inputModal" class="modal">
<div class="modalContent">
<div class="modalHeader">
<span id="modalClose" class="close">×</span>
<h2>Submit Review</h2>
</div>
<div class="modalBody">
<form action="./submitReview.php" method="post" id="reviewForm">
<label for="anime">Anime:</label><br>
<input type="text" id="anime" name="anime"><br>
<label for="name">Name <i>(leave blank for anonymous)</i>:</label><br>
<input type="text" id="name" name="name"><br>
<label for="review">Review:</label><br>
<textarea name="review" id="review" rows="5" cols="80"></textarea></br>
<label for="score">Score:</label><br>
<select id="score" name="score">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
</select>
<hr>
<div style="float: right;">
<button>Cancel</button>
<button type="submit" class="redButton">Submit</button>
</div>
</form>
</div>
</div>
</div>
<script>
var modal = document.getElementById("inputModal");
var btn = document.getElementById("inputBtn");
var span = document.getElementById("modalClose");
btn.onclick = function() {
modal.style.display = "block";
}
span.onclick = function() {
modal.style.display = "none";
}
window.onclick = function(event) {
if (event.target == modal) {
modal.style.display = "none";
}
}
</script>
</body>