commit a26c3de40a7ed288d4f4c4457b74929625b27c35 Author: Pentium44 Date: Tue Nov 3 19:39:41 2020 -0800 Clone from GitHub... continuing devel here diff --git a/README.md b/README.md new file mode 100755 index 0000000..59b475b --- /dev/null +++ b/README.md @@ -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 + + +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 @) +* 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 diff --git a/bbcode.php b/bbcode.php new file mode 100755 index 0000000..b46a742 --- /dev/null +++ b/bbcode.php @@ -0,0 +1,73 @@ +$1", + "$1", + "$1", + "$1", + "$1", + "$2", + "", + "$1", + "$2", + "$2", + ); + + // Do simple BBCode's + $str = preg_replace ($simple_search, $simple_replace, $str); + + // Do
BBCode + $str = bbcode_quote ($str); + + return $str; +} +function bbcode_quote ($str) { + //added div and class for quotes + $open = '
'; + $close = '
'; + + // 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 .= '
'; + } + + // Do replacement + $str = str_replace ('[' . 'quote]', $open, $str); + $str = str_replace ('[/' . 'quote]', $close, $str); + + return $str; +} +?> diff --git a/chatserver.php b/chatserver.php new file mode 100755 index 0000000..7aafe6c --- /dev/null +++ b/chatserver.php @@ -0,0 +1,89 @@ +$nick: $msg\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 = "$nick: $msg"; + $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", "" . $nick . " sent you a message\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'])) { + +}*/ +?> diff --git a/config.php b/config.php new file mode 100755 index 0000000..87f9d6a --- /dev/null +++ b/config.php @@ -0,0 +1,18 @@ + diff --git a/data/bg.jpg b/data/bg.jpg new file mode 100644 index 0000000..4a4cb3f Binary files /dev/null and b/data/bg.jpg differ diff --git a/data/defaultprofile.png b/data/defaultprofile.png new file mode 100644 index 0000000..90b4060 Binary files /dev/null and b/data/defaultprofile.png differ diff --git a/forms.php b/forms.php new file mode 100755 index 0000000..c7ce574 --- /dev/null +++ b/forms.php @@ -0,0 +1,267 @@ + +
+ + +
+
+
+ +
+ Old password:
+ Password:
+ Password Again:
+ +
+
+ +
+
+
+ Choose profile avatar:
+ + +
+
+ + +
+ + +
+ + + + + +
+ + +EOD; + +}*/ + +function registerForm() { +?> +
+ +Italic + + + +
+ +

+ +
+EOD; +} + +function replyForm($id, $puser) { +?> + + + + +
+
+ +
+ + +
+
+ Password:
+ +
+ + +

Request friendship!

+
+ Username:
+ +
+"); + $friendcount = file_get_contents("ssb_db/friends/" . $user . ".count"); + $friendcount = $friendcount + 1; + //echo $friendcount; + file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n "); + 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", "\";?>"); + +} + +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 . "
"; + //echo $friend . "
"; + 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 "); + $friendcount = file_get_contents("ssb_db/friends/" . $user . ".count"); + $friendcount = $friendcount + 1; + //echo $friendcount; + file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n "); + 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", "\";?>"); + } + } + fclose($handle); + } else { + echo "ERROR: Friend: " . $friend . " not found in friend pending database.
"; + } +} +?> diff --git a/functions.php b/functions.php new file mode 100755 index 0000000..a168d40 --- /dev/null +++ b/functions.php @@ -0,0 +1,287 @@ + +
+ + +
+
+
+ +
+ Old password:
+ Password:
+ Password Again:
+ +
+
+ +
+
+
+ Choose profile avatar:
+ + +
+
+ + +
+ + +
+ + + + + +
+ + +EOD; + +}*/ + +function registerForm() { +?> +
+ +Italic + + + +
+ +

+ +
+EOD; +} + +function replyForm($id, $puser) { +?> + + + + +
+
+ +
+ + +
+
+ Password:
+ +
+ + +

Request friendship!

+
+ Username:
+ +
+"); + $friendcount = file_get_contents("ssb_db/friends/" . $user . ".count"); + $friendcount = $friendcount + 1; + //echo $friendcount; + file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n "); + 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", "\";?>"); + +} + +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 . "
"; + //echo $friend . "
"; + 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 "); + $friendcount = file_get_contents("ssb_db/friends/" . $user . ".count"); + $friendcount = $friendcount + 1; + //echo $friendcount; + file_put_contents("ssb_db/friends/" . $user . ".php", $friendlist . "\n "); + 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", "\";?>"); + } + } + fclose($handle); + } else { + echo "ERROR: Friend: " . $friend . " not found in friend pending database.
"; + } +} +?> diff --git a/index.php b/index.php new file mode 100755 index 0000000..078788c --- /dev/null +++ b/index.php @@ -0,0 +1,1603 @@ + + + + +<?php echo htmlentities(stripslashes($ssbtitle)); ?> + +"> + + + +> + + +
+ +
+
+ +"; + echo ""; + + if ($handle) { + while (($line = fgets($handle)) !== false) { + echo ""; + } + fclose($handle); + } else { + echo ""; + } + + echo "
Clear notifications
" . $line . "
No notifications

"; +} + +if(isset($_GET['forms'])) +{ + $forms = $_GET['forms']; + $id = $_GET['pid']; + if($forms=="register") { + registerForm(); + } + else if($forms=="login") { + loginForm(); + } + else if($forms=="friendreq") { + friendReqForm(); + } + else if($forms=="changepass") { + changePassForm(); + } + else if($forms=="deleteacct") { + deleteAcctForm(); + } + else if($forms=="avatarupload") { + uploadAvatarForm(); + } + else if($forms=="post") { + postForm(); + } + else if($forms=="clean") { + cleanForm(); + } + else { + echo "ERROR: Unknown form-name
"; + } +} +else if(isset($_GET['notify'])) +{ + $notify = $_GET['notify']; + if($notify=="1") { echo "Error: User not found"; } + else if($notify=="2") { echo "Error: Incorrect password provided"; } + else if($notify=="3") { echo "Error: Please fill out all the text boxes"; } + else if($notify=="4") { echo "Error: The provided passwords did not match"; } + else if($notify=="5") { echo "Error: Special characters cannot be used in your username"; } + else if($notify=="6") { echo "Error: This username is already in use"; } + else { echo "Error: unknown error... this is quite unusual..."; } +} +else if(isset($_GET['userfeed'])) +{ + $userid = $_GET['userfeed']; + // Make sure we're friends or is my account. + include "ssb_db/users/" . $userid . ".php"; + if ($accttype == "private") { + if (isset($_SESSION['ssb-user']) || isset($_SESSION['ssb-pass'])) { + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + for($x = 1; $x <= $friendcount; $x++) + { + + // If private, and user is following. Allow + if($userid == ${"friend" . $x}) { + echo "
"; + echo "

