April 3, 2019

Universal Forum Version 6


Hard to believe I've been working on this little project for six years. Anyhow, I've made quite a few changes since the last version. The PHP Source Code will be pasted below. In all the previous posts I've deleted the change log before I posted the source, so here it is in its entirety:

2019-03-20 v6.0 (still)
Commented all my code.

2019-03-13 v6.0
Added email thing.

2019-03-13 v5.9
Implemented super-kickass post bubble and message color definer to make it obvious who is who.

2019-01-20 v5.8 (still)
Refined spam measures further, notably added specific SVG icon to denote spammers.

2019-01-01 v5.8
Added spam counter-measures.

2018-07-28 v5.7 (still)
Removed a bunch of fancy bullshit. Added speech bubble unicode.

2018-01-13,27 v5.7
Changed color scheme to match site index. Removed dynamic scale to simplify compatibility. Fixed eye icon SVG to be scale consistent, also improved aesthetic. Removed autofocus attribute because it was really annoying!

2017-03-22 v5.6
Added custom IP code & SVG to show who the admin is.

2017-03-21 v5.5
Integrated changelog directly into source.
Removed custom font settings and replaced with generic web defaults to make even more universal.
Added favicon inline as base64 encode.

2016-01-03 v5.4
Due to unicode inconsistency, tombstone is replaced with dynamic inline SVG 'eye' glyph with RBGA IP iris.
This change log is now linked from the php source code of the forum.

2016-01-02 v5.3
New IP & timestamp system is overhauled and streamlined to display only as a tooltip embedded in avatar.
Avatar is changed from inverse smiley face to more neutral 'tombstone'.

2015-12-21 v5.2
Added major innovation: IP address is now converted to RGBA & applied to unicode avatar for each post.
Form placeholder now notifies posters that their IP will be publicly displayed.

2015-09-01 v5.1
Implemented IP address inclusion in post purely as an anti-spam measure.
Blocked two Chinese domains which were spamming thousands of comments per hour.

2015-08-12 v5.0
Major innovation: css transform operator added to introduce correct reverse-chronological ordering of comments.
General visual styling is significantly gussied up.

2015-06-21 v4.1
Major innovation: css calc operators added to introduce dynamic scaling of all elements.

2014-02-20 v4.0
Font links changed from opentype to woff.
Removed 'Name' Input Field since it was inherently pointless.

2014-02-20 v3.1
Forum closed due to spam.
No major changes.

2013-03-05 v3.0
Version added to page title.
Major innovation: closed loop meta refresh is incorporated to automate feedback.
Minor cosmetic changes to css.

2012-09-12 v2.3
Universal Forum leaves Beta, basic functionality and features are enabled.
Added default timezone & error reporting to maximize php sever compatibility.

===============================================================

<?php
date_default_timezone_set('America/Los_Angeles');
error_reporting (E_ALL ^ E_NOTICE);
echo "<!doctype html><html><head><meta charset='UTF-8'>

<title>Universal Forum v6.0</title>

<link href='data:image/svg+xml;base64,AAABAAEAEBAQAAEABAAoAQAAFgAAACgAAAAQAAAAIAAAAAEABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAAAD/AP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMzMwAAADMzMzMAERERADMzMBERERERAzMBEQAAABEQMBEAIiIiABEAACIiIiIiAAARACIiIgARAwERAAAAERAzMBERERERAzMzAREAERAzMzMwADMAAzMzMzMzMzMzMzMzMzMzMzMzP//wAA//8AAP//AAD4HwAA4AcAAMADAACAAQAAAAAAAAAAAAAAAAAAgAEAAMADAADgBwAA8Y8AAP//AAD//wAA' rel='icon' type='image/svg+xml'/>

<style>

body
{
margin: 0%;
padding: 0%;
background-color: #161616;
color: white;
}

.flip
{
transform: scaleY(-1);
margin: 0%;
padding: 0%;
}

.form
{
margin: 1%;
font-family: sans-serif, monospace;
font-size: 24px;
}

#textarea
{
font-family: sans-serif, monospace;
font-size: 24px;
background-color: black;
color: white;
}

#button
{
padding: 10px;
vertical-align: top;
font-family: sans-serif, monospace;
font-size: 24px;
}

.bubble
{
background-color: #000000;
transform: scaleY(-1);
margin: 1%;
padding: 1%;
border-radius: 6px;
font-family: sans-serif, monospace;
font-size: 24px;
font-weight: bold;
}

</style>
</head>
<body>

