-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.php
241 lines (232 loc) · 8.22 KB
/
main.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
<?php
$cat3 = "";
for($i = 0; $i < count($cat2); $i++) {
$switched = "";
switch($cat2[$i]) {
case "01":
$switched = "Academic";
break;
case "02":
$switched = "Anime/Manga";
break;
case "03":
$switched = "Computers - Hardware";
break;
case "04":
$switched = "Computers - Software";
break;
case "05":
$switched = "Gamers";
break;
case "06":
$switched = "I Don't Know";
break;
case "07":
$switched = "Interwebz";
break;
case "08":
$switched = "Literary";
break;
case "09":
$switched = "Music";
break;
case "10":
$switched = "Other";
break;
case "11":
$switched = "Robotics";
break;
case "12":
$switched = "Doctor Who";
break;
case "13":
$switched = "Firefly";
break;
case "14":
$switched = "TV - Other";
break;
case "15":
$switched = "Trekkies";
break;
case "16":
$switched = "Nerd Love";
break;
case "17":
$switched = "Comics";
break;
}
$cat3 .= "'" . $switched . "'";
if($i != count($cat2) - 1) $cat3 .= ", ";
}
switch($pop) {
case "random":
$query = "SELECT *, DATE_FORMAT(dateTime, '%M %e, %Y, %l:%i%p') AS newdate FROM stories WHERE type NOT IN($cat3) ORDER BY RAND() LIMIT 15";
$result8 = mysql_query($query, $con);
$count = 14;
break;
case "allTime": case "wAllTime":
$query = "SELECT *, DATE_FORMAT(dateTime, '%M %e, %Y, %l:%i%p') AS newdate FROM stories WHERE type NOT IN($cat3) ";
if($pop === "allTime") $query .= "ORDER BY nerdy - fail DESC ";
if($pop === "wAllTime") $query .= "ORDER BY nerdy - fail ASC ";
$query .= "LIMIT ";
$query .= 15 * ($page - 1);
$query .= ",15";
$result8 = mysql_query($query, $con);
$result3 = mysql_query("SELECT nerdy FROM stories WHERE type NOT IN($cat3)", $con);
$count = mysql_num_rows($result3) - 2;
break;
case "month": case "wMonth":
$query = "SELECT *, DATE_FORMAT(dateTime, '%M %e, %Y, %l:%i%p') AS newdate FROM stories WHERE type NOT IN($cat3) AND YEAR(dateTime)=YEAR(CURRENT_DATE()) and MONTH(dateTime)=MONTH(CURRENT_DATE()) ";
if($pop === "month") $query .= "ORDER BY nerdy - fail DESC LIMIT ";
if($pop === "wMonth") $query .= "ORDER BY nerdy - fail ASC LIMIT ";
$query .= 15 * ($page - 1);
$query .= ",15";
$result8 = mysql_query($query, $con);
$result3 = mysql_query("SELECT nerdy FROM stories WHERE type NOT IN($cat3) AND YEAR(`dateTime`)=YEAR(CURRENT_DATE()) and MONTH(`dateTime`)=MONTH(CURRENT_DATE())", $con);
$count = mysql_num_rows($result3) - 1;
break;
case "yesterday": case "wYesterday":
$query = "SELECT *, DATE_FORMAT(dateTime, '%M %e, %Y, %l:%i%p') AS newdate FROM stories WHERE type NOT IN($cat3) AND dateTime<=CURRENT_DATE() - INTERVAL '0' DAY and dateTime>=CURRENT_DATE() - INTERVAL '1' DAY ";
if($pop === "yesterday") $query .= "ORDER BY nerdy - fail DESC LIMIT ";
if($pop === "wYesterday") $query .= "ORDER BY nerdy - fail ASC LIMIT ";
$query .= 15 * ($page - 1);
$query .= ",15";
$result8 = mysql_query($query, $con);
$result3 = mysql_query("SELECT nerdy FROM stories WHERE type NOT IN($cat3) AND dateTime<=CURRENT_DATE() - INTERVAL '0' DAY and dateTime>=CURRENT_DATE() - INTERVAL '1' DAY", $con);
$count = mysql_num_rows($result3) - 1;
break;
default:
$query = "SELECT *, DATE_FORMAT(dateTime, '%M %e, %Y, %l:%i%p') AS newdate FROM stories WHERE type NOT IN($cat3) ";
$query .= "ORDER BY dateTime DESC ";
$query .= "LIMIT ";
$query .= 15 * ($page - 1);
$query .= ",15";
$result8 = mysql_query($query, $con);
$result3 = mysql_query("SELECT nerdy FROM stories WHERE type NOT IN($cat3)", $con);
$count = mysql_num_rows($result3) - 1;
break;
}
if($pop === "tomorrow") {
echo "You probably all know by now that this isn't legitimate...";
$result8 = mysql_query("SELECT * FROM stories WHERE story='no'");
}
while($row = mysql_fetch_array($result8)) {
?>
<div class="story" style=" width: 682px;">
<span style="font-size: 10px;" class="category"><?php echo $row[type]; ?></span><br />
<span class="storytext"><?php echo $row[story]; ?></span><br />
<span style="font-size: 10px;" class="nerdyfail">
<a class="nerdyLink nerdyfail" href="javascript:;">Nerdy?
<div class="dateDiv" style="display: none;"><?php echo $row[dateTime]; ?></div></a>
<span class="nerdyValue">
<?php echo $row[nerdy]; ?></span>.
<a class="failLink nerdyfail" href="javascript:;">Fail?
<div class="dateDiv" style="display: none;"><?php echo $row[dateTime]; ?></div></a>
<span class="failValue">
<?php echo $row[fail]; ?></span>.
<span class="color3" style="float: right;"><?php echo $row[newdate]; ?>.</span><br />
<a class="nerdyfail expand" href="javascript:;"><span class='slideComments'>Expand for Comments</span>
(<?php $commentcount = mysql_query("SELECT COUNT(*) count FROM comments WHERE comments.storyDate = '$row[dateTime]' ORDER BY postDate") or die(mysql_error());
while($countIt = mysql_fetch_array($commentcount)) {
echo $countIt[count];
}
?>)
</a>
<div style="float: right;">
<?php
if($_SESSION[loggedIn]) {
$countsubs = mysql_query("SELECT * FROM subscriptions WHERE user LIKE '$_SESSION[user]' AND story='$row[dateTime]'") or die(mysql_error());
if(mysql_num_rows($countsubs) == 1) {
?>
<a href="javascript:;" class="unsubscribe nerdyfail">Unsubscribe<div class="dateDiv" style="display: none;"><?php echo $row[dateTime]; ?></div></a>
<?php
} else {
?>
<a href="javascript:;" class="subscribe nerdyfail">Subscribe<div class="dateDiv" style="display: none;"><?php echo $row[dateTime]; ?></div></a>
<?php
}
?>
|
<?php
}
?>
<a class="nerdyfail" href="/story/<?php echo str_replace(" ","+",$row[dateTime]); ?>">Permalink</a></div>
<div class="loadDiv" style="display: none;">
<br /><center><img src='/load.php?theme=<?php echo $cookieT; ?>' /></center>
</div>
<div class="expandMe" style="display: none;">
<div class="expandComments">
<br />
<table style='width: 100%; border: 0px;'>
<?php
$result2 = mysql_query("SELECT * FROM comments WHERE comments.storyDate = '$row[dateTime]' ORDER BY postDate") or die(mysql_error());
$i = 1;
while($row2 = mysql_fetch_array($result2)) {
include("showcomment.php");
}
?>
</table>
<?php
if($_SESSION['loggedIn']) {
?>
</div>
<br />
<form accept-charset="utf-8" class="commentForm">
<b style='vertical-align: top;'><?php echo $_SESSION['user']; ?></b><br style="line-height: 1.5;" />
<textarea rows=1 name="comments" class="comment2" style="width: 99%;">Comment</textarea>
<input type="hidden" name="dateTime" value="<?php echo $row['dateTime'] ?>" />
<input type="button" style="float: right;" value="Submit" class="formSubmit"/>
</form>
<?php
}
?>
</span>
</div>
</div>
</div>
<br /><br />
<?php
}
?>
<!-- PAGE LINKS -->
<!-- PAGE LINKS -->
<!-- PAGE LINKS -->
<span class="color2">Page: </span>
<?php
$count2 = (int) round($count / 15 + .5, PHP_ROUND_HALF_DOWN);
?>
<a <?php if(1 == $page) echo "class='pageSelected boxSelected'"; else echo "class='page box'"; ?> href="/home/<?php echo $pop; ?>/1/<?php echo $cat; ?>"> 1 </a>
<?php
if($page > 6) echo "... ";
$startcount = $page - 6;
if($startcount < 1) $startcount = 1;
if($startcount == 1) echo " ";
for($i = $startcount; $i < $page - 1; $i++) {
?>
<a <?php if($i + 1 == $page) echo "class='pageSelected boxSelected'"; else echo "class='page box'"; ?> href="/home/<?php echo $pop . "/" . ($i + 1); ?>/<?php echo $cat; ?>"> <?php echo $i + 1; ?> </a>
<?php
}
if($page != 1 && $page != $count2) {
?>
<a class='pageSelected boxSelected' href="/home/<?php echo $pop . "/" . $page; ?>/<?php echo $cat; ?>"> <?php echo $page; ?> </a>
<?php
}
$endcount = $page + 5;
if($endcount > $count2) $endcount = $count2 - 1;
for($i = $page; $i < $endcount; $i++) {
if($i != $count2 - 1) {
?>
<a <?php if($i + 1 == $page) echo "class='pageSelected boxSelected'"; else echo "class='page box'"; ?> href="/home/<?php echo $pop . "/" . ($i + 1); ?>/<?php echo $cat; ?>"> <?php echo $i + 1; ?> </a>
<?php
}
}
if($page + 6 < $count2) echo "... ";
if($count2 != 1) {
?>
<a <?php if($count2 == $page) echo "class='pageSelected boxSelected'"; else echo "class='page box'"; ?> href="/home/<?php echo $pop . "/" . $count2; ?>/<?php echo $cat; ?>"> <?php echo $count2; ?> </a>
<?php
}
?>
<!-- END PAGE LINKS -->
<!-- END PAGE LINKS -->
<!-- END PAGE LINKS -->