"; + // DONE + echo "
"; + echo "

User information

"; + echo "Username: " . $userid . "@" . $domain . "
"; + echo "Full name: " . $user_fullname . "
"; + echo "

User posts

"; + echo "
"; + } + } + + // Check if viewing your own profile + if($userid == $username) + { + echo "
"; + // Get user avatar if set + echo "

"; + // DONE + echo "
"; + echo "

User information

"; + echo "Username: " . $userid . "@" . $domain . "
"; + echo "Full name: " . $user_fullname . "
"; + echo "

User posts

"; + echo "
"; + + } + + // Lets generate the users feed now. + foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) { + //echo $postfile; + include $postfile; + for($x = 1; $x <= $friendcount; $x++) + { + if($postowner == ${"friend" . $x}) { + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + + // Footer + echo "

\n"; + } + } + + if($postowner == $username) + { + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + // Footer + echo "

\n"; + } + } + echo ""; + } + } + else + { + echo "

User information

"; + echo "
"; + // Get user avatar if set + if(isset($user_avatar)) { echo "
"; } + // DONE + + echo "
"; + // If not friend, allow to send friend request from right here! + $friend = 0; + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + for($x = 1; $x <= $friendcount; $x++) + { + // If private, and user is following. Allow + if($userid == ${"friend" . $x}) { + $friend = 1; + } + } + + if($friend!=1) { + echo "Send friend request

"; + } + + echo "Username: " . $userid . "@" . $domain . "
"; + echo "Full name: " . $user_fullname; + echo "
"; + + foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) { + include $postfile; + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + // Footer + echo "

\n"; + } + + echo ""; + } +} +else if(isset($_GET['view']) && isset($_GET['user'])) +{ + $puser = $_GET['user']; + $id = $_GET['view']; + $postc = file_get_contents("ssb_db/posts/reply_" . $puser . "_" . $id . ".count"); + include "ssb_db/posts/post_" . $puser . "_" . $id . ".php"; + + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + // Footer + + echo "

\n"; + + for($x = 1; $x <= $postc; $x++) { + $reply_content = ${"reply" . $x}; + $reply_user = ${"reply" . $x . "_user"}; + $reply_date = ${"reply" . $x . "_date"}; + + echo "
"; + echo "

$reply_user $reply_date

"; + echo "
" . bbcode_format($reply_content) . "
"; + echo "
\n"; + } + + echo "
"; + + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { + echo "Login to reply..."; + } else { + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + for($x = 1; $x <= $friendcount; $x++) + { + if($puser == ${"friend" . $x}) { + $z = "1"; + replyForm($id, $puser); + } + } + + // Its you dummy + if($puser == $username) { + $z = "1"; + replyForm($id, $puser); + } + + + if(!isset($z)) + { + echo "Not following! Follow to reply...
"; + } + } +} +else if(isset($_GET['do'])) +{ + $do = $_GET['do']; + if($do=="post") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second. + $titledate = date("m-d-Y h:i:sa"); // time stamp for people to read xD + + if(isset($_FILES["file"]["name"]) && isset($username)) { + + $uploaded = array(); // empty array for upload file names + $uploaded_name = array(); // empty array for upload names + // File selected, upload! + for($i=0; $i 0) + { + echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "
"; + } + else + { + if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i])) + { + echo "Error: " . $_FILES["file"]["name"][$i] . " exists.
"; + } + else + { + $randstring = getRandString("32"); + move_uploaded_file($_FILES["file"]["tmp_name"][$i], + "ssb_db/uploads/" . $randstring . "." . $extension); + array_push($uploaded, $randstring . "." . $extension); + array_push($uploaded_name, pathinfo($_FILES["file"]["name"][$i], PATHINFO_FILENAME)); + echo "Success: " . $_FILES["file"]["name"][$i] . " (" . tomb($_FILES["file"]["size"][$i]) . ") uploaded...
"; + //rename("ssb_db/uploads/" . $FILES["file"]["name"][$i], "ssb_db/uploads/" . $username . "_" . $date . $extension); + } + } + } + else + { + // Check if there was actually an issue + if($_FILES["file"]["size"] == "0") { + echo "Error: " . $_FILES["file"]["name"][$i] . " is too large, or is a invalid filetype"; + } + } + } // end of for loop + + $srchcont = stripslashes(htmlentities($_POST['body'])); + $srchcont .= " "; // doesn't find tag if there's not a fucking whitespace + $checkForUserTag = searchForUserTag($srchcont); + $taggedUser = substr($checkForUserTag, 1, -1); + if(file_exists("ssb_db/users/" . $taggedUser . ".name")) { + if($taggedUser!=$postowner) { + $tagged_notifications = file_get_contents("ssb_db/friends/" . $taggedUser . ".notifications"); + file_put_contents("ssb_db/friends/" . $taggedUser . ".notifications", "$username tagged you in a post\n" . $tagged_notifications); + } + } + + $body = nl2br(htmlentities(stripcslashes($_POST['body']))); + //$username = stripcslashes(htmlentities($username)); + include "ssb_db/users/" . $username . ".php"; + $post_file = "ssb_db/posts/post_" . $username . "_" . $date . ".php"; + $post_attachments = "
"; + $post_string = ""; + + $attachments = array(); + $fileCount = 0; + foreach($uploaded as &$upload) + { + if(file_exists("ssb_db/uploads/" . $upload)) { + $ext = pathinfo("ssb_db/uploads/ . $upload", PATHINFO_EXTENSION); + if($ext == "mp4" || $ext == "MP4") { + array_push($attachments, "
" . $uploaded_name[$fileCount] . "
"); + } + else + { + array_push($attachments, "
"); + } + } + + $fileCount++; // Add it up + } + + foreach($attachments as &$attachvar) + { + $post_attachments .= $attachvar; + } + + $post_string_end = "\";\n?>\n"; + + file_put_contents($post_file, $post_string . $post_attachments . $post_string_end); + file_put_contents("ssb_db/posts/" . $date . ".post", "post_" . $username . "_" . $date . ".php"); + file_put_contents("ssb_db/posts/reply_" . $username . "_" . $date . ".count", "0"); + echo "Post processed... if redirection fails, Click Here
"; + header( "refresh: 1;url=?view=$date&user=$username" ); + } + else + { + echo "ERROR: Missing post data! Select an image to upload or let us know whats up!
"; + } + } + } + + if($do=="avatarupload") + { + if(isset($_FILES["file"]["name"]) && isset($username)) { + $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second. + + for($i=0; $i 0) + { + echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "
"; + } + else + { + if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i])) + { + echo "Error: " . $_FILES["file"]["name"][$i] . " exists.
"; + } + else + { + move_uploaded_file($_FILES["file"]["tmp_name"][$i], + "ssb_db/uploads/" . $username . "_" . $date . "." . $extension); + $oldcontent = file_get_contents("ssb_db/users/" . $username . ".php"); + file_put_contents("ssb_db/users/" . $username . ".php", $oldcontent . "\n"); + echo "Avatar uploaded and set! Redirecting in 3 seconds..."; + header("refresh: 3;url=index.php"); + } + } + } else { + echo "Error: " . $_FILES["file"]["name"][$i] . " is too large, or is a invalid filetype"; + } + } + } + } + + if($do=="users") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + + echo "

