231 lines
No EOL
16 KiB
PHP
231 lines
No EOL
16 KiB
PHP
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<title>furpsocial</title>
|
|
<meta charset="UTF-8">
|
|
<link rel="stylesheet" href="style.css">
|
|
<style>
|
|
#center {
|
|
width: 100%;
|
|
max-width: 900px;
|
|
min-width: 720px;
|
|
margin: auto;
|
|
display: flex;
|
|
gap: 10px;
|
|
}
|
|
|
|
#function-column {
|
|
flex: 1;
|
|
}
|
|
|
|
#content-column {
|
|
flex: 1;
|
|
}
|
|
|
|
#canvas-input {
|
|
width: 100%;
|
|
border: 1px solid grey;
|
|
box-sizing: border-box;
|
|
-moz-box-sizing: border-box;
|
|
-webkit-box-sizing: border-box;
|
|
}
|
|
|
|
#image-bits {
|
|
display: none;
|
|
}
|
|
|
|
input[type=submit] {
|
|
width: 64px;
|
|
float: right;
|
|
background: var(--accent);
|
|
color: white;
|
|
font-weight: 600;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
|
|
.feed-header {
|
|
color: white;
|
|
display: inline-block;
|
|
font-size: 20px;
|
|
margin-top: 16px;
|
|
margin-bottom: 0;
|
|
}
|
|
|
|
.post {
|
|
width: 100%;
|
|
background: white;
|
|
padding: 10px;
|
|
box-sizing: border-box;
|
|
-moz-box-sizing: border-box;
|
|
-webkit-box-sizing: border-box;
|
|
box-shadow: 0px 0px 10px gray;
|
|
border-radius: 4px;
|
|
overflow: hidden;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.post h1 {
|
|
margin: 0;
|
|
font-size: 20px;
|
|
}
|
|
|
|
.post h2 {
|
|
margin: 0;
|
|
font-size: 14px;
|
|
padding: 10px;
|
|
margin: -10px;
|
|
display: inline-block;
|
|
}
|
|
|
|
.post i {
|
|
float: right;
|
|
color: grey;
|
|
}
|
|
|
|
#refresh {
|
|
width: 120px;
|
|
margin: 10px 0;
|
|
font-weight: 600;
|
|
text-align: center;
|
|
float: right;
|
|
padding: 5px;
|
|
color: var(--accent);
|
|
cursor: pointer;
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
function loadImageBits(canvasId, bits) {
|
|
alert("loading " + canvasId);
|
|
}
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
<div id="center">
|
|
|
|
<div id="function-column">
|
|
|
|
<!-- header and options for making posts -->
|
|
<div class="post" style="border-top-left-radius: 0; border-top-right-radius: 0;">
|
|
<h1 style="margin-bottom: 4px;"><span style="color: var(--accent);">furp</span>social</h1>
|
|
|
|
<form method="post" action="farp.php">
|
|
Draw here:<br>
|
|
<canvas id="canvas-input" width="128" height="64"></canvas>
|
|
<input id="image-bits" type="text" name="image-bits">
|
|
|
|
Signature (optional): <input id="signature-input" onchange="logSignature();" type="text" name="signature">
|
|
<input type="submit" value="Farp it">
|
|
</form>
|
|
|
|
<span style="font-size: 12px; color: grey;">Privacy Policy: The only data collected by furpsocial server-side is the contents of your posts (signature and body text). This information is stored in our secure databases which are wiped of all post data every week. This data is only used to accomodate furpsocial as a social media platform. Client-side, furpsocial stores your most recently used signature as a cookie, which persists for one day before expiring.</span>
|
|
</div>
|
|
|
|
<script>
|
|
const canvas = document.getElementById("canvas-input");
|
|
const bits = document.getElementById("image-bits");
|
|
const ctx = canvas.getContext("2d");
|
|
|
|
const pen = ctx.createImageData(2, 2);
|
|
for (let i = 0; i < pen.data.length; i += 4) {
|
|
pen.data[i] = 0;
|
|
pen.data[i+1] = 0;
|
|
pen.data[i+2] = 0;
|
|
pen.data[i+3] = 255;
|
|
}
|
|
|
|
var drawing = false;
|
|
canvas.onmousedown = function() { drawing = true; }
|
|
document.onmouseup = function() {
|
|
drawing = false;
|
|
// write image-bits for posting
|
|
let canvasData = ctx.getImageData(0, 0, 128, 64);
|
|
bits.value = "";
|
|
|
|
// not best method, ideally want to create an array and then merge
|
|
for (let i = 0; i < canvasData.data.length; i += 4) {
|
|
if (canvasData.data[i+3] == 255) {
|
|
bits.value += "1";
|
|
} else {
|
|
bits.value += "0";
|
|
}
|
|
}
|
|
}
|
|
|
|
canvas.onmousemove = function() {
|
|
if (drawing) {
|
|
draw(window.event);
|
|
}
|
|
};
|
|
|
|
function draw(e) {
|
|
var posX = e.offsetX * canvas.width / canvas.offsetWidth - 1;
|
|
var posY = e.offsetY * canvas.height / canvas.offsetHeight - 1;
|
|
|
|
ctx.putImageData(pen, posX, posY);
|
|
}
|
|
</script>
|
|
|
|
<!-- save most recent signature as a cookie and autoload on page load -->
|
|
<script>
|
|
function logSignature() {
|
|
// save signature to cookie
|
|
const d = new Date();
|
|
d.setTime(d.getTime() + (1 * 24 * 60 * 60 * 1000));
|
|
document.cookie = "signature=" + document.getElementById("signature-input").value + "; expires=" + d.toUTCString() + ";path=/";
|
|
}
|
|
|
|
// load caches signature
|
|
if (document.cookie.includes('=')) {
|
|
document.getElementById("signature-input").defaultValue = document.cookie.split('=')[1];
|
|
}
|
|
</script>
|
|
|
|
<!--<h1 class="feed-header">Farp highlights</h1>-->
|
|
|
|
<div class="post">
|
|
Furp social is currently under construction as we implement oekaki farping. Come back soon!
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div id="content-column">
|
|
|
|
<!-- feed display -->
|
|
<h1 class="feed-header">Global Feed</h1>
|
|
<span class="post" id="refresh" onclick="window.location.href = 'index.php'">refresh feed</span>
|
|
|
|
|
|
<?php
|
|
// ensure the file exists before attempting to read from it
|
|
if (!file_exists("posts.txt")) {
|
|
$myfile = fopen("posts.txt", "w");
|
|
fclose($myfile);
|
|
}
|
|
|
|
// show content
|
|
$myfile = fopen("posts.txt", "r") or die("Unable to open file!");
|
|
if ($myfile) {
|
|
$index = 0;
|
|
while (($line = fgets($myfile)) !== false) {
|
|
echo "<div class='post'><h2>" . $line . "</h2>";
|
|
echo "<i>" . fgets($myfile) . "</i>";
|
|
echo "<canvas id='c" . $index . "' style='width: 100%;' width='128' height='64'></canvas></div>";
|
|
|
|
echo "<script>loadImageBits('c" . $index . "', '" . "00110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011001100110011" . "');</script>";
|
|
fgets($myfile);
|
|
|
|
$index++;
|
|
}
|
|
|
|
fclose($myfile);
|
|
}
|
|
?>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</body>
|
|
</html>
|