Clone from GitHub... continuing devel here

master
Pentium44 2020-11-03 19:39:41 -08:00
commit a26c3de40a
12 changed files with 4084 additions and 0 deletions

138
README.md Executable file
View File

@ -0,0 +1,138 @@
SSB - Simple Social Board
----
A Simple social media board script coded in php that runs on flatfile databases. It requires
no setup (except setting properties in the config.php script). SSB is released
under the CC-BY-NC-SA v3.0 unported.
SSB was written by Chris Dorman, 2012-2020 <https://cddo.cf>
ChangeLog
----
10/20/2020 -v2.1.0 - version bump - feature release
* Remove jquery from data folder (didn't need that for a while)
* Add bg.jpg to data folder (oops)
* Bug fixes
* Dynamic notification clearing and post reacting
* Reaction lists on hover VIA CSS
* Post footers added
* CSS cleanup for mobile usage
* Allow for user chat scrolling
10/10/2020 -v2.0.3 - minor version bump - release
* Removed unneeded HTML from bbcode parser
* Added user reacts (notifications send with react, checks if trying to react multiple times)
* Added minimal user page for outdated browsers (minimum.php, does most everything index.php can handle)
* Some CSS modifications
10/10/2020 -v2.0.2 - minor version bump - release
* BBCode image addition (***boldtext***) (___underlinetext___)
* Bugfixes with notification menu, and user profile avatar linking
* Added post removal abilities for post owners
* Database speed enhancements (removed a ton of HTML out of the database to free space)
* Reworked post / reply generation code
* Updated some errors in user profile generation
* New BG, hope you like!
9/20/2020 -v2.0.0 - major version bump - release
* BBCode IMG addition for chat
* Multi image uploads added
* Reworked post attachment system
* Added "send friend request" on public profiles
* Added public user list (community tab)
* Attachment CSS updates
* Bugfixes in multiple redirects
* Buffixes in image uploads when on slow connections
* Added user to user tagging within posts & replies (use @<username>)
* Notification box rework, now available among all pages when logged in.
* Post reply notifications, tag notifications, and message notifications working properly
9/13/2020 -v1.3.1 - hotfix
* BBCode bug in database, modified and fixed!
9/13/2020 - v1.3.0 - feature update
* Modified notification system for more board based features (Post reply notifications, message notifications)
* CSS modifications, revamped friends list page
* Little cleanup of unneeded code.
8/3/2020 - v1.2.2 - hotfix
* Private and public chat CSS updates
* Bugfix for user profile avatars not loading on pages when not logged in
* Add "my profile" button on navbar
8/3/2020 - v1.2.1 - feature update
* Added user settings panel for changing account passwords and avatar images.
* Display profile images in posts and user profile page.
* Bug fixes for unauthorized posts by users not friends with people when post links are directly connected to.
* Large CSS changes, more mobile device friendly. More changes to come.
8/2/2020 - v1.1.2 - hotfix
* Minor tweaks
* Another duplicate friend request bugfix
8/2/2020 - v1.1.1 - hotfix
* Mobile CSS and viewport tweaks
* Couple of missed bug tweaks
8/2/2020 - v1.1.0
* Added friend to friend private messaging
* Fixed a few friend request bugs
-- Look for self sent friend requests and block
-- Look for and block already accepted or pending friend requests
* Friend request and new message notifications with wipe function.
* Version bump, new ideas include:
-- Owner / admin post removal
-- Video media support
-- Possible remove of public chat
-- Password change (done)
-- Profile pictures (done)
-- Bot verification prompt for registeration.
8/2/2020 - v1.0.3 - hotfix
* After live version went online, noticed a bug with accepting friend requests multiple times
* Check to see if public user is already followed by user.
8/2/2020 - v1.0.2
* Added private and public accounts for public figures, pages, meme groups.
8/2/2020 - v1.0.1 - hotfix
* Felt it was needed to finish the about page.
* A couple UI tweaks, will probably have more minor version releases but meh.
8/1/2020 - v1.0.0
* Cleaned up functions, added more functions
* View profiles from friends list, user info and feed.
* Image upload capabilities.
* CSS clean up, still things to be done.
* Fully functioning public web chat!
* Considered operational, and beta released!
8/1/2020 - v0.2.0
* Working home feed with personal and friends posts in order by date newest to oldest!
* Public chat room with short term message buffer room. Great for chitchat.
* Personal messaging in progress.
* CSS clean up, added FontAwesome.
* Added form input BB code parsing!
* Known bugs: can send multi friend requests and spam another users notification box.
8/1/2020 - v0.1.0
* Working friends list to be incorporated into each users news feed output (in dev)
* Some more CSS cleaning, more streamline website. More mobile friendly
* NOTE: I'm just pumping out work on this LOL
8/1/2020 - v0.0.2
* Reconstructed posting database for friends list and feed processing
* Separated some files (CSS, and functions within index.php)
* More CSS clean up.
* User base is also capable of replying, and posting. Feed still not operational.
8/1/2020 - v0.0.1
* Official release of SSB, now known Simple Social Board.
* Added userbase to database.
* Separated form functions into separate PHP doc for cleanliness.
* CSS and HTML modifications
* NOTE: Feed is public across all users currently. Working on friends system
* NOTE: Friends list and messaging still in progress.
2/1/2014 -
Little fixing up

73
bbcode.php Executable file
View File

@ -0,0 +1,73 @@
<?php
/*
* This file is part of SSB. code was used from phpit.net
* Modified by Chris Dorman
* Removed some stuff to make it simpler.
*/
// based on http://www.phpit.net/article/create-bbcode-php/
// modified by www.vision.to
// please keep credits, thank you :-)
// document your changes.
function bbcode_format($str) {
$simple_search = array(
'/\[b\](.*?)\[\/b\]/is',
'/\*\*\*(.*?)\*\*\*/is',
'/\[i\](.*?)\[\/i\]/is',
'/\[u\](.*?)\[\/u\]/is',
'/___(.*?)___/is',
'/\[url\=(.*?)\](.*?)\[\/url\]/is',
'/\[img\](.*?)\[\/img\]/is',
'/\[url\](.*?)\[\/url\]/is',
'/\[font\=(.*?)\](.*?)\[\/font\]/is',
'/\[color\=(.*?)\](.*?)\[\/color\]/is',
);
$simple_replace = array(
"<strong>$1</strong>",
"<strong>$1</strong>",
"<em>$1</em>",
"<u>$1</u>",
"<u>$1</u>",
"<a href='$1' title='$2 - $1'>$2</a>",
"<a href='$1'><img src='$1' class='attachment_chat' /></a>",
"<a href='$1' title='$1'>$1</a>",
"<span style='font-family: $1;'>$2</span>",
"<span style='color: $1;'>$2</span>",
);
// Do simple BBCode's
$str = preg_replace ($simple_search, $simple_replace, $str);
// Do <blockquote> BBCode
$str = bbcode_quote ($str);
return $str;
}
function bbcode_quote ($str) {
//added div and class for quotes
$open = '<blockquote>';
$close = '</blockquote>';
// How often is the open tag?
preg_match_all ('/\[quote\]/i', $str, $matches);
$opentags = count($matches['0']);
// How often is the close tag?
preg_match_all ('/\[\/quote\]/i', $str, $matches);
$closetags = count($matches['0']);
// Check how many tags have been unclosed
// And add the unclosing tag at the end of the message
$unclosed = $opentags - $closetags;
for ($i = 0; $i < $unclosed; $i++) {
$str .= '</div></blockquote>';
}
// Do replacement
$str = str_replace ('[' . 'quote]', $open, $str);
$str = str_replace ('[/' . 'quote]', $close, $str);
return $str;
}
?>

89
chatserver.php Executable file
View File

@ -0,0 +1,89 @@
<?php
session_start();
include_once("config.php");
include("functions.php");
include("bbcode.php");
if (!isset($_SESSION['ssb-user']) && !isset($_SESSION['ssb-pass'])) { echo "ERROR: Not logged in!"; header("Location: index.php"); exit(1); }
if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && !isset($_GET['friend'])){
$nick = $_GET['nick'];
$msg = bbcode_format(nl2br(htmlentities(stripcslashes($_GET['msg']))));
$line = "<table><tr><td style='vertical-align: top;'><img class='avatar_chat' src='?do=avatarlocation&user=" . $nick . "' title='User Avatar'></td><td class='message'><b>$nick</b>: $msg</td></tr></table>\n";
$old_content = file_get_contents($chat_db);
$lines = count(file($chat_db));
if($lines>$server_msgcount) {
$old_content = implode("\n", array_slice(explode("\n", $old_content), 1));
}
file_put_contents($chat_db, $old_content.$line);
echo $line;
} else if (isset($_GET['msg']) && $_GET['msg']!="" && isset($_GET['nick']) && isset($_GET['friend'])){
$friendNick = $_GET['friend'];
$nick = $_SESSION['ssb-user'];
$friendcount = file_get_contents("ssb_db/friends/" . $nick . ".count");
include "ssb_db/friends/" . $nick . ".php";
// Checking if you're friend
for($x = 1; $x <= $friendcount; $x++)
{
if($friendNick == ${"friend" . $x}) {
$msgCount = file_get_contents("ssb_db/friends/" . ${"friend_chat_db" . $x} . ".count");
$msgCount = $msgCount + 1;
$msg = bbcode_format(nl2br(htmlentities(stripcslashes($_GET['msg']))));
$line_start = "<?php \$msg" . $msgCount . " = \"<table><tr><td style='vertical-align: top;'><img class='avatar_chat' src='?do=avatarlocation&user=" . $nick . "' title='User Avatar'></td><td class='message'><b>$nick</b>: $msg</td></tr></table>";
$line_end = "\"; ?>\n";
$old_content = file_get_contents("ssb_db/friends/" . ${"friend_chat_db" . $x} . ".php");
$notifications = file_get_contents("ssb_db/friends/" . ${"friend" . $x} . ".notifications");
// update conversation message count
file_put_contents("ssb_db/friends/" . ${"friend_chat_db" . $x} . ".count", $msgCount);
// conents into database
file_put_contents("ssb_db/friends/" . ${"friend_chat_db" . $x} . ".php", $old_content . $line_start . $line_end);
// notifications!
file_put_contents("ssb_db/friends/" . ${"friend" . $x} . ".notifications", "<b>" . $nick . "</b> sent you a <a href='?do=privmsg&friend=" . $nick . "'>message</a>\n" . $notifications);
}
}
} else if (isset($_GET['get'])){
$friendNick = $_GET['get'];
$nick = $_SESSION['ssb-user'];
$friendcount = file_get_contents("ssb_db/friends/" . $nick . ".count");
include "ssb_db/friends/" . $nick . ".php";
for($x = 1; $x <= $friendcount; $x++)
{
if($friendNick == ${"friend" . $x}) {
$msgCount = file_get_contents("ssb_db/friends/" . ${"friend_chat_db" . $x} . ".count");
include "ssb_db/friends/" . ${"friend_chat_db" . $x} . ".php";
for($y = 1; $y <= $msgCount; $y++) {
echo ${"msg" . $y};
}
} //else { echo "Not friend!"; }
//echo "Finding friend in slot " . $x;
}
} else if (isset($_GET['all'])) {
//$content = file_get_contents($server_db);
// This is faster
$flag = file($chat_db);
$content = "";
foreach ($flag as $value) {
$content .= $value;
}
echo $content;
}/* else if(isset($_GET['ping'])) {
$username = $_GET['nick'];
} else if(isset($_GET['pong'])) {
}*/
?>