Community

"; + foreach(array_reverse(glob("ssb_db/users/"."*.name")) as $userfile) { + $userhandle = file_get_contents($userfile); + include "ssb_db/users/" . $userhandle . ".php"; + if($accttype == "public") { + echo "
"; + echo "$userhandle"; + echo "
"; + } + } + } + } + + if($do=="reply") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + if(!isset($_GET['pid']) or !file_exists("ssb_db/posts/" . $_GET['pid'] . ".post")) { echo "ERROR: Post ID is not set, or invalid"; } else { + if(isset($_POST['reply']) && isset($username) && $_POST['body']!="") + { + $pid = $_GET['pid']; + $post_file_name = file_get_contents("ssb_db/posts/$pid.post"); + include "ssb_db/posts/" . $post_file_name; + $srchcont = stripslashes(htmlentities($_POST['body'])); + $srchcont .= " "; + $checkForUserTag = searchForUserTag($srchcont); + $taggedUser = substr($checkForUserTag, 1, -1); + if(file_exists("ssb_db/users/" . $taggedUser . ".name")) { + if($taggedUser!=$postowner) { + $tagged_notifications = file_get_contents("ssb_db/friends/" . $taggedUser . ".notifications"); + file_put_contents("ssb_db/friends/" . $taggedUser . ".notifications", "$username tagged you in a comment\n" . $tagged_notifications); + } + } + + $replydate = date("m-d-Y h:i:sa"); // time stamp for people to read xD + $body = nl2br(htmlentities(stripcslashes($_POST['body']))); + //$username = stripcslashes(htmlentities($username)); + $old_content = file_get_contents("ssb_db/posts/" . $post_file_name); + $reply_count = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $pid . ".count"); + + $reply_count = $reply_count+1; + + $post_string = "\n"; + file_put_contents("ssb_db/posts/" . $post_file_name, $old_content . $post_string); + file_put_contents("ssb_db/posts/reply_" . $postowner . "_" . $pid . ".count", $reply_count); + + if($username!=$postowner) { + $owner_notifications = file_get_contents("ssb_db/friends/" . $postowner . ".notifications"); + file_put_contents("ssb_db/friends/" . $postowner . ".notifications", "$username replied to your post\n" . $owner_notifications); + } + + echo "If you're seeing this; redirection failed: Click Here
"; + header( "refresh: 1;url=index.php?view=$pid&user=$postowner" ); + } + else + { + echo "ERROR: Missing form data
"; + } + } + } + } + + if($do=="delpost") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + if($user_password === $_SESSION['ssb-pass']) { + if(isset($_GET['user']) && $_GET['user']!="" && isset($_GET['pid']) && $_GET['pid']!="") { + if(file_exists("ssb_db/posts/post_" . stripslashes($_GET['user']) . "_" . stripslashes($_GET['pid']) . ".php") && $username == stripslashes($_GET['user'])) { + $postuser = $_GET['user']; + $pid = $_GET['pid']; + unlink("ssb_db/posts/" . $pid . ".post"); + unlink("ssb_db/posts/post_" . $postuser . "_" . $pid . ".php"); + unlink("ssb_db/posts/reply_" . $postuser . "_" . $pid . ".count"); + echo "Post successfully deleted! redirecting in 3 seconds...
"; + header("refresh: 3;url=index.php"); + exit; + } else { echo "ERROR: post doesn't exist or YOU ARE NOT THE OWNER OF SAID POST... THIS incident has been recorded!"; file_put_contents("ssb_db/log.txt", "Post deletion error: IP <" . $_SERVER['REMOTE_ADDR'] . "> post not found or not users post: post_" . $postuser . "_" . $pid . ".php\n"); } + } else { echo "ERROR: USER and PID variables not set!"; } + } else { echo "ERROR: PASSWORD FOR USER INCORRECT! IP LOGGED!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + if($do=="react") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + if($user_password === $_SESSION['ssb-pass']) { + if(isset($_GET['user']) && $_GET['user']!="" && isset($_GET['pid']) && $_GET['pid']!="") { + if(file_exists("ssb_db/posts/post_" . stripslashes($_GET['user']) . "_" . stripslashes($_GET['pid']) . ".php")) { + $postuser = $_GET['user']; + $pid = $_GET['pid']; + $handle = fopen("ssb_db/posts/$pid.reacted", "r"); + + if ($handle) { + while (($line = fgets($handle)) !== false) { + $line = str_replace(array("\n", "\r"), '', $line); + if($line == $username) { + echo "You've already reacted to this post... redirecting"; + header("refresh: 3;url=index.php?view=$pid&user=$postuser"); + exit; + } + } + fclose($handle); + } else { + echo ""; + } + + if(file_exists("ssb_db/posts/$pid.reacted")) { + $reactedPrev = file_get_contents("ssb_db/posts/$pid.reacted"); + file_put_contents("ssb_db/posts/$pid.reacted", $reactedPrev . $username . "\n"); // You reacted + } else { + file_put_contents("ssb_db/posts/$pid.reacted", $username . "\n"); // First react + } + + if(file_exists("ssb_db/posts/$pid.reactcount")) { + $reactCount = file_get_contents("ssb_db/posts/$pid.reactcount"); + $reactCurrent = $reactCount + 1; + file_put_contents("ssb_db/posts/$pid.reactcount", $reactCurrent); // You reacted + } else { + file_put_contents("ssb_db/posts/$pid.reactcount", "1"); // First react + } + + // Don't send yourself a notification, you know you liked your own post ;) + if($postuser != $username) { + $owner_notifications = file_get_contents("ssb_db/friends/" . $postuser . ".notifications"); + file_put_contents("ssb_db/friends/" . $postuser . ".notifications", "$username loved your post\n" . $owner_notifications); + } + + echo "Reacted! Redirecting in 1 second..."; + header("refresh: 1;url=index.php"); + exit; + } else { echo "ERROR: post doesn't exist..."; } + } else { echo "ERROR: USER and PID variables not set!"; } + } else { echo "ERROR: PASSWORD FOR USER INCORRECT! IP LOGGED!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + if($do=="clrnote") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + if($user_password === $_SESSION['ssb-pass']) { + unlink("ssb_db/friends/" . $username . ".notifications"); + header("Location: index.php"); + exit; + } else { echo "ERROR: PASSWORD FROM COOKIE INCORRECT! IP RECORDED!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + if($do=="clrpending") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + if($user_password === $_SESSION['ssb-pass']) { + unlink("ssb_db/friends/" . $username . ".pending"); + header("Location: index.php?do=friends"); + exit; + } else { echo "ERROR: PASSWORD FROM COOKIE INCORRECT! IP RECORDED!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + // Server admin can just delete ssb_db + /*if($do=="clean") + { + if($_POST['password']!="" && $_POST['password']==$pw) + { + $db_content = glob("ssb_db/" . '*', GLOB_MARK); + foreach($db_content as $file) + { + unlink($file); + } + rmdir("ssb_db"); + echo "Database Cleaned
"; + } + else + { + echo "ERROR: Wrong Password
"; + } + }*/ + + + // grab session values and send friend request functions. + if($do=="sendfr") { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + if(isset($_POST['user']) || isset($_GET['user'])) { + + //check if user exists first lol + if(isset($_POST['user'])) { + $givenUser = htmlentities(stripcslashes($_POST['user'])); + } else { + $givenUser = htmlentities(stripcslashes($_GET['user'])); + } + + //check if user exists first lol + if(file_exists("ssb_db/users/" . $givenUser . ".php")) { + include "ssb_db/users/" . $givenUser . ".php"; + + if($accttype == "private") { + sendFriendRequest($_SESSION['ssb-user'], $givenUser); + echo "Follow request sent to " . $givenUser . " redirecting in 3 seconds"; + header("refresh: 3;url=?do=friends"); + } else if($accttype == "public") { + acceptPublicFriendRequest($username, $givenUser); + header("Location: ?do=friends"); + } else { + echo "ERROR: Issues parsing account type..."; + } + } else { + echo "Error: Provided username does not exist in the database!"; + } + } else { + echo "Error: users not set in GET value..."; + } + } + } + + if($do=="accfr") { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + if(isset($_GET['user']) && isset($_GET['friend'])) { + acceptFriendRequest(stripslashes($_GET['user']), stripslashes($_GET['friend'])); + echo "Accepted friend request from " . htmlentities(stripslashes($_GET['friend'])) . " redirecting in 3 seconds"; + header("refresh: 3;url=?do=friends"); + } else { + echo "Error: users not set in GET & SESSION value..."; + } + } + } + + if($do=="userctrl") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + // Beginning of user control panel + echo "