<div class='form'>
<form action='index.php' method='post'>
<textarea  name='comment' placeholder='comment' id='textarea'></textarea>
<input type='submit' value='POST' id='button'>
</form>
</div>
<div class='flip'>
";
$ip = $_SERVER['REMOTE_ADDR']; //get the ip address of the comment poster
$file = "index.php";
$name = fopen($file, 'a') or die("fail"); //open this document to begin appending comments
if ($_POST["comment"]=="")
echo "";
else
{
echo "";

list($r, $g, $b, $a) = explode('.', $ip); //parse the ip address and asign each section to RGBA values, also their inverse
$x = 255-$r;
$y = 255-$g;
$z = 255-$b;

fwrite($name, $string); //set the comment bubble color and text according to the ip RGBA values above
$string = "<div style='background-color: rgba($r,$g,$b,$a); color: rgba($x,$y,$z,1); -webkit-text-stroke: 1px black;' class='bubble'>";

fwrite($name, $string);
$string = strip_tags($_POST["comment"]); //post the visitors comment to the page

$message = $_POST["comment"];

ini_set('SMTP','localhost');
ini_set('smtp_port','25');
ini_set('sendmail_from','x@y.com'); //tell the mail fuction how to do its job

mail('x@y.com','Universal Forum Comment',$message,"From: $ip"); //email the comment to the specified address

$string = preg_replace('/(http|www|url)/', "<span style='color:lightpink;'>SPAM</span>", $string); //filter out spam keywords like TLD etc.

$string = preg_replace('/\\b\\.com\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.net\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.org\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.info\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.ml\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.ru\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.pro\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.ly\\b/', "<span style='color:lightpink;'>.spam</span>", $string);
$string = preg_replace('/\\b\\.online\\b/', "<span style='color:lightpink;'>.spam</span>", $string); //TLD filter added 2019-03-21

if (preg_match('/(SPAM)/', $string)):

fwrite($name, $string);
$string = " <span style='color:red;'><b>(THIS POST IS SPAM)</b></span>"; //flag spam as spam

else:

endif;

if ($ip == '0.0.0.0'): //assign icon to the admin (your IP address goes here)
fwrite($name, $string);
$string = " <svg width='16px' height='16px' viewBox='0 0 100 100'><path fill='darkgoldenrod' d='M50,0a50,50,0,0,0,0,100z'/><path fill='goldenrod' d='M50,0a50,50,0,0,1,0,100z'/><path fill='goldenrod' d='M50,25a25,25,0,0,0,0,50z'/><path fill='darkgoldenrod' d='M50,25a25,25,0,0,1,0,50z'/><title>";

elseif (preg_match('/(SPAM)/', $string)): //assign icon to spammers
fwrite($name, $string);
$string = " <svg width='16px' height='16px' viewBox='0 0 100 100'><path d='m88 68v-43.999s-20-20.001-28-20.001-52 12-52 24 0 32 0 44 20 20 28 20 52-12 52-24z' fill='#E2BEA3'/><g stroke-linejoin='round' stroke='#CEB3A1' stroke-linecap='round' stroke-width='2' fill='none'><line x1='16.001' y2='80' x2='16' y1='44'/><line x1='76' y2='76' x2='76' y1='40'/><line x1='64' y2='80' x2='64' y1='44'/><line x1='52' y2='84' x2='52' y1='48'/><line x1='40' y2='88' x2='40' y1='52'/></g><path d='m88 24c0-12-20-20-28-20s-52 12-52 24 20 20 28 20 52-12 52-24z' fill='#EDC6B7'/><title>";

else:
fwrite($name, $string); //asign icon to random visitors
$string = " <svg width='16px' height='16px' viewBox='0 0 100 100'><path d='m1 50s21-28 49-28 49 28 49 28-21 28-49 28-49-28-49-28z' fill='white'/><path d='m78 50c0 15.463-12.53 28-28 28-15.463 0-28-12.537-28-28s12.537-28 28-28c15.47 0 28 12.537 28 28z' fill='rgba($r,$g,$b,$a)'/><path d='m64 50c0 7.7383-6.2686 14-14 14s-14-6.2617-14-14c0-7.7314 6.2686-14 14-14s14 6.269 14 14z'/><title>";

endif;

fwrite($name, $string);
$string = date("Y-m-d", time()); //create icon and asign it a tooltip including timestamp and ip address

fwrite($name, $string);
$string = "&nbsp;&#149;&nbsp;";

fwrite($name, $string);
$string = date("H:i:s", time());

fwrite($name, $string);
$string = "&nbsp;&#149;&nbsp;";

fwrite($name, $string);
$string = "$ip";

fwrite($name, $string);
$string = "</title></g></svg> ";

fwrite($name, $string);
$string = "</div>";

fwrite($name, $string);
$string = "

";

fwrite($name, $string);
fclose($name);

if ($_POST["comment"]=="")
echo "";

else
{
echo('<meta http-equiv="refresh" content="1">'); //wait one second then reload the page to display the most recent comments
}
}
?>