18
config.php Executable file
View File

@ -0,0 +1,18 @@
<?php
///////
// SSB - Simple Social Board
// (C) Chris Dorman, GPL v3 (2013-2020)
// https://github.com/Pentium44/SSB
// Version: 2.1.0
///////
$title = "Simple Social Board"; // SM title
$desc = "Simple open source social media platform"; // platform description
$domain = "sm.cddo.cf"; // where is SSB operating?
$admin = "Username"; // Administrator account username
$version = "2.1.0"; // version
$chat_db = "ssb_db/friends/chatdb.txt"; //public chat db
$server_msgcount = "52"; // for chat page
$user_max_upload = "4194304";
?>

BIN
data/bg.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 203 KiB

BIN
data/defaultprofile.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

267
forms.php Executable file
View File

@ -0,0 +1,267 @@
<?php
// SSB - Simple Social Board
// (C) Chris Dorman, 2012 - 2020
// License: CC-BY-NC-SA version 3.0
// http://github.com/Pentium44/SSB
// get filesize for uploaded files
function tomb($size, $precision = 2)
{
$base = log($size) / log(1024);
$suffixes = array('', 'KB', 'MB', 'GB', 'TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
}
function loginForm() {
?>
<br />
<div class="login">
<a class="button" href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">Register</a>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
<table><tr><td>
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr></table>
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Login">
</form>
</div>
<?php
}
function changePassForm() {
?>
<br />
<div class="chgpass">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=changepass" method="post">
<table><tr><td>
Old password:</td><td> <input class="text" type="password" name="oldpass"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
Password Again:</td><td> <input class="text" type="password" name="password_again"></td></tr>
</table>
<input class="text" type="submit" name="submitBtn" value="Change">
</form>
</div>
<?php
}
function uploadAvatarForm() {
?>
<br />
<div class="upload">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=avatarupload" method="post" enctype="multipart/form-data">
Choose profile avatar: <br />
<label class="input-upload">
<input type="file" name="file[]" id="file" multiple>
<i class="fa fa-cloud-upload"></i> Upload image
</label>
<input class="text" type="submit" name="submit" value="Set">
</form>
</div>
<?php
}
/*function uploadForm() {
print <<<EOD
Upload
<table style="margin:auto;">
<form action="upload.php" method="post" enctype="multipart/form-data">
<tr>
<td>
<input type="file" name="file[]" id="file" multiple><br>
</td>
<td>
<input type="submit" name="submit" value="Upload">
</td>
</tr>
</form>
</table>
EOD;
}*/
function registerForm() {
?>
<br />
<div class="login">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=register" method="post">
<table><tr><td>
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
Full name:</td><td> <input class="text" type="text" name="fullname"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
Password Again:</td><td> <input class="text" type="password" name="password-again"></td></tr><tr><td>
<label for="acct">Profile type:</label>
<select id="acct" name="acct">
<option value="private">Private</option>
<option value="public">Public</option>
</select></td><td>
<input class="text" type="submit" name="submitBtn" value="Register">
</td></tr></table>
</form>
</div>
<?php
}
function postForm() {
print <<<EOD
<button onclick="javascript:wrapBBCode('i');">Italic</button>
<button onclick="javascript:wrapBBCode('u');">Underline</button>
<button onclick="javascript:wrapBBCode('b');">Bold</button>
<button onclick="javascript:wrapBBCode('url');">URL</button>
<form action="?do=post" method="post" enctype="multipart/form-data">
<label class="input-upload">
<input type="file" name="file[]" id="file" multiple>
<i class="fa fa-cloud-upload"></i> Upload image
</label>
<br /><textarea rows="5" cols="60" id="msg" name="body"></textarea><br />
<input type="submit" name="post" value="Post">
</form>
EOD;
}
function replyForm($id, $puser) {
?>
<button onclick="javascript:wrapBBCode('i');">Italic</button>
<button onclick="javascript:wrapBBCode('u');">Underline</button>
<button onclick="javascript:wrapBBCode('b');">Bold</button>
<button onclick="javascript:wrapBBCode('url');">URL</button>
<form action="?do=reply&pid=<?php echo $id; ?>&user=<?php echo $puser; ?>" method="post">
<textarea rows="7" cols="60" id="msg" name="body">Reply</textarea><br />
<input type="submit" name="reply" value="Reply">
</form>
<?php
}
function cleanForm() {
?>
<br />
<form action="?do=clean" method="post">
Password: <input type="password" name="password" id="password"> <br />
<input type="submit" name="post" value="Post">
</form>
<?php
}
function friendReqForm() {
?>
<h2>Request friendship!</h2>
<form action="?do=sendfr" method="post">
Username: <input type="text" name="user" id="user"> <br />
<input type="submit" name="post" value="Send">
</form>
<?php
}
function sendFriendRequest($user, $friend) {
$friendLocation = "ssb_db/friends/" . $friend . ".pending";
$handle = fopen($friendLocation, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if($line == $user) { break; } // request already pending
}
fclose($handle);
}
// Check if user is itself
if($user == $friend) { header("Location: index.php?do=friends"); exit(1); } // dont request from self.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendcount; $x++)
{
if(${"friend" . $x} == $friend) { header("Location: index.php?do=friends"); echo "Already following!"; exit(1); }
}
if(file_exists($friendLocation)) {
$pending = file_get_contents("ssb_db/friends/" . $friend . ".pending");
file_put_contents("ssb_db/friends/" . $friend . ".pending", $pending . "\n" . $user);
} else {
file_put_contents("ssb_db/friends/" . $friend . ".pending", $user);
}
}
function acceptPublicFriendRequest($user, $friend) {
$friendpending = "ssb_db/friends/" . $user . ".pending";
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
// check if already on friends list.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendcount; $x++)
{
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
}
// populate both users databases with each other.
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
$friendcountFriend = $friendcountFriend + 1;
//echo $friendcountFriend;
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n <?php \$friend" . $friendcountFriend ." = \"" . $user . "\";\n\$friend_chat_db" . $friendcountFriend . " = \"" . $user . $friend . "\";?>");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = $friendcount + 1;
//echo $friendcount;
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n <?php \$friend" . $friendcount . " = \"" . $friend . "\";\n\$friend_chat_db" . $friendcount . " = \"" . $user . $friend . "\";?>");
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "<?php \$msg1 = \"" . $user . " and " . $friend . " are now friends!<br />\";?>");
}
function acceptFriendRequest($user, $friend) {
$friendpending = "ssb_db/friends/" . $user . ".pending";
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
// check if friend request is really pending.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendc; $x++)
{
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
}
$handle = fopen($friendpending, "r");
if ($handle) {
$xx = 0;
while (($line = fgets($handle)) !== false) {
if($xx >= "1") {
$line = str_replace("\n","",$line);
}
$xx++;
//echo $line . "<br />";
//echo $friend . "<br />";
if($friend == $line)
{
// populate both users databases with each other.
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
$friendcountFriend = $friendcountFriend + 1;
//echo $friendcountFriend;
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n <?php \$friend" . $friendcountFriend ." = \"" . $user . "\";\n\$friend_chat_db" . $friendcountFriend . " = \"" . $user . $friend . "\";?>");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = $friendcount + 1;
//echo $friendcount;
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n <?php \$friend" . $friendcount . " = \"" . $friend . "\";\n\$friend_chat_db" . $friendcount . " = \"" . $user . $friend . "\";?>");
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "<?php \$msg1 = \"" . $user . " and " . $friend . " are now friends!<br />\";?>");
}
}
fclose($handle);
} else {
echo "ERROR: Friend: " . $friend . " not found in friend pending database.<br />";
}
}
?>