User control panel

"; + echo "Change password
"; + echo "Upload avatar
"; + } + } + + if($do=="changepass") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + // Beginning password change + // inputs + $oldPassInput = htmlentities(stripslashes($_POST['oldpass'])); + $newPassInput = htmlentities(stripslashes($_POST['password'])); + $passwordAgainInput = htmlentities(stripslashes($_POST['password_again'])); + include "ssb_db/users/" . $username . ".php"; + if(sha1(md5($oldPassInput)) == $user_password) { + if($newPassInput == $passwordAgainInput) { + $oldcontent = file_get_contents("ssb_db/users/" . $username . ".php"); + $passString = "\n"; + file_put_contents("ssb_db/users/" . $username . ".php", $oldcontent . $passString); + echo "Password changed, redirecting in 3 seconds"; + $_SESSION['ssb-user'] = null; + $_SESSION['ssb-pass'] = null; + header("refresh: 3;url=index.php"); + } + } else { echo "ERROR: password incorrect! IP recorded for constant monitoring of possible bots!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + if($do=="pubmsg") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + ?> + +
+
+ "; + $get = file_get_contents($chat_db); + echo $get; + echo "
"; + ?> +
+
+ + + + +
+ + +
+
+ + + +
+ " . $friendNick . ": " . $user_fullname . ""; + + ?> +
+ "; + echo "
"; + ?> +
+
+ + + + +
+ + +
+ + + About"; + echo ""; + echo "

" . $desc; + echo "

"; + echo "$ssbtitle statistics: "; + getUserCount(); + echo "; "; + getPostCount(); + echo "; "; + getUploadFileCount(); + echo "

"; + } + + if($do=="friends") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + + $friendpend = "ssb_db/friends/" . $username . ".pending"; + $handle = fopen($friendpend, "r"); + + echo "

Friend requests

Clear history Send friend request"; + echo "
"; + + if ($handle) { + while (($line = fgets($handle)) !== false) { + echo "Pending friend request from " . $line . "! Accept
"; + } + fclose($handle); + } else { + echo "No pending friend requests
"; + } + + echo "
"; + + // Friends list if you have any. + echo "

Friends list


