-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathexcerpts.php
148 lines (127 loc) · 4.76 KB
/
excerpts.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
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
<link rel="stylesheet" href="style.css">
</head>
<body>
<?php
session_start();
include 'navigate.php'
?>
<div class="container">
<h1>Yesterblog</h1>
<p>A collaborative blog about the past, present and future of the internet. </p>
<p>You can subscribe via RSS <a href="feed.php">here</a>.</p>
<div class="flex">
<div class="wrapper">
<?php
include "config.php";
date_default_timezone_set("US/Eastern");
$stmt = $con->prepare("SELECT * FROM blogs WHERE approved = 1 ORDER BY id DESC");
$stmt->execute();
$result = $stmt->get_result();
while ($row = $result->fetch_assoc()) {
$id = $row['id'];
$name = $row['owner_name'];
$link = $row['owner_link'];
$dateposted = $row['dateposted'];
$title = $row['title'];
$entry = $row['entry'];
$formattedDate = date("l, F j, Y", strtotime($dateposted));
//echo $id, $bowner, $dateposted, $timeposted, $title, $entry, $likes;
echo '<div class="blog">';
echo '<div class="title"><h2>' . $title . '</h2></div>';
echo '<div class="whoWhen">Posted on <span class="date">' . $formattedDate . '</span>';
echo '<span class="author"> by <a href="' . $link . '">' . $name . '</a></span></div>';
echo '<div class="post">' . substr($entry, 0, 350) . '... <a href="view.php?entry=' . $id . '">Read more...</a></div>';
echo '</div></div>';
}
$stmt->close();
?>
</tbody>
</table>
</div>
<div class="sidebar"><? include "sidebar.php" ?>
</div>
</div></div>
</body>
</html>
<style>
.fa-solid {
font-family:'Font Awesome 6 Free';
}
</style>
<script>
var random;
$('#surf').on("click", function(e) {
e.preventDefault();
random = Math.floor(Math.random() * urlArr.length);
console.log(shuffle(urlArr));
window.open(shuffle(urlArr)[0]);
shuffle(urlArr[0].pop());
});
// this puts all of the entries in a random order
function shuffle(urlArr) {
let currentIndex = urlArr.length, randomIndex;
// while there are items left to shuffle...
while (currentIndex != 0) {
// pick a remaining element...
randomIndex = Math.floor(Math.random() * currentIndex);
// decrease
currentIndex--;
// swap with current element
[urlArr[currentIndex], urlArr[randomIndex]] = [urlArr[randomIndex], urlArr[currentIndex]];
}
return urlArr;
}
var firstClick = 0;
$('input[type=checkbox]').on("change", function() {
if (firstClick !== 1) {
//$('tbody').css('display', 'none');
firstClick = 1;
if ($(this).prop("checked") == true) {
console.log('checked');
var cat = $(this).val();
console.log($(this).val());
$('.' + cat).css("display", "table-row");
} else if ($(this).prop("checked") == false) {
console.log('unchecked');
var removeCat = $(this).val();
$('.' + removeCat).css("display", "none");
}
// if not first click...
} else {
//$(this).css("display", "none");
if ($(this).prop("checked") == true) {
console.log('checked');
var cat = $(this).val();
console.log($(this).val());
$('.' + cat).css("display", "table-row");
} else if ($(this).prop("checked") == false) {
console.log('unchecked');
var removeCat = $(this).val();
$('.' + removeCat).css("display", "none");
}
}
});
fetch("https://webring.yesterweb.org/webring.json")
.then(function (response) {
return response.json();
})
.then(function (data) {
appendData(data);
})
.catch(function (err) {
console.log("error: " + err);
});
function appendData(data) {
var random = Math.floor(Math.random() * data.length);
var name = data[random].name;
var url = data[random].url;
var owner = data[random].owner;
console.log(name, url, owner);
$('.webringRand').append("<a href='" + url + "' target='_blank'>" + name + "</a>");
}
</script>