287
functions.php Executable file
View File

@ -0,0 +1,287 @@
<?php
// SSB - Simple Social Board
// (C) Chris Dorman, 2012 - 2020
// License: CC-BY-NC-SA version 3.0
// http://github.com/Pentium44/SSB
// get filesize for uploaded files
function tomb($size, $precision = 2)
{
$base = log($size) / log(1024);
$suffixes = array('', 'KB', 'MB', 'GB', 'TB');
return round(pow(1024, $base - floor($base)), $precision) . $suffixes[floor($base)];
}
function getRandString($n) {
$characters = '0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ';
$randomString = '';
for ($i = 0; $i < $n; $i++) {
$index = rand(0, strlen($characters) - 1);
$randomString .= $characters[$index];
}
return $randomString;
}
function searchForUserTag($str) {
if(preg_match("/\s*@(.+?)\s/", $str, $matches)) {
return $matches["0"];
} else {
return false;
}
}
function loginForm() {
?>
<br />
<div class="login">
<a class="button" href="<?php echo $_SERVER['PHP_SELF']; ?>?forms=register">Register</a>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=login" method="post">
<table><tr><td>
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr></table>
<input style="padding: 2px;" class="text" type="submit" name="submitBtn" value="Login">
</form>
</div>
<?php
}
function changePassForm() {
?>
<br />
<div class="chgpass">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=changepass" method="post">
<table><tr><td>
Old password:</td><td> <input class="text" type="password" name="oldpass"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
Password Again:</td><td> <input class="text" type="password" name="password_again"></td></tr>
</table>
<input class="text" type="submit" name="submitBtn" value="Change">
</form>
</div>
<?php
}
function uploadAvatarForm() {
?>
<br />
<div class="upload">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=avatarupload" method="post" enctype="multipart/form-data">
Choose profile avatar: <br />
<label class="input-upload">
<input type="file" name="file[]" id="file" multiple>
<i class="fa fa-cloud-upload"></i> Upload image
</label>
<input class="text" type="submit" name="submit" value="Set">
</form>
</div>
<?php
}
/*function uploadForm() {
print <<<EOD
Upload
<table style="margin:auto;">
<form action="upload.php" method="post" enctype="multipart/form-data">
<tr>
<td>
<input type="file" name="file[]" id="file" multiple><br>
</td>
<td>
<input type="submit" name="submit" value="Upload">
</td>
</tr>
</form>
</table>
EOD;
}*/
function registerForm() {
?>
<br />
<div class="login">
<form action="<?php echo $_SERVER['PHP_SELF']; ?>?do=register" method="post">
<table><tr><td>
Username:</td><td> <input class="text" type="text" name="username"></td></tr><tr><td>
Full name:</td><td> <input class="text" type="text" name="fullname"></td></tr><tr><td>
Password:</td><td> <input class="text" type="password" name="password"></td></tr><tr><td>
Password Again:</td><td> <input class="text" type="password" name="password-again"></td></tr><tr><td>
<label for="acct">Profile type:</label>
<select id="acct" name="acct">
<option value="private">Private</option>
<option value="public">Public</option>
</select></td><td>
<input class="text" type="submit" name="submitBtn" value="Register">
</td></tr></table>
</form>
</div>
<?php
}
function postForm() {
print <<<EOD
<button onclick="javascript:wrapBBCode('i');">Italic</button>
<button onclick="javascript:wrapBBCode('u');">Underline</button>
<button onclick="javascript:wrapBBCode('b');">Bold</button>
<button onclick="javascript:wrapBBCode('url');">URL</button>
<form action="?do=post" method="post" enctype="multipart/form-data">
<label class="input-upload">
<input type="file" name="file[]" id="file" multiple>
<i class="fa fa-cloud-upload"></i> Upload image
</label>
<br /><textarea rows="5" cols="60" id="msg" name="body"></textarea><br />
<input type="submit" name="post" value="Post">
</form>
EOD;
}
function replyForm($id, $puser) {
?>
<button onclick="javascript:wrapBBCode('i');">Italic</button>
<button onclick="javascript:wrapBBCode('u');">Underline</button>
<button onclick="javascript:wrapBBCode('b');">Bold</button>
<button onclick="javascript:wrapBBCode('url');">URL</button>
<form action="?do=reply&pid=<?php echo $id; ?>&user=<?php echo $puser; ?>" method="post">
<textarea rows="7" cols="60" id="msg" name="body"></textarea><br />
<input type="submit" name="reply" value="Reply">
</form>
<?php
}
function cleanForm() {
?>
<br />
<form action="?do=clean" method="post">
Password: <input type="password" name="password" id="password"> <br />
<input type="submit" name="post" value="Post">
</form>
<?php
}
function friendReqForm() {
?>
<h2>Request friendship!</h2>
<form action="?do=sendfr" method="post">
Username: <input type="text" name="user" id="user"> <br />
<input type="submit" name="post" value="Send">
</form>
<?php
}
function sendFriendRequest($user, $friend) {
$friendLocation = "ssb_db/friends/" . $friend . ".pending";
$handle = fopen($friendLocation, "r");
if ($handle) {
while (($line = fgets($handle)) !== false) {
if($line == $user) { break; } // request already pending
}
fclose($handle);
}
// Check if user is itself
if($user == $friend) { header("Location: index.php?do=friends"); exit(1); } // dont request from self.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendcount; $x++)
{
if(${"friend" . $x} == $friend) { header("Location: index.php?do=friends"); echo "Already following!"; exit(1); }
}
if(file_exists($friendLocation)) {
$pending = file_get_contents("ssb_db/friends/" . $friend . ".pending");
file_put_contents("ssb_db/friends/" . $friend . ".pending", $pending . "\n" . $user);
} else {
file_put_contents("ssb_db/friends/" . $friend . ".pending", $user);
}
}
function acceptPublicFriendRequest($user, $friend) {
$friendpending = "ssb_db/friends/" . $user . ".pending";
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
// check if already on friends list.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendcount; $x++)
{
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
}
// populate both users databases with each other.
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
$friendcountFriend = $friendcountFriend + 1;
//echo $friendcountFriend;
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n <?php \$friend" . $friendcountFriend ." = \"" . $user . "\";\n\$friend_chat_db" . $friendcountFriend . " = \"" . $user . $friend . "\";?>");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = $friendcount + 1;
//echo $friendcount;
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n <?php \$friend" . $friendcount . " = \"" . $friend . "\";\n\$friend_chat_db" . $friendcount . " = \"" . $user . $friend . "\";?>");
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "<?php \$msg1 = \"" . $user . " and " . $friend . " are now friends!<br />\";?>");
}
function acceptFriendRequest($user, $friend) {
$friendpending = "ssb_db/friends/" . $user . ".pending";
$friendlist = file_get_contents("ssb_db/friends/" . $user . ".php");
$frienddb = file_get_contents("ssb_db/friends/" . $friend . ".php");
// check if friend request is really pending.
$friendc = file_get_contents("ssb_db/friends/" . $user . ".count");
include "ssb_db/friends/" . $user . ".php";
for($x = 1; $x <= $friendc; $x++)
{
if(${"friend" . $x} == $friend) { echo "Already following!"; exit(1); }
}
$handle = fopen($friendpending, "r");
if ($handle) {
$xx = 0;
while (($line = fgets($handle)) !== false) {
if($xx >= "1") {
$line = str_replace("\n","",$line);
}
$xx++;
//echo $line . "<br />";
//echo $friend . "<br />";
if($friend == $line)
{
// populate both users databases with each other.
$friendcountFriend = file_get_contents("ssb_db/friends/" . $friend . ".count");
$friendcountFriend = $friendcountFriend + 1;
//echo $friendcountFriend;
file_put_contents("ssb_db/friends/" . $friend . ".php", $frienddb . "\n <?php \$friend" . $friendcountFriend ." = \"" . $user . "\";\n\$friend_chat_db" . $friendcountFriend . " = \"" . $user . $friend . "\";?>");
$friendcount = file_get_contents("ssb_db/friends/" . $user . ".count");
$friendcount = $friendcount + 1;
//echo $friendcount;
file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n <?php \$friend" . $friendcount . " = \"" . $friend . "\";\n\$friend_chat_db" . $friendcount . " = \"" . $user . $friend . "\";?>");
file_put_contents("ssb_db/friends/" . $user . ".count", $friendcount);
file_put_contents("ssb_db/friends/" . $friend . ".count", $friendcountFriend);
file_put_contents("ssb_db/friends/" . $user . $friend . ".count", "1");
file_put_contents("ssb_db/friends/" . $user . $friend . ".php", "<?php \$msg1 = \"" . $user . " and " . $friend . " are now friends!<br />\";?>");
}
}
fclose($handle);
} else {
echo "ERROR: Friend: " . $friend . " not found in friend pending database.<br />";
}
}
?>