"; + + $friendc = file_get_contents("ssb_db/friends/" . $username . ".count"); + if($friendc == "0") + { + echo "We're sorry... no friends found on your user account..."; + } + else + { + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + echo ""; + for($x = 1; $x <= $friendcount; $x++) + { + if(isset(${"friend" . $x})) { + echo ""; + } + } + echo "
" . ${"friend" . $x} . "Private message
"; + } + } + } + + if($do=="login") + { + $username = $_POST['username']; + if(file_exists("ssb_db/users/$username.php")) { + include_once("ssb_db/users/$username.php"); + if($user_password==sha1(md5($_POST['password']))) { + $pass = $user_password; + $user = $username; + $color = $user_color; + $_SESSION['ssb-user'] = $user; + $_SESSION['ssb-pass'] = $pass; + $_SESSION['ssb-color'] = $color; + header("Location: index.php"); + } else { + echo "Wrong password!"; + } + } else { + echo "User $username not found!"; + } + } + + if($do=="logout") + { + $_SESSION['ssb-user'] = null; + $_SESSION['ssb-pass'] = null; + header("Location: index.php?forms=login"); + } + + if($do=="register") + { + if($_POST['username']!="" && $_POST['password']!="" && $_POST['password-again']!="" && $_POST['fullname']!="" && isset($_POST['acct'])) { + if($_POST['password']==$_POST['password-again']) { + if(!preg_match('/[^a-z0-9]/i', $_POST['username'])) { + if(!file_exists("ssb_db/users/" . $_POST['username'] . ".php")) { + $colors = array("0000ff", "9900cc", "0080ff", "008000", "ededed"); + $acct = $_POST['acct']; + file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".php", ""); + file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".name", stripslashes(htmlentities($_POST['username']))); + file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".postnumber", "0"); + file_put_contents("ssb_db/friends/" . stripslashes(htmlentities($_POST['username'])) . ".count", "0"); + file_put_contents("ssb_db/friends/" . stripslashes(htmlentities($_POST['username'])) . ".php", "\n"); + header("Location: index.php"); + } else { + header("Location: index.php?notify=6"); + } + } else { + header("Location: index.php?notify=5"); + } + } else { + header("Location: index.php?notify=4"); + } + } else { + header("Location: index.php?notify=3"); + } + header("Location: index.php"); + } +} +else if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) +{ + loginForm(); +} +else +{ + // Watch feed, lets generate pages while we're at it + $pagecall = $_GET['page']; + $postcount = 1; + if(isset($pagecall) && $pagecall!="") + { + if($pagecall == "1") + { + $poststart = $postcount; + } + else + { + $poststart = ($pagecall - 1) * 15; // 15 posts per page + } + } + else + { + $poststart = $postcount; + } + + + + // Lets actually generate some feed now. + foreach(array_reverse(glob("ssb_db/posts/*.post")) as $postfile) { + $postphp = file_get_contents($postfile); + include "ssb_db/posts/$postphp"; + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + + for($x = 1; $x <= $friendcount; $x++) + { + if($postowner == ${"friend" . $x}) { + // Found a post, post count goes up! + $postcount++; + + if($poststart == "1" && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + // Footer + echo "

\n"; + } + + if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + // Footer + echo "

\n"; + } + } + } + + if($postowner == $username) + { + // Found a post, post count goes up! + $postcount++; + + if($poststart == "1" && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + // Footer + echo "

\n"; + } + + if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate   "; + if(file_exists("ssb_db/posts/$postid.reactcount")) { + $reacts = file_get_contents("ssb_db/posts/$postid.reactcount"); + echo "
$reacts
"; + // Pull up users who reacted, and generate dropdown list. + $reactlist = fopen("ssb_db/posts/$postid.reacted", "r"); + if($reactlist) { + while (($reactor = fgets($reactlist)) !== false) { + echo "$reactor"; + } + fclose($reactlist); + } + echo "
"; + } + echo "

"; + echo "" . bbcode_format($postcontent) . ""; + // Footer + echo "

\n"; + } + } + } + + + // Page button generation + echo "
"; + + if($poststart > "1") { + $prevpage = $poststart / 15; + echo "   Prev page"; + } + + echo "   "; + + if($poststart == "1" && $postcount > ($poststart + 15)) { + echo "Next page   "; + } + + if($poststart > "1" && $postcount > ($poststart + 15)) { + $nextpage = ($poststart / 15) + 2; + echo "Next page   "; + } + + echo "
"; +} + +?> + +

+
Powered By SSB
+ + + + diff --git a/minimum.css b/minimum.css new file mode 100644 index 0000000..7b8a7d9 --- /dev/null +++ b/minimum.css @@ -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; +} diff --git a/minimum.php b/minimum.php new file mode 100644 index 0000000..d6592f3 --- /dev/null +++ b/minimum.php @@ -0,0 +1,1057 @@ + + + + +<?php echo htmlentities(stripslashes($ssbtitle)); ?> + +"> + + +> + + +
+ +
+ +"; + echo ""; + + if ($handle) { + while (($line = fgets($handle)) !== false) { + echo ""; + } + fclose($handle); + } else { + echo ""; + } + + echo "
Clear notifications
" . $line . "
No notifications

"; +} + +if(isset($_GET['forms'])) +{ + $forms = $_GET['forms']; + $id = $_GET['pid']; + if($forms=="register") { + registerForm(); + } + else if($forms=="login") { + loginForm(); + } + else if($forms=="friendreq") { + friendReqForm(); + } + else if($forms=="changepass") { + changePassForm(); + } + else if($forms=="deleteacct") { + deleteAcctForm(); + } + else if($forms=="avatarupload") { + uploadAvatarForm(); + } + else if($forms=="post") + { + postForm(); + } + else if($forms=="clean") + { + cleanForm(); + } + else { echo "ERROR: Unknown form-name
"; } +} +else if(isset($_GET['notify'])) +{ + $notify = $_GET['notify']; + if($notify=="1") { echo "Error: User not found"; } + else if($notify=="2") { echo "Error: Incorrect password provided"; } + else if($notify=="3") { echo "Error: Please fill out all the text boxes"; } + else if($notify=="4") { echo "Error: The provided passwords did not match"; } + else if($notify=="5") { echo "Error: Special characters cannot be used in your username"; } + else if($notify=="6") { echo "Error: This username is already in use"; } + else { echo "Error: unknown error... this is quite unusual..."; } +} +else if(isset($_GET['userfeed'])) +{ + $userid = $_GET['userfeed']; + // Make sure we're friends or is my account. + include "ssb_db/users/" . $userid . ".php"; + if ($accttype == "private") { + if (isset($_SESSION['ssb-user']) || isset($_SESSION['ssb-pass'])) { + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + for($x = 1; $x <= $friendcount; $x++) + { + + // If private, and user is following. Allow + if($userid == ${"friend" . $x}) { + echo "
"; + echo "

"; + // DONE + echo "
"; + echo "

User information

"; + echo "Username: " . $userid . "@" . $domain . "
"; + echo "Full name: " . $user_fullname . "
"; + echo "

User posts

"; + echo "
"; + } + } + + // Check if viewing your own profile + if($userid == $username) + { + echo "
"; + // Get user avatar if set + echo "

"; + // DONE + echo "
"; + echo "

User information

"; + echo "Username: " . $userid . "@" . $domain . "
"; + echo "Full name: " . $user_fullname . "
"; + echo "

User posts

"; + echo "
"; + + } + + // Lets generate the users feed now. + foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) { + //echo $postfile; + include $postfile; + for($x = 1; $x <= $friendcount; $x++) + { + if($postowner == ${"friend" . $x}) { + echo "

$postowner$postdate
 reply

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + } + } + + if($postowner == $username) + { + echo "

$postowner$postdate
 replydelete post

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + } + } + echo ""; + } + } + else + { + echo "

User information

"; + echo "
"; + // Get user avatar if set + if(isset($user_avatar)) { echo "
"; } + // DONE + echo "
"; + // If not friend, allow to send friend request from right here! + $friend = 0; + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + for($x = 1; $x <= $friendcount; $x++) + { + // If private, and user is following. Allow + if($userid == ${"friend" . $x}) { + $friend = 1; + } + } + + if($friend!=1) { + echo "Send friend request

"; + } + + echo "Username: " . $userid . "@" . $domain . "
"; + echo "Full name: " . $user_fullname; + echo "
"; + + foreach(array_reverse(glob("ssb_db/posts/post_" . $userid . "_" . "*.php")) as $postfile) { + //echo $postfile; + include $postfile; + echo "

$postowner$postdate
 reply

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + } + } +} +else if(isset($_GET['view']) && isset($_GET['user'])) +{ + $puser = $_GET['user']; + $id = $_GET['view']; + $postc = file_get_contents("ssb_db/posts/reply_" . $puser . "_" . $id . ".count"); + include "ssb_db/posts/post_" . $puser . "_" . $id . ".php"; + + echo "

$postowner$postdate

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + + for($x = 1; $x <= $postc; $x++) { + $reply_content = ${"reply" . $x}; + $reply_user = ${"reply" . $x . "_user"}; + $reply_date = ${"reply" . $x . "_date"}; + + echo "
"; + echo "

$reply_user$reply_date

"; + echo "
" . bbcode_format($reply_content) . "
"; + echo "
\n"; + } + + echo "
"; + + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { + echo "Login to reply..."; + } else { + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + for($x = 1; $x <= $friendcount; $x++) + { + if($puser == ${"friend" . $x}) { + $z = "1"; + replyForm($id, $puser); + } + } + + // Its you dummy + if($puser == $username) { + $z = "1"; + replyForm($id, $puser); + } + + + if(!isset($z)) + { + echo "Not following! Follow to reply...
"; + } + } +} +else if(isset($_GET['do'])) +{ + $do = $_GET['do']; + if($do=="post") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second. + $titledate = date("m-d-Y h:i:sa"); // time stamp for people to read xD + + if(isset($_FILES["file"]["name"]) && isset($username)) { + + $uploaded = array(); // empty array for upload names + // File selected, upload! + for($i=0; $i 0) + { + echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "
"; + } + else + { + if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i])) + { + echo "Error: " . $_FILES["file"]["name"][$i] . " exists.
"; + } + else + { + $randstring = getRandString("32"); + move_uploaded_file($_FILES["file"]["tmp_name"][$i], + "ssb_db/uploads/" . $randstring . "." . $extension); + array_push($uploaded, $randstring . "." . $extension); + echo "Success: " . $_FILES["file"]["name"][$i] . " (" . tomb($_FILES["file"]["size"][$i]) . ") uploaded...
"; + //rename("ssb_db/uploads/" . $FILES["file"]["name"][$i], "ssb_db/uploads/" . $username . "_" . $date . $extension); + } + } + } + else + { + // Check if there was actually an issue + if($_FILES["file"]["size"] == "0") { + echo "Error: " . $_FILES["file"]["name"][$i] . " is too large, or is a invalid filetype"; + } + } + } // end of for loop + + $srchcont = stripslashes(htmlentities($_POST['body'])); + $srchcont .= " "; // doesn't find tag if there's not a fucking whitespace + $checkForUserTag = searchForUserTag($srchcont); + $taggedUser = substr($checkForUserTag, 1, -1); + if(file_exists("ssb_db/users/" . $taggedUser . ".name")) { + if($taggedUser!=$postowner) { + $tagged_notifications = file_get_contents("ssb_db/friends/" . $taggedUser . ".notifications"); + file_put_contents("ssb_db/friends/" . $taggedUser . ".notifications", "$username tagged you in a comment\n" . $tagged_notifications); + } + } + + $body = nl2br(htmlentities(stripcslashes($_POST['body']))); + //$username = stripcslashes(htmlentities($username)); + include "ssb_db/users/" . $username . ".php"; + $post_file = "ssb_db/posts/post_" . $username . "_" . $date . ".php"; + $post_attachments = "
"; + $post_string = ""; + + $attachments = array(); + foreach($uploaded as &$upload) + { + if(file_exists("ssb_db/uploads/" . $upload)) { + array_push($attachments, "
"); + } + } + + foreach($attachments as &$attachvar) + { + $post_attachments .= $attachvar; + } + + $post_string_end = "\";\n?>\n"; + + file_put_contents($post_file, $post_string . $post_attachments . $post_string_end); + file_put_contents("ssb_db/posts/" . $date . ".post", "post_" . $username . "_" . $date . ".php"); + file_put_contents("ssb_db/posts/reply_" . $username . "_" . $date . ".count", "0"); + echo "Post processed... Redirecting in 3 seconds, if redirection fails, Click Here
"; + //header( "refresh: 3; url=?view=$date&user=$username" ); + } + else + { + echo "ERROR: Missing post data! Select an image to upload or let us know whats up!
"; + } + } + } + + if($do=="avatarupload") + { + if(isset($_FILES["file"]["name"]) && isset($username)) { + $date = date("YmdHis"); // timestamp in year, month, date, hour, minute, and second. + + for($i=0; $i 0) + { + echo $_FILES["file"]["name"][$i] . " - Return Code: " . $_FILES["file"]["error"][$i] . "
"; + } + else + { + if(file_exists("ssb_db/uploads/" . $_FILES["file"]["name"][$i])) + { + echo "Error: " . $_FILES["file"]["name"][$i] . " exists.
"; + } + else + { + move_uploaded_file($_FILES["file"]["tmp_name"][$i], + "ssb_db/uploads/" . $username . "_" . $date . "." . $extension); + $oldcontent = file_get_contents("ssb_db/users/" . $username . ".php"); + file_put_contents("ssb_db/users/" . $username . ".php", $oldcontent . "\n"); + echo "Avatar uploaded and set! Redirecting in 3 seconds..."; + header("refresh: 3;url=minimum.php"); + } + } + } else { + echo "Error: " . $_FILES["file"]["name"][$i] . " is too large, or is a invalid filetype"; + } + } + } + } + + if($do=="users") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + + echo "

Community

"; + foreach(array_reverse(glob("ssb_db/users/"."*.name")) as $userfile) { + $userhandle = file_get_contents($userfile); + include "ssb_db/users/" . $userhandle . ".php"; + if($accttype == "public") { + echo "
"; + echo "$userhandle"; + echo "
"; + } + } + } + } + + if($do=="reply") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + if(!isset($_GET['pid']) or !file_exists("ssb_db/posts/" . $_GET['pid'] . ".post")) { echo "ERROR: Post ID is not set, or invalid"; } else { + if(isset($_POST['reply']) && isset($username) && $_POST['body']!="") + { + $pid = $_GET['pid']; + $post_file_name = file_get_contents("ssb_db/posts/$pid.post"); + include "ssb_db/posts/" . $post_file_name; + $srchcont = stripslashes(htmlentities($_POST['body'])); + $srchcont .= " "; + $checkForUserTag = searchForUserTag($srchcont); + $taggedUser = substr($checkForUserTag, 1, -1); + if(file_exists("ssb_db/users/" . $taggedUser . ".name")) { + if($taggedUser!=$postowner) { + $tagged_notifications = file_get_contents("ssb_db/friends/" . $taggedUser . ".notifications"); + file_put_contents("ssb_db/friends/" . $taggedUser . ".notifications", "$username tagged you in a comment\n" . $tagged_notifications); + } + } + + $replydate = date("m-d-Y h:i:sa"); // time stamp for people to read xD + $body = nl2br(htmlentities(stripcslashes($_POST['body']))); + //$username = stripcslashes(htmlentities($username)); + $old_content = file_get_contents("ssb_db/posts/" . $post_file_name); + $reply_count = file_get_contents("ssb_db/posts/reply_" . $postowner . "_" . $pid . ".count"); + + $reply_count = $reply_count+1; + + $post_string = "\n"; + file_put_contents("ssb_db/posts/" . $post_file_name, $old_content . $post_string); + file_put_contents("ssb_db/posts/reply_" . $postowner . "_" . $pid . ".count", $reply_count); + + if($username!=$postowner) { + $owner_notifications = file_get_contents("ssb_db/friends/" . $postowner . ".notifications"); + file_put_contents("ssb_db/friends/" . $postowner . ".notifications", "$username replied to your post\n" . $owner_notifications); + } + + echo "If you're seeing this; redirection failed: Click Here
"; + header( "Location: minimum.php?view=$pid&user=$postowner" ); + } + else + { + echo "ERROR: Missing form data
"; + } + } + } + } + + if($do=="delpost") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + if($user_password === $_SESSION['ssb-pass']) { + if(isset($_GET['user']) && $_GET['user']!="" && isset($_GET['pid']) && $_GET['pid']!="") { + if(file_exists("ssb_db/posts/post_" . stripslashes($_GET['user']) . "_" . stripslashes($_GET['pid']) . ".php") && $username == stripslashes($_GET['user'])) { + $postuser = $_GET['user']; + $pid = $_GET['pid']; + unlink("ssb_db/posts/" . $pid . ".post"); + unlink("ssb_db/posts/post_" . $postuser . "_" . $pid . ".php"); + unlink("ssb_db/posts/reply_" . $postuser . "_" . $pid . ".count"); + echo "Post successfully deleted! redirecting in 3 seconds...
"; + header("refresh: 3;url=minimum.php"); + exit; + } else { echo "ERROR: post doesn't exist or YOU ARE NOT THE OWNER OF SAID POST... THIS incident has been recorded!"; file_put_contents("ssb_db/log.txt", "Post deletion error: IP <" . $_SERVER['REMOTE_ADDR'] . "> post not found or not users post: post_" . $postuser . "_" . $pid . ".php\n"); } + } else { echo "ERROR: USER and PID variables not set!"; } + } else { echo "ERROR: PASSWORD FOR USER INCORRECT! IP LOGGED!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + if($do=="clrnote") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + if($user_password === $_SESSION['ssb-pass']) { + unlink("ssb_db/friends/" . $username . ".notifications"); + header("Location: minimum.php"); + exit; + } else { echo "ERROR: PASSWORD FROM COOKIE INCORRECT! IP RECORDED!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + if($do=="clrpending") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + include "ssb_db/users/" . $username . ".php"; + if($user_password === $_SESSION['ssb-pass']) { + unlink("ssb_db/friends/" . $username . ".pending"); + header("Location: minimum.php?do=friends"); + exit; + } else { echo "ERROR: PASSWORD FROM COOKIE INCORRECT! IP RECORDED!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + // Server admin can just delete ssb_db + /*if($do=="clean") + { + if($_POST['password']!="" && $_POST['password']==$pw) + { + $db_content = glob("ssb_db/" . '*', GLOB_MARK); + foreach($db_content as $file) + { + unlink($file); + } + rmdir("ssb_db"); + echo "Database Cleaned
"; + } + else + { + echo "ERROR: Wrong Password
"; + } + }*/ + + + // grab session values and send friend request functions. + if($do=="sendfr") { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + if(isset($_POST['user']) || isset($_GET['user'])) { + + //check if user exists first lol + if(isset($_POST['user'])) { + $givenUser = htmlentities(stripcslashes($_POST['user'])); + } else { + $givenUser = htmlentities(stripcslashes($_GET['user'])); + } + + //check if user exists first lol + if(file_exists("ssb_db/users/" . $givenUser . ".php")) { + include "ssb_db/users/" . $givenUser . ".php"; + + if($accttype == "private") { + sendFriendRequest($_SESSION['ssb-user'], $givenUser); + echo "Follow request sent to " . $givenUser . " redirecting in 3 seconds"; + header("refresh: 3;url=minimum.php?do=friends"); + } else if($accttype == "public") { + acceptPublicFriendRequest($username, $givenUser); + header("Location: minimum.php?do=friends"); + } else { + echo "ERROR: Issues parsing account type..."; + } + } else { + echo "Error: Provided username does not exist in the database!"; + } + } else { + echo "Error: users not set in GET value..."; + } + } + } + + if($do=="accfr") { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + if(isset($_GET['user']) && isset($_GET['friend'])) { + acceptFriendRequest(stripslashes($_GET['user']), stripslashes($_GET['friend'])); + echo "Accepted friend request from " . htmlentities(stripslashes($_GET['friend'])) . " redirecting in 3 seconds"; + header("refresh: 3;url=minimum.php?do=friends"); + } else { + echo "Error: users not set in GET & SESSION value..."; + } + } + } + + if($do=="userctrl") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + // Beginning of user control panel + echo "

User control panel

"; + echo "Change password
"; + echo "Upload avatar
"; + } + } + + if($do=="changepass") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + // Beginning password change + // inputs + $oldPassInput = htmlentities(stripslashes($_POST['oldpass'])); + $newPassInput = htmlentities(stripslashes($_POST['password'])); + $passwordAgainInput = htmlentities(stripslashes($_POST['password_again'])); + include "ssb_db/users/" . $username . ".php"; + if(sha1(md5($oldPassInput)) == $user_password) { + if($newPassInput == $passwordAgainInput) { + $oldcontent = file_get_contents("ssb_db/users/" . $username . ".php"); + $passString = "\n"; + file_put_contents("ssb_db/users/" . $username . ".php", $oldcontent . $passString); + echo "Password changed, redirecting in 3 seconds"; + $_SESSION['ssb-user'] = null; + $_SESSION['ssb-pass'] = null; + header("refresh: 3;url=minimum.php"); + } + } else { echo "ERROR: password incorrect! IP recorded for constant monitoring of possible bots!"; file_put_contents("ssb_db/log.txt", "PASS MISMATCH: IP <" . $_SERVER['REMOTE_ADDR'] . "> Cookie spoofing detected from remote client!!!\n"); } + } + } + + if($do=="privmsg") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + + //check if friend is set + if(!isset($_GET['friend'])) { echo "ERROR: No username defined!"; exit(1); } else { + // set friend username + $friendNick = htmlentities(stripslashes($_GET['friend'])); + + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + for($x = 1; $x <= $friendcount; $x++) + { + if($friendNick == ${"friend" . $x}) { + ?> + +
+ " . $friendNick . ": " . $user_fullname . ""; + + ?> +
+ "; + echo "
"; + ?> +
+
+ + + + +
+ + +
+ + + About"; + echo ""; + echo $desc; + echo "