1603
index.php Executable file

File diff suppressed because it is too large Load Diff

234
minimum.css Normal file
View File

@ -0,0 +1,234 @@
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Mono&display=swap');
html, body {
background-color: #d5d5d5;
color: #e3e3e3;
margin: 0 auto;
font-size: 14px;
font-family: "IBM Plex Mono", sans-serif;
padding-bottom: 40px;
}
.title {
font-size: 46px;
text-align: center;
padding: 8px;
}
#navbar {
margin: 0 auto;
/*width: 100%;*/
/*background-color: #ffffff;*/
top: 1px;
left: 1px;
text-align: center;
padding-bottom: 0px;
}
#navbar a {
text-decoration: none;
font-size: 16px;
text-align: center;
padding-top: 4px;
padding-bottom: 5px;
color: #5577ff;
}
#navbar a:hover {
color: #2266cc;
}
.notifications {
background-color: #bbbbbb;
border-radius: 4px;
border: solid 1px #cccccc;
padding: 4px;
color: #121212;
}
table { padding: 1px; }
tr, td { padding: 2px; }
textarea {
background-color: #bbbbbb;
border-radius: 4px;
border: solid 1px #cccccc;
outline: none;
resize: none;
color: #111111;
width: 98%;
padding: 4px;
}
.dllink {
margin: 0 auto;
width: 100%;
text-align: center;
}
input, button, select, label {
background-color: #dddddd;
border: solid 1px #bbbbbb;
outline: none;
border-radius: 4px;
color: #565656;
padding: 4px;
font-size: 14px;
}
.input-upload {
display: inline-block;
cursor: pointer;
padding: 4px;
}
.button {
background-color: #dddddd;
border: solid 1px #bbbbbb;
outline: none;
border-radius: 4px;
color: #565656;
margin: auto;
padding: 4px;
display: inline-flex;
}
.avatar {
border-radius: 50%;
background: 50% 50% no-repeat; /* 50% 50% centers image in div */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
object-fit: cover;
width: 180px;
height: 180px;
}
.avatar_small {
border-radius: 50%;
background: 50% 50% no-repeat; /* 50% 50% centers image in div */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
object-fit: cover;
width: 48px;
height: 48px;
}
.avatar_chat {
border-radius: 50%;
background: 50% 50% no-repeat; /* 50% 50% centers image in div */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
object-fit: cover;
width: 28px;
height: 28px;
}
#msgbox {
display: block;
margin: 0 auto;
}
.message {
padding: 6px;
border-radius: 5px 11px 11px;
background-color: #2255ff;
border: solid 1px #1865ff;
color: #ffffff;
overflow-wrap: break-word;
max-width: 520px;
}
#msgs {
background-color: #bbbbbb;
border: solid 1px #cccccc;
border-radius: 4px;
padding: 6px;
height: 400px;
width: 578px;
margin: auto;
overflow-y: hidden;
}
.replycontain {
margin: 0 auto;
width: 600px;
}
.attachment {
/*max-height: 250px;*/
display: block;
margin: 0 auto;
padding: 6px;
border-radius: 4px;
border: solid 1px #424242;
background-color: #333333;
}
.attachment img {
max-width: 580px;
margin: 0 auto;
display: block;
max-height: 600px;
}
.attachment_chat {
max-width: 280px;
margin: 0 auto;
display: block;
max-height: 200px;
}
.page-controls {
text-align: center;
}
.post {
background-color: #666666;
border-radius: 4px 10px 10px;
border: solid 1px #545454;
padding: 6px;
color: #dddddd;
}
.reply {
background-color: #666666;
border-radius: 4px 10px 10px;
border: solid 1px #545454;
padding: 6px;
color: #dddddd;
}
a {
color: #5577ff;
font-size: 14px;
text-decoration: none;
}
a:hover {
color: #2266cc;
text-decoration: none;
}
.contain {
background-color: #555555;
border: solid 1px #434343;
width: 690px;
max-width: 690px;
min-width: 690px;
margin: 0 auto;
padding: 5px;
}
.friendslist {
padding: 4px;
width: 100%;
text-align: center;
}
.friendslist tr,td {
padding: 2px;
}
.maincontain {
margin: 0 auto;
width: 702px;
}