"; + echo "$ssbtitle statistics: "; + getUserCount(); + echo "; "; + getPostCount(); + echo "; "; + getUploadFileCount(); + } + + if($do=="friends") + { + if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) { loginForm(); } else { + + $friendpend = "ssb_db/friends/" . $username . ".pending"; + $handle = fopen($friendpend, "r"); + + echo "

Friend requests

Clear history Send friend request"; + echo "
"; + + if ($handle) { + while (($line = fgets($handle)) !== false) { + echo "Pending friend request from " . $line . "! Accept
"; + } + fclose($handle); + } else { + echo "No pending friend requests
"; + } + + echo "
"; + + // Friends list if you have any. + echo "

Friends list


"; + + $friendc = file_get_contents("ssb_db/friends/" . $username . ".count"); + if($friendc == "0") + { + echo "We're sorry... no friends found on your user account..."; + } + else + { + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + echo ""; + for($x = 1; $x <= $friendcount; $x++) + { + if(isset(${"friend" . $x})) { + echo ""; + } + } + echo "
" . ${"friend" . $x} . "View user profilePrivate message
"; + } + } + } + + if($do=="login") + { + $username = $_POST['username']; + if(file_exists("ssb_db/users/$username.php")) { + include_once("ssb_db/users/$username.php"); + if($user_password==sha1(md5($_POST['password']))) { + $pass = $user_password; + $user = $username; + $color = $user_color; + $_SESSION['ssb-user'] = $user; + $_SESSION['ssb-pass'] = $pass; + $_SESSION['ssb-color'] = $color; + header("Location: minimum.php"); + } else { + echo "Wrong password!"; + } + } else { + echo "User $username not found!"; + } + } + + // Push user avatar to specific avatar image location + if($do=="avatarlocation") + { + if(isset($_GET['user'])) { + $user = htmlentities(stripslashes($_GET['user'])); + include "ssb_db/users/" . $user . ".php"; + if(file_exists("ssb_db/uploads/" . $user_avatar)) { + echo "Direct to: ssb_db/uploads/" . $user_avatar; + header("Location: ssb_db/uploads/" . $user_avatar . ""); + exit; + } else { + echo "Direct to: data/defaultprofile.png"; + header("Location: data/defaultprofile.png"); + exit; + } + } else { + echo "User is NOT set!"; + } + } + + if($do=="logout") + { + $_SESSION['ssb-user'] = null; + $_SESSION['ssb-pass'] = null; + header("Location: minimum.php?forms=login"); + } + + if($do=="register") + { + if($_POST['username']!="" && $_POST['password']!="" && $_POST['password-again']!="" && $_POST['fullname']!="" && isset($_POST['acct'])) { + if($_POST['password']==$_POST['password-again']) { + if(!preg_match('/[^a-z0-9]/i', $_POST['username'])) { + if(!file_exists("ssb_db/users/" . $_POST['username'] . ".php")) { + $colors = array("0000ff", "9900cc", "0080ff", "008000", "ededed"); + $acct = $_POST['acct']; + file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".php", ""); + file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".name", stripslashes(htmlentities($_POST['username']))); + file_put_contents("ssb_db/users/" . stripslashes(htmlentities($_POST['username'])) . ".postnumber", "0"); + file_put_contents("ssb_db/friends/" . stripslashes(htmlentities($_POST['username'])) . ".count", "0"); + file_put_contents("ssb_db/friends/" . stripslashes(htmlentities($_POST['username'])) . ".php", "\n"); + header("Location: minimum.php"); + } else { + header("Location: minimum.php?notify=6"); + } + } else { + header("Location: minimum.php?notify=5"); + } + } else { + header("Location: minimum.php?notify=4"); + } + } else { + header("Location: minimum.php?notify=3"); + } + header("Location: minimum.php"); + } +} +else if (!isset($_SESSION['ssb-user']) || !isset($_SESSION['ssb-pass'])) +{ + loginForm(); +} +else +{ + // Watch feed, lets generate pages while we're at it + $pagecall = $_GET['page']; + $postcount = 1; + if(isset($pagecall) && $pagecall!="") + { + if($pagecall == "1") + { + $poststart = $postcount; + } + else + { + $poststart = ($pagecall - 1) * 15; // 15 posts per page + } + } + else + { + $poststart = $postcount; + } + + + + // Lets actually generate some feed now. + foreach(array_reverse(glob("ssb_db/posts/*.post")) as $postfile) { + $postphp = file_get_contents($postfile); + include "ssb_db/posts/$postphp"; + $friendcount = file_get_contents("ssb_db/friends/" . $username . ".count"); + include "ssb_db/friends/" . $username . ".php"; + + for($x = 1; $x <= $friendcount; $x++) + { + if($postowner == ${"friend" . $x}) { + // Found a post, post count goes up! + $postcount++; + + if($poststart == "1" && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate
reply

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + } + + if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate
reply

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + } + } + } + + if($postowner == $username) + { + // Found a post, post count goes up! + $postcount++; + + if($poststart == "1" && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate
replydelete post

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + } + + if($poststart > "1" && $postcount > $poststart && $postcount < ($poststart + 15)) { + echo "

$postowner$postdate
replydelete post

"; + echo "" . bbcode_format($postcontent) . ""; + echo "

\n"; + } + } + } + + + // Page button generation + echo "
"; + + if($poststart > "1") { + $prevpage = $poststart / 15; + echo "Prev page"; + } + + if($poststart == "1" && $postcount > ($poststart + 15)) { + echo "Next page"; + } + + if($poststart > "1" && $postcount > ($poststart + 15)) { + $nextpage = ($poststart / 15) + 2; + echo "• Next page"; + } + + echo "
"; +} + +?> + +

+
Powered By SSB
+ + + diff --git a/style.css b/style.css new file mode 100644 index 0000000..c5eaa63 --- /dev/null +++ b/style.css @@ -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; +}