1057
minimum.php Normal file

File diff suppressed because it is too large Load Diff

318
style.css Normal file
View File

@ -0,0 +1,318 @@
@import url('https://fonts.googleapis.com/css2?family=Roboto&family=Ubuntu&display=swap');
html, body {
background-color: #d5d5d5;
background-repeat: no-repeat;
background-attachment: fixed;
background-position: center;
background-image: url('data/bg.jpg');
color: #e3e3e3;
margin: 0 auto;
font-size: 18px;
font-family: "Ubuntu", "Roboto", sans-serif;
padding-bottom: 40px;
}
p {
font-size: 18px;
}
h1 {
font-size: 36px;
}
h2 {
font-size: 32px;
}
h3 {
font-size: 26px;
}
h4 {
font-size: 22px;
}
.title {
font-size: 46px;
text-align: center;
padding: 8px;
}
.date {
font-size: 12px;
padding-left: 8px;
color: #808080;
}
#navbar {
margin: 0 auto;
/*width: 100%;*/
/*background-color: #ffffff;*/
top: 1px;
left: 1px;
padding-bottom: 0px;
}
#navcontainer {
width: 702px;
max-width: 702px;
min-width: 702px;
margin: 0 auto;
background-color: #ffffff;
}
#navbar a {
text-decoration: none;
font-family: "Ubuntu", "Roboto", sans-serif;
font-size: 32px;
text-align: center;
padding-top: 4px;
padding-bottom: 5px;
background-color: #ffffff;
color: #5577ff;
width: 125px;
display: inline-block;
}
#navbar a:hover {
background-color: #999999;
color: #323232;
}
.notifications {
background-color: #171717;
border-radius: 4px;
border: solid 1px #222222;
padding: 4px;
}
table { padding: 1px; }
tr, td { padding: 2px; }
textarea {
background-color: #222222;
border-radius: 10px;
border: 1px solid #323232;
font-family: "Roboto Sans", Ubuntu, sans-serif;
outline: none;
resize: none;
color: #d7d7d7;
width: 98%;
padding: 4px;
}
.dllink {
margin: 0 auto;
width: 100%;
text-align: center;
}
input[type="file"] {
display: none;
}
input, button, select, label {
background-color: #222222;
border: solid 1px #323232;
outline: none;
border-radius: 6px;
color: #d7d7d7;
padding: 4px;
font-size: 18px;
}
.input-upload {
display: inline-block;
cursor: pointer;
padding: 4px;
}
.button {
background-color: #222222;
border: solid 1px #323232;
text-align: center;
outline: none;
font-size: 18px;
border-radius: 6px;
color: #d7d7d7;
margin: auto;
padding: 4px;
display: inline-flex;
cursor: pointer;
}
.avatar {
border-radius: 50%;
background: 50% 50% no-repeat; /* 50% 50% centers image in div */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
object-fit: cover;
width: 180px;
height: 180px;
}
.avatar_small {
border-radius: 50%;
background: 50% 50% no-repeat; /* 50% 50% centers image in div */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
object-fit: cover;
width: 56px;
height: 56px;
}
.avatar_chat {
border-radius: 50%;
background: 50% 50% no-repeat; /* 50% 50% centers image in div */
background-position: center;
background-repeat: no-repeat;
background-size: cover;
object-fit: cover;
width: 28px;
height: 28px;
}
#msgbox {
display: block;
margin: 0 auto;
}
.message {
padding: 6px;
border-radius: 5px 11px 11px;
background-color: #2255ff;
border: solid 1px #1865ff;
color: #ffffff;
overflow-wrap: break-word;
max-width: 520px;
}
#msgs {
background: #222222;
border-radius: 5px;
border: solid 1px #323232;
padding: 6px;
height: 400px;
width: 578px;
margin: auto;
font-size: 16px;
overflow-y: scroll;
}
.replycontain {
margin: 0 auto;
width: 600px;
}
.attachment {
/*max-height: 250px;*/
display: block;
margin: 0 auto;
padding: 6px;
border-radius: 5px;
border: solid 1px #424242;
background-color: #333333;
}
.attachment img {
max-width: 580px;
margin: 0 auto;
display: block;
max-height: 600px;
}
.attachment_chat {
max-width: 280px;
margin: 0 auto;
display: block;
max-height: 200px;
}
.page-controls {
text-align: center;
}
.post {
padding: 6px;
border-radius: 5px;
border: solid 1px #424242;
background-color: #333333;
color: #ffffff;
font-size: 16px;
}
.post-footer {
font-size: 16px;
padding-top: 10px;
border-top: solid 1px #424242;
}
.reply {
background-color: #222222;
border-radius: 4px 10px 10px;
border: solid 1px #323232;
padding: 6px;
color: #d7d7d7;
}
.reacts {
position: relative;
display: inline-block;
}
.react-list {
color: #cccccc;
display: none;
font-size: 12px;
position: absolute;
max-width: 160px;
background-color: #222222;
border: solid 1px #434343;
border-radius: 4px;
padding: 5px;
}
.reacts:hover .react-list {
display: block;
}
a {
color: #5577ff;
text-decoration: none;
}
a:hover {
color: #aabbff;
text-decoration: none;
}
.contain {
background-color: #121212;
border: solid 1px #565656;
width: 690px;
max-width: 690px;
min-width: 690px;
margin: 0 auto;
padding: 5px;
}
.friendslist {
padding: 4px;
text-align: center;
}
.friendslist tr,td {
padding-left: 10px;
padding-right: 10px;
}
.friendslist a {
display: inline-block;
text-align: center;
width: 160px;
}
.maincontain {
margin: 0 auto;
width: 702px;
}